Skip to content

fix: convert direct amount string to wei#376

Merged
onahprosper merged 1 commit intomainfrom
fix-for-migration-amount-error
Feb 20, 2026
Merged

fix: convert direct amount string to wei#376
onahprosper merged 1 commit intomainfrom
fix-for-migration-amount-error

Conversation

@Dprof-in-tech
Copy link
Copy Markdown
Collaborator

@Dprof-in-tech Dprof-in-tech commented Feb 20, 2026

Description

This pull request makes a minor update to the WalletTransferApprovalModal component. 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.

  • Updated the conversion of token.amount to use toString() instead of toFixed(token.decimals) before passing it to parseUnits, improving precision for small token amounts in WalletTransferApprovalModal.tsx.

References

THIS FIXES THE FAILING TRANSACTIONS WHEN TRYING TO MIGRATE VERY SMALL TOKEN AMOUNTS

Testing

  • This change adds test coverage for new/changed/fixed functionality

Checklist

  • I have added documentation and tests for new/changed functionality in this PR
  • All active GitHub checks for tests, formatting, and security are passing
  • The correct base branch is being used, if not main

By submitting a PR, I agree to Paycrest's Contributor Code of Conduct and Contribution Guide.

Summary by CodeRabbit

  • Bug Fixes
    • Improved numeric precision handling for token transfer amounts to ensure accurate calculations, particularly when dealing with very small or very large token values.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Feb 20, 2026

📝 Walkthrough

Walkthrough

Modified WalletTransferApprovalModal.tsx to change how token transfer amounts are serialized. Replaced token.amount.toFixed(token.decimals) with token.amount.toString(), altering the numeric representation before conversion via parseUnits, while maintaining the same downstream control flow.

Changes

Cohort / File(s) Summary
Token Amount Serialization
app/components/WalletTransferApprovalModal.tsx
Changed amount string computation from toFixed(token.decimals) to toString(), affecting precision representation for token transfer values.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Suggested reviewers

  • chibie
  • 5ran6
  • onahprosper

Poem

🐰 A hop, a skip, a string so true,
From fixed decimals to a cleaner view,
The amounts now dance in simpler form,
parseUnits shall keep them warm! ✨

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main change: converting token amount to string directly before parsing to wei, which aligns with the code modification from toFixed to toString.
Description check ✅ Passed The description includes required sections (Description, References, Testing, Checklist) with sufficient detail about the change and its purpose, though test coverage was not added as noted by the unchecked checkbox.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix-for-migration-amount-error

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

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.

Comment thread app/components/WalletTransferApprovalModal.tsx
@onahprosper onahprosper merged commit e3ccadb into main Feb 20, 2026
1 check passed
@onahprosper onahprosper deleted the fix-for-migration-amount-error branch February 20, 2026 13:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants