fix: add dynamic nft and erc20 check#506
Merged
montelaidev merged 9 commits intomainfrom Apr 10, 2026
Merged
Conversation
Contributor
Author
|
@metamaskbot publish-preview |
|
Preview builds have been published. See these instructions (from the Expand for full list of packages and versions. |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 1fa71bd. Configure here.
ccharly
reviewed
Apr 10, 2026
Co-authored-by: Charly Chevalier <charlyy.chevalier@gmail.com>
Similar implementation than `KeyringClient` but using the new unified keyring API (keyring v2) methods. <!-- CURSOR_SUMMARY --> --- > [!NOTE] > **Medium Risk** > Introduces a parallel v2 JSON-RPC surface (including `exportAccount`) across API, clients, and snap dispatch logic; mistakes could break RPC compatibility or unintentionally affect account export/request routing. > > **Overview** > **Adds keyring v2 RPC support end-to-end.** `@metamask/keyring-api` now exports `KeyringRpcV2Method` plus superstruct-validated v2 request/response types and `isKeyringRpcV2Method`, and refines `isKeyringRpcMethod` to be a type predicate. > > **Introduces v2 client and dispatcher.** `@metamask/keyring-snap-client` adds `KeyringClientV2` (UUID ids, strict response masking) and `@metamask/keyring-internal-snap-client` adds `KeyringInternalSnapClientV2` (Messenger-backed). `@metamask/keyring-snap-sdk` adds `handleKeyringRequestV2` to validate and route v2 JSON-RPC calls, including guarding optional `exportAccount`. Tests and package exports/changelogs are updated accordingly. > > <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit cc83c17. Bugbot is set up for automated code reviews on this repo. Configure [here](https://www.cursor.com/dashboard/bugbot).</sup> <!-- /CURSOR_SUMMARY --> --------- Co-authored-by: Mathieu Artu <mathieu.artu@gmail.com>
This is the release candidate for version 99.0.0. See the changelogs for more details. <!-- CURSOR_SUMMARY --> --- > [!NOTE] > **Medium Risk** > Primarily a release/version bump, but it upgrades `@metamask/keyring-sdk` to `1.2.0` across multiple keyrings, which may change generated account IDs (now deterministic for EVM addresses) for downstream consumers. > > **Overview** > **Release 99.0.0**: bumps the monorepo version and publishes patch releases for several keyring packages (HD, Ledger Bridge, Trezor, Simple), updating their changelogs accordingly. > > Updates keyring dependencies to `@metamask/keyring-sdk@^1.2.0` (and bumps `@metamask/eth-hd-keyring` in `@metamask/eth-money-keyring`), with `yarn.lock` refreshed to match. > > <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit 2a58933. Bugbot is set up for automated code reviews on this repo. Configure [here](https://www.cursor.com/dashboard/bugbot).</sup> <!-- /CURSOR_SUMMARY -->
gantunesr
approved these changes
Apr 10, 2026
Merged
github-merge-queue Bot
pushed a commit
that referenced
this pull request
Apr 13, 2026
<!-- Thanks for your contribution! Take a moment to answer these questions so that reviewers have the information they need to properly understand your changes: * What is the current state of things and why does it need to change? * What is the solution your changes offer and how does it work? Are there any issues or other links reviewers should consult to understand this pull request better? For instance: * Fixes #12345 * See: #67890 --> This PR releases a new minor verson for `@metamask/eth-ledger-bridge-keyring` ### Added - Add `getTransactionSelector` to read the 4-byte calldata selector from serialized transaction hex (legacy and typed txs) ([#506](#506)) - Ledger mobile bridge passes `nft: true` to `clearSignTransaction` when that selector is NFT-only (ERC-721 / ERC-1155). - Add `ERC20_WRITE_SELECTORS` for the three EIP-20 write functions (`transfer`, `transferFrom`, `approve`) ([#506](#506)) ## Examples <!-- Are there any examples of this change being used in another repository? When considering changes to the MetaMask module template, it's strongly preferred that the change be experimented with in another repository first. This gives reviewers a better sense of how the change works, making it less likely the change will need to be reverted or adjusted later. --> <!-- CURSOR_SUMMARY --> --- > [!NOTE] > **Low Risk** > Low risk: this PR only updates package versions and publishes changelog entries/compare links; no runtime code changes are included in the diff. > > **Overview** > Bumps the monorepo version to `100.0.0` and releases `@metamask/eth-ledger-bridge-keyring` as `11.4.0`. > > Updates `keyring-eth-ledger-bridge`’s `CHANGELOG.md` with the `11.4.0` release notes and adjusts the *Unreleased* compare links accordingly. > > <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit 408cee7. Bugbot is set up for automated code reviews on this repo. Configure [here](https://www.cursor.com/dashboard/bugbot).</sup> <!-- /CURSOR_SUMMARY -->
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.

This PR replaces hardcoded erc20: true / nft: true flags in the Ledger mobile bridge's clearSignTransaction call with dynamic detection based on the transaction's 4-byte calldata selector. A new
getTransactionSelectorutility parses serialized transaction hex (both legacy RLP and EIP-2718 typed transactions) to extract the selector, which is then checked againstNFT_ONLY_SELECTORS(ERC-721/ERC-1155) andERC20_WRITE_SELECTORS(EIP-20 transfer, transferFrom, approve) constant sets to set the appropriate flags.calldata selector and sets these flags only when the transaction matches the corresponding contract standard.
Note
Medium Risk
Changes how Ledger mobile transaction signing sets
erc20/nftclear-signing flags based on parsed calldata selectors, which can affect which Ledger signing flows are enabled. Includes new selector parsing and updated dependencies/tests, but is scoped and well-covered.Overview
Derives Ledger mobile
clearSignTransactionoptions dynamically by parsing the serialized transaction to extract the 4-byte calldata selector and enablingerc20/nftclear-signing only when it matches known ERC-20 write selectors or NFT-only selectors.Adds
getTransactionSelectorplus exported selector sets (NFT_ONLY_SELECTORS,ERC20_WRITE_SELECTORS) with new unit coverage, updates the mobile bridge tests to assert the new behavior, and bumpsethereum-cryptography(and lockfile) to^2.2.1.Reviewed by Cursor Bugbot for commit 51e56bb. Bugbot is set up for automated code reviews on this repo. Configure here.