Skip to content

fix: quote request should not be sent of amount of token requested by the user is 0#8554

Open
jpuri wants to merge 7 commits intomainfrom
quote_check
Open

fix: quote request should not be sent of amount of token requested by the user is 0#8554
jpuri wants to merge 7 commits intomainfrom
quote_check

Conversation

@jpuri
Copy link
Copy Markdown
Contributor

@jpuri jpuri commented Apr 23, 2026

Explanation

Money account page updated transaction a few times, this change ensure that we get quote only of token amount requested is not 0.

References

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

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 required-token detection logic used to drive quoting/payment flows; consumers that relied on the synthetic gas-fee token may see different quote requests and balance checks.

Overview
parseRequiredTokens no longer synthesizes/returns a native “gas fee required token”; when requiredAssets are absent it now only returns a required token for detected ERC-20 transfer data (otherwise []).

This removes the getGasFeeToken code path (and related BigNumber/native-token helpers), updates unit tests to drop gas-fee expectations and assert empty results for invalid transfer data, and documents the behavioral change in the changelog.

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

}

log('Updating quotes', { transactionId });

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.

On money account page token / accountOverride can be updated few times. We need to ensure that quotes is not refetched unless user enters a non-zero token amount. Thus this change is made.

Another approach could be to change methods setTransactionConfig, 'setPaymentToken' to not refresh quote is amount of token requested is zero.

Base automatically changed from acc_override_support to main April 23, 2026 09:55
@jpuri jpuri marked this pull request as ready for review April 23, 2026 09:57
@jpuri jpuri requested review from a team as code owners April 23, 2026 09:57
@jpuri jpuri enabled auto-merge April 24, 2026 02:37
Comment thread packages/transaction-pay-controller/src/utils/quotes.ts Outdated
tokens,
} = transactionData;

const hasNonZeroTokenAmount =
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 already have this logic in source-amounts.ts, so this was working previously, so is this a unique issue for account override somehow?

Copy link
Copy Markdown
Contributor Author

@jpuri jpuri Apr 29, 2026

Choose a reason for hiding this comment

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

When we update transactionConfig - like update accountOverride, it triggers updating payToken and getting new quote. So this was happening frequently on money account pages.

Also, money account transaction I found was request 0 value for required token and a small value for another token with token.skipIfBalance true. I guess it was for gas fees.

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.

But we only generate quote requests for any source amounts we have, and the logic in calculatePostQuoteSourceAmounts should already skip tokens if its skipIfBalance or if the amount is zero?

So we need to debug why that existing logic isn't working.

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, let me debug existing code.

Copy link
Copy Markdown
Contributor Author

@jpuri jpuri Apr 29, 2026

Choose a reason for hiding this comment

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

I found that we are updating source amount here:

updateSourceAmounts(transactionId, current as never, this.messenger);

But despite zero amount we send request to api.

I think we can simplify code added in this PR to just check if all sourceAmounts are '0' we do not send request.

@jpuri jpuri requested a review from matthewwalsh0 April 29, 2026 09:04
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 29ae3c9. Configure here.

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