Skip to content

feat: adding support for postQuote transactions with paymentOverride defined#8967

Open
jpuri wants to merge 14 commits into
mainfrom
paymentoverride_postquote
Open

feat: adding support for postQuote transactions with paymentOverride defined#8967
jpuri wants to merge 14 commits into
mainfrom
paymentoverride_postquote

Conversation

@jpuri
Copy link
Copy Markdown
Contributor

@jpuri jpuri commented Jun 2, 2026

Explanation

Adding support for postQuote transactions with paymentOverride defined. This is done by calling getPaymentOverrideData when and adding additional transactions to quote request.

References

Related to https://consensyssoftware.atlassian.net/browse/CONF-1407

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 how Relay quote bodies are built for Money Account post-quote flows (transfers, delegation, and client-provided override calls), which affects payment execution though behavior is gated and covered by new tests.

Overview
Adds Money Account handling for Relay quotes when isPostQuote and paymentOverride === PaymentOverride.MoneyAccount. Instead of skipping transaction embedding like other post-quote flows, the Relay strategy now calls getPaymentOverrideData, builds an EXACT_OUTPUT quote with a funding token transfer plus override batch calls, and optionally applies EIP-7702 authorizationList and a custom funding recipient.

GetPaymentOverrideDataResponse gains optional recipient and authorizationList so clients can steer the transfer target and delegation. Authorization normalization is shared via normalizeAuthorizationList (also used by the existing delegation path in processTransactions).

Changelog and a dedicated processMoneyAccountPostQuote test suite cover trade type, txs composition, empty override calls, and defaults for amount/value.

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

@jpuri jpuri force-pushed the paymentoverride_postquote branch from eaea3f1 to dfa88a2 Compare June 2, 2026 12:24
@jpuri jpuri changed the title feat: add support for transactions with paymentOverride and postQuote… feat: adding support for postQuote transactions with paymentProvider defined Jun 2, 2026
@jpuri jpuri marked this pull request as ready for review June 2, 2026 12:27
@jpuri jpuri requested a review from a team as a code owner June 2, 2026 12:27
@jpuri jpuri enabled auto-merge June 2, 2026 12:27
@jpuri jpuri temporarily deployed to default-branch June 2, 2026 12:27 — with GitHub Actions Inactive
@jpuri jpuri requested a review from a team as a code owner June 2, 2026 12:32
Comment thread packages/transaction-pay-controller/src/strategy/relay/relay-quotes.ts Outdated
@OGPoyraz OGPoyraz requested a review from matthewwalsh0 June 3, 2026 15:00

### Added

- Adding processing for postQuote transactions with paymentProvider defined ([#8967](https://github.com/MetaMask/core/pull/8967))
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Do you mean paymentOverride, same for PR description? 😅

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.

My bad, changelog and PR description are updated.


const transactionData = transactionDataList[transaction.id];
const amountHuman = transactionData?.tokens?.[0]?.amountHuman ?? '0';
const amountRaw =
Copy link
Copy Markdown
Member

@matthewwalsh0 matthewwalsh0 Jun 4, 2026

Choose a reason for hiding this comment

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

Why do we have to check the state directly? Shouldn't this always be the sourceTokenAmount in request?

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.

I changed it for amountRaw.

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.

We do not have amountHuman available, an option is that we send amountHuman to callback rather than amountHuman also. That may be more accurate.

});

if (!overrideCalls.length) {
log('No payment override calls for money account post-quote');
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Should we throw in this case as something has gone wrong?

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.

Here it is possible in a future use case the callback conditionally returns calls. Thus we should not throw if there are no calls.

@jpuri jpuri changed the title feat: adding support for postQuote transactions with paymentProvider defined feat: adding support for postQuote transactions with paymentOverride defined Jun 4, 2026
@jpuri jpuri requested a review from matthewwalsh0 June 4, 2026 11:08
Copy link
Copy Markdown

@cursor cursor Bot left a comment

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 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 4311eec. Configure here.

{
to: request.targetTokenAddress,
data: buildTokenTransferData(fundingRecipient, request.sourceTokenAmount),
value: '0x0',
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Wrong ERC20 contract on transfer

High Severity

In post-quote flows, originCurrency is the source token on the origin chain, but the prepended funding transfer sets txs[0].to to request.targetTokenAddress (the destination payment token). That can target the wrong contract on the origin chain and produce invalid or incorrect transfer calldata.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 4311eec. Configure here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants