diff --git a/app/Makefile.version b/app/Makefile.version index 9fb5dce3..750ef5ee 100644 --- a/app/Makefile.version +++ b/app/Makefile.version @@ -3,4 +3,4 @@ APPVERSION_M=2 # This is the `spec_version` field of `Runtime` APPVERSION_N=35 # This is the patch version of this release -APPVERSION_P=0 +APPVERSION_P=1 diff --git a/app/src/crypto.c b/app/src/crypto.c index a6ef1892..8860e396 100644 --- a/app/src/crypto.c +++ b/app/src/crypto.c @@ -201,7 +201,7 @@ zxerr_t crypto_fillAddress(uint8_t *buffer, uint16_t buffer_len, uint16_t *addrR ripemd160_32(hashed2_pk, hashed1_pk); char *addr = (char *) (buffer + PK_LEN_SECP256K1); - CHECK_ZXERR(bech32EncodeFromBytes(addr, buffer_len - PK_LEN_SECP256K1, bech32_hrp, hashed2_pk, CX_RIPEMD160_SIZE, 1)) + CHECK_ZXERR(bech32EncodeFromBytes(addr, buffer_len - PK_LEN_SECP256K1, bech32_hrp, hashed2_pk, CX_RIPEMD160_SIZE, 1, BECH32_ENCODING_BECH32)) *addrResponseLen = PK_LEN_SECP256K1 + strlen(addr); diff --git a/app/src/tx_display.c b/app/src/tx_display.c index 3c50621a..037976cb 100644 --- a/app/src/tx_display.c +++ b/app/src/tx_display.c @@ -483,6 +483,7 @@ static const key_subst_t key_substitutions[] = { {"msgs/value/amount", "Amount"}, {"msgs/value/delegator_address", "Delegator"}, {"msgs/value/validator_address", "Validator"}, + {"msgs/value/withdraw_address", "Withdraw Address"}, {"msgs/value/validator_src_address", "Validator Source"}, {"msgs/value/validator_dst_address", "Validator Dest"}, {"msgs/value/description", "Description"}, @@ -491,9 +492,8 @@ static const key_subst_t key_substitutions[] = { {"msgs/value/proposal_type", "Proposal"}, {"msgs/value/proposer", "Proposer"}, {"msgs/value/title", "Title"}, - {"msgs/value/depositer", "Sender"}, + {"msgs/value/depositor", "Sender"}, {"msgs/value/proposal_id", "Proposal ID"}, - {"msgs/value/amount", "Amount"}, {"msgs/value/voter", "Description"}, {"msgs/value/option", "Option"}, }; @@ -543,7 +543,7 @@ parser_error_t tx_display_translation(char *dst, uint16_t dstLen, char *src) { } else { *dst++ = '\\'; ASSERT_PTR_BOUNDS(count, dstLen); - + uint8_t bytes_to_print = 8; int32_t swapped = ZX_SWAP(tmp_codepoint); if (tmp_codepoint > 0xFFFF) { @@ -555,7 +555,7 @@ parser_error_t tx_display_translation(char *dst, uint16_t dstLen, char *src) { bytes_to_print = 4; swapped = (swapped >> 16) & 0xFFFF; } - + if(dstLen < bytes_to_print) { return parser_unexpected_value; } diff --git a/app/src/tx_parser.c b/app/src/tx_parser.c index f30d0ee0..fd9d85f6 100644 --- a/app/src/tx_parser.c +++ b/app/src/tx_parser.c @@ -62,8 +62,9 @@ static const key_subst_t value_substitutions[] = { {"cosmos-sdk/MsgVote", "Vote"}, {"cosmos-sdk/MsgWithdrawDelegationReward", "Withdraw Reward"}, {"cosmos-sdk/MsgWithdrawValidatorCommission", "Withdraw Val. Commission"}, + {"cosmos-sdk/MsgSetWithdrawAddress", "Withdraw Set Address"}, {"cosmos-sdk/MsgMultiSend", "Multi Send"}, - + }; parser_error_t tx_getToken(uint16_t token_index, @@ -81,7 +82,6 @@ parser_error_t tx_getToken(uint16_t token_index, const char *inValue = parser_tx_obj.tx_json.tx + token_start; uint16_t inLen = token_end - token_start; - // empty strings are considered the first page *pageCount = 1; if (inLen > 0) { @@ -91,11 +91,15 @@ parser_error_t tx_getToken(uint16_t token_index, if (inLen == substStrLen && !MEMCMP(inValue, substStr, substStrLen)) { inValue = value_substitutions[i].str2; inLen = strlen(value_substitutions[i].str2); - + //Extra Depth level for Multisend type - extraDepthLevel = (i == MULTISEND_KEY_IDX); + extraDepthLevel = false; + if (strstr(inValue, "Multi") != NULL) { + extraDepthLevel = true; + } + break; - } + } } pageStringExt(out_val, out_val_len, inValue, inLen, pageIdx, pageCount); diff --git a/app/src/tx_parser.h b/app/src/tx_parser.h index 6b6176fc..6545d51a 100644 --- a/app/src/tx_parser.h +++ b/app/src/tx_parser.h @@ -28,7 +28,6 @@ extern "C" { #endif #define MAX_RECURSION_DEPTH 6 -#define MULTISEND_KEY_IDX 9 extern bool extraDepthLevel; #define INIT_QUERY_CONTEXT(_KEY, _KEY_LEN, _VAL, _VAL_LEN, _PAGE_IDX, _MAX_LEVEL) \ diff --git a/deps/ledger-zxlib b/deps/ledger-zxlib index 9a82671e..09ef1979 160000 --- a/deps/ledger-zxlib +++ b/deps/ledger-zxlib @@ -1 +1 @@ -Subproject commit 9a82671e9c4800425edbb6c55c8867d0b2a92a39 +Subproject commit 09ef19795a03c3031bd26f845817fe5aa195a0c4 diff --git a/tests/testcases/manual.json b/tests/testcases/manual.json index fccc5d75..9d06fab7 100644 --- a/tests/testcases/manual.json +++ b/tests/testcases/manual.json @@ -2031,5 +2031,153 @@ "17 | Tipper [2/2] : 6pkh5t" ], "expert": true - } + }, + { + "name": "MsgSetWithdrawAddress", + "tx":{ + "account_number": "8", + "chain_id": "testing", + "fee": { + "amount": [ + { + "amount": "5000", + "denom": "uatom" + } + ], + "gas": "200000" + }, + "memo": "", + "msgs": [ + { + "type": "cosmos-sdk/MsgSetWithdrawAddress", + "value": { + "delegator_address": "cosmos1hr9x0sjvel6z3vt9qny8sdd5gnnlgk0p69d6cv", + "withdraw_address": "cosmos12d64j98tjjpqkx70r08aspc4nvntqp2w6wr2de" + } + }, + { + "type": "cosmos-sdk/MsgWithdrawDelegationReward", + "value": { + "delegator_address": "cosmos1hr9x0sjvel6z3vt9qny8sdd5gnnlgk0p69d6cv", + "validator_address": "cosmosvaloper13dr26wdygna3s8fdl5tlc45m2le2ydyddxzj49" + } + } + ], + "sequence": "7" + }, + "parsingErr": "No error", + "validationErr": "No error", + "expected": [ + "0 | Chain ID : testing", + "1 | Account : 8", + "2 | Sequence : 7", + "3 | Type : Withdraw Set Address", + "4 | Delegator [1/2] : cosmos1hr9x0sjvel6z3vt9qny8sdd5gnnlgk0p", + "4 | Delegator [2/2] : 69d6cv", + "5 | Withdraw Address [1/2] : cosmos12d64j98tjjpqkx70r08aspc4nvntqp2w", + "5 | Withdraw Address [2/2] : 6wr2de", + "6 | Type : Withdraw Reward", + "7 | Delegator [1/2] : cosmos1hr9x0sjvel6z3vt9qny8sdd5gnnlgk0p", + "7 | Delegator [2/2] : 69d6cv", + "8 | Validator [1/2] : cosmosvaloper13dr26wdygna3s8fdl5tlc45m2", + "8 | Validator [2/2] : le2ydyddxzj49", + "9 | Fee : 5000 uatom", + "10 | Gas : 200000" + ], + "expert": true + }, + { + "name": "Gaia_Sign_00", + "tx": { + "account_number":"8", + "sequence":"2", + "chain_id":"my-chain", + "memo":"A B C", + "fee":{ + "amount":[], + "gas":"200000" + }, + "msgs":[{ + "type":"cosmos-sdk/MsgDeposit", + "value":{ + "amount":[{ + "amount":"10", + "denom":"stake" + }], + "depositor":"cosmos1xl2256vdh0j68khz9wq88hnyqcq0f5f4za2480", + "proposal_id":"1" + } + }] + }, + "parsingErr": "No error", + "validationErr": "No error", + "expected": [ + "0 | Chain ID : my-chain", + "1 | Account : 8", + "2 | Sequence : 2", + "3 | Type : Deposit", + "4 | Amount : 10 stake", + "5 | Sender [1/2] : cosmos1xl2256vdh0j68khz9wq88hnyqcq0f5f4", + "5 | Sender [2/2] : za2480", + "6 | Proposal ID : 1", + "7 | Memo : A B C", + "8 | Fee : Empty", + "9 | Gas : 200000" + ], + "expert": true + }, + { + "name": "Gaia_Sign_01", + "tx": { + "account_number":"123", + "sequence":"8", + "chain_id":"my-chain", + "fee":{ + "amount":[{ + "denom":"uatom", + "amount":"54" + }], + "gas_limit":"106309", + "granter": "cosmosaccaddr1d9h8xxxGRANTER", + "payer": "cosmosaccaddr1d9h8qatxxPAYER" + }, + + "msgs":[{ + "type":"cosmos-sdk/MsgDeposit", + "value":{ + "amount":[{ + "amount":"255000000", + "denom":"uatom" + }], + "depositor":"cosmos1849m9wncrqp6v4tkss6a3j8uzvuv0cp7wcgvqa", + "proposal_id":"44" + } + }], + "memo":"", + "timeout_height":"0", + "extension_options":[], + "non_critical_extension_options":[], + "auth_info":{ + "signer_infos":[] + }, + "signatures":[] + }, + "parsingErr": "No error", + "validationErr": "No error", + "expected": [ + "0 | Chain ID : my-chain", + "1 | Account : 123", + "2 | Sequence : 8", + "3 | Type : Deposit", + "4 | Amount : 255000000 uatom", + "5 | Sender [1/2] : cosmos1849m9wncrqp6v4tkss6a3j8uzvuv0cp7", + "5 | Sender [2/2] : wcgvqa", + "6 | Proposal ID : 44", + "7 | Fee : 54 uatom", + "8 | fee/gas_limit : 106309", + "9 | Granter : cosmosaccaddr1d9h8xxxGRANTER", + "10 | Payer : cosmosaccaddr1d9h8qatxxPAYER" + ], + "expert": true + } ] diff --git a/tests_zemu/snapshots/s-govDeposit/00000.png b/tests_zemu/snapshots/s-govDeposit/00000.png new file mode 100644 index 00000000..ff615887 Binary files /dev/null and b/tests_zemu/snapshots/s-govDeposit/00000.png differ diff --git a/tests_zemu/snapshots/s-govDeposit/00001.png b/tests_zemu/snapshots/s-govDeposit/00001.png new file mode 100644 index 00000000..74c74ba3 Binary files /dev/null and b/tests_zemu/snapshots/s-govDeposit/00001.png differ diff --git a/tests_zemu/snapshots/s-govDeposit/00002.png b/tests_zemu/snapshots/s-govDeposit/00002.png new file mode 100644 index 00000000..99ba8e04 Binary files /dev/null and b/tests_zemu/snapshots/s-govDeposit/00002.png differ diff --git a/tests_zemu/snapshots/s-govDeposit/00003.png b/tests_zemu/snapshots/s-govDeposit/00003.png new file mode 100644 index 00000000..5fcf6cec Binary files /dev/null and b/tests_zemu/snapshots/s-govDeposit/00003.png differ diff --git a/tests_zemu/snapshots/s-govDeposit/00004.png b/tests_zemu/snapshots/s-govDeposit/00004.png new file mode 100644 index 00000000..da09bb9b Binary files /dev/null and b/tests_zemu/snapshots/s-govDeposit/00004.png differ diff --git a/tests_zemu/snapshots/s-govDeposit/00005.png b/tests_zemu/snapshots/s-govDeposit/00005.png new file mode 100644 index 00000000..217f452c Binary files /dev/null and b/tests_zemu/snapshots/s-govDeposit/00005.png differ diff --git a/tests_zemu/snapshots/s-govDeposit/00006.png b/tests_zemu/snapshots/s-govDeposit/00006.png new file mode 100644 index 00000000..29e56bcd Binary files /dev/null and b/tests_zemu/snapshots/s-govDeposit/00006.png differ diff --git a/tests_zemu/snapshots/s-govDeposit/00007.png b/tests_zemu/snapshots/s-govDeposit/00007.png new file mode 100644 index 00000000..db7eee0a Binary files /dev/null and b/tests_zemu/snapshots/s-govDeposit/00007.png differ diff --git a/tests_zemu/snapshots/s-govDeposit/00008.png b/tests_zemu/snapshots/s-govDeposit/00008.png new file mode 100644 index 00000000..56ebb532 Binary files /dev/null and b/tests_zemu/snapshots/s-govDeposit/00008.png differ diff --git a/tests_zemu/snapshots/s-govDeposit/00009.png b/tests_zemu/snapshots/s-govDeposit/00009.png new file mode 100644 index 00000000..aeed27a4 Binary files /dev/null and b/tests_zemu/snapshots/s-govDeposit/00009.png differ diff --git a/tests_zemu/snapshots/s-govDeposit/00010.png b/tests_zemu/snapshots/s-govDeposit/00010.png new file mode 100644 index 00000000..1162e20a Binary files /dev/null and b/tests_zemu/snapshots/s-govDeposit/00010.png differ diff --git a/tests_zemu/snapshots/s-govDeposit/00011.png b/tests_zemu/snapshots/s-govDeposit/00011.png new file mode 100644 index 00000000..006c26ab Binary files /dev/null and b/tests_zemu/snapshots/s-govDeposit/00011.png differ diff --git a/tests_zemu/snapshots/s-govDeposit/00012.png b/tests_zemu/snapshots/s-govDeposit/00012.png new file mode 100644 index 00000000..131855e2 Binary files /dev/null and b/tests_zemu/snapshots/s-govDeposit/00012.png differ diff --git a/tests_zemu/snapshots/s-mainmenu/00004.png b/tests_zemu/snapshots/s-mainmenu/00004.png index 3e235870..900a5f73 100644 Binary files a/tests_zemu/snapshots/s-mainmenu/00004.png and b/tests_zemu/snapshots/s-mainmenu/00004.png differ diff --git a/tests_zemu/snapshots/s-mainmenu/00010.png b/tests_zemu/snapshots/s-mainmenu/00010.png index 3e235870..900a5f73 100644 Binary files a/tests_zemu/snapshots/s-mainmenu/00010.png and b/tests_zemu/snapshots/s-mainmenu/00010.png differ diff --git a/tests_zemu/snapshots/s-setWithdrawAddress/00000.png b/tests_zemu/snapshots/s-setWithdrawAddress/00000.png new file mode 100644 index 00000000..9708f9ac Binary files /dev/null and b/tests_zemu/snapshots/s-setWithdrawAddress/00000.png differ diff --git a/tests_zemu/snapshots/s-setWithdrawAddress/00001.png b/tests_zemu/snapshots/s-setWithdrawAddress/00001.png new file mode 100644 index 00000000..74c74ba3 Binary files /dev/null and b/tests_zemu/snapshots/s-setWithdrawAddress/00001.png differ diff --git a/tests_zemu/snapshots/s-setWithdrawAddress/00002.png b/tests_zemu/snapshots/s-setWithdrawAddress/00002.png new file mode 100644 index 00000000..24d43572 Binary files /dev/null and b/tests_zemu/snapshots/s-setWithdrawAddress/00002.png differ diff --git a/tests_zemu/snapshots/s-setWithdrawAddress/00003.png b/tests_zemu/snapshots/s-setWithdrawAddress/00003.png new file mode 100644 index 00000000..d5fd7c5c Binary files /dev/null and b/tests_zemu/snapshots/s-setWithdrawAddress/00003.png differ diff --git a/tests_zemu/snapshots/s-setWithdrawAddress/00004.png b/tests_zemu/snapshots/s-setWithdrawAddress/00004.png new file mode 100644 index 00000000..cbcd3e91 Binary files /dev/null and b/tests_zemu/snapshots/s-setWithdrawAddress/00004.png differ diff --git a/tests_zemu/snapshots/s-setWithdrawAddress/00005.png b/tests_zemu/snapshots/s-setWithdrawAddress/00005.png new file mode 100644 index 00000000..4daa424c Binary files /dev/null and b/tests_zemu/snapshots/s-setWithdrawAddress/00005.png differ diff --git a/tests_zemu/snapshots/s-setWithdrawAddress/00006.png b/tests_zemu/snapshots/s-setWithdrawAddress/00006.png new file mode 100644 index 00000000..e8125389 Binary files /dev/null and b/tests_zemu/snapshots/s-setWithdrawAddress/00006.png differ diff --git a/tests_zemu/snapshots/s-setWithdrawAddress/00007.png b/tests_zemu/snapshots/s-setWithdrawAddress/00007.png new file mode 100644 index 00000000..4505dd80 Binary files /dev/null and b/tests_zemu/snapshots/s-setWithdrawAddress/00007.png differ diff --git a/tests_zemu/snapshots/s-setWithdrawAddress/00008.png b/tests_zemu/snapshots/s-setWithdrawAddress/00008.png new file mode 100644 index 00000000..6355910e Binary files /dev/null and b/tests_zemu/snapshots/s-setWithdrawAddress/00008.png differ diff --git a/tests_zemu/snapshots/s-setWithdrawAddress/00009.png b/tests_zemu/snapshots/s-setWithdrawAddress/00009.png new file mode 100644 index 00000000..cbcd3e91 Binary files /dev/null and b/tests_zemu/snapshots/s-setWithdrawAddress/00009.png differ diff --git a/tests_zemu/snapshots/s-setWithdrawAddress/00010.png b/tests_zemu/snapshots/s-setWithdrawAddress/00010.png new file mode 100644 index 00000000..4daa424c Binary files /dev/null and b/tests_zemu/snapshots/s-setWithdrawAddress/00010.png differ diff --git a/tests_zemu/snapshots/s-setWithdrawAddress/00011.png b/tests_zemu/snapshots/s-setWithdrawAddress/00011.png new file mode 100644 index 00000000..d0b78b88 Binary files /dev/null and b/tests_zemu/snapshots/s-setWithdrawAddress/00011.png differ diff --git a/tests_zemu/snapshots/s-setWithdrawAddress/00012.png b/tests_zemu/snapshots/s-setWithdrawAddress/00012.png new file mode 100644 index 00000000..0ca7eb7d Binary files /dev/null and b/tests_zemu/snapshots/s-setWithdrawAddress/00012.png differ diff --git a/tests_zemu/snapshots/s-setWithdrawAddress/00013.png b/tests_zemu/snapshots/s-setWithdrawAddress/00013.png new file mode 100644 index 00000000..27b467d0 Binary files /dev/null and b/tests_zemu/snapshots/s-setWithdrawAddress/00013.png differ diff --git a/tests_zemu/snapshots/s-setWithdrawAddress/00014.png b/tests_zemu/snapshots/s-setWithdrawAddress/00014.png new file mode 100644 index 00000000..1162e20a Binary files /dev/null and b/tests_zemu/snapshots/s-setWithdrawAddress/00014.png differ diff --git a/tests_zemu/snapshots/s-setWithdrawAddress/00015.png b/tests_zemu/snapshots/s-setWithdrawAddress/00015.png new file mode 100644 index 00000000..006c26ab Binary files /dev/null and b/tests_zemu/snapshots/s-setWithdrawAddress/00015.png differ diff --git a/tests_zemu/snapshots/s-setWithdrawAddress/00016.png b/tests_zemu/snapshots/s-setWithdrawAddress/00016.png new file mode 100644 index 00000000..131855e2 Binary files /dev/null and b/tests_zemu/snapshots/s-setWithdrawAddress/00016.png differ diff --git a/tests_zemu/snapshots/sp-govDeposit/00000.png b/tests_zemu/snapshots/sp-govDeposit/00000.png new file mode 100644 index 00000000..50c23a06 Binary files /dev/null and b/tests_zemu/snapshots/sp-govDeposit/00000.png differ diff --git a/tests_zemu/snapshots/sp-govDeposit/00001.png b/tests_zemu/snapshots/sp-govDeposit/00001.png new file mode 100644 index 00000000..54b3e630 Binary files /dev/null and b/tests_zemu/snapshots/sp-govDeposit/00001.png differ diff --git a/tests_zemu/snapshots/sp-govDeposit/00002.png b/tests_zemu/snapshots/sp-govDeposit/00002.png new file mode 100644 index 00000000..5e8c47b6 Binary files /dev/null and b/tests_zemu/snapshots/sp-govDeposit/00002.png differ diff --git a/tests_zemu/snapshots/sp-govDeposit/00003.png b/tests_zemu/snapshots/sp-govDeposit/00003.png new file mode 100644 index 00000000..84bc70f9 Binary files /dev/null and b/tests_zemu/snapshots/sp-govDeposit/00003.png differ diff --git a/tests_zemu/snapshots/sp-govDeposit/00004.png b/tests_zemu/snapshots/sp-govDeposit/00004.png new file mode 100644 index 00000000..6b223738 Binary files /dev/null and b/tests_zemu/snapshots/sp-govDeposit/00004.png differ diff --git a/tests_zemu/snapshots/sp-govDeposit/00005.png b/tests_zemu/snapshots/sp-govDeposit/00005.png new file mode 100644 index 00000000..eaecc407 Binary files /dev/null and b/tests_zemu/snapshots/sp-govDeposit/00005.png differ diff --git a/tests_zemu/snapshots/sp-govDeposit/00006.png b/tests_zemu/snapshots/sp-govDeposit/00006.png new file mode 100644 index 00000000..b3a92e31 Binary files /dev/null and b/tests_zemu/snapshots/sp-govDeposit/00006.png differ diff --git a/tests_zemu/snapshots/sp-govDeposit/00007.png b/tests_zemu/snapshots/sp-govDeposit/00007.png new file mode 100644 index 00000000..5ecf01cc Binary files /dev/null and b/tests_zemu/snapshots/sp-govDeposit/00007.png differ diff --git a/tests_zemu/snapshots/sp-govDeposit/00008.png b/tests_zemu/snapshots/sp-govDeposit/00008.png new file mode 100644 index 00000000..9d32864f Binary files /dev/null and b/tests_zemu/snapshots/sp-govDeposit/00008.png differ diff --git a/tests_zemu/snapshots/sp-govDeposit/00009.png b/tests_zemu/snapshots/sp-govDeposit/00009.png new file mode 100644 index 00000000..480a738d Binary files /dev/null and b/tests_zemu/snapshots/sp-govDeposit/00009.png differ diff --git a/tests_zemu/snapshots/sp-govDeposit/00010.png b/tests_zemu/snapshots/sp-govDeposit/00010.png new file mode 100644 index 00000000..62eac008 Binary files /dev/null and b/tests_zemu/snapshots/sp-govDeposit/00010.png differ diff --git a/tests_zemu/snapshots/sp-govDeposit/00011.png b/tests_zemu/snapshots/sp-govDeposit/00011.png new file mode 100644 index 00000000..1e4be699 Binary files /dev/null and b/tests_zemu/snapshots/sp-govDeposit/00011.png differ diff --git a/tests_zemu/snapshots/sp-govDeposit/00012.png b/tests_zemu/snapshots/sp-govDeposit/00012.png new file mode 100644 index 00000000..430a37e8 Binary files /dev/null and b/tests_zemu/snapshots/sp-govDeposit/00012.png differ diff --git a/tests_zemu/snapshots/sp-mainmenu/00004.png b/tests_zemu/snapshots/sp-mainmenu/00004.png index 59fafb82..ffb5b94a 100644 Binary files a/tests_zemu/snapshots/sp-mainmenu/00004.png and b/tests_zemu/snapshots/sp-mainmenu/00004.png differ diff --git a/tests_zemu/snapshots/sp-mainmenu/00010.png b/tests_zemu/snapshots/sp-mainmenu/00010.png index 59fafb82..ffb5b94a 100644 Binary files a/tests_zemu/snapshots/sp-mainmenu/00010.png and b/tests_zemu/snapshots/sp-mainmenu/00010.png differ diff --git a/tests_zemu/snapshots/sp-setWithdrawAddress/00000.png b/tests_zemu/snapshots/sp-setWithdrawAddress/00000.png new file mode 100644 index 00000000..50c23a06 Binary files /dev/null and b/tests_zemu/snapshots/sp-setWithdrawAddress/00000.png differ diff --git a/tests_zemu/snapshots/sp-setWithdrawAddress/00001.png b/tests_zemu/snapshots/sp-setWithdrawAddress/00001.png new file mode 100644 index 00000000..797d0277 Binary files /dev/null and b/tests_zemu/snapshots/sp-setWithdrawAddress/00001.png differ diff --git a/tests_zemu/snapshots/sp-setWithdrawAddress/00002.png b/tests_zemu/snapshots/sp-setWithdrawAddress/00002.png new file mode 100644 index 00000000..5e8c47b6 Binary files /dev/null and b/tests_zemu/snapshots/sp-setWithdrawAddress/00002.png differ diff --git a/tests_zemu/snapshots/sp-setWithdrawAddress/00003.png b/tests_zemu/snapshots/sp-setWithdrawAddress/00003.png new file mode 100644 index 00000000..350ef295 Binary files /dev/null and b/tests_zemu/snapshots/sp-setWithdrawAddress/00003.png differ diff --git a/tests_zemu/snapshots/sp-setWithdrawAddress/00004.png b/tests_zemu/snapshots/sp-setWithdrawAddress/00004.png new file mode 100644 index 00000000..65b749f5 Binary files /dev/null and b/tests_zemu/snapshots/sp-setWithdrawAddress/00004.png differ diff --git a/tests_zemu/snapshots/sp-setWithdrawAddress/00005.png b/tests_zemu/snapshots/sp-setWithdrawAddress/00005.png new file mode 100644 index 00000000..8c729777 Binary files /dev/null and b/tests_zemu/snapshots/sp-setWithdrawAddress/00005.png differ diff --git a/tests_zemu/snapshots/sp-setWithdrawAddress/00006.png b/tests_zemu/snapshots/sp-setWithdrawAddress/00006.png new file mode 100644 index 00000000..4dc44ae4 Binary files /dev/null and b/tests_zemu/snapshots/sp-setWithdrawAddress/00006.png differ diff --git a/tests_zemu/snapshots/sp-setWithdrawAddress/00007.png b/tests_zemu/snapshots/sp-setWithdrawAddress/00007.png new file mode 100644 index 00000000..0f9cfb13 Binary files /dev/null and b/tests_zemu/snapshots/sp-setWithdrawAddress/00007.png differ diff --git a/tests_zemu/snapshots/sp-setWithdrawAddress/00008.png b/tests_zemu/snapshots/sp-setWithdrawAddress/00008.png new file mode 100644 index 00000000..8c729777 Binary files /dev/null and b/tests_zemu/snapshots/sp-setWithdrawAddress/00008.png differ diff --git a/tests_zemu/snapshots/sp-setWithdrawAddress/00009.png b/tests_zemu/snapshots/sp-setWithdrawAddress/00009.png new file mode 100644 index 00000000..21583d12 Binary files /dev/null and b/tests_zemu/snapshots/sp-setWithdrawAddress/00009.png differ diff --git a/tests_zemu/snapshots/sp-setWithdrawAddress/00010.png b/tests_zemu/snapshots/sp-setWithdrawAddress/00010.png new file mode 100644 index 00000000..d666b4d0 Binary files /dev/null and b/tests_zemu/snapshots/sp-setWithdrawAddress/00010.png differ diff --git a/tests_zemu/snapshots/sp-setWithdrawAddress/00011.png b/tests_zemu/snapshots/sp-setWithdrawAddress/00011.png new file mode 100644 index 00000000..62eac008 Binary files /dev/null and b/tests_zemu/snapshots/sp-setWithdrawAddress/00011.png differ diff --git a/tests_zemu/snapshots/sp-setWithdrawAddress/00012.png b/tests_zemu/snapshots/sp-setWithdrawAddress/00012.png new file mode 100644 index 00000000..1e4be699 Binary files /dev/null and b/tests_zemu/snapshots/sp-setWithdrawAddress/00012.png differ diff --git a/tests_zemu/snapshots/sp-setWithdrawAddress/00013.png b/tests_zemu/snapshots/sp-setWithdrawAddress/00013.png new file mode 100644 index 00000000..430a37e8 Binary files /dev/null and b/tests_zemu/snapshots/sp-setWithdrawAddress/00013.png differ diff --git a/tests_zemu/snapshots/x-govDeposit/00000.png b/tests_zemu/snapshots/x-govDeposit/00000.png new file mode 100644 index 00000000..50c23a06 Binary files /dev/null and b/tests_zemu/snapshots/x-govDeposit/00000.png differ diff --git a/tests_zemu/snapshots/x-govDeposit/00001.png b/tests_zemu/snapshots/x-govDeposit/00001.png new file mode 100644 index 00000000..54b3e630 Binary files /dev/null and b/tests_zemu/snapshots/x-govDeposit/00001.png differ diff --git a/tests_zemu/snapshots/x-govDeposit/00002.png b/tests_zemu/snapshots/x-govDeposit/00002.png new file mode 100644 index 00000000..5e8c47b6 Binary files /dev/null and b/tests_zemu/snapshots/x-govDeposit/00002.png differ diff --git a/tests_zemu/snapshots/x-govDeposit/00003.png b/tests_zemu/snapshots/x-govDeposit/00003.png new file mode 100644 index 00000000..84bc70f9 Binary files /dev/null and b/tests_zemu/snapshots/x-govDeposit/00003.png differ diff --git a/tests_zemu/snapshots/x-govDeposit/00004.png b/tests_zemu/snapshots/x-govDeposit/00004.png new file mode 100644 index 00000000..6b223738 Binary files /dev/null and b/tests_zemu/snapshots/x-govDeposit/00004.png differ diff --git a/tests_zemu/snapshots/x-govDeposit/00005.png b/tests_zemu/snapshots/x-govDeposit/00005.png new file mode 100644 index 00000000..eaecc407 Binary files /dev/null and b/tests_zemu/snapshots/x-govDeposit/00005.png differ diff --git a/tests_zemu/snapshots/x-govDeposit/00006.png b/tests_zemu/snapshots/x-govDeposit/00006.png new file mode 100644 index 00000000..b3a92e31 Binary files /dev/null and b/tests_zemu/snapshots/x-govDeposit/00006.png differ diff --git a/tests_zemu/snapshots/x-govDeposit/00007.png b/tests_zemu/snapshots/x-govDeposit/00007.png new file mode 100644 index 00000000..5ecf01cc Binary files /dev/null and b/tests_zemu/snapshots/x-govDeposit/00007.png differ diff --git a/tests_zemu/snapshots/x-govDeposit/00008.png b/tests_zemu/snapshots/x-govDeposit/00008.png new file mode 100644 index 00000000..9d32864f Binary files /dev/null and b/tests_zemu/snapshots/x-govDeposit/00008.png differ diff --git a/tests_zemu/snapshots/x-govDeposit/00009.png b/tests_zemu/snapshots/x-govDeposit/00009.png new file mode 100644 index 00000000..480a738d Binary files /dev/null and b/tests_zemu/snapshots/x-govDeposit/00009.png differ diff --git a/tests_zemu/snapshots/x-govDeposit/00010.png b/tests_zemu/snapshots/x-govDeposit/00010.png new file mode 100644 index 00000000..62eac008 Binary files /dev/null and b/tests_zemu/snapshots/x-govDeposit/00010.png differ diff --git a/tests_zemu/snapshots/x-govDeposit/00011.png b/tests_zemu/snapshots/x-govDeposit/00011.png new file mode 100644 index 00000000..1e4be699 Binary files /dev/null and b/tests_zemu/snapshots/x-govDeposit/00011.png differ diff --git a/tests_zemu/snapshots/x-govDeposit/00012.png b/tests_zemu/snapshots/x-govDeposit/00012.png new file mode 100644 index 00000000..430a37e8 Binary files /dev/null and b/tests_zemu/snapshots/x-govDeposit/00012.png differ diff --git a/tests_zemu/snapshots/x-mainmenu/00004.png b/tests_zemu/snapshots/x-mainmenu/00004.png index 59fafb82..ffb5b94a 100644 Binary files a/tests_zemu/snapshots/x-mainmenu/00004.png and b/tests_zemu/snapshots/x-mainmenu/00004.png differ diff --git a/tests_zemu/snapshots/x-mainmenu/00010.png b/tests_zemu/snapshots/x-mainmenu/00010.png index 59fafb82..ffb5b94a 100644 Binary files a/tests_zemu/snapshots/x-mainmenu/00010.png and b/tests_zemu/snapshots/x-mainmenu/00010.png differ diff --git a/tests_zemu/snapshots/x-setWithdrawAddress/00000.png b/tests_zemu/snapshots/x-setWithdrawAddress/00000.png new file mode 100644 index 00000000..50c23a06 Binary files /dev/null and b/tests_zemu/snapshots/x-setWithdrawAddress/00000.png differ diff --git a/tests_zemu/snapshots/x-setWithdrawAddress/00001.png b/tests_zemu/snapshots/x-setWithdrawAddress/00001.png new file mode 100644 index 00000000..797d0277 Binary files /dev/null and b/tests_zemu/snapshots/x-setWithdrawAddress/00001.png differ diff --git a/tests_zemu/snapshots/x-setWithdrawAddress/00002.png b/tests_zemu/snapshots/x-setWithdrawAddress/00002.png new file mode 100644 index 00000000..5e8c47b6 Binary files /dev/null and b/tests_zemu/snapshots/x-setWithdrawAddress/00002.png differ diff --git a/tests_zemu/snapshots/x-setWithdrawAddress/00003.png b/tests_zemu/snapshots/x-setWithdrawAddress/00003.png new file mode 100644 index 00000000..350ef295 Binary files /dev/null and b/tests_zemu/snapshots/x-setWithdrawAddress/00003.png differ diff --git a/tests_zemu/snapshots/x-setWithdrawAddress/00004.png b/tests_zemu/snapshots/x-setWithdrawAddress/00004.png new file mode 100644 index 00000000..65b749f5 Binary files /dev/null and b/tests_zemu/snapshots/x-setWithdrawAddress/00004.png differ diff --git a/tests_zemu/snapshots/x-setWithdrawAddress/00005.png b/tests_zemu/snapshots/x-setWithdrawAddress/00005.png new file mode 100644 index 00000000..8c729777 Binary files /dev/null and b/tests_zemu/snapshots/x-setWithdrawAddress/00005.png differ diff --git a/tests_zemu/snapshots/x-setWithdrawAddress/00006.png b/tests_zemu/snapshots/x-setWithdrawAddress/00006.png new file mode 100644 index 00000000..4dc44ae4 Binary files /dev/null and b/tests_zemu/snapshots/x-setWithdrawAddress/00006.png differ diff --git a/tests_zemu/snapshots/x-setWithdrawAddress/00007.png b/tests_zemu/snapshots/x-setWithdrawAddress/00007.png new file mode 100644 index 00000000..0f9cfb13 Binary files /dev/null and b/tests_zemu/snapshots/x-setWithdrawAddress/00007.png differ diff --git a/tests_zemu/snapshots/x-setWithdrawAddress/00008.png b/tests_zemu/snapshots/x-setWithdrawAddress/00008.png new file mode 100644 index 00000000..8c729777 Binary files /dev/null and b/tests_zemu/snapshots/x-setWithdrawAddress/00008.png differ diff --git a/tests_zemu/snapshots/x-setWithdrawAddress/00009.png b/tests_zemu/snapshots/x-setWithdrawAddress/00009.png new file mode 100644 index 00000000..21583d12 Binary files /dev/null and b/tests_zemu/snapshots/x-setWithdrawAddress/00009.png differ diff --git a/tests_zemu/snapshots/x-setWithdrawAddress/00010.png b/tests_zemu/snapshots/x-setWithdrawAddress/00010.png new file mode 100644 index 00000000..d666b4d0 Binary files /dev/null and b/tests_zemu/snapshots/x-setWithdrawAddress/00010.png differ diff --git a/tests_zemu/snapshots/x-setWithdrawAddress/00011.png b/tests_zemu/snapshots/x-setWithdrawAddress/00011.png new file mode 100644 index 00000000..62eac008 Binary files /dev/null and b/tests_zemu/snapshots/x-setWithdrawAddress/00011.png differ diff --git a/tests_zemu/snapshots/x-setWithdrawAddress/00012.png b/tests_zemu/snapshots/x-setWithdrawAddress/00012.png new file mode 100644 index 00000000..1e4be699 Binary files /dev/null and b/tests_zemu/snapshots/x-setWithdrawAddress/00012.png differ diff --git a/tests_zemu/snapshots/x-setWithdrawAddress/00013.png b/tests_zemu/snapshots/x-setWithdrawAddress/00013.png new file mode 100644 index 00000000..430a37e8 Binary files /dev/null and b/tests_zemu/snapshots/x-setWithdrawAddress/00013.png differ diff --git a/tests_zemu/tests/common.ts b/tests_zemu/tests/common.ts index d969c8f0..d6ef63f9 100644 --- a/tests_zemu/tests/common.ts +++ b/tests_zemu/tests/common.ts @@ -14,7 +14,6 @@ * limitations under the License. ******************************************************************************* */ import { DEFAULT_START_OPTIONS, DeviceModel } from '@zondax/zemu' -import {DEFAULT_KEY_DELAY} from "@zondax/zemu/src/constants"; const Resolve = require('path').resolve @@ -245,3 +244,59 @@ export const ibc_denoms = { ], sequence: '1' } + +export const setWithdrawAddress = { + account_number: '8', + chain_id: 'testing', + fee: { + amount: [ + { + amount: '5000', + denom: 'uatom' + } + ], + gas: '200000' + }, + memo: '', + msgs: [ + { + type: 'cosmos-sdk/MsgSetWithdrawAddress', + value: { + delegator_address: 'cosmos1hr9x0sjvel6z3vt9qny8sdd5gnnlgk0p69d6cv', + withdraw_address: 'cosmos12d64j98tjjpqkx70r08aspc4nvntqp2w6wr2de' + } + }, + { + type: 'cosmos-sdk/MsgWithdrawDelegationReward', + value: { + delegator_address: 'cosmos1hr9x0sjvel6z3vt9qny8sdd5gnnlgk0p69d6cv', + validator_address: 'cosmosvaloper13dr26wdygna3s8fdl5tlc45m2le2ydyddxzj49' + } + } + ], + sequence: '7' + } + + export const cliGovDeposit = { + account_number: '8', + chain_id: 'my-chain', + fee: { + amount: [], + gas: '200000' + }, + memo: 'A B C', + msgs: [ + { + type: 'cosmos-sdk/MsgDeposit', + value: { + amount: [{ + amount: '10', + denom: 'stake', + }], + depositor: 'cosmos1xl2256vdh0j68khz9wq88hnyqcq0f5f4za2480', + proposal_id: '1' + } + }, + ], + sequence: '2' + } diff --git a/tests_zemu/tests/json.test.ts b/tests_zemu/tests/json.test.ts index 642eabd9..cb0d13f6 100644 --- a/tests_zemu/tests/json.test.ts +++ b/tests_zemu/tests/json.test.ts @@ -17,7 +17,7 @@ import Zemu from '@zondax/zemu' // @ts-ignore import { CosmosApp } from '@zondax/ledger-cosmos-js' -import { DEFAULT_OPTIONS, DEVICE_MODELS, example_tx_str_basic, example_tx_str_basic2, ibc_denoms, AMINO_JSON_TX } from './common' +import { DEFAULT_OPTIONS, DEVICE_MODELS, example_tx_str_basic, example_tx_str_basic2, ibc_denoms, AMINO_JSON_TX, setWithdrawAddress, cliGovDeposit } from './common' // @ts-ignore import secp256k1 from 'secp256k1/elliptic' @@ -215,4 +215,94 @@ describe('Json', function () { await sim.close() } }) + + test.each(DEVICE_MODELS)('SetWithdrawAddress', async function (m) { + const sim = new Zemu(m.path) + try { + await sim.start({ ...DEFAULT_OPTIONS, model: m.name }) + const app = new CosmosApp(sim.getTransport()) + + const path = [44, 118, 0, 0, 0] + const tx = Buffer.from(JSON.stringify(setWithdrawAddress)) + + // get address / publickey + const respPk = await app.getAddressAndPubKey(path, 'cosmos') + expect(respPk.return_code).toEqual(0x9000) + expect(respPk.error_message).toEqual('No errors') + console.log(respPk) + + // do not wait here.. + const signatureRequest = app.sign(path, tx, 0x0) + + // Wait until we are not in the main menu + await sim.waitUntilScreenIsNot(sim.getMainMenuSnapshot()) + await sim.compareSnapshotsAndApprove('.', `${m.prefix.toLowerCase()}-setWithdrawAddress`) + + const resp = await signatureRequest + console.log(resp) + + expect(resp.return_code).toEqual(0x9000) + expect(resp.error_message).toEqual('No errors') + expect(resp).toHaveProperty('signature') + + // Now verify the signature + const hash = crypto.createHash('sha256') + const msgHash = Uint8Array.from(hash.update(tx).digest()) + + const signatureDER = resp.signature + const signature = secp256k1.signatureImport(Uint8Array.from(signatureDER)) + + const pk = Uint8Array.from(respPk.compressed_pk) + + const signatureOk = secp256k1.ecdsaVerify(signature, msgHash, pk) + expect(signatureOk).toEqual(true) + } finally { + await sim.close() + } + }) + + test.each(DEVICE_MODELS)('CLIGovDeposit', async function (m) { + const sim = new Zemu(m.path) + try { + await sim.start({ ...DEFAULT_OPTIONS, model: m.name }) + const app = new CosmosApp(sim.getTransport()) + + const path = [44, 118, 0, 0, 0] + const tx = Buffer.from(JSON.stringify(cliGovDeposit)) + + // get address / publickey + const respPk = await app.getAddressAndPubKey(path, 'cosmos') + expect(respPk.return_code).toEqual(0x9000) + expect(respPk.error_message).toEqual('No errors') + console.log(respPk) + + // do not wait here.. + const signatureRequest = app.sign(path, tx, 0x0) + + // Wait until we are not in the main menu + await sim.waitUntilScreenIsNot(sim.getMainMenuSnapshot()) + await sim.compareSnapshotsAndApprove('.', `${m.prefix.toLowerCase()}-govDeposit`) + + const resp = await signatureRequest + console.log(resp) + + expect(resp.return_code).toEqual(0x9000) + expect(resp.error_message).toEqual('No errors') + expect(resp).toHaveProperty('signature') + + // Now verify the signature + const hash = crypto.createHash('sha256') + const msgHash = Uint8Array.from(hash.update(tx).digest()) + + const signatureDER = resp.signature + const signature = secp256k1.signatureImport(Uint8Array.from(signatureDER)) + + const pk = Uint8Array.from(respPk.compressed_pk) + + const signatureOk = secp256k1.ecdsaVerify(signature, msgHash, pk) + expect(signatureOk).toEqual(true) + } finally { + await sim.close() + } + }) })