diff --git a/app/src/parser/micheline_parser.c b/app/src/parser/micheline_parser.c index a7209c77c..0b33a9d83 100644 --- a/app/src/parser/micheline_parser.c +++ b/app/src/parser/micheline_parser.c @@ -47,6 +47,7 @@ tz_micheline_parser_init(tz_parser_state *state) m->frame = m->stack; m->stack[0].step = TZ_MICHELINE_STEP_TAG; + m->is_unit = false; } /** @@ -373,6 +374,12 @@ tz_micheline_parser_step(tz_parser_state *state) } m->frame->step = TZ_MICHELINE_STEP_PRIM_NAME; m->frame->step_prim.op = op; + // clang-format off + m->is_unit = ((m->frame == m->stack) + && (op == TZ_MICHELSON_OP_Unit) + && (m->frame->step_prim.nargs == 0) + && (!m->frame->step_prim.annot)); + // clang-format on break; case TZ_MICHELINE_STEP_PRIM_NAME: if (m->frame->step_prim.wrap && m->frame->step_prim.first) { diff --git a/app/src/parser/micheline_state.h b/app/src/parser/micheline_state.h index d77ddaf5a..6584396d7 100644 --- a/app/src/parser/micheline_state.h +++ b/app/src/parser/micheline_state.h @@ -129,4 +129,5 @@ typedef struct { stack[TZ_MICHELINE_STACK_DEPTH]; /// stack of frames tz_micheline_parser_frame *frame; /// current frame /// init == stack, NULL when done + bool is_unit; /// indicates whether the micheline read is a unit } tz_micheline_state; diff --git a/app/src/parser/operation_parser.c b/app/src/parser/operation_parser.c index 9703d2ca6..118ec8fb9 100644 --- a/app/src/parser/operation_parser.c +++ b/app/src/parser/operation_parser.c @@ -573,6 +573,9 @@ tz_step_read_micheline(tz_parser_state *state) } tz_micheline_parser_step(state); if (state->errno == TZ_BLO_DONE) { + if (state->micheline.is_unit) { + state->field_info.is_field_complex = false; + } if ((op->frame->stop != 0) && (state->ofs != op->frame->stop)) { tz_raise(TOO_LARGE); } diff --git a/tests/integration/nano/snapshots/nanos/test_sign_transaction/finalize_unstake/00011.png b/tests/integration/nano/snapshots/nanos/test_sign_transaction/finalize_unstake/00011.png index 92b4bce4e..ea964d444 100644 Binary files a/tests/integration/nano/snapshots/nanos/test_sign_transaction/finalize_unstake/00011.png and b/tests/integration/nano/snapshots/nanos/test_sign_transaction/finalize_unstake/00011.png differ diff --git a/tests/integration/nano/snapshots/nanos/test_sign_transaction/finalize_unstake/00012.png b/tests/integration/nano/snapshots/nanos/test_sign_transaction/finalize_unstake/00012.png index ea964d444..7e0e23820 100644 Binary files a/tests/integration/nano/snapshots/nanos/test_sign_transaction/finalize_unstake/00012.png and b/tests/integration/nano/snapshots/nanos/test_sign_transaction/finalize_unstake/00012.png differ diff --git a/tests/integration/nano/snapshots/nanos/test_sign_transaction/finalize_unstake/00013.png b/tests/integration/nano/snapshots/nanos/test_sign_transaction/finalize_unstake/00013.png deleted file mode 100644 index 7e0e23820..000000000 Binary files a/tests/integration/nano/snapshots/nanos/test_sign_transaction/finalize_unstake/00013.png and /dev/null differ diff --git a/tests/integration/nano/snapshots/nanos/test_sign_transaction/stake/00011.png b/tests/integration/nano/snapshots/nanos/test_sign_transaction/stake/00011.png index 92b4bce4e..ea964d444 100644 Binary files a/tests/integration/nano/snapshots/nanos/test_sign_transaction/stake/00011.png and b/tests/integration/nano/snapshots/nanos/test_sign_transaction/stake/00011.png differ diff --git a/tests/integration/nano/snapshots/nanos/test_sign_transaction/stake/00012.png b/tests/integration/nano/snapshots/nanos/test_sign_transaction/stake/00012.png index ea964d444..7e0e23820 100644 Binary files a/tests/integration/nano/snapshots/nanos/test_sign_transaction/stake/00012.png and b/tests/integration/nano/snapshots/nanos/test_sign_transaction/stake/00012.png differ diff --git a/tests/integration/nano/snapshots/nanos/test_sign_transaction/stake/00013.png b/tests/integration/nano/snapshots/nanos/test_sign_transaction/stake/00013.png deleted file mode 100644 index 7e0e23820..000000000 Binary files a/tests/integration/nano/snapshots/nanos/test_sign_transaction/stake/00013.png and /dev/null differ diff --git a/tests/integration/nano/snapshots/nanos/test_sign_transaction/unstake/00011.png b/tests/integration/nano/snapshots/nanos/test_sign_transaction/unstake/00011.png index 92b4bce4e..ea964d444 100644 Binary files a/tests/integration/nano/snapshots/nanos/test_sign_transaction/unstake/00011.png and b/tests/integration/nano/snapshots/nanos/test_sign_transaction/unstake/00011.png differ diff --git a/tests/integration/nano/snapshots/nanos/test_sign_transaction/unstake/00012.png b/tests/integration/nano/snapshots/nanos/test_sign_transaction/unstake/00012.png index ea964d444..7e0e23820 100644 Binary files a/tests/integration/nano/snapshots/nanos/test_sign_transaction/unstake/00012.png and b/tests/integration/nano/snapshots/nanos/test_sign_transaction/unstake/00012.png differ diff --git a/tests/integration/nano/snapshots/nanos/test_sign_transaction/unstake/00013.png b/tests/integration/nano/snapshots/nanos/test_sign_transaction/unstake/00013.png deleted file mode 100644 index 7e0e23820..000000000 Binary files a/tests/integration/nano/snapshots/nanos/test_sign_transaction/unstake/00013.png and /dev/null differ diff --git a/tests/integration/nano/snapshots/nanosp/test_sign_transaction/finalize_unstake/00008.png b/tests/integration/nano/snapshots/nanosp/test_sign_transaction/finalize_unstake/00008.png index 59fce75cd..6b562f764 100644 Binary files a/tests/integration/nano/snapshots/nanosp/test_sign_transaction/finalize_unstake/00008.png and b/tests/integration/nano/snapshots/nanosp/test_sign_transaction/finalize_unstake/00008.png differ diff --git a/tests/integration/nano/snapshots/nanosp/test_sign_transaction/finalize_unstake/00009.png b/tests/integration/nano/snapshots/nanosp/test_sign_transaction/finalize_unstake/00009.png index 6b562f764..471324463 100644 Binary files a/tests/integration/nano/snapshots/nanosp/test_sign_transaction/finalize_unstake/00009.png and b/tests/integration/nano/snapshots/nanosp/test_sign_transaction/finalize_unstake/00009.png differ diff --git a/tests/integration/nano/snapshots/nanosp/test_sign_transaction/finalize_unstake/00010.png b/tests/integration/nano/snapshots/nanosp/test_sign_transaction/finalize_unstake/00010.png deleted file mode 100644 index 471324463..000000000 Binary files a/tests/integration/nano/snapshots/nanosp/test_sign_transaction/finalize_unstake/00010.png and /dev/null differ diff --git a/tests/integration/nano/snapshots/nanosp/test_sign_transaction/stake/00008.png b/tests/integration/nano/snapshots/nanosp/test_sign_transaction/stake/00008.png index 59fce75cd..6b562f764 100644 Binary files a/tests/integration/nano/snapshots/nanosp/test_sign_transaction/stake/00008.png and b/tests/integration/nano/snapshots/nanosp/test_sign_transaction/stake/00008.png differ diff --git a/tests/integration/nano/snapshots/nanosp/test_sign_transaction/stake/00009.png b/tests/integration/nano/snapshots/nanosp/test_sign_transaction/stake/00009.png index 6b562f764..471324463 100644 Binary files a/tests/integration/nano/snapshots/nanosp/test_sign_transaction/stake/00009.png and b/tests/integration/nano/snapshots/nanosp/test_sign_transaction/stake/00009.png differ diff --git a/tests/integration/nano/snapshots/nanosp/test_sign_transaction/stake/00010.png b/tests/integration/nano/snapshots/nanosp/test_sign_transaction/stake/00010.png deleted file mode 100644 index 471324463..000000000 Binary files a/tests/integration/nano/snapshots/nanosp/test_sign_transaction/stake/00010.png and /dev/null differ diff --git a/tests/integration/nano/snapshots/nanosp/test_sign_transaction/unstake/00008.png b/tests/integration/nano/snapshots/nanosp/test_sign_transaction/unstake/00008.png index 59fce75cd..6b562f764 100644 Binary files a/tests/integration/nano/snapshots/nanosp/test_sign_transaction/unstake/00008.png and b/tests/integration/nano/snapshots/nanosp/test_sign_transaction/unstake/00008.png differ diff --git a/tests/integration/nano/snapshots/nanosp/test_sign_transaction/unstake/00009.png b/tests/integration/nano/snapshots/nanosp/test_sign_transaction/unstake/00009.png index 6b562f764..471324463 100644 Binary files a/tests/integration/nano/snapshots/nanosp/test_sign_transaction/unstake/00009.png and b/tests/integration/nano/snapshots/nanosp/test_sign_transaction/unstake/00009.png differ diff --git a/tests/integration/nano/snapshots/nanosp/test_sign_transaction/unstake/00010.png b/tests/integration/nano/snapshots/nanosp/test_sign_transaction/unstake/00010.png deleted file mode 100644 index 471324463..000000000 Binary files a/tests/integration/nano/snapshots/nanosp/test_sign_transaction/unstake/00010.png and /dev/null differ diff --git a/tests/integration/nano/snapshots/nanox/test_sign_transaction/finalize_unstake/00008.png b/tests/integration/nano/snapshots/nanox/test_sign_transaction/finalize_unstake/00008.png index 59fce75cd..6b562f764 100644 Binary files a/tests/integration/nano/snapshots/nanox/test_sign_transaction/finalize_unstake/00008.png and b/tests/integration/nano/snapshots/nanox/test_sign_transaction/finalize_unstake/00008.png differ diff --git a/tests/integration/nano/snapshots/nanox/test_sign_transaction/finalize_unstake/00009.png b/tests/integration/nano/snapshots/nanox/test_sign_transaction/finalize_unstake/00009.png index 6b562f764..471324463 100644 Binary files a/tests/integration/nano/snapshots/nanox/test_sign_transaction/finalize_unstake/00009.png and b/tests/integration/nano/snapshots/nanox/test_sign_transaction/finalize_unstake/00009.png differ diff --git a/tests/integration/nano/snapshots/nanox/test_sign_transaction/finalize_unstake/00010.png b/tests/integration/nano/snapshots/nanox/test_sign_transaction/finalize_unstake/00010.png deleted file mode 100644 index 471324463..000000000 Binary files a/tests/integration/nano/snapshots/nanox/test_sign_transaction/finalize_unstake/00010.png and /dev/null differ diff --git a/tests/integration/nano/snapshots/nanox/test_sign_transaction/stake/00008.png b/tests/integration/nano/snapshots/nanox/test_sign_transaction/stake/00008.png index 59fce75cd..6b562f764 100644 Binary files a/tests/integration/nano/snapshots/nanox/test_sign_transaction/stake/00008.png and b/tests/integration/nano/snapshots/nanox/test_sign_transaction/stake/00008.png differ diff --git a/tests/integration/nano/snapshots/nanox/test_sign_transaction/stake/00009.png b/tests/integration/nano/snapshots/nanox/test_sign_transaction/stake/00009.png index 6b562f764..471324463 100644 Binary files a/tests/integration/nano/snapshots/nanox/test_sign_transaction/stake/00009.png and b/tests/integration/nano/snapshots/nanox/test_sign_transaction/stake/00009.png differ diff --git a/tests/integration/nano/snapshots/nanox/test_sign_transaction/stake/00010.png b/tests/integration/nano/snapshots/nanox/test_sign_transaction/stake/00010.png deleted file mode 100644 index 471324463..000000000 Binary files a/tests/integration/nano/snapshots/nanox/test_sign_transaction/stake/00010.png and /dev/null differ diff --git a/tests/integration/nano/snapshots/nanox/test_sign_transaction/unstake/00008.png b/tests/integration/nano/snapshots/nanox/test_sign_transaction/unstake/00008.png index 59fce75cd..6b562f764 100644 Binary files a/tests/integration/nano/snapshots/nanox/test_sign_transaction/unstake/00008.png and b/tests/integration/nano/snapshots/nanox/test_sign_transaction/unstake/00008.png differ diff --git a/tests/integration/nano/snapshots/nanox/test_sign_transaction/unstake/00009.png b/tests/integration/nano/snapshots/nanox/test_sign_transaction/unstake/00009.png index 6b562f764..471324463 100644 Binary files a/tests/integration/nano/snapshots/nanox/test_sign_transaction/unstake/00009.png and b/tests/integration/nano/snapshots/nanox/test_sign_transaction/unstake/00009.png differ diff --git a/tests/integration/nano/snapshots/nanox/test_sign_transaction/unstake/00010.png b/tests/integration/nano/snapshots/nanox/test_sign_transaction/unstake/00010.png deleted file mode 100644 index 471324463..000000000 Binary files a/tests/integration/nano/snapshots/nanox/test_sign_transaction/unstake/00010.png and /dev/null differ diff --git a/tests/unit/ctest/tests_parser.c b/tests/unit/ctest/tests_parser.c index 62981111e..6d0db9ce6 100644 --- a/tests/unit/ctest/tests_parser.c +++ b/tests/unit/ctest/tests_parser.c @@ -304,7 +304,7 @@ CTEST2(operation_parser, check_stake_complexity) // {"Option", _, 6}, // {"Tuple", _, 7}, {"Entrypoint", false, 8}, - {"Parameter", true, 9}, + {"Parameter", false, 9}, }; check_field_complexity(data, str, fields_check, sizeof(fields_check)); } @@ -324,7 +324,7 @@ CTEST2(operation_parser, check_unstake_complexity) // {"Option", _, 6}, // {"Tuple", _, 7}, {"Entrypoint", false, 8}, - {"Parameter", true, 9}, + {"Parameter", false, 9}, }; check_field_complexity(data, str, fields_check, sizeof(fields_check)); } @@ -344,7 +344,7 @@ CTEST2(operation_parser, check_finalize_unstake_complexity) // {"Option", _, 6}, // {"Tuple", _, 7}, {"Entrypoint", false, 8}, - {"Parameter", true, 9}, + {"Parameter", false, 9}, }; check_field_complexity(data, str, fields_check, sizeof(fields_check)); }