chore(card): migrate Card BigInt usage to new library#29679
Conversation
|
CLA Signature Action: All authors have signed the CLA. You may need to manually re-run the blocking PR check if it doesn't pass in a few minutes. |
🔍 Smart E2E Test Selection
click to see 🤖 AI reasoning detailsE2E Test Selection:
These are pure refactoring changes within the Card feature. The Card delegation flow (spending limit increases via ERC20 approve transactions) and asset balance display are the affected user flows. These are covered by SmokeMoney tests. No shared infrastructure (navigation, TabBar, confirmations modal system, Engine) is modified. The changes don't affect any other feature areas. The test files confirm the new import paths are already updated to match. Performance Test Selection: |
|



Description
This change migrates Card feature hooks from the legacy BN.js /
app/util/numberhelpers to the native BigInt module atapp/util/number/bigint, following the repository bigint migration guide.Reason: Reduce BN.js usage, align Card code with the bigint utilities, and keep behavior equivalent for balances, delegation amounts, and gas-faucet checks.
What changed:
useAssetBalances.tsx— importbalanceToFiatNumberfromutil/number/bigint; test mock updated to match.useCardDelegation.ts— importtoTokenMinimalUnitfromutil/number/bigint; tests mockbigintreturn values instead of decimal strings.useNeedsGasFaucet.ts— removebnjs4; usehexToBigIntfor wei gas price and balance; compare with native<; multiply withBigInt(gasLimitWithBuffer); castdecGWEIToHexWEIresult tostringfor TypeScript (legacyconversionUtilunion type).Changelog
CHANGELOG entry: null
Related issues
No issue: internal refactor (Card BigInt burndown / migration guide).
Manual testing steps
Screenshots/Recordings
Before
N/A
After
N/A
Pre-merge author checklist
Performance checks (if applicable)
trace()for usage andaddTokenfor an exampleFor performance guidelines and tooling, see the Performance Guide.
Pre-merge reviewer checklist
Note
Medium Risk
Touches Card delegation amount conversion and EVM gas-faucet checks by switching from BN/string math to
bigint, which could change edge-case numeric behavior and transaction approval amounts if not equivalent.Overview
Migrates Card hooks off legacy
app/util/number/ BN usage ontoapp/util/number/bigintutilities.useAssetBalancesnow uses bigint-basedbalanceToFiatNumberfor fiat calculations,useCardDelegationswitchestoTokenMinimalUnitto returnbigint(with tests updated to expectbigint), anduseNeedsGasFaucetremoves BN math in favor ofhexToBigIntand nativebigintarithmetic/comparisons for EVM gas-fee estimation and balance checks.Reviewed by Cursor Bugbot for commit 42a64d9. Bugbot is set up for automated code reviews on this repo. Configure here.