Now only loops through tokens once to match it

This commit is contained in:
Alexandre Paillier
2022-03-09 11:47:38 +01:00
parent 76c7f9dbd8
commit 89070cd2be

View File

@@ -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;
}