Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update screen texts #6

Merged
merged 3 commits into from
Jun 17, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion src/handle_query_contract_ui.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,15 @@
static void set_amount_ui(ethQueryContractUI_t *msg, context_t *context) {
strlcpy(msg->title, "Amount", msg->titleLength);

// set network ticker (ETH, BNB, etc) if needed
if (ADDRESS_IS_NETWORK_TOKEN(context->contract_address_sent)) {
strlcpy(context->ticker_sent, msg->network_ticker, sizeof(context->ticker_sent));
}

amountToString(msg->pluginSharedRO->txContent->value.value,
msg->pluginSharedRO->txContent->value.length,
WEI_TO_ETHER,
context->ticker,
context->ticker_sent,
msg->msg,
msg->msgLength);
}
Expand Down
17 changes: 16 additions & 1 deletion src/ledger_nft_plugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@
#define PARAMETER_LENGTH 32
#define RUN_APPLICATION 1

// Plugin uses 0x00000 as a dummy address to reprecent ETH.
extern const uint8_t NULL_ETH_ADDRESS[ADDRESS_LENGTH];

#define ADDRESS_IS_NETWORK_TOKEN(_addr) (!memcmp(_addr, NULL_ETH_ADDRESS, ADDRESS_LENGTH))
typedef enum {
MINT,
PRE_SALE_MINT,
Expand All @@ -33,7 +37,8 @@ extern const uint8_t *const LEDGER_NFT_SELECTORS[NUM_SELECTORS];
typedef struct context_t {
// For display.
uint8_t amount[PARAMETER_LENGTH];
char ticker[MAX_TICKER_LEN];
uint8_t contract_address_sent[ADDRESS_LENGTH];
char ticker_sent[MAX_TICKER_LEN];

// For parsing data.
uint16_t offset;
Expand All @@ -56,3 +61,13 @@ void handle_query_contract_ui(void *parameters);
void handle_init_contract(void *parameters);
void handle_finalize(void *parameters);
void handle_query_contract_id(void *parameters);

static inline void printf_hex_array(const char *title __attribute__((unused)),
size_t len __attribute__((unused)),
const uint8_t *data __attribute__((unused))) {
PRINTF(title);
for (size_t i = 0; i < len; ++i) {
PRINTF("%02x", data[i]);
};
PRINTF("\n");
}
5 changes: 5 additions & 0 deletions src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@ static const uint8_t MINT_SELECTOR[SELECTOR_SIZE] = {0x12, 0x49, 0xc5, 0x8b};
// Selector: 0xc111fb91
static const uint8_t PRE_SALE_MINT_SELECTOR[SELECTOR_SIZE] = {0xc1, 0x11, 0xfb, 0x91};

// Plugin uses 0x00000 as a dummy address to reprecent ETH.
const uint8_t NULL_ETH_ADDRESS[ADDRESS_LENGTH] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00};

// Array of all the different nft selectors.
const uint8_t *const LEDGER_NFT_SELECTORS[NUM_SELECTORS] = {
MINT_SELECTOR,
Expand Down
Binary file modified tests/snapshots/ethereum_nanos_mint/00002.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 modified tests/snapshots/ethereum_nanos_pre_sale_mint/00002.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 modified tests/snapshots/ethereum_nanosp_mint/00002.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 modified tests/snapshots/ethereum_nanosp_pre_sale_mint/00002.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 modified tests/snapshots/ethereum_nanox_mint/00002.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 modified tests/snapshots/ethereum_nanox_pre_sale_mint/00002.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.