Unified nbgl layoutTagValue variable naming

This commit is contained in:
Alexandre Paillier
2023-04-07 11:29:27 +02:00
parent cb7334ceed
commit e0bb1225fe
7 changed files with 66 additions and 66 deletions

View File

@@ -15,7 +15,7 @@ enum {
START_REVIEW_TOKEN,
};
static nbgl_layoutTagValue_t tlv;
static nbgl_layoutTagValue_t pair;
// these buffers are used as circular
static char title_buffer[MAX_PLUGIN_ITEMS_PER_SCREEN][TAG_MAX_LEN];
static char msg_buffer[MAX_PLUGIN_ITEMS_PER_SCREEN][VALUE_MAX_LEN];
@@ -74,17 +74,17 @@ static nbgl_layoutTagValue_t *getTagValuePair(uint8_t pairIndex) {
TAG_MAX_LEN,
(uint8_t *) msg_buffer[counter],
VALUE_MAX_LEN);
tlv.item = title_buffer[counter];
tlv.value = msg_buffer[counter];
pair.item = title_buffer[counter];
pair.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;
pair.item = "Network";
pair.value = strings.common.network_name;
} else {
tlv.item = "Max fees";
tlv.value = strings.common.maxFee;
pair.item = "Max fees";
pair.value = strings.common.maxFee;
}
}
} else {
@@ -95,24 +95,24 @@ static nbgl_layoutTagValue_t *getTagValuePair(uint8_t pairIndex) {
switch (pairIndex) {
case 0:
tlv.item = "Amount";
tlv.value = strings.common.fullAmount;
pair.item = "Amount";
pair.value = strings.common.fullAmount;
break;
case 1:
tlv.item = "Address";
tlv.value = strings.common.fullAddress;
pair.item = "Address";
pair.value = strings.common.fullAddress;
break;
case 2:
tlv.item = "Nonce";
tlv.value = strings.common.nonce;
pair.item = "Nonce";
pair.value = strings.common.nonce;
break;
case 3:
tlv.item = "Max fees";
tlv.value = strings.common.maxFee;
pair.item = "Max fees";
pair.value = strings.common.maxFee;
break;
case 4:
tlv.item = "Network";
tlv.value = strings.common.network_name;
pair.item = "Network";
pair.value = strings.common.network_name;
break;
}
}
@@ -121,7 +121,7 @@ static nbgl_layoutTagValue_t *getTagValuePair(uint8_t pairIndex) {
if (counter == MAX_PLUGIN_ITEMS_PER_SCREEN) {
counter = 0;
}
return &tlv;
return &pair;
}
static void pageCallback(int token, uint8_t index) {

View File

@@ -4,7 +4,7 @@
#include "nbgl_use_case.h"
#include "network.h"
static nbgl_layoutTagValue_t tlv[2];
static nbgl_layoutTagValue_t pairs[2];
static char *review_string;
static void reviewReject(void) {
@@ -25,14 +25,14 @@ static void reviewChoice(bool confirm) {
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;
pairs[0].item = "Address";
pairs[0].value = strings.common.fullAddress;
pairs[1].item = "Key";
pairs[1].value = strings.common.fullAmount;
content->type = TAG_VALUE_LIST;
content->tagValueList.nbPairs = 2;
content->tagValueList.pairs = (nbgl_layoutTagValue_t *) tlv;
content->tagValueList.pairs = (nbgl_layoutTagValue_t *) pairs;
} else if (page == 1) {
content->type = INFO_LONG_PRESS, content->infoLongPress.icon = get_app_icon(true);
content->infoLongPress.text = review_string;

View File

@@ -7,7 +7,7 @@ static const char* const infoContents[] = {APPVERSION, "(c) 2022 Ledger"};
enum { BLIND_SIGNING_TOKEN = FIRST_USER_TOKEN, DEBUG_TOKEN, NONCE_TOKEN, EIP712_VERBOSE_TOKEN };
static nbgl_layoutSwitch_t switches[4];
static nbgl_layoutSwitch_t switches[3];
static bool navCallback(uint8_t page, nbgl_pageContent_t* content) {
switch (page) {

View File

@@ -5,7 +5,7 @@
#include "ethUtils.h"
#include "ui_712_common.h"
static nbgl_layoutTagValue_t tlv[2];
static nbgl_layoutTagValue_t pairs[2];
static void start_review(void); // forward declaration
@@ -16,21 +16,21 @@ static char *format_hash(const uint8_t *hash, char *buffer, size_t buffer_size,
static bool display_review_page(uint8_t page, nbgl_pageContent_t *content) {
if (page == 0) {
tlv[0].item = "Domain hash";
tlv[0].value = format_hash(tmpCtx.messageSigningContext712.domainHash,
strings.tmp.tmp,
sizeof(strings.tmp.tmp),
0);
tlv[1].item = "Message hash";
tlv[1].value = format_hash(tmpCtx.messageSigningContext712.messageHash,
strings.tmp.tmp,
sizeof(strings.tmp.tmp),
70);
pairs[0].item = "Domain hash";
pairs[0].value = format_hash(tmpCtx.messageSigningContext712.domainHash,
strings.tmp.tmp,
sizeof(strings.tmp.tmp),
0);
pairs[1].item = "Message hash";
pairs[1].value = format_hash(tmpCtx.messageSigningContext712.messageHash,
strings.tmp.tmp,
sizeof(strings.tmp.tmp),
70);
content->type = TAG_VALUE_LIST;
content->tagValueList.nbPairs = 2;
content->tagValueList.nbMaxLinesForValue = 0;
content->tagValueList.pairs = (nbgl_layoutTagValue_t *) tlv;
content->tagValueList.pairs = (nbgl_layoutTagValue_t *) pairs;
} else if (page == 1) {
content->type = INFO_LONG_PRESS, content->infoLongPress.icon = get_app_icon(true);
content->infoLongPress.text = "Sign typed message";

View File

@@ -6,7 +6,7 @@
#ifdef HAVE_STARKWARE
static nbgl_layoutTagValue_t tlv[3];
static nbgl_layoutTagValue_t pairs[3];
static void reviewReject(void) {
io_seproxyhal_touch_tx_cancel(NULL);
@@ -26,16 +26,16 @@ static void reviewChoice(bool confirm) {
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;
pairs[0].item = "Sell";
pairs[0].value = strings.common.fullAmount;
pairs[1].item = "Buy";
pairs[1].value = strings.common.maxFee;
pairs[2].item = "Token amount";
pairs[2].value = strings.common.fullAddress;
content->type = TAG_VALUE_LIST;
content->tagValueList.nbPairs = 3;
content->tagValueList.pairs = (nbgl_layoutTagValue_t *) tlv;
content->tagValueList.pairs = (nbgl_layoutTagValue_t *) pairs;
} else if (page == 1) {
content->type = INFO_LONG_PRESS, content->infoLongPress.icon = get_app_icon(false);
content->infoLongPress.text = "Review stark limit order";

View File

@@ -8,7 +8,7 @@
#ifdef HAVE_STARKWARE
static nbgl_layoutTagValue_t tlv[3];
static nbgl_layoutTagValue_t pairs[3];
static char condAddressBuffer[43];
struct stark_transfer_context {
bool selfTransfer;
@@ -36,26 +36,26 @@ static void reviewChoice(bool confirm) {
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;
pairs[count].item = "Amount";
pairs[count].value = tmpContent.tmp;
count++;
if (context.selfTransfer == false && context.conditional == false) {
tlv[count].item = "Master Account";
tlv[count].value = strings.tmp.tmp;
pairs[count].item = "Master Account";
pairs[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;
pairs[count].item = "Master Account";
pairs[count].value = strings.tmp.tmp;
count++;
}
tlv[count].item = "Token Account";
tlv[count].value = strings.tmp.tmp2;
pairs[count].item = "Token Account";
pairs[count].value = strings.tmp.tmp2;
content->type = TAG_VALUE_LIST;
content->tagValueList.nbPairs = count;
content->tagValueList.pairs = (nbgl_layoutTagValue_t *) tlv;
content->tagValueList.pairs = (nbgl_layoutTagValue_t *) pairs;
return true;
}
@@ -66,16 +66,16 @@ static bool displayTransactionPage(uint8_t page, nbgl_pageContent_t *content) {
sizeof(condAddressBuffer),
&global_sha3,
chainConfig->chainId),
tlv[0].item = "Cond. Address";
tlv[0].value = condAddressBuffer;
pairs[0].item = "Cond. Address";
pairs[0].value = condAddressBuffer;
stark_sign_display_condition_fact();
tlv[1].item = "Cond. Address";
tlv[1].value = strings.tmp.tmp;
pairs[1].item = "Cond. Address";
pairs[1].value = strings.tmp.tmp;
content->type = TAG_VALUE_LIST;
content->tagValueList.nbPairs = 2;
content->tagValueList.pairs = (nbgl_layoutTagValue_t *) tlv;
content->tagValueList.pairs = (nbgl_layoutTagValue_t *) pairs;
} else {
page++;

View File

@@ -7,7 +7,7 @@
#ifdef HAVE_STARKWARE
static nbgl_layoutTagValue_t tlv[2];
static nbgl_layoutTagValue_t pairs[2];
static char from_account[64];
static char message_hash[64];
@@ -32,13 +32,13 @@ static bool displayTransactionPage(uint8_t page, nbgl_pageContent_t *content) {
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;
pairs[0].item = "From Account";
pairs[0].value = from_account;
pairs[1].item = "Hash";
pairs[1].value = message_hash;
content->type = TAG_VALUE_LIST;
content->tagValueList.nbPairs = 2;
content->tagValueList.pairs = (nbgl_layoutTagValue_t *) tlv;
content->tagValueList.pairs = (nbgl_layoutTagValue_t *) pairs;
} else if (page == 1) {
content->type = INFO_LONG_PRESS, content->infoLongPress.icon = get_app_icon(false);
content->infoLongPress.text = "Unsafe Stark Sign";