Skip to content

fix: fix NFT balance in send flow #31239

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

Merged
merged 1 commit into from
Apr 7, 2025
Merged

Conversation

sahar-fehri
Copy link
Contributor

@sahar-fehri sahar-fehri commented Mar 24, 2025

Description

Fixes balance for NFTs in send flow.

Open in GitHub Codespaces

Related issues

Fixes: #28298

Manual testing steps

  1. Go to this page...

Screenshots/Recordings

Before

Please see video in issue 🙏

After

Screen.Recording.2025-03-24.at.12.40.35.mov

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.

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.

@@ -2731,9 +2732,7 @@ export function updateSendAsset(

if (isCurrentOwner) {
asset.error = null;
asset.balance = details.balance
? addHexPrefix(details.balance)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Using addHexPrefix is what triggered the bug in the NFT send flow.
When deploying a tokenId 1 and 2 with amount 10 and 15
using addHexPrefix resulted in the balance being 0x10 and 0x15.
In the AssetBalanceText component we will calculate the number of tokens of nfts
const numberOfTokens = hexToDecimal(asset.balance || '0x0');
Which results in numberOfTokens being 16 and 21 instead of 10 and 15

@sahar-fehri sahar-fehri marked this pull request as ready for review March 24, 2025 11:39
@metamaskbot
Copy link
Collaborator

Builds ready [862b93d]
Page Load Metrics (2829 ± 360 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint38042912416856411
domContentLoaded181239802324470226
load186946092829751360
domInteractive28152503115
backgroundConnect871567515424204
firstReactRender201112162227109
getState181048214234112
initialActions021152
loadScripts131124831619252121
setupStore111895199407195
uiStartup256420359629945882203
Bundle size diffs [🚨 Warning! Bundle size has increased!]
  • background: 0 Bytes (0.00%)
  • ui: 0 Bytes (0.00%)
  • common: 142 Bytes (0.00%)

@sahar-fehri sahar-fehri added this pull request to the merge queue Mar 25, 2025
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Mar 25, 2025
@sahar-fehri sahar-fehri added this pull request to the merge queue Apr 7, 2025
github-merge-queue bot pushed a commit that referenced this pull request Apr 7, 2025
## **Description**

Fixes balance for NFTs in send flow.

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

## **Related issues**

Fixes: #28298

## **Manual testing steps**

1. Go to this page...
2.
3.

## **Screenshots/Recordings**

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

### **Before**

<!-- [screenshots/recordings] -->
Please see video in issue 🙏 

### **After**

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



https://github.com/user-attachments/assets/eec659f1-4201-4999-9952-b76877cc365b



## **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/main/.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/main/.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.
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Apr 7, 2025
@sahar-fehri sahar-fehri added this pull request to the merge queue Apr 7, 2025
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Apr 7, 2025
@sahar-fehri sahar-fehri added this pull request to the merge queue Apr 7, 2025
Merged via the queue into main with commit 9751219 Apr 7, 2025
120 checks passed
@sahar-fehri sahar-fehri deleted the fix/fix-nft-balance-in-send-flow branch April 7, 2025 14:28
@github-actions github-actions bot locked and limited conversation to collaborators Apr 7, 2025
@metamaskbot metamaskbot added the release-12.17.0 Issue or pull request that will be included in release 12.17.0 label Apr 7, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
release-12.17.0 Issue or pull request that will be included in release 12.17.0 team-assets
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug]: Assets Balance - The balance for my ERC1155 token is incorrect in the Send flow screen
4 participants