feat: call getPaymentOverrideData method to get payment override steps for transactions when paymentOverride is defined#8870
feat: call getPaymentOverrideData method to get payment override steps for transactions when paymentOverride is defined#8870jpuri wants to merge 51 commits into
Conversation
…ditional_trxn_steps
…Mask/core into build_additional_trxn_steps
…Mask/core into build_additional_trxn_steps
| export type GetPaymentOverrideDataCallback = ( | ||
| transactionId: string, | ||
| amount: string, | ||
| ) => Promise<TransactionParams | undefined>; |
There was a problem hiding this comment.
Also here, should we return an object for future-proofing so:
Promise<{ calls: BatchTransactionParams[]}>?
There was a problem hiding this comment.
PR is updated to address this
There was a problem hiding this comment.
Ah I missed that part to convert it to object, done now.
…Mask/core into build_additional_trxn_steps
| } | ||
|
|
||
| // Hardcoded gas allowance for the prepended payment override transaction(s). | ||
| const PAYMENT_OVERRIDE_GAS = 75_000; |
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
We don't need this logic anymore do we? Since we're providing an extra gas limit in the list?
There was a problem hiding this comment.
Good catch, PR is updated
| ? toHex(metamask.gasLimits[0]) | ||
| : undefined; | ||
|
|
||
| const overrideCount = quote.request.paymentOverride |
There was a problem hiding this comment.
Could we make this generic for the post quote scenario also? What if we have a payment override and post quote?
There was a problem hiding this comment.
Yep, I updated the PR
| ): TransactionMeta['type'] { | ||
| // Post-quote index 0 is the original transaction | ||
| if (isPostQuote && index === 0) { | ||
| const prependCount = isPostQuote ? 1 : overrideCount; |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
Good point, PR is updated to address this
| */ | ||
| export type GetPaymentOverrideDataCallback = ( | ||
| request: GetPaymentOverrideDataRequest, | ||
| ) => Promise<BatchTransactionParams[]>; |
There was a problem hiding this comment.
Do we want that response object for future-proofing? So the {calls}?
There was a problem hiding this comment.
PR is updated to address this
…Mask/core into build_additional_trxn_steps
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ 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.

Explanation
If
paymentOverrideis defined callgetPaymentOverrideDatamethod to get payment override steps for transactions.References
Related to https://consensyssoftware.atlassian.net/browse/CONF-1404
Checklist
Note
Medium Risk
Changes how Relay batches are built, gas is estimated, and source balances are validated when
paymentOverrideis 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
getPaymentOverrideDatahook onTransactionPayController(constructor option +TransactionPayController:getPaymentOverrideDatamessenger action). WhenpaymentOverrideis set on transaction config/data, quote requests carry that flag through, and the Relay path prepends client-suppliedBatchTransactionParamsahead 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 onlyisPostQuote), 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.