Skip to content

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

Closed
prasanna-anchorage wants to merge 1 commit into
mainfrom
fix/number-fields-text-v2
Closed

fix(visualsign): render number fields as amount_v2 (VSP has no number type)#390
prasanna-anchorage wants to merge 1 commit into
mainfrom
fix/number-fields-text-v2

Conversation

@prasanna-anchorage

Copy link
Copy Markdown
Contributor

Problem

The Anchorage wallet's Visual Signing Protocol engine has no number field type — its FieldType decoder recognizes only text_v2, address_v2, amount_v2, preview_layout, delta, highlight, rule, accordion, diagnostic. Any field emitted by create_number_field (compute_budget, system, token_2022, jupiter_swap, …) therefore decodes to .unknown and is surfaced as an unsupported field, also flagging its enclosing preview_layout as containsUnsupportedNestedFields.

Fix

Render the Number variant as text_v2 at the serialization layer (serialize_to_map/get_expected_fields), carrying the human value (incl. any unit) from fallback_text. The in-memory SignablePayloadField::Number variant and the create_number_field helper are unchanged — callers and variant-matching tests keep working; only the wire output changes. They stay visibly distinct from amount_v2 (these are not amounts).

General fix, independent of the DFlow render work.

Tests

cargo test -p visualsign -p visualsign-solana, clippy --all-targets -D warnings, cargo fmt --check pass. The one serialization-output assertion in jupiter_swap (Slippage field type) updated numbertext_v2.

🤖 Generated with Claude Code

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

This PR updates the Visual Signing Protocol JSON wire output so that SignablePayloadField::Number no longer serializes as a number field type (unsupported by Anchorage), and instead serializes as text_v2 while preserving the human-readable display value via fallback_text. This keeps the in-memory Rust enum variant unchanged while making emitted payloads compatible with the Anchorage wallet decoder.

Changes:

  • Serialize SignablePayloadField::Number as Type: "text_v2" and emit a TextV2 payload derived from common.fallback_text.
  • Update get_expected_fields so serialization verification expects TextV2 for the Number variant.
  • Adjust the Jupiter Swap serialization assertion to expect text_v2 on the wire for the Slippage field.

Reviewed changes

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

File Description
src/visualsign/src/lib.rs Changes Number serialization to emit text_v2 + TextV2 using fallback_text, and updates expected-field verification accordingly.
src/chain_parsers/visualsign-solana/src/presets/jupiter_swap/mod.rs Updates the JSON serialization test expectation for the Slippage field from number to text_v2.

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

@prasanna-anchorage prasanna-anchorage marked this pull request as draft June 23, 2026 05:19
…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>
@prasanna-anchorage prasanna-anchorage changed the title fix(visualsign): render number fields as text_v2 under the hood fix(visualsign): render number fields as amount_v2 (VSP has no number type) Jun 23, 2026
@prasanna-anchorage

Copy link
Copy Markdown
Contributor Author

Updated per the VSP design: there is no number field type (HSM vsp.py + iOS decoder list text_v2/address_v2/amount_v2/preview_layout/list_layout/delta/accordion/diagnostic/divider). So number now serializes as amount_v2 (amount = value, abbreviation = unit; unitless = empty abbreviation, which iOS parseAmount accepts). In-memory Number variant + create_number_field unchanged; only the wire output. Force-pushed (SSH-signed).

(Branch name fix/number-fields-text-v2 is legacy from the earlier text_v2 approach.)

@prasanna-anchorage

Copy link
Copy Markdown
Contributor Author

Superseded by #393 — same change, renamed branch fix/number-fields-amount-v2 to match the amount_v2 content (this branch was the legacy text-v2 name).

@prasanna-anchorage prasanna-anchorage deleted the fix/number-fields-text-v2 branch June 23, 2026 05:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants