This commit is contained in:
Alex Coseru 2022-02-21 13:06:20 +02:00 committed by GitHub
parent f5c7eeae00
commit 3aabf53da4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -11,11 +11,17 @@ export function createToken(address: Address, isDatatoken: boolean): Token {
} }
const token = new Token(address.toHexString()) const token = new Token(address.toHexString())
const contract = ERC20.bind(address) const contract = ERC20.bind(address)
token.name = contract.name() const name = contract.try_name()
token.symbol = contract.symbol() if (name.reverted) token.name = ''
else token.name = name.value
const symbol = contract.try_symbol()
if (name.reverted) token.symbol = ''
else token.symbol = symbol.value
token.address = address.toHexString() token.address = address.toHexString()
token.isDatatoken = isDatatoken token.isDatatoken = isDatatoken
token.decimals = contract.decimals() const decimals = contract.try_decimals()
if (decimals.reverted) token.decimals = 18
else token.decimals = decimals.value
token.save() token.save()
return token return token
} }