diff --git a/CHANGELOG.md b/CHANGELOG.md index 0c8def5..9b72ae0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,11 +5,17 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/) and this project adheres to [Semantic Versioning](http://semver.org/). -## [1.9.15](https://github.com/ledgerhq/app-ethereum/compare/1.9.14...1.9.15) - 2021-12-15 +## [1.9.17](https://github.com/ledgerhq/app-ethereum/compare/1.9.16...1.9.17) - 2022-01-14 ### Added -- Support for Non-Fungible Token (ERC-721 & ERC-1155) +- Support for Non-Fungible Tokens (ERC-721 & ERC-1155) + +## [1.9.16](https://github.com/ledgerhq/app-ethereum/compare/1.9.14...1.9.16) - 2022-01-13 + +### Added + +- Shyft variant ## [1.9.14](https://github.com/ledgerhq/app-ethereum/compare/1.9.13...1.9.14) - 2021-11-30 diff --git a/Makefile b/Makefile index c65535b..4607051 100644 --- a/Makefile +++ b/Makefile @@ -30,7 +30,7 @@ APP_LOAD_PARAMS += --path "1517992542'/1101353413'" APPVERSION_M=1 APPVERSION_N=9 -APPVERSION_P=15 +APPVERSION_P=17 APPVERSION=$(APPVERSION_M).$(APPVERSION_N).$(APPVERSION_P) APP_LOAD_FLAGS= --appFlags 0x240 --dep Ethereum:$(APPVERSION) @@ -234,9 +234,13 @@ else ifeq ($(CHAIN),polygon) APP_LOAD_PARAMS += --path "44'/60'" DEFINES += CHAINID_UPCASE=\"POLYGON\" CHAINID_COINNAME=\"MATIC\" CHAIN_KIND=CHAIN_KIND_POLYGON CHAIN_ID=137 APPNAME = "Polygon" +else ifeq ($(CHAIN),shyft) +APP_LOAD_PARAMS += --path "44'/60'" +DEFINES += CHAINID_UPCASE=\"SHYFT\" CHAINID_COINNAME=\"SHFT\" CHAIN_KIND=CHAIN_KIND_SHYFT CHAIN_ID=7341 +APPNAME = "Shyft" else ifeq ($(filter clean,$(MAKECMDGOALS)),) -$(error Unsupported CHAIN - use ethereum, ropsten, goerli, moonriver, ethereum_classic, expanse, poa, artis_sigma1, artis_tau1, rsk, rsk_testnet, ubiq, wanchain, kusd, musicoin, pirl, akroma, atheios, callisto, ethersocial, ellaism, ether1, ethergem, gochain, mix, reosc, hpb, tomochain, tobalaba, dexon, volta, ewc, webchain, thundercore, bsc, songbird, polygon) +$(error Unsupported CHAIN - use ethereum, ropsten, goerli, moonriver, ethereum_classic, expanse, poa, artis_sigma1, artis_tau1, rsk, rsk_testnet, ubiq, wanchain, kusd, musicoin, pirl, akroma, atheios, callisto, ethersocial, ellaism, ether1, ethergem, gochain, mix, reosc, hpb, tomochain, tobalaba, dexon, volta, ewc, webchain, thundercore, bsc, songbird, polygon, shyft) endif endif @@ -417,4 +421,4 @@ include $(BOLOS_SDK)/Makefile.rules dep/%.d: %.c Makefile listvariants: - @echo VARIANTS CHAIN ethereum ropsten goerli moonriver ethereum_classic expanse poa rsk rsk_testnet ubiq wanchain pirl akroma atheios callisto ethersocial ether1 gochain musicoin ethergem mix ellaism reosc hpb tomochain dexon volta ewc thundercore bsc songbird polygon + @echo VARIANTS CHAIN ethereum ropsten goerli moonriver ethereum_classic expanse poa rsk rsk_testnet ubiq wanchain pirl akroma atheios callisto ethersocial ether1 gochain musicoin ethergem mix ellaism reosc hpb tomochain dexon volta ewc thundercore bsc songbird polygon shyft diff --git a/icons/nanos_app_shyft.gif b/icons/nanos_app_shyft.gif new file mode 100644 index 0000000..3a07de0 Binary files /dev/null and b/icons/nanos_app_shyft.gif differ diff --git a/icons/nanox_app_shyft.gif b/icons/nanox_app_shyft.gif new file mode 100644 index 0000000..fd1cb06 Binary files /dev/null and b/icons/nanox_app_shyft.gif differ diff --git a/src/chainConfig.h b/src/chainConfig.h index 3a174a1..733a1a6 100644 --- a/src/chainConfig.h +++ b/src/chainConfig.h @@ -57,7 +57,8 @@ typedef enum chain_kind_e { CHAIN_KIND_FLARE, CHAIN_KIND_BSC, CHAIN_KIND_SONGBIRD, - CHAIN_KIND_POLYGON + CHAIN_KIND_POLYGON, + CHAIN_KIND_SHYFT } chain_kind_t; typedef struct chain_config_s { diff --git a/src/eth_plugin_handler.c b/src/eth_plugin_handler.c index a6e685e..b82c6a5 100644 --- a/src/eth_plugin_handler.c +++ b/src/eth_plugin_handler.c @@ -133,7 +133,7 @@ eth_plugin_result_t eth_plugin_perform_init(uint8_t *contractAddress, #ifdef HAVE_NFT_SUPPORT case ERC1155: case ERC721: -#endif // HAVE_NFT_SUPPORT +#endif // HAVE_NFT_SUPPORT case EXTERNAL: eth_plugin_perform_init_default(contractAddress, init); contractAddress = NULL; @@ -277,7 +277,7 @@ eth_plugin_result_t eth_plugin_call(int method, void *parameter) { erc1155_plugin_call(method, parameter); break; } -#endif // HAVE_NFT_SUPPORT +#endif // HAVE_NFT_SUPPORT case OLD_INTERNAL: { // Perform the call for (i = 0;; i++) { diff --git a/src/main.c b/src/main.c index b677645..a06bac0 100644 --- a/src/main.c +++ b/src/main.c @@ -266,6 +266,9 @@ extraInfo_t *getKnownToken(uint8_t *contractAddress) { case CHAIN_KIND_POLYGON: numTokens = NUM_TOKENS_POLYGON; break; + case CHAIN_KIND_SHYFT: + numTokens = NUM_TOKENS_SHYFT; + break; } for (i = 0; i < numTokens; i++) { switch (chainConfig->kind) { @@ -374,6 +377,9 @@ extraInfo_t *getKnownToken(uint8_t *contractAddress) { case CHAIN_KIND_POLYGON: currentToken = (tokenDefinition_t *) PIC(&TOKENS_POLYGON[i]); break; + case CHAIN_KIND_SHYFT: + currentToken = (tokenDefinition_t *) PIC(&TOKENS_SHYFT[i]); + break; } if (memcmp(currentToken->address, tmpContent.txContent.destination, ADDRESS_LENGTH) == 0) { return currentToken; @@ -522,7 +528,7 @@ void handleApdu(unsigned int *flags, unsigned int *tx) { flags, tx); break; -#endif // HAVE_NFT_SUPPORT +#endif // HAVE_NFT_SUPPORT case INS_SET_EXTERNAL_PLUGIN: handleSetExternalPlugin(G_io_apdu_buffer[OFFSET_P1], diff --git a/src/shared_context.h b/src/shared_context.h index b5c944f..035f7c2 100644 --- a/src/shared_context.h +++ b/src/shared_context.h @@ -204,10 +204,10 @@ extern const internalStorage_t N_storage_real; extern bool called_from_swap; typedef enum { - EXTERNAL, // External plugin, set by setExternalPlugin. - ERC721, // Specific ERC721 internal plugin, set by setPlugin. - ERC1155, // Specific ERC1155 internal plugin, set by setPlugin - OLD_INTERNAL // Old internal plugin, not set by any command. + EXTERNAL, // External plugin, set by setExternalPlugin. + ERC721, // Specific ERC721 internal plugin, set by setPlugin. + ERC1155, // Specific ERC1155 internal plugin, set by setPlugin + OLD_INTERNAL // Old internal plugin, not set by any command. } pluginType_t; extern pluginType_t pluginType; diff --git a/src/stark_utils.c b/src/stark_utils.c index 5344ba4..4df86e9 100644 --- a/src/stark_utils.c +++ b/src/stark_utils.c @@ -94,7 +94,6 @@ void pedersen(FieldElement res, /* out */ memcpy(res, hash + 1, FIELD_ELEMENT_SIZE); } -#ifdef TARGET_NANOX void shift_stark_hash(FieldElement hash) { uint256_t hash256, final_hash256; readu256BE(hash, &hash256); @@ -112,7 +111,6 @@ void shift_stark_hash(FieldElement hash) { THROW(0x6A80); } } -#endif // TARGET_NANOX int stark_sign(uint8_t *signature, /* out */ uint8_t *privateKeyData, @@ -137,9 +135,7 @@ int stark_sign(uint8_t *signature, /* out */ } pedersen(hash, hash, msg); PRINTF("Pedersen hash 2 %.*H\n", 32, hash); -#ifdef TARGET_NANOX shift_stark_hash(hash); -#endif cx_ecfp_init_private_key(CX_CURVE_Stark256, privateKeyData, 32, &privateKey); io_seproxyhal_io_heartbeat(); int signatureLength = cx_ecdsa_sign(&privateKey, diff --git a/src/tokens.c b/src/tokens.c index b6a9181..e1ddb5f 100644 --- a/src/tokens.c +++ b/src/tokens.c @@ -192,4 +192,6 @@ const tokenDefinition_t const TOKENS_MOONRIVER[NUM_TOKENS_MOONRIVER] = {}; const tokenDefinition_t const TOKENS_POLYGON[NUM_TOKENS_POLYGON] = {}; +const tokenDefinition_t const TOKENS_SHYFT[NUM_TOKENS_SHYFT] = {}; + #endif diff --git a/src/tokens.h b/src/tokens.h index 13e98e7..4391d67 100644 --- a/src/tokens.h +++ b/src/tokens.h @@ -105,6 +105,7 @@ static const uint8_t LEDGER_SIGNATURE_PUBLIC_KEY[] = { #define NUM_TOKENS_SONGBIRD 0 #define NUM_TOKENS_MOONRIVER 0 #define NUM_TOKENS_POLYGON 0 +#define NUM_TOKENS_SHYFT 0 extern tokenDefinition_t const TOKENS_AKROMA[NUM_TOKENS_AKROMA]; extern tokenDefinition_t const TOKENS_ELLAISM[NUM_TOKENS_ELLAISM]; @@ -141,6 +142,7 @@ extern tokenDefinition_t const TOKENS_BSC[NUM_TOKENS_BSC]; extern tokenDefinition_t const TOKENS_SONGBIRD[NUM_TOKENS_SONGBIRD]; extern tokenDefinition_t const TOKENS_MOONRIVER[NUM_TOKENS_MOONRIVER]; extern tokenDefinition_t const TOKENS_POLYGON[NUM_TOKENS_POLYGON]; +extern tokenDefinition_t const TOKENS_SHYFT[NUM_TOKENS_SHYFT]; #endif /* HAVE_TOKENS_LIST */ diff --git a/src_features/provideNFTInformation/cmd_provideNFTInfo.c b/src_features/provideNFTInformation/cmd_provideNFTInfo.c index 1495f2c..a4256a3 100644 --- a/src_features/provideNFTInformation/cmd_provideNFTInfo.c +++ b/src_features/provideNFTInformation/cmd_provideNFTInfo.c @@ -18,8 +18,8 @@ #define MIN_DER_SIG_SIZE 67 #define MAX_DER_SIG_SIZE 72 -#define TEST_NFT_METADATA_KEY 0 -#define PROD_NFT_METADATA_KEY 1 +#define TEST_NFT_METADATA_KEY 0 +#define PROD_NFT_METADATA_KEY 1 #define ALGORITHM_ID_1 1 @@ -29,18 +29,18 @@ static const uint8_t LEDGER_NFT_METADATA_PUBLIC_KEY[] = { #ifdef HAVE_NFT_TESTING_KEY - 0x04, 0xf5, 0x70, 0x0c, 0xa1, 0xe8, 0x74, 0x24, 0xc7, 0xc7, 0xd1, 0x19, 0xe7, - 0xe3, 0xc1, 0x89, 0xb1, 0x62, 0x50, 0x94, 0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x46, 0xf2, 0x8e, 0x77, 0xc1, 0xba, 0xb6, 0x75, 0xcb, + 0x2a, 0x27, 0x44, 0xf7, 0xf5, 0xce, 0xc5, 0x6a, 0xe6, 0xe0, 0x32, 0x23, 0x33, 0x7b, + 0x57, 0x94, 0xcd, 0x6a, 0xe0, 0x7d, 0x48, 0xb3, 0x0d, 0xb9, 0xcc, 0xb4, 0x0f, 0x5a, + 0x02, 0xa1, 0x1a, 0x3a, 0xb9, 0x9d, 0x5f, 0x59, 0x5a, 0x3d, 0x50, 0xa0, 0xe1, 0x30, + 0x23, 0xfd, 0x0d, 0x95, 0x87, 0x92, 0xd7, 0x97, 0x01 #endif }; @@ -176,7 +176,7 @@ void handleProvideNFTInformation(uint8_t p1, switch (algorithmId) { case ALGORITHM_ID_1: curve = CX_CURVE_256K1; - verificationFn = (verificationAlgo*)cx_ecdsa_verify; + verificationFn = (verificationAlgo *) cx_ecdsa_verify; hashId = CX_SHA256; break; default: @@ -227,4 +227,4 @@ void handleProvideNFTInformation(uint8_t p1, THROW(0x9000); } -#endif // HAVE_NFT_SUPPORT +#endif // HAVE_NFT_SUPPORT diff --git a/src_features/setPlugin/cmd_setPlugin.c b/src_features/setPlugin/cmd_setPlugin.c index ea39aa2..d2969f7 100644 --- a/src_features/setPlugin/cmd_setPlugin.c +++ b/src_features/setPlugin/cmd_setPlugin.c @@ -46,17 +46,17 @@ typedef enum AlgorithmID { // Only used for signing NFT plugins (ERC721 and ERC1155) static const uint8_t LEDGER_NFT_SELECTOR_PUBLIC_KEY[] = { #ifdef HAVE_NFT_TESTING_KEY - 0x04, 0xf5, 0x70, 0x0c, 0xa1, 0xe8, 0x74, 0x24, 0xc7, 0xc7, 0xd1, 0x19, 0xe7, - 0xe3, 0xc1, 0x89, 0xb1, 0x62, 0x50, 0x94, 0xdb, 0x6e, 0xa0, 0x40, 0x87, 0xc8, - 0x30, 0x00, 0x7d, 0x0b, 0x46, 0x9a, 0x53, 0x11, 0xee, 0x6a, 0x1a, 0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x79, 0x77, 0x33, 0x6d, + 0x78, 0x24, 0xee, 0xe3, 0xa2, 0x62, 0x24, 0x1a, 0x62, 0x73, 0x52, 0x3b, 0x09, 0xb8, + 0xd0, 0xce, 0x0d, 0x39, 0xe8, 0x60, 0xc9, 0x4d, 0x02, 0x53, 0x58, 0xdb, 0xdc, 0x25, + 0x92, 0xc7, 0xc6, 0x48, 0x0d, 0x39, 0xce, 0xbb, 0xa3 #endif }; @@ -209,7 +209,7 @@ void handleSetPlugin(uint8_t p1, switch (algorithmId) { case ECC_SECG_P256K1__ECDSA_SHA_256: curve = CX_CURVE_256K1; - verificationFn = (verificationAlgo*)cx_ecdsa_verify; + verificationFn = (verificationAlgo *) cx_ecdsa_verify; hashId = CX_SHA256; break; default: diff --git a/src_plugins/erc1155/erc1155_plugin.c b/src_plugins/erc1155/erc1155_plugin.c index 7eebd8c..dbc1b8e 100644 --- a/src_plugins/erc1155/erc1155_plugin.c +++ b/src_plugins/erc1155/erc1155_plugin.c @@ -139,4 +139,4 @@ void erc1155_plugin_call(int message, void *parameters) { } } -#endif // HAVE_NFT_SUPPORT +#endif // HAVE_NFT_SUPPORT diff --git a/src_plugins/erc1155/erc1155_plugin.h b/src_plugins/erc1155/erc1155_plugin.h index 22462a8..0702fdf 100644 --- a/src_plugins/erc1155/erc1155_plugin.h +++ b/src_plugins/erc1155/erc1155_plugin.h @@ -34,9 +34,9 @@ typedef enum { } erc1155_selector_field; typedef struct erc1155_context_t { - uint8_t address[ADDRESS_LENGTH]; - uint8_t tokenId[INT256_LENGTH]; - uint256_t value; + uint8_t address[ADDRESS_LENGTH]; + uint8_t tokenId[INT256_LENGTH]; + uint256_t value; uint16_t ids_array_len; uint32_t ids_offset; @@ -52,4 +52,4 @@ typedef struct erc1155_context_t { void handle_provide_parameter_1155(void *parameters); void handle_query_contract_ui_1155(void *parameters); -#endif // HAVE_NFT_SUPPORT +#endif // HAVE_NFT_SUPPORT diff --git a/src_plugins/erc1155/erc1155_provide_parameters.c b/src_plugins/erc1155/erc1155_provide_parameters.c index 59da428..800aafb 100644 --- a/src_plugins/erc1155/erc1155_provide_parameters.c +++ b/src_plugins/erc1155/erc1155_provide_parameters.c @@ -30,7 +30,7 @@ static void handle_safe_transfer(ethPluginProvideParameter_t *msg, erc1155_conte } static void handle_batch_transfer(ethPluginProvideParameter_t *msg, erc1155_context_t *context) { - uint256_t new_value; + uint256_t new_value; switch (context->next_param) { case FROM: @@ -41,23 +41,19 @@ static void handle_batch_transfer(ethPluginProvideParameter_t *msg, erc1155_cont context->next_param = TOKEN_IDS_OFFSET; break; case TOKEN_IDS_OFFSET: - context->ids_offset = \ - U4BE(msg->parameter, - PARAMETER_LENGTH - sizeof(context->ids_offset)) + 4; + context->ids_offset = + U4BE(msg->parameter, PARAMETER_LENGTH - sizeof(context->ids_offset)) + 4; context->next_param = VALUE_OFFSET; break; case VALUE_OFFSET: - context->values_offset = \ - U4BE(msg->parameter, - PARAMETER_LENGTH - sizeof(context->values_offset)) + 4; + context->values_offset = + U4BE(msg->parameter, PARAMETER_LENGTH - sizeof(context->values_offset)) + 4; context->next_param = TOKEN_IDS_LENGTH; break; case TOKEN_IDS_LENGTH: - if ((msg->parameterOffset + PARAMETER_LENGTH) > context->ids_offset) - { - context->ids_array_len = \ - U2BE(msg->parameter, - PARAMETER_LENGTH - sizeof(context->ids_array_len)); + if ((msg->parameterOffset + PARAMETER_LENGTH) > context->ids_offset) { + context->ids_array_len = + U2BE(msg->parameter, PARAMETER_LENGTH - sizeof(context->ids_array_len)); context->next_param = TOKEN_ID; // set to zero for next step context->array_index = 0; @@ -65,20 +61,16 @@ static void handle_batch_transfer(ethPluginProvideParameter_t *msg, erc1155_cont break; case TOKEN_ID: // don't copy anything since we won't display it - if (--context->ids_array_len == 0) - { + if (--context->ids_array_len == 0) { context->next_param = VALUE_LENGTH; } context->array_index++; break; case VALUE_LENGTH: - if ((msg->parameterOffset + PARAMETER_LENGTH) > context->values_offset) - { - context->values_array_len = \ - U2BE(msg->parameter, - PARAMETER_LENGTH - sizeof(context->values_array_len)); - if (context->values_array_len != context->array_index) - { + if ((msg->parameterOffset + PARAMETER_LENGTH) > context->values_offset) { + context->values_array_len = + U2BE(msg->parameter, PARAMETER_LENGTH - sizeof(context->values_array_len)); + if (context->values_array_len != context->array_index) { PRINTF("Token ids and values array sizes mismatch!"); } context->next_param = VALUE; @@ -92,8 +84,7 @@ static void handle_batch_transfer(ethPluginProvideParameter_t *msg, erc1155_cont copy_parameter(context->tokenId, msg->parameter, sizeof(context->value)); convertUint256BE(context->tokenId, sizeof(context->tokenId), &new_value); add256(&context->value, &new_value, &context->value); - if (--context->values_array_len == 0) - { + if (--context->values_array_len == 0) { context->next_param = NONE; } context->array_index++; @@ -132,10 +123,10 @@ void handle_provide_parameter_1155(void *parameters) { msg->result = ETH_PLUGIN_RESULT_SUCCESSFUL; - //if (context->targetOffset > SELECTOR_SIZE && - // context->targetOffset != msg->parameterOffset - SELECTOR_SIZE) { - // return; - //} + // if (context->targetOffset > SELECTOR_SIZE && + // context->targetOffset != msg->parameterOffset - SELECTOR_SIZE) { + // return; + // } switch (context->selectorIndex) { case SAFE_TRANSFER: handle_safe_transfer(msg, context); @@ -153,4 +144,4 @@ void handle_provide_parameter_1155(void *parameters) { } } -#endif // HAVE_NFT_SUPPORT +#endif // HAVE_NFT_SUPPORT diff --git a/src_plugins/erc1155/erc1155_ui.c b/src_plugins/erc1155/erc1155_ui.c index 5237a16..5b4e941 100644 --- a/src_plugins/erc1155/erc1155_ui.c +++ b/src_plugins/erc1155/erc1155_ui.c @@ -59,7 +59,7 @@ static void set_transfer_ui(ethQueryContractUI_t *msg, erc1155_context_t *contex break; case 2: strlcpy(msg->title, "NFT Address", msg->titleLength); - getEthDisplayableAddress((uint8_t *)msg->item1->nft.contractAddress, + getEthDisplayableAddress((uint8_t *) msg->item1->nft.contractAddress, msg->msg, msg->msgLength, &global_sha3, @@ -84,7 +84,7 @@ static void set_transfer_ui(ethQueryContractUI_t *msg, erc1155_context_t *contex } static void set_batch_transfer_ui(ethQueryContractUI_t *msg, erc1155_context_t *context) { - char quantity_str[48]; + char quantity_str[48]; switch (msg->screenIndex) { case 0: @@ -105,7 +105,7 @@ static void set_batch_transfer_ui(ethQueryContractUI_t *msg, erc1155_context_t * break; case 2: strlcpy(msg->title, "NFT Address", msg->titleLength); - getEthDisplayableAddress((uint8_t *)msg->item1->nft.contractAddress, + getEthDisplayableAddress((uint8_t *) msg->item1->nft.contractAddress, msg->msg, msg->msgLength, &global_sha3, @@ -149,4 +149,4 @@ void handle_query_contract_ui_1155(void *parameters) { } } -#endif // HAVE_NFT_SUPPORT +#endif // HAVE_NFT_SUPPORT diff --git a/src_plugins/erc721/erc721_plugin.c b/src_plugins/erc721/erc721_plugin.c index 4bdd232..badddb3 100644 --- a/src_plugins/erc721/erc721_plugin.c +++ b/src_plugins/erc721/erc721_plugin.c @@ -147,4 +147,4 @@ void erc721_plugin_call(int message, void *parameters) { } } -#endif // HAVE_NFT_SUPPORT +#endif // HAVE_NFT_SUPPORT diff --git a/src_plugins/erc721/erc721_plugin.h b/src_plugins/erc721/erc721_plugin.h index 2ab80df..1846609 100644 --- a/src_plugins/erc721/erc721_plugin.h +++ b/src_plugins/erc721/erc721_plugin.h @@ -43,4 +43,4 @@ typedef struct erc721_context_t { void handle_provide_parameter_721(void *parameters); void handle_query_contract_ui_721(void *parameters); -#endif // HAVE_NFT_SUPPORT +#endif // HAVE_NFT_SUPPORT diff --git a/src_plugins/erc721/erc721_provide_parameters.c b/src_plugins/erc721/erc721_provide_parameters.c index a315af0..ac5b870 100644 --- a/src_plugins/erc721/erc721_provide_parameters.c +++ b/src_plugins/erc721/erc721_provide_parameters.c @@ -94,4 +94,4 @@ void handle_provide_parameter_721(void *parameters) { } } -#endif // HAVE_NFT_SUPPORT +#endif // HAVE_NFT_SUPPORT diff --git a/src_plugins/erc721/erc721_ui.c b/src_plugins/erc721/erc721_ui.c index bb8264c..e312932 100644 --- a/src_plugins/erc721/erc721_ui.c +++ b/src_plugins/erc721/erc721_ui.c @@ -115,7 +115,7 @@ static void set_transfer_ui(ethQueryContractUI_t *msg, erc721_context_t *context break; case 2: strlcpy(msg->title, "NFT Address", msg->titleLength); - getEthDisplayableAddress((uint8_t *)msg->item1->nft.contractAddress, + getEthDisplayableAddress((uint8_t *) msg->item1->nft.contractAddress, msg->msg, msg->msgLength, &global_sha3, @@ -167,4 +167,4 @@ void handle_query_contract_ui_721(void *parameters) { } } -#endif // HAVE_NFT_SUPPORT +#endif // HAVE_NFT_SUPPORT