EIP712 now displays integers differently if signed or unsigned
This commit is contained in:
@@ -33,7 +33,7 @@ void array_hexstr(char *strbuf, const void *bin, unsigned int len) {
|
||||
*strbuf = 0; // EOS
|
||||
}
|
||||
|
||||
void convertUint256BE(uint8_t *data, uint32_t length, uint256_t *target) {
|
||||
void convertUint256BE(const uint8_t *const data, uint32_t length, uint256_t *const target) {
|
||||
uint8_t tmp[INT256_LENGTH];
|
||||
memset(tmp, 0, 32);
|
||||
memmove(tmp + 32 - length, data, length);
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
|
||||
void array_hexstr(char* strbuf, const void* bin, unsigned int len);
|
||||
|
||||
void convertUint256BE(uint8_t* data, uint32_t length, uint256_t* target);
|
||||
void convertUint256BE(const uint8_t *const data, uint32_t length, uint256_t *const target);
|
||||
|
||||
uint64_t u64_from_BE(const uint8_t* in, uint8_t size);
|
||||
|
||||
|
||||
@@ -14,6 +14,8 @@
|
||||
#include "utils.h" // uint256_to_decimal
|
||||
#include "common_712.h"
|
||||
#include "context.h" // eip712_context_deinit
|
||||
#include "uint256.h" // tostring256
|
||||
#include "int256.h" // tostring256_s
|
||||
|
||||
|
||||
static t_ui_context *ui_ctx = NULL;
|
||||
@@ -108,6 +110,7 @@ void ui_712_new_field(const void *const field_ptr, const uint8_t *const data,
|
||||
{
|
||||
const char *key;
|
||||
uint8_t key_len;
|
||||
uint256_t value256;
|
||||
|
||||
if (ui_ctx == NULL)
|
||||
{
|
||||
@@ -162,10 +165,13 @@ void ui_712_new_field(const void *const field_ptr, const uint8_t *const data,
|
||||
strcat(strings.tmp.tmp, "...");
|
||||
}
|
||||
break;
|
||||
// TODO: signed integers should be handled differently
|
||||
case TYPE_SOL_INT:
|
||||
convertUint256BE(data, length, &value256);
|
||||
tostring256_s(&value256, 10, strings.tmp.tmp, sizeof(strings.tmp.tmp));
|
||||
break;
|
||||
case TYPE_SOL_UINT:
|
||||
uint256_to_decimal(data, length, strings.tmp.tmp, sizeof(strings.tmp.tmp));
|
||||
convertUint256BE(data, length, &value256);
|
||||
tostring256(&value256, 10, strings.tmp.tmp, sizeof(strings.tmp.tmp));
|
||||
break;
|
||||
default:
|
||||
PRINTF("Unhandled type\n");
|
||||
|
||||
Reference in New Issue
Block a user