Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Max balance for dApp erc20 approval #13881

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Conversation

pedronfigueiredo
Copy link
Contributor

@pedronfigueiredo pedronfigueiredo commented Mar 6, 2025

Description

When the user clicks "Max" on ERC20 token approvals, the account token balance is set as the spending cap. However, this number is rounded to 5 decimals places, which sometimes results in a value smaller than the actual token balance.

This PR fixes this bug by setting the unrounded account token balance instead.

Related issues

Fixes: #13122

Manual testing steps

  1. Go to this page...

Screenshots/Recordings

Before

After

Screenshot 2025-03-06 at 14 00 32

Pre-merge author checklist

Pre-merge reviewer checklist

  • I've manually tested the PR (e.g. pull and build branch, run the app, test code being changed).
  • I confirm that this PR addresses all acceptance criteria described in the ticket it closes and includes the necessary testing evidence such as recordings and or screenshots.

@pedronfigueiredo pedronfigueiredo added the team-confirmations Push issues to confirmations team label Mar 6, 2025
@pedronfigueiredo pedronfigueiredo self-assigned this Mar 6, 2025
@pedronfigueiredo pedronfigueiredo requested review from a team as code owners March 6, 2025 14:05
Copy link
Contributor

github-actions bot commented Mar 6, 2025

CLA Signature Action: All authors have signed the CLA. You may need to manually re-run the blocking PR check if it doesn't pass in a few minutes.

@pedronfigueiredo pedronfigueiredo added the Run Smoke E2E Triggers smoke e2e on Bitrise label Mar 6, 2025
Copy link
Contributor

github-actions bot commented Mar 6, 2025

https://bitrise.io/ Bitrise

✅✅✅ pr_smoke_e2e_pipeline passed on Bitrise! ✅✅✅

Commit hash: ed9a2e3
Build link: https://app.bitrise.io/app/be69d4368ee7e86d/pipelines/1acbcf0f-3f53-4063-8491-7f61862c7cd5

Note

  • You can kick off another pr_smoke_e2e_pipeline on Bitrise by removing and re-applying the Run Smoke E2E label on the pull request

@pedronfigueiredo pedronfigueiredo added Run Smoke E2E Triggers smoke e2e on Bitrise and removed Run Smoke E2E Triggers smoke e2e on Bitrise labels Mar 6, 2025
Copy link
Contributor

github-actions bot commented Mar 6, 2025

https://bitrise.io/ Bitrise

❌❌❌ pr_smoke_e2e_pipeline failed on Bitrise! ❌❌❌

Commit hash: 8527fc0
Build link: https://app.bitrise.io/app/be69d4368ee7e86d/pipelines/f8a5224d-ff56-4f0d-9b36-577449d68feb

Note

  • You can kick off another pr_smoke_e2e_pipeline on Bitrise by removing and re-applying the Run Smoke E2E label on the pull request

Tip

  • Check the documentation if you have any doubts on how to understand the failure on bitrise

@pedronfigueiredo pedronfigueiredo added Run Smoke E2E Triggers smoke e2e on Bitrise and removed Run Smoke E2E Triggers smoke e2e on Bitrise labels Mar 6, 2025
Copy link
Contributor

@digiwand digiwand left a comment

Choose a reason for hiding this comment

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

added a suggestion to remove conditional

It could also be helpful to add tests to check the full balance is shown

Comment on lines +79 to +80
if (maxSelected) setValue(unroundedAccountBalance || accountBalance);
}, [maxSelected, accountBalance, unroundedAccountBalance]);
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
if (maxSelected) setValue(unroundedAccountBalance || accountBalance);
}, [maxSelected, accountBalance, unroundedAccountBalance]);
if (maxSelected) setValue(unroundedAccountBalance);
}, [maxSelected, unroundedAccountBalance]);

I think we may no longer need accountBalance. Else I think since unroundedAccountBalance may be an empty string, || accountBalance may never be reached

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Run Smoke E2E Triggers smoke e2e on Bitrise team-confirmations Push issues to confirmations team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug]: Clicking on Max button in approval confirmation results in infinite dapp approval requests
2 participants