Bug: TransferForm crashes on large amounts — BigInt cannot convert scientific notation #95

Closed
opened 2026-04-01 04:14:56 +00:00 by Brouie · 8 comments
Brouie commented 2026-04-01 04:14:56 +00:00 (Migrated from gitlab.com)

entering 1000 TKNA on Anvil->Solana crashes the entire TransferForm component. the scaled amount becomes 1e+21 (scientific notation) which BigInt() cannot parse.

error: Uncaught SyntaxError: Cannot convert 1e+21 to a BigInt (at TransferForm.tsx:781:20)

the UI goes blank (only background visible). no error boundary catches it.

fix: use a BigInt-safe conversion that handles scientific notation, e.g. BigInt(Math.round(Number(value))) or a string-based approach that avoids Number coercion to scientific notation.

commit 003bf31, laptop Vite workflow.

entering 1000 TKNA on Anvil->Solana crashes the entire TransferForm component. the scaled amount becomes 1e+21 (scientific notation) which BigInt() cannot parse. error: Uncaught SyntaxError: Cannot convert 1e+21 to a BigInt (at TransferForm.tsx:781:20) the UI goes blank (only background visible). no error boundary catches it. fix: use a BigInt-safe conversion that handles scientific notation, e.g. BigInt(Math.round(Number(value))) or a string-based approach that avoids Number coercion to scientific notation. commit 003bf31, laptop Vite workflow.
Brouie commented 2026-04-01 04:35:08 +00:00 (Migrated from gitlab.com)

mentioned in issue #90

mentioned in issue #90
Brouie commented 2026-04-01 04:55:41 +00:00 (Migrated from gitlab.com)

mentioned in issue #96

mentioned in issue #96
PlasticDigits commented 2026-04-01 11:42:28 +00:00 (Migrated from gitlab.com)

mentioned in commit e9d9a2e1b0

mentioned in commit e9d9a2e1b04442471b1c91bd39a412a62cb2a782
PlasticDigits commented 2026-04-01 11:48:29 +00:00 (Migrated from gitlab.com)

mentioned in commit 02fac941c3

mentioned in commit 02fac941c375fd51b637cf42b9ed14e45085b914
Brouie commented 2026-04-02 04:39:26 +00:00 (Migrated from gitlab.com)

still reproducing on 02d8e6a. tested Anvil->Solana with TKNA (2.985, max amount).

TransferForm.tsx:781 crashes with: Cannot convert 4.999005e+23 to a BigInt

the new bigintAmount.ts and scientificDecimal.ts utils were added in this build but TransferForm.tsx:781 is still calling raw BigInt() on a number in scientific notation. the util needs to be wired into TransferForm where the conversion happens.

note: this triggers even on small amounts (2.985 TKNA) because the underlying wei value (2985000000000000000 * fee math) produces scientific notation in JS before the BigInt() call.

still reproducing on 02d8e6a. tested Anvil->Solana with TKNA (2.985, max amount). TransferForm.tsx:781 crashes with: Cannot convert 4.999005e+23 to a BigInt the new bigintAmount.ts and scientificDecimal.ts utils were added in this build but TransferForm.tsx:781 is still calling raw BigInt() on a number in scientific notation. the util needs to be wired into TransferForm where the conversion happens. note: this triggers even on small amounts (2.985 TKNA) because the underlying wei value (2985000000000000000 * fee math) produces scientific notation in JS before the BigInt() call.
PlasticDigits commented 2026-04-02 12:02:53 +00:00 (Migrated from gitlab.com)

mentioned in commit df7e0664e3

mentioned in commit df7e0664e34a79d291b0d02c003faa7c1eabd7b5
PlasticDigits commented 2026-04-02 12:03:28 +00:00 (Migrated from gitlab.com)

Pushed fix in df7e066 on feat/solana-integration: receive amount now uses bigint fee math (same as Solana record path) instead of parseFloat scaling, and parseAmountAsBigInt delegates to bigintFromBaseUnitsString for the final conversion. Please re-test Anvil→Solana with TKNA / max. Issue stays open until you confirm.

Pushed fix in df7e066 on `feat/solana-integration`: receive amount now uses bigint fee math (same as Solana record path) instead of `parseFloat` scaling, and `parseAmountAsBigInt` delegates to `bigintFromBaseUnitsString` for the final conversion. Please re-test Anvil→Solana with TKNA / max. Issue stays open until you confirm.
Brouie commented 2026-04-04 03:19:52 +00:00 (Migrated from gitlab.com)

verified on 84c8df3. large amount transfers work without the BigInt scientific notation crash. the bigint fee math fix resolved it. closing.

verified on 84c8df3. large amount transfers work without the BigInt scientific notation crash. the bigint fee math fix resolved it. closing.
Brouie (Migrated from gitlab.com) closed this issue 2026-04-04 03:19:52 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
code/cl8y-bridge-monorepo#95
No description provided.