Skip to content

feat: persist pay strategy in TransactionController metamaskPay metadata - #9733

Merged
OGPoyraz merged 2 commits into
mainfrom
ogp/persist-pay-strategy
Jul 31, 2026
Merged

feat: persist pay strategy in TransactionController metamaskPay metadata#9733
OGPoyraz merged 2 commits into
mainfrom
ogp/persist-pay-strategy

Conversation

@OGPoyraz

@OGPoyraz OGPoyraz commented Jul 31, 2026

Copy link
Copy Markdown
Member

Explanation

TransactionPayController.transactionData (including quotes and their strategy) is not persisted, but transactionMeta.metamaskPay is. When a MetaMask Pay transaction finalizes after the transaction data is gone (e.g. the app restarted mid-flight), clients cannot report which pay strategy funded the transaction — mobile currently has to assume relay for all non-fiat backfills in its metrics builder (see MetaMask/metamask-mobile#34111).

This PR persists the strategy at the same point the rest of the pay metadata is synced:

  • @metamask/transaction-controller: adds an optional strategy?: string field to MetamaskPayMetadata.
  • @metamask/transaction-pay-controller: syncTransaction (called from updateQuotes) now writes the first executable quote's strategy to tx.metamaskPay.strategy. No-op quotes are already filtered out, so a direct route persists no strategy (consistent with mm_pay_strategy metrics semantics, which only count real quotes).

Non-breaking: the field is optional and additive.

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

Low Risk
Additive optional metadata and quote-sync wiring only; no auth, signing, or transaction lifecycle changes.

Overview
Adds an optional strategy field on persisted metamaskPay metadata so clients can tell which MetaMask Pay funding route was used after in-memory pay quote data is gone (e.g. after restart).

@metamask/transaction-controller extends MetamaskPayMetadata with strategy?: string. @metamask/transaction-pay-controller passes the first executable quote’s strategy from updateQuotes into syncTransaction, which writes it alongside existing fiat totals when pay metadata is synced. Direct / no-op routes (TransactionPayStrategy.None) still count as no executable quotes, so strategy stays unset, matching existing pay-metrics semantics. Tests cover successful persistence and the no-quote case.

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

@OGPoyraz
OGPoyraz force-pushed the ogp/persist-pay-strategy branch from bd4f72e to 8764cb8 Compare July 31, 2026 10:16
OGPoyraz and others added 2 commits July 31, 2026 13:16
Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
…ay metadata

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
@OGPoyraz
OGPoyraz force-pushed the ogp/persist-pay-strategy branch from 8764cb8 to 71afa7e Compare July 31, 2026 10:16
@OGPoyraz OGPoyraz changed the title feat: persist pay strategy in TransactionController metamaskPay metadata feat: persist pay strategy in TransactionController metamaskPay metadata Jul 31, 2026
@OGPoyraz
OGPoyraz marked this pull request as ready for review July 31, 2026 10:17
@OGPoyraz
OGPoyraz requested review from a team as code owners July 31, 2026 10:17
@OGPoyraz
OGPoyraz temporarily deployed to default-branch July 31, 2026 10:17 — with GitHub Actions Inactive
@OGPoyraz
OGPoyraz added this pull request to the merge queue Jul 31, 2026
Merged via the queue into main with commit 9bbce8d Jul 31, 2026
140 checks passed
@OGPoyraz
OGPoyraz deleted the ogp/persist-pay-strategy branch July 31, 2026 10:28
@OGPoyraz OGPoyraz mentioned this pull request Jul 31, 2026
4 tasks
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.

2 participants