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
1 changed files with 9 additions and 3 deletions

View File

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