Skip to content

Commit

Permalink
Add expert mode (#37)
Browse files Browse the repository at this point in the history
* add expert mode requirement when unknown asset Id

* add zemu test with expert mode enabled
  • Loading branch information
chcmedeiros authored Nov 6, 2024
1 parent c7a86ad commit 07aeaf6
Show file tree
Hide file tree
Showing 42 changed files with 13 additions and 1 deletion.
1 change: 1 addition & 0 deletions app/src/common/parser_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ typedef enum {
parser_unexpected_chain,
parser_missing_field,
paser_unknown_transaction,
parser_require_expert_mode,
} parser_error_t;

typedef struct {
Expand Down
11 changes: 10 additions & 1 deletion app/src/parser.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include <zxmacros.h>
#include <zxtypes.h>

#include "app_mode.h"
#include "coin.h"
#include "crypto.h"
#include "crypto_helper.h"
Expand Down Expand Up @@ -49,8 +50,14 @@ parser_error_t parser_verify_asset_id(uint8_t *asset_id, uint8_t *index) {
return parser_ok;
}
}
// Temporarly set to unknown asset
#if defined(LEDGER_SPECIFIC)
// If no asset id is found, required expert mode
if (!app_mode_expert()) {
return parser_require_expert_mode;
}
#else
*index = 1;
#endif
return parser_ok;
}

Expand Down Expand Up @@ -212,6 +219,8 @@ const char *parser_getErrorDescription(parser_error_t err) {
return "display index out of range";
case parser_display_page_out_of_range:
return "display page out of range";
case parser_require_expert_mode:
return "Expert mode required";

default:
return "Unrecognized error code";
Expand Down
Binary file modified tests_zemu/snapshots/fl-sign_3_out_tx/00000.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/fl-sign_3_out_tx/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/fl-sign_3_out_tx/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/fl-sign_3_out_tx/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/fl-sign_3_out_tx/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/fl-sign_3_out_tx/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/fl-sign_3_out_tx/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/sp-sign_3_out_tx/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_3_out_tx/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_3_out_tx/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_3_out_tx/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/sp-sign_3_out_tx/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/sp-sign_3_out_tx/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 modified tests_zemu/snapshots/sp-sign_3_out_tx/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 modified tests_zemu/snapshots/sp-sign_3_out_tx/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/sp-sign_3_out_tx/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_3_out_tx/00011.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_3_out_tx/00012.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_3_out_tx/00013.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_3_out_tx/00014.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-sign_3_out_tx/00000.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-sign_3_out_tx/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/st-sign_3_out_tx/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/st-sign_3_out_tx/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/st-sign_3_out_tx/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/st-sign_3_out_tx/00005.png
Binary file modified tests_zemu/snapshots/x-sign_3_out_tx/00002.png
Binary file modified tests_zemu/snapshots/x-sign_3_out_tx/00003.png
Binary file modified tests_zemu/snapshots/x-sign_3_out_tx/00004.png
Binary file modified tests_zemu/snapshots/x-sign_3_out_tx/00005.png
Binary file modified tests_zemu/snapshots/x-sign_3_out_tx/00006.png
Binary file modified tests_zemu/snapshots/x-sign_3_out_tx/00007.png
Binary file modified tests_zemu/snapshots/x-sign_3_out_tx/00008.png
Binary file modified tests_zemu/snapshots/x-sign_3_out_tx/00009.png
Binary file modified tests_zemu/snapshots/x-sign_3_out_tx/00010.png
Binary file modified tests_zemu/snapshots/x-sign_3_out_tx/00011.png
Binary file modified tests_zemu/snapshots/x-sign_3_out_tx/00012.png
Binary file modified tests_zemu/snapshots/x-sign_3_out_tx/00013.png
Binary file modified tests_zemu/snapshots/x-sign_3_out_tx/00014.png
2 changes: 2 additions & 0 deletions tests_zemu/tests/standard.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,8 @@ describe('Standard', function () {
await sim.start({ ...defaultOptions, model: m.name })
const app = new IronfishApp(sim.getTransport(), false)

await sim.toggleExpertMode()

const txBlob = Buffer.from(tx_output_3, 'hex')
const responsePublicAddress = await app.retrieveKeys(PATH, IronfishKeys.PublicAddress, false)
console.log(responsePublicAddress)
Expand Down

0 comments on commit 07aeaf6

Please sign in to comment.