Skip to content

Commit

Permalink
Add partner name in screen
Browse files Browse the repository at this point in the history
  • Loading branch information
fbeutin-ledger committed Apr 17, 2024
1 parent 2b0d2fb commit 803bc6e
Show file tree
Hide file tree
Showing 209 changed files with 54 additions and 28 deletions.
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ APP_LOAD_PARAMS += $(COMMON_LOAD_PARAMS)

APPNAME = "Exchange"
APPVERSION_M = 3
APPVERSION_N = 3
APPVERSION_P = 4
APPVERSION_N = 4
APPVERSION_P = 0
APPVERSION = $(APPVERSION_M).$(APPVERSION_N).$(APPVERSION_P)

ifdef TESTING
Expand Down
5 changes: 4 additions & 1 deletion src/globals.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,10 @@ extern uint8_t G_io_seproxyhal_spi_buffer[IO_SEPROXYHAL_BUFFER_SIZE_B];
#define PARTNER_NAME_PREFIX_FOR_FUND "To "

typedef struct partner_data_s {
char prefixed_name[sizeof(PARTNER_NAME_PREFIX_FOR_FUND) - 1 + MAX_PARTNER_NAME_LENGHT + 1];
union {
char unprefixed_name[MAX_PARTNER_NAME_LENGHT + 1];
char prefixed_name[sizeof(PARTNER_NAME_PREFIX_FOR_FUND) - 1 + MAX_PARTNER_NAME_LENGHT + 1];
};
cx_ecfp_256_public_key_t public_key;
} partner_data_t;

Expand Down
22 changes: 14 additions & 8 deletions src/set_partner_key.c
Original file line number Diff line number Diff line change
Expand Up @@ -73,14 +73,20 @@ int set_partner_key(const command_t *cmd) {
return reply_error(err);
}

memset(G_swap_ctx.partner.prefixed_name, 0, sizeof(G_swap_ctx.partner.prefixed_name));
// Prepare the prefix for FUND display
strlcpy(G_swap_ctx.partner.prefixed_name,
PARTNER_NAME_PREFIX_FOR_FUND,
sizeof(G_swap_ctx.partner.prefixed_name));
// The incoming partner name is NOT NULL terminated, so we use strncat
// Don't erase the prefix copied above
strncat(G_swap_ctx.partner.prefixed_name, (char *) partner.bytes, partner.size);
if (G_swap_ctx.subcommand == FUND || G_swap_ctx.subcommand == FUND_NG) {
// Prepare the prefix for FUND display
memset(G_swap_ctx.partner.prefixed_name, 0, sizeof(G_swap_ctx.partner.prefixed_name));
strlcpy(G_swap_ctx.partner.prefixed_name,
PARTNER_NAME_PREFIX_FOR_FUND,
sizeof(G_swap_ctx.partner.prefixed_name));
// The incoming partner name is NOT NULL terminated, so we use strncat
// Don't erase the prefix copied above
strncat(G_swap_ctx.partner.prefixed_name, (char *) partner.bytes, partner.size);
} else {
memset(G_swap_ctx.partner.unprefixed_name, 0, sizeof(G_swap_ctx.partner.unprefixed_name));
// The incoming partner name is NOT NULL terminated, so we use strncpy
strncpy(G_swap_ctx.partner.unprefixed_name, (char *) partner.bytes, partner.size);
}

// Create the verifying key from the raw public key
if (cx_ecfp_init_public_key_no_throw(curve,
Expand Down
43 changes: 27 additions & 16 deletions src/ui/validate_transaction_bagl.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,40 +43,45 @@ UX_STEP_NOCB(ux_confirm_flow_2_step, bnnn_paging,
.title = "Send",
.text = G_swap_ctx.printable_send_amount,
});
UX_STEP_NOCB(ux_confirm_flow_3_step, bnnn_paging,
UX_STEP_NOCB(ux_confirm_flow_3_fund_step, bnnn_paging,
{
.title = G_swap_ctx.partner.prefixed_name,
.text = G_swap_ctx.account_name,
});
UX_STEP_NOCB(ux_confirm_flow_3_not_fund_step, bnnn_paging,
{
.title = "Exchange partner",
.text = G_swap_ctx.partner.unprefixed_name,
});
UX_STEP_NOCB(ux_confirm_flow_4_fixed_step, bnnn_paging,
{
.title = "Get",
.text = G_swap_ctx.printable_get_amount,
});
UX_STEP_NOCB(ux_confirm_flow_3_floating_step, bnnn_paging,
UX_STEP_NOCB(ux_confirm_flow_4_floating_step, bnnn_paging,
{
.title = "Get estimated",
.text = G_swap_ctx.printable_get_amount,
});
UX_STEP_NOCB(ux_confirm_flow_3_2_step, bnnn_paging,
{
.title = G_swap_ctx.partner.prefixed_name,
.text = G_swap_ctx.account_name,
});
UX_STEP_NOCB(ux_confirm_flow_4_step, bnnn_paging,
UX_STEP_NOCB(ux_confirm_flow_5_step, bnnn_paging,
{
.title = "Fees",
.text = G_swap_ctx.printable_fees_amount,
});
UX_STEP_CB(ux_confirm_flow_5_step, pbb, on_accept(NULL),
UX_STEP_CB(ux_confirm_flow_6_step, pbb, on_accept(NULL),
{
&C_icon_validate_14,
"Accept",
"and send",
});
UX_STEP_CB(ux_confirm_flow_6_step, pb, on_reject(NULL),
UX_STEP_CB(ux_confirm_flow_7_step, pb, on_reject(NULL),
{
&C_icon_crossmark,
"Reject",
});

// clang-format on
const ux_flow_step_t *ux_confirm_flow[8];
const ux_flow_step_t *ux_confirm_flow[9];

void ui_validate_amounts(void) {
int step = 0;
Expand All @@ -92,16 +97,22 @@ void ui_validate_amounts(void) {
ux_confirm_flow[step++] = &ux_confirm_flow_2_step;

if (G_swap_ctx.subcommand == FUND || G_swap_ctx.subcommand == FUND_NG) {
ux_confirm_flow[step++] = &ux_confirm_flow_3_2_step;
} else if (G_swap_ctx.rate == FLOATING) {
ux_confirm_flow[step++] = &ux_confirm_flow_3_floating_step;
ux_confirm_flow[step++] = &ux_confirm_flow_3_fund_step;
} else {
ux_confirm_flow[step++] = &ux_confirm_flow_3_step;
ux_confirm_flow[step++] = &ux_confirm_flow_3_not_fund_step;
}

if (G_swap_ctx.subcommand != FUND && G_swap_ctx.subcommand != FUND_NG) {
if (G_swap_ctx.rate == FLOATING) {
ux_confirm_flow[step++] = &ux_confirm_flow_4_floating_step;
} else {
ux_confirm_flow[step++] = &ux_confirm_flow_4_fixed_step;
}
}

ux_confirm_flow[step++] = &ux_confirm_flow_4_step;
ux_confirm_flow[step++] = &ux_confirm_flow_5_step;
ux_confirm_flow[step++] = &ux_confirm_flow_6_step;
ux_confirm_flow[step++] = &ux_confirm_flow_7_step;
ux_confirm_flow[step++] = FLOW_END_STEP;

ux_flow_init(0, ux_confirm_flow, NULL);
Expand Down
8 changes: 7 additions & 1 deletion src/ui/validate_transaction_nbgl.c
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ static void review_choice(bool confirm) {
}
}

static nbgl_layoutTagValue_t pairs[4];
static nbgl_layoutTagValue_t pairs[5];
static nbgl_layoutTagValueList_t pair_list;
static nbgl_pageInfoLongPress_t info_long_press;

Expand All @@ -130,6 +130,12 @@ static void continue_review(void) {
pairs[index].value = G_swap_ctx.printable_get_amount;
index++;
} else {
pairs[index].item = "Exchange partner";
pairs[index].value = G_swap_ctx.partner.unprefixed_name;
index++;
}

if (G_swap_ctx.subcommand != FUND && G_swap_ctx.subcommand != FUND_NG) {
if (G_swap_ctx.rate == FLOATING) {
pairs[index].item = "Get estimated";
} else {
Expand Down
Binary file modified test/python/snapshots/nanos/test_stellar_sell_valid_1/00003.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/python/snapshots/nanos/test_stellar_sell_valid_1/00004.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/python/snapshots/nanos/test_stellar_sell_valid_1/00005.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/python/snapshots/nanos/test_stellar_sell_valid_1/00006.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/python/snapshots/nanos/test_stellar_sell_valid_2/00003.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/python/snapshots/nanos/test_stellar_sell_valid_2/00004.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/python/snapshots/nanos/test_stellar_sell_valid_2/00005.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/python/snapshots/nanos/test_stellar_sell_valid_2/00006.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/python/snapshots/nanos/test_stellar_sell_wrong_fees/00003.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/python/snapshots/nanos/test_stellar_sell_wrong_fees/00005.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/python/snapshots/nanos/test_stellar_sell_wrong_fees/00006.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/python/snapshots/nanos/test_stellar_sell_wrong_memo/00003.png
Binary file modified test/python/snapshots/nanos/test_stellar_sell_wrong_memo/00005.png
Binary file modified test/python/snapshots/nanos/test_stellar_sell_wrong_memo/00006.png
Binary file modified test/python/snapshots/nanos/test_stellar_swap_valid_1/00002.png
Binary file modified test/python/snapshots/nanos/test_stellar_swap_valid_1/00003.png
Binary file modified test/python/snapshots/nanos/test_stellar_swap_valid_1/00004.png
Binary file modified test/python/snapshots/nanos/test_stellar_swap_valid_1/00005.png
Binary file modified test/python/snapshots/nanos/test_stellar_swap_valid_2/00002.png
Binary file modified test/python/snapshots/nanos/test_stellar_swap_valid_2/00003.png
Binary file modified test/python/snapshots/nanos/test_stellar_swap_valid_2/00004.png
Binary file modified test/python/snapshots/nanos/test_stellar_swap_valid_2/00005.png
Binary file modified test/python/snapshots/nanos/test_stellar_swap_wrong_fees/00002.png
Binary file modified test/python/snapshots/nanos/test_stellar_swap_wrong_fees/00003.png
Binary file modified test/python/snapshots/nanos/test_stellar_swap_wrong_fees/00004.png
Binary file modified test/python/snapshots/nanos/test_stellar_swap_wrong_fees/00005.png
Binary file modified test/python/snapshots/nanos/test_stellar_swap_wrong_memo/00002.png
Binary file modified test/python/snapshots/nanos/test_stellar_swap_wrong_memo/00003.png
Binary file modified test/python/snapshots/nanos/test_stellar_swap_wrong_memo/00004.png
Binary file modified test/python/snapshots/nanos/test_stellar_swap_wrong_memo/00005.png
Binary file modified test/python/snapshots/nanosp/test_stellar_sell_valid_1/00003.png
Binary file modified test/python/snapshots/nanosp/test_stellar_sell_valid_1/00005.png
Binary file modified test/python/snapshots/nanosp/test_stellar_sell_valid_1/00006.png
Binary file modified test/python/snapshots/nanosp/test_stellar_sell_valid_2/00003.png
Binary file modified test/python/snapshots/nanosp/test_stellar_sell_valid_2/00004.png
Binary file modified test/python/snapshots/nanosp/test_stellar_sell_valid_2/00005.png
Binary file modified test/python/snapshots/nanosp/test_stellar_sell_valid_2/00006.png
Binary file modified test/python/snapshots/nanosp/test_stellar_sell_wrong_fees/00003.png
Binary file modified test/python/snapshots/nanosp/test_stellar_sell_wrong_memo/00003.png
Binary file modified test/python/snapshots/nanosp/test_stellar_swap_valid_1/00002.png
Binary file modified test/python/snapshots/nanosp/test_stellar_swap_valid_1/00003.png
Binary file modified test/python/snapshots/nanosp/test_stellar_swap_valid_1/00004.png
Binary file modified test/python/snapshots/nanosp/test_stellar_swap_valid_1/00005.png
Binary file modified test/python/snapshots/nanosp/test_stellar_swap_valid_2/00002.png
Binary file modified test/python/snapshots/nanosp/test_stellar_swap_valid_2/00003.png
Binary file modified test/python/snapshots/nanosp/test_stellar_swap_valid_2/00004.png
Binary file modified test/python/snapshots/nanosp/test_stellar_swap_valid_2/00005.png
Binary file modified test/python/snapshots/nanox/test_stellar_sell_valid_1/00003.png
Binary file modified test/python/snapshots/nanox/test_stellar_sell_valid_1/00004.png
Binary file modified test/python/snapshots/nanox/test_stellar_sell_valid_1/00005.png
Binary file modified test/python/snapshots/nanox/test_stellar_sell_valid_1/00006.png
Binary file modified test/python/snapshots/nanox/test_stellar_sell_valid_2/00003.png
Binary file modified test/python/snapshots/nanox/test_stellar_sell_valid_2/00004.png
Binary file modified test/python/snapshots/nanox/test_stellar_sell_valid_2/00005.png
Binary file modified test/python/snapshots/nanox/test_stellar_sell_valid_2/00006.png
Binary file modified test/python/snapshots/nanox/test_stellar_sell_wrong_fees/00003.png
Binary file modified test/python/snapshots/nanox/test_stellar_sell_wrong_fees/00005.png
Binary file modified test/python/snapshots/nanox/test_stellar_sell_wrong_fees/00006.png
Binary file modified test/python/snapshots/nanox/test_stellar_sell_wrong_memo/00003.png
Binary file modified test/python/snapshots/nanox/test_stellar_sell_wrong_memo/00005.png
Binary file modified test/python/snapshots/nanox/test_stellar_sell_wrong_memo/00006.png
Binary file modified test/python/snapshots/nanox/test_stellar_swap_valid_1/00002.png
Binary file modified test/python/snapshots/nanox/test_stellar_swap_valid_1/00003.png
Binary file modified test/python/snapshots/nanox/test_stellar_swap_valid_1/00004.png
Binary file modified test/python/snapshots/nanox/test_stellar_swap_valid_1/00005.png
Binary file modified test/python/snapshots/nanox/test_stellar_swap_valid_2/00002.png
Binary file modified test/python/snapshots/nanox/test_stellar_swap_valid_2/00003.png
Binary file modified test/python/snapshots/nanox/test_stellar_swap_valid_2/00004.png
Binary file modified test/python/snapshots/nanox/test_stellar_swap_valid_2/00005.png
Binary file modified test/python/snapshots/nanox/test_stellar_swap_wrong_fees/00002.png
Binary file modified test/python/snapshots/nanox/test_stellar_swap_wrong_fees/00003.png
Binary file modified test/python/snapshots/nanox/test_stellar_swap_wrong_fees/00004.png
Binary file modified test/python/snapshots/nanox/test_stellar_swap_wrong_fees/00005.png
Binary file modified test/python/snapshots/nanox/test_stellar_swap_wrong_memo/00002.png
Binary file modified test/python/snapshots/nanox/test_stellar_swap_wrong_memo/00003.png
Binary file modified test/python/snapshots/nanox/test_stellar_swap_wrong_memo/00004.png
Binary file modified test/python/snapshots/nanox/test_stellar_swap_wrong_memo/00005.png

0 comments on commit 803bc6e

Please sign in to comment.