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

Fix/UI add contract names #18

Merged
merged 2 commits into from
Mar 17, 2023
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
32 changes: 27 additions & 5 deletions src/contract.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,6 @@ static const uint8_t STABLE_MINT_SELECTOR[SELECTOR_SIZE] = {0x80, 0x4b, 0x93, 0x
// Selector: 0xf39247a9
static const uint8_t MINT_SIGN_SELECTOR[SELECTOR_SIZE] = {0xf3, 0x92, 0x47, 0xa9};

// Function: mint (v2)
// Selector: 0xa0712d68
static const uint8_t MINT_V2_SELECTOR[SELECTOR_SIZE] = {0xa0, 0x71, 0x2d, 0x68};

// Function: mintSign (v2)
// Selector: 0x657bb113
static const uint8_t MINT_SIGN_V2_SELECTOR[SELECTOR_SIZE] = {0x65, 0x7b, 0xb1, 0x13};
Expand All @@ -48,8 +44,34 @@ const uint8_t *const LEDGER_NFT_SELECTORS[NUM_SELECTORS] = {
STABLE_MINT_SIGN_SELECTOR,
STABLE_MINT_SELECTOR,
MINT_SIGN_SELECTOR,
MINT_V2_SELECTOR,
MINT_SIGN_V2_SELECTOR,
BID_SELECTOR,
FINALIZE_AUCTION_SELECTOR,
};

static const uint8_t MULTI_MINT_CONTRACT_NFT_ADDRESS[ADDRESS_LENGTH] = {
0x6c, 0x30, 0x4a, 0x1f, 0x99, 0xce, 0xcd, 0x3a, 0x99, 0x83,
0x00, 0x1e, 0x94, 0x3f, 0x3d, 0xe0, 0x0e, 0xd8, 0x11, 0xd0,
};

static const uint8_t STABLE_MULTI_MINT_ERC_721_ADDRESS[ADDRESS_LENGTH] = {
0x9e, 0xa4, 0x57, 0x1a, 0x73, 0x9a, 0x1d, 0x64, 0x4e, 0x17,
0xd3, 0x4a, 0x86, 0xe7, 0xde, 0xe9, 0x76, 0x09, 0xb2, 0x56,
};

static const uint8_t MULTI_MINT_1155_ADDRESS[ADDRESS_LENGTH] = {
0x12, 0xb1, 0x80, 0x05, 0x3d, 0xb3, 0x89, 0xb6, 0x20, 0x0e,
0x6f, 0x64, 0x69, 0x49, 0xe6, 0xab, 0x7b, 0x38, 0x5d, 0x40,
};

static const uint8_t AUCTION_CORE_ADDRESS[ADDRESS_LENGTH] = {
0xc5, 0xae, 0x7f, 0xf0, 0x25, 0xd5, 0xc3, 0x73, 0x76, 0x2a,
0x73, 0x55, 0x7e, 0x3d, 0xd3, 0x04, 0x9c, 0xda, 0x1f, 0x2d,
};

const uint8_t *const LEDGER_NFT_CONTRACTS[NUM_CONTRACTS] = {
MULTI_MINT_CONTRACT_NFT_ADDRESS,
STABLE_MULTI_MINT_ERC_721_ADDRESS,
MULTI_MINT_1155_ADDRESS,
AUCTION_CORE_ADDRESS,
};
1 change: 0 additions & 1 deletion src/handle_finalize.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ void handle_finalize(void *parameters) {
case STABLE_MINT_SIGN:
case STABLE_MINT:
case MINT_SIGN:
case MINT_V2:
case BID:
msg->numScreens = 2;
break;
Expand Down
1 change: 0 additions & 1 deletion src/handle_init_contract.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ void handle_init_contract(void *parameters) {
case STABLE_MINT_SIGN:
case STABLE_MINT:
case MINT_SIGN:
case MINT_V2:
context->next_param = AMOUNT;
break;
case MINT_SIGN_V2:
Expand Down
1 change: 0 additions & 1 deletion src/handle_provide_parameter.c
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,6 @@ void handle_provide_parameter(void *parameters) {
case STABLE_MINT_SIGN:
case STABLE_MINT:
case MINT_SIGN:
case MINT_V2:
handle_mint(msg, context);
break;
case MINT_SIGN_V2:
Expand Down
24 changes: 17 additions & 7 deletions src/handle_query_contract_id.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,21 @@ void handle_query_contract_id(void *parameters) {

switch (context->selectorIndex) {
case MINT:
strlcpy(msg->version, "Mint", msg->versionLength);
break;
if (memcmp((uint8_t *) PIC(LEDGER_NFT_CONTRACTS[MULTI_MINT_CONTRACT_NFT]),
msg->pluginSharedRO->txContent->destination,
ADDRESS_LENGTH) == 0) {
strlcpy(msg->version, "MultiMintContractNFT - Mint", msg->versionLength);
break;
} else if (memcmp((uint8_t *) PIC(LEDGER_NFT_CONTRACTS[STABLE_MULTI_MINT_ERC_721]),
msg->pluginSharedRO->txContent->destination,
ADDRESS_LENGTH) == 0) {
strlcpy(msg->version, "StableMultiMintERC721 - Mint", msg->versionLength);
break;
} else {
PRINTF("Unsupported contract address\n");
msg->result = ETH_PLUGIN_RESULT_ERROR;
return;
}
case PRE_SALE_MINT:
strlcpy(msg->version, "Presale Mint", msg->versionLength);
break;
Expand All @@ -20,13 +33,10 @@ void handle_query_contract_id(void *parameters) {
strlcpy(msg->version, "Stable Mint", msg->versionLength);
break;
case MINT_SIGN:
strlcpy(msg->version, "Mint Sign", msg->versionLength);
break;
case MINT_V2:
strlcpy(msg->version, "Mint", msg->versionLength);
strlcpy(msg->version, "StableMultiMintERC721 - Mint Sign", msg->versionLength);
break;
case MINT_SIGN_V2:
strlcpy(msg->version, "Mint Sign", msg->versionLength);
strlcpy(msg->version, "MultiMint1155 - Mint Sign", msg->versionLength);
break;
case BID:
strlcpy(msg->version, "Bid", msg->versionLength);
Expand Down
1 change: 0 additions & 1 deletion src/handle_query_contract_ui.c
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ static screens_t get_screen(const ethQueryContractUI_t *msg,
case STABLE_MINT_SIGN:
case STABLE_MINT:
case MINT_SIGN:
case MINT_V2:
switch (index) {
case 0:
return AMOUNT_SCREEN;
Expand Down
13 changes: 11 additions & 2 deletions src/ledger_nft_plugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
#include "eth_internals.h"
#include "eth_plugin_interface.h"

#define NUM_SELECTORS 9
#define NUM_SELECTORS 8
#define NUM_CONTRACTS 4
#define PLUGIN_NAME "Ledger NFT"
#define TOKEN_FOUND 1 << 1
#define SELECTOR_SIZE 4
Expand All @@ -21,7 +22,6 @@ typedef enum {
STABLE_MINT_SIGN,
STABLE_MINT,
MINT_SIGN,
MINT_V2,
MINT_SIGN_V2,
BID,
FINALIZE_AUCTION,
Expand Down Expand Up @@ -51,6 +51,15 @@ typedef enum {

extern const uint8_t *const LEDGER_NFT_SELECTORS[NUM_SELECTORS];

extern const uint8_t *const LEDGER_NFT_CONTRACTS[NUM_CONTRACTS];

typedef enum {
MULTI_MINT_CONTRACT_NFT = 0,
STABLE_MULTI_MINT_ERC_721,
MULTI_MINT_1155,
AUCTION_CORE,
} contracts_t;

// Shared global memory with Ethereum app. Must be at most 5 * 32 bytes.
typedef struct context_t {
// For display.
Expand Down
Binary file modified tests/snapshots/ethereum_goerli_nanos_mint/00001.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_goerli_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_goerli_nanos_mint/00003.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_goerli_nanos_mint/00004.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_goerli_nanos_mint/00005.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_goerli_nanos_mint/00006.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 added tests/snapshots/ethereum_goerli_nanos_mint/00007.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_goerli_nanos_mint_sign/00001.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_goerli_nanos_mint_sign/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_goerli_nanos_mint_sign/00003.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_goerli_nanos_mint_sign/00004.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_goerli_nanos_mint_sign/00005.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_goerli_nanos_mint_sign/00006.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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_goerli_nanos_mint_sign_v2/00001.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_goerli_nanos_mint_sign_v2/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_goerli_nanos_mint_sign_v2/00003.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_goerli_nanos_mint_sign_v2/00004.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_goerli_nanos_mint_sign_v2/00005.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_goerli_nanos_mint_sign_v2/00006.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_goerli_nanos_mint_sign_v2/00007.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_goerli_nanos_mint_sign_v2/00008.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_goerli_nanos_mint_sign_v2/00009.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_goerli_nanos_mint_sign_v2/00010.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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_goerli_nanos_mint_v2/00001.png
Binary file modified tests/snapshots/ethereum_goerli_nanos_mint_v2/00002.png
Binary file modified tests/snapshots/ethereum_goerli_nanos_mint_v2/00003.png
Binary file modified tests/snapshots/ethereum_goerli_nanos_mint_v2/00004.png
Binary file modified tests/snapshots/ethereum_goerli_nanos_mint_v2/00005.png
Binary file modified tests/snapshots/ethereum_goerli_nanos_mint_v2/00006.png
Binary file modified tests/snapshots/ethereum_goerli_nanosp_mint/00001.png
Binary file modified tests/snapshots/ethereum_goerli_nanosp_mint_sign/00001.png
Binary file modified tests/snapshots/ethereum_goerli_nanosp_mint_sign_v2/00001.png
Binary file modified tests/snapshots/ethereum_goerli_nanosp_mint_v2/00001.png
Binary file modified tests/snapshots/ethereum_goerli_nanox_mint/00001.png
Binary file modified tests/snapshots/ethereum_goerli_nanox_mint_sign/00001.png
Binary file modified tests/snapshots/ethereum_goerli_nanox_mint_sign_v2/00001.png
Binary file modified tests/snapshots/ethereum_goerli_nanox_mint_v2/00001.png
2 changes: 1 addition & 1 deletion tests/src/mint.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const devices = [
{
name: "nanos",
label: "Nano S",
steps: 5, // <= Define the number of steps for this test case and this device
steps: 6, // <= Define the number of steps for this test case and this device
},
{
name: "nanox",
Expand Down
2 changes: 1 addition & 1 deletion tests/src/mintSign.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ const devices = [
{
name: "nanos",
label: "Nano S",
steps: 5, // <= Define the number of steps for this test case and this device
steps: 6, // <= Define the number of steps for this test case and this device
},
{
name: "nanox",
Expand Down
2 changes: 1 addition & 1 deletion tests/src/mintSignV2.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ const devices = [
{
name: "nanos",
label: "Nano S",
steps: 9, // <= Define the number of steps for this test case and this device
steps: 10, // <= Define the number of steps for this test case and this device
},
{
name: "nanox",
Expand Down
2 changes: 1 addition & 1 deletion tests/src/mintV2.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const devices = [
{
name: "nanos",
label: "Nano S",
steps: 5, // <= Define the number of steps for this test case and this device
steps: 6, // <= Define the number of steps for this test case and this device
},
{
name: "nanox",
Expand Down