mirror of
https://github.com/oceanprotocol/ocean-subgraph.git
synced 2024-12-02 05:57:29 +01:00
parent
f5c7eeae00
commit
3aabf53da4
@ -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
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user