Skip to content

Commit 95bd50a

Browse files
committed
test
1 parent 7a892ad commit 95bd50a

14 files changed

Lines changed: 281 additions & 331 deletions

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,4 @@ test-filter: build
2929
cd build && ./zxlib_tests --gtest_filter="$(FILTER)"
3030

3131
format:
32-
find src evm tests \( -iname '*.h' -o -iname '*.c' -o -iname '*.cpp' -o -iname '*.hpp' \) | xargs clang-format -i
32+
find src evm tests include app \( -iname '*.h' -o -iname '*.c' -o -iname '*.cpp' -o -iname '*.hpp' \) | xargs clang-format -i

app/ui/view.c

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -60,20 +60,15 @@ void view_review_init(viewfunc_getItem_t viewfuncGetItem, viewfunc_getNumItems_t
6060
#if defined(TARGET_NANOS) || defined(TARGET_NANOS2) || defined(TARGET_NANOX)
6161
viewdata.with_confirmation = false;
6262
#endif
63-
6463
}
6564

66-
void view_review_init_progressive(
67-
viewfunc_getItem_t viewfuncGetItem,
68-
viewfunc_getNumItems_t viewfuncGetNumItems,
69-
viewfunc_accept_t viewfuncAccept) {
70-
65+
void view_review_init_progressive(viewfunc_getItem_t viewfuncGetItem, viewfunc_getNumItems_t viewfuncGetNumItems,
66+
viewfunc_accept_t viewfuncAccept) {
7167
view_review_init(viewfuncGetItem, viewfuncGetNumItems, viewfuncAccept);
7268

7369
#if defined(TARGET_NANOS) || defined(TARGET_NANOS2) || defined(TARGET_NANOX)
7470
viewdata.with_confirmation = true;
7571
#endif
76-
7772
}
7873

7974
void view_initialize_init(viewfunc_initialize_t viewFuncInit) { viewdata.viewfuncInitialize = viewFuncInit; }

app/ui/view.h

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -120,10 +120,8 @@ void view_blindsign_error_show();
120120
void view_review_init(viewfunc_getItem_t viewfuncGetItem, viewfunc_getNumItems_t viewfuncGetNumItems,
121121
viewfunc_accept_t viewfuncAccept);
122122

123-
void view_review_init_progressive(
124-
viewfunc_getItem_t viewfuncGetItem,
125-
viewfunc_getNumItems_t viewfuncGetNumItems,
126-
viewfunc_accept_t viewfuncAccept);
123+
void view_review_init_progressive(viewfunc_getItem_t viewfuncGetItem, viewfunc_getNumItems_t viewfuncGetNumItems,
124+
viewfunc_accept_t viewfuncAccept);
127125

128126
void view_inspect_init(viewfunc_getInnerItem_t view_funcGetInnerItem, viewfunc_getNumItems_t view_funcGetInnerNumItems,
129127
viewfunc_canInspectItem_t view_funcCanInspectItem);
@@ -150,4 +148,4 @@ typedef enum {
150148
} settings_list_e;
151149

152150
void view_set_switch_subtext(settings_list_e switch_id, const char *subtext);
153-
#endif // TARGET_STAX || TARGET_FLEX
151+
#endif // TARGET_STAX || TARGET_FLEX

app/ui/view_inspect_x.c

Lines changed: 43 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,25 @@
11
/*******************************************************************************
2-
* (c) 2018 - 2023 Zondax AG
3-
*
4-
* Licensed under the Apache License, Version 2.0 (the "License");
5-
* you may not use this file except in compliance with the License.
6-
* You may obtain a copy of the License at
7-
*
8-
* http://www.apache.org/licenses/LICENSE-2.0
9-
*
10-
* Unless required by applicable law or agreed to in writing, software
11-
* distributed under the License is distributed on an "AS IS" BASIS,
12-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13-
* See the License for the specific language governing permissions and
14-
* limitations under the License.
15-
********************************************************************************/
2+
* (c) 2018 - 2023 Zondax AG
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
********************************************************************************/
1616
#include "bolos_target.h"
1717

1818
#if defined(TARGET_NANOX) || defined(TARGET_NANOS2)
1919
#include "view_internal.h"
20+
#include "view_nano.h"
2021
#include "view_nano_inspect.h"
2122
#include "view_templates.h"
22-
#include "view_nano.h"
2323
#include "zxmacros.h"
2424

2525
extern const ux_flow_step_t *ux_review_flow[MAX_REVIEW_UX_SCREENS];
@@ -38,18 +38,22 @@ uint8_t flow_inside_inspect_loop;
3838
extern unsigned int review_type;
3939

4040
// Menu to recursively inspect elements from a transaction
41-
UX_STEP_VALID(ux_inspect_flow_root_step, pb, h_rootTxn(), { &C_icon_back, "Go to root" });
41+
UX_STEP_VALID(ux_inspect_flow_root_step, pb, h_rootTxn(), {&C_icon_back, "Go to root"});
4242

4343
UX_STEP_INIT(ux_inspect_flow_start_step, NULL, NULL, { h_inspect_loop_start(); });
44-
UX_STEP_CB_INIT(ux_inspect_flow_step, bnnn_paging, h_inspect_loop_inside(), h_inspect(), { .title = viewdata.key, .text = viewdata.value, });
44+
UX_STEP_CB_INIT(ux_inspect_flow_step, bnnn_paging, h_inspect_loop_inside(), h_inspect(),
45+
{
46+
.title = viewdata.key,
47+
.text = viewdata.value,
48+
});
4549

4650
UX_STEP_INIT(ux_inspect_flow_end_step, NULL, NULL, { h_inspect_loop_end(); });
4751

48-
UX_STEP_VALID(ux_inspect_flow_back_step, pb, h_back(), { &C_icon_back, "BACK" });
52+
UX_STEP_VALID(ux_inspect_flow_back_step, pb, h_back(), {&C_icon_back, "BACK"});
4953

50-
void view_inspect_show_impl(){
54+
void view_inspect_show_impl() {
5155
// h_inspect_loop_inside();
52-
if(G_ux.stack_count == 0) {
56+
if (G_ux.stack_count == 0) {
5357
ux_stack_push();
5458
}
5559

@@ -65,24 +69,23 @@ void view_inspect_show_impl(){
6569
}
6670

6771
void inspect_init() {
68-
#ifdef HAVE_INSPECT
69-
h_inspect_init();
70-
if (!viewdata.viewfuncCanInspectItem(viewdata.innerField.level,
71-
viewdata.innerField.trace,
72-
viewdata.innerField.paging.itemIdx)) {
73-
h_rootTxn();
74-
return;
75-
}
72+
#ifdef HAVE_INSPECT
73+
h_inspect_init();
74+
if (!viewdata.viewfuncCanInspectItem(viewdata.innerField.level, viewdata.innerField.trace,
75+
viewdata.innerField.paging.itemIdx)) {
76+
h_rootTxn();
77+
return;
78+
}
7679

77-
const zxerr_t err = h_inspect_update_data();
78-
if (err != zxerr_ok) {
79-
// Show error
80-
view_error_show();
81-
// h_rootTxn();
82-
return;
83-
}
84-
view_inspect_show_impl();
85-
#endif
80+
const zxerr_t err = h_inspect_update_data();
81+
if (err != zxerr_ok) {
82+
// Show error
83+
view_error_show();
84+
// h_rootTxn();
85+
return;
86+
}
87+
view_inspect_show_impl();
88+
#endif
8689
}
8790

8891
void h_inspect() {
@@ -93,9 +96,8 @@ void h_inspect() {
9396

9497
// Check if we can inspect this element
9598
if (viewdata.innerField.level >= MAX_DEPTH ||
96-
!viewdata.viewfuncCanInspectItem(viewdata.innerField.level+1,
97-
viewdata.innerField.trace,
98-
viewdata.innerField.paging.itemIdx)) {
99+
!viewdata.viewfuncCanInspectItem(viewdata.innerField.level + 1, viewdata.innerField.trace,
100+
viewdata.innerField.paging.itemIdx)) {
99101
flow_inside_inspect_loop = 0;
100102
h_inspect_update_data();
101103
view_inspect_show_impl();
@@ -190,7 +192,7 @@ void h_inspect_loop_end() {
190192
}
191193

192194
ux_layout_bnnn_paging_reset();
193-
CUR_FLOW.prev_index = CUR_FLOW.index-2;
195+
CUR_FLOW.prev_index = CUR_FLOW.index - 2;
194196
CUR_FLOW.index--;
195197
ux_flow_relayout();
196198
}

app/ui/view_nano.h

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,26 @@
11
/*******************************************************************************
2-
* (c) 2018 - 2024 Zondax AG
3-
*
4-
* Licensed under the Apache License, Version 2.0 (the "License");
5-
* you may not use this file except in compliance with the License.
6-
* You may obtain a copy of the License at
7-
*
8-
* http://www.apache.org/licenses/LICENSE-2.0
9-
*
10-
* Unless required by applicable law or agreed to in writing, software
11-
* distributed under the License is distributed on an "AS IS" BASIS,
12-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13-
* See the License for the specific language governing permissions and
14-
* limitations under the License.
15-
********************************************************************************/
2+
* (c) 2018 - 2024 Zondax AG
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
********************************************************************************/
1616
#pragma once
17-
#include "bolos_target.h"
1817
#include <stdint.h>
1918

19+
#include "bolos_target.h"
20+
2021
#if defined(TARGET_NANOS)
2122
#define INCLUDE_ACTIONS_AS_ITEMS 2
22-
#define INCLUDE_ACTIONS_COUNT (INCLUDE_ACTIONS_AS_ITEMS-1)
23+
#define INCLUDE_ACTIONS_COUNT (INCLUDE_ACTIONS_AS_ITEMS - 1)
2324
typedef uint8_t max_char_display;
2425
#else
2526
#define INCLUDE_ACTIONS_COUNT 0

app/ui/view_nano_inspect.c

Lines changed: 23 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,25 @@
11
/*******************************************************************************
2-
* (c) 2018 - 2023 Zondax AG
3-
*
4-
* Licensed under the Apache License, Version 2.0 (the "License");
5-
* you may not use this file except in compliance with the License.
6-
* You may obtain a copy of the License at
7-
*
8-
* http://www.apache.org/licenses/LICENSE-2.0
9-
*
10-
* Unless required by applicable law or agreed to in writing, software
11-
* distributed under the License is distributed on an "AS IS" BASIS,
12-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13-
* See the License for the specific language governing permissions and
14-
* limitations under the License.
15-
********************************************************************************/
2+
* (c) 2018 - 2023 Zondax AG
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
********************************************************************************/
1616
#include "bolos_target.h"
1717

1818
#if defined(TARGET_NANOS) || defined(TARGET_NANOS2) || defined(TARGET_NANOX)
19-
#include "view_nano_inspect.h"
2019
#include "view_internal.h"
21-
#include "view_templates.h"
2220
#include "view_nano.h"
21+
#include "view_nano_inspect.h"
22+
#include "view_templates.h"
2323
#include "zxmacros.h"
2424

2525
void h_inspect_init() {
@@ -33,22 +33,20 @@ void h_inspect_init() {
3333
viewdata.innerField.paging.itemCount = 0xFF;
3434
}
3535

36-
void view_inspect_init(viewfunc_getInnerItem_t view_funcGetInnerItem,
37-
viewfunc_getNumItems_t view_funcGetInnerNumItems,
36+
void view_inspect_init(viewfunc_getInnerItem_t view_funcGetInnerItem, viewfunc_getNumItems_t view_funcGetInnerNumItems,
3837
viewfunc_canInspectItem_t view_funcCanInspectItem) {
3938
viewdata.viewfuncGetInnerItem = view_funcGetInnerItem;
4039
viewdata.viewfuncGetInnerNumItems = view_funcGetInnerNumItems;
4140
viewdata.viewfuncCanInspectItem = view_funcCanInspectItem;
4241
}
4342

4443
bool h_paging_inspect_go_to_root_screen() {
45-
return (viewdata.innerField.paging.itemIdx == 0)
46-
&& (viewdata.innerField.trace[0] != 0);
44+
return (viewdata.innerField.paging.itemIdx == 0) && (viewdata.innerField.trace[0] != 0);
4745
}
4846

4947
bool h_paging_inspect_back_screen() {
50-
return (viewdata.innerField.paging.itemIdx == (viewdata.innerField.paging.itemCount - 1))
51-
&& (viewdata.innerField.trace[0] != 0);
48+
return (viewdata.innerField.paging.itemIdx == (viewdata.innerField.paging.itemCount - 1)) &&
49+
(viewdata.innerField.trace[0] != 0);
5250
}
5351

5452
bool h_can_increase(paging_t *paging, uint8_t actionsCount) {
@@ -137,15 +135,15 @@ zxerr_t h_inspect_update_data() {
137135
viewdata.innerField.paging.itemCount += 2;
138136
viewdata.innerField.paging.pageCount = 1;
139137
if (h_paging_inspect_go_to_root_screen()) {
140-
snprintf(viewdata.key, MAX_CHARS_PER_KEY_LINE, "%s","");
138+
snprintf(viewdata.key, MAX_CHARS_PER_KEY_LINE, "%s", "");
141139
snprintf(viewdata.value, MAX_CHARS_PER_VALUE1_LINE, "%s", "Go to root");
142140
splitValueField();
143141
page.pageIdx = 0;
144142
return zxerr_ok;
145143
}
146144

147145
if (h_paging_inspect_back_screen()) {
148-
snprintf(viewdata.key, MAX_CHARS_PER_KEY_LINE, "%s","");
146+
snprintf(viewdata.key, MAX_CHARS_PER_KEY_LINE, "%s", "");
149147
snprintf(viewdata.value, MAX_CHARS_PER_VALUE1_LINE, "%s", "BACK");
150148
splitValueField();
151149
page.pageIdx = 0;
@@ -165,10 +163,7 @@ zxerr_t h_inspect_update_data() {
165163
.pageCount = &viewdata.innerField.paging.pageCount,
166164
};
167165

168-
CHECK_ZXERR(viewdata.viewfuncGetInnerItem(
169-
viewdata.innerField.level,
170-
viewdata.innerField.trace,
171-
&thisItem))
166+
CHECK_ZXERR(viewdata.viewfuncGetInnerItem(viewdata.innerField.level, viewdata.innerField.trace, &thisItem))
172167

173168
return zxerr_ok;
174169
}

app/ui/view_nbgl.c

Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,6 @@ static void reviewMessageChoice(bool confirm) {
132132
}
133133
}
134134

135-
136135
static void reviewGenericChoice(bool confirm) {
137136
const char *msg = "Operation rejected";
138137
bool isSuccess = false;
@@ -177,26 +176,21 @@ void view_custom_error_show(const char *upper, const char *lower) {
177176
}
178177

179178
void view_blindsign_error_show() {
180-
nbgl_useCaseChoice(&C_Warning_64px,
181-
"This transaction cannot\nbe clear-signed",
182-
"Enable blind signing in the\nsettings to sign this\ntransaction.",
183-
"Go to settings",
184-
"Reject Transaction",
185-
goto_settings);
179+
nbgl_useCaseChoice(&C_Warning_64px, "This transaction cannot\nbe clear-signed",
180+
"Enable blind signing in the\nsettings to sign this\ntransaction.", "Go to settings",
181+
"Reject Transaction", goto_settings);
186182
}
187183

188184
void view_error_show_impl() {
189185
nbgl_useCaseChoice(&C_Important_Circle_64px, viewdata.key, viewdata.value, "Ok", NULL, confirm_setting);
190186
}
191187

192188
void view_settings_show_impl() {
193-
nbgl_useCaseHomeAndSettings(MENU_MAIN_APP_LINE1, &C_icon_stax_64, HOME_TEXT, 0, &settingContents,
194-
&infoList, NULL, app_quit);
189+
nbgl_useCaseHomeAndSettings(MENU_MAIN_APP_LINE1, &C_icon_stax_64, HOME_TEXT, 0, &settingContents, &infoList, NULL,
190+
app_quit);
195191
}
196192

197-
void view_spinner_impl(const char *text) {
198-
nbgl_useCaseSpinner(text);
199-
}
193+
void view_spinner_impl(const char *text) { nbgl_useCaseSpinner(text); }
200194

201195
static uint8_t get_pair_number() {
202196
uint8_t numItems = 0;
@@ -472,12 +466,13 @@ static void config_useCaseReview(nbgl_operationType_t type) {
472466
pairList.startIndex = 0;
473467
if (app_mode_blindsign_required()) {
474468
nbgl_useCaseReviewBlindSigning(type, &pairList, &C_icon_stax_64,
475-
(intro_message == NULL ? "Review transaction" : intro_message), (intro_submessage == NULL ? NULL : intro_submessage),
469+
(intro_message == NULL ? "Review transaction" : intro_message),
470+
(intro_submessage == NULL ? NULL : intro_submessage),
476471
"Accept risk and sign transaction ?", NULL, reviewTransactionChoice);
477472
} else {
478-
nbgl_useCaseReview(type, &pairList, &C_icon_stax_64,
479-
(intro_message == NULL ? "Review transaction" : intro_message), (intro_submessage == NULL ? NULL : intro_submessage), APPROVE_LABEL_NBGL,
480-
reviewTransactionChoice);
473+
nbgl_useCaseReview(
474+
type, &pairList, &C_icon_stax_64, (intro_message == NULL ? "Review transaction" : intro_message),
475+
(intro_submessage == NULL ? NULL : intro_submessage), APPROVE_LABEL_NBGL, reviewTransactionChoice);
481476
}
482477
}
483478

@@ -534,7 +529,7 @@ void view_review_show_impl(unsigned int requireReply, const char *title, const c
534529
// Retrieve intro text for transaction
535530
if (viewdata.viewfuncGetItem != NULL) {
536531
viewdata.viewfuncGetItem(0xFF, intro_msg_buf, MAX_CHARS_PER_KEY_LINE, intro_submsg_buf,
537-
MAX_CHARS_PER_VALUE1_LINE, 0, &viewdata.pageCount);
532+
MAX_CHARS_PER_VALUE1_LINE, 0, &viewdata.pageCount);
538533
if (strlen(intro_msg_buf) > strlen(" ")) {
539534
intro_message = intro_msg_buf;
540535
}

0 commit comments

Comments
 (0)