EIP-712 code linting
This commit is contained in:
@@ -19,8 +19,7 @@ typedef cx_sha256_t cx_sha224_t;
|
||||
*
|
||||
* @return whether the schema hash was successful or not
|
||||
*/
|
||||
bool compute_schema_hash(void)
|
||||
{
|
||||
bool compute_schema_hash(void) {
|
||||
const void *struct_ptr;
|
||||
uint8_t structs_count;
|
||||
const void *field_ptr;
|
||||
@@ -32,42 +31,37 @@ bool compute_schema_hash(void)
|
||||
cx_sha224_init(&hash_ctx);
|
||||
|
||||
struct_ptr = get_structs_array(&structs_count);
|
||||
hash_byte('{', (cx_hash_t*)&hash_ctx);
|
||||
while (structs_count-- > 0)
|
||||
{
|
||||
hash_byte('{', (cx_hash_t *) &hash_ctx);
|
||||
while (structs_count-- > 0) {
|
||||
name = get_struct_name(struct_ptr, &name_length);
|
||||
hash_byte('"', (cx_hash_t*)&hash_ctx);
|
||||
hash_nbytes((uint8_t*)name, name_length, (cx_hash_t*)&hash_ctx);
|
||||
hash_nbytes((uint8_t*)"\":[", 3, (cx_hash_t*)&hash_ctx);
|
||||
hash_byte('"', (cx_hash_t *) &hash_ctx);
|
||||
hash_nbytes((uint8_t *) name, name_length, (cx_hash_t *) &hash_ctx);
|
||||
hash_nbytes((uint8_t *) "\":[", 3, (cx_hash_t *) &hash_ctx);
|
||||
field_ptr = get_struct_fields_array(struct_ptr, &fields_count);
|
||||
while (fields_count-- > 0)
|
||||
{
|
||||
hash_nbytes((uint8_t*)"{\"name\":\"", 9, (cx_hash_t*)&hash_ctx);
|
||||
while (fields_count-- > 0) {
|
||||
hash_nbytes((uint8_t *) "{\"name\":\"", 9, (cx_hash_t *) &hash_ctx);
|
||||
name = get_struct_field_keyname(field_ptr, &name_length);
|
||||
hash_nbytes((uint8_t*)name, name_length, (cx_hash_t*)&hash_ctx);
|
||||
hash_nbytes((uint8_t*)"\",\"type\":\"", 10, (cx_hash_t*)&hash_ctx);
|
||||
if (!format_hash_field_type(field_ptr, (cx_hash_t*)&hash_ctx))
|
||||
{
|
||||
hash_nbytes((uint8_t *) name, name_length, (cx_hash_t *) &hash_ctx);
|
||||
hash_nbytes((uint8_t *) "\",\"type\":\"", 10, (cx_hash_t *) &hash_ctx);
|
||||
if (!format_hash_field_type(field_ptr, (cx_hash_t *) &hash_ctx)) {
|
||||
return false;
|
||||
}
|
||||
hash_nbytes((uint8_t*)"\"}", 2, (cx_hash_t*)&hash_ctx);
|
||||
if (fields_count > 0)
|
||||
{
|
||||
hash_byte(',', (cx_hash_t*)&hash_ctx);
|
||||
hash_nbytes((uint8_t *) "\"}", 2, (cx_hash_t *) &hash_ctx);
|
||||
if (fields_count > 0) {
|
||||
hash_byte(',', (cx_hash_t *) &hash_ctx);
|
||||
}
|
||||
field_ptr = get_next_struct_field(field_ptr);
|
||||
}
|
||||
hash_byte(']', (cx_hash_t*)&hash_ctx);
|
||||
if (structs_count > 0)
|
||||
{
|
||||
hash_byte(',', (cx_hash_t*)&hash_ctx);
|
||||
hash_byte(']', (cx_hash_t *) &hash_ctx);
|
||||
if (structs_count > 0) {
|
||||
hash_byte(',', (cx_hash_t *) &hash_ctx);
|
||||
}
|
||||
struct_ptr = get_next_struct(struct_ptr);
|
||||
}
|
||||
hash_byte('}', (cx_hash_t*)&hash_ctx);
|
||||
hash_byte('}', (cx_hash_t *) &hash_ctx);
|
||||
|
||||
// copy hash into context struct
|
||||
cx_hash((cx_hash_t*)&hash_ctx,
|
||||
cx_hash((cx_hash_t *) &hash_ctx,
|
||||
CX_LAST,
|
||||
NULL,
|
||||
0,
|
||||
@@ -76,4 +70,4 @@ bool compute_schema_hash(void)
|
||||
return true;
|
||||
}
|
||||
|
||||
#endif // HAVE_EIP712_FULL_SUPPORT
|
||||
#endif // HAVE_EIP712_FULL_SUPPORT
|
||||
|
||||
Reference in New Issue
Block a user