Small simplification/refactoring of EIP712 typed data
This commit is contained in:
@@ -61,7 +61,7 @@ static const void *get_nth_field(uint8_t *const fields_count_ptr,
|
||||
if (struct_field_type(field_ptr) == TYPE_CUSTOM)
|
||||
{
|
||||
typename = get_struct_field_typename(field_ptr, &length);
|
||||
if ((struct_ptr = get_structn(eip712_context->structs_array, typename, length)) == NULL)
|
||||
if ((struct_ptr = get_structn(typename, length)) == NULL)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
@@ -97,7 +97,7 @@ const void *path_get_nth_field_to_last(uint8_t n)
|
||||
if (field_ptr != NULL)
|
||||
{
|
||||
typename = get_struct_field_typename(field_ptr, &typename_len);
|
||||
struct_ptr = get_structn(eip712_context->structs_array, typename, typename_len);
|
||||
struct_ptr = get_structn(typename, typename_len);
|
||||
}
|
||||
return struct_ptr;
|
||||
}
|
||||
@@ -298,7 +298,7 @@ static bool path_update(void)
|
||||
while (struct_field_type(field_ptr) == TYPE_CUSTOM)
|
||||
{
|
||||
typename = get_struct_field_typename(field_ptr, &typename_len);
|
||||
if ((struct_ptr = get_structn(eip712_context->structs_array, typename, typename_len)) == NULL)
|
||||
if ((struct_ptr = get_structn(typename, typename_len)) == NULL)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@@ -318,7 +318,7 @@ static bool path_update(void)
|
||||
}
|
||||
cx_keccak_init(hash_ctx, 256); // initialize it
|
||||
// get the struct typehash
|
||||
if ((thash_ptr = type_hash(eip712_context->structs_array, typename, typename_len)) == NULL)
|
||||
if ((thash_ptr = type_hash(typename, typename_len)) == NULL)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@@ -353,7 +353,7 @@ bool path_set_root(const char *const struct_name, uint8_t name_length)
|
||||
return false;
|
||||
}
|
||||
|
||||
path_struct->root_struct = get_structn(eip712_context->structs_array, struct_name, name_length);
|
||||
path_struct->root_struct = get_structn(struct_name, name_length);
|
||||
|
||||
if (path_struct->root_struct == NULL)
|
||||
{
|
||||
@@ -376,7 +376,7 @@ bool path_set_root(const char *const struct_name, uint8_t name_length)
|
||||
return false;
|
||||
}
|
||||
cx_keccak_init(hash_ctx, 256); // init hash
|
||||
if ((thash_ptr = type_hash(eip712_context->structs_array, struct_name, name_length)) == NULL)
|
||||
if ((thash_ptr = type_hash(struct_name, name_length)) == NULL)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user