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: 0 token balance in send flow #28136

Merged
merged 1 commit into from
Oct 29, 2024
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
2 changes: 1 addition & 1 deletion ui/ducks/send/send.js
Original file line number Diff line number Diff line change
Expand Up @@ -2670,7 +2670,7 @@ export function updateSendAsset(

if (details.standard === TokenStandard.ERC20) {
asset.balance =
details.balance && typeof details.decimals === 'number'
details.balance && details.decimals !== undefined
Copy link
Contributor Author

Choose a reason for hiding this comment

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

or maybe parseInt(details.decimals) >= 0. I'm not sure when this can be something unexpected. The number check was introduced to replace a truthiness check, which did not work for 0 decimal tokens.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I did verify this PR still works for 0 decimal tokens

Copy link
Contributor

Choose a reason for hiding this comment

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

This will also be false when balance === 0 - should change the details.balance to typeof details.balance, or is it typed well enough that we know that details.balance is never a number representation?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I dont really know. Trying to make minimal changes when hotfixing things. The decimal check is the only bit that changed recently.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

its true that balance is a string in every place i can reproduce though

? addHexPrefix(
calcTokenAmount(details.balance, details.decimals).toString(16),
)
Expand Down
Loading