EIP-712 code linting
This commit is contained in:
@@ -34,14 +34,13 @@
|
||||
#define COMMON_CLA 0xB0
|
||||
#define COMMON_INS_GET_WALLET_ID 0x04
|
||||
|
||||
#define APDU_RESPONSE_OK 0x9000
|
||||
#define APDU_RESPONSE_INVALID_DATA 0x6a80
|
||||
#define APDU_RESPONSE_INSUFFICIENT_MEMORY 0x6a84
|
||||
#define APDU_RESPONSE_INVALID_INS 0x6d00
|
||||
#define APDU_RESPONSE_INVALID_P1_P2 0x6b00
|
||||
#define APDU_RESPONSE_CONDITION_NOT_SATISFIED 0x6985
|
||||
#define APDU_RESPONSE_REF_DATA_NOT_USABLE 0x6a88
|
||||
|
||||
#define APDU_RESPONSE_OK 0x9000
|
||||
#define APDU_RESPONSE_INVALID_DATA 0x6a80
|
||||
#define APDU_RESPONSE_INSUFFICIENT_MEMORY 0x6a84
|
||||
#define APDU_RESPONSE_INVALID_INS 0x6d00
|
||||
#define APDU_RESPONSE_INVALID_P1_P2 0x6b00
|
||||
#define APDU_RESPONSE_CONDITION_NOT_SATISFIED 0x6985
|
||||
#define APDU_RESPONSE_REF_DATA_NOT_USABLE 0x6a88
|
||||
|
||||
#ifdef HAVE_STARKWARE
|
||||
|
||||
@@ -63,14 +62,7 @@
|
||||
|
||||
#endif
|
||||
|
||||
enum {
|
||||
OFFSET_CLA = 0,
|
||||
OFFSET_INS,
|
||||
OFFSET_P1,
|
||||
OFFSET_P2,
|
||||
OFFSET_LC,
|
||||
OFFSET_CDATA
|
||||
};
|
||||
enum { OFFSET_CLA = 0, OFFSET_INS, OFFSET_P1, OFFSET_P2, OFFSET_LC, OFFSET_CDATA };
|
||||
|
||||
void handleGetPublicKey(uint8_t p1,
|
||||
uint8_t p2,
|
||||
|
||||
13
src/main.c
13
src/main.c
@@ -71,7 +71,7 @@ const internalStorage_t N_storage_real;
|
||||
chain_config_t *chainConfig;
|
||||
|
||||
void reset_app_context() {
|
||||
//PRINTF("!!RESET_APP_CONTEXT\n");
|
||||
// PRINTF("!!RESET_APP_CONTEXT\n");
|
||||
appState = APP_STATE_IDLE;
|
||||
called_from_swap = false;
|
||||
pluginType = OLD_INTERNAL;
|
||||
@@ -664,8 +664,7 @@ void handleApdu(unsigned int *flags, unsigned int *tx) {
|
||||
break;
|
||||
|
||||
case INS_SIGN_EIP_712_MESSAGE:
|
||||
if (G_io_apdu_buffer[OFFSET_P2] == 0)
|
||||
{
|
||||
if (G_io_apdu_buffer[OFFSET_P2] == 0) {
|
||||
memset(tmpCtx.transactionContext.tokenSet, 0, MAX_ITEMS);
|
||||
handleSignEIP712Message_v0(G_io_apdu_buffer[OFFSET_P1],
|
||||
G_io_apdu_buffer[OFFSET_P2],
|
||||
@@ -673,15 +672,13 @@ void handleApdu(unsigned int *flags, unsigned int *tx) {
|
||||
G_io_apdu_buffer[OFFSET_LC],
|
||||
flags,
|
||||
tx);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
#ifdef HAVE_EIP712_FULL_SUPPORT
|
||||
*flags |= IO_ASYNCH_REPLY;
|
||||
handle_eip712_sign(G_io_apdu_buffer);
|
||||
#else
|
||||
THROW(0x6B00);
|
||||
#endif // HAVE_EIP712_FULL_SUPPORT
|
||||
#endif // HAVE_EIP712_FULL_SUPPORT
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -723,7 +720,7 @@ void handleApdu(unsigned int *flags, unsigned int *tx) {
|
||||
*flags |= IO_ASYNCH_REPLY;
|
||||
handle_eip712_filtering(G_io_apdu_buffer);
|
||||
break;
|
||||
#endif // HAVE_EIP712_FULL_SUPPORT
|
||||
#endif // HAVE_EIP712_FULL_SUPPORT
|
||||
|
||||
#if 0
|
||||
case 0xFF: // return to dashboard
|
||||
|
||||
@@ -29,7 +29,7 @@ typedef struct internalStorage_t {
|
||||
unsigned char displayNonce;
|
||||
#ifdef HAVE_EIP712_FULL_SUPPORT
|
||||
bool verbose_eip712;
|
||||
#endif // HAVE_EIP712_FULL_SUPPORT
|
||||
#endif // HAVE_EIP712_FULL_SUPPORT
|
||||
uint8_t initialized;
|
||||
} internalStorage_t;
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ void switch_settings_display_data(void);
|
||||
void switch_settings_display_nonce(void);
|
||||
#ifdef HAVE_EIP712_FULL_SUPPORT
|
||||
void switch_settings_verbose_eip712(void);
|
||||
#endif // HAVE_EIP712_FULL_SUPPORT
|
||||
#endif // HAVE_EIP712_FULL_SUPPORT
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// clang-format off
|
||||
@@ -148,27 +148,22 @@ UX_FLOW(ux_settings_flow,
|
||||
&ux_settings_flow_display_nonce_step,
|
||||
#ifdef HAVE_EIP712_FULL_SUPPORT
|
||||
&ux_settings_flow_verbose_eip712_step,
|
||||
#endif // HAVE_EIP712_FULL_SUPPORT
|
||||
#endif // HAVE_EIP712_FULL_SUPPORT
|
||||
&ux_settings_flow_back_step);
|
||||
|
||||
void display_settings(const ux_flow_step_t* const start_step) {
|
||||
const char *const values[] = {
|
||||
"Enabled",
|
||||
"Disabled"
|
||||
};
|
||||
bool settings[] = {
|
||||
N_storage.dataAllowed,
|
||||
N_storage.contractDetails,
|
||||
N_storage.displayNonce,
|
||||
const char* const values[] = {"Enabled", "Disabled"};
|
||||
bool settings[] = {N_storage.dataAllowed,
|
||||
N_storage.contractDetails,
|
||||
N_storage.displayNonce,
|
||||
#ifdef HAVE_EIP712_FULL_SUPPORT
|
||||
N_storage.verbose_eip712
|
||||
#endif // HAVE_EIP712_FULL_SUPPORT
|
||||
N_storage.verbose_eip712
|
||||
#endif // HAVE_EIP712_FULL_SUPPORT
|
||||
};
|
||||
uint8_t offset = 0;
|
||||
uint8_t increment = MAX(strlen(values[0]), strlen(values[1])) + 1;
|
||||
|
||||
for (unsigned int i = 0; i < (sizeof(settings) / sizeof(settings[0])); ++i)
|
||||
{
|
||||
for (unsigned int i = 0; i < (sizeof(settings) / sizeof(settings[0])); ++i) {
|
||||
strlcpy(strings.common.fullAddress + offset,
|
||||
(settings[i] ? values[0] : values[1]),
|
||||
sizeof(strings.common.fullAddress) - offset);
|
||||
@@ -197,13 +192,12 @@ void switch_settings_display_nonce(void) {
|
||||
}
|
||||
|
||||
#ifdef HAVE_EIP712_FULL_SUPPORT
|
||||
void switch_settings_verbose_eip712(void)
|
||||
{
|
||||
void switch_settings_verbose_eip712(void) {
|
||||
bool value = !N_storage.verbose_eip712;
|
||||
nvm_write((void*) &N_storage.verbose_eip712, (void*) &value, sizeof(value));
|
||||
display_settings(&ux_settings_flow_verbose_eip712_step);
|
||||
}
|
||||
#endif // HAVE_EIP712_FULL_SUPPORT
|
||||
#endif // HAVE_EIP712_FULL_SUPPORT
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// clang-format off
|
||||
|
||||
@@ -22,14 +22,13 @@
|
||||
|
||||
#include "uint256.h"
|
||||
|
||||
|
||||
#define ARRAY_SIZE(a) (sizeof(a) / sizeof(a[0]))
|
||||
#define ARRAY_SIZE(a) (sizeof(a) / sizeof(a[0]))
|
||||
|
||||
void array_hexstr(char* strbuf, const void* bin, unsigned int len);
|
||||
|
||||
void convertUint128BE(const uint8_t *const data, uint32_t length, uint128_t *const target);
|
||||
void convertUint256BE(const uint8_t *const data, uint32_t length, uint256_t *const target);
|
||||
void convertUint64BEto128(const uint8_t *const data, uint32_t length, uint128_t *const target);
|
||||
void convertUint128BE(const uint8_t* const data, uint32_t length, uint128_t* const target);
|
||||
void convertUint256BE(const uint8_t* const data, uint32_t length, uint256_t* const target);
|
||||
void convertUint64BEto128(const uint8_t* const data, uint32_t length, uint128_t* const target);
|
||||
|
||||
uint64_t u64_from_BE(const uint8_t* in, uint8_t size);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user