Fix ERC resolver for tokens with empty name/symbol
This commit is contained in:
parent
087b531905
commit
e640d11a16
|
@ -11,11 +11,17 @@ export class ERCTokenResolver implements IAddressResolver<TokenMeta> {
|
||||||
): Promise<TokenMeta | undefined> {
|
): Promise<TokenMeta | undefined> {
|
||||||
const erc20Contract = new Contract(address, erc20, provider);
|
const erc20Contract = new Contract(address, erc20, provider);
|
||||||
try {
|
try {
|
||||||
const [name, symbol, decimals] = await Promise.all([
|
const [name, symbol, decimals] = (await Promise.all([
|
||||||
erc20Contract.name(),
|
erc20Contract.name(),
|
||||||
erc20Contract.symbol(),
|
erc20Contract.symbol(),
|
||||||
erc20Contract.decimals(),
|
erc20Contract.decimals(),
|
||||||
]);
|
])) as [string, string, number];
|
||||||
|
|
||||||
|
// Prevent faulty tokens with empty name/symbol
|
||||||
|
if (!name.trim() || !symbol.trim()) {
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
name,
|
name,
|
||||||
symbol,
|
symbol,
|
||||||
|
|
Loading…
Reference in New Issue