buy/sell color change fix

This commit is contained in:
tim
2024-11-04 14:39:43 -04:00
parent 61101fcf0a
commit cfcba95445
5 changed files with 31 additions and 18 deletions

View File

@@ -61,21 +61,28 @@ export async function addExtraToken(chainId, addr) {
}
else {
if( provider===null ) {
console.log('warning: token lookup cancelled due to null provider', addr)
console.warn('warning: token lookup cancelled due to null provider', addr)
resolve(null)
}
else {
const token = await newContract(addr, 'IERC20Metadata', provider)
Promise.all( [token.name(), token.symbol(), token.decimals()] ).then((name,symbol,decimals)=>{
info = {
a: addr,
n: name,
s: symbol,
d: decimals,
for( let tries=1; tries<=5; tries++ ) {
try {
const token = await newContract(addr, 'IERC20Metadata', provider)
const [name, symbol, decimals] = await Promise.all([token.name(), token.symbol(), token.decimals()])
info = {
a: addr,
n: name,
s: symbol,
d: decimals,
}
s.addToken(chainId, info)
resolve(info)
break
}
s.addToken(chainId, info)
resolve(info)
})
catch (e) {
console.warn(`Could not lookup token ${addr}`, e)
}
}
}
}
})