fix: convert direct amount string to wei#376
Conversation
📝 WalkthroughWalkthroughModified Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@app/components/WalletTransferApprovalModal.tsx`:
- Around line 264-266: The current use of token.amount.toString() before
parseUnits causes scientific-notation strings (e.g., "1e-8") which parseUnits
rejects; change the conversion to use a fixed-point formatter
(token.amount.toFixed(token.decimals)) so strings never use scientific notation,
then detect and skip non-transferable dust by filtering out zero/empty amounts
(or mapping non-transferable cases to null and filtering nulls) before building
the calls array in the code that uses parseUnits (refer to token.amount,
token.decimals, parseUnits and the calls.map pipeline in
WalletTransferApprovalModal); optionally consider retaining the raw bigint
balance path long-term to avoid Number precision issues.
Description
This pull request makes a minor update to the
WalletTransferApprovalModalcomponent. The change updates how token amounts are converted to strings before being parsed to units, which helps ensure accuracy when dealing with very small values.token.amountto usetoString()instead oftoFixed(token.decimals)before passing it toparseUnits, improving precision for small token amounts inWalletTransferApprovalModal.tsx.References
THIS FIXES THE FAILING TRANSACTIONS WHEN TRYING TO MIGRATE VERY SMALL TOKEN AMOUNTS
Testing
Checklist
mainBy submitting a PR, I agree to Paycrest's Contributor Code of Conduct and Contribution Guide.
Summary by CodeRabbit