Fixes the location in memory of the address between nftInfo_t & tokenDefinition_t
Both used as members of the same union, also unifies the type (array of uint8_t)
This commit is contained in:
14
src/nft.h
14
src/nft.h
@@ -1,14 +1,8 @@
|
||||
#include "tokens.h"
|
||||
|
||||
// An `nftInfo_t` must be the same size as a `tokenDefinition_t`. This is because both will be held
|
||||
// in a `extraInfo_t` which is a union of a `nftInfo_t` and a `tokenDefinition_t`. By having both
|
||||
// struct the same size, we know they will be aligned, which facilitates accessing the items.
|
||||
|
||||
// We defined the collection name max length to be the size of a `tokenDefinition_t` and remove the
|
||||
// `ADDRESS_LENGTH` which corresponds to `sizeof(contractAddress`).
|
||||
#define COLLECTION_NAME_MAX_LEN (sizeof(tokenDefinition_t) - ADDRESS_LENGTH)
|
||||
#define COLLECTION_NAME_MAX_LEN 70
|
||||
|
||||
typedef struct nftInfo_t {
|
||||
char collectionName[COLLECTION_NAME_MAX_LEN];
|
||||
char contractAddress[ADDRESS_LENGTH];
|
||||
} nftInfo_t;
|
||||
uint8_t contractAddress[ADDRESS_LENGTH]; // must be first item
|
||||
char collectionName[COLLECTION_NAME_MAX_LEN + 1];
|
||||
} nftInfo_t;
|
||||
|
||||
31
src/tokens.h
31
src/tokens.h
@@ -25,14 +25,11 @@
|
||||
#define MAX_ITEMS 2
|
||||
|
||||
typedef struct tokenDefinition_t {
|
||||
uint8_t address[ADDRESS_LENGTH]; // must be first item
|
||||
#ifdef HAVE_CONTRACT_NAME_IN_DESCRIPTOR
|
||||
uint8_t contractName[ADDRESS_LENGTH];
|
||||
#endif
|
||||
uint8_t address[ADDRESS_LENGTH];
|
||||
char ticker[MAX_TICKER_LEN];
|
||||
char nft_pad[20]; // Adding some padding because the `nftInfo_t` is based on the size of a
|
||||
// `tokenDefinition_t`. By adding some padding here we give more space to the
|
||||
// collection name in the `nftInfo_t`. See `nftInfo_t` for more information.
|
||||
uint8_t decimals;
|
||||
} tokenDefinition_t;
|
||||
|
||||
@@ -46,25 +43,23 @@ extern tokenDefinition_t const TOKENS_EXTRA[NUM_TOKENS_EXTRA];
|
||||
|
||||
#ifndef HAVE_TOKENS_LIST
|
||||
|
||||
static const uint8_t LEDGER_SIGNATURE_PUBLIC_KEY[] = {
|
||||
#ifndef LEDGER_TEST_PUBLIC_KEY
|
||||
static const uint8_t LEDGER_SIGNATURE_PUBLIC_KEY[] = {
|
||||
// production key 2019-01-11 03:07PM (erc20signer)
|
||||
0x04, 0x5e, 0x6c, 0x10, 0x20, 0xc1, 0x4d, 0xc4, 0x64, 0x42, 0xfe, 0x89, 0xf9,
|
||||
0x7c, 0x0b, 0x68, 0xcd, 0xb1, 0x59, 0x76, 0xdc, 0x24, 0xf2, 0x4c, 0x31, 0x6e,
|
||||
0x7b, 0x30, 0xfe, 0x4e, 0x8c, 0xc7, 0x6b, 0x14, 0x89, 0x15, 0x0c, 0x21, 0x51,
|
||||
0x4e, 0xbf, 0x44, 0x0f, 0xf5, 0xde, 0xa5, 0x39, 0x3d, 0x83, 0xde, 0x53, 0x58,
|
||||
0xcd, 0x09, 0x8f, 0xce, 0x8f, 0xd0, 0xf8, 0x1d, 0xaa, 0x94, 0x97, 0x91, 0x83};
|
||||
|
||||
0x04, 0x5e, 0x6c, 0x10, 0x20, 0xc1, 0x4d, 0xc4, 0x64, 0x42, 0xfe, 0x89, 0xf9, 0x7c,
|
||||
0x0b, 0x68, 0xcd, 0xb1, 0x59, 0x76, 0xdc, 0x24, 0xf2, 0x4c, 0x31, 0x6e, 0x7b, 0x30,
|
||||
0xfe, 0x4e, 0x8c, 0xc7, 0x6b, 0x14, 0x89, 0x15, 0x0c, 0x21, 0x51, 0x4e, 0xbf, 0x44,
|
||||
0x0f, 0xf5, 0xde, 0xa5, 0x39, 0x3d, 0x83, 0xde, 0x53, 0x58, 0xcd, 0x09, 0x8f, 0xce,
|
||||
0x8f, 0xd0, 0xf8, 0x1d, 0xaa, 0x94, 0x97, 0x91, 0x83
|
||||
#else
|
||||
static const uint8_t LEDGER_SIGNATURE_PUBLIC_KEY[] = {
|
||||
// test key 2019-01-11 03:07PM (erc20signer)
|
||||
0x04, 0x20, 0xda, 0x62, 0x00, 0x3c, 0x0c, 0xe0, 0x97, 0xe3, 0x36, 0x44, 0xa1,
|
||||
0x0f, 0xe4, 0xc3, 0x04, 0x54, 0x06, 0x9a, 0x44, 0x54, 0xf0, 0xfa, 0x9d, 0x4e,
|
||||
0x84, 0xf4, 0x50, 0x91, 0x42, 0x9b, 0x52, 0x20, 0xaf, 0x9e, 0x35, 0xc0, 0xb2,
|
||||
0xd9, 0x28, 0x93, 0x80, 0x13, 0x73, 0x07, 0xde, 0x4d, 0xd1, 0xd4, 0x18, 0x42,
|
||||
0x8c, 0xf2, 0x1a, 0x93, 0xb3, 0x35, 0x61, 0xbb, 0x09, 0xd8, 0x8f, 0xe5, 0x79,
|
||||
};
|
||||
0x04, 0x20, 0xda, 0x62, 0x00, 0x3c, 0x0c, 0xe0, 0x97, 0xe3, 0x36, 0x44, 0xa1, 0x0f,
|
||||
0xe4, 0xc3, 0x04, 0x54, 0x06, 0x9a, 0x44, 0x54, 0xf0, 0xfa, 0x9d, 0x4e, 0x84, 0xf4,
|
||||
0x50, 0x91, 0x42, 0x9b, 0x52, 0x20, 0xaf, 0x9e, 0x35, 0xc0, 0xb2, 0xd9, 0x28, 0x93,
|
||||
0x80, 0x13, 0x73, 0x07, 0xde, 0x4d, 0xd1, 0xd4, 0x18, 0x42, 0x8c, 0xf2, 0x1a, 0x93,
|
||||
0xb3, 0x35, 0x61, 0xbb, 0x09, 0xd8, 0x8f, 0xe5, 0x79
|
||||
#endif
|
||||
};
|
||||
|
||||
#else
|
||||
|
||||
|
||||
@@ -34,7 +34,6 @@ static const uint8_t LEDGER_NFT_METADATA_PUBLIC_KEY[] = {
|
||||
0x7d, 0x0b, 0x46, 0x9a, 0x53, 0x11, 0xee, 0x6a, 0x1a, 0xcd, 0x1d, 0xa5, 0xaa, 0xb0,
|
||||
0xf5, 0xc6, 0xdf, 0x13, 0x15, 0x8d, 0x28, 0xcc, 0x12, 0xd1, 0xdd, 0xa6, 0xec, 0xe9,
|
||||
0x46, 0xb8, 0x9d, 0x5c, 0x05, 0x49, 0x92, 0x59, 0xc4
|
||||
|
||||
#else
|
||||
0x04, 0x98, 0x8d, 0xa6, 0xb2, 0x46, 0xf2, 0x8e, 0x77, 0xc1, 0xba, 0xb6, 0x75, 0xcb,
|
||||
0x2a, 0x27, 0x44, 0xf7, 0xf5, 0xce, 0xc5, 0x6a, 0xe6, 0xe0, 0x32, 0x23, 0x33, 0x7b,
|
||||
@@ -117,10 +116,10 @@ void handleProvideNFTInformation(uint8_t p1,
|
||||
THROW(0x6A80);
|
||||
}
|
||||
|
||||
if (collectionNameLength + 1 > sizeof(nft->collectionName)) {
|
||||
if (collectionNameLength > COLLECTION_NAME_MAX_LEN) {
|
||||
PRINTF("CollectionName too big: expected max %d, got %d\n",
|
||||
sizeof(nft->collectionName),
|
||||
collectionNameLength + 1);
|
||||
COLLECTION_NAME_MAX_LEN,
|
||||
collectionNameLength);
|
||||
THROW(0x6A80);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user