Skip to content

fix(visualsign): render number fields as amount_v2 (VSP has no number type)#393

Open
prasanna-anchorage wants to merge 2 commits into
mainfrom
fix/number-fields-amount-v2
Open

fix(visualsign): render number fields as amount_v2 (VSP has no number type)#393
prasanna-anchorage wants to merge 2 commits into
mainfrom
fix/number-fields-amount-v2

Conversation

@prasanna-anchorage

Copy link
Copy Markdown
Contributor

VSP defines no number field type — the HSM vsp.py enum and the iOS decoder recognize text_v2, address_v2, **amount_v2**, preview_layout, list_layout, delta, accordion, diagnostic, divider. So a number field decoded to .unknown and surfaced as unsupported.

This serializes the Number variant as amount_v2 on the wire: amount = the numeric value, abbreviation = the unit (empty for unitless numbers — iOS parseAmount accepts an empty abbreviation). The in-memory Number variant and the create_number_field helper are unchanged (callers + variant-matching tests keep working); only the wire output changes. Covers every number producer (compute_budget, system, token_2022, jupiter_swap, …).

Replaces #390 (which used the legacy fix/number-fields-text-v2 branch name and an earlier text_v2 approach).

🤖 Generated with Claude Code

…ber` type)

VSP defines no `number` field type (HSM vsp.py + iOS decoder list text_v2,
address_v2, amount_v2, preview_layout, list_layout, delta, accordion,
diagnostic, divider) -- numeric values are `amount_v2`. Previously a `number`
field decoded to `.unknown` and surfaced as unsupported.

Serialize the `Number` variant as `amount_v2` at the wire layer: amount = the
numeric value, abbreviation = the unit (empty for unitless numbers, which iOS
renders fine -- parseAmount accepts an empty abbreviation). The in-memory
`Number` variant and `create_number_field` helper are unchanged, so callers and
variant-matching tests keep working; only the wire output changes. This covers
every `number` producer (compute_budget, system, token_2022, jupiter_swap, ...).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…tion

The Compute Unit Limit / Price per Compute Unit fields now serialize as
amount_v2 (amount + abbreviation derived from fallback text) instead of
the removed `number` type. Updates the two fixture blocks accordingly.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings June 23, 2026 05:44

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Updates VisualSign field serialization to avoid emitting the unsupported number wire type by serializing SignablePayloadField::Number as amount_v2, aligning with VSP’s supported field types and ensuring Solana “number” producers (e.g., compute budget fields, slippage) no longer decode as unknown/unsupported.

Changes:

  • Serialize SignablePayloadField::Number as amount_v2, deriving AmountV2.abbreviation from fallback_text.
  • Update CLI expected-display fixture output to reflect amount_v2 + AmountV2 payload instead of number + Number.
  • Update Jupiter swap preset test to assert Slippage serializes as amount_v2 on the wire.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
src/visualsign/src/lib.rs Changes Number-field serialization to emit amount_v2 wire shape and updates expected-field verification accordingly.
src/parser/cli/tests/fixtures/solana-json.display.expected Updates expected JSON fixture output for compute-budget number fields to the new amount_v2 representation.
src/chain_parsers/visualsign-solana/src/presets/jupiter_swap/mod.rs Adjusts serialization assertions in tests to match the new wire Type for slippage.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/visualsign/src/lib.rs
Comment on lines +276 to +279
let amount_v2 = SignablePayloadFieldAmountV2 {
amount: number.number.clone(),
abbreviation: Some(abbreviation),
};
Comment thread src/visualsign/src/lib.rs
Comment on lines +334 to 336
// Serialized as `amount_v2` under the hood (see `serialize_to_map`).
SignablePayloadField::Number { .. } => base_fields.push("AmountV2"),
SignablePayloadField::Amount { .. } => base_fields.push("Amount"),
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants