From fb28efc012978312820814e502cb97429787c696 Mon Sep 17 00:00:00 2001 From: Alexandre Paillier Date: Wed, 9 Mar 2022 15:36:03 +0100 Subject: [PATCH] Removed the helper getNftContractAddress helper function and some NULL checks Useless since we don't allow NFT signing without the NFT metadata anymore --- src_common/ethUtils.c | 6 ------ src_common/ethUtils.h | 3 --- src_plugins/erc1155/erc1155_ui.c | 24 ++++++------------------ src_plugins/erc721/erc721_ui.c | 24 ++++++------------------ 4 files changed, 12 insertions(+), 45 deletions(-) diff --git a/src_common/ethUtils.c b/src_common/ethUtils.c index 4239136..804837c 100644 --- a/src_common/ethUtils.c +++ b/src_common/ethUtils.c @@ -237,12 +237,6 @@ void getEthDisplayableAddress(uint8_t *in, getEthAddressStringFromBinary(in, out + 2, sha3, chainId); } -uint8_t *getNftContractAddress(const ethQueryContractUI_t *const msg) { - // In case of no PROVIDE_NFT_INFO, we already have the address from the SET_PLUGIN - return ((msg->item1) ? ((uint8_t *) msg->item1->nft.contractAddress) - : msg->pluginSharedRO->txContent->destination); -} - bool adjustDecimals(const char *src, size_t srcLength, char *target, diff --git a/src_common/ethUtils.h b/src_common/ethUtils.h index eadd639..3c147cc 100644 --- a/src_common/ethUtils.h +++ b/src_common/ethUtils.h @@ -22,7 +22,6 @@ #include "cx.h" #include "chainConfig.h" -#include "eth_plugin_interface.h" /** * @brief Decode an RLP encoded field - see @@ -59,8 +58,6 @@ void getEthDisplayableAddress(uint8_t *in, cx_sha3_t *sha3, uint64_t chainId); -uint8_t *getNftContractAddress(const ethQueryContractUI_t *const msg); - bool adjustDecimals(const char *src, size_t srcLength, char *target, diff --git a/src_plugins/erc1155/erc1155_ui.c b/src_plugins/erc1155/erc1155_ui.c index 2386793..4306704 100644 --- a/src_plugins/erc1155/erc1155_ui.c +++ b/src_plugins/erc1155/erc1155_ui.c @@ -22,15 +22,11 @@ static void set_approval_for_all_ui(ethQueryContractUI_t *msg, erc1155_context_t break; case 1: strlcpy(msg->title, "To Manage ALL", msg->titleLength); - if (msg->item1) { - strlcpy(msg->msg, (const char *) &msg->item1->nft.collectionName, msg->msgLength); - } else { - strlcpy(msg->msg, "Not found", msg->msgLength); - } + strlcpy(msg->msg, msg->item1->nft.collectionName, msg->msgLength); break; case 2: strlcpy(msg->title, "NFT Address", msg->titleLength); - getEthDisplayableAddress(getNftContractAddress(msg), + getEthDisplayableAddress(msg->item1->nft.contractAddress, msg->msg, msg->msgLength, &global_sha3, @@ -55,15 +51,11 @@ static void set_transfer_ui(ethQueryContractUI_t *msg, erc1155_context_t *contex break; case 1: strlcpy(msg->title, "Collection Name", msg->titleLength); - if (msg->item1) { - strlcpy(msg->msg, (const char *) &msg->item1->nft.collectionName, msg->msgLength); - } else { - strlcpy(msg->msg, "Not Found", msg->msgLength); - } + strlcpy(msg->msg, msg->item1->nft.collectionName, msg->msgLength); break; case 2: strlcpy(msg->title, "NFT Address", msg->titleLength); - getEthDisplayableAddress(getNftContractAddress(msg), + getEthDisplayableAddress(msg->item1->nft.contractAddress, msg->msg, msg->msgLength, &global_sha3, @@ -101,15 +93,11 @@ static void set_batch_transfer_ui(ethQueryContractUI_t *msg, erc1155_context_t * break; case 1: strlcpy(msg->title, "Collection Name", msg->titleLength); - if (msg->item1) { - strlcpy(msg->msg, (const char *) &msg->item1->nft.collectionName, msg->msgLength); - } else { - strlcpy(msg->msg, "Not Found", msg->msgLength); - } + strlcpy(msg->msg, msg->item1->nft.collectionName, msg->msgLength); break; case 2: strlcpy(msg->title, "NFT Address", msg->titleLength); - getEthDisplayableAddress(getNftContractAddress(msg), + getEthDisplayableAddress(msg->item1->nft.contractAddress, msg->msg, msg->msgLength, &global_sha3, diff --git a/src_plugins/erc721/erc721_ui.c b/src_plugins/erc721/erc721_ui.c index a968aa6..8fc4c59 100644 --- a/src_plugins/erc721/erc721_ui.c +++ b/src_plugins/erc721/erc721_ui.c @@ -18,15 +18,11 @@ static void set_approval_ui(ethQueryContractUI_t *msg, erc721_context_t *context break; case 1: strlcpy(msg->title, "To Manage Your", msg->titleLength); - if (msg->item1) { - strlcpy(msg->msg, (const char *) &msg->item1->nft.collectionName, msg->msgLength); - } else { - strlcpy(msg->msg, "Not Found", msg->msgLength); - } + strlcpy(msg->msg, msg->item1->nft.collectionName, msg->msgLength); break; case 2: strlcpy(msg->title, "NFT Address", msg->titleLength); - getEthDisplayableAddress(getNftContractAddress(msg), + getEthDisplayableAddress(msg->item1->nft.contractAddress, msg->msg, msg->msgLength, &global_sha3, @@ -62,15 +58,11 @@ static void set_approval_for_all_ui(ethQueryContractUI_t *msg, erc721_context_t break; case 1: strlcpy(msg->title, "To Manage ALL", msg->titleLength); - if (msg->item1) { - strlcpy(msg->msg, (const char *) &msg->item1->nft.collectionName, msg->msgLength); - } else { - strlcpy(msg->msg, "Not found", msg->msgLength); - } + strlcpy(msg->msg, msg->item1->nft.collectionName, msg->msgLength); break; case 2: strlcpy(msg->title, "NFT Address", msg->titleLength); - getEthDisplayableAddress(getNftContractAddress(msg), + getEthDisplayableAddress(msg->item1->nft.contractAddress, msg->msg, msg->msgLength, &global_sha3, @@ -95,15 +87,11 @@ static void set_transfer_ui(ethQueryContractUI_t *msg, erc721_context_t *context break; case 1: strlcpy(msg->title, "Collection Name", msg->titleLength); - if (msg->item1) { - strlcpy(msg->msg, (const char *) &msg->item1->nft.collectionName, msg->msgLength); - } else { - strlcpy(msg->msg, "Not Found", msg->msgLength); - } + strlcpy(msg->msg, msg->item1->nft.collectionName, msg->msgLength); break; case 2: strlcpy(msg->title, "NFT Address", msg->titleLength); - getEthDisplayableAddress(getNftContractAddress(msg), + getEthDisplayableAddress(msg->item1->nft.contractAddress, msg->msg, msg->msgLength, &global_sha3,