Now only loops through tokens once to match it
This commit is contained in:
12
src/main.c
12
src/main.c
@@ -386,7 +386,8 @@ extraInfo_t *getKnownToken(uint8_t *contractAddress) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#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++) {
|
for (uint8_t i = 0; i < MAX_ITEMS; i++) {
|
||||||
currentItem = (union extraInfo_t *) &tmpCtx.transactionContext.extraInfo[i].token;
|
currentItem = (union extraInfo_t *) &tmpCtx.transactionContext.extraInfo[i].token;
|
||||||
if (tmpCtx.transactionContext.tokenSet[i] &&
|
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;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user