Skip to content

Commit e041f09

Browse files
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=2
2 parents 9ce04f0 + ee627fa commit e041f09

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

  • yarn-project/cli-wallet/src/utils/options

yarn-project/cli-wallet/src/utils/options/fees.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -158,10 +158,10 @@ export function parsePaymentMethod(
158158
const { FeeJuicePaymentMethodWithClaim } = await import('@aztec/aztec.js/fee');
159159
return new FeeJuicePaymentMethodWithClaim(from, {
160160
claimAmount: (typeof claimAmount === 'string'
161-
? Fr.fromHexString(claimAmount)
161+
? Fr.fromString(claimAmount)
162162
: new Fr(claimAmount)
163163
).toBigInt(),
164-
claimSecret: Fr.fromHexString(claimSecret),
164+
claimSecret: typeof claimSecret === 'string' ? Fr.fromString(claimSecret) : claimSecret,
165165
messageLeafIndex: BigInt(messageLeafIndex),
166166
});
167167
} else {

0 commit comments

Comments
 (0)