diff --git a/src/handle_swap_sign_transaction.c b/src/handle_swap_sign_transaction.c index 23b4a39a..fcfd11ae 100644 --- a/src/handle_swap_sign_transaction.c +++ b/src/handle_swap_sign_transaction.c @@ -66,10 +66,10 @@ void handle_swap_sign_transaction(chain_config_t* config) { } #ifdef HAVE_BAGL - UX_INIT(); + UX_INIT(); #endif // HAVE_BAGL #ifdef HAVE_NBGL - nbgl_objInit(); + nbgl_objInit(); #endif // HAVE_NBGL USB_power(0); USB_power(1); diff --git a/src/main.c b/src/main.c index 557182ca..0ad9b63a 100644 --- a/src/main.c +++ b/src/main.c @@ -875,7 +875,7 @@ unsigned char io_event(__attribute__((unused)) unsigned char channel) { case SEPROXYHAL_TAG_BUTTON_PUSH_EVENT: UX_BUTTON_PUSH_EVENT(G_io_seproxyhal_spi_buffer); break; -#endif // HAVE_BAGL +#endif // HAVE_BAGL case SEPROXYHAL_TAG_STATUS_EVENT: // if (G_io_apdu_media == IO_APDU_MEDIA_USB_HID && @@ -894,12 +894,10 @@ unsigned char io_event(__attribute__((unused)) unsigned char channel) { #endif // HAVE_BAGL break; - case SEPROXYHAL_TAG_TICKER_EVENT: - G_ticks++; - UX_TICKER_EVENT(G_io_seproxyhal_spi_buffer, - { - }); - break; + case SEPROXYHAL_TAG_TICKER_EVENT: + G_ticks++; + UX_TICKER_EVENT(G_io_seproxyhal_spi_buffer, {}); + break; } // close the event if not done previously (by a display or whatever) diff --git a/src_common/network.c b/src_common/network.c index 8f752101..544837a9 100644 --- a/src_common/network.c +++ b/src_common/network.c @@ -7,10 +7,7 @@ #include "shared_context.h" #include "utils.h" -typedef enum { - APP, - TX -} e_net_type; +typedef enum { APP, TX } e_net_type; // Mappping of chain ids to networks. const network_info_t NETWORK_MAPPING[] = { @@ -59,7 +56,6 @@ const network_info_t NETWORK_MAPPING[] = { {.chain_id = 534352, .name = "Scroll", .ticker = "SCR "}, {.chain_id = 321, .name = "KCC", .ticker = "KCS "}}; - uint64_t get_tx_chain_id(void) { uint64_t chain_id = 0; diff --git a/src_nbgl/ui_approve_tx.c b/src_nbgl/ui_approve_tx.c index 60e974bb..4245b72e 100644 --- a/src_nbgl/ui_approve_tx.c +++ b/src_nbgl/ui_approve_tx.c @@ -8,11 +8,11 @@ // 1 more than actually displayed on screen, because of calculations in StaticReview #define MAX_PLUGIN_ITEMS_PER_SCREEN 4 -#define TAG_MAX_LEN 43 -#define VALUE_MAX_LEN 79 +#define TAG_MAX_LEN 43 +#define VALUE_MAX_LEN 79 enum { - REJECT_TOKEN, - START_REVIEW_TOKEN, + REJECT_TOKEN, + START_REVIEW_TOKEN, }; static nbgl_layoutTagValue_t tlv; @@ -24,199 +24,214 @@ static nbgl_layoutTagValueList_t useCaseTagValueList; static nbgl_pageInfoLongPress_t infoLongPress; struct tx_approval_context_t { - bool fromPlugin; - bool blindSigning; - bool displayNetwork; + bool fromPlugin; + bool blindSigning; + bool displayNetwork; }; static struct tx_approval_context_t tx_approval_context; static void reviewContinueCommon(void); - static void reviewReject(void) { - io_seproxyhal_touch_tx_cancel(NULL); - ui_idle(); + io_seproxyhal_touch_tx_cancel(NULL); + ui_idle(); } static void confirmTransation(void) { - io_seproxyhal_touch_tx_ok(NULL); - ui_idle(); + io_seproxyhal_touch_tx_ok(NULL); + ui_idle(); } static void onConfirmAbandon(void) { - nbgl_useCaseStatus("Transaction rejected", false, reviewReject); + nbgl_useCaseStatus("Transaction rejected", false, reviewReject); } static void rejectTransactionQuestion(void) { - nbgl_useCaseConfirm("Reject transaction?", NULL, "Yes, reject", "Go back to transaction", onConfirmAbandon); + nbgl_useCaseConfirm("Reject transaction?", + NULL, + "Yes, reject", + "Go back to transaction", + onConfirmAbandon); } static void reviewChoice(bool confirm) { - if (confirm) { - nbgl_useCaseStatus("TRANSACTION\nSIGNED", true, confirmTransation); - } else { - rejectTransactionQuestion(); - } + if (confirm) { + nbgl_useCaseStatus("TRANSACTION\nSIGNED", true, confirmTransation); + } else { + rejectTransactionQuestion(); + } } // called by NBGL to get the tag/value pair corresponding to pairIndex -static nbgl_layoutTagValue_t* getTagValuePair(uint8_t pairIndex) { - static int counter = 0; +static nbgl_layoutTagValue_t *getTagValuePair(uint8_t pairIndex) { + static int counter = 0; - if (tx_approval_context.fromPlugin) { - if (pairIndex < dataContext.tokenContext.pluginUiMaxItems) { - // for the next dataContext.tokenContext.pluginUiMaxItems items, get tag/value from plugin_ui_get_item_internal() - dataContext.tokenContext.pluginUiCurrentItem = pairIndex; - plugin_ui_get_item_internal( - (uint8_t *)title_buffer[counter], - TAG_MAX_LEN, - (uint8_t *)msg_buffer[counter], - VALUE_MAX_LEN - ); - tlv.item = title_buffer[counter]; - tlv.value = msg_buffer[counter]; - } - else { - pairIndex -= dataContext.tokenContext.pluginUiMaxItems; - // for the last 1 (or 2), tags are fixed - if (tx_approval_context.displayNetwork && (pairIndex == 0)) { - tlv.item = "Network"; - tlv.value = strings.common.network_name; - } - else { - tlv.item = "Max fees"; - tlv.value = strings.common.maxFee; - } - } - } else { - // if displayNonce is false, we skip index 2 - if ((pairIndex > 1) && (!N_storage.displayNonce)) { - pairIndex++; - } + if (tx_approval_context.fromPlugin) { + if (pairIndex < dataContext.tokenContext.pluginUiMaxItems) { + // for the next dataContext.tokenContext.pluginUiMaxItems items, get tag/value from + // plugin_ui_get_item_internal() + dataContext.tokenContext.pluginUiCurrentItem = pairIndex; + plugin_ui_get_item_internal((uint8_t *) title_buffer[counter], + TAG_MAX_LEN, + (uint8_t *) msg_buffer[counter], + VALUE_MAX_LEN); + tlv.item = title_buffer[counter]; + tlv.value = msg_buffer[counter]; + } else { + pairIndex -= dataContext.tokenContext.pluginUiMaxItems; + // for the last 1 (or 2), tags are fixed + if (tx_approval_context.displayNetwork && (pairIndex == 0)) { + tlv.item = "Network"; + tlv.value = strings.common.network_name; + } else { + tlv.item = "Max fees"; + tlv.value = strings.common.maxFee; + } + } + } else { + // if displayNonce is false, we skip index 2 + if ((pairIndex > 1) && (!N_storage.displayNonce)) { + pairIndex++; + } - switch (pairIndex) { - case 0: - tlv.item = "Amount"; - tlv.value = strings.common.fullAmount; - break; - case 1: - tlv.item = "Address"; - tlv.value = strings.common.fullAddress; - break; - case 2: - tlv.item = "Nonce"; - tlv.value = strings.common.nonce; - break; - case 3: - tlv.item = "Max fees"; - tlv.value = strings.common.maxFee; - break; - case 4: - tlv.item = "Network"; - tlv.value = strings.common.network_name; - break; + switch (pairIndex) { + case 0: + tlv.item = "Amount"; + tlv.value = strings.common.fullAmount; + break; + case 1: + tlv.item = "Address"; + tlv.value = strings.common.fullAddress; + break; + case 2: + tlv.item = "Nonce"; + tlv.value = strings.common.nonce; + break; + case 3: + tlv.item = "Max fees"; + tlv.value = strings.common.maxFee; + break; + case 4: + tlv.item = "Network"; + tlv.value = strings.common.network_name; + break; + } } - } - // counter is used as index to circular buffer - counter++; - if (counter == MAX_PLUGIN_ITEMS_PER_SCREEN) { - counter = 0; - } - return &tlv; + // counter is used as index to circular buffer + counter++; + if (counter == MAX_PLUGIN_ITEMS_PER_SCREEN) { + counter = 0; + } + return &tlv; } static void pageCallback(int token, uint8_t index) { - (void)index; - nbgl_pageRelease(pageContext); - if (token == REJECT_TOKEN) { - reviewReject(); - } - else if (token == START_REVIEW_TOKEN) { - reviewContinueCommon(); - } + (void) index; + nbgl_pageRelease(pageContext); + if (token == REJECT_TOKEN) { + reviewReject(); + } else if (token == START_REVIEW_TOKEN) { + reviewContinueCommon(); + } } static void reviewContinue(void) { - if (tx_approval_context.blindSigning) { - nbgl_pageInfoDescription_t info = { - .centeredInfo.icon = &C_round_warning_64px, - .centeredInfo.text1 = "Blind Signing", - .centeredInfo.text2 = "This transaction cannot be\nsecurely interpreted by Ledger\nStax. It might put your assets\nat risk.", - .centeredInfo.text3 = NULL, - .centeredInfo.style = LARGE_CASE_INFO, - .centeredInfo.offsetY = -32, - .footerText = "Reject transaction", - .footerToken = REJECT_TOKEN, - .tapActionText = "Tap to continue", - .tapActionToken = START_REVIEW_TOKEN, - .topRightStyle = NO_BUTTON_STYLE, - .actionButtonText = NULL, - .tuneId = TUNE_TAP_CASUAL - }; + if (tx_approval_context.blindSigning) { + nbgl_pageInfoDescription_t info = { + .centeredInfo.icon = &C_round_warning_64px, + .centeredInfo.text1 = "Blind Signing", + .centeredInfo.text2 = + "This transaction cannot be\nsecurely interpreted by Ledger\nStax. It might put " + "your assets\nat risk.", + .centeredInfo.text3 = NULL, + .centeredInfo.style = LARGE_CASE_INFO, + .centeredInfo.offsetY = -32, + .footerText = "Reject transaction", + .footerToken = REJECT_TOKEN, + .tapActionText = "Tap to continue", + .tapActionToken = START_REVIEW_TOKEN, + .topRightStyle = NO_BUTTON_STYLE, + .actionButtonText = NULL, + .tuneId = TUNE_TAP_CASUAL}; - if (pageContext != NULL) { - nbgl_pageRelease(pageContext); - pageContext = NULL; + if (pageContext != NULL) { + nbgl_pageRelease(pageContext); + pageContext = NULL; + } + pageContext = nbgl_pageDrawInfo(&pageCallback, NULL, &info); + } else { + reviewContinueCommon(); } - pageContext = nbgl_pageDrawInfo(&pageCallback, NULL, &info); - } - else { - reviewContinueCommon(); - } } static void reviewContinueCommon(void) { - uint8_t nbPairs = 0; + uint8_t nbPairs = 0; - if (tx_approval_context.fromPlugin) { - // plugin id + max items + fees - nbPairs += dataContext.tokenContext.pluginUiMaxItems + 1; - if (tx_approval_context.displayNetwork) { - nbPairs ++; + if (tx_approval_context.fromPlugin) { + // plugin id + max items + fees + nbPairs += dataContext.tokenContext.pluginUiMaxItems + 1; + if (tx_approval_context.displayNetwork) { + nbPairs++; + } + } else { + nbPairs += 3; + if (N_storage.displayNonce) { + nbPairs++; + } + if (tx_approval_context.displayNetwork) { + nbPairs++; + } } - } else { - nbPairs += 3; - if (N_storage.displayNonce) { - nbPairs ++; - } - if (tx_approval_context.displayNetwork) { - nbPairs ++; - } - } - useCaseTagValueList.pairs = NULL; - useCaseTagValueList.callback = getTagValuePair; - useCaseTagValueList.startIndex = 0; - useCaseTagValueList.nbPairs = nbPairs; ///< number of pairs in pairs array - useCaseTagValueList.smallCaseForValue = false; - useCaseTagValueList.wrapping = false; - infoLongPress.icon = &ICONGLYPH; - infoLongPress.text = tx_approval_context.fromPlugin ? transaction_type : "Review transaction"; - infoLongPress.longPressText = "Hold to sign"; - nbgl_useCaseStaticReview(&useCaseTagValueList, &infoLongPress, "Reject transaction", reviewChoice); + useCaseTagValueList.pairs = NULL; + useCaseTagValueList.callback = getTagValuePair; + useCaseTagValueList.startIndex = 0; + useCaseTagValueList.nbPairs = nbPairs; ///< number of pairs in pairs array + useCaseTagValueList.smallCaseForValue = false; + useCaseTagValueList.wrapping = false; + infoLongPress.icon = &ICONGLYPH; + infoLongPress.text = tx_approval_context.fromPlugin ? transaction_type : "Review transaction"; + infoLongPress.longPressText = "Hold to sign"; + nbgl_useCaseStaticReview(&useCaseTagValueList, + &infoLongPress, + "Reject transaction", + reviewChoice); } - static void buildFirstPage(void) { - if (tx_approval_context.fromPlugin) { - plugin_ui_get_id(); - SPRINTF(transaction_type, "Review %s\ntransaction:\n%s", strings.common.fullAddress,strings.common.fullAmount); - nbgl_useCaseReviewStart(&ICONGLYPH, transaction_type, NULL, "Reject transaction", reviewContinue, rejectTransactionQuestion); - } else { - nbgl_useCaseReviewStart(&ICONGLYPH, "Review transaction", NULL, "Reject transaction", reviewContinue, rejectTransactionQuestion); - } + if (tx_approval_context.fromPlugin) { + plugin_ui_get_id(); + SPRINTF(transaction_type, + "Review %s\ntransaction:\n%s", + strings.common.fullAddress, + strings.common.fullAmount); + nbgl_useCaseReviewStart(&ICONGLYPH, + transaction_type, + NULL, + "Reject transaction", + reviewContinue, + rejectTransactionQuestion); + } else { + nbgl_useCaseReviewStart(&ICONGLYPH, + "Review transaction", + NULL, + "Reject transaction", + reviewContinue, + rejectTransactionQuestion); + } } void ux_approve_tx(bool fromPlugin) { - tx_approval_context.blindSigning = !fromPlugin && tmpContent.txContent.dataPresent && !N_storage.contractDetails; - tx_approval_context.fromPlugin = fromPlugin; - tx_approval_context.displayNetwork = false; + tx_approval_context.blindSigning = + !fromPlugin && tmpContent.txContent.dataPresent && !N_storage.contractDetails; + tx_approval_context.fromPlugin = fromPlugin; + tx_approval_context.displayNetwork = false; - uint64_t chain_id = get_tx_chain_id(); - if (chainConfig->chainId == ETHEREUM_MAINNET_CHAINID && chain_id != chainConfig->chainId) { - tx_approval_context.displayNetwork = true; - } + uint64_t chain_id = get_tx_chain_id(); + if (chainConfig->chainId == ETHEREUM_MAINNET_CHAINID && chain_id != chainConfig->chainId) { + tx_approval_context.displayNetwork = true; + } - buildFirstPage(); + buildFirstPage(); } diff --git a/src_nbgl/ui_confirm_parameter.c b/src_nbgl/ui_confirm_parameter.c index 62eb2f02..3ac99d5e 100644 --- a/src_nbgl/ui_confirm_parameter.c +++ b/src_nbgl/ui_confirm_parameter.c @@ -4,52 +4,53 @@ static nbgl_layoutTagValue_t tlv; static void reviewReject(void) { - io_seproxyhal_touch_data_cancel(NULL); - ui_idle(); + io_seproxyhal_touch_data_cancel(NULL); + ui_idle(); } static void confirmTransation(void) { - io_seproxyhal_touch_data_ok(NULL); + io_seproxyhal_touch_data_ok(NULL); } static void reviewChoice(bool confirm) { - if (confirm) { - confirmTransation(); - } else { - reviewReject(); - } + if (confirm) { + confirmTransation(); + } else { + reviewReject(); + } } static bool displayTransactionPage(uint8_t page, nbgl_pageContent_t *content) { - if (page == 0) { - tlv.item = "Parameter"; - tlv.value = strings.tmp.tmp; - content->type = TAG_VALUE_LIST; - content->tagValueList.nbPairs = 1; - content->tagValueList.pairs = (nbgl_layoutTagValue_t *)&tlv; - } - else if (page == 1) { - content->type = INFO_LONG_PRESS, - content->infoLongPress.icon = &ICONGLYPH; - content->infoLongPress.text = "Confirm parameter"; - content->infoLongPress.longPressText = "Hold to confirm"; - } - else { - return false; - } - // valid page so return true - return true; + if (page == 0) { + tlv.item = "Parameter"; + tlv.value = strings.tmp.tmp; + content->type = TAG_VALUE_LIST; + content->tagValueList.nbPairs = 1; + content->tagValueList.pairs = (nbgl_layoutTagValue_t *) &tlv; + } else if (page == 1) { + content->type = INFO_LONG_PRESS, content->infoLongPress.icon = &ICONGLYPH; + content->infoLongPress.text = "Confirm parameter"; + content->infoLongPress.longPressText = "Hold to confirm"; + } else { + return false; + } + // valid page so return true + return true; } - static void reviewContinue(void) { - nbgl_useCaseRegularReview(0, 2, "Reject parameter", NULL, displayTransactionPage, reviewChoice); + nbgl_useCaseRegularReview(0, 2, "Reject parameter", NULL, displayTransactionPage, reviewChoice); } static void buildScreen(void) { - nbgl_useCaseReviewStart(&ICONGLYPH, "Verify parameter", NULL, "Reject", reviewContinue, reviewReject); + nbgl_useCaseReviewStart(&ICONGLYPH, + "Verify parameter", + NULL, + "Reject", + reviewContinue, + reviewReject); } void ui_confirm_parameter(void) { - buildScreen(); + buildScreen(); } diff --git a/src_nbgl/ui_confirm_selector.c b/src_nbgl/ui_confirm_selector.c index 30e3ab8b..dbff6adb 100644 --- a/src_nbgl/ui_confirm_selector.c +++ b/src_nbgl/ui_confirm_selector.c @@ -4,52 +4,53 @@ static nbgl_layoutTagValue_t tlv; static void reviewReject(void) { - io_seproxyhal_touch_data_cancel(NULL); - ui_idle(); + io_seproxyhal_touch_data_cancel(NULL); + ui_idle(); } static void confirmTransation(void) { - io_seproxyhal_touch_data_ok(NULL); + io_seproxyhal_touch_data_ok(NULL); } static void reviewChoice(bool confirm) { - if (confirm) { - confirmTransation(); - } else { - reviewReject(); - } + if (confirm) { + confirmTransation(); + } else { + reviewReject(); + } } static bool displayTransactionPage(uint8_t page, nbgl_pageContent_t *content) { - if (page == 0) { - tlv.item = "Parameter"; - tlv.value = strings.tmp.tmp; - content->type = TAG_VALUE_LIST; - content->tagValueList.nbPairs = 1; - content->tagValueList.pairs = (nbgl_layoutTagValue_t *)&tlv; - } - else if (page == 1) { - content->type = INFO_LONG_PRESS, - content->infoLongPress.icon = &ICONGLYPH; - content->infoLongPress.text = "Confirm selector"; - content->infoLongPress.longPressText = "Hold to confirm"; - } - else { - return false; - } - // valid page so return true - return true; + if (page == 0) { + tlv.item = "Parameter"; + tlv.value = strings.tmp.tmp; + content->type = TAG_VALUE_LIST; + content->tagValueList.nbPairs = 1; + content->tagValueList.pairs = (nbgl_layoutTagValue_t *) &tlv; + } else if (page == 1) { + content->type = INFO_LONG_PRESS, content->infoLongPress.icon = &ICONGLYPH; + content->infoLongPress.text = "Confirm selector"; + content->infoLongPress.longPressText = "Hold to confirm"; + } else { + return false; + } + // valid page so return true + return true; } - static void reviewContinue(void) { - nbgl_useCaseRegularReview(0, 2, "Reject selector", NULL, displayTransactionPage, reviewChoice); + nbgl_useCaseRegularReview(0, 2, "Reject selector", NULL, displayTransactionPage, reviewChoice); } static void buildScreen(void) { - nbgl_useCaseReviewStart(&ICONGLYPH, "Verify selector", NULL, "Reject", reviewContinue, reviewReject); + nbgl_useCaseReviewStart(&ICONGLYPH, + "Verify selector", + NULL, + "Reject", + reviewContinue, + reviewReject); } void ui_confirm_selector(void) { - buildScreen(); + buildScreen(); } diff --git a/src_nbgl/ui_display_privacy.c b/src_nbgl/ui_display_privacy.c index 8433e28c..6114b4c8 100644 --- a/src_nbgl/ui_display_privacy.c +++ b/src_nbgl/ui_display_privacy.c @@ -4,65 +4,66 @@ #include "nbgl_use_case.h" static nbgl_layoutTagValue_t tlv[2]; -static char* review_string; +static char *review_string; static void reviewReject(void) { - io_seproxyhal_touch_privacy_cancel(NULL); - ui_idle(); + io_seproxyhal_touch_privacy_cancel(NULL); + ui_idle(); } static void confirmTransation(void) { - io_seproxyhal_touch_privacy_ok(NULL); - ui_idle(); + io_seproxyhal_touch_privacy_ok(NULL); + ui_idle(); } static void reviewChoice(bool confirm) { - if (confirm) { - confirmTransation(); - } else { - reviewReject(); - } + if (confirm) { + confirmTransation(); + } else { + reviewReject(); + } } static bool displayTransactionPage(uint8_t page, nbgl_pageContent_t *content) { - if (page == 0) { - tlv[0].item = "Address"; - tlv[0].value = strings.common.fullAddress; - tlv[1].item = "Key"; - tlv[1].value = strings.common.fullAmount; + if (page == 0) { + tlv[0].item = "Address"; + tlv[0].value = strings.common.fullAddress; + tlv[1].item = "Key"; + tlv[1].value = strings.common.fullAmount; - content->type = TAG_VALUE_LIST; - content->tagValueList.nbPairs = 2; - content->tagValueList.pairs = (nbgl_layoutTagValue_t *)tlv; - } - else if (page == 1) { - content->type = INFO_LONG_PRESS, - content->infoLongPress.icon = &ICONGLYPH; - content->infoLongPress.text = review_string; - content->infoLongPress.longPressText = "Hold to approve"; - } - else { - return false; - } - // valid page so return true - return true; + content->type = TAG_VALUE_LIST; + content->tagValueList.nbPairs = 2; + content->tagValueList.pairs = (nbgl_layoutTagValue_t *) tlv; + } else if (page == 1) { + content->type = INFO_LONG_PRESS, content->infoLongPress.icon = &ICONGLYPH; + content->infoLongPress.text = review_string; + content->infoLongPress.longPressText = "Hold to approve"; + } else { + return false; + } + // valid page so return true + return true; } static void reviewContinue(void) { - nbgl_useCaseRegularReview(0, 2, "Reject", NULL, displayTransactionPage, reviewChoice); + nbgl_useCaseRegularReview(0, 2, "Reject", NULL, displayTransactionPage, reviewChoice); } static void buildFirstPage(void) { - nbgl_useCaseReviewStart(&ICONGLYPH, review_string, NULL, "Reject", reviewContinue, reviewReject); + nbgl_useCaseReviewStart(&ICONGLYPH, + review_string, + NULL, + "Reject", + reviewContinue, + reviewReject); } void ui_display_privacy_public_key(void) { - review_string = "Provide public\nprivacy key"; - buildFirstPage(); + review_string = "Provide public\nprivacy key"; + buildFirstPage(); } void ui_display_privacy_shared_secret(void) { - review_string = "Provide public\nsecret key"; - buildFirstPage(); + review_string = "Provide public\nsecret key"; + buildFirstPage(); } - diff --git a/src_nbgl/ui_get_eth2_public_key.c b/src_nbgl/ui_get_eth2_public_key.c index b6f98236..204f3a61 100644 --- a/src_nbgl/ui_get_eth2_public_key.c +++ b/src_nbgl/ui_get_eth2_public_key.c @@ -4,30 +4,29 @@ #include "ui_nbgl.h" static void reviewReject(void) { - io_seproxyhal_touch_address_cancel(NULL); - ui_idle(); + io_seproxyhal_touch_address_cancel(NULL); + ui_idle(); } static void confirmTransation(void) { - io_seproxyhal_touch_address_ok(NULL); - ui_idle(); + io_seproxyhal_touch_address_ok(NULL); + ui_idle(); } static void reviewChoice(bool confirm) { - if (confirm) { - // display a status page and go back to main - nbgl_useCaseStatus("ADDRESS\nVERIFIED",true,confirmTransation); - } - else { - nbgl_useCaseStatus("Address verification\ncancelled",false,reviewReject); - } + if (confirm) { + // display a status page and go back to main + nbgl_useCaseStatus("ADDRESS\nVERIFIED", true, confirmTransation); + } else { + nbgl_useCaseStatus("Address verification\ncancelled", false, reviewReject); + } } static void buildScreen(void) { - snprintf(strings.tmp.tmp, 100, "0x%.*H", 48, tmpCtx.publicKeyContext.publicKey.W); - nbgl_useCaseAddressConfirmation(strings.tmp.tmp, reviewChoice); + snprintf(strings.tmp.tmp, 100, "0x%.*H", 48, tmpCtx.publicKeyContext.publicKey.W); + nbgl_useCaseAddressConfirmation(strings.tmp.tmp, reviewChoice); } void ui_display_public_eth2(void) { - buildScreen(); + buildScreen(); } \ No newline at end of file diff --git a/src_nbgl/ui_get_public_key.c b/src_nbgl/ui_get_public_key.c index 8ad9a599..1f994d85 100644 --- a/src_nbgl/ui_get_public_key.c +++ b/src_nbgl/ui_get_public_key.c @@ -4,28 +4,27 @@ #include "ui_nbgl.h" static void reviewReject(void) { - io_seproxyhal_touch_address_cancel(NULL); - ui_idle(); + io_seproxyhal_touch_address_cancel(NULL); + ui_idle(); } static void confirmTransation(void) { - io_seproxyhal_touch_address_ok(NULL); - ui_idle(); + io_seproxyhal_touch_address_ok(NULL); + ui_idle(); } static void reviewChoice(bool confirm) { - if (confirm) { - // display a status page and go back to main - nbgl_useCaseStatus("ADDRESS\nVERIFIED",true,confirmTransation); - } - else { - nbgl_useCaseStatus("Address verification\ncancelled",false,reviewReject); - } + if (confirm) { + // display a status page and go back to main + nbgl_useCaseStatus("ADDRESS\nVERIFIED", true, confirmTransation); + } else { + nbgl_useCaseStatus("Address verification\ncancelled", false, reviewReject); + } } static void buildScreen(void) { - nbgl_useCaseAddressConfirmation(strings.common.fullAddress, reviewChoice); + nbgl_useCaseAddressConfirmation(strings.common.fullAddress, reviewChoice); } void ui_display_public_key(void) { - buildScreen(); + buildScreen(); } \ No newline at end of file diff --git a/src_nbgl/ui_get_stark_public_key.c b/src_nbgl/ui_get_stark_public_key.c index 66ba855b..d26e9de3 100644 --- a/src_nbgl/ui_get_stark_public_key.c +++ b/src_nbgl/ui_get_stark_public_key.c @@ -4,29 +4,28 @@ #include "ui_nbgl.h" static void reviewReject(void) { - io_seproxyhal_touch_address_cancel(NULL); - ui_idle(); + io_seproxyhal_touch_address_cancel(NULL); + ui_idle(); } static void confirmTransation(void) { - io_seproxyhal_touch_stark_pubkey_ok(NULL); - ui_idle(); + io_seproxyhal_touch_stark_pubkey_ok(NULL); + ui_idle(); } static void reviewChoice(bool confirm) { - if (confirm) { - // display a status page and go back to main - nbgl_useCaseStatus("ADDRESS\nVERIFIED",true,confirmTransation); - } - else { - nbgl_useCaseStatus("Address verification\ncancelled",false,reviewReject); - } + if (confirm) { + // display a status page and go back to main + nbgl_useCaseStatus("ADDRESS\nVERIFIED", true, confirmTransation); + } else { + nbgl_useCaseStatus("Address verification\ncancelled", false, reviewReject); + } } static void buildScreen(void) { - nbgl_useCaseAddressConfirmation(strings.tmp.tmp, reviewChoice); + nbgl_useCaseAddressConfirmation(strings.tmp.tmp, reviewChoice); } void ui_display_stark_public(void) { - buildScreen(); + buildScreen(); } \ No newline at end of file diff --git a/src_nbgl/ui_idle.c b/src_nbgl/ui_idle.c index 13402d8d..b1ff436e 100644 --- a/src_nbgl/ui_idle.c +++ b/src_nbgl/ui_idle.c @@ -20,7 +20,7 @@ void app_quit(void) { } void ui_idle(void) { - char *app_name = (char*)get_app_network_name(); + char* app_name = (char*) get_app_network_name(); // In case a new clone is ran with an older ethereum app (unknown chain ID) if (app_name == NULL) { diff --git a/src_nbgl/ui_nbgl.h b/src_nbgl/ui_nbgl.h index 3a9a3eac..ed1217ad 100644 --- a/src_nbgl/ui_nbgl.h +++ b/src_nbgl/ui_nbgl.h @@ -12,4 +12,4 @@ void ui_idle(void); void ui_menu_settings(void); void ui_menu_about(void); -#endif // _UI_NBGL_H_ \ No newline at end of file +#endif // _UI_NBGL_H_ \ No newline at end of file diff --git a/src_nbgl/ui_settings.c b/src_nbgl/ui_settings.c index 8e35f031..9c2d8efe 100644 --- a/src_nbgl/ui_settings.c +++ b/src_nbgl/ui_settings.c @@ -5,98 +5,88 @@ static const char* const infoTypes[] = {"Version", "Ethereum App"}; static const char* const infoContents[] = {APPVERSION, "(c) 2022 Ledger"}; -enum { - BLIND_SIGNING_TOKEN = FIRST_USER_TOKEN, - DEBUG_TOKEN, - NONCE_TOKEN, - EIP712_VERBOSE_TOKEN -}; +enum { BLIND_SIGNING_TOKEN = FIRST_USER_TOKEN, DEBUG_TOKEN, NONCE_TOKEN, EIP712_VERBOSE_TOKEN }; static nbgl_layoutSwitch_t switches[4]; static bool navCallback(uint8_t page, nbgl_pageContent_t* content) { - switch (page) - { - case 0: - switches[0] = (nbgl_layoutSwitch_t) { - .initState = N_storage.dataAllowed ? ON_STATE : OFF_STATE, - .text = "Blind signing", - .subText = "Enable transaction blind signing", - .token = BLIND_SIGNING_TOKEN, - .tuneId = TUNE_TAP_CASUAL - }; - switches[1] = (nbgl_layoutSwitch_t) { - .initState = N_storage.contractDetails ? ON_STATE : OFF_STATE, - .text = "Debug", - .subText = "Display contract data details", - .token = DEBUG_TOKEN, - .tuneId = TUNE_TAP_CASUAL - }; - switches[2] = (nbgl_layoutSwitch_t) { - .initState = N_storage.displayNonce ? ON_STATE : OFF_STATE, - .text = "Nonce", - .subText = "Display account nonce\nin transaction", - .token = NONCE_TOKEN, - .tuneId = TUNE_TAP_CASUAL - }; + switch (page) { + case 0: + switches[0] = + (nbgl_layoutSwitch_t){.initState = N_storage.dataAllowed ? ON_STATE : OFF_STATE, + .text = "Blind signing", + .subText = "Enable transaction blind signing", + .token = BLIND_SIGNING_TOKEN, + .tuneId = TUNE_TAP_CASUAL}; + switches[1] = + (nbgl_layoutSwitch_t){.initState = N_storage.contractDetails ? ON_STATE : OFF_STATE, + .text = "Debug", + .subText = "Display contract data details", + .token = DEBUG_TOKEN, + .tuneId = TUNE_TAP_CASUAL}; + switches[2] = + (nbgl_layoutSwitch_t){.initState = N_storage.displayNonce ? ON_STATE : OFF_STATE, + .text = "Nonce", + .subText = "Display account nonce\nin transaction", + .token = NONCE_TOKEN, + .tuneId = TUNE_TAP_CASUAL}; - content->type = SWITCHES_LIST; - content->switchesList.nbSwitches = 3; - content->switchesList.switches = (nbgl_layoutSwitch_t*)switches; - break; + content->type = SWITCHES_LIST; + content->switchesList.nbSwitches = 3; + content->switchesList.switches = (nbgl_layoutSwitch_t*) switches; + break; - case 1: - switches[0] = (nbgl_layoutSwitch_t) { - .initState = N_storage.verbose_eip712 ? ON_STATE : OFF_STATE, - .text = "Verbose EIP712", - .subText = "Ignore filtering and\ndisplay raw content", - .token = EIP712_VERBOSE_TOKEN, - .tuneId = TUNE_TAP_CASUAL - }; + case 1: + switches[0] = + (nbgl_layoutSwitch_t){.initState = N_storage.verbose_eip712 ? ON_STATE : OFF_STATE, + .text = "Verbose EIP712", + .subText = "Ignore filtering and\ndisplay raw content", + .token = EIP712_VERBOSE_TOKEN, + .tuneId = TUNE_TAP_CASUAL}; - content->type = SWITCHES_LIST; - content->switchesList.nbSwitches = 1; - content->switchesList.switches = (nbgl_layoutSwitch_t*)switches; - break; + content->type = SWITCHES_LIST; + content->switchesList.nbSwitches = 1; + content->switchesList.switches = (nbgl_layoutSwitch_t*) switches; + break; - case 2: - content->type = INFOS_LIST; - content->infosList.nbInfos = 2; - content->infosList.infoTypes = (const char**) infoTypes; - content->infosList.infoContents = (const char**) infoContents; - break; + case 2: + content->type = INFOS_LIST; + content->infosList.nbInfos = 2; + content->infosList.infoTypes = (const char**) infoTypes; + content->infosList.infoContents = (const char**) infoContents; + break; - default: - return false; - break; - } + default: + return false; + break; + } - return true; + return true; } static void controlsCallback(int token, uint8_t index) { - (void) index; - uint8_t value; - switch (token) { - case BLIND_SIGNING_TOKEN: - value = (N_storage.dataAllowed ? 0 : 1); - nvm_write((void*) &N_storage.dataAllowed, (void*) &value, sizeof(uint8_t)); - break; - case DEBUG_TOKEN: - value = (N_storage.contractDetails ? 0 : 1); - nvm_write((void*) &N_storage.contractDetails, (void*) &value, sizeof(uint8_t)); - break; - case NONCE_TOKEN: - value = (N_storage.displayNonce ? 0 : 1); - nvm_write((void*) &N_storage.displayNonce, (void*) &value, sizeof(uint8_t)); - break; - case EIP712_VERBOSE_TOKEN: - value = (N_storage.verbose_eip712 ? 0 : 1); - nvm_write((void*) &N_storage.verbose_eip712, (void*) &value, sizeof(uint8_t)); - break; - } + (void) index; + uint8_t value; + switch (token) { + case BLIND_SIGNING_TOKEN: + value = (N_storage.dataAllowed ? 0 : 1); + nvm_write((void*) &N_storage.dataAllowed, (void*) &value, sizeof(uint8_t)); + break; + case DEBUG_TOKEN: + value = (N_storage.contractDetails ? 0 : 1); + nvm_write((void*) &N_storage.contractDetails, (void*) &value, sizeof(uint8_t)); + break; + case NONCE_TOKEN: + value = (N_storage.displayNonce ? 0 : 1); + nvm_write((void*) &N_storage.displayNonce, (void*) &value, sizeof(uint8_t)); + break; + case EIP712_VERBOSE_TOKEN: + value = (N_storage.verbose_eip712 ? 0 : 1); + nvm_write((void*) &N_storage.verbose_eip712, (void*) &value, sizeof(uint8_t)); + break; + } } void ui_menu_settings(void) { - nbgl_useCaseSettings("Ethereum settings", 0, 3, true, ui_idle, navCallback, controlsCallback); + nbgl_useCaseSettings("Ethereum settings", 0, 3, true, ui_idle, navCallback, controlsCallback); } diff --git a/src_nbgl/ui_sign_712.c b/src_nbgl/ui_sign_712.c index c936ff99..dfffa9ad 100644 --- a/src_nbgl/ui_sign_712.c +++ b/src_nbgl/ui_sign_712.c @@ -8,58 +8,57 @@ static nbgl_layoutTagValue_t tlv; static void reject_message(void) { - ui_712_reject(NULL); + ui_712_reject(NULL); } static void sign_message() { - ui_712_approve(NULL); + ui_712_approve(NULL); } static void reviewChoice(bool confirm) { - if (confirm) { - sign_message(); - } else { - reject_message(); - } + if (confirm) { + sign_message(); + } else { + reject_message(); + } } static bool displaySignPage(uint8_t page, nbgl_pageContent_t *content) { - content->type = INFO_LONG_PRESS, - content->infoLongPress.icon = &ICONGLYPH; - content->infoLongPress.text = "Sign typed message"; - content->infoLongPress.longPressText = "Hold to sign"; - return true; + content->type = INFO_LONG_PRESS, content->infoLongPress.icon = &ICONGLYPH; + content->infoLongPress.text = "Sign typed message"; + content->infoLongPress.longPressText = "Hold to sign"; + return true; } static bool displayTransactionPage(uint8_t page, nbgl_pageContent_t *content) { - if (page == 0) { - tlv.item = strings.tmp.tmp2; - tlv.value = strings.tmp.tmp; - content->type = TAG_VALUE_LIST; - content->tagValueList.nbPairs = 1; - content->tagValueList.pairs = &tlv; - return true; - } else { - switch (ui_712_next_field()) { - case EIP712_NO_MORE_FIELD: - return displaySignPage(page, content); - break; - case EIP712_FIELD_INCOMING: - case EIP712_FIELD_LATER: - default: - break; + if (page == 0) { + tlv.item = strings.tmp.tmp2; + tlv.value = strings.tmp.tmp; + content->type = TAG_VALUE_LIST; + content->tagValueList.nbPairs = 1; + content->tagValueList.pairs = &tlv; + return true; + } else { + switch (ui_712_next_field()) { + case EIP712_NO_MORE_FIELD: + return displaySignPage(page, content); + break; + case EIP712_FIELD_INCOMING: + case EIP712_FIELD_LATER: + default: + break; + } + return false; } - return false; - } } void ui_712_switch_to_sign(void) { - nbgl_useCaseRegularReview(0, 0, "Reject", NULL, displaySignPage, reviewChoice); + nbgl_useCaseRegularReview(0, 0, "Reject", NULL, displaySignPage, reviewChoice); } void ui_712_start(void) { - nbgl_useCaseRegularReview(0, 0, "Reject", NULL, displayTransactionPage, reviewChoice); + nbgl_useCaseRegularReview(0, 0, "Reject", NULL, displayTransactionPage, reviewChoice); } void ui_712_switch_to_message(void) { - nbgl_useCaseRegularReview(0, 0, "Reject", NULL, displayTransactionPage, reviewChoice); + nbgl_useCaseRegularReview(0, 0, "Reject", NULL, displayTransactionPage, reviewChoice); } diff --git a/src_nbgl/ui_sign_712_v0.c b/src_nbgl/ui_sign_712_v0.c index 5bc32e57..d74d37f7 100644 --- a/src_nbgl/ui_sign_712_v0.c +++ b/src_nbgl/ui_sign_712_v0.c @@ -8,60 +8,60 @@ static char domain_hash[70]; static char message_hash[70]; static void reviewReject(void) { - ui_712_approve_cb(NULL); - ui_idle(); + ui_712_approve_cb(NULL); + ui_idle(); } static void confirmTransation(void) { - ui_712_reject_cb(NULL); - ui_idle(); + ui_712_reject_cb(NULL); + ui_idle(); } static void reviewChoice(bool confirm) { - if (confirm) { - // display a status page and go back to main - nbgl_useCaseStatus("MESSAGE\nSIGNED",true,confirmTransation); - } - else { - nbgl_useCaseStatus("Message signing\ncancelled",false,reviewReject); - } + if (confirm) { + // display a status page and go back to main + nbgl_useCaseStatus("MESSAGE\nSIGNED", true, confirmTransation); + } else { + nbgl_useCaseStatus("Message signing\ncancelled", false, reviewReject); + } } static bool displayTransactionPage(uint8_t page, nbgl_pageContent_t *content) { - snprintf(domain_hash, 70, "0x%.*H", 32, tmpCtx.messageSigningContext712.domainHash); - snprintf(message_hash, 70, "0x%.*H", 32, tmpCtx.messageSigningContext712.messageHash); + snprintf(domain_hash, 70, "0x%.*H", 32, tmpCtx.messageSigningContext712.domainHash); + snprintf(message_hash, 70, "0x%.*H", 32, tmpCtx.messageSigningContext712.messageHash); - if (page == 0) { - tlv[0].item = "Domain hash"; - tlv[0].value = domain_hash; - tlv[1].item = "Message hash"; - tlv[1].value = message_hash; + if (page == 0) { + tlv[0].item = "Domain hash"; + tlv[0].value = domain_hash; + tlv[1].item = "Message hash"; + tlv[1].value = message_hash; - content->type = TAG_VALUE_LIST; - content->tagValueList.nbPairs = 2; - content->tagValueList.pairs = (nbgl_layoutTagValue_t *)tlv; - } - else if (page == 1) { - content->type = INFO_LONG_PRESS, - content->infoLongPress.icon = &ICONGLYPH; - content->infoLongPress.text = "Sign typed message"; - content->infoLongPress.longPressText = "Hold to sign"; - } - else { - return false; - } - // valid page so return true - return true; + content->type = TAG_VALUE_LIST; + content->tagValueList.nbPairs = 2; + content->tagValueList.pairs = (nbgl_layoutTagValue_t *) tlv; + } else if (page == 1) { + content->type = INFO_LONG_PRESS, content->infoLongPress.icon = &ICONGLYPH; + content->infoLongPress.text = "Sign typed message"; + content->infoLongPress.longPressText = "Hold to sign"; + } else { + return false; + } + // valid page so return true + return true; } static void reviewContinue(void) { - nbgl_useCaseRegularReview(0, 2, "Reject", NULL, displayTransactionPage, reviewChoice); + nbgl_useCaseRegularReview(0, 2, "Reject", NULL, displayTransactionPage, reviewChoice); } - static void buildFirstPage(void) { - nbgl_useCaseReviewStart(&ICONGLYPH, "Sign typed message", NULL, "Reject", reviewContinue, reviewReject); + nbgl_useCaseReviewStart(&ICONGLYPH, + "Sign typed message", + NULL, + "Reject", + reviewContinue, + reviewReject); } void ui_sign_712_v0(void) { - buildFirstPage(); + buildFirstPage(); } diff --git a/src_nbgl/ui_sign_message.c b/src_nbgl/ui_sign_message.c index e87d07c7..23c6da7a 100644 --- a/src_nbgl/ui_sign_message.c +++ b/src_nbgl/ui_sign_message.c @@ -19,7 +19,7 @@ static e_ui_nbgl_191_state state; static e_ui_nbgl_191_state state_before_reject_cancel; static nbgl_layoutTagValue_t pair; -#define MAX_CHARS_PER_PAGE 128+1 +#define MAX_CHARS_PER_PAGE 128 + 1 static char eip191Message[MAX_CHARS_PER_PAGE] = {0}; static uint32_t eip191MessageIdx = 0; diff --git a/src_nbgl/ui_stark_limit_order.c b/src_nbgl/ui_stark_limit_order.c index 9fe36c72..482aee56 100644 --- a/src_nbgl/ui_stark_limit_order.c +++ b/src_nbgl/ui_stark_limit_order.c @@ -8,60 +8,61 @@ static nbgl_layoutTagValue_t tlv[3]; #ifdef HAVE_STARKWARE static void reviewReject(void) { - io_seproxyhal_touch_tx_cancel(NULL); - ui_idle(); + io_seproxyhal_touch_tx_cancel(NULL); + ui_idle(); } static void confirmTransation(void) { - io_seproxyhal_touch_stark_ok(NULL); - ui_idle(); + io_seproxyhal_touch_stark_ok(NULL); + ui_idle(); } static void reviewChoice(bool confirm) { - if (confirm) { - confirmTransation(); - } else { - reviewReject(); - } + if (confirm) { + confirmTransation(); + } else { + reviewReject(); + } } static bool displayTransactionPage(uint8_t page, nbgl_pageContent_t *content) { - if (page == 0) { - tlv[0].item = "Sell"; - tlv[0].value = strings.common.fullAmount; - tlv[1].item = "Buy"; - tlv[1].value = strings.common.maxFee; - tlv[2].item = "Token amount"; - tlv[2].value = strings.common.fullAddress; + if (page == 0) { + tlv[0].item = "Sell"; + tlv[0].value = strings.common.fullAmount; + tlv[1].item = "Buy"; + tlv[1].value = strings.common.maxFee; + tlv[2].item = "Token amount"; + tlv[2].value = strings.common.fullAddress; - content->type = TAG_VALUE_LIST; - content->tagValueList.nbPairs = 3; - content->tagValueList.pairs = (nbgl_layoutTagValue_t *)tlv; - } - else if (page == 1) { - content->type = INFO_LONG_PRESS, - content->infoLongPress.icon = &ICONGLYPH; - content->infoLongPress.text = "Review stark limit order"; - content->infoLongPress.longPressText = "Hold to sign"; - } - else { - return false; - } - // valid page so return true - return true; + content->type = TAG_VALUE_LIST; + content->tagValueList.nbPairs = 3; + content->tagValueList.pairs = (nbgl_layoutTagValue_t *) tlv; + } else if (page == 1) { + content->type = INFO_LONG_PRESS, content->infoLongPress.icon = &ICONGLYPH; + content->infoLongPress.text = "Review stark limit order"; + content->infoLongPress.longPressText = "Hold to sign"; + } else { + return false; + } + // valid page so return true + return true; } static void reviewContinue(void) { - nbgl_useCaseRegularReview(0, 2, "Reject", NULL, displayTransactionPage, reviewChoice); + nbgl_useCaseRegularReview(0, 2, "Reject", NULL, displayTransactionPage, reviewChoice); } - static void buildFirstPage(void) { - nbgl_useCaseReviewStart(&ICONGLYPH, "Review stark limit order", NULL, "Reject", reviewContinue, reviewReject); + nbgl_useCaseReviewStart(&ICONGLYPH, + "Review stark limit order", + NULL, + "Reject", + reviewContinue, + reviewReject); } void ui_stark_limit_order(void) { - buildFirstPage(); + buildFirstPage(); } #endif \ No newline at end of file diff --git a/src_nbgl/ui_stark_transfer.c b/src_nbgl/ui_stark_transfer.c index 81cba7b4..1ae43aef 100644 --- a/src_nbgl/ui_stark_transfer.c +++ b/src_nbgl/ui_stark_transfer.c @@ -10,111 +10,119 @@ static nbgl_layoutTagValue_t tlv[3]; static char condAddressBuffer[43]; struct stark_transfer_context { - bool selfTransfer; - bool conditional; + bool selfTransfer; + bool conditional; }; static struct stark_transfer_context context; static void reviewReject(void) { - io_seproxyhal_touch_tx_cancel(NULL); - ui_idle(); + io_seproxyhal_touch_tx_cancel(NULL); + ui_idle(); } static void confirmTransation(void) { - io_seproxyhal_touch_stark_ok(NULL); - ui_idle(); + io_seproxyhal_touch_stark_ok(NULL); + ui_idle(); } static void reviewChoice(bool confirm) { - if (confirm) { - confirmTransation(); - } else { - reviewReject(); - } + if (confirm) { + confirmTransation(); + } else { + reviewReject(); + } } - static bool displayTransactionPage(uint8_t page, nbgl_pageContent_t *content) { - uint8_t count = 0; - if (page == 0) { - tlv[count].item = "Amount"; - tlv[count].value = tmpContent.tmp; - count++; + uint8_t count = 0; + if (page == 0) { + tlv[count].item = "Amount"; + tlv[count].value = tmpContent.tmp; + count++; - if (context.selfTransfer == false && context.conditional == false) { - tlv[count].item = "Master Account"; - tlv[count].value = strings.tmp.tmp; - count++; + if (context.selfTransfer == false && context.conditional == false) { + tlv[count].item = "Master Account"; + tlv[count].value = strings.tmp.tmp; + count++; + } + if (context.conditional) { + stark_sign_display_master_account(); + tlv[count].item = "Master Account"; + tlv[count].value = strings.tmp.tmp; + count++; + } + tlv[count].item = "Token Account"; + tlv[count].value = strings.tmp.tmp2; + content->type = TAG_VALUE_LIST; + content->tagValueList.nbPairs = count; + content->tagValueList.pairs = (nbgl_layoutTagValue_t *) tlv; + + return true; } - if (context.conditional) { - stark_sign_display_master_account(); - tlv[count].item = "Master Account"; - tlv[count].value = strings.tmp.tmp; - count++; + if (page == 1) { + if (context.conditional) { + getEthDisplayableAddress(dataContext.starkContext.conditionAddress, + condAddressBuffer, + sizeof(condAddressBuffer), + &global_sha3, + chainConfig->chainId), + tlv[0].item = "Cond. Address"; + tlv[0].value = condAddressBuffer; + + stark_sign_display_condition_fact(); + tlv[1].item = "Cond. Address"; + tlv[1].value = strings.tmp.tmp; + + content->type = TAG_VALUE_LIST; + content->tagValueList.nbPairs = 2; + content->tagValueList.pairs = (nbgl_layoutTagValue_t *) tlv; + + } else { + page++; + } } - tlv[count].item = "Token Account"; - tlv[count].value = strings.tmp.tmp2; - content->type = TAG_VALUE_LIST; - content->tagValueList.nbPairs = count; - content->tagValueList.pairs = (nbgl_layoutTagValue_t *)tlv; - - return true; - } - if (page == 1) { - if (context.conditional) { - getEthDisplayableAddress(dataContext.starkContext.conditionAddress, - condAddressBuffer, - sizeof(condAddressBuffer), - &global_sha3, - chainConfig->chainId), - tlv[0].item = "Cond. Address"; - tlv[0].value = condAddressBuffer; - - stark_sign_display_condition_fact(); - tlv[1].item = "Cond. Address"; - tlv[1].value = strings.tmp.tmp; - - content->type = TAG_VALUE_LIST; - content->tagValueList.nbPairs = 2; - content->tagValueList.pairs = (nbgl_layoutTagValue_t *)tlv; - - } else { - page++; + if (page == 2) { + content->type = INFO_LONG_PRESS, content->infoLongPress.icon = &ICONGLYPH; + content->infoLongPress.text = "Review transaction"; + content->infoLongPress.longPressText = "Hold to sign"; } - } - if (page == 2) { - content->type = INFO_LONG_PRESS, - content->infoLongPress.icon = &ICONGLYPH; - content->infoLongPress.text = "Review transaction"; - content->infoLongPress.longPressText = "Hold to sign"; - } - return false; + return false; } static void reviewContinue(void) { - nbgl_useCaseRegularReview(0, context.conditional ? 3 : 2, "Reject", NULL, displayTransactionPage, reviewChoice); + nbgl_useCaseRegularReview(0, + context.conditional ? 3 : 2, + "Reject", + NULL, + displayTransactionPage, + reviewChoice); } void ui_stark_transfer(bool selfTransfer, bool conditional) { - context.selfTransfer = selfTransfer; - context.conditional = conditional; - char* subTitle; - if (conditional) { - if (selfTransfer) { - subTitle = "Conditionnal self transfer"; + context.selfTransfer = selfTransfer; + context.conditional = conditional; + char *subTitle; + if (conditional) { + if (selfTransfer) { + subTitle = "Conditionnal self transfer"; + } else { + subTitle = "Conditionnal transfer"; + } } else { - subTitle = "Conditionnal transfer"; + if (selfTransfer) { + subTitle = "self transfer"; + } else { + subTitle = "Transfer"; + } } - } else { - if (selfTransfer) { - subTitle = "self transfer"; - } else { - subTitle = "Transfer"; - } - } - nbgl_useCaseReviewStart(&ICONGLYPH, "Review stark transaction", subTitle, "Reject", reviewContinue, reviewReject); + nbgl_useCaseReviewStart(&ICONGLYPH, + "Review stark transaction", + subTitle, + "Reject", + reviewContinue, + reviewReject); } -#endif // #ifdef HAVE_STARKWARE +#endif // #ifdef HAVE_STARKWARE diff --git a/src_nbgl/ui_stark_unsafe_sign.c b/src_nbgl/ui_stark_unsafe_sign.c index 755dc2e4..9a112087 100644 --- a/src_nbgl/ui_stark_unsafe_sign.c +++ b/src_nbgl/ui_stark_unsafe_sign.c @@ -11,59 +11,61 @@ static char from_account[64]; static char message_hash[64]; static void reviewReject(void) { - io_seproxyhal_touch_tx_cancel(NULL); - ui_idle(); + io_seproxyhal_touch_tx_cancel(NULL); + ui_idle(); } static void confirmTransation(void) { - io_seproxyhal_touch_stark_unsafe_sign_ok(NULL); - ui_idle(); + io_seproxyhal_touch_stark_unsafe_sign_ok(NULL); + ui_idle(); } static void reviewChoice(bool confirm) { - if (confirm) { - confirmTransation(); - } else { - reviewReject(); - } + if (confirm) { + confirmTransation(); + } else { + reviewReject(); + } } static bool displayTransactionPage(uint8_t page, nbgl_pageContent_t *content) { - snprintf(from_account, sizeof(from_account), "0x%.*H", 32, dataContext.starkContext.w1); - snprintf(message_hash, sizeof(message_hash), "0x%.*H", 32, dataContext.starkContext.w2); + snprintf(from_account, sizeof(from_account), "0x%.*H", 32, dataContext.starkContext.w1); + snprintf(message_hash, sizeof(message_hash), "0x%.*H", 32, dataContext.starkContext.w2); - if (page == 0) { - tlv[0].item = "From Account"; - tlv[0].value = from_account; - tlv[1].item = "Hash"; - tlv[1].value = message_hash; - content->type = TAG_VALUE_LIST; - content->tagValueList.nbPairs = 2; - content->tagValueList.pairs = (nbgl_layoutTagValue_t *)tlv; - } - else if (page == 1) { - content->type = INFO_LONG_PRESS, - content->infoLongPress.icon = &ICONGLYPH; - content->infoLongPress.text = "Unsafe Stark Sign"; - content->infoLongPress.longPressText = "Hold to sign"; - } - else { - return false; - } - // valid page so return true - return true; + if (page == 0) { + tlv[0].item = "From Account"; + tlv[0].value = from_account; + tlv[1].item = "Hash"; + tlv[1].value = message_hash; + content->type = TAG_VALUE_LIST; + content->tagValueList.nbPairs = 2; + content->tagValueList.pairs = (nbgl_layoutTagValue_t *) tlv; + } else if (page == 1) { + content->type = INFO_LONG_PRESS, content->infoLongPress.icon = &ICONGLYPH; + content->infoLongPress.text = "Unsafe Stark Sign"; + content->infoLongPress.longPressText = "Hold to sign"; + } else { + return false; + } + // valid page so return true + return true; } static void reviewContinue(void) { - nbgl_useCaseRegularReview(0, 2, "Reject", NULL, displayTransactionPage, reviewChoice); + nbgl_useCaseRegularReview(0, 2, "Reject", NULL, displayTransactionPage, reviewChoice); } static void buildFirstPage(void) { - nbgl_useCaseReviewStart(&ICONGLYPH,"Unsafe Stark Sign", NULL, "Reject", reviewContinue, reviewReject); + nbgl_useCaseReviewStart(&ICONGLYPH, + "Unsafe Stark Sign", + NULL, + "Reject", + reviewContinue, + reviewReject); } void ui_stark_unsafe_sign(void) { - buildFirstPage(); + buildFirstPage(); } -#endif // HAVE_STARKWARE \ No newline at end of file +#endif // HAVE_STARKWARE \ No newline at end of file diff --git a/src_nbgl/ui_warning_contract_data.c b/src_nbgl/ui_warning_contract_data.c index 4efac232..2619dce4 100644 --- a/src_nbgl/ui_warning_contract_data.c +++ b/src_nbgl/ui_warning_contract_data.c @@ -4,18 +4,18 @@ #include "ui_nbgl.h" static void ui_warning_contract_data_choice(bool confirm) { - if (confirm) { - ui_idle(); - } else { - ui_menu_settings(); - } + if (confirm) { + ui_idle(); + } else { + ui_menu_settings(); + } } void ui_warning_contract_data(void) { - nbgl_useCaseChoice(&C_warning64px, - "This message cannot\nbe clear-signed", - "Enable blind-signing in\nthe settings to sign\nthis transaction.", - "Exit", - "Go to settings", - ui_warning_contract_data_choice); + nbgl_useCaseChoice(&C_warning64px, + "This message cannot\nbe clear-signed", + "Enable blind-signing in\nthe settings to sign\nthis transaction.", + "Exit", + "Go to settings", + ui_warning_contract_data_choice); }