Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix/LDG-599-enable-flex-stax-compilation #17

Merged
merged 3 commits into from
Dec 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/common/getPublicKey.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ UX_FLOW(ux_generate_public_flow, &ux_generate_public_flow_0_step, &ux_decline_st
UX_STEP_NOCB(ux_sign_compare_public_key_0_step,
bnnn_paging,
{.title = "Compare", .text = (char *) global.exportPublicKeyContext.publicKey});
UX_STEP_CB(ux_compare_accept_step, pb, ui_idle(), {&C_icon_validate_14, "Accept"});
UX_STEP_CB(ux_compare_decline_step, pb, ui_idle(), {&C_icon_crossmark, "Decline"});
UX_STEP_CB(ux_compare_accept_step, pb, ui_menu_main(), {&C_icon_validate_14, "Accept"});
UX_STEP_CB(ux_compare_decline_step, pb, ui_menu_main(), {&C_icon_crossmark, "Decline"});
UX_FLOW(ux_sign_compare_public_key,
&ux_sign_compare_public_key_0_step,
&ux_compare_accept_step,
Expand Down
100 changes: 57 additions & 43 deletions src/common/menu.c
Original file line number Diff line number Diff line change
@@ -1,54 +1,68 @@
#include "globals.h"
#include "util.h"
/*****************************************************************************
* Ledger App Concordium.
* (c) 2024 Concordium.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*****************************************************************************/

#ifdef HAVE_BAGL

#include "os.h"
#include "ux.h"
#include "glyphs.h"

#include "../globals.h"
#include "util.h"
#include "menu.h"

static tx_state_t *tx_state = &global_tx_state;
uint8_t appVersion[10];

/**
* Constructs the version in the format MAJOR.MINOR.PATCH. We only
* reserve 10 bytes to hold the version, so the maximum version
* supported is xx.yy.zzz.
*/
void loadVersion(uint8_t *version) {
int majorLength = numberToText(version, 2, APPVERSION_M);
version[majorLength] = '.';
int minorLength = numberToText(version + majorLength + 1, 2, APPVERSION_N);
version[majorLength + minorLength + 1] = '.';
numberToText(version + majorLength + minorLength + 2, 3, APPVERSION_P);
version[9] = '\0';
}

UX_STEP_NOCB(ux_menu_idle_flow_1_step,
bn,
{
APPNAME,
"is ready",
});
UX_STEP_CB(ux_menu_idle_flow_2_step,
pb,
os_sched_exit(-1),
{
&C_icon_dashboard_x,
"Quit",
});
UX_STEP_NOCB(ux_menu_idle_flow_3_step,
bn,
{
"Version",
(char *) appVersion,
});
UX_FLOW(ux_menu_idle_flow,
&ux_menu_idle_flow_1_step,
&ux_menu_idle_flow_2_step,
&ux_menu_idle_flow_3_step,
UX_STEP_NOCB(ux_menu_ready_step, pnn, {&C_app_concordium_16px, "Concordium", "is ready"});
UX_STEP_NOCB(ux_menu_version_step, bn, {"Version", APPVERSION});
UX_STEP_CB(ux_menu_about_step, pb, ui_menu_about(), {&C_icon_certificate, "About"});
UX_STEP_CB(ux_menu_exit_step, pb, os_sched_exit(-1), {&C_icon_dashboard_x, "Quit"});

// FLOW for the main menu:
// #1 screen: ready
// #2 screen: version of the app
// #3 screen: about submenu
// #4 screen: quit
UX_FLOW(ux_menu_main_flow,
&ux_menu_ready_step,
&ux_menu_version_step,
&ux_menu_about_step,
&ux_menu_exit_step,
FLOW_LOOP);

void ui_idle(void) {
void ui_menu_main() {
tx_state->currentInstruction = -1;
if (G_ux.stack_count == 0) {
ux_stack_push();
}
loadVersion(appVersion);
ux_flow_init(0, ux_menu_idle_flow, NULL);

ux_flow_init(0, ux_menu_main_flow, NULL);
}

UX_STEP_NOCB(ux_menu_info_step, bn, {"Concordium App", "(c) 2024 Concordium"});
UX_STEP_CB(ux_menu_back_step, pb, ui_menu_main(), {&C_icon_back, "Back"});

// FLOW for the about submenu:
// #1 screen: app info
// #2 screen: back button to main menu
UX_FLOW(ux_menu_about_flow, &ux_menu_info_step, &ux_menu_back_step, FLOW_LOOP);

void ui_menu_about() {
ux_flow_init(0, ux_menu_about_flow, NULL);
}

#endif
15 changes: 7 additions & 8 deletions src/common/menu.h
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
#ifndef _MENU_H_
#define _MENU_H_
#pragma once

/**
* Initialize the Concordium idle menu and display it to the
* user of the application. This should always be called at the
* end of a successful command flow to reset the display and state
* correctly.
* Show main menu (ready screen, version, about, quit).
*/
void ui_idle(void);
void ui_menu_main(void);

#endif
/**
* Show about submenu (copyright, date).
*/
void ui_menu_about(void);
4 changes: 2 additions & 2 deletions src/common/util.c
Original file line number Diff line number Diff line change
Expand Up @@ -119,14 +119,14 @@ void sendUserRejection() {
G_io_apdu_buffer[0] = ERROR_REJECTED_BY_USER >> 8;
G_io_apdu_buffer[1] = ERROR_REJECTED_BY_USER & 0xFF;
io_exchange(CHANNEL_APDU | IO_RETURN_AFTER_TX, 2);
ui_idle();
ui_menu_main();
}

void sendSuccess(uint8_t tx) {
G_io_apdu_buffer[tx++] = SUCCESS >> 8;
G_io_apdu_buffer[tx++] = SUCCESS & 0xFF;
io_exchange(CHANNEL_APDU | IO_RETURN_AFTER_TX, tx);
ui_idle();
ui_menu_main();
}

void sendSuccessNoIdle() {
Expand Down
2 changes: 1 addition & 1 deletion src/common/util.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ static const uint8_t r[32] = {0x73, 0xed, 0xa7, 0x53, 0x29, 0x9d, 0x7d, 0x48, 0x
* Converts bytes into uint64_t (big endian).
*/
#define U8BE(buf, off) \
(((uint64_t)(U4BE(buf, off)) << 32) | ((uint64_t) (U4BE(buf, off + 4)) & 0xFFFFFFFF))
(((uint64_t)(U4BE(buf, off)) << 32) | ((uint64_t)(U4BE(buf, off + 4)) & 0xFFFFFFFF))

/**
* Send a user rejection back to the caller, which will indicate to
Expand Down
2 changes: 1 addition & 1 deletion src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ __attribute__((section(".boot"))) int main(void) {

USB_power(0);
USB_power(1);
ui_idle();
ui_menu_main();

#if defined(HAVE_BLE)
BLE_power(0, NULL);
Expand Down
Binary file modified tests/snapshots/nanosp/test_app_mainmenu/00000.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/snapshots/nanosp/test_app_mainmenu/00001.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/snapshots/nanosp/test_app_mainmenu/00002.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/snapshots/nanosp/test_app_mainmenu/00003.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/snapshots/nanox/test_app_mainmenu/00000.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/snapshots/nanox/test_app_mainmenu/00001.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/snapshots/nanox/test_app_mainmenu/00002.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/snapshots/nanox/test_app_mainmenu/00003.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 1 addition & 2 deletions tests/test_pubkey_cmd.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,7 @@ def test_get_signed_legacy_governance_public_key_confirm_accepted(


# In this test we check that the GET_PUBLIC_KEY works in confirmation mode
@pytest.mark.active_test_scope
def test_get_legacy_public_key_confirm_accepted(
def test_get_legacy_public_key_confirm_accepted_2(
backend, navigator, firmware, default_screenshot_path, test_name
):
client = BoilerplateCommandSender(backend)
Expand Down
Loading