Fix ERC resolver for tokens with empty name/symbol

This commit is contained in:
Willian Mitsuda 2021-11-21 09:04:08 -03:00
parent 087b531905
commit e640d11a16
1 changed files with 8 additions and 2 deletions

View File

@ -11,11 +11,17 @@ export class ERCTokenResolver implements IAddressResolver<TokenMeta> {
): Promise<TokenMeta | undefined> {
const erc20Contract = new Contract(address, erc20, provider);
try {
const [name, symbol, decimals] = await Promise.all([
const [name, symbol, decimals] = (await Promise.all([
erc20Contract.name(),
erc20Contract.symbol(),
erc20Contract.decimals(),
]);
])) as [string, string, number];
// Prevent faulty tokens with empty name/symbol
if (!name.trim() || !symbol.trim()) {
return undefined;
}
return {
name,
symbol,