Now buffers the EIP-712 pairs to show more than one per screen
This commit is contained in:
@@ -56,6 +56,9 @@ typedef struct {
|
|||||||
uint8_t field_flags;
|
uint8_t field_flags;
|
||||||
uint8_t structs_to_review;
|
uint8_t structs_to_review;
|
||||||
s_amount_context amount;
|
s_amount_context amount;
|
||||||
|
#ifdef SCREEN_SIZE_WALLET
|
||||||
|
char ui_pairs_buffer[(SHARED_CTX_FIELD_1_SIZE + SHARED_CTX_FIELD_2_SIZE) * 2];
|
||||||
|
#endif
|
||||||
} t_ui_context;
|
} t_ui_context;
|
||||||
|
|
||||||
static t_ui_context *ui_ctx = NULL;
|
static t_ui_context *ui_ctx = NULL;
|
||||||
@@ -210,6 +213,7 @@ void ui_712_message_hash(void) {
|
|||||||
sizeof(strings.tmp.tmp),
|
sizeof(strings.tmp.tmp),
|
||||||
tmpCtx.messageSigningContext712.messageHash,
|
tmpCtx.messageSigningContext712.messageHash,
|
||||||
KECCAK256_HASH_BYTESIZE);
|
KECCAK256_HASH_BYTESIZE);
|
||||||
|
ui_ctx->end_reached = true;
|
||||||
ui_712_redraw_generic_step();
|
ui_712_redraw_generic_step();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -594,9 +598,9 @@ void ui_712_end_sign(void) {
|
|||||||
apdu_response_code = APDU_RESPONSE_CONDITION_NOT_SATISFIED;
|
apdu_response_code = APDU_RESPONSE_CONDITION_NOT_SATISFIED;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
ui_ctx->end_reached = true;
|
|
||||||
|
|
||||||
if (N_storage.verbose_eip712 || (ui_ctx->filtering_mode == EIP712_FILTERING_FULL)) {
|
if (N_storage.verbose_eip712 || (ui_ctx->filtering_mode == EIP712_FILTERING_FULL)) {
|
||||||
|
ui_ctx->end_reached = true;
|
||||||
ui_712_switch_to_sign();
|
ui_712_switch_to_sign();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -778,4 +782,17 @@ bool ui_712_show_raw_key(const void *field_ptr) {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef SCREEN_SIZE_WALLET
|
||||||
|
/*
|
||||||
|
* Get UI pairs buffer
|
||||||
|
*
|
||||||
|
* @param[out] size buffer size
|
||||||
|
* @return pointer to the buffer
|
||||||
|
*/
|
||||||
|
char *get_ui_pairs_buffer(size_t *size) {
|
||||||
|
*size = sizeof(ui_ctx->ui_pairs_buffer);
|
||||||
|
return ui_ctx->ui_pairs_buffer;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif // HAVE_EIP712_FULL_SUPPORT
|
#endif // HAVE_EIP712_FULL_SUPPORT
|
||||||
|
|||||||
@@ -43,6 +43,9 @@ void ui_712_token_join_prepare_addr_check(uint8_t index);
|
|||||||
void ui_712_token_join_prepare_amount(uint8_t index, const char *name, uint8_t name_length);
|
void ui_712_token_join_prepare_amount(uint8_t index, const char *name, uint8_t name_length);
|
||||||
void amount_join_set_token_received(void);
|
void amount_join_set_token_received(void);
|
||||||
bool ui_712_show_raw_key(const void *field_ptr);
|
bool ui_712_show_raw_key(const void *field_ptr);
|
||||||
|
#ifdef SCREEN_SIZE_WALLET
|
||||||
|
char *get_ui_pairs_buffer(size_t *size);
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif // HAVE_EIP712_FULL_SUPPORT
|
#endif // HAVE_EIP712_FULL_SUPPORT
|
||||||
|
|
||||||
|
|||||||
@@ -7,11 +7,28 @@
|
|||||||
#include "common_712.h"
|
#include "common_712.h"
|
||||||
#include "nbgl_use_case.h"
|
#include "nbgl_use_case.h"
|
||||||
#include "ui_message_signing.h"
|
#include "ui_message_signing.h"
|
||||||
|
#include "ledger_assert.h"
|
||||||
|
|
||||||
static nbgl_contentTagValue_t pair;
|
static nbgl_contentTagValue_t pairs[6];
|
||||||
static nbgl_contentTagValueList_t pairs_list;
|
static nbgl_contentTagValueList_t pairs_list;
|
||||||
|
static uint8_t pair_idx;
|
||||||
|
static size_t buf_idx;
|
||||||
|
|
||||||
static void message_progress(bool confirm) {
|
static void message_progress(bool confirm) {
|
||||||
|
char *buf;
|
||||||
|
size_t buf_size;
|
||||||
|
size_t shift_off;
|
||||||
|
|
||||||
|
if (pairs_list.nbPairs < pair_idx) {
|
||||||
|
buf = get_ui_pairs_buffer(&buf_size);
|
||||||
|
memmove(&pairs[0], &pairs[pairs_list.nbPairs], sizeof(pairs[0]));
|
||||||
|
memmove(buf, pairs[0].item, (buf + buf_idx) - pairs[0].item);
|
||||||
|
shift_off = pairs[0].item - buf;
|
||||||
|
buf_idx -= shift_off;
|
||||||
|
pairs[0].value -= shift_off;
|
||||||
|
pairs[0].item = buf;
|
||||||
|
pair_idx = 1;
|
||||||
|
}
|
||||||
if (confirm) {
|
if (confirm) {
|
||||||
if (ui_712_next_field() == EIP712_NO_MORE_FIELD) {
|
if (ui_712_next_field() == EIP712_NO_MORE_FIELD) {
|
||||||
ui_712_switch_to_sign();
|
ui_712_switch_to_sign();
|
||||||
@@ -22,22 +39,40 @@ static void message_progress(bool confirm) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void message_update(bool confirm) {
|
static void message_update(bool confirm) {
|
||||||
if (confirm) {
|
char *buf;
|
||||||
explicit_bzero(&pair, sizeof(pair));
|
size_t buf_size;
|
||||||
explicit_bzero(&pairs_list, sizeof(pairs_list));
|
size_t buf_off;
|
||||||
|
bool flag;
|
||||||
|
|
||||||
pair.item = strings.tmp.tmp2;
|
buf = get_ui_pairs_buffer(&buf_size);
|
||||||
pair.value = strings.tmp.tmp;
|
if (confirm) {
|
||||||
pairs_list.nbPairs = 1;
|
buf_off = strlen(strings.tmp.tmp2) + 1;
|
||||||
pairs_list.pairs = &pair;
|
LEDGER_ASSERT((buf_idx + buf_off) < buf_size, "UI pairs buffer overflow");
|
||||||
pairs_list.wrapping = false;
|
pairs[pair_idx].item = memmove(buf + buf_idx, strings.tmp.tmp2, buf_off);
|
||||||
nbgl_useCaseReviewStreamingContinue(&pairs_list, message_progress);
|
buf_idx += buf_off;
|
||||||
|
buf_off = strlen(strings.tmp.tmp) + 1;
|
||||||
|
LEDGER_ASSERT((buf_idx + buf_off) < buf_size, "UI pairs buffer overflow");
|
||||||
|
pairs[pair_idx].value = memmove(buf + buf_idx, strings.tmp.tmp, buf_off);
|
||||||
|
buf_idx += buf_off;
|
||||||
|
pair_idx += 1;
|
||||||
|
pairs_list.nbPairs = nbgl_useCaseGetNbTagValuesInPage(pair_idx, &pairs_list, 0, &flag);
|
||||||
|
if (pairs_list.nbPairs < pair_idx) {
|
||||||
|
nbgl_useCaseReviewStreamingContinue(&pairs_list, message_progress);
|
||||||
|
} else {
|
||||||
|
message_progress(true);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
ui_typed_message_review_choice(false);
|
ui_typed_message_review_choice(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ui_712_start(void) {
|
void ui_712_start(void) {
|
||||||
|
explicit_bzero(&pairs, sizeof(pairs));
|
||||||
|
explicit_bzero(&pairs_list, sizeof(pairs_list));
|
||||||
|
pairs_list.pairs = pairs;
|
||||||
|
pair_idx = 0;
|
||||||
|
buf_idx = 0;
|
||||||
|
|
||||||
nbgl_useCaseReviewStreamingStart(TYPE_MESSAGE,
|
nbgl_useCaseReviewStreamingStart(TYPE_MESSAGE,
|
||||||
&C_Review_64px,
|
&C_Review_64px,
|
||||||
TEXT_REVIEW_EIP712,
|
TEXT_REVIEW_EIP712,
|
||||||
@@ -50,7 +85,13 @@ void ui_712_switch_to_message(void) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void ui_712_switch_to_sign(void) {
|
void ui_712_switch_to_sign(void) {
|
||||||
nbgl_useCaseReviewStreamingFinish(TEXT_SIGN_EIP712, ui_typed_message_review_choice);
|
if (pair_idx > 0) {
|
||||||
|
pairs_list.nbPairs = pair_idx;
|
||||||
|
pair_idx = 0;
|
||||||
|
nbgl_useCaseReviewStreamingContinue(&pairs_list, message_progress);
|
||||||
|
} else {
|
||||||
|
nbgl_useCaseReviewStreamingFinish(TEXT_SIGN_EIP712, ui_typed_message_review_choice);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // HAVE_EIP712_FULL_SUPPORT
|
#endif // HAVE_EIP712_FULL_SUPPORT
|
||||||
|
|||||||
Reference in New Issue
Block a user