Repository navigation
Add v2 import_private_key example - #141
Merged
Merged
Conversation
Migrate the private_keys/import_private_key example from v1 (v0.17.0) to the v2 SDK. - Use the v2 client API (NewAPIKeyStamper / NewClient) and flat request structs in place of the v1 pointer-heavy models. - Replace manual hex/base58 decoding and enclave-encrypt setup with crypto.EncryptPrivateKeyToBundle. - Read config from environment variables, consistent with the other v2 examples. - Support both Secp256k1 (Ethereum, hex) and Ed25519 (Solana, base58) keys. Add a private_keys README and list the example in examples/README.md. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Extract key selection and address printing into selectKey and printAddresses helpers so main's cyclomatic complexity is under the gocyclo threshold (was 13, limit 10). Behavior is unchanged. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary & Motivation
Migrate the
private_keys/import_private_keyexample from v1 (v0.17.0) to the v2 SDK.NewAPIKeyStamper/NewClient) and flat request structs in place of the v1 pointer-heavy modelscrypto.EncryptPrivateKeyToBundleAlso adds a
private_keysREADME and lists the example inexamples/README.mdHow I Tested These Changes
Ran the example end-to-end against a live org, importing a private key exported from MetaMask. Confirmed it returns a private key ID and that the derived address matches the source account. Also verified the duplicate-import path surfaces a clean
409error.Did you add a changeset?
No changeset required — this only adds an example and does not change SDK behavior.