refactor(wallet): migrate to strict parseTokenAmount + drop dup currency util (S2, #611)#383
Merged
Merged
Conversation
…ount; drop dup currency util Adopts sphere-sdk 0.10.3 (parseTokenAmount/safeParseTokenAmount; lenient toSmallestUnit removed). - Bump @unicitylabs/sphere-sdk 0.10.2 -> 0.10.3. - Submit/build paths -> parseTokenAmount (throws on invalid; caught as a clean error): SendModal (handleSend), SendPaymentRequestModal (handleSend), SwapModal (handleSwap), useTopUp. - Live/keystroke/render paths -> safeParseTokenAmount (null = not a valid amount; no crash, no silent 0n): SendModal (validate + insufficient-balance), SendPaymentRequestModal (validate). - Delete duplicate src/components/wallet/L3/utils/currency.ts (dead CurrencyUtils copy + lossy parseFloat-based AmountFormatUtils.formatDisplayAmount); PaymentRequestModal now uses SDK formatAmount. Part of #611 (track S2).
igmahl
approved these changes
Jun 18, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Migrates the Sphere wallet to the strict amount parser shipped in
sphere-sdk@0.10.3(parseTokenAmount/safeParseTokenAmount), and removes a duplicate currency util. Part of #611 — track S2.sphere-sdk@0.10.3removed the lenienttoSmallestUnit(silent0n/ truncation). This PR bumps the SDK pin and migrates every call site.Changes
@unicitylabs/sphere-sdk0.10.2→0.10.3.parseTokenAmount(throws on invalid; caught by the existingtry/catchas a clean error):SendModal(handleSend),SendPaymentRequestModal(handleSend),SwapModal(handleSwap),useTopUp.safeParseTokenAmount(null= not a valid amount → button disabled / no proceed; no crash, no silent0n):SendModal(handleDetailsNextvalidation + the render-time insufficient-balance check),SendPaymentRequestModal(validation).src/components/wallet/L3/utils/currency.ts— a dead duplicate of the SDK helpers (CurrencyUtils, unused) plus a lossyparseFloat/Math.powAmountFormatUtils.formatDisplayAmount(its single consumer,PaymentRequestModal, now uses the SDK's bigint-safeformatAmount).Verification
tsc -b→ clean (exit 0). It caught one real bug during migration —useTopUppassed anumberto the now string-only parser; fixed withString(human).eslint→ clean.Notes
sphere-extensionis out of scope (deprecated; keeps its own currency copy).