Now has a separate struct for caller app name & icon

- New home screen wording
- Removed duplicate RUN_APPLICATION macro
This commit is contained in:
Alexandre Paillier
2023-03-20 10:27:19 +01:00
parent 0414a043c8
commit 8361e349b7
19 changed files with 103 additions and 93 deletions

View File

@@ -188,7 +188,7 @@ static void reviewContinueCommon(void) {
useCaseTagValueList.nbPairs = nbPairs; ///< number of pairs in pairs array
useCaseTagValueList.smallCaseForValue = false;
useCaseTagValueList.wrapping = false;
infoLongPress.icon = get_app_chain_icon();
infoLongPress.icon = get_app_icon(true);
infoLongPress.text = tx_approval_context.fromPlugin ? transaction_type : "Review transaction";
infoLongPress.longPressText = "Hold to sign";
nbgl_useCaseStaticReview(&useCaseTagValueList,
@@ -204,14 +204,14 @@ static void buildFirstPage(void) {
"Review %s\ntransaction:\n%s",
strings.common.fullAddress,
strings.common.fullAmount);
nbgl_useCaseReviewStart(get_app_chain_icon(),
nbgl_useCaseReviewStart(get_app_icon(true),
transaction_type,
NULL,
"Reject transaction",
reviewContinue,
rejectTransactionQuestion);
} else {
nbgl_useCaseReviewStart(get_app_chain_icon(),
nbgl_useCaseReviewStart(get_app_icon(true),
"Review transaction",
NULL,
"Reject transaction",

View File

@@ -28,7 +28,7 @@ static bool displayTransactionPage(uint8_t page, nbgl_pageContent_t *content) {
content->tagValueList.nbPairs = 1;
content->tagValueList.pairs = (nbgl_layoutTagValue_t *) &tlv;
} else if (page == 1) {
content->type = INFO_LONG_PRESS, content->infoLongPress.icon = get_app_chain_icon();
content->type = INFO_LONG_PRESS, content->infoLongPress.icon = get_app_icon(true);
content->infoLongPress.text = "Confirm parameter";
content->infoLongPress.longPressText = "Hold to confirm";
} else {
@@ -43,7 +43,7 @@ static void reviewContinue(void) {
}
static void buildScreen(void) {
nbgl_useCaseReviewStart(get_app_chain_icon(),
nbgl_useCaseReviewStart(get_app_icon(true),
"Verify parameter",
NULL,
"Reject",

View File

@@ -28,7 +28,7 @@ static bool displayTransactionPage(uint8_t page, nbgl_pageContent_t *content) {
content->tagValueList.nbPairs = 1;
content->tagValueList.pairs = (nbgl_layoutTagValue_t *) &tlv;
} else if (page == 1) {
content->type = INFO_LONG_PRESS, content->infoLongPress.icon = get_app_chain_icon();
content->type = INFO_LONG_PRESS, content->infoLongPress.icon = get_app_icon(true);
content->infoLongPress.text = "Confirm selector";
content->infoLongPress.longPressText = "Hold to confirm";
} else {
@@ -43,7 +43,7 @@ static void reviewContinue(void) {
}
static void buildScreen(void) {
nbgl_useCaseReviewStart(get_app_chain_icon(),
nbgl_useCaseReviewStart(get_app_icon(true),
"Verify selector",
NULL,
"Reject",

View File

@@ -34,7 +34,7 @@ static bool displayTransactionPage(uint8_t page, nbgl_pageContent_t *content) {
content->tagValueList.nbPairs = 2;
content->tagValueList.pairs = (nbgl_layoutTagValue_t *) tlv;
} else if (page == 1) {
content->type = INFO_LONG_PRESS, content->infoLongPress.icon = get_app_chain_icon();
content->type = INFO_LONG_PRESS, content->infoLongPress.icon = get_app_icon(true);
content->infoLongPress.text = review_string;
content->infoLongPress.longPressText = "Hold to approve";
} else {
@@ -49,7 +49,7 @@ static void reviewContinue(void) {
}
static void buildFirstPage(void) {
nbgl_useCaseReviewStart(get_app_chain_icon(),
nbgl_useCaseReviewStart(get_app_icon(true),
review_string,
NULL,
"Reject",

View File

@@ -5,9 +5,10 @@
#include "glyphs.h"
#include "network.h"
uint8_t staxSharedBuffer[SHARED_BUFFER_SIZE] = {0};
char staxSharedBuffer[SHARED_BUFFER_SIZE] = {0};
nbgl_page_t *pageContext;
nbgl_page_t* pageContext;
#define FORMAT_PLUGIN "This app enables clear\nsigning transactions for\nthe %s dApp."
void releaseContext(void) {
if (pageContext != NULL) {
@@ -15,47 +16,44 @@ void releaseContext(void) {
pageContext = NULL;
}
}
enum { BACK_TOKEN = 0, INFO_TOKEN, NEXT_TOKEN, CANCEL_TOKEN, QUIT_INFO_TOKEN, QUIT_APP_TOKEN };
void app_quit(void) {
// exit app here
os_sched_exit(-1);
}
void ui_idle(void) {
if (plugin_name != NULL) { // plugin
nbgl_useCasePlugInHome((char*) plugin_name,
APPNAME,
&ICONGLYPH_SMALL,
NULL,
NULL,
true,
ui_menu_settings,
app_quit);
} else {
char* app_name = (char*) get_app_network_name();
const nbgl_icon_details_t *get_app_icon(bool caller_icon) {
const nbgl_icon_details_t *icon = NULL;
switch (get_app_chain_id()) {
// Standalone apps
case 1: // Mainnet
case 3: // Ropsten
case 5: // Goerli
nbgl_useCaseHome(app_name,
get_app_chain_icon(),
NULL,
true,
ui_menu_settings,
app_quit);
break;
// Clones
default:
nbgl_useCaseHome(app_name,
get_app_chain_icon(),
NULL,
true,
ui_menu_settings,
app_quit);
break;
if (caller_icon && caller_app) {
if (caller_app->icon) {
icon = caller_app->icon;
}
} else {
icon = &ICONGLYPH;
}
return icon;
}
void ui_idle(void) {
const char *app_name = NULL;
const char *tagline = NULL;
if (caller_app) {
app_name = caller_app->name;
if (caller_app->type == CALLER_TYPE_PLUGIN) {
snprintf(staxSharedBuffer, sizeof(staxSharedBuffer), FORMAT_PLUGIN, app_name);
tagline = staxSharedBuffer;
}
} else { // Ethereum app
app_name = get_app_network_name();
}
nbgl_useCaseHome((char *) app_name,
get_app_icon(true),
tagline,
true,
ui_menu_settings,
app_quit);
}

View File

@@ -6,14 +6,16 @@
#include <shared_context.h>
#define SHARED_BUFFER_SIZE SHARED_CTX_FIELD_1_SIZE
extern uint8_t staxSharedBuffer[SHARED_BUFFER_SIZE];
extern char staxSharedBuffer[SHARED_BUFFER_SIZE];
extern nbgl_page_t* pageContext;
void releaseContext(void);
const nbgl_icon_details_t* get_app_icon(bool caller_icon);
void ui_idle(void);
void ui_menu_settings(void);
void ui_menu_about(void);
#endif // _UI_NBGL_H_
#endif // _UI_NBGL_H_

View File

@@ -25,7 +25,7 @@ static void reviewChoice(bool confirm) {
}
static bool displaySignPage(uint8_t page, nbgl_pageContent_t *content) {
(void) page;
content->type = INFO_LONG_PRESS, content->infoLongPress.icon = get_app_chain_icon();
content->type = INFO_LONG_PRESS, content->infoLongPress.icon = get_app_icon(true);
content->infoLongPress.text = "Sign typed message";
content->infoLongPress.longPressText = "Hold to sign";
return true;

View File

@@ -39,7 +39,7 @@ static bool displayTransactionPage(uint8_t page, nbgl_pageContent_t *content) {
content->tagValueList.nbPairs = 2;
content->tagValueList.pairs = (nbgl_layoutTagValue_t *) tlv;
} else if (page == 1) {
content->type = INFO_LONG_PRESS, content->infoLongPress.icon = get_app_chain_icon();
content->type = INFO_LONG_PRESS, content->infoLongPress.icon = get_app_icon(true);
content->infoLongPress.text = "Sign typed message";
content->infoLongPress.longPressText = "Hold to sign";
} else {

View File

@@ -37,7 +37,7 @@ static bool displayTransactionPage(uint8_t page, nbgl_pageContent_t *content) {
content->tagValueList.nbPairs = 3;
content->tagValueList.pairs = (nbgl_layoutTagValue_t *) tlv;
} else if (page == 1) {
content->type = INFO_LONG_PRESS, content->infoLongPress.icon = get_app_chain_icon();
content->type = INFO_LONG_PRESS, content->infoLongPress.icon = get_app_icon(false);
content->infoLongPress.text = "Review stark limit order";
content->infoLongPress.longPressText = "Hold to sign";
} else {
@@ -52,7 +52,7 @@ static void reviewContinue(void) {
}
static void buildFirstPage(void) {
nbgl_useCaseReviewStart(get_app_chain_icon(),
nbgl_useCaseReviewStart(get_app_icon(false),
"Review stark limit order",
NULL,
"Reject",
@@ -64,4 +64,4 @@ void ui_stark_limit_order(void) {
buildFirstPage();
}
#endif
#endif

View File

@@ -82,7 +82,7 @@ static bool displayTransactionPage(uint8_t page, nbgl_pageContent_t *content) {
}
}
if (page == 2) {
content->type = INFO_LONG_PRESS, content->infoLongPress.icon = get_app_chain_icon();
content->type = INFO_LONG_PRESS, content->infoLongPress.icon = get_app_icon(false);
content->infoLongPress.text = "Review transaction";
content->infoLongPress.longPressText = "Hold to sign";
}
@@ -116,7 +116,7 @@ void ui_stark_transfer(bool selfTransfer, bool conditional) {
subTitle = "Transfer";
}
}
nbgl_useCaseReviewStart(get_app_chain_icon(),
nbgl_useCaseReviewStart(get_app_icon(false),
"Review stark transaction",
subTitle,
"Reject",

View File

@@ -40,7 +40,7 @@ static bool displayTransactionPage(uint8_t page, nbgl_pageContent_t *content) {
content->tagValueList.nbPairs = 2;
content->tagValueList.pairs = (nbgl_layoutTagValue_t *) tlv;
} else if (page == 1) {
content->type = INFO_LONG_PRESS, content->infoLongPress.icon = get_app_chain_icon();
content->type = INFO_LONG_PRESS, content->infoLongPress.icon = get_app_icon(false);
content->infoLongPress.text = "Unsafe Stark Sign";
content->infoLongPress.longPressText = "Hold to sign";
} else {
@@ -55,7 +55,7 @@ static void reviewContinue(void) {
}
static void buildFirstPage(void) {
nbgl_useCaseReviewStart(get_app_chain_icon(),
nbgl_useCaseReviewStart(get_app_icon(false),
"Unsafe Stark Sign",
NULL,
"Reject",
@@ -67,4 +67,4 @@ void ui_stark_unsafe_sign(void) {
buildFirstPage();
}
#endif // HAVE_STARKWARE
#endif // HAVE_STARKWARE