From 89070cd2bee4f50ec57001f1f7d6948d22c3d045 Mon Sep 17 00:00:00 2001 From: Alexandre Paillier Date: Wed, 9 Mar 2022 11:47:38 +0100 Subject: [PATCH] Now only loops through tokens once to match it --- src/main.c | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/src/main.c b/src/main.c index a06bac0..2b5c878 100644 --- a/src/main.c +++ b/src/main.c @@ -386,7 +386,8 @@ extraInfo_t *getKnownToken(uint8_t *contractAddress) { } } #endif - // + // Works for ERC-20 & NFT tokens since both structs in the union have the + // contract address aligned for (uint8_t i = 0; i < MAX_ITEMS; i++) { currentItem = (union extraInfo_t *) &tmpCtx.transactionContext.extraInfo[i].token; if (tmpCtx.transactionContext.tokenSet[i] && @@ -396,15 +397,6 @@ extraInfo_t *getKnownToken(uint8_t *contractAddress) { } } - for (uint8_t i = 0; i < MAX_ITEMS; i++) { - currentItem = (union extraInfo_t *) &tmpCtx.transactionContext.extraInfo[i].token; - if (tmpCtx.transactionContext.tokenSet[i] && - (memcmp(currentItem->nft.contractAddress, contractAddress, ADDRESS_LENGTH) == 0)) { - PRINTF("Token found at index %d\n", i); - return currentItem; - } - } - return NULL; }