-
Notifications
You must be signed in to change notification settings - Fork 7
SHARD-2738: value display fix for erc20 #92
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
base: dev
Are you sure you want to change the base?
Conversation
PR Reviewer Guide 🔍Here are some key observations to aid the review process:
|
| const decimalsValue = tokenTx.contractInfo.decimals && !isNaN(parseInt(tokenTx.contractInfo.decimals)) | ||
| ? parseInt(tokenTx.contractInfo.decimals) | ||
| : 18 | ||
|
|
||
| return tokenTx.tokenValue === '0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff' | ||
| ? 'unlimited' | ||
| : fullValue | ||
| ? utils.formatUnits(tokenTx.tokenValue, decimalsValue) | ||
| : roundTokenValue(utils.formatUnits(tokenTx.tokenValue, decimalsValue)) | ||
| ? formatUnits(tokenTx.tokenValue, decimalsValue) | ||
| : roundTokenValue(formatUnits(tokenTx.tokenValue, decimalsValue)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggestion: Ensure that tokenTx.tokenValue is a valid string or BigNumber before passing it to formatUnits, as invalid input may cause runtime errors. Add a check to handle undefined or null values for tokenTx.tokenValue. [possible issue, importance: 7]
| const decimalsValue = tokenTx.contractInfo.decimals && !isNaN(parseInt(tokenTx.contractInfo.decimals)) | |
| ? parseInt(tokenTx.contractInfo.decimals) | |
| : 18 | |
| return tokenTx.tokenValue === '0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff' | |
| ? 'unlimited' | |
| : fullValue | |
| ? utils.formatUnits(tokenTx.tokenValue, decimalsValue) | |
| : roundTokenValue(utils.formatUnits(tokenTx.tokenValue, decimalsValue)) | |
| ? formatUnits(tokenTx.tokenValue, decimalsValue) | |
| : roundTokenValue(formatUnits(tokenTx.tokenValue, decimalsValue)) | |
| const decimalsValue = tokenTx.contractInfo.decimals && !isNaN(parseInt(tokenTx.contractInfo.decimals)) | |
| ? parseInt(tokenTx.contractInfo.decimals) | |
| : 18 | |
| if (!tokenTx.tokenValue) { | |
| return '0'; | |
| } | |
| return tokenTx.tokenValue === '0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff' | |
| ? 'unlimited' | |
| : fullValue | |
| ? formatUnits(tokenTx.tokenValue, decimalsValue) | |
| : roundTokenValue(formatUnits(tokenTx.tokenValue, decimalsValue)) |
PR Type
Bug fix, Enhancement
Description
Fixed ERC20 value display for transactions with invalid decimals.
Replaced deprecated
utils.formatUnitswithformatUnitsfrom ethers.Improved handling of decimals parsing for ERC20 tokens.
Ensured correct value formatting for ERC20 and EVM_Internal tokens.
Changes walkthrough 📝
calculateValue.ts
Fix and enhance ERC20 value formatting logicsrc/frontend/utils/calculateValue.ts
utils.formatUnitswithformatUnitsfrom ethers.