Skip to content

Commit

Permalink
Merge pull request #108 from cosmos/dev
Browse files Browse the repository at this point in the history
Improvements
  • Loading branch information
ftheirs authored Jan 11, 2024
2 parents 0c768a3 + 8e751a7 commit 25096fa
Show file tree
Hide file tree
Showing 66 changed files with 29 additions and 196 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=35
# This is the patch version of this release
APPVERSION_P=17
APPVERSION_P=18
170 changes: 0 additions & 170 deletions app/script_s2.ld

This file was deleted.

10 changes: 1 addition & 9 deletions app/src/apdu_handler.c
Original file line number Diff line number Diff line change
Expand Up @@ -203,18 +203,10 @@ __Z_INLINE void handleSign(volatile uint32_t *flags, volatile uint32_t *tx, uint
THROW(APDU_CODE_DATA_INVALID);
}

// Put address in output buffer, we will use it to confirm source address
zxerr_t zxerr = app_fill_address();
if (zxerr != zxerr_ok) {
*tx = 0;
THROW(APDU_CODE_DATA_INVALID);
}

parser_tx_obj.tx_json.own_addr = (const char *) (G_io_apdu_buffer + VIEW_ADDRESS_OFFSET_SECP256K1);
const char *error_msg = tx_parse(sign_type);

if (error_msg != NULL) {
int error_msg_length = strlen(error_msg);
const int error_msg_length = strnlen(error_msg, sizeof(G_io_apdu_buffer));
MEMCPY(G_io_apdu_buffer, error_msg, error_msg_length);
*tx += (error_msg_length);
THROW(APDU_CODE_DATA_INVALID);
Expand Down
4 changes: 2 additions & 2 deletions app/src/parser_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ typedef struct {
} parser_context_t;

typedef struct {
char str1[50];
char str2[50];
const char *str1;
const char *str2;
} key_subst_t;

typedef struct {
Expand Down
20 changes: 15 additions & 5 deletions app/src/tx_display.c
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,7 @@ __Z_INLINE parser_error_t is_default_chainid(bool *is_default) {
if (is_default == NULL) {
return parser_unexpected_value;
}

CHECK_PARSER_ERR(tx_indexRootFields())
*is_default = display_cache.is_default_chain;

Expand Down Expand Up @@ -355,7 +355,7 @@ __Z_INLINE parser_error_t get_subitem_count(root_item_e root_item, uint8_t *num_

int32_t tmp_num_items = display_cache.root_item_number_subitems[root_item];
bool is_expert_or_default = false;

switch (root_item) {
case root_item_chain_id:
case root_item_sequence:
Expand Down Expand Up @@ -508,6 +508,7 @@ static const key_subst_t key_substitutions[] = {
{"memo", "Memo"},
{"fee/amount", "Fee"},
{"fee/gas", "Gas"},
{"fee/gas_limit", "Gas Limit"},
{"fee/granter", "Granter"},
{"fee/payer", "Payer"},
{"msgs/type", "Type"},
Expand Down Expand Up @@ -550,9 +551,18 @@ parser_error_t tx_display_make_friendly() {

// post process keys
for (size_t i = 0; i < array_length(key_substitutions); i++) {
if (!strncmp(parser_tx_obj.tx_json.query.out_key, key_substitutions[i].str1, strlen(key_substitutions[i].str1))) {
strncpy_s(parser_tx_obj.tx_json.query.out_key, key_substitutions[i].str2, parser_tx_obj.tx_json.query.out_key_len);
break;
const char* str1 = (const char*) PIC(key_substitutions[i].str1);
const char* str2 = (const char*) PIC(key_substitutions[i].str2);
const uint16_t str1Len = strlen(str1);
const uint16_t str2Len = strlen(str2);


const uint16_t outKeyLen = strnlen(parser_tx_obj.tx_json.query.out_key, parser_tx_obj.tx_json.query.out_key_len);
if ((outKeyLen == str1Len && strncmp(parser_tx_obj.tx_json.query.out_key, str1, str1Len) == 0)
&& parser_tx_obj.tx_json.query.out_key_len >= str2Len) {
MEMZERO(parser_tx_obj.tx_json.query.out_key, parser_tx_obj.tx_json.query.out_key_len);
MEMCPY(parser_tx_obj.tx_json.query.out_key, str2, str2Len);
break;
}
}

Expand Down
17 changes: 9 additions & 8 deletions app/src/tx_parser.c
Original file line number Diff line number Diff line change
Expand Up @@ -84,28 +84,29 @@ 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) {
for (uint32_t i = 0; i < array_length(value_substitutions); i++) {
const char *substStr = value_substitutions[i].str1;
const size_t substStrLen = strlen(substStr);
if (inLen == substStrLen && !MEMCMP(inValue, substStr, substStrLen)) {
inValue = value_substitutions[i].str2;
inLen = strlen(value_substitutions[i].str2);
const char* str1 = (const char*) PIC(value_substitutions[i].str1);
const char* str2 = (const char*) PIC(value_substitutions[i].str2);
const uint16_t str1Len = strlen(str1);
const uint16_t str2Len = strlen(str2);

if (inLen == str1Len && strncmp(inValue, str1, str1Len) == 0) {
inValue = str2;
inLen = str2Len;

//Extra Depth level for Multisend type
extraDepthLevel = false;
if (strstr(inValue, "Multi") != NULL) {
extraDepthLevel = true;
}

break;
}
}

pageStringExt(out_val, out_val_len, inValue, inLen, pageIdx, pageCount);

}

if (pageIdx >= *pageCount) {
Expand Down
2 changes: 1 addition & 1 deletion tests/testcases/manual.json
Original file line number Diff line number Diff line change
Expand Up @@ -2174,7 +2174,7 @@
"5 | Sender [2/2] : wcgvqa",
"6 | Proposal ID : 44",
"7 | Fee : 54 uatom",
"8 | Gas : 106309",
"8 | Gas Limit : 106309",
"9 | Granter : cosmosaccaddr1d9h8xxxGRANTER",
"10 | Payer : cosmosaccaddr1d9h8qatxxPAYER"
],
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/s-sign_basic/00001.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-sign_basic/00002.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-sign_basic/00003.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-sign_basic/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-sign_basic/00005.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-sign_basic/00006.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-sign_basic/00007.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 added tests_zemu/snapshots/s-sign_basic/00008.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 added tests_zemu/snapshots/s-sign_basic/00009.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-sign_basic_extra_fields/00001.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-sign_basic_extra_fields/00002.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-sign_basic_extra_fields/00003.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-sign_basic_extra_fields/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-sign_basic_extra_fields/00005.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-sign_basic_extra_fields/00006.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-sign_basic_extra_fields/00007.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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/sp-sign_basic/00002.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-sign_basic/00003.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-sign_basic/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-sign_basic/00005.png
Binary file modified tests_zemu/snapshots/sp-sign_basic/00006.png
Binary file added tests_zemu/snapshots/sp-sign_basic/00007.png
Binary file modified tests_zemu/snapshots/sp-sign_basic_extra_fields/00002.png
Binary file modified tests_zemu/snapshots/sp-sign_basic_extra_fields/00003.png
Binary file modified tests_zemu/snapshots/sp-sign_basic_extra_fields/00004.png
Binary file modified tests_zemu/snapshots/sp-sign_basic_extra_fields/00005.png
Binary file modified tests_zemu/snapshots/sp-sign_basic_extra_fields/00006.png
Binary file modified tests_zemu/snapshots/st-mainmenu/00001.png
Binary file modified tests_zemu/snapshots/st-sign_basic/00001.png
Binary file modified tests_zemu/snapshots/st-sign_basic/00002.png
Binary file modified tests_zemu/snapshots/st-sign_basic/00003.png
Binary file modified tests_zemu/snapshots/st-sign_basic/00004.png
Binary file added tests_zemu/snapshots/st-sign_basic/00005.png
Binary file modified tests_zemu/snapshots/st-sign_basic_extra_fields/00001.png
Binary file modified tests_zemu/snapshots/st-sign_basic_extra_fields/00002.png
Binary file modified tests_zemu/snapshots/st-sign_basic_extra_fields/00003.png
Binary file modified tests_zemu/snapshots/st-sign_basic_extra_fields/00004.png
Binary file modified tests_zemu/snapshots/x-mainmenu/00004.png
Binary file modified tests_zemu/snapshots/x-mainmenu/00010.png
Binary file modified tests_zemu/snapshots/x-sign_basic/00002.png
Binary file modified tests_zemu/snapshots/x-sign_basic/00003.png
Binary file modified tests_zemu/snapshots/x-sign_basic/00004.png
Binary file modified tests_zemu/snapshots/x-sign_basic/00005.png
Binary file modified tests_zemu/snapshots/x-sign_basic/00006.png
Binary file added tests_zemu/snapshots/x-sign_basic/00007.png
Binary file modified tests_zemu/snapshots/x-sign_basic_extra_fields/00002.png
Binary file modified tests_zemu/snapshots/x-sign_basic_extra_fields/00003.png
Binary file modified tests_zemu/snapshots/x-sign_basic_extra_fields/00004.png
Binary file modified tests_zemu/snapshots/x-sign_basic_extra_fields/00005.png
Binary file modified tests_zemu/snapshots/x-sign_basic_extra_fields/00006.png

0 comments on commit 25096fa

Please sign in to comment.