fix(visualsign): render number fields as amount_v2 (VSP has no number type)#390
fix(visualsign): render number fields as amount_v2 (VSP has no number type)#390prasanna-anchorage wants to merge 1 commit into
number fields as amount_v2 (VSP has no number type)#390Conversation
There was a problem hiding this comment.
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::NumberasType: "text_v2"and emit aTextV2payload derived fromcommon.fallback_text. - Update
get_expected_fieldsso serialization verification expectsTextV2for theNumbervariant. - Adjust the Jupiter Swap serialization assertion to expect
text_v2on 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.
…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>
number fields as text_v2 under the hoodnumber fields as amount_v2 (VSP has no number type)
|
Updated per the VSP design: there is no (Branch name |
c0a6e41 to
52eda7f
Compare
|
Superseded by #393 — same change, renamed branch |
Problem
The Anchorage wallet's Visual Signing Protocol engine has no
numberfield type — itsFieldTypedecoder recognizes onlytext_v2,address_v2,amount_v2,preview_layout,delta,highlight,rule,accordion,diagnostic. Any field emitted bycreate_number_field(compute_budget,system,token_2022,jupiter_swap, …) therefore decodes to.unknownand is surfaced as an unsupported field, also flagging its enclosingpreview_layoutascontainsUnsupportedNestedFields.Fix
Render the
Numbervariant astext_v2at the serialization layer (serialize_to_map/get_expected_fields), carrying the human value (incl. any unit) fromfallback_text. The in-memorySignablePayloadField::Numbervariant and thecreate_number_fieldhelper are unchanged — callers and variant-matching tests keep working; only the wire output changes. They stay visibly distinct fromamount_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 --checkpass. The one serialization-output assertion injupiter_swap(Slippage field type) updatednumber→text_v2.🤖 Generated with Claude Code