Skip to content

Commit

Permalink
Merge pull request #69 from cosmos/multisend-display
Browse files Browse the repository at this point in the history
Multisend display
  • Loading branch information
ftheirs authored Jul 29, 2022
2 parents aa13af4 + 5ae68bc commit 181deab
Show file tree
Hide file tree
Showing 12 changed files with 38 additions and 15 deletions.
2 changes: 1 addition & 1 deletion app/Makefile.version
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ APPVERSION_M=2
# This is the `spec_version` field of `Runtime`
APPVERSION_N=34
# This is the patch version of this release
APPVERSION_P=6
APPVERSION_P=7
9 changes: 9 additions & 0 deletions app/src/parser.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ parser_error_t parser_parse(parser_context_t *ctx,
const uint8_t *data,
size_t dataLen) {
CHECK_PARSER_ERR(tx_display_readTx(ctx, data, dataLen))
extraDepthLevel =false;
return parser_ok;
}

Expand Down Expand Up @@ -92,6 +93,14 @@ __Z_INLINE bool_t parser_isAmount(char *key) {
return bool_true;
}

if (strcmp(key, "msgs/value/inputs/coins") == 0) {
return bool_true;
}

if (strcmp(key, "msgs/value/outputs/coins") == 0) {
return bool_true;
}

if (strcmp(key, "msgs/value/amount") == 0) {
return bool_true;
}
Expand Down
7 changes: 6 additions & 1 deletion app/src/tx_display.c
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ __Z_INLINE uint8_t get_root_max_level(root_item_e i) {
case root_item_memo:
return 2;
case root_item_msgs:
return 2;
return extraDepthLevel ? 3 : 2;
case root_item_tip:
return 1;
default:
Expand Down Expand Up @@ -471,6 +471,11 @@ static const key_subst_t key_substitutions[] = {
{"msgs/outputs/address", "Dest Address"},
{"msgs/outputs/coins", "Dest Coins"},

{"msgs/value/inputs/address", "Source Address"},
{"msgs/value/inputs/coins", "Source Coins"},
{"msgs/value/outputs/address", "Dest Address"},
{"msgs/value/outputs/coins", "Dest Coins"},

{"msgs/value/from_address", "From"},
{"msgs/value/to_address", "To"},
{"msgs/value/amount", "Amount"},
Expand Down
9 changes: 8 additions & 1 deletion app/src/tx_parser.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
#include "zxformat.h"
#include "parser_impl.h"

bool extraDepthLevel = false;

// strcat but source does not need to be terminated (a chunk from a bigger string is concatenated)
// dst_max is measured in bytes including the space for NULL termination
// src_size does not include NULL termination
Expand Down Expand Up @@ -60,6 +62,8 @@ static const key_subst_t value_substitutions[] = {
{"cosmos-sdk/MsgVote", "Vote"},
{"cosmos-sdk/MsgWithdrawDelegationReward", "Withdraw Reward"},
{"cosmos-sdk/MsgWithdrawValidatorCommission", "Withdraw Val. Commission"},
{"cosmos-sdk/MsgMultiSend", "Multi Send"},

};

parser_error_t tx_getToken(uint16_t token_index,
Expand Down Expand Up @@ -87,8 +91,11 @@ 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);
break;
}
}
}

pageStringExt(out_val, out_val_len, inValue, inLen, pageIdx, pageCount);
Expand Down
2 changes: 2 additions & 0 deletions app/src/tx_parser.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ 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) \
parser_tx_obj.query._item_index_current = 0; \
Expand Down
24 changes: 12 additions & 12 deletions tests/testcases/manual.json
Original file line number Diff line number Diff line change
Expand Up @@ -1826,18 +1826,18 @@
"0 | Chain ID : testing",
"1 | Account : 8",
"2 | Sequence : 0",
"3 | Type : cosmos-sdk/MsgMultiSend",
"4 | msgs/value/inputs [1/3] : [{\"address\":\"cosmos1hr9x0sjvel6z3vt9qny",
"4 | msgs/value/inputs [2/3] : 8sdd5gnnlgk0p69d6cv\",\"coins\":[{\"amount\"",
"4 | msgs/value/inputs [3/3] : :\"101000\",\"denom\":\"uatom\"}]}]",
"5 | msgs/value/outputs [1/6] : [{\"address\":\"cosmos13dr26wdygna3s8fdl5t",
"5 | msgs/value/outputs [2/6] : lc45m2le2ydydgjk8ek\",\"coins\":[{\"amount\"",
"5 | msgs/value/outputs [3/6] : :\"1000\",\"denom\":\"uatom\"}]},{\"address\":\"",
"5 | msgs/value/outputs [4/6] : cosmos1hr9x0sjvel6z3vt9qny8sdd5gnnlgk0p",
"5 | msgs/value/outputs [5/6] : 69d6cv\",\"coins\":[{\"amount\":\"100000\",\"de",
"5 | msgs/value/outputs [6/6] : nom\":\"uatom\"}]}]",
"6 | Fee : 0 uatom",
"7 | Gas : 200000"
"3 | Type : Multi Send",
"4 | Source Address [1/2] : cosmos1hr9x0sjvel6z3vt9qny8sdd5gnnlgk0p",
"4 | Source Address [2/2] : 69d6cv",
"5 | Source Coins : 101000 uatom",
"6 | Dest Address [1/2] : cosmos13dr26wdygna3s8fdl5tlc45m2le2ydyd",
"6 | Dest Address [2/2] : gjk8ek",
"7 | Dest Coins : 1000 uatom",
"8 | Dest Address [1/2] : cosmos1hr9x0sjvel6z3vt9qny8sdd5gnnlgk0p",
"8 | Dest Address [2/2] : 69d6cv",
"9 | Dest Coins : 100000 uatom",
"10 | Fee : 0 uatom",
"11 | Gas : 200000"
],
"expert": true
},
Expand Down
Binary file modified tests_zemu/snapshots/s-mainmenu/00004.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests_zemu/snapshots/s-mainmenu/00010.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests_zemu/snapshots/sp-mainmenu/00004.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests_zemu/snapshots/sp-mainmenu/00010.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests_zemu/snapshots/x-mainmenu/00004.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests_zemu/snapshots/x-mainmenu/00010.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 181deab

Please sign in to comment.