Skip to content

Commit

Permalink
add the code part related to the demo variant
Browse files Browse the repository at this point in the history
  • Loading branch information
tdejoigny-ledger committed Oct 21, 2024
1 parent b027399 commit fca118a
Show file tree
Hide file tree
Showing 83 changed files with 408 additions and 45 deletions.
12 changes: 10 additions & 2 deletions .github/workflows/build_and_functional_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,23 @@ on:
pull_request:

jobs:
build_application:
build_application_nbgl_test:
name: Build application using the reusable workflow
uses: LedgerHQ/ledger-app-workflows/.github/workflows/reusable_build.yml@v1
with:
upload_app_binaries_artifact: "compiled_app_binaries"
flags: "COIN=nbgl_test"

build_application:
name: Build application using the reusable workflow
uses: LedgerHQ/ledger-app-workflows/.github/workflows/reusable_build.yml@v1
with:
upload_app_binaries_artifact: "compiled_app_binaries_demo"
flags: "COIN=demo"

ragger_tests:
name: Run ragger tests using the reusable workflow
needs: build_application
needs: build_application_nbgl_test
uses: LedgerHQ/ledger-app-workflows/.github/workflows/reusable_ragger_tests.yml@v1
with:
download_app_binaries_artifact: "compiled_app_binaries"
Expand Down
22 changes: 0 additions & 22 deletions .vscode/settings.json

This file was deleted.

38 changes: 28 additions & 10 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@ include $(BOLOS_SDK)/Makefile.defines
########################################
# Mandatory configuration #
########################################
# Application name
APPNAME = "NBGL Tests"

# Application version
APPVERSION_M = 1
Expand All @@ -39,13 +37,6 @@ APPVERSION = "$(APPVERSION_M).$(APPVERSION_N).$(APPVERSION_P)"
# Application source files
APP_SOURCE_PATH += src

# Application icons following guidelines:
# https://developers.ledger.com/docs/embedded-app/design-requirements/#device-icon
ICON_NANOX = icons/app_nbgl_tests_14px.png
ICON_NANOSP = icons/app_nbgl_tests_14px.png
ICON_STAX = icons/app_nbgl_tests_32px.png
ICON_FLEX = icons/app_nbgl_tests_40px.png

# Application allowed derivation curves.
# Possibles curves are: secp256k1, secp256r1, ed25519 and bls12381g1
# If your app needs it, you can specify multiple curves by using:
Expand All @@ -68,7 +59,34 @@ PATH_APP_LOAD_PARAMS = "44'/1'" # purpose=coin(44) / coin_type=Testnet(1)
# * It must at least contains one value.
# * Values can be the app ticker or anything else but should be unique.
VARIANT_PARAM = COIN
VARIANT_VALUES = NBT
VARIANT_VALUES = nbgl_test demo

# Application icons following guidelines:
# https://developers.ledger.com/docs/embedded-app/design-requirements/#device-icon
ICON_NANOX = icons/app_nbgl_tests_14px.png
ICON_NANOSP = icons/app_nbgl_tests_14px.png

ifeq ($(COIN),nbgl_test)
ICON_STAX = icons/app_nbgl_tests_32px.png
ICON_FLEX = icons/app_nbgl_tests_40px.png
else
ICON_STAX = icons/app_demo_32px.png
ICON_FLEX = icons/app_demo_40px.png
endif

APP_DEMO_TYPE=0
APP_NBGL_TYPE=1
DEFINES +=APP_DEMO_TYPE
DEFINES +=APP_NBGL_TYPE
ifeq ($(COIN),nbgl_test)
# NBGL Test app
APPNAME = "NBGL Tests"
DEFINES +=APP_TYPE=$(APP_DEMO_TYPE)
else
# Demo app
APPNAME = "Ledger Demo"
DEFINES +=APP_TYPE=$(APP_NBGL_TYPE)
endif

# Enabling DEBUG flag will enable PRINTF and disable optimizations
#DEBUG = 1
Expand Down
Binary file added glyphs/app_demo_64px.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 added glyphs/bitcoin_64px.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added glyphs/ethereum_64px.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added glyphs/info_button_64px.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 added glyphs/polygon_64px.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added glyphs/solana_64px.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added icons/app_demo_32px.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 added icons/app_demo_40px.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 6 additions & 1 deletion src/ui/display.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
/**
* Show main menu (ready screen, version, about, quit).
*/
void ui_menu_main(void);
void ui_menu_main();
void ui_display_demo_list();
int ui_display_review(bool is_blind_signed);
int ui_display_address_review();
int ui_display_long_address_review();
Expand All @@ -14,3 +15,7 @@ int ui_display_long_address_review_with_tags();
int ui_display_spinner();
int ui_display_static_review();
int ui_display_light_review();
int ui_display_BTC_review();
int ui_display_SOL_address_review();
int ui_display_BS_staking_review();
int ui_display_swap_review();
6 changes: 5 additions & 1 deletion src/ui/menu.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@
#define LARGE_ICON C_app_nbgl_tests_16px
#define LARGE_WARNING_ICON C_icon_warning
#else
#define LARGE_ICON C_app_nbgl_tests_64px
#if (APP_TYPE == APP_DEMO_TYPE)
#define LARGE_ICON C_app_demo_64px
#else
#define LARGE_ICON C_app_nbgl_tests_64px
#endif
#define LARGE_WARNING_ICON C_Warning_64px
#endif
117 changes: 108 additions & 9 deletions src/ui/menu_nbgl.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,18 +26,15 @@
#include "globals.h"
#include "menu.h"

// -----------------------------------------------------------
// ----------------------- HOME PAGE -------------------------
// -----------------------------------------------------------

void app_quit(void) {
// exit app here
os_sched_exit(-1);
}

// -----------------------------------------------------------
// --------------------- SETTINGS MENU -----------------------
// --------------- NBGL TEST HOME PAGE -----------------------
// -----------------------------------------------------------

#define SETTING_INFO_NB 4
static const char* const INFO_TYPES[SETTING_INFO_NB] = {"Version",
"Developer",
Expand All @@ -62,6 +59,7 @@ static const nbgl_contentInfoList_t infoList = {
};

static uint8_t initSettingPage;
static nbgl_homeAction_t homeAction;
static void review_warning_choice(bool confirm);
static void controls_callback(int token, uint8_t index, int page);

Expand Down Expand Up @@ -95,7 +93,7 @@ static void review_warning_choice(bool confirm) {
initSettingPage,
&settingContents,
&infoList,
NULL,
&homeAction,
app_quit);
}

Expand Down Expand Up @@ -135,9 +133,8 @@ static void controls_callback(int token, uint8_t index, int page) {
}
}

static nbgl_homeAction_t homeAction;
// home page definition
void ui_menu_main(void) {
void ui_menu_main_nbgl_test(void) {
// Initialize switches data
switches[DUMMY_SWITCH_1_ID].initState = (nbgl_state_t) N_storage.dummy1_allowed;
switches[DUMMY_SWITCH_1_ID].text = "Dummy 1";
Expand All @@ -155,7 +152,7 @@ void ui_menu_main(void) {
switches[DUMMY_SWITCH_2_ID].tuneId = TUNE_TAP_CASUAL;
#endif

homeAction.callback = (nbgl_callback_t) ui_display_address_review;
homeAction.callback = (nbgl_callback_t) ui_display_demo_list;
homeAction.icon = NULL;
homeAction.text = "Display flows";
nbgl_useCaseHomeAndSettings(APPNAME,
Expand All @@ -168,4 +165,106 @@ void ui_menu_main(void) {
app_quit);
}

// -----------------------------------------------------------
// -------------------- DEMO HOME PAGE -----------------------
// -----------------------------------------------------------

#define SETTING_DEMO_INFO_NB 2
static const char* const INFO_TYPES_DEMO[SETTING_DEMO_INFO_NB] = {"Version", "Developer"};

static const char* const INFO_CONTENTS_DEMO[SETTING_DEMO_INFO_NB] = {APPVERSION, "Ledger"};

static const nbgl_contentInfoList_t infoListDemo = {
.nbInfos = SETTING_DEMO_INFO_NB,
.infoTypes = INFO_TYPES_DEMO,
.infoContents = INFO_CONTENTS_DEMO,
};

static nbgl_homeAction_t homeActionDemo;
// home page definition
void ui_menu_main_demo(void) {
homeActionDemo.callback = (nbgl_callback_t) ui_display_demo_list;
homeActionDemo.icon = NULL;
homeActionDemo.text = "View demos";
nbgl_useCaseHomeAndSettings(APPNAME,
&LARGE_ICON,
"Showcase transactions and\n"
"address verification, without\n"
"spending.",
INIT_HOME_PAGE,
NULL,
&infoListDemo,
&homeActionDemo,
app_quit);
}

// -----------------------------------------------------------
// -------------------- DEMO FLOW LIST -----------------------
// -----------------------------------------------------------

// demo flow
#define DEMO_FLOW_NB 4

enum {
BTC_SEND_REVIEW_TOKEN = FIRST_USER_TOKEN,
SWAP_1INCH_REVIEW_TOKEN,
STAKE_BLIND_SIGNING_REVIEW_TOKEN,
SOL_ADDRESS_REVIEW_TOKEN
};

static const char* const barTexts[DEMO_FLOW_NB] = {"Send bitcoin",
"Swap with 1inch",
"Stake with unknown dApp",
"Receive SOL"};

static const uint8_t tokens[DEMO_FLOW_NB] = {BTC_SEND_REVIEW_TOKEN,
SWAP_1INCH_REVIEW_TOKEN,
STAKE_BLIND_SIGNING_REVIEW_TOKEN,
SOL_ADDRESS_REVIEW_TOKEN};

static void demo_control_cb(int token, uint8_t index) {
UNUSED(index);
switch (token) {
case BTC_SEND_REVIEW_TOKEN:
ui_display_BTC_review();
break;
case SWAP_1INCH_REVIEW_TOKEN:
ui_display_swap_review();
break;
case STAKE_BLIND_SIGNING_REVIEW_TOKEN:
ui_display_BS_staking_review();
break;
case SOL_ADDRESS_REVIEW_TOKEN:
ui_display_SOL_address_review();
break;
default:
PRINTF("Should not happen !");
break;
}
}

static bool nav_callback(uint8_t page, nbgl_pageContent_t* content) {
UNUSED(page);
content->tuneId = NBGL_NO_TUNE;
content->type = BARS_LIST;
content->barsList.barTexts = barTexts;
content->barsList.tokens = tokens;
content->barsList.nbBars = DEMO_FLOW_NB;
content->barsList.tuneId = TUNE_TAP_CASUAL;

return true;
}

// display the list of demo flows
void ui_display_demo_list(void) {
nbgl_useCaseNavigableContent("Select demo", 0, 1, ui_menu_main, nav_callback, demo_control_cb);
}

void ui_menu_main(void) {
if (APP_TYPE == APP_DEMO_TYPE) {
ui_menu_main_demo();
} else {
ui_menu_main_nbgl_test();
}
}
#endif
Loading

0 comments on commit fca118a

Please sign in to comment.