Skip to content

feat(bridge-status-controller): pass swap asset ids to Tron, Solana, and Bitcoin snap requests - #10775

Merged
Battambang merged 24 commits into
mainfrom
feat/tron-flow-classification-analytics
Oct 13, 2026
Merged

Battambang merged 24 commits into
mainfrom
feat/tron-flow-classification-analytics

Conversation

@Battambang

@Battambang Battambang commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor

Explanation

Current state

getClientRequest builds the signAndSendTransaction options per non-EVM chain. Before this PR it forwarded the swap/bridge sourceAssetId/destAssetId only for Stellar. Tron, Solana, and Bitcoin therefore could not see the swap asset ids, so their snaps could not tell a same-chain swap from a cross-chain bridge and reported unknown (Tron) or a balance-derived send (Solana, Bitcoin) for those transactions.

Solution

Forward sourceAssetId and destAssetId for Tron, Solana, and Bitcoin, mirroring the existing Stellar behavior.

  • For Stellar, Solana, and Bitcoin, the options contain only the two asset ids.
  • Tron additionally keeps its visible flag and contract type in the same options object.
  • The asset-id condition uses the chain-id guards (isStellarChainId, isSolanaChainId, isBitcoinChainId) rather than trade-shape guards, since getClientRequest already receives srcChainId and a Stellar trade can also be a plain base64 string.

Each snap then compares the CAIP-2 chains of the two asset ids to classify the transaction as a same-chain swap or a cross-chain bridgeSend.

Non-obvious points

  • The asset ids describe the swap or bridge transaction, not the token approval that can precede it. handleNonEvmTx now takes an isApproval flag and only attaches the asset ids to the main trade. Without this, the approval request would inherit the swap asset ids, and the Tron snap (which gives the asset ids precedence over the contract type) would classify an approve as swap/bridgeSend instead of tokenApprove.
  • The fields are added conditionally, so a request without asset ids is unchanged.
  • The Tron branch still uses isTronTrade because it needs to read visible and the contract type off the trade object.
  • This change is additive for the snaps: Tron validates the new options explicitly, while Solana and Bitcoin use permissive option schemas that ignore unknown keys. Releasing the corresponding snap changes first is still preferable so classification starts as soon as this lands.
  • The Solana swap test fixture previously set destChainId to Solana but gave the destination asset an eip155 CAIP id. Now that the asset ids are forwarded, that mismatch would classify the same-chain swap as a bridgeSend, so the fixture was corrected to use a Solana asset id.

References

  • Depends on the snap changes that classify swap/bridge from the asset ids: MetaMask/internal-snaps (Tron, Solana, Bitcoin).
  • Related to the Non-EVM flow analytics work for Tron, Solana, Bitcoin, and Stellar.

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

Note

Medium Risk
Changes non-EVM transaction submission payloads that snaps use for tx classification; incorrect approval vs main-trade handling could mislabel user-facing flows, though behavior is additive when asset ids are omitted.

Overview
Non-EVM snap signAndSendTransaction requests now include sourceAssetId and destAssetId in options for Solana, Bitcoin, and Tron (in addition to Stellar), so snaps can distinguish same-chain swaps from cross-chain bridges. Tron still merges visible and contract type into the same options object.

handleNonEvmTx gains an isApproval flag (wired from the non-EVM strategy for approval txs) so swap/bridge asset ids are not sent on token approvals—avoiding misclassification when Tron would otherwise treat an approve as swap/bridge.

Tests and snapshots were updated for correct CAIP asset ids (e.g. Solana native/USDC, Tron TRC20) and to assert asset ids on main trades but not approvals.

Reviewed by Cursor Bugbot for commit ec899ef. Bugbot is set up for automated code reviews on this repo. Configure here.

@Battambang
Battambang force-pushed the feat/tron-flow-classification-analytics branch 2 times, most recently from cd64d52 to 1d9e239 Compare October 9, 2026 14:49
@Battambang
Battambang requested a lite review from Copilot October 9, 2026 14:56

Copilot AI 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.

🟡 Changes recommended

Add missing no-ID coverage, correct the bridge snapshot fixture, and update the stale validation comment.

2 open findings
What changed in this PR

Updates Tron Snap transaction requests with asset IDs so swaps and bridges are classified correctly.

Changes:

  • Adds conditional source and destination asset IDs for Tron.
  • Updates tests and snapshots.
  • Updates the changelog and lint suppressions.
File Description
packages/​bridge-status-controller/​src/​utils/​transaction.test.ts Tests Tron asset-ID propagation.
packages/​bridge-status-controller/​src/​utils/​snaps.ts Adds asset IDs to Tron request options.
packages/​bridge-status-controller/​src/​__snapshots__/​bridge-status-controller.test.ts.snap Updates request snapshots.
packages/​bridge-status-controller/​CHANGELOG.md Documents the behavior change.
oxlint-suppressions.json Updates lint suppression count.

🧠 Review effort: Lite


💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread packages/bridge-status-controller/src/utils/snaps.ts Outdated
Comment thread packages/bridge-status-controller/src/utils/snaps.ts Outdated
@Battambang

Copy link
Copy Markdown
Contributor Author

@metamaskbot publish-preview

@github-actions

github-actions Bot commented Oct 9, 2026

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/account-tree-controller@11.0.1-preview-1d9e239b6
@metamask-previews/accounts-controller@40.0.0-preview-1d9e239b6
@metamask-previews/address-book-controller@8.0.0-preview-1d9e239b6
@metamask-previews/advanced-chart-core@1.0.0-preview-1d9e239b6
@metamask-previews/ai-controllers@2.0.0-preview-1d9e239b6
@metamask-previews/analytics-controller@4.0.0-preview-1d9e239b6
@metamask-previews/analytics-data-regulation-controller@0.0.0-preview-1d9e239b6
@metamask-previews/announcement-controller@9.0.0-preview-1d9e239b6
@metamask-previews/app-metadata-controller@3.0.0-preview-1d9e239b6
@metamask-previews/approval-controller@10.0.0-preview-1d9e239b6
@metamask-previews/assets-controller@18.0.1-preview-1d9e239b6
@metamask-previews/assets-controllers@112.1.2-preview-1d9e239b6
@metamask-previews/authenticated-user-storage@4.1.0-preview-1d9e239b6
@metamask-previews/base-controller@10.0.0-preview-1d9e239b6
@metamask-previews/base-data-service@2.1.0-preview-1d9e239b6
@metamask-previews/bitcoin-regtest-up@2.0.0-preview-1d9e239b6
@metamask-previews/bridge-controller@82.0.2-preview-1d9e239b6
@metamask-previews/bridge-status-controller@76.3.5-preview-1d9e239b6
@metamask-previews/build-utils@4.0.0-preview-1d9e239b6
@metamask-previews/chain-agnostic-permission@2.0.0-preview-1d9e239b6
@metamask-previews/chomp-api-service@6.0.1-preview-1d9e239b6
@metamask-previews/claims-controller@1.0.3-preview-1d9e239b6
@metamask-previews/client-controller@2.0.0-preview-1d9e239b6
@metamask-previews/client-utils@3.0.4-preview-1d9e239b6
@metamask-previews/compliance-controller@3.0.0-preview-1d9e239b6
@metamask-previews/composable-controller@13.0.0-preview-1d9e239b6
@metamask-previews/config-registry-controller@5.0.0-preview-1d9e239b6
@metamask-previews/connectivity-controller@1.0.0-preview-1d9e239b6
@metamask-previews/controller-utils@13.0.0-preview-1d9e239b6
@metamask-previews/core-backend@12.0.1-preview-1d9e239b6
@metamask-previews/cryptography@1.1.2-preview-1d9e239b6
@metamask-previews/delegation-controller@4.0.0-preview-1d9e239b6
@metamask-previews/earn-controller@13.0.2-preview-1d9e239b6
@metamask-previews/eip-5792-middleware@4.0.1-preview-1d9e239b6
@metamask-previews/eip-7702-internal-rpc-middleware@1.0.0-preview-1d9e239b6
@metamask-previews/eip1193-permission-middleware@3.0.0-preview-1d9e239b6
@metamask-previews/eth-block-tracker@16.0.0-preview-1d9e239b6
@metamask-previews/eth-json-rpc-middleware@25.0.0-preview-1d9e239b6
@metamask-previews/eth-json-rpc-provider@7.0.0-preview-1d9e239b6
@metamask-previews/foundryup@2.0.0-preview-1d9e239b6
@metamask-previews/gas-fee-controller@27.0.0-preview-1d9e239b6
@metamask-previews/gator-permissions-controller@6.0.1-preview-1d9e239b6
@metamask-previews/geolocation-controller@2.0.0-preview-1d9e239b6
@metamask-previews/java-tron-up@2.0.0-preview-1d9e239b6
@metamask-previews/json-rpc-engine@11.0.0-preview-1d9e239b6
@metamask-previews/json-rpc-middleware-stream@9.0.0-preview-1d9e239b6
@metamask-previews/keyring-controller@28.1.0-preview-1d9e239b6
@metamask-previews/kyc-controller@0.7.0-preview-1d9e239b6
@metamask-previews/local-node-utils@2.0.0-preview-1d9e239b6
@metamask-previews/logging-controller@10.0.0-preview-1d9e239b6
@metamask-previews/message-manager@15.0.0-preview-1d9e239b6
@metamask-previews/messenger@3.0.0-preview-1d9e239b6
@metamask-previews/messenger-cli@1.0.0-preview-1d9e239b6
@metamask-previews/money-account-api-data-service@2.1.0-preview-1d9e239b6
@metamask-previews/money-account-balance-service@3.1.2-preview-1d9e239b6
@metamask-previews/money-account-controller@2.0.0-preview-1d9e239b6
@metamask-previews/money-account-upgrade-controller@5.1.0-preview-1d9e239b6
@metamask-previews/money-account-utils@2.1.0-preview-1d9e239b6
@metamask-previews/multichain-account-service@14.1.0-preview-1d9e239b6
@metamask-previews/multichain-api-middleware@5.0.0-preview-1d9e239b6
@metamask-previews/multichain-network-controller@4.0.0-preview-1d9e239b6
@metamask-previews/multichain-transactions-controller@8.0.0-preview-1d9e239b6
@metamask-previews/name-controller@10.0.0-preview-1d9e239b6
@metamask-previews/network-connection-banner-controller@1.0.0-preview-1d9e239b6
@metamask-previews/network-controller@37.0.1-preview-1d9e239b6
@metamask-previews/network-enablement-controller@7.0.2-preview-1d9e239b6
@metamask-previews/notification-services-controller@29.0.3-preview-1d9e239b6
@metamask-previews/passkey-controller@4.1.0-preview-1d9e239b6
@metamask-previews/permission-controller@14.0.0-preview-1d9e239b6
@metamask-previews/permission-log-controller@6.0.0-preview-1d9e239b6
@metamask-previews/perps-controller@20.0.0-preview-1d9e239b6
@metamask-previews/phishing-controller@18.2.0-preview-1d9e239b6
@metamask-previews/platform-api-docs@0.2.1-preview-1d9e239b6
@metamask-previews/polling-controller@17.0.0-preview-1d9e239b6
@metamask-previews/preferences-controller@24.0.0-preview-1d9e239b6
@metamask-previews/profile-controller@1.0.1-preview-1d9e239b6
@metamask-previews/profile-metrics-controller@5.1.3-preview-1d9e239b6
@metamask-previews/profile-sync-controller@34.0.3-preview-1d9e239b6
@metamask-previews/ramps-controller@27.0.1-preview-1d9e239b6
@metamask-previews/rate-limit-controller@8.0.0-preview-1d9e239b6
@metamask-previews/react-data-query@2.0.0-preview-1d9e239b6
@metamask-previews/remote-feature-flag-controller@7.0.0-preview-1d9e239b6
@metamask-previews/sample-controllers@6.0.0-preview-1d9e239b6
@metamask-previews/seedless-onboarding-controller@12.0.0-preview-1d9e239b6
@metamask-previews/selected-network-controller@27.0.0-preview-1d9e239b6
@metamask-previews/sentinel-api-service@2.1.0-preview-1d9e239b6
@metamask-previews/shield-controller@7.0.4-preview-1d9e239b6
@metamask-previews/signature-controller@40.0.0-preview-1d9e239b6
@metamask-previews/smart-transactions-controller@27.1.0-preview-1d9e239b6
@metamask-previews/snap-account-service@4.0.0-preview-1d9e239b6
@metamask-previews/social-controllers@3.6.0-preview-1d9e239b6
@metamask-previews/solana-test-validator-up@2.0.0-preview-1d9e239b6
@metamask-previews/stellar-quickstart-up@0.0.0-preview-1d9e239b6
@metamask-previews/storage-service@2.0.0-preview-1d9e239b6
@metamask-previews/subscription-controller@13.0.0-preview-1d9e239b6
@metamask-previews/transaction-controller@72.2.0-preview-1d9e239b6
@metamask-previews/transaction-pay-controller@30.0.3-preview-1d9e239b6
@metamask-previews/user-operation-controller@42.0.1-preview-1d9e239b6
@metamask-previews/utils@12.0.0-preview-1d9e239b6
@metamask-previews/wallet@17.0.0-preview-1d9e239b6
@metamask-previews/wallet-cli@0.0.0-preview-1d9e239b6

Copilot AI 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.

🔵 Needs a closer look

Two moderate review issues remain unresolved.

0 open findings

2 resolved since last review

🧠 Review effort: Lite

…ests

Include the sourceAssetId and destAssetId in the Tron
signAndSendTransaction options so the Tron snap can classify the
transaction as a same-chain swap or a cross-chain bridge, mirroring the
Stellar snap.
@Battambang
Battambang force-pushed the feat/tron-flow-classification-analytics branch from 1d9e239 to 44b7ded Compare October 9, 2026 15:48
@Battambang
Battambang requested a lite review from Copilot October 9, 2026 15:53

Copilot AI 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.

🟢 Approval recommended

No unresolved blocking issues were identified.

0 open findings

🧠 Review effort: Lite

@Battambang

Copy link
Copy Markdown
Contributor Author

@metamaskbot publish-preview

@github-actions

github-actions Bot commented Oct 9, 2026

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/account-tree-controller@11.0.1-preview-44b7ded21
@metamask-previews/accounts-controller@40.0.0-preview-44b7ded21
@metamask-previews/address-book-controller@8.0.0-preview-44b7ded21
@metamask-previews/advanced-chart-core@1.0.0-preview-44b7ded21
@metamask-previews/ai-controllers@2.0.0-preview-44b7ded21
@metamask-previews/analytics-controller@4.0.0-preview-44b7ded21
@metamask-previews/analytics-data-regulation-controller@0.0.0-preview-44b7ded21
@metamask-previews/announcement-controller@9.0.0-preview-44b7ded21
@metamask-previews/app-metadata-controller@3.0.0-preview-44b7ded21
@metamask-previews/approval-controller@10.0.0-preview-44b7ded21
@metamask-previews/assets-controller@18.0.1-preview-44b7ded21
@metamask-previews/assets-controllers@112.1.2-preview-44b7ded21
@metamask-previews/authenticated-user-storage@4.1.0-preview-44b7ded21
@metamask-previews/base-controller@10.0.0-preview-44b7ded21
@metamask-previews/base-data-service@2.1.0-preview-44b7ded21
@metamask-previews/bitcoin-regtest-up@2.0.0-preview-44b7ded21
@metamask-previews/bridge-controller@82.0.2-preview-44b7ded21
@metamask-previews/bridge-status-controller@76.3.5-preview-44b7ded21
@metamask-previews/build-utils@4.0.0-preview-44b7ded21
@metamask-previews/chain-agnostic-permission@2.0.0-preview-44b7ded21
@metamask-previews/chomp-api-service@6.0.1-preview-44b7ded21
@metamask-previews/claims-controller@1.0.3-preview-44b7ded21
@metamask-previews/client-controller@2.0.0-preview-44b7ded21
@metamask-previews/client-utils@3.0.4-preview-44b7ded21
@metamask-previews/compliance-controller@3.0.0-preview-44b7ded21
@metamask-previews/composable-controller@13.0.0-preview-44b7ded21
@metamask-previews/config-registry-controller@5.0.0-preview-44b7ded21
@metamask-previews/connectivity-controller@1.0.0-preview-44b7ded21
@metamask-previews/controller-utils@13.0.0-preview-44b7ded21
@metamask-previews/core-backend@12.0.1-preview-44b7ded21
@metamask-previews/cryptography@1.1.2-preview-44b7ded21
@metamask-previews/delegation-controller@4.0.0-preview-44b7ded21
@metamask-previews/earn-controller@13.0.2-preview-44b7ded21
@metamask-previews/eip-5792-middleware@4.0.1-preview-44b7ded21
@metamask-previews/eip-7702-internal-rpc-middleware@1.0.0-preview-44b7ded21
@metamask-previews/eip1193-permission-middleware@3.0.0-preview-44b7ded21
@metamask-previews/eth-block-tracker@16.0.0-preview-44b7ded21
@metamask-previews/eth-json-rpc-middleware@25.0.0-preview-44b7ded21
@metamask-previews/eth-json-rpc-provider@7.0.0-preview-44b7ded21
@metamask-previews/foundryup@2.0.0-preview-44b7ded21
@metamask-previews/gas-fee-controller@27.0.0-preview-44b7ded21
@metamask-previews/gator-permissions-controller@6.0.1-preview-44b7ded21
@metamask-previews/geolocation-controller@2.0.0-preview-44b7ded21
@metamask-previews/java-tron-up@2.0.0-preview-44b7ded21
@metamask-previews/json-rpc-engine@11.0.0-preview-44b7ded21
@metamask-previews/json-rpc-middleware-stream@9.0.0-preview-44b7ded21
@metamask-previews/keyring-controller@28.1.0-preview-44b7ded21
@metamask-previews/kyc-controller@0.7.0-preview-44b7ded21
@metamask-previews/local-node-utils@2.0.0-preview-44b7ded21
@metamask-previews/logging-controller@10.0.0-preview-44b7ded21
@metamask-previews/message-manager@15.0.0-preview-44b7ded21
@metamask-previews/messenger@3.0.0-preview-44b7ded21
@metamask-previews/messenger-cli@1.0.0-preview-44b7ded21
@metamask-previews/money-account-api-data-service@2.1.0-preview-44b7ded21
@metamask-previews/money-account-balance-service@3.1.2-preview-44b7ded21
@metamask-previews/money-account-controller@2.0.0-preview-44b7ded21
@metamask-previews/money-account-upgrade-controller@5.1.0-preview-44b7ded21
@metamask-previews/money-account-utils@2.1.0-preview-44b7ded21
@metamask-previews/multichain-account-service@14.1.0-preview-44b7ded21
@metamask-previews/multichain-api-middleware@5.0.0-preview-44b7ded21
@metamask-previews/multichain-network-controller@4.0.0-preview-44b7ded21
@metamask-previews/multichain-transactions-controller@8.0.0-preview-44b7ded21
@metamask-previews/name-controller@10.0.0-preview-44b7ded21
@metamask-previews/network-connection-banner-controller@1.0.0-preview-44b7ded21
@metamask-previews/network-controller@37.0.1-preview-44b7ded21
@metamask-previews/network-enablement-controller@7.0.2-preview-44b7ded21
@metamask-previews/notification-services-controller@29.0.3-preview-44b7ded21
@metamask-previews/passkey-controller@4.1.0-preview-44b7ded21
@metamask-previews/permission-controller@14.0.0-preview-44b7ded21
@metamask-previews/permission-log-controller@6.0.0-preview-44b7ded21
@metamask-previews/perps-controller@20.0.0-preview-44b7ded21
@metamask-previews/phishing-controller@18.2.0-preview-44b7ded21
@metamask-previews/platform-api-docs@0.2.1-preview-44b7ded21
@metamask-previews/polling-controller@17.0.0-preview-44b7ded21
@metamask-previews/preferences-controller@24.0.0-preview-44b7ded21
@metamask-previews/profile-controller@1.0.1-preview-44b7ded21
@metamask-previews/profile-metrics-controller@5.1.3-preview-44b7ded21
@metamask-previews/profile-sync-controller@34.0.3-preview-44b7ded21
@metamask-previews/ramps-controller@27.0.1-preview-44b7ded21
@metamask-previews/rate-limit-controller@8.0.0-preview-44b7ded21
@metamask-previews/react-data-query@2.0.0-preview-44b7ded21
@metamask-previews/remote-feature-flag-controller@7.0.0-preview-44b7ded21
@metamask-previews/sample-controllers@6.0.0-preview-44b7ded21
@metamask-previews/seedless-onboarding-controller@12.0.0-preview-44b7ded21
@metamask-previews/selected-network-controller@27.0.0-preview-44b7ded21
@metamask-previews/sentinel-api-service@2.1.0-preview-44b7ded21
@metamask-previews/shield-controller@7.0.4-preview-44b7ded21
@metamask-previews/signature-controller@40.0.0-preview-44b7ded21
@metamask-previews/smart-transactions-controller@27.1.0-preview-44b7ded21
@metamask-previews/snap-account-service@4.0.0-preview-44b7ded21
@metamask-previews/social-controllers@3.6.0-preview-44b7ded21
@metamask-previews/solana-test-validator-up@2.0.0-preview-44b7ded21
@metamask-previews/stellar-quickstart-up@0.0.0-preview-44b7ded21
@metamask-previews/storage-service@2.0.0-preview-44b7ded21
@metamask-previews/subscription-controller@13.0.0-preview-44b7ded21
@metamask-previews/transaction-controller@72.2.0-preview-44b7ded21
@metamask-previews/transaction-pay-controller@30.0.3-preview-44b7ded21
@metamask-previews/user-operation-controller@42.0.1-preview-44b7ded21
@metamask-previews/utils@12.0.0-preview-44b7ded21
@metamask-previews/wallet@17.0.0-preview-44b7ded21
@metamask-previews/wallet-cli@0.0.0-preview-44b7ded21

…quests

Include the sourceAssetId and destAssetId in the Solana
signAndSendTransaction options so the Solana snap can classify the
transaction as a same-chain swap or a cross-chain bridge, mirroring the
Stellar snap.

The Solana and Stellar branches share the same asset-id-only options
shape, so they are combined into a single condition.
…equests

Include the sourceAssetId and destAssetId in the Bitcoin
signAndSendTransaction options so the Bitcoin snap can classify the
transaction as a same-chain swap or a cross-chain bridge, mirroring the
Stellar snap.

The Bitcoin snap ignores unknown options, so no strict rollout ordering
is required.
…ltichain-flow-classification-analytics

# Conflicts:
#	oxlint-suppressions.json
#	packages/bridge-status-controller/CHANGELOG.md
#	packages/bridge-status-controller/src/utils/snaps.ts
…ultichain-flow-classification-analytics

# Conflicts:
#	oxlint-suppressions.json
#	packages/bridge-status-controller/CHANGELOG.md
#	packages/bridge-status-controller/src/utils/snaps.ts
…t ids

Replace the mixed isStellarTrade/isBitcoinTrade guards with
isStellarChainId/isBitcoinChainId so all three non-Tron chains use the
same chain-id check, since getClientRequest already receives srcChainId.
The Tron branch is unchanged as it reads fields from the trade object.
@Battambang Battambang changed the title feat(bridge-status-controller): pass swap asset ids to Tron snap request feat(bridge-status-controller): pass swap asset ids to Tron, Solana, and Bitcoin snap requests Oct 10, 2026
Add the pull request reference to the combined Tron, Solana, and
Bitcoin changelog entry.
Comment on lines +96 to +99
if (
isStellarChainId(srcChainId) ||
isSolanaChainId(srcChainId) ||
isBitcoinChainId(srcChainId)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Why srcChainId instead of trade

Two reasons: consistency, and the trade shape does not always tell you the chain.

1. The trade shape is a lossy proxy for the chain

The strategy layer establishes that trade shape maps 1:1 to chain, but note the Stellar case in strategy/index.ts:

case ChainId.STELLAR:
  return txs.every((tx) => typeof tx === 'string' || isStellarTrade(tx));

A Stellar trade is either a string or an { xdr / xdrBase64 } object. So isStellarTrade(trade) is false for a string-shaped Stellar trade, and that string is indistinguishable from a Solana trade by shape alone. The chain id is the only reliable signal for Stellar-vs-Solana strings, which is exactly why the original Solana check used isSolanaChainId(srcChainId) (there is no isSolanaTrade).

2. Consistency: one condition, one kind of check

Before, the condition mixed two kinds of check:

isStellarTrade(trade) ||        // trade-shape guard
isSolanaChainId(srcChainId) ||  // chain guard
isBitcoinTrade(trade)           // trade-shape guard

getClientRequest already has srcChainId in scope (it derives scope from it on the first line), so using chain guards for all three makes the condition uniform:

isStellarChainId(srcChainId) ||
isSolanaChainId(srcChainId) ||
isBitcoinChainId(srcChainId)

3. It is also slightly more accurate

isStellarChainId accepts both pubnet and testnet (XlmScope.Pubnet / XlmScope.Testnet), whereas isStellarTrade only reflects the payload shape.

Behavior equivalence

Chain Before After Same?
Stellar (object xdr) isStellarTrade -> true isStellarChainId -> true Yes
Stellar (string xdr) isStellarTrade -> false isStellarChainId -> true After is more correct
Solana isSolanaChainId -> true isSolanaChainId -> true Yes
Bitcoin isBitcoinTrade -> true isBitcoinChainId -> true Yes
Tron not in this condition not in this condition Yes (separate branch)
EVM all false all false Yes

The only behavioral difference is the string-shaped Stellar case, where the new version is correct and the old one would have silently omitted the asset ids.

Copilot AI 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.

🟡 Changes recommended

Approval requests are misclassified, and swap/bridge fixtures contain contradictory CAIP chains.

2 open findings

🧠 Review effort: Balanced

Comment thread packages/bridge-status-controller/src/utils/snaps.ts Outdated
…he swap fixture

The Solana swap fixture set destChainId to Solana but gave the
destination asset an eip155 CAIP id. Now that the swap asset ids are
forwarded to the snap, that mismatch would classify the same-chain swap
as a bridgeSend, contradicting the fixture's own swap_type of
single_chain. Use a Solana asset id for the destination asset and
regenerate the affected snapshots.
…he swap fixture

The Solana swap fixture set destChainId to Solana but gave the
destination asset an eip155 CAIP id. Now that the swap asset ids are
forwarded to the snap, that mismatch would classify the same-chain swap
as a bridgeSend, contradicting the fixture's own swap_type of
single_chain. Use a Solana asset id for the destination asset and
regenerate the affected snapshots.
… requests

handleNonEvmTx always attached the quote's source and destination asset
ids to the signAndSendTransaction options, including for the token
approval that precedes a swap or bridge. The Tron snap gives those asset
ids precedence over the contract type, so an approve was classified as a
swap or bridgeSend instead of tokenApprove.

Add an isApproval flag and only attach the asset ids to the main trade.
The approval request now falls back to the contract-type classification.
# Conflicts:
#	packages/bridge-status-controller/src/utils/snaps.ts
@Battambang
Battambang marked this pull request as draft October 13, 2026 07:26
@Battambang

Copy link
Copy Markdown
Contributor Author

Snap release PR: MetaMask/internal-snaps#443

@Julink-eth
Julink-eth marked this pull request as ready for review October 13, 2026 09:16
@Julink-eth
Julink-eth deployed to default-branch October 13, 2026 09:16 — with GitHub Actions Active
@Julink-eth
Julink-eth marked this pull request as draft October 13, 2026 09:16
Julink-eth
Julink-eth previously approved these changes Oct 13, 2026
@Battambang
Battambang marked this pull request as ready for review October 13, 2026 09:57
@Battambang
Battambang deployed to default-branch October 13, 2026 09:57 — with GitHub Actions Active
@Battambang

Copy link
Copy Markdown
Contributor Author

@metamaskbot publish-preview

@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/account-tree-controller@11.0.1-preview-0bfdd33e2
@metamask-previews/accounts-controller@40.0.0-preview-0bfdd33e2
@metamask-previews/address-book-controller@8.0.0-preview-0bfdd33e2
@metamask-previews/advanced-chart-core@1.0.0-preview-0bfdd33e2
@metamask-previews/ai-controllers@2.0.0-preview-0bfdd33e2
@metamask-previews/analytics-controller@4.0.0-preview-0bfdd33e2
@metamask-previews/analytics-data-regulation-controller@0.0.0-preview-0bfdd33e2
@metamask-previews/announcement-controller@9.0.0-preview-0bfdd33e2
@metamask-previews/app-metadata-controller@3.0.0-preview-0bfdd33e2
@metamask-previews/approval-controller@10.0.0-preview-0bfdd33e2
@metamask-previews/assets-controller@19.0.0-preview-0bfdd33e2
@metamask-previews/assets-controllers@112.1.2-preview-0bfdd33e2
@metamask-previews/authenticated-user-storage@4.1.0-preview-0bfdd33e2
@metamask-previews/base-controller@10.0.0-preview-0bfdd33e2
@metamask-previews/base-data-service@2.1.0-preview-0bfdd33e2
@metamask-previews/bitcoin-regtest-up@2.0.0-preview-0bfdd33e2
@metamask-previews/bridge-controller@82.0.3-preview-0bfdd33e2
@metamask-previews/bridge-status-controller@76.3.5-preview-0bfdd33e2
@metamask-previews/build-utils@4.0.0-preview-0bfdd33e2
@metamask-previews/chain-agnostic-permission@2.0.0-preview-0bfdd33e2
@metamask-previews/chomp-api-service@6.0.1-preview-0bfdd33e2
@metamask-previews/claims-controller@1.0.3-preview-0bfdd33e2
@metamask-previews/client-controller@2.0.0-preview-0bfdd33e2
@metamask-previews/client-utils@3.0.4-preview-0bfdd33e2
@metamask-previews/compliance-controller@3.0.0-preview-0bfdd33e2
@metamask-previews/composable-controller@13.0.0-preview-0bfdd33e2
@metamask-previews/config-registry-controller@5.0.0-preview-0bfdd33e2
@metamask-previews/connectivity-controller@1.0.0-preview-0bfdd33e2
@metamask-previews/controller-utils@13.0.0-preview-0bfdd33e2
@metamask-previews/core-backend@12.1.0-preview-0bfdd33e2
@metamask-previews/cryptography@1.1.2-preview-0bfdd33e2
@metamask-previews/delegation-controller@4.0.0-preview-0bfdd33e2
@metamask-previews/earn-controller@13.0.2-preview-0bfdd33e2
@metamask-previews/eip-5792-middleware@4.0.1-preview-0bfdd33e2
@metamask-previews/eip-7702-internal-rpc-middleware@1.0.0-preview-0bfdd33e2
@metamask-previews/eip1193-permission-middleware@3.0.0-preview-0bfdd33e2
@metamask-previews/eth-block-tracker@16.0.0-preview-0bfdd33e2
@metamask-previews/eth-json-rpc-middleware@25.0.0-preview-0bfdd33e2
@metamask-previews/eth-json-rpc-provider@7.0.0-preview-0bfdd33e2
@metamask-previews/foundryup@2.0.0-preview-0bfdd33e2
@metamask-previews/gas-fee-controller@27.0.0-preview-0bfdd33e2
@metamask-previews/gator-permissions-controller@6.0.1-preview-0bfdd33e2
@metamask-previews/geolocation-controller@2.0.0-preview-0bfdd33e2
@metamask-previews/java-tron-up@2.0.0-preview-0bfdd33e2
@metamask-previews/json-rpc-engine@11.0.0-preview-0bfdd33e2
@metamask-previews/json-rpc-middleware-stream@9.0.0-preview-0bfdd33e2
@metamask-previews/keyring-controller@28.1.0-preview-0bfdd33e2
@metamask-previews/kyc-controller@0.8.0-preview-0bfdd33e2
@metamask-previews/local-node-utils@2.0.0-preview-0bfdd33e2
@metamask-previews/logging-controller@10.0.0-preview-0bfdd33e2
@metamask-previews/message-manager@15.0.0-preview-0bfdd33e2
@metamask-previews/messenger@3.0.0-preview-0bfdd33e2
@metamask-previews/messenger-cli@1.0.0-preview-0bfdd33e2
@metamask-previews/money-account-api-data-service@2.1.0-preview-0bfdd33e2
@metamask-previews/money-account-balance-service@3.1.2-preview-0bfdd33e2
@metamask-previews/money-account-controller@2.0.0-preview-0bfdd33e2
@metamask-previews/money-account-upgrade-controller@5.1.0-preview-0bfdd33e2
@metamask-previews/money-account-utils@2.1.0-preview-0bfdd33e2
@metamask-previews/multichain-account-service@14.1.0-preview-0bfdd33e2
@metamask-previews/multichain-api-middleware@5.0.0-preview-0bfdd33e2
@metamask-previews/multichain-network-controller@4.0.0-preview-0bfdd33e2
@metamask-previews/multichain-transactions-controller@8.0.0-preview-0bfdd33e2
@metamask-previews/name-controller@10.0.0-preview-0bfdd33e2
@metamask-previews/network-connection-banner-controller@1.0.0-preview-0bfdd33e2
@metamask-previews/network-controller@37.0.1-preview-0bfdd33e2
@metamask-previews/network-enablement-controller@7.0.2-preview-0bfdd33e2
@metamask-previews/notification-services-controller@29.0.3-preview-0bfdd33e2
@metamask-previews/passkey-controller@4.1.0-preview-0bfdd33e2
@metamask-previews/permission-controller@14.0.0-preview-0bfdd33e2
@metamask-previews/permission-log-controller@6.0.0-preview-0bfdd33e2
@metamask-previews/perps-controller@20.0.0-preview-0bfdd33e2
@metamask-previews/phishing-controller@18.2.0-preview-0bfdd33e2
@metamask-previews/platform-api-docs@0.2.1-preview-0bfdd33e2
@metamask-previews/polling-controller@17.0.0-preview-0bfdd33e2
@metamask-previews/preferences-controller@24.0.0-preview-0bfdd33e2
@metamask-previews/profile-controller@1.0.1-preview-0bfdd33e2
@metamask-previews/profile-metrics-controller@5.1.3-preview-0bfdd33e2
@metamask-previews/profile-sync-controller@34.0.3-preview-0bfdd33e2
@metamask-previews/ramps-controller@27.0.1-preview-0bfdd33e2
@metamask-previews/rate-limit-controller@8.0.0-preview-0bfdd33e2
@metamask-previews/react-data-query@2.0.0-preview-0bfdd33e2
@metamask-previews/remote-feature-flag-controller@7.0.0-preview-0bfdd33e2
@metamask-previews/sample-controllers@6.0.0-preview-0bfdd33e2
@metamask-previews/seedless-onboarding-controller@12.0.0-preview-0bfdd33e2
@metamask-previews/selected-network-controller@27.0.0-preview-0bfdd33e2
@metamask-previews/sentinel-api-service@2.1.0-preview-0bfdd33e2
@metamask-previews/shield-controller@7.0.4-preview-0bfdd33e2
@metamask-previews/signature-controller@40.0.0-preview-0bfdd33e2
@metamask-previews/smart-transactions-controller@27.1.0-preview-0bfdd33e2
@metamask-previews/snap-account-service@4.0.0-preview-0bfdd33e2
@metamask-previews/social-controllers@3.7.0-preview-0bfdd33e2
@metamask-previews/solana-test-validator-up@2.0.0-preview-0bfdd33e2
@metamask-previews/stellar-quickstart-up@0.0.0-preview-0bfdd33e2
@metamask-previews/storage-service@2.0.0-preview-0bfdd33e2
@metamask-previews/subscription-controller@13.0.0-preview-0bfdd33e2
@metamask-previews/transaction-controller@72.2.0-preview-0bfdd33e2
@metamask-previews/transaction-pay-controller@30.1.0-preview-0bfdd33e2
@metamask-previews/user-operation-controller@42.0.1-preview-0bfdd33e2
@metamask-previews/utils@12.0.0-preview-0bfdd33e2
@metamask-previews/wallet@17.0.0-preview-0bfdd33e2
@metamask-previews/wallet-cli@0.0.0-preview-0bfdd33e2

Comment thread packages/bridge-status-controller/src/utils/snaps.ts Outdated
@Battambang
Battambang added this pull request to the merge queue Oct 13, 2026
Merged via the queue into main with commit f55b36e Oct 13, 2026
346 checks passed
@Battambang
Battambang deleted the feat/tron-flow-classification-analytics branch October 13, 2026 18:49
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.

5 participants