You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix(tron): keep TRC-20 amounts as strings through dApp sign path
decodeTronTx was holding the decoded TRC-20 amount as BigInt, then
casting to Number before stashing it on DecodedTronTx.sunAmount and
passing it to signTronViaRest + the approval event. Any 18-decimal
token (most non-stablecoin TRC-20s) exceeds Number.MAX_SAFE_INTEGER
in base units, so the value silently rounds before the vault sees it
— firmware displays the wrong amount on-device and the signed tx
spends the wrong amount on-chain.
Changes:
- DecodedTronTx.sunAmount (number) → amountRaw (decimal string).
Renamed to signal "this is base units not native sun".
- TransferContract decode emits String(v.amount); TRC-20 decode emits
BigInt.toString(); contract-call emits String(callValue). All paths
preserve precision.
- signTronViaRest signature widened to `string | number | bigint`.
Internal stringification uses bigint.toString() when applicable so
nothing re-enters the Number casting path.
- Approval event now carries amountRaw (not sun) so downstream UIs
that display the raw-unit hint get the untruncated value.
Native TRX amounts never overflow Number (max 90B TRX in sun = 9e16,
fits in 2^53 comfortably), but the change makes that path uniform
and the code easier to audit.
Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
0 commit comments