Merge nft and tokens into a single asset header

This commit is contained in:
Francois Beutin
2024-01-16 17:17:42 +01:00
parent e64a04da51
commit 5bf5023e35
12 changed files with 27 additions and 32 deletions

View File

@@ -7,11 +7,9 @@
#include "os.h"
#include "cx.h"
#include "ethUstream.h"
#include "tokens.h"
#include "extra_info.h"
#include "tx_content.h"
#include "chainConfig.h"
#include "nft.h"
#include "asset_info.h"
#ifdef HAVE_NBGL
#include "nbgl_types.h"
#endif

View File

@@ -19,7 +19,7 @@
#include <string.h>
#include <stdbool.h>
#include "tokens.h"
#include "asset_info.h"
#include "swap_utils.h"
bool parse_swap_config(const uint8_t *config, uint8_t config_len, char *ticker, uint8_t *decimals) {

View File

@@ -20,6 +20,17 @@
#include <stdint.h>
#include "common_utils.h"
// NFT
#define COLLECTION_NAME_MAX_LEN 70
typedef struct nftInfo_t {
uint8_t contractAddress[ADDRESS_LENGTH]; // must be first item
char collectionName[COLLECTION_NAME_MAX_LEN + 1];
} nftInfo_t;
// TOKENS
#define MAX_TICKER_LEN 11 // 10 characters + '\0'
#define MAX_ITEMS 2
@@ -31,3 +42,10 @@ typedef struct tokenDefinition_t {
char ticker[MAX_TICKER_LEN];
uint8_t decimals;
} tokenDefinition_t;
// UNION
typedef union extraInfo_t {
tokenDefinition_t token;
nftInfo_t nft;
} extraInfo_t;

View File

@@ -18,7 +18,7 @@
#include <stdint.h>
#include <string.h>
#include "tokens.h"
#include "asset_info.h"
#include "common_utils.h"
void array_hexstr(char *strbuf, const void *bin, unsigned int len) {

View File

@@ -5,7 +5,7 @@
#include "os.h"
#include "cx.h"
#include "tokens.h"
#include "asset_info.h"
#include "tx_content.h"
/*************************************************************************************************

View File

@@ -1,9 +0,0 @@
#pragma once
#include "tokens.h"
#include "nft.h"
typedef union extraInfo_t {
tokenDefinition_t token;
nftInfo_t nft;
} extraInfo_t;

View File

@@ -1,10 +0,0 @@
#pragma once
#include <stdint.h>
#define COLLECTION_NAME_MAX_LEN 70
typedef struct nftInfo_t {
uint8_t contractAddress[ADDRESS_LENGTH]; // must be first item
char collectionName[COLLECTION_NAME_MAX_LEN + 1];
} nftInfo_t;

View File

@@ -2,7 +2,7 @@
#include "shared_context.h"
#include "apdu_constants.h"
#include "tokens.h"
#include "asset_info.h"
#include "common_utils.h"
#include "common_ui.h"
#include "os_io_seproxyhal.h"

View File

@@ -1,6 +1,6 @@
#include "shared_context.h"
#include "apdu_constants.h"
#include "tokens.h"
#include "asset_info.h"
#include "eth_plugin_interface.h"
#include "eth_plugin_internal.h"
#include "plugin_utils.h"

View File

@@ -7,7 +7,7 @@
#include <stdint.h>
#include "ethUstream.h"
#include "uint256.h"
#include "nft.h"
#include "asset_info.h"
// Internal plugin for EIP 1155: https://eips.ethereum.org/EIPS/eip-1155

View File

@@ -6,7 +6,7 @@
#include <stdbool.h>
#include <stdint.h>
#include "ethUstream.h"
#include "nft.h"
#include "asset_info.h"
// Internal plugin for EIP 721: https://eips.ethereum.org/EIPS/eip-721

View File

@@ -154,12 +154,10 @@ if __name__ == "__main__":
# some nodes will be extracted from these headers and merged into a new
# one, copied to sdk
headers_to_merge = [
"src_common/tokens.h",
"src_common/asset_info.h",
"src_common/common_utils.h",
"src_common/tx_content.h",
"src_common/plugin_utils.h",
"src_common/nft.h",
"src_common/extra_info.h",
"src_common/caller_api.h",
]
nodes_to_extract = {