Skip to content

Commit

Permalink
Merge pull request cosmos#149 from cosmos/dev
Browse files Browse the repository at this point in the history
Swap improve (cosmos#148)
  • Loading branch information
chcmedeiros authored Jan 30, 2025
2 parents 5a180b0 + 1f01a63 commit c9c4d9b
Show file tree
Hide file tree
Showing 13 changed files with 25 additions and 16 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ jobs:
run: "cd tests_zemu; yarn test"
- name: Upload Snapshots (only failure)
if: ${{ failure() }}
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: snapshots-tmp
path: tests_zemu/snapshots-tmp/
Expand Down
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=36
# This is the patch version of this release
APPVERSION_P=5
APPVERSION_P=6
1 change: 1 addition & 0 deletions app/src/common/parser_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ typedef enum {
parser_swap_wrong_fee,
parser_swap_unexpected_number_of_items,
parser_swap_unexpected_field,
parser_swap_memo_not_present,
parser_swap_wrap_amount_computation_error,
parser_swap_wrong_type,
} parser_error_t;
Expand Down
2 changes: 2 additions & 0 deletions app/src/parser_impl.c
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,8 @@ const char *parser_getErrorDescription(parser_error_t err) {
return "Swap wrap amount computation error";
case parser_swap_wrong_type:
return "Swap wrong type";
case parser_swap_memo_not_present:
return "Swap memo not present";

default:
return "Unrecognized error code";
Expand Down
34 changes: 20 additions & 14 deletions app/src/swap/handle_sign_transaction.c
Original file line number Diff line number Diff line change
Expand Up @@ -179,17 +179,20 @@ parser_error_t parser_msg_send(parser_context_t *ctx_parsed_tx, uint8_t displayI
return parser_swap_wrong_dest_address;
}

// Check if memo is present
// Check if memo is present. If size of G_swap_state.memo is bigger than 0, then a memo should be present
displayIdx += 1;
uint8_t has_memo = 0;
CHECK_PARSER_ERR(parser_getItem(ctx_parsed_tx, displayIdx, tmpKey, sizeof(tmpKey), tmpValue, sizeof(tmpValue), pageIdx, &pageCount))
if (strcmp(tmpKey, "Memo") == 0) {
has_memo = 1;
if(strcmp(tmpValue, G_swap_state.memo) != 0) {
ZEMU_LOGF(200, "Wrong swap tx memo ('%s', should be : '%s').\n", tmpValue, G_swap_state.memo);
return parser_swap_wrong_memo;
if (strlen(G_swap_state.memo) > 0) {
if (strcmp(tmpKey, "Memo") == 0) {
has_memo = 1;
if(strcmp(tmpValue, G_swap_state.memo) != 0) {
ZEMU_LOGF(200, "Wrong swap tx memo ('%s', should be : '%s').\n", tmpValue, G_swap_state.memo);
return parser_swap_wrong_memo;
}
} else {
return parser_swap_memo_not_present;
}

// Prepare for fees
displayIdx += 1;
CHECK_PARSER_ERR(parser_getItem(ctx_parsed_tx, displayIdx, tmpKey, sizeof(tmpKey), tmpValue, sizeof(tmpValue), pageIdx, &pageCount))
Expand Down Expand Up @@ -309,17 +312,20 @@ parser_error_t parser_simple_transfer(parser_context_t *ctx_parsed_tx, uint8_t d
return parser_swap_wrong_dest_coins;
}

// Check if memo is present
// Check if memo is present. If size of G_swap_state.memo is bigger than 0, then a memo should be present
displayIdx += 1;
uint8_t has_memo = 0;
CHECK_PARSER_ERR(parser_getItem(ctx_parsed_tx, displayIdx, tmpKey, sizeof(tmpKey), tmpValue, sizeof(tmpValue), pageIdx, &pageCount))
if (strcmp(tmpKey, "Memo") == 0) {
has_memo = 1;
if(strcmp(tmpValue, G_swap_state.memo) != 0) {
ZEMU_LOGF(200, "Wrong swap tx memo ('%s', should be : '%s').\n", tmpValue, G_swap_state.memo);
return parser_swap_wrong_memo;
if (strlen(G_swap_state.memo) > 0) {
if (strcmp(tmpKey, "Memo") == 0) {
has_memo = 1;
if(strcmp(tmpValue, G_swap_state.memo) != 0) {
ZEMU_LOGF(200, "Wrong swap tx memo ('%s', should be : '%s').\n", tmpValue, G_swap_state.memo);
return parser_swap_wrong_memo;
}
} else {
return parser_swap_memo_not_present;
}

// Prepare for fees
displayIdx += 1;
CHECK_PARSER_ERR(parser_getItem(ctx_parsed_tx, displayIdx, tmpKey, sizeof(tmpKey), tmpValue, sizeof(tmpValue), pageIdx, &pageCount))
Expand Down
Binary file modified tests_zemu/snapshots/fl-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/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/st-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/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 c9c4d9b

Please sign in to comment.