Skip to content
This repository has been archived by the owner on Oct 18, 2024. It is now read-only.

Commit

Permalink
ui improvement
Browse files Browse the repository at this point in the history
  • Loading branch information
jleni committed May 17, 2020
1 parent 137eca5 commit fb938c8
Show file tree
Hide file tree
Showing 8 changed files with 51 additions and 14 deletions.
2 changes: 1 addition & 1 deletion app/Makefile.version
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
APPVERSION_M=0
APPVERSION_N=1062
APPVERSION_P=0
APPVERSION_P=1
2 changes: 1 addition & 1 deletion app/src/common/parser.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ parser_error_t parser_parse(parser_context_t *ctx,
parser_error_t parser_validate(const parser_context_t *ctx);

//// returns the number of items in the current parsing context
parser_error_t parser_getNumItems(const parser_context_t *ctx, uint16_t *num_items);
parser_error_t parser_getNumItems(const parser_context_t *ctx, uint8_t *num_items);

// retrieves a readable output for each field / page
parser_error_t parser_getItem(const parser_context_t *ctx,
Expand Down
4 changes: 2 additions & 2 deletions app/src/common/tx.c
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ const char *tx_parse() {
return NULL;
}

tx_error_t tx_getNumItems(uint16_t *num_items) {
tx_error_t tx_getNumItems(uint8_t *num_items) {
parser_error_t err = parser_getNumItems(&ctx_parsed_tx, num_items);

if (err != parser_ok) {
Expand All @@ -109,7 +109,7 @@ tx_error_t tx_getItem(int8_t displayIdx,
uint8_t pageIdx, uint8_t *pageCount) {
tx_error_t err = tx_no_error;

uint16_t numItems = 0;
uint8_t numItems = 0;
err = tx_getNumItems(&numItems);
if (err != tx_no_error) {
return err;
Expand Down
2 changes: 1 addition & 1 deletion app/src/common/tx.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ uint8_t *tx_get_buffer();
const char *tx_parse();

/// Return the number of items in the transaction
tx_error_t tx_getNumItems(uint16_t *num_items);
tx_error_t tx_getNumItems(uint8_t *num_items);

/// Gets an specific item from the transaction (including paging)
tx_error_t tx_getItem(int8_t displayIdx,
Expand Down
4 changes: 2 additions & 2 deletions app/src/parser.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ parser_error_t parser_validate(const parser_context_t *ctx) {
return parser_ok;
}

parser_error_t parser_getNumItems(const parser_context_t *ctx, uint16_t *num_items) {
parser_error_t parser_getNumItems(const parser_context_t *ctx, uint8_t *num_items) {
uint8_t methodArgCount = _getMethod_NumItems(parser_tx_obj.callIndex.moduleIdx,
parser_tx_obj.callIndex.idx,
&parser_tx_obj.method);
Expand All @@ -57,7 +57,7 @@ parser_error_t parser_getItem(const parser_context_t *ctx,
MEMZERO(outKey, outKeyLen);
MEMZERO(outValue, outValueLen);

uint16_t numItems;
uint8_t numItems;

CHECK_PARSER_ERR(parser_getNumItems(ctx, &numItems));
*pageCount = 1;
Expand Down
19 changes: 15 additions & 4 deletions deps/ledger-zxlib/app/common/view.c
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,17 @@ view_error_t h_review_update_data() {
tx_error_t err = tx_no_error;

do {
err = tx_getNumItems(&viewdata.itemCount);
viewdata.itemCount++;

if (err == tx_no_data) {
return view_no_data;
}

if (err != tx_no_error) {
return view_error_detected;
}

err = tx_getItem(viewdata.itemIdx,
viewdata.key, MAX_CHARS_PER_KEY_LINE,
viewdata.value, MAX_CHARS_PER_VALUE1_LINE,
Expand All @@ -124,15 +135,15 @@ view_error_t h_review_update_data() {
return view_no_data;
}

if (err != tx_no_error) {
return view_error_detected;
}

if (viewdata.pageCount == 0) {
h_paging_increase();
}
} while (viewdata.pageCount == 0);

if (err != tx_no_error) {
return view_error_detected;
}

splitValueField();
return view_no_error;
}
Expand Down
2 changes: 1 addition & 1 deletion tests/utils/common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
std::vector<std::string> dumpUI(parser_context_t *ctx,
uint16_t maxKeyLen,
uint16_t maxValueLen) {
uint16_t numItems;
uint8_t numItems;

parser_getNumItems(ctx, &numItems);

Expand Down
30 changes: 28 additions & 2 deletions tests_zemu/tools/debug.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,37 @@ async function debugScenario(sim, app) {
const pathChange = 0x80000000;
const pathIndex = 0x80000000;

let txBlobStr = "0400ffbc10f71d63e0da1b9e7ee2eb4037466551dc32b9d4641aafd73a65970fae4202286beed502000022040000b0a8d493285c2df73290dfb7e61f870f17b41801197a149ca93654499ea3dafe280b332587f46c556aa806781884284f50d90b8c1b02488a059700673c93f41c";
let txBlobStr = "04002756865871cd8e8c2e27b5c5254a8ab6933a5c3081bdcbdc78751fb9c8af12f200d503008ed73e0d26040000b0a8d493285c2df73290dfb7e61f870f17b41801197a149ca93654499ea3dafeb0a8d493285c2df73290dfb7e61f870f17b41801197a149ca93654499ea3dafe";
const txBlob = Buffer.from(txBlobStr, "hex");

const respRequest = app.getAddress(0x80000000, 0x80000000, 0x80000000, true);
await Zemu.default.sleep(1000);
await sim.clickRight();
await sim.clickRight();
await sim.clickRight();
await sim.clickRight();
await sim.clickRight();
await sim.clickBoth();
let addr = await respRequest;

// do not wait here.. we need to navigate
const signature = await app.sign(pathAccount, pathChange, pathIndex, txBlob);
const signatureRequest = app.sign(pathAccount, pathChange, pathIndex, txBlob);
await Zemu.default.sleep(1000);
await sim.clickRight();
await sim.clickRight();
await sim.clickRight();
await sim.clickRight();
await sim.clickRight();
await sim.clickRight();
await sim.clickRight();
await sim.clickRight();
await sim.clickRight();
await sim.clickRight();
await sim.clickRight();
await sim.clickRight();
await sim.clickBoth();

let signature = await signatureRequest;
console.log(signature);
}

Expand Down

0 comments on commit fb938c8

Please sign in to comment.