Guard against errors on getting erc20 metadata

This commit is contained in:
Willian Mitsuda 2021-09-22 15:30:54 -03:00
parent b5c76a4e01
commit 5e982d3b55
2 changed files with 15 additions and 10 deletions

View File

@ -18,6 +18,7 @@ type TokenTransferItemProps = {
tokenMetas: TokenMetas; tokenMetas: TokenMetas;
}; };
// TODO: handle partial
const TokenTransferItem: React.FC<TokenTransferItemProps> = ({ const TokenTransferItem: React.FC<TokenTransferItemProps> = ({
t, t,
txData, txData,

View File

@ -225,6 +225,7 @@ export const useTxData = (
continue; continue;
} }
const erc20Contract = new Contract(t.token, erc20, provider); const erc20Contract = new Contract(t.token, erc20, provider);
try {
const [name, symbol, decimals] = await Promise.all([ const [name, symbol, decimals] = await Promise.all([
erc20Contract.name(), erc20Contract.name(),
erc20Contract.symbol(), erc20Contract.symbol(),
@ -235,6 +236,9 @@ export const useTxData = (
symbol, symbol,
decimals, decimals,
}; };
} catch (err) {
console.warn(`Couldn't get token ${t.token} metadata; ignoring`, err);
}
} }
setTxData({ setTxData({