Skip to content

Commit

Permalink
Merge pull request trilitech#192 from trilitech/palmer@functori@exper…
Browse files Browse the repository at this point in the history
…t-mode-splash-screen-before-parameter

Add an expert mode splash screen before the parameter field of the transaction operation
  • Loading branch information
ajinkyaraj-23 authored Jan 12, 2024
2 parents 5ea20f3 + 80762b9 commit 487015d
Show file tree
Hide file tree
Showing 219 changed files with 1,039 additions and 792 deletions.
1,742 changes: 967 additions & 775 deletions app/src/parser/operation_parser.c

Large diffs are not rendered by default.

35 changes: 28 additions & 7 deletions app/src/parser/operation_state.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,15 @@ typedef enum {
} tz_operation_tag;

typedef enum {
TZ_OPERATION_STEP_OPTION,
TZ_OPERATION_STEP_TUPLE,
TZ_OPERATION_STEP_MAGIC,
TZ_OPERATION_STEP_READ_BINARY,
TZ_OPERATION_STEP_BRANCH,
TZ_OPERATION_STEP_BATCH,
TZ_OPERATION_STEP_TAG,
TZ_OPERATION_STEP_SIZE,
TZ_OPERATION_STEP_OPERATION,
TZ_OPERATION_STEP_FIELD,
TZ_OPERATION_STEP_PRINT,
TZ_OPERATION_STEP_PARTIAL_PRINT,
TZ_OPERATION_STEP_READ_NUM,
Expand All @@ -62,7 +64,9 @@ typedef enum {
} tz_operation_parser_step_kind;

typedef enum {
TZ_OPERATION_FIELD_SKIP, // not for use in field descriptors
TZ_OPERATION_FIELD_END = 0, // not for use in field descriptors
TZ_OPERATION_FIELD_OPTION,
TZ_OPERATION_FIELD_TUPLE,
TZ_OPERATION_FIELD_BINARY,
TZ_OPERATION_FIELD_INT,
TZ_OPERATION_FIELD_NAT,
Expand All @@ -78,7 +82,7 @@ typedef enum {
TZ_OPERATION_FIELD_PROTO,
TZ_OPERATION_FIELD_PROTOS,
TZ_OPERATION_FIELD_DESTINATION,
TZ_OPERATION_FIELD_PARAMETER,
TZ_OPERATION_FIELD_SMART_ENTRYPOINT,
TZ_OPERATION_FIELD_EXPR,
TZ_OPERATION_FIELD_OPH,
TZ_OPERATION_FIELD_BH,
Expand All @@ -87,10 +91,23 @@ typedef enum {
TZ_OPERATION_FIELD_BALLOT
} tz_operation_field_kind;

struct tz_operation_field_descriptor;

typedef struct {
const struct tz_operation_field_descriptor *field;
uint8_t display_none : 1;
} tz_operation_option_field_descriptor;

typedef struct tz_operation_field_descriptor {
const char *name;
tz_operation_field_kind kind : 5;
uint8_t required : 1, skip : 1, display_none : 1, complex : 1;
union {
tz_operation_option_field_descriptor field_option;
struct {
const struct tz_operation_field_descriptor *fields;
} field_tuple;
};
uint8_t skip : 1, complex : 1;
} tz_operation_field_descriptor;

typedef struct {
Expand All @@ -103,14 +120,18 @@ typedef struct {
tz_operation_parser_step_kind step : 5;
uint16_t stop;
union {
tz_operation_option_field_descriptor step_option;
struct {
uint8_t size_len;
uint16_t size;
} step_size;
struct {
const tz_operation_descriptor *descriptor;
uint8_t field;
} step_operation;
const tz_operation_field_descriptor *field;
} step_field;
struct {
const tz_operation_field_descriptor *fields;
uint8_t field_index;
} step_tuple;
struct {
const char *str;
} step_print;
Expand Down
3 changes: 2 additions & 1 deletion tests/generate/gen_integration.ml
Original file line number Diff line number Diff line change
Expand Up @@ -279,8 +279,9 @@ let operation_to_screens
then []
else
[
need_expert_mode_screen "Parameter";
need_expert_mode_screen "Entrypoint";
make_screen ~title:"Entrypoint" "%a" Entrypoint.pp entrypoint;
need_expert_mode_screen "Parameter";
make_screen ~title:"Parameter" "%a" pp_lazy_expr parameters;
]
in
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions tests/integration/stax/test_blindsign_valid.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@
app.review.tap()
app.assert_screen("tst_review_003")
app.review.tap()
app.assert_screen("expert_mode_splash")
app.review.tap()
app.assert_screen("tst_review_004")
app.review.tap()
app.assert_screen("operation_sign")

expected_apdu = "f6d5fa0e79cac216e25104938ac873ca17ee9d7f06763719293b413cf2ed475cf63d045a1cc9f73eee5775c5d496fa9d3aa9ae57fb97217f746a8728639795b7b2220e84ce5759ed111399ea3263d810c230d6a4fffcb6e82797c5ca673a17089000"
Expand Down
4 changes: 4 additions & 0 deletions tests/integration/stax/test_parsing_errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,10 @@
app.review.tap()
app.assert_screen("tpe_review_0_03_full")
app.review.tap()
app.assert_screen("expert_mode_splash")
app.review.tap()
app.assert_screen("tpe_review_0_04_full")
app.review.tap()

verify_err_reject_response(app, "invalid_tag")

Expand Down
12 changes: 12 additions & 0 deletions tests/integration/stax/test_sign_transfer.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,12 @@
app.review.tap()
app.assert_screen("tst_review_003")

app.review.tap()
app.assert_screen("tst_expert_splash")

app.review.tap()
app.assert_screen("tst_review_004")

app.review.tap()
app.assert_screen("operation_sign")

Expand Down Expand Up @@ -75,6 +81,12 @@
app.review.tap()
app.assert_screen("tst_review_003")

app.review.tap()
app.assert_screen("tst_expert_splash")

app.review.tap()
app.assert_screen("tst_review_004")

app.review.tap()
app.assert_screen("operation_sign")

Expand Down
6 changes: 6 additions & 0 deletions tests/integration/stax/test_sign_transfer_without_hash.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,12 @@
app.review.tap()
app.assert_screen("review_2")

app.review.tap()
app.assert_screen("expert_mode_splash")

app.review.tap()
app.assert_screen("review_3")

app.review.tap()
app.assert_screen("operation_sign")

Expand Down
25 changes: 16 additions & 9 deletions tests/unit/ctest/tests_parser.c
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,7 @@ CTEST2(operation_parser, check_simple_transaction_complexity)
{"Storage limit", false, 3},
{"Amount", false, 4},
{"Destination", false, 5},
// {"Option", _, 6},
};
check_field_complexity(data, str, fields_check, sizeof(fields_check));
}
Expand All @@ -250,8 +251,10 @@ CTEST2(operation_parser, check_transaction_complexity)
{"Storage limit", false, 3},
{"Amount", false, 4},
{"Destination", false, 5},
{"Entrypoint", true, 6},
{"Parameter", true, 6},
// {"Option", _, 6},
// {"Tuple", _, 7},
{"Entrypoint", true, 8},
{"Parameter", true, 9},
};
check_field_complexity(data, str, fields_check, sizeof(fields_check));
}
Expand All @@ -270,14 +273,16 @@ CTEST2(operation_parser, check_double_transaction_complexity)
{"Storage limit", false, 3 },
{"Amount", false, 4 },
{"Destination", false, 5 },
// {"None" , false, 6 },
// {"Option", _, 6 },
{"Source", false, 7 },
{"Fee", false, 8 },
{"Storage limit", false, 9 },
{"Amount", false, 10},
{"Destination", false, 11},
{"Entrypoint", true, 12},
{"Parameter", true, 12},
// {"Option", _, 12},
// {"Tuple", _, 13},
{"Entrypoint", true, 14},
{"Parameter", true, 15},
};
check_field_complexity(data, str, fields_check, sizeof(fields_check));
}
Expand All @@ -293,7 +298,7 @@ CTEST2(operation_parser, check_origination_complexity)
{"Fee", false, 2},
{"Storage limit", false, 3},
{"Balance", false, 4},
{"Delegate", false, 5},
{"Delegate", false, 5}, // None
{"Code", true, 6},
{"Storage", true, 7},
};
Expand All @@ -310,7 +315,8 @@ CTEST2(operation_parser, check_delegation_complexity)
{"Source", false, 1},
{"Fee", false, 2},
{"Storage limit", false, 3},
{"Delegate", false, 4},
// {"Option", _, 4},
{"Delegate", false, 5},
};
check_field_complexity(data, str, fields_check, sizeof(fields_check));
}
Expand All @@ -330,7 +336,7 @@ CTEST2(operation_parser, check_register_global_constant_complexity)
check_field_complexity(data, str, fields_check, sizeof(fields_check));
}

CTEST2(operation_parser, check_set_deposit_limite_complexity)
CTEST2(operation_parser, check_set_deposit_limit_complexity)
{
char str[]
= "030000000000000000000000000000000000000000000000000000000000000000"
Expand All @@ -340,7 +346,8 @@ CTEST2(operation_parser, check_set_deposit_limite_complexity)
{"Source", false, 1},
{"Fee", false, 2},
{"Storage limit", false, 3},
{"Staking limit", false, 4},
// {"Option", _, 4},
{"Staking limit", false, 5},
};
check_field_complexity(data, str, fields_check, sizeof(fields_check));
}
Expand Down

0 comments on commit 487015d

Please sign in to comment.