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
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions ui/ducks/send/send.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {
TransactionEnvelopeType,
TransactionType,
} from '@metamask/transaction-controller';
import { toHex } from '@metamask/controller-utils';
import { getErrorMessage } from '../../../shared/modules/error';
import {
decimalToHex,
Expand Down Expand Up @@ -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

: '0x1';
asset.balance = details.balance ? toHex(details.balance) : '0x1';
} else {
throw new Error(
'Send slice initialized as NFT send with an NFT not currently owned by the select account',
Expand Down
Loading