Skip to content

Commit

Permalink
Adding new error error code.
Browse files Browse the repository at this point in the history
  • Loading branch information
joaoccmartins committed Feb 5, 2025
1 parent dca0347 commit 497b6d6
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 1 deletion.
1 change: 1 addition & 0 deletions doc/COMMANDS.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,4 +96,5 @@ _Note:_ The maximum number of chunks depends on the maximum available RAM on eac
| 0xB007 | `SW_BAD_STATE` | Security issue with bad state |
| 0xB008 | `SW_SIGNATURE_FAIL` | Signature of raw transaction failed |
| 0xB009 | `SW_DISPLAY_GAS_FEE_FAIL` | Failed to display gas fee |
| 0xB00A | `SW_SWAP_CHECKING_FAIL` | Failed to validate a swap transaction |
| 0x9000 | `OK` | Success |
2 changes: 2 additions & 0 deletions src/handler/sign_tx.c
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ int handler_sign_tx(buffer_t *cdata, uint8_t chunk, bool more) {
// This code should never be triggered as the app is supposed to exit after
// sending the signed transaction
PRINTF("Safety against double signing triggered\n");
io_send_sw(SW_SWAP_CHECKING_FAIL);
os_sched_exit(-1);
} else {
// We will quit the app after this transaction, whether it succeeds or fails
Expand All @@ -143,6 +144,7 @@ int handler_sign_tx(buffer_t *cdata, uint8_t chunk, bool more) {
// Swap mode
PRINTF("swap_check_validity failed\n");
// Failsafe
io_send_sw(SW_SWAP_CHECKING_FAIL);
swap_finalize_exchange_sign_transaction(false);
}

Expand Down
2 changes: 1 addition & 1 deletion src/sw.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,4 +67,4 @@
/**
* Status word for fail to display gas fee.
*/
#define SW_SWAP_CHECKING_FAIL 0xB010
#define SW_SWAP_CHECKING_FAIL 0xB00A
1 change: 1 addition & 0 deletions tests/application_client/aptos_command_sender.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ class Errors(IntEnum):
SW_BAD_STATE = 0xB007
SW_SIGNATURE_FAIL = 0xB008
SW_DISPLAY_GAS_FEE_FAIL = 0xB009
SW_SWAP_CHECKING_FAIL = 0xB00A


def split_message(message: bytes, max_size: int) -> List[bytes]:
Expand Down

0 comments on commit 497b6d6

Please sign in to comment.