Skip to content

feat: call getPaymentOverrideData method to get payment override steps for transactions when paymentOverride is defined#8870

Open
jpuri wants to merge 51 commits into
mainfrom
build_additional_trxn_steps
Open

feat: call getPaymentOverrideData method to get payment override steps for transactions when paymentOverride is defined#8870
jpuri wants to merge 51 commits into
mainfrom
build_additional_trxn_steps

Conversation

@jpuri
Copy link
Copy Markdown
Contributor

@jpuri jpuri commented May 21, 2026

Explanation

If paymentOverride is defined call getPaymentOverrideData method to get payment override steps for transactions.

References

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

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 batches are built, gas is estimated, and source balances are validated when paymentOverride is active; incorrect client callback data could mis-submit or underfund txs, though the feature is opt-in and covered by tests.

Overview
Adds an optional getPaymentOverrideData hook on TransactionPayController (constructor option + TransactionPayController:getPaymentOverrideData messenger action). When paymentOverride is set on transaction config/data, quote requests carry that flag through, and the Relay path prepends client-supplied BatchTransactionParams ahead of relay steps instead of using the post-quote “original tx” prepend.

Relay gas now reserves a fixed 75,000 for those prepended override txs (including on combined EIP-7702 limits). Submit skips source balance validation for override flows, maps batch transaction types via a generic prependCount (not only isPostQuote), and falls back to a single-tx path if the callback returns no calls.

Public exports add GetPaymentOverrideDataRequest / GetPaymentOverrideDataResponse; tests cover controller delegation, quote gas, and submit batch behavior.

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

Base automatically changed from money_account_support to main May 21, 2026 12:04
@jpuri jpuri changed the title feat: support for money account source for MM pay deposit transactions feat: if paymentOverride is defined call getPaymentOverrideData method to get payment override steps for transactions May 25, 2026
@jpuri jpuri changed the title feat: if paymentOverride is defined call getPaymentOverrideData method to get payment override steps for transactions feat: call getPaymentOverrideData method to get payment override steps for transactions when paymentOverride is defined May 27, 2026
@jpuri jpuri enabled auto-merge May 27, 2026 14:47
Comment thread packages/transaction-pay-controller/src/strategy/relay/relay-submit.ts Outdated
Comment thread packages/transaction-pay-controller/src/strategy/relay/relay-submit.ts Outdated
Comment thread packages/transaction-pay-controller/src/types.ts Outdated
Comment thread packages/transaction-pay-controller/src/types.ts Outdated
Comment thread packages/transaction-pay-controller/src/types.ts
Comment thread packages/transaction-pay-controller/src/types.ts Outdated
export type GetPaymentOverrideDataCallback = (
transactionId: string,
amount: string,
) => Promise<TransactionParams | undefined>;
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.

Also here, should we return an object for future-proofing so:

Promise<{ calls: BatchTransactionParams[]}>?

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.

PR is updated to address this

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.

Can't see this one?

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.

Ah I missed that part to convert it to object, done now.

Comment thread packages/transaction-pay-controller/src/strategy/relay/relay-submit.test.ts Outdated
Comment thread packages/transaction-pay-controller/src/strategy/relay/relay-submit.test.ts Outdated
Comment thread packages/transaction-pay-controller/src/TransactionPayController.test.ts Outdated
@jpuri jpuri requested a review from matthewwalsh0 May 27, 2026 16:55
Comment thread packages/transaction-pay-controller/src/strategy/relay/relay-submit.ts Outdated
}

// Hardcoded gas allowance for the prepended payment override transaction(s).
const PAYMENT_OVERRIDE_GAS = 75_000;
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.

Minor, constants at top.

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.

PR is updated to address this.

const transactions = allParams.map((singleParams, index) => {
const gasLimit = gasLimits[index];
const relayIndex = overrideCount > 0 ? index - overrideCount : index;
const gasLimit = relayIndex >= 0 ? gasLimits[relayIndex] : undefined;
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.

We don't need this logic anymore do we? Since we're providing an extra gas limit in the list?

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.

Good catch, PR is updated

? toHex(metamask.gasLimits[0])
: undefined;

const overrideCount = quote.request.paymentOverride
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.

Could we make this generic for the post quote scenario also? What if we have a payment override and post quote?

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.

Yep, I updated the PR

): TransactionMeta['type'] {
// Post-quote index 0 is the original transaction
if (isPostQuote && index === 0) {
const prependCount = isPostQuote ? 1 : overrideCount;
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.

We don't need to check post quote do we as we may have post quote plus payment override? So just the overrideCount is sufficient?

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.

Good point, PR is updated to address this

*/
export type GetPaymentOverrideDataCallback = (
request: GetPaymentOverrideDataRequest,
) => Promise<BatchTransactionParams[]>;
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 we want that response object for future-proofing? So the {calls}?

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.

PR is updated to address this

Comment thread packages/transaction-pay-controller/src/index.ts
@jpuri jpuri requested a review from matthewwalsh0 May 28, 2026 09:43
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 e4c41e3. 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