From 056dc0099e9c300eaba2ddf04e7e13915ca94554 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20P=C3=A9ron?= Date: Wed, 19 Dec 2018 17:02:00 +0100 Subject: [PATCH 1/7] Remove trailing spaces find -name '*.c' -o -name '*.h' -o -name 'Makefile' -print0 | xargs -r0 sed -e 's/[[:blank:]]\+$//' -i --- Makefile | 8 +- src_common/ethUstream.c | 18 ++-- src_common/ethUtils.c | 6 +- src_genericwallet/main.c | 172 +++++++++++++++++++-------------------- 4 files changed, 102 insertions(+), 102 deletions(-) diff --git a/Makefile b/Makefile index 7458895..a6f294c 100755 --- a/Makefile +++ b/Makefile @@ -21,7 +21,7 @@ endif include $(BOLOS_SDK)/Makefile.defines DEFINES_LIB = USE_LIB_ETHEREUM -APP_LOAD_PARAMS= --curve secp256k1 $(COMMON_LOAD_PARAMS) +APP_LOAD_PARAMS= --curve secp256k1 $(COMMON_LOAD_PARAMS) APPVERSION_M=1 APPVERSION_N=1 @@ -184,7 +184,7 @@ ifeq ($(GCCPATH),) $(info GCCPATH is not set: arm-none-eabi-* will be used from PATH) endif -CC := $(CLANGPATH)clang +CC := $(CLANGPATH)clang #CFLAGS += -O0 CFLAGS += -O3 -Os @@ -193,13 +193,13 @@ AS := $(GCCPATH)arm-none-eabi-gcc LD := $(GCCPATH)arm-none-eabi-gcc LDFLAGS += -O3 -Os -LDLIBS += -lm -lgcc -lc +LDLIBS += -lm -lgcc -lc # import rules to compile glyphs(/pone) include $(BOLOS_SDK)/Makefile.glyphs ### variables processed by the common makefile.rules of the SDK to grab source files and include dirs -APP_SOURCE_PATH += src_genericwallet src_common src +APP_SOURCE_PATH += src_genericwallet src_common src SDK_SOURCE_PATH += lib_stusb lib_stusb_impl lib_u2f load: all diff --git a/src_common/ethUstream.c b/src_common/ethUstream.c index 0e1f06a..585d2fa 100644 --- a/src_common/ethUstream.c +++ b/src_common/ethUstream.c @@ -20,7 +20,7 @@ #define MAX_INT256 32 #define MAX_ADDRESS 20 -#define MAX_V 4 +#define MAX_V 4 void initTx(txContext_t *context, cx_sha3_t *sha3, txContent_t *content, ustreamProcess_t customProcessor, void *extra) { @@ -206,7 +206,7 @@ static void processValue(txContext_t *context) { } } -static void processTo(txContext_t *context) { +static void processTo(txContext_t *context) { if (context->currentFieldIsList) { PRINTF("Invalid type for RLP_TO\n"); THROW(EXCEPTION); @@ -214,7 +214,7 @@ static void processTo(txContext_t *context) { if (context->currentFieldLength > MAX_ADDRESS) { PRINTF("Invalid length for RLP_TO\n"); THROW(EXCEPTION); - } + } if (context->currentFieldPos < context->currentFieldLength) { uint32_t copySize = (context->commandLength < @@ -232,7 +232,7 @@ static void processTo(txContext_t *context) { } } -static void processData(txContext_t *context) { +static void processData(txContext_t *context) { if (context->currentFieldIsList) { PRINTF("Invalid type for RLP_DATA\n"); THROW(EXCEPTION); @@ -251,7 +251,7 @@ static void processData(txContext_t *context) { } } -static void processV(txContext_t *context) { +static void processV(txContext_t *context) { if (context->currentFieldIsList) { PRINTF("Invalid type for RLP_V\n"); THROW(EXCEPTION); @@ -259,7 +259,7 @@ static void processV(txContext_t *context) { if (context->currentFieldLength > MAX_V) { PRINTF("Invalid length for RLP_V\n"); THROW(EXCEPTION); - } + } if (context->currentFieldPos < context->currentFieldLength) { uint32_t copySize = (context->commandLength < @@ -350,7 +350,7 @@ static parserStatus_e processTxInternal(txContext_t *context) { return USTREAM_SUSPENDED; case CUSTOM_FAULT: PRINTF("Custom processor aborted\n"); - return USTREAM_FAULT; + return USTREAM_FAULT; default: PRINTF("Unhandled custom processor status\n"); return USTREAM_FAULT; @@ -360,7 +360,7 @@ static parserStatus_e processTxInternal(txContext_t *context) { switch (context->currentField) { case TX_RLP_CONTENT: processContent(context); - if ((context->processingFlags & TX_FLAG_TYPE) == 0) { + if ((context->processingFlags & TX_FLAG_TYPE) == 0) { context->currentField++; } break; @@ -431,5 +431,5 @@ parserStatus_e continueTx(txContext_t *context) { } } END_TRY; - return result; + return result; } diff --git a/src_common/ethUtils.c b/src_common/ethUtils.c index 199ca40..dc2f68e 100644 --- a/src_common/ethUtils.c +++ b/src_common/ethUtils.c @@ -26,7 +26,7 @@ #include "os.h" #include "cx.h" #include -#include "ethUtils.h" +#include "ethUtils.h" #include "chainConfig.h" extern chain_config_t *chainConfig; @@ -245,7 +245,7 @@ bool adjustDecimals(char *src, uint32_t srcLength, char *target, target[0] = '0'; target[1] = '\0'; return true; - } + } if (srcLength <= decimals) { uint32_t delta = decimals - srcLength; if (targetLength < srcLength + 1 + 2 + delta) { @@ -292,7 +292,7 @@ bool adjustDecimals(char *src, uint32_t srcLength, char *target, target[lastZeroOffset] = '\0'; if (target[lastZeroOffset - 1] == '.') { target[lastZeroOffset - 1] = '\0'; - } + } } return true; } diff --git a/src_genericwallet/main.c b/src_genericwallet/main.c index 763ffd2..8639765 100644 --- a/src_genericwallet/main.c +++ b/src_genericwallet/main.c @@ -76,10 +76,10 @@ void finalizeParsing(bool); static const uint8_t const TOKEN_TRANSFER_ID[] = { 0xa9, 0x05, 0x9c, 0xbb }; typedef struct tokenContext_t { uint8_t data[4 + 32 + 32]; - uint32_t dataFieldPos; + uint32_t dataFieldPos; } tokenContext_t; -typedef struct rawDataContext_t { +typedef struct rawDataContext_t { uint8_t data[32]; uint8_t fieldIndex; uint8_t fieldOffset; @@ -102,7 +102,7 @@ typedef struct messageSigningContext_t { uint8_t pathLength; uint32_t bip32Path[MAX_BIP32_PATH]; uint8_t hash[32]; - uint32_t remainingLength; + uint32_t remainingLength; } messageSigningContext_t; union { @@ -121,7 +121,7 @@ cx_sha3_t sha3; union { tokenContext_t tokenContext; - rawDataContext_t rawDataContext; + rawDataContext_t rawDataContext; } dataContext; volatile uint8_t dataAllowed; @@ -160,7 +160,7 @@ union { } strings; WIDE internalStorage_t N_storage_real; -#define N_storage (*(WIDE internalStorage_t*) PIC(&N_storage_real)) +#define N_storage (*(WIDE internalStorage_t*) PIC(&N_storage_real)) static const char const CONTRACT_ADDRESS[] = "New contract"; @@ -170,7 +170,7 @@ static const char const SIGN_MAGIC[] = "\x19" const unsigned char hex_digits[] = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'}; -chain_config_t *chainConfig; +chain_config_t *chainConfig; void array_hexstr(char *strbuf, const void *bin, unsigned int len) { while (len--) { @@ -426,7 +426,7 @@ const bagl_element_t * ui_settings_blue_prepro(const bagl_element_t * e) { } unsigned int ui_settings_blue_button(unsigned int button_mask, unsigned int button_mask_counter) { - return 0; + return 0; } #endif // #if defined(TARGET_BLUE) @@ -519,19 +519,19 @@ const bagl_element_t* ui_approval_blue_cancel_callback(const bagl_element_t* e) } typedef enum { - APPROVAL_TRANSACTION, - APPROVAL_MESSAGE, + APPROVAL_TRANSACTION, + APPROVAL_MESSAGE, } ui_approval_blue_state_t; ui_approval_blue_state_t G_ui_approval_blue_state; // pointer to value to be displayed const char* ui_approval_blue_values[3]; // variable part of the structure const char* const ui_approval_blue_details_name[][5] = { - /*APPROVAL_TRANSACTION*/ + /*APPROVAL_TRANSACTION*/ {"AMOUNT", "ADDRESS", "MAX FEES","CONFIRM TRANSACTION","Transaction details",}, - - /*APPROVAL_MESSAGE*/ - {"HASH", NULL, NULL, "SIGN MESSAGE", "Message signature", }, + + /*APPROVAL_MESSAGE*/ + {"HASH", NULL, NULL, "SIGN MESSAGE", "Message signature", }, }; const bagl_element_t* ui_approval_blue_1_details(const bagl_element_t* e) { @@ -579,7 +579,7 @@ const bagl_element_t ui_approval_blue[] = { {{BAGL_LABELINE , 0x20, 284, 196, 6, 16, 0, 0, BAGL_FILL, 0x999999, COLOR_BG_1, BAGL_FONT_SYMBOLS_0|BAGL_FONT_ALIGNMENT_RIGHT, 0 }, BAGL_FONT_SYMBOLS_0_MINIRIGHT, 0, 0, 0, NULL, NULL, NULL}, {{BAGL_NONE | BAGL_FLAG_TOUCHABLE , 0x00, 0, 168, 320, 48, 0, 9, BAGL_FILL, 0xFFFFFF, 0x000000, 0 , 0 }, NULL, 0, 0xEEEEEE, 0x000000, ui_approval_blue_1_details, ui_menu_item_out_over, ui_menu_item_out_over }, {{BAGL_RECTANGLE , 0x20, 0, 168, 5, 48, 0, 0, BAGL_FILL, COLOR_BG_1, COLOR_BG_1, 0 , 0 }, NULL, 0, 0x41CCB4, 0, NULL, NULL, NULL }, - + {{BAGL_RECTANGLE , 0x31, 30, 216, 260, 1, 1, 0, 0 , 0xEEEEEE, COLOR_BG_1, 0 , 0 }, NULL, 0, 0, 0, NULL, NULL, NULL }, @@ -588,10 +588,10 @@ const bagl_element_t ui_approval_blue[] = { {{BAGL_LABELINE , 0x11, 130, 245, 160, 30, 0, 0, BAGL_FILL, 0x000000, COLOR_BG_1, BAGL_FONT_OPEN_SANS_REGULAR_10_13PX|BAGL_FONT_ALIGNMENT_RIGHT, 0 }, NULL, 0, 0, 0, NULL, NULL, NULL}, // fullAddress {{BAGL_LABELINE , 0x21, 284, 245, 6, 16, 0, 0, BAGL_FILL, 0x999999, COLOR_BG_1, BAGL_FONT_SYMBOLS_0|BAGL_FONT_ALIGNMENT_RIGHT, 0 }, BAGL_FONT_SYMBOLS_0_MINIRIGHT, 0, 0, 0, NULL, NULL, NULL}, {{BAGL_NONE | BAGL_FLAG_TOUCHABLE , 0x00, 0, 217, 320, 48, 0, 9, BAGL_FILL, 0xFFFFFF, 0x000000, 0 , 0 }, NULL, 0, 0xEEEEEE, 0x000000, ui_approval_blue_2_details, ui_menu_item_out_over, ui_menu_item_out_over }, - {{BAGL_RECTANGLE , 0x21, 0, 217, 5, 48, 0, 0, BAGL_FILL, COLOR_BG_1, COLOR_BG_1, 0 , 0 }, NULL, 0, 0x41CCB4, 0, NULL, NULL, NULL }, + {{BAGL_RECTANGLE , 0x21, 0, 217, 5, 48, 0, 0, BAGL_FILL, COLOR_BG_1, COLOR_BG_1, 0 , 0 }, NULL, 0, 0x41CCB4, 0, NULL, NULL, NULL }, {{BAGL_RECTANGLE , 0x32, 30, 265, 260, 1, 1, 0, 0 , 0xEEEEEE, COLOR_BG_1, 0 , 0 }, NULL, 0, 0, 0, NULL, NULL, NULL }, - + {{BAGL_LABELINE , 0x72, 30, 294, 100, 30, 0, 0, BAGL_FILL, 0x000000, COLOR_BG_1, BAGL_FONT_OPEN_SANS_SEMIBOLD_8_11PX, 0 }, NULL, 0, 0, 0, NULL, NULL, NULL}, // MAX FEES // x-18 when ... @@ -603,7 +603,7 @@ const bagl_element_t ui_approval_blue[] = { {{BAGL_RECTANGLE, 0x90, 30, 314, 260, 1, 1, 0, 0, 0xEEEEEE, COLOR_BG_1, 0, 0}, NULL, 0, 0, 0, NULL, NULL, NULL}, {{BAGL_LABELINE, 0x90, 30, 343, 120, 30, 0, 0, BAGL_FILL, 0x000000, COLOR_BG_1, BAGL_FONT_OPEN_SANS_SEMIBOLD_8_11PX, 0}, "CONTRACT DATA", 0, 0, 0, NULL, NULL, NULL}, {{BAGL_LABELINE, 0x90, 133, 343, 140, 30, 0, 0, BAGL_FILL, 0x666666, COLOR_BG_1, BAGL_FONT_OPEN_SANS_REGULAR_10_13PX | BAGL_FONT_ALIGNMENT_RIGHT, 0}, "Present", 0, 0, 0, NULL, NULL, NULL}, - {{BAGL_ICON, 0x90, 278, 333, 12, 12, 0, 0, BAGL_FILL, 0, COLOR_BG_1, 0, 0}, &C_icon_warning, 0, 0, 0, NULL, NULL, NULL}, + {{BAGL_ICON, 0x90, 278, 333, 12, 12, 0, 0, BAGL_FILL, 0, COLOR_BG_1, 0, 0}, &C_icon_warning, 0, 0, 0, NULL, NULL, NULL}, {{BAGL_RECTANGLE | BAGL_FLAG_TOUCHABLE, 0x00, 40, 414, 115, 36, 0,18, BAGL_FILL, 0xCCCCCC, COLOR_BG_1, BAGL_FONT_OPEN_SANS_REGULAR_11_14PX|BAGL_FONT_ALIGNMENT_CENTER|BAGL_FONT_ALIGNMENT_MIDDLE, 0 }, "REJECT", 0, 0xB7B7B7, COLOR_BG_1, ui_approval_blue_cancel_callback, NULL, NULL}, {{BAGL_RECTANGLE | BAGL_FLAG_TOUCHABLE, 0x00, 165, 414, 115, 36, 0,18, BAGL_FILL, 0x41ccb4, COLOR_BG_1, BAGL_FONT_OPEN_SANS_REGULAR_11_14PX|BAGL_FONT_ALIGNMENT_CENTER|BAGL_FONT_ALIGNMENT_MIDDLE, 0 }, "CONFIRM", 0, 0x3ab7a2, COLOR_BG_1, ui_approval_blue_ok_callback, NULL, NULL}, @@ -624,17 +624,17 @@ const bagl_element_t* ui_approval_blue_prepro(const bagl_element_t* element) { // icon case 0x40: - return &tmp_element; + return &tmp_element; break; - + // TITLE - case 0x60: + case 0x60: tmp_element.text = ui_approval_blue_details_name[G_ui_approval_blue_state][3]; return &tmp_element; break; - + // SUBLINE - case 0x50: + case 0x50: tmp_element.text = ui_approval_blue_details_name[G_ui_approval_blue_state][4]; return &tmp_element; @@ -737,7 +737,7 @@ const bagl_element_t ui_address_nanos[] = { {{BAGL_ICON , 0x00, 3, 12, 7, 7, 0, 0, 0 , 0xFFFFFF, 0x000000, 0, BAGL_GLYPH_ICON_CROSS }, NULL, 0, 0, 0, NULL, NULL, NULL }, {{BAGL_ICON , 0x00, 117, 13, 8, 6, 0, 0, 0 , 0xFFFFFF, 0x000000, 0, BAGL_GLYPH_ICON_CHECK }, NULL, 0, 0, 0, NULL, NULL, NULL }, - //{{BAGL_ICON , 0x01, 31, 9, 14, 14, 0, 0, 0 , 0xFFFFFF, 0x000000, 0, BAGL_GLYPH_ICON_EYE_BADGE }, NULL, 0, 0, 0, NULL, NULL, NULL }, + //{{BAGL_ICON , 0x01, 31, 9, 14, 14, 0, 0, 0 , 0xFFFFFF, 0x000000, 0, BAGL_GLYPH_ICON_EYE_BADGE }, NULL, 0, 0, 0, NULL, NULL, NULL }, {{BAGL_LABELINE , 0x01, 0, 12, 128, 12, 0, 0, 0 , 0xFFFFFF, 0x000000, BAGL_FONT_OPEN_SANS_EXTRABOLD_11px|BAGL_FONT_ALIGNMENT_CENTER, 0 }, "Confirm", 0, 0, 0, NULL, NULL, NULL }, {{BAGL_LABELINE , 0x01, 0, 26, 128, 12, 0, 0, 0 , 0xFFFFFF, 0x000000, BAGL_FONT_OPEN_SANS_EXTRABOLD_11px|BAGL_FONT_ALIGNMENT_CENTER, 0 }, "address", 0, 0, 0, NULL, NULL, NULL }, @@ -776,7 +776,7 @@ const bagl_element_t ui_approval_nanos[] = { {{BAGL_ICON , 0x00, 3, 12, 7, 7, 0, 0, 0 , 0xFFFFFF, 0x000000, 0, BAGL_GLYPH_ICON_CROSS }, NULL, 0, 0, 0, NULL, NULL, NULL }, {{BAGL_ICON , 0x00, 117, 13, 8, 6, 0, 0, 0 , 0xFFFFFF, 0x000000, 0, BAGL_GLYPH_ICON_CHECK }, NULL, 0, 0, 0, NULL, NULL, NULL }, - //{{BAGL_ICON , 0x01, 21, 9, 14, 14, 0, 0, 0 , 0xFFFFFF, 0x000000, 0, BAGL_GLYPH_ICON_TRANSACTION_BADGE }, NULL, 0, 0, 0, NULL, NULL, NULL }, + //{{BAGL_ICON , 0x01, 21, 9, 14, 14, 0, 0, 0 , 0xFFFFFF, 0x000000, 0, BAGL_GLYPH_ICON_TRANSACTION_BADGE }, NULL, 0, 0, 0, NULL, NULL, NULL }, {{BAGL_LABELINE , 0x01, 0, 12, 128, 32, 0, 0, 0 , 0xFFFFFF, 0x000000, BAGL_FONT_OPEN_SANS_EXTRABOLD_11px|BAGL_FONT_ALIGNMENT_CENTER, 0 }, "Confirm", 0, 0, 0, NULL, NULL, NULL }, {{BAGL_LABELINE , 0x01, 0, 26, 128, 32, 0, 0, 0 , 0xFFFFFF, 0x000000, BAGL_FONT_OPEN_SANS_EXTRABOLD_11px|BAGL_FONT_ALIGNMENT_CENTER, 0 }, "transaction", 0, 0, 0, NULL, NULL, NULL }, @@ -832,7 +832,7 @@ unsigned int ui_approval_nanos_button(unsigned int button_mask, unsigned int but const bagl_element_t ui_approval_signMessage_nanos[] = { // type userid x y w h str rad fill fg bg fid iid txt touchparams... ] {{BAGL_RECTANGLE , 0x00, 0, 0, 128, 32, 0, 0, BAGL_FILL, 0x000000, 0xFFFFFF, 0, 0}, NULL, 0, 0, 0, NULL, NULL, NULL}, - + {{BAGL_ICON , 0x00, 3, 12, 7, 7, 0, 0, 0 , 0xFFFFFF, 0x000000, 0, BAGL_GLYPH_ICON_CROSS }, NULL, 0, 0, 0, NULL, NULL, NULL }, {{BAGL_ICON , 0x00, 117, 13, 8, 6, 0, 0, 0 , 0xFFFFFF, 0x000000, 0, BAGL_GLYPH_ICON_CHECK }, NULL, 0, 0, 0, NULL, NULL, NULL }, @@ -1060,7 +1060,7 @@ void ui_idle(void) { #if defined(TARGET_BLUE) UX_DISPLAY(ui_idle_blue, ui_idle_blue_prepro); #elif defined(TARGET_NANOS) - UX_MENU_DISPLAY(0, menu_main, NULL); + UX_MENU_DISPLAY(0, menu_main, NULL); #endif // #if TARGET_ID } @@ -1115,24 +1115,24 @@ unsigned int ui_address_nanos_button(unsigned int button_mask, unsigned int butt #endif // #if defined(TARGET_NANOS) uint32_t getV(txContent_t *txContent) { - uint32_t v = 0; + uint32_t v = 0; if (txContent->vLength == 1) { v = txContent->v[0]; } - else + else if (txContent->vLength == 2) { v = (txContent->v[0] << 8) | txContent->v[1]; } - else + else if (txContent->vLength == 3) { v = (txContent->v[0] << 16) | (txContent->v[1] << 8) | txContent->v[2]; - } + } else if (txContent->vLength == 4) { - v = (txContent->v[0] << 24) | (txContent->v[1] << 16) | + v = (txContent->v[0] << 24) | (txContent->v[1] << 16) | (txContent->v[2] << 8) | txContent->v[3]; } - else + else if (txContent->vLength != 0) { PRINTF("Unexpected v format\n"); THROW(EXCEPTION); @@ -1161,12 +1161,12 @@ unsigned int io_seproxyhal_touch_tx_ok(const bagl_element_t *e) { cx_ecfp_init_private_key(CX_CURVE_256K1, privateKeyData, 32, &privateKey); os_memset(privateKeyData, 0, sizeof(privateKeyData)); - unsigned int info = 0; + unsigned int info = 0; signatureLength = cx_ecdsa_sign(&privateKey, CX_RND_RFC6979 | CX_LAST, CX_SHA256, tmpCtx.transactionContext.hash, sizeof(tmpCtx.transactionContext.hash), signature, &info); - os_memset(&privateKey, 0, sizeof(privateKey)); + os_memset(&privateKey, 0, sizeof(privateKey)); // Parity is present in the sequence tag in the legacy API if (tmpContent.txContent.vLength == 0) { // Legacy API @@ -1175,7 +1175,7 @@ unsigned int io_seproxyhal_touch_tx_ok(const bagl_element_t *e) { else { // New API // Note that this is wrong for a large v, but the client can always recover - G_io_apdu_buffer[0] = (v * 2) + 35; + G_io_apdu_buffer[0] = (v * 2) + 35; } if (info & CX_ECCINFO_PARITY_ODD) { G_io_apdu_buffer[0]++; @@ -1193,7 +1193,7 @@ unsigned int io_seproxyhal_touch_tx_ok(const bagl_element_t *e) { tx = 65; G_io_apdu_buffer[tx++] = 0x90; G_io_apdu_buffer[tx++] = 0x00; -send: +send: // Send back the response, do not restart the event loop io_exchange(CHANNEL_APDU | IO_RETURN_AFTER_TX, tx); // Display back the original UX @@ -1224,7 +1224,7 @@ unsigned int io_seproxyhal_touch_signMessage_ok(const bagl_element_t *e) { tmpCtx.messageSigningContext.pathLength, privateKeyData, NULL); cx_ecfp_init_private_key(CX_CURVE_256K1, privateKeyData, 32, &privateKey); os_memset(privateKeyData, 0, sizeof(privateKeyData)); - unsigned int info = 0; + unsigned int info = 0; signatureLength = cx_ecdsa_sign(&privateKey, CX_RND_RFC6979 | CX_LAST, CX_SHA256, tmpCtx.messageSigningContext.hash, @@ -1236,7 +1236,7 @@ unsigned int io_seproxyhal_touch_signMessage_ok(const bagl_element_t *e) { } if (info & CX_ECCINFO_xGTn) { G_io_apdu_buffer[0] += 2; - } + } rLength = signature[3]; sLength = signature[4 + rLength + 1]; rOffset = (rLength == 33 ? 1 : 0); @@ -1298,7 +1298,7 @@ unsigned int io_seproxyhal_touch_data_cancel(const bagl_element_t *e) { io_seproxyhal_send_status(0x6985); // Display back the original UX ui_idle(); - return 0; // do not redraw the widget + return 0; // do not redraw the widget } #if defined(TARGET_BLUE) @@ -1337,7 +1337,7 @@ unsigned int ui_approval_nanos_button(unsigned int button_mask, unsigned int but io_seproxyhal_touch_tx_ok(NULL); break; } - } + } return 0; } @@ -1468,7 +1468,7 @@ tokenDefinition_t* getKnownToken() { break; case CHAIN_KIND_ETHEREUM_CLASSIC: numTokens = NUM_TOKENS_ETHEREUM_CLASSIC; - break; + break; case CHAIN_KIND_PIRL: numTokens = NUM_TOKENS_PIRL; break; @@ -1477,7 +1477,7 @@ tokenDefinition_t* getKnownToken() { break; case CHAIN_KIND_RSK: numTokens = NUM_TOKENS_RSK; - break; + break; case CHAIN_KIND_EXPANSE: numTokens = NUM_TOKENS_EXPANSE; break; @@ -1486,16 +1486,16 @@ tokenDefinition_t* getKnownToken() { break; case CHAIN_KIND_WANCHAIN: numTokens = NUM_TOKENS_WANCHAIN; - break; + break; case CHAIN_KIND_KUSD: numTokens = NUM_TOKENS_KUSD; - break; + break; case CHAIN_KIND_MUSICOIN: numTokens = NUM_TOKENS_MUSICOIN; break; case CHAIN_KIND_CALLISTO: numTokens = NUM_TOKENS_CALLISTO; - break; + break; case CHAIN_KIND_ETHERSOCIAL: numTokens = NUM_TOKENS_ETHERSOCIAL; break; @@ -1521,7 +1521,7 @@ tokenDefinition_t* getKnownToken() { numTokens = NUM_TOKENS_REOSC; break; } - for (i=0; ikind) { case CHAIN_KIND_AKROMA: currentToken = PIC(&TOKENS_AKROMA[i]); @@ -1531,7 +1531,7 @@ tokenDefinition_t* getKnownToken() { break; case CHAIN_KIND_ETHEREUM_CLASSIC: currentToken = PIC(&TOKENS_ETHEREUM_CLASSIC[i]); - break; + break; case CHAIN_KIND_PIRL: currentToken = PIC(&TOKENS_PIRL[i]); break; @@ -1540,16 +1540,16 @@ tokenDefinition_t* getKnownToken() { break; case CHAIN_KIND_RSK: currentToken = PIC(&TOKENS_RSK[i]); - break; + break; case CHAIN_KIND_EXPANSE: currentToken = PIC(&TOKENS_EXPANSE[i]); - break; + break; case CHAIN_KIND_UBIQ: currentToken = PIC(&TOKENS_UBIQ[i]); - break; + break; case CHAIN_KIND_WANCHAIN: currentToken = PIC(&TOKENS_WANCHAIN[i]); - break; + break; case CHAIN_KIND_KUSD: currentToken = PIC(&TOKENS_KUSD[i]); break; @@ -1583,7 +1583,7 @@ tokenDefinition_t* getKnownToken() { case CHAIN_KIND_REOSC: currentToken = PIC(&TOKENS_REOSC[i]); break; - } + } if (os_memcmp(currentToken->address, tmpContent.txContent.destination, 20) == 0) { return currentToken; } @@ -1600,16 +1600,16 @@ customStatus_e customProcessor(txContext_t *context) { if (tmpContent.txContent.destinationLength == 0) { return CUSTOM_NOT_HANDLED; } - if (context->currentFieldPos == 0) { + if (context->currentFieldPos == 0) { // If handling the beginning of the data field, assume that the function selector is present if (context->commandLength < 4) { PRINTF("Missing function selector\n"); return CUSTOM_FAULT; } // Initial check to see if the token content can be processed - tokenProvisioned = + tokenProvisioned = (context->currentFieldLength == sizeof(dataContext.tokenContext.data)) && - (os_memcmp(context->workBuffer, TOKEN_TRANSFER_ID, 4) == 0) && + (os_memcmp(context->workBuffer, TOKEN_TRANSFER_ID, 4) == 0) && (getKnownToken() != NULL); } if (tokenProvisioned) { @@ -1649,7 +1649,7 @@ customStatus_e customProcessor(txContext_t *context) { else { if (!N_storage.contractDetails) { return CUSTOM_NOT_HANDLED; - } + } blockSize = 32 - (dataContext.rawDataContext.fieldOffset % 32); } @@ -1676,7 +1676,7 @@ customStatus_e customProcessor(txContext_t *context) { if (fieldPos != 0) { dataContext.rawDataContext.fieldIndex++; } - dataContext.rawDataContext.fieldOffset = 0; + dataContext.rawDataContext.fieldOffset = 0; if (fieldPos == 0) { array_hexstr(strings.tmp.tmp, dataContext.rawDataContext.data, 4); #if defined(TARGET_BLUE) @@ -1703,14 +1703,14 @@ customStatus_e customProcessor(txContext_t *context) { ux_step = 0; ux_step_count = 2; UX_DISPLAY(ui_data_parameter_nanos, ui_data_parameter_prepro); -#endif // #if TARGET_ID +#endif // #if TARGET_ID } } else { return CUSTOM_HANDLED; } - return CUSTOM_SUSPENDED; + return CUSTOM_SUSPENDED; } } return CUSTOM_NOT_HANDLED; @@ -1718,7 +1718,7 @@ customStatus_e customProcessor(txContext_t *context) { void handleGetPublicKey(uint8_t p1, uint8_t p2, uint8_t *dataBuffer, uint16_t dataLength, volatile unsigned int *flags, volatile unsigned int *tx) { - UNUSED(dataLength); + UNUSED(dataLength); uint8_t privateKeyData[32]; uint32_t bip32Path[MAX_BIP32_PATH]; uint32_t i; @@ -1752,8 +1752,8 @@ void handleGetPublicKey(uint8_t p1, uint8_t p2, uint8_t *dataBuffer, uint16_t da if (p1 == P1_NON_CONFIRM) { *tx = set_result_get_publicKey(); THROW(0x9000); - } - else + } + else { /* addressSummary[0] = '0'; @@ -1772,9 +1772,9 @@ void handleGetPublicKey(uint8_t p1, uint8_t p2, uint8_t *dataBuffer, uint16_t da snprintf(strings.common.fullAddress, sizeof(strings.common.fullAddress), "0x%.*s", 40, tmpCtx.publicKeyContext.address); ux_step = 0; ux_step_count = 2; - UX_DISPLAY(ui_address_nanos, ui_address_prepro); + UX_DISPLAY(ui_address_nanos, ui_address_prepro); #endif // #if TARGET_ID - + *flags |= IO_ASYNCH_REPLY; } } @@ -1817,7 +1817,7 @@ void finalizeParsing(bool direct) { os_memmove(tmpContent.txContent.value.value, dataContext.tokenContext.data + 4 + 32, 32); tmpContent.txContent.value.length = 32; } - } + } else { if (dataPresent && !N_storage.dataAllowed) { PRINTF("Data field forbidden\n"); @@ -1829,7 +1829,7 @@ void finalizeParsing(bool direct) { ui_idle(); return; } - } + } } // Add address if (tmpContent.txContent.destinationLength != 0) { @@ -1848,7 +1848,7 @@ void finalizeParsing(bool direct) { os_memmove((unsigned char *)strings.common.fullAddress+2, address, 40); strings.common.fullAddress[42] = '\0'; } - else + else { os_memmove((void*)addressSummary, CONTRACT_ADDRESS, sizeof(CONTRACT_ADDRESS)); strcpy(strings.common.fullAddress, "Contract"); @@ -1870,7 +1870,7 @@ void finalizeParsing(bool direct) { while (G_io_apdu_buffer[i]) { strings.common.fullAmount[tickerOffset + i] = G_io_apdu_buffer[i]; i++; - } + } strings.common.fullAmount[tickerOffset + i] = '\0'; // Compute maximum fee convertUint256BE(tmpContent.txContent.gasprice.value, tmpContent.txContent.gasprice.length, &gasPrice); @@ -1900,13 +1900,13 @@ void finalizeParsing(bool direct) { #elif defined(TARGET_NANOS) ux_step = 0; ux_step_count = 5; - UX_DISPLAY(ui_approval_nanos, ui_approval_prepro); + UX_DISPLAY(ui_approval_nanos, ui_approval_prepro); #endif // #if TARGET_ID } void handleSign(uint8_t p1, uint8_t p2, uint8_t *workBuffer, uint16_t dataLength, volatile unsigned int *flags, volatile unsigned int *tx) { UNUSED(tx); - parserStatus_e txResult; + parserStatus_e txResult; uint32_t i; if (p1 == P1_FIRST) { tmpCtx.transactionContext.pathLength = workBuffer[0]; @@ -1927,8 +1927,8 @@ void handleSign(uint8_t p1, uint8_t p2, uint8_t *workBuffer, uint16_t dataLength dataPresent = false; tokenProvisioned = false; initTx(&txContext, &sha3, &tmpContent.txContent, customProcessor, NULL); - } - else + } + else if (p1 != P1_MORE) { THROW(0x6B00); } @@ -1958,7 +1958,7 @@ void handleSign(uint8_t p1, uint8_t p2, uint8_t *workBuffer, uint16_t dataLength if (txResult == USTREAM_FINISHED) { finalizeParsing(true); - } + } } void handleGetAppConfiguration(uint8_t p1, uint8_t p2, uint8_t *workBuffer, uint16_t dataLength, volatile unsigned int *flags, volatile unsigned int *tx) { @@ -2016,7 +2016,7 @@ void handleSignPersonalMessage(uint8_t p1, uint8_t p2, uint8_t *workBuffer, uint tmp[pos] = '\0'; cx_hash((cx_hash_t *)&sha3, 0, tmp, pos, NULL); cx_sha256_init(&tmpContent.sha2); - } + } else if (p1 != P1_MORE) { THROW(0x6B00); } @@ -2066,26 +2066,26 @@ void handleApdu(volatile unsigned int *flags, volatile unsigned int *tx) { } switch (G_io_apdu_buffer[OFFSET_INS]) { - case INS_GET_PUBLIC_KEY: + case INS_GET_PUBLIC_KEY: handleGetPublicKey(G_io_apdu_buffer[OFFSET_P1], G_io_apdu_buffer[OFFSET_P2], G_io_apdu_buffer + OFFSET_CDATA, G_io_apdu_buffer[OFFSET_LC], flags, tx); break; - case INS_SIGN: + case INS_SIGN: handleSign(G_io_apdu_buffer[OFFSET_P1], G_io_apdu_buffer[OFFSET_P2], G_io_apdu_buffer + OFFSET_CDATA, G_io_apdu_buffer[OFFSET_LC], flags, tx); break; - case INS_GET_APP_CONFIGURATION: + case INS_GET_APP_CONFIGURATION: handleGetAppConfiguration(G_io_apdu_buffer[OFFSET_P1], G_io_apdu_buffer[OFFSET_P2], G_io_apdu_buffer + OFFSET_CDATA, G_io_apdu_buffer[OFFSET_LC], flags, tx); break; - case INS_SIGN_PERSONAL_MESSAGE: + case INS_SIGN_PERSONAL_MESSAGE: handleSignPersonalMessage(G_io_apdu_buffer[OFFSET_P1], G_io_apdu_buffer[OFFSET_P2], G_io_apdu_buffer + OFFSET_CDATA, G_io_apdu_buffer[OFFSET_LC], flags, tx); break; #if 0 case 0xFF: // return to dashboard goto return_to_dashboard; -#endif +#endif default: THROW(0x6D00); @@ -2203,7 +2203,7 @@ unsigned char io_event(unsigned char channel) { case SEPROXYHAL_TAG_FINGER_EVENT: UX_FINGER_EVENT(G_io_seproxyhal_spi_buffer); break; - + case SEPROXYHAL_TAG_BUTTON_PUSH_EVENT: UX_BUTTON_PUSH_EVENT(G_io_seproxyhal_spi_buffer); break; @@ -2222,14 +2222,14 @@ unsigned char io_event(unsigned char channel) { break; case SEPROXYHAL_TAG_TICKER_EVENT: - UX_TICKER_EVENT(G_io_seproxyhal_spi_buffer, + UX_TICKER_EVENT(G_io_seproxyhal_spi_buffer, { if (UX_ALLOWED) { if (ux_step_count) { // prepare next screen ux_step = (ux_step+1)%ux_step_count; // redisplay screen - UX_REDISPLAY(); + UX_REDISPLAY(); } } }); @@ -2296,15 +2296,15 @@ __attribute__((section(".boot"))) int main(int arg0) { app_exit(); } } - END_TRY; -#else + END_TRY; +#else // exit critical section __asm volatile("cpsie i"); if (arg0) { if (((unsigned int *)arg0)[0] != 0x100) { os_lib_throw(INVALID_PARAMETER); - } + } chainConfig = (chain_config_t *)((unsigned int *)arg0)[1]; } else { @@ -2342,7 +2342,7 @@ __attribute__((section(".boot"))) int main(int arg0) { // setup the status bar colors (remembered after wards, even more if another app does not resetup after app switch) UX_SET_STATUS_BAR_COLOR(0xFFFFFF, chainConfig->color_header); #endif // #if defined(TARGET_BLUE) - + sample_main(); } CATCH(EXCEPTION_IO_RESET) { From f30462f863afe8181f535211c028d40b178327a3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20P=C3=A9ron?= Date: Wed, 19 Dec 2018 17:02:01 +0100 Subject: [PATCH 2/7] fix tokens array size Compiler warns about "excess elements in array initializer" Fix this by setting the correct size of the array --- src_genericwallet/tokens.c | 6 +++--- src_genericwallet/tokens.h | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src_genericwallet/tokens.c b/src_genericwallet/tokens.c index 0f700fa..8d9b3d6 100644 --- a/src_genericwallet/tokens.c +++ b/src_genericwallet/tokens.c @@ -20,7 +20,7 @@ const tokenDefinition_t const TOKENS_AKROMA[NUM_TOKENS_AKROMA] = {}; const tokenDefinition_t const TOKENS_ETHEREUM[NUM_TOKENS_ETHEREUM] = { - {{0x4E,0x84,0xE9,0xe5,0xfb,0x0A,0x97,0x26,0x28,0xCf,0x45,0x68,0xc4,0x03,0x16,0x7E,0xF1,0xD4,0x04,0x31}, "$FFC ", 18}, + {{0x4E,0x84,0xE9,0xe5,0xfb,0x0A,0x97,0x26,0x28,0xCf,0x45,0x68,0xc4,0x03,0x16,0x7E,0xF1,0xD4,0x04,0x31}, "$FFC ", 18}, {{0xa0,0x24,0xe8,0x05,0x7e,0xec,0x47,0x4a,0x9b,0x23,0x56,0x83,0x37,0x07,0xdd,0x05,0x79,0xe2,0x6e,0xf3}, "$FYX ", 18}, {{0xcd,0xb7,0xec,0xfd,0x34,0x03,0xee,0xf3,0x88,0x2c,0x65,0xb7,0x61,0xef,0x9b,0x50,0x54,0x89,0x0a,0x47}, "$HUR ", 18}, {{0x0d,0xb8,0xd8,0xb7,0x6b,0xc3,0x61,0xba,0xcb,0xb7,0x2e,0x2c,0x49,0x1e,0x06,0x08,0x5a,0x97,0xab,0x31}, "$IQN ", 18}, @@ -1125,11 +1125,11 @@ const tokenDefinition_t const TOKENS_ETHEREUM[NUM_TOKENS_ETHEREUM] = { }; const tokenDefinition_t const TOKENS_ELLAISM[NUM_TOKENS_ELLAISM] = { - {{0x99,0x1e,0x7f,0xe4,0xb0,0x5f,0x2b,0x3d,0xb1,0xd7,0x88,0xe7,0x05,0x96,0x3f,0x5d,0x64,0x7b,0x00,0x44}, "MINING", 18}, + {{0x99,0x1e,0x7f,0xe4,0xb0,0x5f,0x2b,0x3d,0xb1,0xd7,0x88,0xe7,0x05,0x96,0x3f,0x5d,0x64,0x7b,0x00,0x44}, "MINING", 18}, }; const tokenDefinition_t const TOKENS_ETHEREUM_CLASSIC[NUM_TOKENS_ETHEREUM_CLASSIC] = { - {{0x6F,0x6D,0xEb,0x5d,0xb0,0xC4,0x99,0x4A,0x82,0x83,0xA0,0x1D,0x6C,0xFe,0xEB,0x27,0xFc,0x3b,0xBe,0x9C}, "Smart ", 0}, + {{0x6F,0x6D,0xEb,0x5d,0xb0,0xC4,0x99,0x4A,0x82,0x83,0xA0,0x1D,0x6C,0xFe,0xEB,0x27,0xFc,0x3b,0xBe,0x9C}, "Smart ", 0}, {{0x08,0x5f,0xb4,0xf2,0x40,0x31,0xea,0xed,0xbc,0x2b,0x61,0x1a,0xa5,0x28,0xf2,0x23,0x43,0xeb,0x52,0xdb}, "BEC ", 8}, {{0x5a,0xce,0x17,0xf8,0x7c,0x73,0x91,0xe5,0x79,0x2a,0x76,0x83,0x06,0x9a,0x80,0x25,0xb8,0x3b,0xbd,0x85}, "PLAY ", 0}, {{0x6A,0xDa,0x6F,0x48,0xC8,0x15,0x68,0x95,0x02,0xC4,0x3e,0xC1,0xa5,0x9F,0x1b,0x5D,0xD3,0xC0,0x4E,0x1F}, "UNV ", 18}, diff --git a/src_genericwallet/tokens.h b/src_genericwallet/tokens.h index 129fded..e51d85a 100644 --- a/src_genericwallet/tokens.h +++ b/src_genericwallet/tokens.h @@ -25,8 +25,8 @@ typedef struct tokenDefinition_t { #define NUM_TOKENS_AKROMA 0 #define NUM_TOKENS_ELLAISM 1 -#define NUM_TOKENS_ETHEREUM 1073 -#define NUM_TOKENS_ETHEREUM_CLASSIC 0 +#define NUM_TOKENS_ETHEREUM 1102 +#define NUM_TOKENS_ETHEREUM_CLASSIC 4 #define NUM_TOKENS_ETHERSOCIAL 0 #define NUM_TOKENS_ETHER1 0 #define NUM_TOKENS_PIRL 0 From 1686e7033d9c189cd96637ba295cf928346a4aa0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20P=C3=A9ron?= Date: Wed, 19 Dec 2018 17:02:01 +0100 Subject: [PATCH 3/7] remove unused label --- src_genericwallet/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src_genericwallet/main.c b/src_genericwallet/main.c index 8639765..15dea8b 100644 --- a/src_genericwallet/main.c +++ b/src_genericwallet/main.c @@ -1193,7 +1193,7 @@ unsigned int io_seproxyhal_touch_tx_ok(const bagl_element_t *e) { tx = 65; G_io_apdu_buffer[tx++] = 0x90; G_io_apdu_buffer[tx++] = 0x00; -send: + // Send back the response, do not restart the event loop io_exchange(CHANNEL_APDU | IO_RETURN_AFTER_TX, tx); // Display back the original UX From 727bef9815657fa33bafdc86741c05d129d20a28 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20P=C3=A9ron?= Date: Wed, 19 Dec 2018 17:02:01 +0100 Subject: [PATCH 4/7] Remove WIDE class --- src_genericwallet/main.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src_genericwallet/main.c b/src_genericwallet/main.c index 15dea8b..2a62ea4 100644 --- a/src_genericwallet/main.c +++ b/src_genericwallet/main.c @@ -159,8 +159,8 @@ union { strDataTmp_t tmp; } strings; -WIDE internalStorage_t N_storage_real; -#define N_storage (*(WIDE internalStorage_t*) PIC(&N_storage_real)) +internalStorage_t N_storage_real; +#define N_storage (*(internalStorage_t*) PIC(&N_storage_real)) static const char const CONTRACT_ADDRESS[] = "New contract"; From 6d51932970c7c96ff93691f37fe813ec5371f912 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20P=C3=A9ron?= Date: Wed, 19 Dec 2018 17:02:02 +0100 Subject: [PATCH 5/7] Add cast for token definitions using PIC macro --- src_genericwallet/main.c | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/src_genericwallet/main.c b/src_genericwallet/main.c index 2a62ea4..cda7e6d 100644 --- a/src_genericwallet/main.c +++ b/src_genericwallet/main.c @@ -1524,64 +1524,64 @@ tokenDefinition_t* getKnownToken() { for (i=0; ikind) { case CHAIN_KIND_AKROMA: - currentToken = PIC(&TOKENS_AKROMA[i]); + currentToken = (tokenDefinition_t *)PIC(&TOKENS_AKROMA[i]); break; case CHAIN_KIND_ETHEREUM: - currentToken = PIC(&TOKENS_ETHEREUM[i]); + currentToken = (tokenDefinition_t *)PIC(&TOKENS_ETHEREUM[i]); break; case CHAIN_KIND_ETHEREUM_CLASSIC: - currentToken = PIC(&TOKENS_ETHEREUM_CLASSIC[i]); + currentToken = (tokenDefinition_t *)PIC(&TOKENS_ETHEREUM_CLASSIC[i]); break; case CHAIN_KIND_PIRL: - currentToken = PIC(&TOKENS_PIRL[i]); + currentToken = (tokenDefinition_t *)PIC(&TOKENS_PIRL[i]); break; case CHAIN_KIND_POA: - currentToken = PIC(&TOKENS_POA[i]); + currentToken = (tokenDefinition_t *)PIC(&TOKENS_POA[i]); break; case CHAIN_KIND_RSK: - currentToken = PIC(&TOKENS_RSK[i]); + currentToken = (tokenDefinition_t *)PIC(&TOKENS_RSK[i]); break; case CHAIN_KIND_EXPANSE: - currentToken = PIC(&TOKENS_EXPANSE[i]); + currentToken = (tokenDefinition_t *)PIC(&TOKENS_EXPANSE[i]); break; case CHAIN_KIND_UBIQ: - currentToken = PIC(&TOKENS_UBIQ[i]); + currentToken = (tokenDefinition_t *)PIC(&TOKENS_UBIQ[i]); break; case CHAIN_KIND_WANCHAIN: - currentToken = PIC(&TOKENS_WANCHAIN[i]); + currentToken = (tokenDefinition_t *)PIC(&TOKENS_WANCHAIN[i]); break; case CHAIN_KIND_KUSD: - currentToken = PIC(&TOKENS_KUSD[i]); + currentToken = (tokenDefinition_t *)PIC(&TOKENS_KUSD[i]); break; case CHAIN_KIND_MUSICOIN: - currentToken = PIC(&TOKENS_MUSICOIN[i]); + currentToken = (tokenDefinition_t *)PIC(&TOKENS_MUSICOIN[i]); break; case CHAIN_KIND_CALLISTO: - currentToken = PIC(&TOKENS_CALLISTO[i]); + currentToken = (tokenDefinition_t *)PIC(&TOKENS_CALLISTO[i]); break; case CHAIN_KIND_ETHERSOCIAL: - currentToken = PIC(&TOKENS_ETHERSOCIAL[i]); + currentToken = (tokenDefinition_t *)PIC(&TOKENS_ETHERSOCIAL[i]); break; case CHAIN_KIND_ELLAISM: - currentToken = PIC(&TOKENS_ELLAISM[i]); + currentToken = (tokenDefinition_t *)PIC(&TOKENS_ELLAISM[i]); break; case CHAIN_KIND_ETHER1: - currentToken = PIC(&TOKENS_ETHER1[i]); + currentToken = (tokenDefinition_t *)PIC(&TOKENS_ETHER1[i]); break; case CHAIN_KIND_ETHERGEM: - currentToken = PIC(&TOKENS_ETHERGEM[i]); + currentToken = (tokenDefinition_t *)PIC(&TOKENS_ETHERGEM[i]); break; case CHAIN_KIND_ATHEIOS: - currentToken = PIC(&TOKENS_ATHEIOS[i]); + currentToken = (tokenDefinition_t *)PIC(&TOKENS_ATHEIOS[i]); break; case CHAIN_KIND_GOCHAIN: - currentToken = PIC(&TOKENS_GOCHAIN[i]); + currentToken = (tokenDefinition_t *)PIC(&TOKENS_GOCHAIN[i]); break; case CHAIN_KIND_MIX: - currentToken = PIC(&TOKENS_MIX[i]); + currentToken = (tokenDefinition_t *)PIC(&TOKENS_MIX[i]); break; case CHAIN_KIND_REOSC: - currentToken = PIC(&TOKENS_REOSC[i]); + currentToken = (tokenDefinition_t *)PIC(&TOKENS_REOSC[i]); break; } if (os_memcmp(currentToken->address, tmpContent.txContent.destination, 20) == 0) { From 400bece1842945c059cb7b81814549097cdea08e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20P=C3=A9ron?= Date: Wed, 19 Dec 2018 17:02:02 +0100 Subject: [PATCH 6/7] move src_genericwallet to src This will avoid an error with glyph.h which is not found when compiling deps. Due to INCLUDE_PATH is looking for *.h but the glyph.h doesn't exist at this moment --- Makefile | 2 +- {src_genericwallet => src}/chainConfig.h | 0 {src_genericwallet => src}/main.c | 0 {src_genericwallet => src}/tokens.c | 0 {src_genericwallet => src}/tokens.h | 0 5 files changed, 1 insertion(+), 1 deletion(-) rename {src_genericwallet => src}/chainConfig.h (100%) rename {src_genericwallet => src}/main.c (100%) rename {src_genericwallet => src}/tokens.c (100%) rename {src_genericwallet => src}/tokens.h (100%) diff --git a/Makefile b/Makefile index a6f294c..d078c09 100755 --- a/Makefile +++ b/Makefile @@ -199,7 +199,7 @@ LDLIBS += -lm -lgcc -lc include $(BOLOS_SDK)/Makefile.glyphs ### variables processed by the common makefile.rules of the SDK to grab source files and include dirs -APP_SOURCE_PATH += src_genericwallet src_common src +APP_SOURCE_PATH += src_common src SDK_SOURCE_PATH += lib_stusb lib_stusb_impl lib_u2f load: all diff --git a/src_genericwallet/chainConfig.h b/src/chainConfig.h similarity index 100% rename from src_genericwallet/chainConfig.h rename to src/chainConfig.h diff --git a/src_genericwallet/main.c b/src/main.c similarity index 100% rename from src_genericwallet/main.c rename to src/main.c diff --git a/src_genericwallet/tokens.c b/src/tokens.c similarity index 100% rename from src_genericwallet/tokens.c rename to src/tokens.c diff --git a/src_genericwallet/tokens.h b/src/tokens.h similarity index 100% rename from src_genericwallet/tokens.h rename to src/tokens.h From 7c25f2643a0da7d8b8ecdc2b1eb12e624f47ba3d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20P=C3=A9ron?= Date: Wed, 19 Dec 2018 17:02:03 +0100 Subject: [PATCH 7/7] Add cast for var using PIC Macro --- src/main.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main.c b/src/main.c index cda7e6d..92a3d56 100644 --- a/src/main.c +++ b/src/main.c @@ -1784,8 +1784,8 @@ void finalizeParsing(bool direct) { uint32_t i; uint8_t address[41]; uint8_t decimals = WEI_TO_ETHER; - uint8_t *ticker = PIC(chainConfig->coinName); - uint8_t *feeTicker = PIC(chainConfig->coinName); + uint8_t *ticker = (uint8_t *)PIC(chainConfig->coinName); + uint8_t *feeTicker = (uint8_t *)PIC(chainConfig->coinName); uint8_t tickerOffset = 0; // Verify the chain