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 (cherry-pick): 0 token balance in send flow (#28136) #28151

Merged
merged 1 commit into from
Oct 29, 2024

Conversation

danjm
Copy link
Contributor

@danjm danjm commented Oct 29, 2024

Cherry-picks #28136 (1fd9510). Original PR description:

Description

Fixes an issue where token balance showed as 0 during send flow. This occurred when clicking the token in the token list, then clicking the send button from the token details page.

When going send first and then picking a token, picking decimals was a number:

image

But when going token first and then clicking send , decimals was a string and skipped calculating the balance.

image

calcTokenAmount seems to work with either string or number, so changing logic from
#27083 which introduced the number check

Open in GitHub Codespaces

Related issues

Fixes: #28112

Manual testing steps

  1. Click on an erc20 token on the token list
  2. Click the send button on the token details page
  3. Choose a destination account
  4. The balance under the asset picker should be accurate

Screenshots/Recordings

Before

After

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.

Description

Open in GitHub Codespaces

Related issues

Fixes:

Manual testing steps

  1. Go to this page...

Screenshots/Recordings

Before

After

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.

## **Description**

Fixes an issue where token balance showed as 0 during send flow. This
occurred when clicking the token in the token list, then clicking the
send button from the token details page.

When going send first and then picking a token, picking `decimals` was a
number:


![image](https://github.com/user-attachments/assets/95d32a68-1076-4050-b129-187672694794)

But when going token first and then clicking send , `decimals` was a
string and skipped calculating the balance.


![image](https://github.com/user-attachments/assets/99a8fcd4-bd29-4969-b98d-6639d50553ff)


`calcTokenAmount` seems to work with either string or number, so
changing logic from
#27083 which
introduced the number check


[![Open in GitHub
Codespaces](https://github.com/codespaces/badge.svg)](https://codespaces.new/MetaMask/metamask-extension/pull/28136?quickstart=1)

## **Related issues**

Fixes: #28112

## **Manual testing steps**

1. Click on an erc20 token on the token list
2. Click the send button on the token details page
3. Choose a destination account
4. The balance under the asset picker should be accurate

## **Screenshots/Recordings**

<!-- If applicable, add screenshots and/or recordings to visualize the
before and after of your change. -->

### **Before**

<!-- [screenshots/recordings] -->

### **After**

<!-- [screenshots/recordings] -->

## **Pre-merge author checklist**

- [ ] I've followed [MetaMask Contributor
Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask
Extension Coding
Standards](https://github.com/MetaMask/metamask-extension/blob/develop/.github/guidelines/CODING_GUIDELINES.md).
- [ ] I've completed the PR template to the best of my ability
- [ ] I’ve included tests if applicable
- [ ] I’ve documented my code using [JSDoc](https://jsdoc.app/) format
if applicable
- [ ] I’ve applied the right labels on the PR (see [labeling
guidelines](https://github.com/MetaMask/metamask-extension/blob/develop/.github/guidelines/LABELING_GUIDELINES.md)).
Not required for external contributors.

## **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.
@danjm danjm requested a review from a team as a code owner October 29, 2024 13:47
Copy link
Contributor

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.

@metamaskbot
Copy link
Collaborator

Builds ready [13a3537]
Page Load Metrics (1930 ± 125 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint31223931760533256
domContentLoaded152623851903257124
load158423931930260125
domInteractive247742178

@danjm danjm merged commit d7108ed into Version-v12.5.1 Oct 29, 2024
74 of 76 checks passed
@danjm danjm deleted the cherry-pick-1fd9510 branch October 29, 2024 17:08
@github-actions github-actions bot locked and limited conversation to collaborators Oct 29, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants