-
Notifications
You must be signed in to change notification settings - Fork 7
SHARD-2738: populate token dropdown, fix conversion errors #93
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:
|
| <MenuItem | ||
| key={index} | ||
| label={row.balance} | ||
| label2={row?.contractInfo?.name || row.contractAddress} |
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 row.contractInfo is not null before accessing name to avoid potential runtime errors if contractInfo is null. This prevents possible crashes when rendering the dropdown. [possible issue, importance: 7]
| label2={row?.contractInfo?.name || row.contractAddress} | |
| label2={row?.contractInfo && row.contractInfo.name ? row.contractInfo.name : row.contractAddress} |
| contractInfo: accountExist?.contractInfo || null, | ||
| contractType: accountExist?.contractType || null, |
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: Returning null for contractType may cause issues if downstream code expects a valid contract type. Consider only including tokens with a valid contractType to avoid propagating invalid data. [possible issue, importance: 6]
| contractInfo: accountExist?.contractInfo || null, | |
| contractType: accountExist?.contractType || null, | |
| if (accountExist && accountExist.contractType) { | |
| filterTokens.push({ | |
| contractAddress: contractAddress, | |
| contractInfo: accountExist?.contractInfo || null, | |
| contractType: accountExist.contractType, | |
| balance: tokenValue, | |
| }) | |
| } |
PR Type
Bug fix, Enhancement
Description
Fix ERC-20 token balance formatting and null checks throughout frontend
Improve robustness for missing or null contract info in token handling
Display correct ERC-20 token count and fallback names in dropdown
Update backend token query to handle missing contract info gracefully
Changes walkthrough 📝
useAccountDetailHook.ts
Improve token balance formatting and null safetysrc/frontend/account/AccountDetail/useAccountDetailHook.ts
formatUnitsfrom ethers for balance formattingcontractInfoandtokensarrayToken.tsx
Use formatUnits and add null checks in Token pagesrc/frontend/token/Token.tsx
utils.formatUnitswithformatUnitsfor balance/supplyOvewview.tsx
Null-safe contract name display in transaction overviewsrc/frontend/transaction/TransactionDetail/Overview/Ovewview.tsx
contractInfo.namein token displaycalculateValue.ts
Use formatUnits and null checks in value calculationsrc/frontend/utils/calculateValue.ts
formatUnitsfor ERC-20/EVM_Internal value formattingaccount.ts
Null-safe contract info in token query backendsrc/storage/account.ts
contractInfoandcontractTypeTokenDropdown.tsx
Fix token count and fallback name in dropdownsrc/frontend/account/TokenDropdown/TokenDropdown.tsx
contractInfo