fix: support FA2 token swaps (LIVE-36514) - #30
Closed
dbaranov-hoodies wants to merge 6 commits into
Closed
Conversation
…issions' Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Checklist
developSwapping USDT (Tezos) failed: the app answered 0x6985 to the final signature
and Ledger Live showed "Operation denied on device".
swap_check_validity() only understood a native XTZ transfer. A token swap
signs an FA2
transfercall, so the operation carries 0 mutez and itsdestination is the token contract, while the recipient and the amount live in
the Michelson parameters — both comparisons could never match.
The check now branches on whether Exchange passed a coin configuration:
contract and token id to resolve in the FA2 registry, that entry's symbol
and decimals to match the Ledger-signed coin configuration, and the
Michelson
to_and amount to match the swap's destination and amountswap_handle_get_printable_amount() now uses the token's ticker and decimals
instead of hardcoded XTZ/6, so the Exchange screen no longer labels a USDt
amount as XTZ.
The parser keeps the decoded recipient, token id and amount in the operation
state, since the emit steps reuse both the CAPTURE and decimal buffers and the
frame holding the token id is popped before validation runs. Anything it
cannot represent leaves the transfer unvalidated, so the swap refuses while
the display path is untouched.
Unit tests now build with -DHAVE_SWAP; two new ones pin the captured operation
and check that a Micheline fallback leaves the swap fields unset.
Version bumped to 3.2.4 (3.2.3 is released but its tags are not ancestors of
develop, so that number is taken).
Needs the app-exchange tests in LedgerHQ/app-exchange#382, and a CAL entry
publishing ticker + decimals for FA2 tokens on Tezos — Exchange forwards only
the sub-coin config to the coin app, so without it the app is never told which
token the operation moves and keeps refusing, by design.