Skip to content

feat: tron v2 - #56

Merged
hmalik88 merged 45 commits into
mainfrom
hm/tron-v2
Aug 3, 2026
Merged

feat: tron v2#56
hmalik88 merged 45 commits into
mainfrom
hm/tron-v2

Conversation

@hmalik88

@hmalik88 hmalik88 commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

Explanation

Migrates the Tron wallet snap from the v1 Keyring interface to the v2 KeyringSnapRpc interface, matching the pattern already established in the Solana snap.

Changes:

  • Dependencies: Bumped keyring-api to ^23.7.0, keyring-snap-sdk to ^9.2.1, snaps-cli to ^8.4.1, and superstruct to ^3.4.1 to get v2 support and the sensitive() utility.

  • TypeScript config: Switched moduleResolution to bundler (and module to preserve) to support /v2 subpath imports like @metamask/keyring-api/v2 and @metamask/keyring-snap-sdk/v2.

  • Interface: KeyringHandler now implements KeyringSnapRpc instead of Keyring. Method renames: listAccountsgetAccounts, listAccountAssetsgetAccountAssets, listAccountTransactionsgetAccountTransactions. getAccount now throws instead of returning undefined. Removed v1-only stubs (filterAccountChains, updateAccount). The handle method now routes through handleKeyringRequest from keyring-snap-sdk/v2.

  • exportAccount: New method that derives the Tron keypair and returns the private key in hexadecimal format. Uses sensitive() from @metamask/superstruct to wrap the validation struct so any assertion failure redacts the key value from error messages and logs.

  • Permissions: Added all v2 KeyringSnapRpcMethod strings alongside the existing v1 KeyringRpcMethod strings (kept for backwards compatibility with callers on older versions). Added ExportAccount to MetaMask permissions.

  • Manifest: Added capabilities block to endowment:keyring declaring the tron:728126428 scope, hexadecimal private key export support, and BIP-44 derivation strategies.

References

PR to introduce new e2e around the new keyring_exportAccount method (cannot be merged yet since this requires all our Snaps to support this method AND to be released):

Checklist

  • I've updated the test suite for new or updated code as appropriate
  • I've updated documentation (JSDoc, Markdown, etc.) for new or updated code as appropriate
  • I've communicated my changes to consumers by updating changelogs for packages I've changed
  • I've introduced breaking changes in this PR and have prepared draft pull requests for clients and consumer packages to resolve them

@socket-security

socket-security Bot commented Jul 28, 2026

Copy link
Copy Markdown

No dependency changes detected. Learn more about Socket for GitHub.

👍 No dependency changes detected in pull request

@github-actions

Copy link
Copy Markdown
Contributor

Preview builds have been published. Learn how to use preview builds in other projects.

Expand for full list of packages and versions.
@metamask-previews/bitcoin-wallet-snap@1.15.2-preview-e04998fd
@metamask-previews/tron-wallet-snap@1.33.2-preview-e04998fd

Comment thread packages/tron-wallet-snap/src/handlers/keyring/keyring.test.ts
Comment thread packages/tron-wallet-snap/src/handlers/keyring.ts Outdated
Comment thread packages/tron-wallet-snap/src/permissions.ts Outdated
@hmalik88

hmalik88 commented Aug 3, 2026

Copy link
Copy Markdown
Contributor Author

@metamaskbot publish-preview

1 similar comment
@hmalik88

hmalik88 commented Aug 3, 2026

Copy link
Copy Markdown
Contributor Author

@metamaskbot publish-preview

@hmalik88

hmalik88 commented Aug 3, 2026

Copy link
Copy Markdown
Contributor Author

Note: There is an extension PR open that adds e2e tests that ensure the risky method exportAccount is not callable by daps: MetaMask/metamask-extension#45149

ccharly
ccharly previously approved these changes Aug 3, 2026

@ccharly ccharly left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(CI is failing, but code-wise that LGTM)

ccharly
ccharly previously approved these changes Aug 3, 2026
@hmalik88
hmalik88 added this pull request to the merge queue Aug 3, 2026
Merged via the queue into main with commit 27aa57b Aug 3, 2026
46 checks passed
@hmalik88
hmalik88 deleted the hm/tron-v2 branch August 3, 2026 16:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants