diff --git a/app/src/coin.h b/app/src/coin.h index 5ff033c3..18557165 100644 --- a/app/src/coin.h +++ b/app/src/coin.h @@ -57,6 +57,7 @@ typedef enum { #define COIN_DEFAULT_DENOM_BASE "rune" #define COIN_DEFAULT_DENOM_REPR "RUNE" +#define COIN_DEFAULT_DENOM_REPR_2 "THOR.RUNE" #define COIN_DEFAULT_DENOM_FACTOR 8u #define COIN_DEFAULT_DENOM_TRIMMING 0u diff --git a/app/src/parser.c b/app/src/parser.c index 4108e356..b5fd754d 100644 --- a/app/src/parser.c +++ b/app/src/parser.c @@ -110,12 +110,12 @@ __Z_INLINE parser_error_t is_default_denom_base(const char *denom, uint8_t denom return parser_ok; } - if (strlen(COIN_DEFAULT_DENOM_BASE) != denom_len) { + if (strlen(COIN_DEFAULT_DENOM_BASE) != denom_len && strlen(COIN_DEFAULT_DENOM_REPR_2) != denom_len) { *is_default = false; return parser_ok; } - if (memcmp(denom, COIN_DEFAULT_DENOM_BASE, denom_len) == 0) { + if (memcmp(denom, COIN_DEFAULT_DENOM_BASE, denom_len) == 0 || memcmp(denom, COIN_DEFAULT_DENOM_REPR_2, denom_len) == 0) { *is_default = true; return parser_ok; } @@ -125,7 +125,7 @@ __Z_INLINE parser_error_t is_default_denom_base(const char *denom, uint8_t denom __Z_INLINE parser_error_t parser_formatAmountItem(uint16_t amountToken, char *outVal, uint16_t outValLen, - uint8_t pageIdx, uint8_t *pageCount) { + uint8_t pageIdx, uint8_t *pageCount, bool *is_default) { *pageCount = 0; uint16_t numElements; @@ -187,9 +187,9 @@ __Z_INLINE parser_error_t parser_formatAmountItem(uint16_t amountToken, snprintf(bufferUI, sizeof(bufferUI), "%s ", tmpAmount); // If denomination has been recognized format and replace - bool is_default =false; - CHECK_PARSER_ERR(is_default_denom_base(denomPtr, denomLen, &is_default)) - if (is_default) { + *is_default = false; + CHECK_PARSER_ERR(is_default_denom_base(denomPtr, denomLen, is_default)) + if (*is_default) { if (fpstr_to_str(bufferUI, sizeof(bufferUI), tmpAmount, COIN_DEFAULT_DENOM_FACTOR) != 0) { return parser_unexpected_error; } @@ -205,12 +205,12 @@ __Z_INLINE parser_error_t parser_formatAmountItem(uint16_t amountToken, __Z_INLINE parser_error_t parser_formatAmount(uint16_t amountToken, char *outVal, uint16_t outValLen, - uint8_t pageIdx, uint8_t *pageCount) { - ZEMU_LOGF(200, "[formatAmount] ------- pageidx %d", pageIdx) + uint8_t pageIdx, uint8_t *pageCount, bool *is_default) { + ZEMU_LOGF(200, "[formatAmount] ------- pageidx %d\n", pageIdx) *pageCount = 0; if (parser_tx_obj.tx_json.json.tokens[amountToken].type != JSMN_ARRAY) { - return parser_formatAmountItem(amountToken, outVal, outValLen, pageIdx, pageCount); + return parser_formatAmountItem(amountToken, outVal, outValLen, pageIdx, pageCount, is_default); } uint8_t totalPages = 0; @@ -227,7 +227,7 @@ __Z_INLINE parser_error_t parser_formatAmount(uint16_t amountToken, uint8_t subpagesCount; CHECK_PARSER_ERR(array_get_nth_element(&parser_tx_obj.tx_json.json, amountToken, i, &itemTokenIdx)); - CHECK_PARSER_ERR(parser_formatAmountItem(itemTokenIdx, outVal, outValLen, 0, &subpagesCount)); + CHECK_PARSER_ERR(parser_formatAmountItem(itemTokenIdx, outVal, outValLen, 0, &subpagesCount, is_default)); totalPages += subpagesCount; ZEMU_LOGF(200, "[formatAmount] [%d] TokenIdx: %d - PageIdx: %d - Pages: %d - Total %d", i, itemTokenIdx, @@ -256,7 +256,7 @@ __Z_INLINE parser_error_t parser_formatAmount(uint16_t amountToken, } uint8_t dummy; - return parser_formatAmountItem(showItemTokenIdx, outVal, outValLen, showPageIdx, &dummy); + return parser_formatAmountItem(showItemTokenIdx, outVal, outValLen, showPageIdx, &dummy, is_default); } __Z_INLINE parser_error_t parser_getJsonItem(uint8_t displayIdx, @@ -287,10 +287,12 @@ __Z_INLINE parser_error_t parser_getJsonItem(uint8_t displayIdx, CHECK_APP_CANARY() snprintf(outKey, outKeyLen, "%s", tmpKey); + bool is_default = false; + if (parser_isAmount(tmpKey)) { CHECK_PARSER_ERR(parser_formatAmount(ret_value_token_index, outVal, outValLen, - pageIdx, pageCount)) + pageIdx, pageCount, &is_default)) } else { CHECK_PARSER_ERR(tx_getToken(ret_value_token_index, outVal, outValLen, @@ -300,8 +302,12 @@ __Z_INLINE parser_error_t parser_getJsonItem(uint8_t displayIdx, CHECK_PARSER_ERR(tx_display_make_friendly()) CHECK_APP_CANARY() - - snprintf(outKey, outKeyLen, "%s", tmpKey); + // Display "Raw Amount" for non-default tokens + if(memcmp(tmpKey, "Amount", 6) == 0 && is_default == false){ + snprintf(outKey, outKeyLen, "Raw %s", tmpKey); + } else { + snprintf(outKey, outKeyLen, "%s", tmpKey); + } CHECK_APP_CANARY() return parser_ok; diff --git a/tests_zemu/snapshots/fl-sign_msgDeposit/00001.png b/tests_zemu/snapshots/fl-sign_msgDeposit/00001.png index 9eddd17c..8124e736 100644 Binary files a/tests_zemu/snapshots/fl-sign_msgDeposit/00001.png and b/tests_zemu/snapshots/fl-sign_msgDeposit/00001.png differ diff --git a/tests_zemu/snapshots/fl-sign_msgDeposit_token_2/00000.png b/tests_zemu/snapshots/fl-sign_msgDeposit_token_2/00000.png new file mode 100644 index 00000000..7db05010 Binary files /dev/null and b/tests_zemu/snapshots/fl-sign_msgDeposit_token_2/00000.png differ diff --git a/tests_zemu/snapshots/fl-sign_msgDeposit_token_2/00001.png b/tests_zemu/snapshots/fl-sign_msgDeposit_token_2/00001.png new file mode 100644 index 00000000..2491596a Binary files /dev/null and b/tests_zemu/snapshots/fl-sign_msgDeposit_token_2/00001.png differ diff --git a/tests_zemu/snapshots/fl-sign_msgDeposit_token_2/00002.png b/tests_zemu/snapshots/fl-sign_msgDeposit_token_2/00002.png new file mode 100644 index 00000000..4d22495e Binary files /dev/null and b/tests_zemu/snapshots/fl-sign_msgDeposit_token_2/00002.png differ diff --git a/tests_zemu/snapshots/fl-sign_msgDeposit_token_2/00003.png b/tests_zemu/snapshots/fl-sign_msgDeposit_token_2/00003.png new file mode 100644 index 00000000..e337a062 Binary files /dev/null and b/tests_zemu/snapshots/fl-sign_msgDeposit_token_2/00003.png differ diff --git a/tests_zemu/snapshots/fl-sign_msgDeposit_token_2/00004.png b/tests_zemu/snapshots/fl-sign_msgDeposit_token_2/00004.png new file mode 100644 index 00000000..6c76e6a4 Binary files /dev/null and b/tests_zemu/snapshots/fl-sign_msgDeposit_token_2/00004.png differ diff --git a/tests_zemu/snapshots/s-sign_msgDeposit/00001.png b/tests_zemu/snapshots/s-sign_msgDeposit/00001.png index c882ca34..17b99374 100644 Binary files a/tests_zemu/snapshots/s-sign_msgDeposit/00001.png and b/tests_zemu/snapshots/s-sign_msgDeposit/00001.png differ diff --git a/tests_zemu/snapshots/s-sign_msgDeposit_token_2/00000.png b/tests_zemu/snapshots/s-sign_msgDeposit_token_2/00000.png new file mode 100644 index 00000000..9d416d5f Binary files /dev/null and b/tests_zemu/snapshots/s-sign_msgDeposit_token_2/00000.png differ diff --git a/tests_zemu/snapshots/s-sign_msgDeposit_token_2/00001.png b/tests_zemu/snapshots/s-sign_msgDeposit_token_2/00001.png new file mode 100644 index 00000000..5a8f226e Binary files /dev/null and b/tests_zemu/snapshots/s-sign_msgDeposit_token_2/00001.png differ diff --git a/tests_zemu/snapshots/s-sign_msgDeposit_token_2/00002.png b/tests_zemu/snapshots/s-sign_msgDeposit_token_2/00002.png new file mode 100644 index 00000000..a07a571c Binary files /dev/null and b/tests_zemu/snapshots/s-sign_msgDeposit_token_2/00002.png differ diff --git a/tests_zemu/snapshots/s-sign_msgDeposit_token_2/00003.png b/tests_zemu/snapshots/s-sign_msgDeposit_token_2/00003.png new file mode 100644 index 00000000..ff57ad16 Binary files /dev/null and b/tests_zemu/snapshots/s-sign_msgDeposit_token_2/00003.png differ diff --git a/tests_zemu/snapshots/s-sign_msgDeposit_token_2/00004.png b/tests_zemu/snapshots/s-sign_msgDeposit_token_2/00004.png new file mode 100644 index 00000000..9ebadfbf Binary files /dev/null and b/tests_zemu/snapshots/s-sign_msgDeposit_token_2/00004.png differ diff --git a/tests_zemu/snapshots/s-sign_msgDeposit_token_2/00005.png b/tests_zemu/snapshots/s-sign_msgDeposit_token_2/00005.png new file mode 100644 index 00000000..107c36db Binary files /dev/null and b/tests_zemu/snapshots/s-sign_msgDeposit_token_2/00005.png differ diff --git a/tests_zemu/snapshots/s-sign_msgDeposit_token_2/00006.png b/tests_zemu/snapshots/s-sign_msgDeposit_token_2/00006.png new file mode 100644 index 00000000..006c26ab Binary files /dev/null and b/tests_zemu/snapshots/s-sign_msgDeposit_token_2/00006.png differ diff --git a/tests_zemu/snapshots/s-sign_msgDeposit_token_2/00007.png b/tests_zemu/snapshots/s-sign_msgDeposit_token_2/00007.png new file mode 100644 index 00000000..f1867e44 Binary files /dev/null and b/tests_zemu/snapshots/s-sign_msgDeposit_token_2/00007.png differ diff --git a/tests_zemu/snapshots/sp-sign_msgDeposit/00002.png b/tests_zemu/snapshots/sp-sign_msgDeposit/00002.png index 3b0813cc..7ea7d0fe 100644 Binary files a/tests_zemu/snapshots/sp-sign_msgDeposit/00002.png and b/tests_zemu/snapshots/sp-sign_msgDeposit/00002.png differ diff --git a/tests_zemu/snapshots/sp-sign_msgDeposit_token_2/00000.png b/tests_zemu/snapshots/sp-sign_msgDeposit_token_2/00000.png new file mode 100644 index 00000000..07b7c037 Binary files /dev/null and b/tests_zemu/snapshots/sp-sign_msgDeposit_token_2/00000.png differ diff --git a/tests_zemu/snapshots/sp-sign_msgDeposit_token_2/00001.png b/tests_zemu/snapshots/sp-sign_msgDeposit_token_2/00001.png new file mode 100644 index 00000000..6b223738 Binary files /dev/null and b/tests_zemu/snapshots/sp-sign_msgDeposit_token_2/00001.png differ diff --git a/tests_zemu/snapshots/sp-sign_msgDeposit_token_2/00002.png b/tests_zemu/snapshots/sp-sign_msgDeposit_token_2/00002.png new file mode 100644 index 00000000..3d828b81 Binary files /dev/null and b/tests_zemu/snapshots/sp-sign_msgDeposit_token_2/00002.png differ diff --git a/tests_zemu/snapshots/sp-sign_msgDeposit_token_2/00003.png b/tests_zemu/snapshots/sp-sign_msgDeposit_token_2/00003.png new file mode 100644 index 00000000..8e2ae03e Binary files /dev/null and b/tests_zemu/snapshots/sp-sign_msgDeposit_token_2/00003.png differ diff --git a/tests_zemu/snapshots/sp-sign_msgDeposit_token_2/00004.png b/tests_zemu/snapshots/sp-sign_msgDeposit_token_2/00004.png new file mode 100644 index 00000000..a888d147 Binary files /dev/null and b/tests_zemu/snapshots/sp-sign_msgDeposit_token_2/00004.png differ diff --git a/tests_zemu/snapshots/sp-sign_msgDeposit_token_2/00005.png b/tests_zemu/snapshots/sp-sign_msgDeposit_token_2/00005.png new file mode 100644 index 00000000..d9fd802f Binary files /dev/null and b/tests_zemu/snapshots/sp-sign_msgDeposit_token_2/00005.png differ diff --git a/tests_zemu/snapshots/sp-sign_msgDeposit_token_2/00006.png b/tests_zemu/snapshots/sp-sign_msgDeposit_token_2/00006.png new file mode 100644 index 00000000..1e4be699 Binary files /dev/null and b/tests_zemu/snapshots/sp-sign_msgDeposit_token_2/00006.png differ diff --git a/tests_zemu/snapshots/sp-sign_msgDeposit_token_2/00007.png b/tests_zemu/snapshots/sp-sign_msgDeposit_token_2/00007.png new file mode 100644 index 00000000..1d4449e7 Binary files /dev/null and b/tests_zemu/snapshots/sp-sign_msgDeposit_token_2/00007.png differ diff --git a/tests_zemu/snapshots/st-sign_msgDeposit/00001.png b/tests_zemu/snapshots/st-sign_msgDeposit/00001.png index 851018b9..4f43f931 100644 Binary files a/tests_zemu/snapshots/st-sign_msgDeposit/00001.png and b/tests_zemu/snapshots/st-sign_msgDeposit/00001.png differ diff --git a/tests_zemu/snapshots/st-sign_msgDeposit_token_2/00000.png b/tests_zemu/snapshots/st-sign_msgDeposit_token_2/00000.png new file mode 100644 index 00000000..dd77b1f6 Binary files /dev/null and b/tests_zemu/snapshots/st-sign_msgDeposit_token_2/00000.png differ diff --git a/tests_zemu/snapshots/st-sign_msgDeposit_token_2/00001.png b/tests_zemu/snapshots/st-sign_msgDeposit_token_2/00001.png new file mode 100644 index 00000000..2932de83 Binary files /dev/null and b/tests_zemu/snapshots/st-sign_msgDeposit_token_2/00001.png differ diff --git a/tests_zemu/snapshots/st-sign_msgDeposit_token_2/00002.png b/tests_zemu/snapshots/st-sign_msgDeposit_token_2/00002.png new file mode 100644 index 00000000..b8c272b1 Binary files /dev/null and b/tests_zemu/snapshots/st-sign_msgDeposit_token_2/00002.png differ diff --git a/tests_zemu/snapshots/st-sign_msgDeposit_token_2/00003.png b/tests_zemu/snapshots/st-sign_msgDeposit_token_2/00003.png new file mode 100644 index 00000000..73365839 Binary files /dev/null and b/tests_zemu/snapshots/st-sign_msgDeposit_token_2/00003.png differ diff --git a/tests_zemu/snapshots/st-sign_msgDeposit_token_2/00004.png b/tests_zemu/snapshots/st-sign_msgDeposit_token_2/00004.png new file mode 100644 index 00000000..ce8d6909 Binary files /dev/null and b/tests_zemu/snapshots/st-sign_msgDeposit_token_2/00004.png differ diff --git a/tests_zemu/snapshots/x-sign_msgDeposit/00002.png b/tests_zemu/snapshots/x-sign_msgDeposit/00002.png index 3b0813cc..7ea7d0fe 100644 Binary files a/tests_zemu/snapshots/x-sign_msgDeposit/00002.png and b/tests_zemu/snapshots/x-sign_msgDeposit/00002.png differ diff --git a/tests_zemu/snapshots/x-sign_msgDeposit_token_2/00000.png b/tests_zemu/snapshots/x-sign_msgDeposit_token_2/00000.png new file mode 100644 index 00000000..07b7c037 Binary files /dev/null and b/tests_zemu/snapshots/x-sign_msgDeposit_token_2/00000.png differ diff --git a/tests_zemu/snapshots/x-sign_msgDeposit_token_2/00001.png b/tests_zemu/snapshots/x-sign_msgDeposit_token_2/00001.png new file mode 100644 index 00000000..6b223738 Binary files /dev/null and b/tests_zemu/snapshots/x-sign_msgDeposit_token_2/00001.png differ diff --git a/tests_zemu/snapshots/x-sign_msgDeposit_token_2/00002.png b/tests_zemu/snapshots/x-sign_msgDeposit_token_2/00002.png new file mode 100644 index 00000000..3d828b81 Binary files /dev/null and b/tests_zemu/snapshots/x-sign_msgDeposit_token_2/00002.png differ diff --git a/tests_zemu/snapshots/x-sign_msgDeposit_token_2/00003.png b/tests_zemu/snapshots/x-sign_msgDeposit_token_2/00003.png new file mode 100644 index 00000000..8e2ae03e Binary files /dev/null and b/tests_zemu/snapshots/x-sign_msgDeposit_token_2/00003.png differ diff --git a/tests_zemu/snapshots/x-sign_msgDeposit_token_2/00004.png b/tests_zemu/snapshots/x-sign_msgDeposit_token_2/00004.png new file mode 100644 index 00000000..a888d147 Binary files /dev/null and b/tests_zemu/snapshots/x-sign_msgDeposit_token_2/00004.png differ diff --git a/tests_zemu/snapshots/x-sign_msgDeposit_token_2/00005.png b/tests_zemu/snapshots/x-sign_msgDeposit_token_2/00005.png new file mode 100644 index 00000000..d9fd802f Binary files /dev/null and b/tests_zemu/snapshots/x-sign_msgDeposit_token_2/00005.png differ diff --git a/tests_zemu/snapshots/x-sign_msgDeposit_token_2/00006.png b/tests_zemu/snapshots/x-sign_msgDeposit_token_2/00006.png new file mode 100644 index 00000000..1e4be699 Binary files /dev/null and b/tests_zemu/snapshots/x-sign_msgDeposit_token_2/00006.png differ diff --git a/tests_zemu/snapshots/x-sign_msgDeposit_token_2/00007.png b/tests_zemu/snapshots/x-sign_msgDeposit_token_2/00007.png new file mode 100644 index 00000000..1d4449e7 Binary files /dev/null and b/tests_zemu/snapshots/x-sign_msgDeposit_token_2/00007.png differ diff --git a/tests_zemu/tests/common.ts b/tests_zemu/tests/common.ts index f03d1508..9eed2e24 100644 --- a/tests_zemu/tests/common.ts +++ b/tests_zemu/tests/common.ts @@ -91,4 +91,30 @@ export const example_tx_str_MsgDeposit = { } ], "sequence": "6" +}; + +export const example_tx_str_MsgDeposit_token_2 = { + "account_number": "588", + "chain_id": "thorchain", + "fee": { + "amount": [], + "gas": "10000000" + }, + "memo": "", + "msgs": [ + { + "type": "thorchain/MsgDeposit", + "value": { + "coins": [ + { + "amount": "330000000", + "asset": "ETH.ETH" + } + ], + "memo": "SWAP:BNB.BNB:tbnb1qk2m905ypazwfau9cn0qnr4c4yxz63v9u9md20:", + "signer": "tthor1c648xgpter9xffhmcqvs7lzd7hxh0prgv5t5gp" + } + } + ], + "sequence": "6" }; \ No newline at end of file diff --git a/tests_zemu/tests/thor.test.ts b/tests_zemu/tests/thor.test.ts index 42638800..0e7d3db0 100644 --- a/tests_zemu/tests/thor.test.ts +++ b/tests_zemu/tests/thor.test.ts @@ -23,6 +23,7 @@ import { AMINO_JSON_TX, example_tx_str_MsgSend, example_tx_str_MsgDeposit, + example_tx_str_MsgDeposit_token_2 } from './common' // @ts-ignore @@ -98,4 +99,8 @@ describe('Thor', function () { await signAndVerifyTransaction(m, 'sign_msgDeposit', example_tx_str_MsgDeposit); }); + test.concurrent.each(DEVICE_MODELS)('sign msgDeposit token 2', async function (m) { + await signAndVerifyTransaction(m, 'sign_msgDeposit_token_2', example_tx_str_MsgDeposit_token_2); + }); + })