diff --git a/src/main.c b/src/main.c index ebad4d62..d381fddf 100644 --- a/src/main.c +++ b/src/main.c @@ -264,93 +264,6 @@ unsigned int ui_idle_blue_button(unsigned int button_mask, } #endif // #if TARGET_BLUE -#if defined(TARGET_NANOS) && !defined(HAVE_UX_FLOW) - -const ux_menu_entry_t menu_main[]; -const ux_menu_entry_t menu_settings[]; -const ux_menu_entry_t menu_settings_data[]; -const ux_menu_entry_t menu_settings_custom[]; - -// change the setting -void menu_settings_data_change(unsigned int enabled) { - dataAllowed = enabled; - nvm_write((void *)&N_storage.dataAllowed, (void*)&dataAllowed, sizeof(uint8_t)); - // go back to the menu entry - UX_MENU_DISPLAY(0, menu_settings, NULL); -} - -void menu_settings_custom_change(unsigned int enabled) { - customContract = enabled; - nvm_write((void *)&N_storage.customContract, (void*)&customContract, sizeof(uint8_t)); - // go back to the menu entry - UX_MENU_DISPLAY(0, menu_settings, NULL); -} - -void menu_settings_truncate_change(unsigned int enabled) { - truncateAddress = enabled; - nvm_write((void *)&N_storage.truncateAddress, (void*)&truncateAddress, sizeof(uint8_t)); - // go back to the menu entry - UX_MENU_DISPLAY(0, menu_settings, NULL); -} - -// show the currently activated entry -void menu_settings_data_init(unsigned int ignored) { - UNUSED(ignored); - UX_MENU_DISPLAY(N_storage.dataAllowed?1:0, menu_settings_data, NULL); -} - -void menu_settings_custom_init(unsigned int ignored) { - UNUSED(ignored); - UX_MENU_DISPLAY(N_storage.customContract?1:0, menu_settings_custom, NULL); -} - -void menu_settings_truncate_init(unsigned int ignored) { - UNUSED(ignored); - UX_MENU_DISPLAY(N_storage.truncateAddress?1:0, menu_settings_custom, NULL); -} - -const ux_menu_entry_t menu_settings_data[] = { - {NULL, menu_settings_data_change, 0, NULL, "No", NULL, 0, 0}, - {NULL, menu_settings_data_change, 1, NULL, "Yes", NULL, 0, 0}, - UX_MENU_END -}; - -const ux_menu_entry_t menu_settings_custom[] = { - {NULL, menu_settings_custom_change, 0, NULL, "No", NULL, 0, 0}, - {NULL, menu_settings_custom_change, 1, NULL, "Yes", NULL, 0, 0}, - UX_MENU_END -}; - -const ux_menu_entry_t menu_settings_truncate[] = { - {NULL, menu_settings_truncate_change, 0, NULL, "No", NULL, 0, 0}, - {NULL, menu_settings_truncate_change, 1, NULL, "Yes", NULL, 0, 0}, - UX_MENU_END -}; - -// Menu Settings -const ux_menu_entry_t menu_settings[] = { - {NULL, menu_settings_data_init, 0, NULL, "Allow data", NULL, 0, 0}, - {NULL, menu_settings_custom_init, 0, NULL, "Custom Contracts", NULL, 0, 0}, - {NULL, menu_settings_truncate_init, 0, NULL, "Truncate Address", NULL, 0, 0}, - {menu_main, NULL, 0, &C_icon_back, "Back", NULL, 61, 40}, - UX_MENU_END}; - -// Menu About -const ux_menu_entry_t menu_about[] = { - {NULL, NULL, 0, NULL, "Version", APPVERSION, 0, 0}, - {menu_main, NULL, 2, &C_icon_back, "Back", NULL, 61, 40}, - UX_MENU_END}; - -// Main menu -const ux_menu_entry_t menu_main[] = { - {NULL, NULL, 0, &C_icon, "Use wallet to", "view accounts", 33, 12}, - {menu_settings, NULL, 0, NULL, "Settings", NULL, 0, 0}, - {menu_about, NULL, 0, NULL, "About", NULL, 0, 0}, - {NULL, (ux_menu_callback_t)os_sched_exit, 0, &C_icon_dashboard, "Quit app", NULL, 50, 29}, - UX_MENU_END}; - -#endif // #if TARGET_NANOS && !defined(HAVE_UX_FLOW) - #if defined(TARGET_BLUE) const bagl_element_t * ui_settings_blue_toggle_data(const bagl_element_t * e) { // swap setting and request redraw of settings elements @@ -598,103 +511,6 @@ unsigned int ui_address_blue_button(unsigned int button_mask, } #endif // #if defined(TARGET_BLUE) -#if defined(TARGET_NANOS) && !defined(HAVE_UX_FLOW) -const bagl_element_t ui_address_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}, - - //{{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, 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}, - "address", - 0, - 0, - 0, - NULL, - NULL, - NULL}, - - {{BAGL_LABELINE, 0x02, 0, 12, 128, 32, 0, 0, 0, 0xFFFFFF, 0x000000, - BAGL_FONT_OPEN_SANS_REGULAR_11px | BAGL_FONT_ALIGNMENT_CENTER, 0}, - "Address", - 0, - 0, - 0, - NULL, - NULL, - NULL}, - {{BAGL_LABELINE, 0x02, 23, 26, 82, 12, 0x80 | 10, 0, 0, 0xFFFFFF, 0x000000, - BAGL_FONT_OPEN_SANS_EXTRABOLD_11px | BAGL_FONT_ALIGNMENT_CENTER, 26}, - (char *)toAddress, - 0, - 0, - 0, - NULL, - NULL, - NULL}, -}; - -unsigned int ui_address_prepro(const bagl_element_t *element) { - if (element->component.userid > 0) { - unsigned int display = (ux_step == element->component.userid - 1); - if (display) { - switch (element->component.userid) { - case 1: - UX_CALLBACK_SET_INTERVAL(2000); - break; - case 2: - UX_CALLBACK_SET_INTERVAL(MAX( - 3000, 1000 + bagl_label_roundtrip_duration_ms(element, 7))); - break; - } - } - return display; - } - return 1; -} - -unsigned int ui_address_nanos_button(unsigned int button_mask, - unsigned int button_mask_counter); -#endif // #if defined(TARGET_NANOS) && !defined(HAVE_UX_FLOW) #if defined(TARGET_BLUE) // reuse addressSummary for each line content @@ -1681,1666 +1497,82 @@ void ui_approval_exchange_create_blue_init(void) { ui_approval_blue_values[0] = (const char*)fullContract; ui_approval_blue_values[1] = (const char*)G_io_apdu_buffer; ui_approval_blue_values[2] = (const char*)toAddress; - ui_approval_blue_values[3] = (const char*)G_io_apdu_buffer+100; - ui_approval_blue_values[4] = (const char*)fromAddress; - - ui_approval_blue_init(); -} - -void ui_approval_message_sign_blue_init(void) { - // wipe all cases - os_memset(ui_approval_blue_values, 0, sizeof(ui_approval_blue_values)); - ui_approval_blue_ok = (bagl_element_callback_t)io_seproxyhal_touch_signMessage_ok; - ui_approval_blue_cancel = - (bagl_element_callback_t)io_seproxyhal_touch_cancel; - ui_approval_blue_values[0] = (const char*)fullContract; - ui_approval_blue_values[1] = (const char*)fromAddress; - - ui_approval_blue_init(); -} - -void ui_approval_custom_contract_blue_init(void) { - // wipe all cases - os_memset(ui_approval_blue_values, 0, sizeof(ui_approval_blue_values)); - ui_approval_blue_ok = (bagl_element_callback_t)io_seproxyhal_touch_tx_ok; - ui_approval_blue_cancel = - (bagl_element_callback_t)io_seproxyhal_touch_cancel; - ui_approval_blue_values[0] = (const char*)TRC20Action; - ui_approval_blue_values[1] = (const char*)fullContract; - ui_approval_blue_values[2] = (const char*)toAddress; - ui_approval_blue_values[3] = (const char*)G_io_apdu_buffer; - ui_approval_blue_values[4] = (const char*)fromAddress; - - ui_approval_blue_init(); -} - -#endif // #if defined(TARGET_BLUE) - -// PGP ECDH -unsigned int io_seproxyhal_touch_ecdh_ok(const bagl_element_t *e) { - uint8_t privateKeyData[32]; - cx_ecfp_private_key_t privateKey; - uint32_t tx = 0; - - // Get private key - os_perso_derive_node_bip32(CX_CURVE_256K1, transactionContext.bip32_path.indices, - transactionContext.bip32_path.length, privateKeyData, NULL); - cx_ecfp_init_private_key(CX_CURVE_256K1, privateKeyData, 32, &privateKey); - - tx = cx_ecdh(&privateKey, CX_ECDH_POINT, - transactionContext.signature, 65, - G_io_apdu_buffer, 160); - - // Clear tmp buffer data - explicit_bzero(&privateKey, sizeof(privateKey)); - explicit_bzero(privateKeyData, sizeof(privateKeyData)); - - G_io_apdu_buffer[tx++] = 0x90; - G_io_apdu_buffer[tx++] = 0x00; - - // Send back the response, do not restart the event loop - io_exchange(CHANNEL_APDU | IO_RETURN_AFTER_TX, tx); - // Display back the original UX - ui_idle(); - return 0; // do not redraw the widget -} - -#if defined(TARGET_BLUE) - -unsigned int -ui_approval_pgp_ecdh_blue_button(unsigned int button_mask, - unsigned int button_mask_counter) { - return 0; -} - -// UI to approve or deny the signature proposal -static const bagl_element_t const ui_approval_pgp_ecdh_blue[] = { - {{BAGL_RECTANGLE, 0x00, 0, 68, 320, 413, 0, 0, BAGL_FILL, COLOR_BG_1, - 0x000000, 0, 0}, - NULL, - 0, - 0, - 0, - NULL, - NULL, - NULL}, - - // erase screen (only under the status bar) - {{BAGL_RECTANGLE, 0x00, 0, 20, 320, 48, 0, 0, BAGL_FILL, COLOR_APP, - COLOR_APP, 0, 0}, - NULL, - 0, - 0, - 0, - NULL, - NULL, - NULL}, - - /// TOP STATUS BAR - {{BAGL_LABELINE, 0x00, 0, 45, 320, 30, 0, 0, BAGL_FILL, 0xFFFFFF, COLOR_APP, - BAGL_FONT_OPEN_SANS_SEMIBOLD_10_13PX | BAGL_FONT_ALIGNMENT_CENTER, 0}, - "TRON SHARED SECRETE", - 0, - 0, - 0, - NULL, - NULL, - NULL}, - - {{BAGL_LABEL, 0x00, 0, 87, 320, 32, 0, 0, 0, 0x000000, 0xF9F9F9, - BAGL_FONT_OPEN_SANS_LIGHT_14px | BAGL_FONT_ALIGNMENT_CENTER, 0}, - "Confirm ECDH Address:", - 0, - 0, - 0, - NULL, - NULL, - NULL}, - - {{BAGL_LABEL, 0x00, 0, 136, 320, 33, 0, 0, 0, 0x000000, 0xF9F9F9, - BAGL_FONT_OPEN_SANS_SEMIBOLD_11_16PX | BAGL_FONT_ALIGNMENT_CENTER, 0}, - (const char *)fromAddress, - 0, - 0, - 0, - NULL, - NULL, - NULL}, - - {{BAGL_LABEL, 0x00, 0, 185, 320, 32, 0, 0, 0, 0x000000, 0xF9F9F9, - BAGL_FONT_OPEN_SANS_LIGHT_14px | BAGL_FONT_ALIGNMENT_CENTER, 0}, - "Shared with", - 0, - 0, - 0, - NULL, - NULL, - NULL}, - - {{BAGL_LABEL, 0x00, 0, 234, 320, 33, 0, 0, 0, 0x000000, 0xF9F9F9, - BAGL_FONT_OPEN_SANS_SEMIBOLD_11_16PX | BAGL_FONT_ALIGNMENT_CENTER, 0}, - (const char *)toAddress, - 0, - 0, - 0, - NULL, - NULL, - NULL}, - - {{BAGL_BUTTON | BAGL_FLAG_TOUCHABLE, 0x00, 35, 385, 120, 40, 0, 6, - BAGL_FILL, 0xcccccc, COLOR_BG_1, - BAGL_FONT_OPEN_SANS_LIGHT_14px | BAGL_FONT_ALIGNMENT_CENTER | - BAGL_FONT_ALIGNMENT_MIDDLE, - 0}, - "CANCEL", - 0, - 0x37ae99, - COLOR_BG_1, - io_seproxyhal_touch_cancel, - NULL, - NULL}, - {{BAGL_BUTTON | BAGL_FLAG_TOUCHABLE, 0x00, 165, 385, 120, 40, 0, 6, - BAGL_FILL, 0x41ccb4, COLOR_BG_1, - BAGL_FONT_OPEN_SANS_LIGHT_14px | BAGL_FONT_ALIGNMENT_CENTER | - BAGL_FONT_ALIGNMENT_MIDDLE, - 0}, - "CONFIRM", - 0, - 0x37ae99, - COLOR_BG_1, - io_seproxyhal_touch_ecdh_ok, - NULL, - NULL}, - -}; - -#endif // #if defined(TARGET_BLUE) - -#if defined(TARGET_NANOS) && !defined(HAVE_UX_FLOW) -unsigned int ui_approval_pgp_ecdh_nanos_button(unsigned int button_mask, - unsigned int button_mask_counter) { - switch (button_mask) { - case BUTTON_EVT_RELEASED | BUTTON_LEFT: // CANCEL - io_seproxyhal_touch_cancel(NULL); - break; - - case BUTTON_EVT_RELEASED | BUTTON_RIGHT: { // OK - io_seproxyhal_touch_ecdh_ok(NULL); - break; - } - } - return 0; -} - -const bagl_element_t ui_approval_pgp_ecdh_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}, - - //{{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, 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}, - "Shared Secret", - 0, - 0, - 0, - NULL, - NULL, - NULL}, - - {{BAGL_LABELINE, 0x02, 0, 12, 128, 32, 0, 0, 0, 0xFFFFFF, 0x000000, - BAGL_FONT_OPEN_SANS_REGULAR_11px | BAGL_FONT_ALIGNMENT_CENTER, 0}, - "ECDH Address", - 0, - 0, - 0, - NULL, - NULL, - NULL}, - {{BAGL_LABELINE, 0x02, 23, 26, 82, 12, 0x80 | 10, 0, 0, 0xFFFFFF, 0x000000, - BAGL_FONT_OPEN_SANS_EXTRABOLD_11px | BAGL_FONT_ALIGNMENT_CENTER, 26}, - (char *)fromAddress, - 0, - 0, - 0, - NULL, - NULL, - NULL}, - {{BAGL_LABELINE, 0x03, 0, 12, 128, 32, 0, 0, 0, 0xFFFFFF, 0x000000, - BAGL_FONT_OPEN_SANS_REGULAR_11px | BAGL_FONT_ALIGNMENT_CENTER, 0}, - "Shared With", - 0, - 0, - 0, - NULL, - NULL, - NULL}, - {{BAGL_LABELINE, 0x03, 23, 26, 82, 12, 0x80 | 10, 0, 0, 0xFFFFFF, 0x000000, - BAGL_FONT_OPEN_SANS_EXTRABOLD_11px | BAGL_FONT_ALIGNMENT_CENTER, 26}, - (char *)toAddress, - 0, - 0, - 0, - NULL, - NULL, - NULL}, -}; - -unsigned int ui_approval_pgp_ecdh_prepro(const bagl_element_t *element) { - if (element->component.userid > 0) { - unsigned int display = (ux_step == element->component.userid - 1); - if (display) { - switch (element->component.userid) { - case 1: - UX_CALLBACK_SET_INTERVAL(2000); - break; - case 2: - UX_CALLBACK_SET_INTERVAL(MAX( - 3000, 1000 + bagl_label_roundtrip_duration_ms(element, 7))); - break; - case 3: - UX_CALLBACK_SET_INTERVAL(MAX( - 3000, 1000 + bagl_label_roundtrip_duration_ms(element, 7))); - break; - } - } - return display; - } - return 1; -} - -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 }, - - {{BAGL_LABELINE , 0x01, 0, 12, 128, 32, 0, 0, 0 , 0xFFFFFF, 0x000000, BAGL_FONT_OPEN_SANS_EXTRABOLD_11px|BAGL_FONT_ALIGNMENT_CENTER, 0 }, "Sign the", 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 }, "message", 0, 0, 0, NULL, NULL, NULL }, - - {{BAGL_LABELINE , 0x02, 0, 12, 128, 32, 0, 0, 0 , 0xFFFFFF, 0x000000, BAGL_FONT_OPEN_SANS_REGULAR_11px|BAGL_FONT_ALIGNMENT_CENTER, 0 }, "Message hash", 0, 0, 0, NULL, NULL, NULL }, - {{BAGL_LABELINE , 0x02, 0, 26, 128, 32, 0, 0, 0 , 0xFFFFFF, 0x000000, BAGL_FONT_OPEN_SANS_EXTRABOLD_11px|BAGL_FONT_ALIGNMENT_CENTER, 0 }, (char *)fullContract, 0, 0, 0, NULL, NULL, NULL }, - - {{BAGL_LABELINE , 0x03, 0, 12, 128, 32, 0, 0, 0 , 0xFFFFFF, 0x000000, BAGL_FONT_OPEN_SANS_REGULAR_11px|BAGL_FONT_ALIGNMENT_CENTER, 0 }, "Sign with", 0, 0, 0, NULL, NULL, NULL }, - {{BAGL_LABELINE , 0x03, 23, 26, 82, 12, 0x80 | 10, 0, 0 , 0xFFFFFF, 0x000000, BAGL_FONT_OPEN_SANS_EXTRABOLD_11px | BAGL_FONT_ALIGNMENT_CENTER, 26}, (char *)fromAddress, 0, 0, 0, NULL, NULL, NULL}, - -}; - -unsigned int -ui_approval_signMessage_nanos_button(unsigned int button_mask, unsigned int button_mask_counter); - -unsigned int ui_approval_signMessage_prepro(const bagl_element_t *element) { - if (element->component.userid > 0) { - unsigned int display = (ux_step == element->component.userid - 1); - if (display) { - switch (element->component.userid) { - case 1: - UX_CALLBACK_SET_INTERVAL(2000); - break; - case 2: - UX_CALLBACK_SET_INTERVAL(3000); - break; - case 3: - UX_CALLBACK_SET_INTERVAL(MAX( - 3000, 1000 + bagl_label_roundtrip_duration_ms(element, 7))); - break; - } - } - return display; - } - return 1; -} - -unsigned int ui_approval_signMessage_nanos_button(unsigned int button_mask, unsigned int button_mask_counter) { - switch (button_mask) { - case BUTTON_EVT_RELEASED | BUTTON_LEFT: - io_seproxyhal_touch_cancel(NULL); - break; - - case BUTTON_EVT_RELEASED | BUTTON_RIGHT: { - io_seproxyhal_touch_signMessage_ok(NULL); - break; - } - } - return 0; -} - -#endif // #if defined(TARGET_NANOS) && !defined(HAVE_UX_FLOW) - -#if defined(TARGET_NANOS) && !defined(HAVE_UX_FLOW) -const bagl_element_t ui_approval_simple_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}, - - //{{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, 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}, - - {{BAGL_LABELINE, 0x02, 0, 12, 128, 32, 0, 0, 0, 0xFFFFFF, 0x000000, - BAGL_FONT_OPEN_SANS_REGULAR_11px | BAGL_FONT_ALIGNMENT_CENTER, 0}, - "Transaction Type", - 0, - 0, - 0, - NULL, - NULL, - NULL}, - {{BAGL_LABELINE, 0x02, 23, 26, 82, 12, 0x80 | 10, 0, 0, 0xFFFFFF, 0x000000, - BAGL_FONT_OPEN_SANS_EXTRABOLD_11px | BAGL_FONT_ALIGNMENT_CENTER, 26}, - (char *)fullContract, - 0, - 0, - 0, - NULL, - NULL, - NULL}, - - {{BAGL_LABELINE, 0x03, 0, 12, 128, 32, 0, 0, 0, 0xFFFFFF, 0x000000, - BAGL_FONT_OPEN_SANS_REGULAR_11px | BAGL_FONT_ALIGNMENT_CENTER, 0}, - "Transaction Hash", - 0, - 0, - 0, - NULL, - NULL, - NULL}, - {{BAGL_LABELINE, 0x03, 23, 26, 82, 12, 0x80 | 10, 0, 0, 0xFFFFFF, 0x000000, - BAGL_FONT_OPEN_SANS_EXTRABOLD_11px | BAGL_FONT_ALIGNMENT_CENTER, 26}, - (char *)fullHash, - 0, - 0, - 0, - NULL, - NULL, - NULL}, - - {{BAGL_LABELINE, 0x04, 0, 12, 128, 32, 0, 0, 0, 0xFFFFFF, 0x000000, - BAGL_FONT_OPEN_SANS_REGULAR_11px | BAGL_FONT_ALIGNMENT_CENTER, 0}, - "Send From", - 0, - 0, - 0, - NULL, - NULL, - NULL}, - {{BAGL_LABELINE, 0x04, 23, 26, 82, 12, 0x80 | 10, 0, 0, 0xFFFFFF, 0x000000, - BAGL_FONT_OPEN_SANS_EXTRABOLD_11px | BAGL_FONT_ALIGNMENT_CENTER, 26}, - (char *)fromAddress, - 0, - 0, - 0, - NULL, - NULL, - NULL}, -}; - -unsigned int ui_approval_simple_prepro(const bagl_element_t *element) { - if (element->component.userid > 0) { - unsigned int display = (ux_step == element->component.userid - 1); - if (display) { - switch (element->component.userid) { - case 1: - UX_CALLBACK_SET_INTERVAL(2000); - break; - case 2: - case 3: - case 4: - UX_CALLBACK_SET_INTERVAL(MAX( - 3000, 1000 + bagl_label_roundtrip_duration_ms(element, 7))); - break; - } - } - return display; - } - return 1; -} - -unsigned int ui_approval_simple_nanos_button(unsigned int button_mask, - unsigned int button_mask_counter); -#endif // #if defined(TARGET_NANOS) && !defined(HAVE_UX_FLOW) - - -#if defined(TARGET_NANOS) && !defined(HAVE_UX_FLOW) -// Show transactions details for approval -const bagl_element_t ui_approval_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}, - - //{{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}, - - {{BAGL_LABELINE, 0x02, 0, 12, 128, 32, 0, 0, 0, 0xFFFFFF, 0x000000, BAGL_FONT_OPEN_SANS_REGULAR_11px | BAGL_FONT_ALIGNMENT_CENTER, 0}, "WARNING", 0, 0, 0, NULL, NULL, NULL}, - {{BAGL_LABELINE, 0x02, 23, 26, 82, 12, 0, 0, 0, 0xFFFFFF, 0x000000, BAGL_FONT_OPEN_SANS_EXTRABOLD_11px | BAGL_FONT_ALIGNMENT_CENTER, 0}, "Data present", 0, 0, 0, NULL, NULL, NULL}, - - {{BAGL_LABELINE, 0x03, 0, 12, 128, 32, 0, 0, 0, 0xFFFFFF, 0x000000, - BAGL_FONT_OPEN_SANS_REGULAR_11px | BAGL_FONT_ALIGNMENT_CENTER, 0}, - "Token Name", - 0, - 0, - 0, - NULL, - NULL, - NULL}, - {{BAGL_LABELINE, 0x03, 12, 28, 104, 12, 0x00 | 10, 0, 0, 0xFFFFFF, 0x000000, - BAGL_FONT_OPEN_SANS_EXTRABOLD_11px | BAGL_FONT_ALIGNMENT_CENTER, 26}, - (char *)fullContract, - 0, - 0, - 0, - NULL, - NULL, - NULL}, - - {{BAGL_LABELINE, 0x04, 0, 12, 128, 32, 0, 0, 0, 0xFFFFFF, 0x000000, - BAGL_FONT_OPEN_SANS_EXTRABOLD_11px | BAGL_FONT_ALIGNMENT_CENTER, 0}, - (char *)TRC20Action, - 0, - 0, - 0, - NULL, - NULL, - NULL}, - {{BAGL_LABELINE, 0x04, 23, 26, 82, 12, 0x80 | 10, 0, 0, 0xFFFFFF, 0x000000, - BAGL_FONT_OPEN_SANS_EXTRABOLD_11px | BAGL_FONT_ALIGNMENT_CENTER, 26}, - "Transfer", - 0, - 0, - 0, - NULL, - NULL, - NULL}, - - {{BAGL_LABELINE, 0x05, 0, 12, 128, 32, 0, 0, 0, 0xFFFFFF, 0x000000, - BAGL_FONT_OPEN_SANS_REGULAR_11px | BAGL_FONT_ALIGNMENT_CENTER, 0}, - "Amount", - 0, - 0, - 0, - NULL, - NULL, - NULL}, - {{BAGL_LABELINE, 0x05, 23, 26, 82, 12, 0x80 | 10, 0, 0, 0xFFFFFF, 0x000000, - BAGL_FONT_OPEN_SANS_EXTRABOLD_11px | BAGL_FONT_ALIGNMENT_CENTER, 26}, - (char *)G_io_apdu_buffer, - 0, - 0, - 0, - NULL, - NULL, - NULL}, - - {{BAGL_LABELINE, 0x06, 0, 12, 128, 32, 0, 0, 0, 0xFFFFFF, 0x000000, - BAGL_FONT_OPEN_SANS_REGULAR_11px | BAGL_FONT_ALIGNMENT_CENTER, 0}, - (char *)TRC20ActionSendAllow, - 0, - 0, - 0, - NULL, - NULL, - NULL}, - {{BAGL_LABELINE, 0x06, 23, 26, 82, 12, 0x80 | 10, 0, 0, 0xFFFFFF, 0x000000, - BAGL_FONT_OPEN_SANS_EXTRABOLD_11px | BAGL_FONT_ALIGNMENT_CENTER, 26}, - (char *)toAddress, - 0, - 0, - 0, - NULL, - NULL, - NULL}, - - {{BAGL_LABELINE, 0x07, 0, 12, 128, 32, 0, 0, 0, 0xFFFFFF, 0x000000, - BAGL_FONT_OPEN_SANS_REGULAR_11px | BAGL_FONT_ALIGNMENT_CENTER, 0}, - "Send From", - 0, - 0, - 0, - NULL, - NULL, - NULL}, - {{BAGL_LABELINE, 0x07, 23, 26, 82, 12, 0x80 | 10, 0, 0, 0xFFFFFF, 0x000000, - BAGL_FONT_OPEN_SANS_EXTRABOLD_11px | BAGL_FONT_ALIGNMENT_CENTER, 26}, - (char *)fromAddress, - 0, - 0, - 0, - NULL, - NULL, - NULL}, - -}; - -/* - ux_step 0: confirm - 1: amount - 2: address -*/ -unsigned int ui_approval_prepro(const bagl_element_t *element) { - unsigned int display = 1; - if (element->component.userid > 0) { - display = (ux_step == element->component.userid - 1); - if (display) { - switch (element->component.userid) { - case 0x01: - UX_CALLBACK_SET_INTERVAL(2000); - break; - case 2: - if (txContent.dataBytes>0) { - UX_CALLBACK_SET_INTERVAL(3000); - } - else { - display = 0; - ux_step++; // display the next step - } - break; - case 0x03: - UX_CALLBACK_SET_INTERVAL(MAX( - 3000, - 1000 + bagl_label_roundtrip_duration_ms(element, 7))); - break; - case 0x04: - if (txContent.contractType==TRIGGERSMARTCONTRACT){ - UX_CALLBACK_SET_INTERVAL(3000); - } - else { - display = 0; - ux_step++; // display the next step - } - break; - case 0x05: - case 0x06: - case 0x07: - UX_CALLBACK_SET_INTERVAL(MAX( - 3000, - 1000 + bagl_label_roundtrip_duration_ms(element, 7))); - break; - } - } - } - return display; -} - -unsigned int ui_approval_nanos_button(unsigned int button_mask, - unsigned int button_mask_counter) { - switch (button_mask) { - case BUTTON_EVT_RELEASED | BUTTON_LEFT: - io_seproxyhal_touch_cancel(NULL); - break; - - case BUTTON_EVT_RELEASED | BUTTON_RIGHT: { - io_seproxyhal_touch_tx_ok(NULL); - break; - } - } - return 0; -} - - -// EXCHANGE TRANSACTIONS DETAILS -const bagl_element_t ui_approval_exchange_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}, - - //{{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}, - "Exchange", - 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}, - (char *)exchangeContractDetail, - 0, - 0, - 0, - NULL, - NULL, - NULL}, - - {{BAGL_LABELINE, 0x02, 0, 12, 128, 32, 0, 0, 0, 0xFFFFFF, 0x000000, - BAGL_FONT_OPEN_SANS_REGULAR_11px | BAGL_FONT_ALIGNMENT_CENTER, 0}, - "Token Name 1", - 0, - 0, - 0, - NULL, - NULL, - NULL}, - {{BAGL_LABELINE, 0x02, 23, 26, 82, 12, 0x80 | 10, 0, 0, 0xFFFFFF, 0x000000, - BAGL_FONT_OPEN_SANS_EXTRABOLD_11px | BAGL_FONT_ALIGNMENT_CENTER, 26}, - (char *)fullContract, - 0, - 0, - 0, - NULL, - NULL, - NULL}, - - {{BAGL_LABELINE, 0x03, 0, 12, 128, 32, 0, 0, 0, 0xFFFFFF, 0x000000, - BAGL_FONT_OPEN_SANS_REGULAR_11px | BAGL_FONT_ALIGNMENT_CENTER, 0}, - "Amount Token 1", - 0, - 0, - 0, - NULL, - NULL, - NULL}, - {{BAGL_LABELINE, 0x03, 23, 26, 82, 12, 0x80 | 10, 0, 0, 0xFFFFFF, 0x000000, - BAGL_FONT_OPEN_SANS_EXTRABOLD_11px | BAGL_FONT_ALIGNMENT_CENTER, 26}, - (char *)G_io_apdu_buffer, - 0, - 0, - 0, - NULL, - NULL, - NULL}, - - {{BAGL_LABELINE, 0x04, 0, 12, 128, 32, 0, 0, 0, 0xFFFFFF, 0x000000, - BAGL_FONT_OPEN_SANS_REGULAR_11px | BAGL_FONT_ALIGNMENT_CENTER, 0}, - "Token Name 2", - 0, - 0, - 0, - NULL, - NULL, - NULL}, - {{BAGL_LABELINE, 0x04, 23, 26, 82, 12, 0x80 | 10, 0, 0, 0xFFFFFF, 0x000000, - BAGL_FONT_OPEN_SANS_EXTRABOLD_11px | BAGL_FONT_ALIGNMENT_CENTER, 26}, - (char *)toAddress, - 0, - 0, - 0, - NULL, - NULL, - NULL}, - - {{BAGL_LABELINE, 0x05, 0, 12, 128, 32, 0, 0, 0, 0xFFFFFF, 0x000000, - BAGL_FONT_OPEN_SANS_REGULAR_11px | BAGL_FONT_ALIGNMENT_CENTER, 0}, - "Amount Token 2", - 0, - 0, - 0, - NULL, - NULL, - NULL}, - {{BAGL_LABELINE, 0x05, 23, 26, 82, 12, 0x80 | 10, 0, 0, 0xFFFFFF, 0x000000, - BAGL_FONT_OPEN_SANS_EXTRABOLD_11px | BAGL_FONT_ALIGNMENT_CENTER, 26}, - (char *)G_io_apdu_buffer+100, - 0, - 0, - 0, - NULL, - NULL, - NULL}, - - {{BAGL_LABELINE, 0x06, 0, 12, 128, 32, 0, 0, 0, 0xFFFFFF, 0x000000, - BAGL_FONT_OPEN_SANS_REGULAR_11px | BAGL_FONT_ALIGNMENT_CENTER, 0}, - "Send From", - 0, - 0, - 0, - NULL, - NULL, - NULL}, - {{BAGL_LABELINE, 0x06, 23, 26, 82, 12, 0x80 | 10, 0, 0, 0xFFFFFF, 0x000000, - BAGL_FONT_OPEN_SANS_EXTRABOLD_11px | BAGL_FONT_ALIGNMENT_CENTER, 26}, - (char *)fromAddress, - 0, - 0, - 0, - NULL, - NULL, - NULL}, - -}; - -/* - ux_step 0: confirm - 1: amount - 2: address -*/ -unsigned int ui_approval_exchange_prepro(const bagl_element_t *element) { - unsigned int display = 1; - if (element->component.userid > 0) { - display = (ux_step == element->component.userid - 1); - if (display) { - switch (element->component.userid) { - case 0x01: - UX_CALLBACK_SET_INTERVAL(2000); - break; - case 0x02: - case 0x03: - case 0x04: - case 0x05: - case 0x06: - UX_CALLBACK_SET_INTERVAL(MAX( - 3000, - 1000 + bagl_label_roundtrip_duration_ms(element, 7))); - break; - } - } - } - return display; -} - -unsigned int ui_approval_exchange_nanos_button(unsigned int button_mask, - unsigned int button_mask_counter) { - switch (button_mask) { - case BUTTON_EVT_RELEASED | BUTTON_LEFT: - io_seproxyhal_touch_cancel(NULL); - break; - - case BUTTON_EVT_RELEASED | BUTTON_RIGHT: { - io_seproxyhal_touch_tx_ok(NULL); - break; - } - } - return 0; -} - -// Show exchange withdraw/inject approval -const bagl_element_t ui_approval_exchange_withdraw_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}, - - //{{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}, - "Exchange", - 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}, - (char *)exchangeContractDetail, - 0, - 0, - 0, - NULL, - NULL, - NULL}, - - {{BAGL_LABELINE, 0x02, 0, 12, 128, 32, 0, 0, 0, 0xFFFFFF, 0x000000, - BAGL_FONT_OPEN_SANS_REGULAR_11px | BAGL_FONT_ALIGNMENT_CENTER, 0}, - "Exchange ID", - 0, - 0, - 0, - NULL, - NULL, - NULL}, - {{BAGL_LABELINE, 0x02, 23, 26, 82, 12, 0x80 | 10, 0, 0, 0xFFFFFF, 0x000000, - BAGL_FONT_OPEN_SANS_EXTRABOLD_11px | BAGL_FONT_ALIGNMENT_CENTER, 26}, - (char *)toAddress, - 0, - 0, - 0, - NULL, - NULL, - NULL}, - - {{BAGL_LABELINE, 0x03, 0, 12, 128, 32, 0, 0, 0, 0xFFFFFF, 0x000000, - BAGL_FONT_OPEN_SANS_REGULAR_11px | BAGL_FONT_ALIGNMENT_CENTER, 0}, - "Token Name", - 0, - 0, - 0, - NULL, - NULL, - NULL}, - {{BAGL_LABELINE, 0x03, 23, 26, 82, 12, 0x80 | 10, 0, 0, 0xFFFFFF, 0x000000, - BAGL_FONT_OPEN_SANS_EXTRABOLD_11px | BAGL_FONT_ALIGNMENT_CENTER, 26}, - (char *)fullContract, - 0, - 0, - 0, - NULL, - NULL, - NULL}, - - {{BAGL_LABELINE, 0x04, 0, 12, 128, 32, 0, 0, 0, 0xFFFFFF, 0x000000, - BAGL_FONT_OPEN_SANS_REGULAR_11px | BAGL_FONT_ALIGNMENT_CENTER, 0}, - "Amount", - 0, - 0, - 0, - NULL, - NULL, - NULL}, - {{BAGL_LABELINE, 0x04, 23, 26, 82, 12, 0x80 | 10, 0, 0, 0xFFFFFF, 0x000000, - BAGL_FONT_OPEN_SANS_EXTRABOLD_11px | BAGL_FONT_ALIGNMENT_CENTER, 26}, - (char *)G_io_apdu_buffer, - 0, - 0, - 0, - NULL, - NULL, - NULL}, - - {{BAGL_LABELINE, 0x05, 0, 12, 128, 32, 0, 0, 0, 0xFFFFFF, 0x000000, - BAGL_FONT_OPEN_SANS_REGULAR_11px | BAGL_FONT_ALIGNMENT_CENTER, 0}, - "Send From", - 0, - 0, - 0, - NULL, - NULL, - NULL}, - {{BAGL_LABELINE, 0x05, 23, 26, 82, 12, 0x80 | 10, 0, 0, 0xFFFFFF, 0x000000, - BAGL_FONT_OPEN_SANS_EXTRABOLD_11px | BAGL_FONT_ALIGNMENT_CENTER, 26}, - (char *)fromAddress, - 0, - 0, - 0, - NULL, - NULL, - NULL}, - -}; - -/* - ux_step 0: confirm - 1: amount - 2: address -*/ -unsigned int ui_approval_exchange_withdraw_prepro(const bagl_element_t *element) { - unsigned int display = 1; - if (element->component.userid > 0) { - display = (ux_step == element->component.userid - 1); - if (display) { - switch (element->component.userid) { - case 0x01: - UX_CALLBACK_SET_INTERVAL(2000); - break; - case 0x02: - case 0x03: - case 0x04: - case 0x05: - UX_CALLBACK_SET_INTERVAL(MAX( - 3000, - 1000 + bagl_label_roundtrip_duration_ms(element, 7))); - break; - } - } - } - return display; -} - -unsigned int ui_approval_exchange_withdraw_nanos_button(unsigned int button_mask, - unsigned int button_mask_counter) { - switch (button_mask) { - case BUTTON_EVT_RELEASED | BUTTON_LEFT: - io_seproxyhal_touch_cancel(NULL); - break; - - case BUTTON_EVT_RELEASED | BUTTON_RIGHT: { - io_seproxyhal_touch_tx_ok(NULL); - break; - } - } - return 0; -} - -// Show exchange transaction details for approval -const bagl_element_t ui_approval_exchange_transaction_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}, - - //{{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}, - "Exchange", - 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}, - (char *)exchangeContractDetail, - 0, - 0, - 0, - NULL, - NULL, - NULL}, - - {{BAGL_LABELINE, 0x02, 0, 12, 128, 32, 0, 0, 0, 0xFFFFFF, 0x000000, - BAGL_FONT_OPEN_SANS_REGULAR_11px | BAGL_FONT_ALIGNMENT_CENTER, 0}, - "Exchange ID", - 0, - 0, - 0, - NULL, - NULL, - NULL}, - {{BAGL_LABELINE, 0x02, 23, 26, 82, 12, 0x80 | 10, 0, 0, 0xFFFFFF, 0x000000, - BAGL_FONT_OPEN_SANS_EXTRABOLD_11px | BAGL_FONT_ALIGNMENT_CENTER, 26}, - (char *)toAddress, - 0, - 0, - 0, - NULL, - NULL, - NULL}, - - {{BAGL_LABELINE, 0x03, 0, 12, 128, 32, 0, 0, 0, 0xFFFFFF, 0x000000, - BAGL_FONT_OPEN_SANS_REGULAR_11px | BAGL_FONT_ALIGNMENT_CENTER, 0}, - "Token Name", - 0, - 0, - 0, - NULL, - NULL, - NULL}, - {{BAGL_LABELINE, 0x03, 23, 26, 82, 12, 0x80 | 10, 0, 0, 0xFFFFFF, 0x000000, - BAGL_FONT_OPEN_SANS_EXTRABOLD_11px | BAGL_FONT_ALIGNMENT_CENTER, 26}, - (char *)fullContract, - 0, - 0, - 0, - NULL, - NULL, - NULL}, - - {{BAGL_LABELINE, 0x04, 0, 12, 128, 32, 0, 0, 0, 0xFFFFFF, 0x000000, - BAGL_FONT_OPEN_SANS_REGULAR_11px | BAGL_FONT_ALIGNMENT_CENTER, 0}, - "Amount", - 0, - 0, - 0, - NULL, - NULL, - NULL}, - {{BAGL_LABELINE, 0x04, 23, 26, 82, 12, 0x80 | 10, 0, 0, 0xFFFFFF, 0x000000, - BAGL_FONT_OPEN_SANS_EXTRABOLD_11px | BAGL_FONT_ALIGNMENT_CENTER, 26}, - (char *)G_io_apdu_buffer, - 0, - 0, - 0, - NULL, - NULL, - NULL}, - - {{BAGL_LABELINE, 0x05, 0, 12, 128, 32, 0, 0, 0, 0xFFFFFF, 0x000000, - BAGL_FONT_OPEN_SANS_REGULAR_11px | BAGL_FONT_ALIGNMENT_CENTER, 0}, - "Expected", - 0, - 0, - 0, - NULL, - NULL, - NULL}, - {{BAGL_LABELINE, 0x05, 23, 26, 82, 12, 0x80 | 10, 0, 0, 0xFFFFFF, 0x000000, - BAGL_FONT_OPEN_SANS_EXTRABOLD_11px | BAGL_FONT_ALIGNMENT_CENTER, 26}, - (char *)G_io_apdu_buffer+100, - 0, - 0, - 0, - NULL, - NULL, - NULL}, - - {{BAGL_LABELINE, 0x06, 0, 12, 128, 32, 0, 0, 0, 0xFFFFFF, 0x000000, - BAGL_FONT_OPEN_SANS_REGULAR_11px | BAGL_FONT_ALIGNMENT_CENTER, 0}, - "Send From", - 0, - 0, - 0, - NULL, - NULL, - NULL}, - {{BAGL_LABELINE, 0x06, 23, 26, 82, 12, 0x80 | 10, 0, 0, 0xFFFFFF, 0x000000, - BAGL_FONT_OPEN_SANS_EXTRABOLD_11px | BAGL_FONT_ALIGNMENT_CENTER, 26}, - (char *)fromAddress, - 0, - 0, - 0, - NULL, - NULL, - NULL}, - -}; - -/* - ux_step 0: confirm - 1: amount - 2: address -*/ -unsigned int ui_approval_exchange_transaction_prepro(const bagl_element_t *element) { - unsigned int display = 1; - if (element->component.userid > 0) { - display = (ux_step == element->component.userid - 1); - if (display) { - switch (element->component.userid) { - case 0x01: - UX_CALLBACK_SET_INTERVAL(2000); - break; - case 0x02: - case 0x03: - case 0x04: - case 0x05: - case 0x06: - UX_CALLBACK_SET_INTERVAL(MAX( - 3000, - 1000 + bagl_label_roundtrip_duration_ms(element, 7))); - break; - } - } - } - return display; -} - -unsigned int ui_approval_exchange_transaction_nanos_button(unsigned int button_mask, - unsigned int button_mask_counter) { - switch (button_mask) { - case BUTTON_EVT_RELEASED | BUTTON_LEFT: - io_seproxyhal_touch_cancel(NULL); - break; - - case BUTTON_EVT_RELEASED | BUTTON_RIGHT: { - io_seproxyhal_touch_tx_ok(NULL); - break; - } - } - return 0; -} - -// Show VOTES details for approval -const bagl_element_t ui_approval_votes_transaction_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}, - - //{{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, 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}, - "Votes", - 0, - 0, - 0, - NULL, - NULL, - NULL}, - - {{BAGL_LABELINE, 0x02, 0, 12, 128, 32, 0, 0, 0, 0xFFFFFF, 0x000000, - BAGL_FONT_OPEN_SANS_REGULAR_11px | BAGL_FONT_ALIGNMENT_CENTER, 0}, - (char *)(G_io_apdu_buffer+voteSlot(0, VOTE_ADDRESS)), - 0, - 0, - 0, - NULL, - NULL, - NULL}, - {{BAGL_LABELINE, 0x02, 23, 26, 82, 12, 0x80 | 10, 0, 0, 0xFFFFFF, 0x000000, - BAGL_FONT_OPEN_SANS_EXTRABOLD_11px | BAGL_FONT_ALIGNMENT_CENTER, 26}, - (char *)(G_io_apdu_buffer+voteSlot(0, VOTE_AMOUNT)), - 0, - 0, - 0, - NULL, - NULL, - NULL}, - - {{BAGL_LABELINE, 0x03, 0, 12, 128, 32, 0, 0, 0, 0xFFFFFF, 0x000000, - BAGL_FONT_OPEN_SANS_REGULAR_11px | BAGL_FONT_ALIGNMENT_CENTER, 0}, - (char *)(G_io_apdu_buffer+voteSlot(1, VOTE_ADDRESS)), - 0, - 0, - 0, - NULL, - NULL, - NULL}, - {{BAGL_LABELINE, 0x03, 23, 26, 82, 12, 0x80 | 10, 0, 0, 0xFFFFFF, 0x000000, - BAGL_FONT_OPEN_SANS_EXTRABOLD_11px | BAGL_FONT_ALIGNMENT_CENTER, 26}, - (char *)(G_io_apdu_buffer+voteSlot(1, VOTE_AMOUNT)), - 0, - 0, - 0, - NULL, - NULL, - NULL}, - - {{BAGL_LABELINE, 0x04, 0, 12, 128, 32, 0, 0, 0, 0xFFFFFF, 0x000000, - BAGL_FONT_OPEN_SANS_REGULAR_11px | BAGL_FONT_ALIGNMENT_CENTER, 0}, - (char *)(G_io_apdu_buffer+voteSlot(2, VOTE_ADDRESS)), - 0, - 0, - 0, - NULL, - NULL, - NULL}, - {{BAGL_LABELINE, 0x04, 23, 26, 82, 12, 0x80 | 10, 0, 0, 0xFFFFFF, 0x000000, - BAGL_FONT_OPEN_SANS_EXTRABOLD_11px | BAGL_FONT_ALIGNMENT_CENTER, 26}, - (char *)(G_io_apdu_buffer+voteSlot(2, VOTE_AMOUNT)), - 0, - 0, - 0, - NULL, - NULL, - NULL}, - - {{BAGL_LABELINE, 0x05, 0, 12, 128, 32, 0, 0, 0, 0xFFFFFF, 0x000000, - BAGL_FONT_OPEN_SANS_REGULAR_11px | BAGL_FONT_ALIGNMENT_CENTER, 0}, - (char *)(G_io_apdu_buffer+voteSlot(3, VOTE_ADDRESS)), - 0, - 0, - 0, - NULL, - NULL, - NULL}, - {{BAGL_LABELINE, 0x05, 23, 26, 82, 12, 0x80 | 10, 0, 0, 0xFFFFFF, 0x000000, - BAGL_FONT_OPEN_SANS_EXTRABOLD_11px | BAGL_FONT_ALIGNMENT_CENTER, 26}, - (char *)(G_io_apdu_buffer+voteSlot(3, VOTE_AMOUNT)), - 0, - 0, - 0, - NULL, - NULL, - NULL}, - - {{BAGL_LABELINE, 0x06, 0, 12, 128, 32, 0, 0, 0, 0xFFFFFF, 0x000000, - BAGL_FONT_OPEN_SANS_REGULAR_11px | BAGL_FONT_ALIGNMENT_CENTER, 0}, - (char *)(G_io_apdu_buffer+voteSlot(4, VOTE_ADDRESS)), - 0, - 0, - 0, - NULL, - NULL, - NULL}, - {{BAGL_LABELINE, 0x06, 23, 26, 82, 12, 0x80 | 10, 0, 0, 0xFFFFFF, 0x000000, - BAGL_FONT_OPEN_SANS_EXTRABOLD_11px | BAGL_FONT_ALIGNMENT_CENTER, 26}, - (char *)(G_io_apdu_buffer+voteSlot(4, VOTE_AMOUNT)), - 0, - 0, - 0, - NULL, - NULL, - NULL}, - - - {{BAGL_LABELINE, 0x07, 0, 12, 128, 32, 0, 0, 0, 0xFFFFFF, 0x000000, - BAGL_FONT_OPEN_SANS_REGULAR_11px | BAGL_FONT_ALIGNMENT_CENTER, 0}, - "Send From", - 0, - 0, - 0, - NULL, - NULL, - NULL}, - {{BAGL_LABELINE, 0x07, 23, 26, 82, 12, 0x80 | 10, 0, 0, 0xFFFFFF, 0x000000, - BAGL_FONT_OPEN_SANS_EXTRABOLD_11px | BAGL_FONT_ALIGNMENT_CENTER, 26}, - (char *)fromAddress, - 0, - 0, - 0, - NULL, - NULL, - NULL}, - -}; - -unsigned int ui_approval_votes_transaction_prepro(const bagl_element_t *element) { - unsigned int display = 1; - if (element->component.userid > 0) { - if (ux_step > txContent.amount[0] && ux_step < 0x06) - ux_step = 6; - display = (ux_step == element->component.userid - 1); - if (display) { - switch (element->component.userid) { - case 0x01: - case 0x02: - case 0x03: - case 0x04: - case 0x05: - case 0x06: - case 0x07: - UX_CALLBACK_SET_INTERVAL(MAX( - 3000, - 1000 + bagl_label_roundtrip_duration_ms(element, 7))); - break; - } - } - } - return display; + ui_approval_blue_values[3] = (const char*)G_io_apdu_buffer+100; + ui_approval_blue_values[4] = (const char*)fromAddress; + + ui_approval_blue_init(); } -unsigned int ui_approval_votes_transaction_nanos_button(unsigned int button_mask, - unsigned int button_mask_counter) { - switch (button_mask) { - case BUTTON_EVT_RELEASED | BUTTON_LEFT: - io_seproxyhal_touch_cancel(NULL); - break; - case BUTTON_EVT_RELEASED | BUTTON_RIGHT: { - io_seproxyhal_touch_tx_ok(NULL); - break; - } - } - return 0; +void ui_approval_message_sign_blue_init(void) { + // wipe all cases + os_memset(ui_approval_blue_values, 0, sizeof(ui_approval_blue_values)); + ui_approval_blue_ok = (bagl_element_callback_t)io_seproxyhal_touch_signMessage_ok; + ui_approval_blue_cancel = + (bagl_element_callback_t)io_seproxyhal_touch_cancel; + ui_approval_blue_values[0] = (const char*)fullContract; + ui_approval_blue_values[1] = (const char*)fromAddress; + + ui_approval_blue_init(); } -// Show Freeze details for approval -const bagl_element_t ui_approval_freeze_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}, +void ui_approval_custom_contract_blue_init(void) { + // wipe all cases + os_memset(ui_approval_blue_values, 0, sizeof(ui_approval_blue_values)); + ui_approval_blue_ok = (bagl_element_callback_t)io_seproxyhal_touch_tx_ok; + ui_approval_blue_cancel = + (bagl_element_callback_t)io_seproxyhal_touch_cancel; + ui_approval_blue_values[0] = (const char*)TRC20Action; + ui_approval_blue_values[1] = (const char*)fullContract; + ui_approval_blue_values[2] = (const char*)toAddress; + ui_approval_blue_values[3] = (const char*)G_io_apdu_buffer; + ui_approval_blue_values[4] = (const char*)fromAddress; + + ui_approval_blue_init(); +} - //{{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, 32, 0, 0, 0, 0xFFFFFF, 0x000000, - BAGL_FONT_OPEN_SANS_EXTRABOLD_11px | BAGL_FONT_ALIGNMENT_CENTER, 0}, - "Freeze For", - 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}, - (char *)fullContract, - 0, - 0, - 0, - NULL, - NULL, - NULL}, +#endif // #if defined(TARGET_BLUE) - {{BAGL_LABELINE, 0x02, 0, 12, 128, 32, 0, 0, 0, 0xFFFFFF, 0x000000, - BAGL_FONT_OPEN_SANS_REGULAR_11px | BAGL_FONT_ALIGNMENT_CENTER, 0}, - "Freeze To", - 0, - 0, - 0, - NULL, - NULL, - NULL}, - {{BAGL_LABELINE, 0x02, 23, 26, 82, 12, 0x80 | 10, 0, 0, 0xFFFFFF, 0x000000, - BAGL_FONT_OPEN_SANS_EXTRABOLD_11px | BAGL_FONT_ALIGNMENT_CENTER, 26}, - (char *)toAddress, - 0, - 0, - 0, - NULL, - NULL, - NULL}, +// PGP ECDH +unsigned int io_seproxyhal_touch_ecdh_ok(const bagl_element_t *e) { + uint8_t privateKeyData[32]; + cx_ecfp_private_key_t privateKey; + uint32_t tx = 0; - {{BAGL_LABELINE, 0x03, 0, 12, 128, 32, 0, 0, 0, 0xFFFFFF, 0x000000, - BAGL_FONT_OPEN_SANS_REGULAR_11px | BAGL_FONT_ALIGNMENT_CENTER, 0}, - "Amount", - 0, - 0, - 0, - NULL, - NULL, - NULL}, - {{BAGL_LABELINE, 0x03, 23, 26, 82, 12, 0x80 | 10, 0, 0, 0xFFFFFF, 0x000000, - BAGL_FONT_OPEN_SANS_EXTRABOLD_11px | BAGL_FONT_ALIGNMENT_CENTER, 26}, - (char *)G_io_apdu_buffer, - 0, - 0, - 0, - NULL, - NULL, - NULL}, + // Get private key + os_perso_derive_node_bip32(CX_CURVE_256K1, transactionContext.bip32_path.indices, + transactionContext.bip32_path.length, privateKeyData, NULL); + cx_ecfp_init_private_key(CX_CURVE_256K1, privateKeyData, 32, &privateKey); + + tx = cx_ecdh(&privateKey, CX_ECDH_POINT, + transactionContext.signature, 65, + G_io_apdu_buffer, 160); + + // Clear tmp buffer data + explicit_bzero(&privateKey, sizeof(privateKey)); + explicit_bzero(privateKeyData, sizeof(privateKeyData)); - {{BAGL_LABELINE, 0x04, 0, 12, 128, 32, 0, 0, 0, 0xFFFFFF, 0x000000, - BAGL_FONT_OPEN_SANS_REGULAR_11px | BAGL_FONT_ALIGNMENT_CENTER, 0}, - "Send From", - 0, - 0, - 0, - NULL, - NULL, - NULL}, - {{BAGL_LABELINE, 0x04, 23, 26, 82, 12, 0x80 | 10, 0, 0, 0xFFFFFF, 0x000000, - BAGL_FONT_OPEN_SANS_EXTRABOLD_11px | BAGL_FONT_ALIGNMENT_CENTER, 26}, - (char *)fromAddress, - 0, - 0, - 0, - NULL, - NULL, - NULL}, - -}; + G_io_apdu_buffer[tx++] = 0x90; + G_io_apdu_buffer[tx++] = 0x00; -unsigned int ui_approval_freeze_prepro(const bagl_element_t *element) { - unsigned int display = 1; - if (element->component.userid > 0) { - display = (ux_step == element->component.userid - 1); - if (display) { - switch (element->component.userid) { - case 0x01: - case 0x02: - case 0x03: - case 0x04: - case 0x05: - UX_CALLBACK_SET_INTERVAL(MAX( - 3000, - 1000 + bagl_label_roundtrip_duration_ms(element, 7))); - break; - } - } - } - return display; + // Send back the response, do not restart the event loop + io_exchange(CHANNEL_APDU | IO_RETURN_AFTER_TX, tx); + // Display back the original UX + ui_idle(); + return 0; // do not redraw the widget } -unsigned int ui_approval_freeze_nanos_button(unsigned int button_mask, - unsigned int button_mask_counter) { - switch (button_mask) { - case BUTTON_EVT_RELEASED | BUTTON_LEFT: - io_seproxyhal_touch_cancel(NULL); - break; - case BUTTON_EVT_RELEASED | BUTTON_RIGHT: { - io_seproxyhal_touch_tx_ok(NULL); - break; - } - } +#if defined(TARGET_BLUE) + +unsigned int +ui_approval_pgp_ecdh_blue_button(unsigned int button_mask, + unsigned int button_mask_counter) { return 0; } -// Show transactions details for Custom Contracts -const bagl_element_t ui_approval_custom_contract_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}, +// UI to approve or deny the signature proposal +static const bagl_element_t const ui_approval_pgp_ecdh_blue[] = { + {{BAGL_RECTANGLE, 0x00, 0, 68, 320, 413, 0, 0, BAGL_FILL, COLOR_BG_1, + 0x000000, 0, 0}, NULL, 0, 0, @@ -3349,17 +1581,9 @@ const bagl_element_t ui_approval_custom_contract_nanos[] = { 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}, + // erase screen (only under the status bar) + {{BAGL_RECTANGLE, 0x00, 0, 20, 320, 48, 0, 0, BAGL_FILL, COLOR_APP, + COLOR_APP, 0, 0}, NULL, 0, 0, @@ -3368,21 +1592,10 @@ const bagl_element_t ui_approval_custom_contract_nanos[] = { 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", + /// TOP STATUS BAR + {{BAGL_LABELINE, 0x00, 0, 45, 320, 30, 0, 0, BAGL_FILL, 0xFFFFFF, COLOR_APP, + BAGL_FONT_OPEN_SANS_SEMIBOLD_10_13PX | BAGL_FONT_ALIGNMENT_CENTER, 0}, + "TRON SHARED SECRETE", 0, 0, 0, @@ -3390,21 +1603,19 @@ const bagl_element_t ui_approval_custom_contract_nanos[] = { NULL, NULL}, - {{BAGL_LABELINE, 0x02, 0, 12, 128, 32, 0, 0, 0, 0xFFFFFF, 0x000000, BAGL_FONT_OPEN_SANS_REGULAR_11px | BAGL_FONT_ALIGNMENT_CENTER, 0}, "WARNING", 0, 0, 0, NULL, NULL, NULL}, - {{BAGL_LABELINE, 0x02, 23, 26, 82, 12, 0, 0, 0, 0xFFFFFF, 0x000000, BAGL_FONT_OPEN_SANS_EXTRABOLD_11px | BAGL_FONT_ALIGNMENT_CENTER, 0}, "Custom Contract", 0, 0, 0, NULL, NULL, NULL}, - - {{BAGL_LABELINE, 0x03, 0, 12, 128, 32, 0, 0, 0, 0xFFFFFF, 0x000000, - BAGL_FONT_OPEN_SANS_REGULAR_11px | BAGL_FONT_ALIGNMENT_CENTER, 0}, - "Contract Address", + {{BAGL_LABEL, 0x00, 0, 87, 320, 32, 0, 0, 0, 0x000000, 0xF9F9F9, + BAGL_FONT_OPEN_SANS_LIGHT_14px | BAGL_FONT_ALIGNMENT_CENTER, 0}, + "Confirm ECDH Address:", 0, 0, 0, NULL, NULL, NULL}, - {{BAGL_LABELINE, 0x03, 12, 28, 104, 12, 0x00 | 10, 0, 0, 0xFFFFFF, 0x000000, - BAGL_FONT_OPEN_SANS_EXTRABOLD_11px | BAGL_FONT_ALIGNMENT_CENTER, 26}, - (char *)fullContract, + + {{BAGL_LABEL, 0x00, 0, 136, 320, 33, 0, 0, 0, 0x000000, 0xF9F9F9, + BAGL_FONT_OPEN_SANS_SEMIBOLD_11_16PX | BAGL_FONT_ALIGNMENT_CENTER, 0}, + (const char *)fromAddress, 0, 0, 0, @@ -3412,150 +1623,54 @@ const bagl_element_t ui_approval_custom_contract_nanos[] = { NULL, NULL}, - {{BAGL_LABELINE, 0x04, 0, 12, 128, 32, 0, 0, 0, 0xFFFFFF, 0x000000, - BAGL_FONT_OPEN_SANS_EXTRABOLD_11px | BAGL_FONT_ALIGNMENT_CENTER, 0}, - "Custom Selector", + {{BAGL_LABEL, 0x00, 0, 185, 320, 32, 0, 0, 0, 0x000000, 0xF9F9F9, + BAGL_FONT_OPEN_SANS_LIGHT_14px | BAGL_FONT_ALIGNMENT_CENTER, 0}, + "Shared with", 0, 0, 0, NULL, NULL, NULL}, - {{BAGL_LABELINE, 0x04, 23, 26, 82, 12, 0x80 | 10, 0, 0, 0xFFFFFF, 0x000000, - BAGL_FONT_OPEN_SANS_EXTRABOLD_11px | BAGL_FONT_ALIGNMENT_CENTER, 26}, - (char *)TRC20Action, - 0, - 0, - 0, - NULL, - NULL, - NULL}, - {{BAGL_LABELINE, 0x05, 0, 12, 128, 32, 0, 0, 0, 0xFFFFFF, 0x000000, - BAGL_FONT_OPEN_SANS_REGULAR_11px | BAGL_FONT_ALIGNMENT_CENTER, 0}, - "Token ID", + {{BAGL_LABEL, 0x00, 0, 234, 320, 33, 0, 0, 0, 0x000000, 0xF9F9F9, + BAGL_FONT_OPEN_SANS_SEMIBOLD_11_16PX | BAGL_FONT_ALIGNMENT_CENTER, 0}, + (const char *)toAddress, 0, 0, 0, NULL, NULL, NULL}, - {{BAGL_LABELINE, 0x05, 23, 26, 82, 12, 0x80 | 10, 0, 0, 0xFFFFFF, 0x000000, - BAGL_FONT_OPEN_SANS_EXTRABOLD_11px | BAGL_FONT_ALIGNMENT_CENTER, 26}, - (char *)toAddress, - 0, - 0, - 0, - NULL, - NULL, - NULL}, - - {{BAGL_LABELINE, 0x06, 0, 12, 128, 32, 0, 0, 0, 0xFFFFFF, 0x000000, - BAGL_FONT_OPEN_SANS_REGULAR_11px | BAGL_FONT_ALIGNMENT_CENTER, 0}, - "Call Amount", - 0, - 0, + + {{BAGL_BUTTON | BAGL_FLAG_TOUCHABLE, 0x00, 35, 385, 120, 40, 0, 6, + BAGL_FILL, 0xcccccc, COLOR_BG_1, + BAGL_FONT_OPEN_SANS_LIGHT_14px | BAGL_FONT_ALIGNMENT_CENTER | + BAGL_FONT_ALIGNMENT_MIDDLE, + 0}, + "CANCEL", 0, - NULL, + 0x37ae99, + COLOR_BG_1, + io_seproxyhal_touch_cancel, NULL, NULL}, - {{BAGL_LABELINE, 0x06, 23, 26, 82, 12, 0x80 | 10, 0, 0, 0xFFFFFF, 0x000000, - BAGL_FONT_OPEN_SANS_EXTRABOLD_11px | BAGL_FONT_ALIGNMENT_CENTER, 26}, - (char *)G_io_apdu_buffer, - 0, - 0, - 0, - NULL, - NULL, - NULL}, - - {{BAGL_LABELINE, 0x07, 0, 12, 128, 32, 0, 0, 0, 0xFFFFFF, 0x000000, - BAGL_FONT_OPEN_SANS_REGULAR_11px | BAGL_FONT_ALIGNMENT_CENTER, 0}, - "Send From", - 0, - 0, + {{BAGL_BUTTON | BAGL_FLAG_TOUCHABLE, 0x00, 165, 385, 120, 40, 0, 6, + BAGL_FILL, 0x41ccb4, COLOR_BG_1, + BAGL_FONT_OPEN_SANS_LIGHT_14px | BAGL_FONT_ALIGNMENT_CENTER | + BAGL_FONT_ALIGNMENT_MIDDLE, + 0}, + "CONFIRM", 0, - NULL, + 0x37ae99, + COLOR_BG_1, + io_seproxyhal_touch_ecdh_ok, NULL, NULL}, - {{BAGL_LABELINE, 0x07, 23, 26, 82, 12, 0x80 | 10, 0, 0, 0xFFFFFF, 0x000000, - BAGL_FONT_OPEN_SANS_EXTRABOLD_11px | BAGL_FONT_ALIGNMENT_CENTER, 26}, - (char *)fromAddress, - 0, - 0, - 0, - NULL, - NULL, - NULL}, }; -/* - ux_step 0: confirm - 1: amount - 2: address -*/ -unsigned int ui_approval_custom_contract_prepro(const bagl_element_t *element) { - unsigned int display = 1; - if (element->component.userid > 0) { - display = (ux_step == element->component.userid - 1); - if (display) { - switch (element->component.userid) { - case 0x01: - UX_CALLBACK_SET_INTERVAL(2000); - break; - case 2: - if (txContent.dataBytes>0) { - UX_CALLBACK_SET_INTERVAL(3000); - } - else { - display = 0; - ux_step++; // display the next step - } - break; - case 0x03: - case 0x04: - UX_CALLBACK_SET_INTERVAL(MAX( - 3000, - 1000 + bagl_label_roundtrip_duration_ms(element, 7))); - break; - case 0x05: - case 0x06: - if (customContractField&(1<component.userid)){ - UX_CALLBACK_SET_INTERVAL(3000); - } - else { - display = 0; - ux_step++; // display the next step - } - break; - case 0x07: - UX_CALLBACK_SET_INTERVAL(MAX( - 3000, - 1000 + bagl_label_roundtrip_duration_ms(element, 7))); - break; - } - } - } - return display; -} - -unsigned int ui_approval_custom_contract_nanos_button(unsigned int button_mask, - unsigned int button_mask_counter) { - switch (button_mask) { - case BUTTON_EVT_RELEASED | BUTTON_LEFT: - io_seproxyhal_touch_cancel(NULL); - break; - - case BUTTON_EVT_RELEASED | BUTTON_RIGHT: { - io_seproxyhal_touch_tx_ok(NULL); - break; - } - } - return 0; -} - -#endif // #if defined(TARGET_NANOS) && !defined(HAVE_UX_FLOW) +#endif // #if defined(TARGET_BLUE) #if defined(HAVE_UX_FLOW) @@ -4426,8 +2541,6 @@ void ui_idle(void) { ux_stack_push(); } ux_flow_init(0, ux_idle_flow, NULL); -#elif defined(TARGET_NANOS) - UX_MENU_DISPLAY(0, menu_main, NULL); #endif // #if TARGET_ID } @@ -4483,39 +2596,6 @@ unsigned int io_seproxyhal_touch_signMessage_ok(const bagl_element_t *e) { return 0; // do not redraw the widget } -#if defined(TARGET_NANOS) -unsigned int ui_address_nanos_button(unsigned int button_mask, - unsigned int button_mask_counter) { - switch (button_mask) { - case BUTTON_EVT_RELEASED | BUTTON_LEFT: // CANCEL - io_seproxyhal_touch_cancel(NULL); - break; - - case BUTTON_EVT_RELEASED | BUTTON_RIGHT: { // OK - io_seproxyhal_touch_address_ok(NULL); - break; - } - } - return 0; -} -#endif // #if defined(TARGET_NANOS) - -#if defined(TARGET_NANOS) -unsigned int ui_approval_simple_nanos_button(unsigned int button_mask, - unsigned int button_mask_counter) { - switch (button_mask) { - case BUTTON_EVT_RELEASED | BUTTON_LEFT: // CANCEL - io_seproxyhal_touch_cancel(NULL); - break; - - case BUTTON_EVT_RELEASED | BUTTON_RIGHT: { // OK - io_seproxyhal_touch_tx_ok(NULL); - break; - } - } - return 0; -} -#endif // #if defined(TARGET_NANOS) unsigned int io_seproxyhal_touch_tx_ok(const bagl_element_t *e) { uint32_t tx = 0; @@ -4653,10 +2733,6 @@ void handleGetPublicKey(uint8_t p1, uint8_t p2, uint8_t *dataBuffer, UX_DISPLAY(ui_address_blue, ui_address_blue_prepro); #elif defined(HAVE_UX_FLOW) ux_flow_init(0, ux_display_public_flow, NULL); -#elif defined(TARGET_NANOS) - ux_step = 0; - ux_step_count = 2; - UX_DISPLAY(ui_address_nanos, (bagl_element_callback_t) ui_address_prepro); #endif // #if TARGET *flags |= IO_ASYNCH_REPLY; @@ -4820,10 +2896,6 @@ void handleSign(uint8_t p1, uint8_t p2, uint8_t *workBuffer, ux_flow_init(0, ((txContent.dataBytes>0)? ux_approval_custom_contract_data_warning_flow : ux_approval_custom_contract_flow), NULL); - #elif defined(TARGET_NANOS) - ux_step = 0; - ux_step_count = 7; - UX_DISPLAY(ui_approval_custom_contract_nanos,(bagl_element_callback_t) ui_approval_custom_contract_prepro); #endif // #if TARGET_ID break; @@ -4849,10 +2921,6 @@ void handleSign(uint8_t p1, uint8_t p2, uint8_t *workBuffer, ux_flow_init(0, ((txContent.dataBytes>0)? ux_approval_tx_data_warning_flow : ux_approval_tx_flow), NULL); - #elif defined(TARGET_NANOS) - ux_step = 0; - ux_step_count = 7; - UX_DISPLAY(ui_approval_nanos,(bagl_element_callback_t) ui_approval_prepro); #endif // #if TARGET_ID break; @@ -4872,10 +2940,6 @@ void handleSign(uint8_t p1, uint8_t p2, uint8_t *workBuffer, ux_flow_init(0, ((txContent.dataBytes>0)? ux_approval_exchange_create_data_warning_flow : ux_approval_exchange_create_flow), NULL); - #elif defined(TARGET_NANOS) - ux_step = 0; - ux_step_count = 6; - UX_DISPLAY(ui_approval_exchange_nanos,(bagl_element_callback_t) ui_approval_exchange_prepro); #endif // #if TARGET_ID break; case EXCHANGEINJECTCONTRACT: @@ -4894,10 +2958,6 @@ void handleSign(uint8_t p1, uint8_t p2, uint8_t *workBuffer, ux_flow_init(0, ((txContent.dataBytes>0)? ux_approval_exchange_wi_data_warning_flow : ux_approval_exchange_wi_flow), NULL); - #elif defined(TARGET_NANOS) - ux_step = 0; - ux_step_count = 5; - UX_DISPLAY(ui_approval_exchange_withdraw_nanos,(bagl_element_callback_t) ui_approval_exchange_withdraw_prepro); #endif // #if TARGET_ID break; case EXCHANGETRANSACTIONCONTRACT: @@ -4917,10 +2977,6 @@ void handleSign(uint8_t p1, uint8_t p2, uint8_t *workBuffer, ux_flow_init(0, ((txContent.dataBytes>0)? ux_approval_exchange_transaction_data_warning_flow : ux_approval_exchange_transaction_flow), NULL); - #elif defined(TARGET_NANOS) - ux_step = 0; - ux_step_count = 6; - UX_DISPLAY(ui_approval_exchange_transaction_nanos, (bagl_element_callback_t)ui_approval_exchange_transaction_prepro); #endif // #if TARGET_ID break; case VOTEWITNESSCONTRACT: { @@ -4988,10 +3044,6 @@ void handleSign(uint8_t p1, uint8_t p2, uint8_t *workBuffer, ux_approval_vote_flow[step++] = &ux_approval_reject_step; ux_approval_vote_flow[step++] = FLOW_END_STEP; ux_flow_init(0, ux_approval_vote_flow, NULL); - #elif defined(TARGET_NANOS) - ux_step = 0; - ux_step_count = 7; - UX_DISPLAY(ui_approval_votes_transaction_nanos,(bagl_element_callback_t) ui_approval_votes_transaction_prepro); #endif // #if TARGET_ID } break; @@ -5016,10 +3068,6 @@ void handleSign(uint8_t p1, uint8_t p2, uint8_t *workBuffer, ux_flow_init(0, ((txContent.dataBytes>0)? ux_approval_freeze_data_warning_flow : ux_approval_freeze_flow), NULL); - #elif defined(TARGET_NANOS) - ux_step = 0; - ux_step_count = 5; - UX_DISPLAY(ui_approval_freeze_nanos,(bagl_element_callback_t) ui_approval_freeze_prepro); #endif // #if TARGET_ID break; case UNFREEZEBALANCECONTRACT: // unreeze TRX @@ -5042,8 +3090,6 @@ void handleSign(uint8_t p1, uint8_t p2, uint8_t *workBuffer, ux_flow_init(0, ((txContent.dataBytes>0)? ux_approval_unfreeze_data_warning_flow : ux_approval_unfreeze_flow), NULL); - #elif defined(TARGET_NANOS) - THROW(0x6B00); // not implemented #endif // #if TARGET_ID break; case WITHDRAWBALANCECONTRACT: // Claim Rewards @@ -5057,8 +3103,6 @@ void handleSign(uint8_t p1, uint8_t p2, uint8_t *workBuffer, ux_flow_init(0, ((txContent.dataBytes>0)? ux_approval_withdraw_balance_data_warning_flow : ux_approval_withdraw_balance_flow), NULL); - #elif defined(TARGET_NANOS) - THROW(0x6B00); // not implemented #endif // #if TARGET_ID break; case INVALID_CONTRACT: @@ -5077,10 +3121,6 @@ void handleSign(uint8_t p1, uint8_t p2, uint8_t *workBuffer, ux_flow_init(0, ((txContent.dataBytes>0)? ux_approval_st_data_warning_flow : ux_approval_st_flow), NULL); - #elif defined(TARGET_NANOS) - ux_step = 0; - ux_step_count = 4; - UX_DISPLAY(ui_approval_simple_nanos,(bagl_element_callback_t) ui_approval_simple_prepro); #endif // #if TARGET_ID break; } @@ -5170,10 +3210,6 @@ void handleECDHSecret(uint8_t p1, uint8_t p2, uint8_t *workBuffer, ux_stack_push(); } ux_flow_init(0, ux_approval_pgp_ecdh_flow, NULL); - #elif defined(TARGET_NANOS) - ux_step = 0; - ux_step_count = 3; - UX_DISPLAY(ui_approval_pgp_ecdh_nanos,(bagl_element_callback_t) ui_approval_pgp_ecdh_prepro); #endif *flags |= IO_ASYNCH_REPLY; @@ -5256,11 +3292,6 @@ void handleSignPersonalMessage(uint8_t p1, uint8_t p2, uint8_t *workBuffer, uint ui_approval_message_sign_blue_init(); #elif defined(HAVE_UX_FLOW) ux_flow_init(0, ux_sign_flow, NULL); - #elif defined(TARGET_NANOS) - ux_step = 0; - ux_step_count = 3; - UX_DISPLAY(ui_approval_signMessage_nanos, - (bagl_element_callback_t) ui_approval_signMessage_prepro); #endif *flags |= IO_ASYNCH_REPLY; @@ -5465,19 +3496,7 @@ unsigned char io_event(unsigned char channel) { break; case SEPROXYHAL_TAG_TICKER_EVENT: - UX_TICKER_EVENT(G_io_seproxyhal_spi_buffer, - { - #ifndef HAVE_UX_FLOW - if (UX_ALLOWED) { - if (ux_step_count) { - // prepare next screen - ux_step = (ux_step+1)%ux_step_count; - // redisplay screen - UX_REDISPLAY(); - } - } - #endif // HAVE_UX_FLOW - }); + UX_TICKER_EVENT(G_io_seproxyhal_spi_buffer,{}); break; }