Skip to content

Commit 642b229

Browse files
Renamed trusted name enums
1 parent ef0839b commit 642b229

File tree

5 files changed

+39
-34
lines changed

5 files changed

+39
-34
lines changed

src_bagl/ui_flow_signTx.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,7 @@ void ux_approve_tx(bool fromPlugin) {
267267
}
268268
#ifdef HAVE_TRUSTED_NAME
269269
uint64_t chain_id = get_tx_chain_id();
270-
e_name_type type = TYPE_ACCOUNT;
270+
e_name_type type = TN_TYPE_ACCOUNT;
271271
if (has_trusted_name(1, &type, &chain_id, tmpContent.txContent.destination)) {
272272
ux_approval_tx_flow[step++] = &ux_trusted_name_step;
273273
if (N_storage.verbose_trusted_name) {

src_features/provideTrustedName/cmd_provide_trusted_name.c

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ bool has_trusted_name(uint8_t types_count,
132132
for (int i = 0; i < types_count; ++i) {
133133
switch (g_trusted_name_info.struct_version) {
134134
case 1:
135-
if (types[i] == TYPE_ACCOUNT) {
135+
if (types[i] == TN_TYPE_ACCOUNT) {
136136
// Check if chain ID is known to be Ethereum-compatible (same derivation
137137
// path)
138138
if ((chain_is_ethereum_compatible(chain_id)) &&
@@ -378,7 +378,7 @@ static bool handle_trusted_name(const s_tlv_data *data,
378378
return false;
379379
}
380380
if ((trusted_name_info->struct_version == 1) ||
381-
(trusted_name_info->name_type == TYPE_ACCOUNT)) {
381+
(trusted_name_info->name_type == TN_TYPE_ACCOUNT)) {
382382
// TODO: Remove once other domain name providers are supported
383383
if ((data->length < 5) ||
384384
(strncmp(".eth", (char *) &data->value[data->length - 4], 4) != 0)) {
@@ -474,10 +474,10 @@ static bool handle_trusted_name_type(const s_tlv_data *data,
474474
return false;
475475
}
476476
switch (value) {
477-
case TYPE_ACCOUNT:
478-
case TYPE_CONTRACT:
477+
case TN_TYPE_ACCOUNT:
478+
case TN_TYPE_CONTRACT:
479479
break;
480-
case TYPE_NFT:
480+
case TN_TYPE_NFT_COLLECTION:
481481
default:
482482
PRINTF("Error: unsupported trusted name type (%u)!\n", value);
483483
return false;
@@ -505,13 +505,13 @@ static bool handle_trusted_name_source(const s_tlv_data *data,
505505
return false;
506506
}
507507
switch (value) {
508-
case SOURCE_CAL:
509-
case SOURCE_ENS:
508+
case TN_SOURCE_CAL:
509+
case TN_SOURCE_ENS:
510510
break;
511-
case SOURCE_LAB:
512-
case SOURCE_UD:
513-
case SOURCE_FN:
514-
case SOURCE_DNS:
511+
case TN_SOURCE_LAB:
512+
case TN_SOURCE_UD:
513+
case TN_SOURCE_FN:
514+
case TN_SOURCE_DNS:
515515
default:
516516
PRINTF("Error: unsupported trusted name source (%u)!\n", value);
517517
return false;
@@ -651,8 +651,8 @@ static bool verify_struct(const s_trusted_name_info *trusted_name_info) {
651651
return false;
652652
}
653653
switch (trusted_name_info->name_type) {
654-
case TYPE_ACCOUNT:
655-
if (trusted_name_info->name_source == SOURCE_CAL) {
654+
case TN_TYPE_ACCOUNT:
655+
if (trusted_name_info->name_source == TN_SOURCE_CAL) {
656656
PRINTF("Error: cannot accept an account name from the CAL!\n");
657657
return false;
658658
}
@@ -661,8 +661,8 @@ static bool verify_struct(const s_trusted_name_info *trusted_name_info) {
661661
return false;
662662
}
663663
break;
664-
case TYPE_CONTRACT:
665-
if (trusted_name_info->name_source != SOURCE_CAL) {
664+
case TN_TYPE_CONTRACT:
665+
if (trusted_name_info->name_source != TN_SOURCE_CAL) {
666666
PRINTF("Error: cannot accept a contract name from given source (%u)!\n",
667667
trusted_name_info->name_source);
668668
return false;

src_features/provideTrustedName/trusted_name.h

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,23 @@
99
#define TRUSTED_NAME_MAX_LENGTH 30
1010

1111
typedef enum {
12-
TYPE_ACCOUNT = 1,
13-
TYPE_CONTRACT,
14-
TYPE_NFT,
12+
TN_TYPE_ACCOUNT = 1,
13+
TN_TYPE_CONTRACT,
14+
TN_TYPE_NFT_COLLECTION,
15+
_TN_TYPE_COUNT_,
1516
} e_name_type;
1617

18+
// because the enum does not start at 0
19+
#define TN_TYPE_COUNT (_TN_TYPE_COUNT_ - TN_TYPE_ACCOUNT)
20+
1721
typedef enum {
18-
SOURCE_LAB = 0,
19-
SOURCE_CAL,
20-
SOURCE_ENS,
21-
SOURCE_UD,
22-
SOURCE_FN,
23-
SOURCE_DNS,
22+
TN_SOURCE_LAB = 0,
23+
TN_SOURCE_CAL,
24+
TN_SOURCE_ENS,
25+
TN_SOURCE_UD,
26+
TN_SOURCE_FN,
27+
TN_SOURCE_DNS,
28+
TN_SOURCE_COUNT,
2429
} e_name_source;
2530

2631
bool has_trusted_name(uint8_t types_count,

src_features/signMessageEIP712/filtering.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -376,8 +376,8 @@ bool filtering_trusted_name(const uint8_t *payload,
376376
// sanity check
377377
for (int i = 0; i < types_count; ++i) {
378378
switch (types[i]) {
379-
case TYPE_ACCOUNT:
380-
case TYPE_CONTRACT:
379+
case TN_TYPE_ACCOUNT:
380+
case TN_TYPE_CONTRACT:
381381
break;
382382
default:
383383
return false;
@@ -395,12 +395,12 @@ bool filtering_trusted_name(const uint8_t *payload,
395395
// sanity check
396396
for (int i = 0; i < sources_count; ++i) {
397397
switch (sources[i]) {
398-
case SOURCE_LAB:
399-
case SOURCE_CAL:
400-
case SOURCE_ENS:
401-
case SOURCE_UD:
402-
case SOURCE_FN:
403-
case SOURCE_DNS:
398+
case TN_SOURCE_LAB:
399+
case TN_SOURCE_CAL:
400+
case TN_SOURCE_ENS:
401+
case TN_SOURCE_UD:
402+
case TN_SOURCE_FN:
403+
case TN_SOURCE_DNS:
404404
break;
405405
default:
406406
return false;

src_nbgl/ui_approve_tx.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ static uint8_t setTagValuePairs(void) {
148148

149149
#ifdef HAVE_TRUSTED_NAME
150150
uint64_t chain_id = get_tx_chain_id();
151-
e_name_type type = TYPE_ACCOUNT;
151+
e_name_type type = TN_TYPE_ACCOUNT;
152152
tx_approval_context.trusted_name_match =
153153
has_trusted_name(1, &type, &chain_id, tmpContent.txContent.destination);
154154
if (tx_approval_context.trusted_name_match) {

0 commit comments

Comments
 (0)