Commit e041f09
authored
fix: use Fr.fromString for CLI wallet claim params to handle decimal values (#22197)
## Summary
Fixes incorrect parsing of `--payment` claim parameters in the CLI
wallet when using the explicit long form:
```
--payment method=fee_juice,claimAmount=123,claimSecret=0xabc,messageLeafIndex=42
```
**Bug**: `Fr.fromHexString()` was used to parse `claimAmount`, which
interprets bare numeric strings as hex. When a user copy-pastes the
output of `bridge-fee-juice` (which prints `claimAmount` as a decimal
bigint like `1000000000000000000`), it would be silently misinterpreted
as a hex value, resulting in a completely wrong claim amount.
**Fix**: Switch to `Fr.fromString()` which correctly auto-detects
decimal vs hex (0x-prefixed) input. Also adds a type guard for
`claimSecret` to handle both the DB path (which returns a string) and
the direct CLI path uniformly.
## Changes
- `Fr.fromHexString(claimAmount)` → `Fr.fromString(claimAmount)` —
handles decimal amounts correctly
- `Fr.fromHexString(claimSecret)` → `Fr.fromString(claimSecret)` with
type guard — consistent handling for both DB and CLI paths
## Test plan
- Verify `deploy-account --payment
method=fee_juice,claimAmount=1000000000000000000,claimSecret=0xabc...,messageLeafIndex=42`
correctly parses the decimal amount
- Verify `deploy-account --payment method=fee_juice,claim` (DB-backed
short form) still works unchanged
- Verify hex-prefixed values like `claimAmount=0x1234` still work
correctly
ClaudeBox log: https://claudebox.work/s/7737b856f8012542?run=21 file changed
Lines changed: 2 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
158 | 158 | | |
159 | 159 | | |
160 | 160 | | |
161 | | - | |
| 161 | + | |
162 | 162 | | |
163 | 163 | | |
164 | | - | |
| 164 | + | |
165 | 165 | | |
166 | 166 | | |
167 | 167 | | |
| |||
0 commit comments