Skip to content

feat: add accountOverride to override default recipient or delegator for MM Pay transactions#8454

Open
jpuri wants to merge 16 commits intomainfrom
acc_override_support
Open

feat: add accountOverride to override default recipient or delegator for MM Pay transactions#8454
jpuri wants to merge 16 commits intomainfrom
acc_override_support

Conversation

@jpuri
Copy link
Copy Markdown
Contributor

@jpuri jpuri commented Apr 14, 2026

Explanation

Add accountOverride in transaction config to override default recipient or delegator for MM Pay transactions

References

Fixes https://consensyssoftware.atlassian.net/browse/CONF-1188

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 which address is used as the from account in quote/balance logic, which can affect pricing, eligibility, and funding behavior if misconfigured. Scope is localized to transaction-pay config/state and quote building and is covered by targeted unit tests.

Overview
Adds a new optional transaction config/state field accountOverride to override the default account used for MM Pay transactions.

When set, quote generation (and payment-token balance refresh) uses accountOverride as the from address instead of txParams.from, and the controller now treats changes to accountOverride as quote-affecting (triggering updateSourceAmounts/updateQuotes). Tests and changelog are updated to cover the new behavior for both post-quote and standard flows.

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

@jpuri jpuri marked this pull request as ready for review April 15, 2026 09:46
@jpuri jpuri requested review from a team as code owners April 15, 2026 09:46
@jpuri jpuri enabled auto-merge April 15, 2026 09:46
transactionData.isPostQuote = config.isPostQuote;
transactionData.isHyperliquidSource = config.isHyperliquidSource;
transactionData.refundTo = config.refundTo;
transactionData.accountOverride = config.accountOverride;
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, alphabetical.

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 callsForActions = [...destinationCalls];
let recipient = from;
let recipient = accountOverride ?? from;
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.

For a standard deposit flow, should accountOverride just be the funding account and gas payer, but the recipient of the funds should remain as the original from?

So in the money account example, from is money account so it gets the funds, but the source transactions are submitted by accountOverride.

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.

That is good catch, let me fix this.

But I am bit confused here why we are using from account and not to account as destination ?

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.

*/
refundTo?: Hex;

/** Optional address to override the default account used by the transaction.
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 we elaborate here and confirm that the accountOverride provides the funds and pays for gas, and if isPostQuote is also the recipient.

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.

: from,
slippageTolerance,
tradeType: useExactInput ? 'EXACT_INPUT' : 'EXPECTED_OUTPUT',
user: from,
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 also need to change this user since the accountOverride will be the one providing the funds and signing the source transactions?

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.

For audit sake, just confirming that processTransactions shouldn't need changing as it already uses the original transactionMeta to build the delegations where the from would be the money account?

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 need to update across-quotes to set the depositor to the accountOverride?

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.

Since depositor is set to from which we updated in quotes.ts to use accountOverride. This change is not needed separately.

});

const requests = buildQuoteRequests({
accountOverride,
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 abstract this from the strategies by setting from here to accountOverride instead?

The delegations on the target side should still work as that uses the original full transactionMeta?

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.

This is nice simplification, PR is updated.

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.

For the fully gasless flow, do we need to update submitViaRelayExecute in relay-submit to use the accountOverride also since it would be providing the funds?

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.

This should also already work as from is now updated in 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.

Can do in a separate PR if easier, but for the withdraw flows, if we have a accountOverride, then we want that to sign the withdraw transaction rather than the original from.

So do we need to convert the withdraw transaction data to delegations on line 353 of relay-submit.ts?

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.

This should also already work since from is quote is updated.

Comment thread packages/transaction-pay-controller/src/strategy/relay/relay-quotes.ts Outdated
@jpuri jpuri requested a review from matthewwalsh0 April 15, 2026 12:07
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 1b7f538. Configure here.

Comment thread packages/transaction-pay-controller/src/TransactionPayController.ts
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