Skip to content

refactor: move swap utils around for money account integration - #11403

Open
micaelae wants to merge 9 commits into
mainfrom
swaps-refactor-before-money-acct
Open

micaelae wants to merge 9 commits into
mainfrom
swaps-refactor-before-money-acct

Conversation

@micaelae

@micaelae micaelae commented Nov 10, 2026 •

Copy link
Copy Markdown
Member

Explanation

References

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
Touches bridge submit/status lifecycle, history keys, and transaction confirmation side effects—regressions could affect polling, metrics, or activity list accuracy without breaking compile-time safety.

Overview
Pulls Accounts, Network, and Remote Feature Flags messenger access into shared helpers under bridge-controller (getAccountByAddress, getNetworkClientByChainId, getFeatureFlags) and re-exports them so other packages (including bridge-status) can depend on one place instead of duplicating #getNetworkClientByChainId or local accounts.ts.

Bridge Status Controller gets the larger behavioral refactor: TransactionController:transactionStatusUpdated handling moves into tradeUpdateHandler / approvalUpdateHandler with resolveHistoryKeyForTxMeta, confirmation logic distinguishes bridge vs swap/nested txs more explicitly, and history rekeying no longer threads raw TransactionMeta—overrides come from getHistoryOverridesFromTxMeta and an updated rekeyHistoryItemInState. Quote v1/v2 normalization is extracted to normalizeQuoteResponses, and the Firefox-specific StartPollingForBridgeTxStatusArgsSerialized type is removed in favor of a single args type.

Submit strategies (EVM, batch, batch-sell) and tests are updated for the new history override shape; lint/tsc suppression counts are adjusted accordingly.

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

@micaelae
micaelae requested review from a team as code owners November 10, 2026 00:53
@micaelae
micaelae added this pull request to stack #11404 November 10, 2026 00:57

@cursor cursor Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Stale Bugbot comment from a previous run.

Base automatically changed from swaps5256-amount-helper to main November 10, 2026 08:04
@micaelae
micaelae force-pushed the swaps-refactor-before-money-acct branch from f3f6fd5 to 9fd4045 Compare November 10, 2026 08:04

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.

Fix All in Cursor

❌ 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 9fd4045. Configure here.

};

// Only EVM txs
/**

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Nested bridge failures skip quote finalization

Medium Severity

Failed nested 7702/batch bridges are now routed through tradeUpdateHandler, but #onTransactionFailed still only treats isCrossChainTx(type) or hasNestedSwapTransactions as a trade. A batch tx with nested bridges therefore never calls reportFinalised. isAtomic7702BatchTx has the same gap, so history matching for nested-bridge batches is inconsistent with nested swaps.

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 9fd4045. Configure here.

@micaelae
micaelae force-pushed the swaps-refactor-before-money-acct branch from 9fd4045 to 0f61514 Compare November 10, 2026 17:43
@micaelae

Copy link
Copy Markdown
Member 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.2.0-preview-0f61514
@metamask-previews/accounts-controller@40.2.0-preview-0f61514
@metamask-previews/address-book-controller@8.0.0-preview-0f61514
@metamask-previews/advanced-chart-core@1.1.0-preview-0f61514
@metamask-previews/ai-controllers@2.0.0-preview-0f61514
@metamask-previews/analytics-controller@4.3.0-preview-0f61514
@metamask-previews/analytics-data-regulation-controller@0.0.0-preview-0f61514
@metamask-previews/announcement-controller@9.0.0-preview-0f61514
@metamask-previews/app-metadata-controller@3.0.0-preview-0f61514
@metamask-previews/approval-controller@10.0.0-preview-0f61514
@metamask-previews/assets-controller@20.3.1-preview-0f61514
@metamask-previews/assets-controllers@113.3.1-preview-0f61514
@metamask-previews/authenticated-user-storage@4.1.0-preview-0f61514
@metamask-previews/base-controller@10.1.0-preview-0f61514
@metamask-previews/base-data-service@2.1.0-preview-0f61514
@metamask-previews/bitcoin-regtest-up@2.0.0-preview-0f61514
@metamask-previews/bridge-controller@83.1.4-preview-0f61514
@metamask-previews/bridge-status-controller@78.0.2-preview-0f61514
@metamask-previews/build-utils@4.0.0-preview-0f61514
@metamask-previews/byte-utils@0.1.0-preview-0f61514
@metamask-previews/chain-agnostic-permission@2.1.0-preview-0f61514
@metamask-previews/chomp-api-service@7.0.0-preview-0f61514
@metamask-previews/claims-controller@1.1.0-preview-0f61514
@metamask-previews/client-controller@2.0.0-preview-0f61514
@metamask-previews/client-utils@3.2.0-preview-0f61514
@metamask-previews/compliance-controller@3.0.0-preview-0f61514
@metamask-previews/composable-controller@13.0.0-preview-0f61514
@metamask-previews/config-registry-controller@5.0.0-preview-0f61514
@metamask-previews/connectivity-controller@1.0.0-preview-0f61514
@metamask-previews/controller-utils@13.0.0-preview-0f61514
@metamask-previews/core-backend@14.0.0-preview-0f61514
@metamask-previews/cryptography@1.1.2-preview-0f61514
@metamask-previews/delegation-controller@4.0.0-preview-0f61514
@metamask-previews/earn-controller@13.1.0-preview-0f61514
@metamask-previews/eip-5792-middleware@4.1.0-preview-0f61514
@metamask-previews/eip-7702-internal-rpc-middleware@1.0.0-preview-0f61514
@metamask-previews/eip1193-permission-middleware@3.0.0-preview-0f61514
@metamask-previews/error-utils@0.1.0-preview-0f61514
@metamask-previews/eth-block-tracker@16.0.0-preview-0f61514
@metamask-previews/eth-json-rpc-middleware@26.0.0-preview-0f61514
@metamask-previews/eth-json-rpc-provider@7.0.0-preview-0f61514
@metamask-previews/eth-sig-util@9.0.0-preview-0f61514
@metamask-previews/foundryup@2.0.0-preview-0f61514
@metamask-previews/gas-fee-controller@27.1.1-preview-0f61514
@metamask-previews/gator-permissions-controller@6.1.1-preview-0f61514
@metamask-previews/geolocation-controller@2.0.0-preview-0f61514
@metamask-previews/java-tron-up@2.0.0-preview-0f61514
@metamask-previews/json-rpc-engine@11.0.0-preview-0f61514
@metamask-previews/json-rpc-middleware-stream@9.0.0-preview-0f61514
@metamask-previews/key-tree@10.1.1-preview-0f61514
@metamask-previews/keyring-controller@28.2.0-preview-0f61514
@metamask-previews/kyc-controller@0.16.0-preview-0f61514
@metamask-previews/local-node-utils@2.0.0-preview-0f61514
@metamask-previews/logging-controller@10.0.0-preview-0f61514
@metamask-previews/marketing-consent-controller@1.1.0-preview-0f61514
@metamask-previews/message-manager@15.0.0-preview-0f61514
@metamask-previews/messenger@3.0.0-preview-0f61514
@metamask-previews/messenger-cli@1.0.0-preview-0f61514
@metamask-previews/mfa-recovery-controller@0.0.0-preview-0f61514
@metamask-previews/money-account-api-data-service@2.3.1-preview-0f61514
@metamask-previews/money-account-balance-service@3.2.0-preview-0f61514
@metamask-previews/money-account-controller@3.0.0-preview-0f61514
@metamask-previews/money-account-lifecycle-controller@0.0.0-preview-0f61514
@metamask-previews/money-account-mfa-whitelist@0.2.0-preview-0f61514
@metamask-previews/money-account-upgrade-controller@6.0.1-preview-0f61514
@metamask-previews/money-account-utils@2.2.0-preview-0f61514
@metamask-previews/multichain-account-service@14.1.0-preview-0f61514
@metamask-previews/multichain-api-middleware@5.1.0-preview-0f61514
@metamask-previews/multichain-network-controller@4.1.1-preview-0f61514
@metamask-previews/multichain-transactions-controller@8.0.0-preview-0f61514
@metamask-previews/name-controller@10.0.0-preview-0f61514
@metamask-previews/network-connection-banner-controller@1.1.0-preview-0f61514
@metamask-previews/network-controller@38.0.0-preview-0f61514
@metamask-previews/network-enablement-controller@7.1.1-preview-0f61514
@metamask-previews/node-utils@0.1.0-preview-0f61514
@metamask-previews/notification-services-controller@30.1.0-preview-0f61514
@metamask-previews/passkey-controller@4.1.0-preview-0f61514
@metamask-previews/permission-controller@14.1.0-preview-0f61514
@metamask-previews/permission-log-controller@6.0.0-preview-0f61514
@metamask-previews/perps-controller@23.0.0-preview-0f61514
@metamask-previews/phishing-controller@18.3.0-preview-0f61514
@metamask-previews/platform-api-docs@0.2.1-preview-0f61514
@metamask-previews/polling-controller@17.0.0-preview-0f61514
@metamask-previews/preferences-controller@24.0.0-preview-0f61514
@metamask-previews/profile-controller@3.0.0-preview-0f61514
@metamask-previews/profile-metrics-controller@5.2.1-preview-0f61514
@metamask-previews/profile-sync-controller@36.1.1-preview-0f61514
@metamask-previews/ramps-controller@29.0.0-preview-0f61514
@metamask-previews/rate-limit-controller@8.0.0-preview-0f61514
@metamask-previews/react-data-query@2.0.0-preview-0f61514
@metamask-previews/remote-feature-flag-controller@7.0.0-preview-0f61514
@metamask-previews/sample-controllers@6.1.0-preview-0f61514
@metamask-previews/seedless-onboarding-controller@12.0.0-preview-0f61514
@metamask-previews/selected-network-controller@27.1.0-preview-0f61514
@metamask-previews/sentinel-api-service@2.1.0-preview-0f61514
@metamask-previews/shield-controller@7.1.1-preview-0f61514
@metamask-previews/signature-controller@40.1.0-preview-0f61514
@metamask-previews/smart-transactions-controller@27.2.2-preview-0f61514
@metamask-previews/snap-account-service@4.0.0-preview-0f61514
@metamask-previews/social-controllers@3.20.0-preview-0f61514
@metamask-previews/solana-test-validator-up@2.0.0-preview-0f61514
@metamask-previews/stellar-quickstart-up@0.0.0-preview-0f61514
@metamask-previews/storage-service@2.0.0-preview-0f61514
@metamask-previews/subscription-controller@15.2.0-preview-0f61514
@metamask-previews/transaction-controller@73.1.2-preview-0f61514
@metamask-previews/transaction-pay-controller@31.1.0-preview-0f61514
@metamask-previews/transaction-pay-middleware@2.0.3-preview-0f61514
@metamask-previews/type-utils@0.1.0-preview-0f61514
@metamask-previews/user-operation-controller@42.1.1-preview-0f61514
@metamask-previews/utils@12.0.1-preview-0f61514
@metamask-previews/wallet@21.0.1-preview-0f61514
@metamask-previews/watch-only-account-service@0.1.0-preview-0f61514

This branch has not been deployed

No deployments
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.

1 participant