Avoid getting erc20 metadata multiple times in the same session
This commit is contained in:
parent
7b611f96e2
commit
a3626136a6
@ -15,7 +15,7 @@ import {
|
||||
type TokenTransferItemProps = {
|
||||
t: TokenTransfer;
|
||||
txData: TransactionData;
|
||||
tokenMeta?: TokenMeta | undefined;
|
||||
tokenMeta: TokenMeta | null | undefined;
|
||||
};
|
||||
|
||||
// TODO: handle partial
|
||||
|
@ -20,7 +20,7 @@ type DecoratedAddressLinkProps = {
|
||||
selfDestruct?: boolean;
|
||||
txFrom?: boolean;
|
||||
txTo?: boolean;
|
||||
tokenMeta?: TokenMeta;
|
||||
tokenMeta?: TokenMeta | null | undefined;
|
||||
};
|
||||
|
||||
const DecoratedAddresssLink: React.FC<DecoratedAddressLinkProps> = ({
|
||||
|
@ -108,4 +108,4 @@ export type TokenMeta = {
|
||||
decimals: number;
|
||||
};
|
||||
|
||||
export type TokenMetas = Record<string, TokenMeta>;
|
||||
export type TokenMetas = Record<string, TokenMeta | null | undefined>;
|
||||
|
@ -222,7 +222,7 @@ export const useTxData = (
|
||||
// Extract token meta
|
||||
const tokenMetas: TokenMetas = {};
|
||||
for (const t of tokenTransfers) {
|
||||
if (tokenMetas[t.token]) {
|
||||
if (tokenMetas[t.token] !== undefined) {
|
||||
continue;
|
||||
}
|
||||
const erc20Contract = new Contract(t.token, erc20, provider);
|
||||
@ -238,6 +238,7 @@ export const useTxData = (
|
||||
decimals,
|
||||
};
|
||||
} catch (err) {
|
||||
tokenMetas[t.token] = null;
|
||||
console.warn(`Couldn't get token ${t.token} metadata; ignoring`, err);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user