(tokenAddress: Address)
| 200 | } |
| 201 | |
| 202 | function fetchTokenSymbol(tokenAddress: Address): string { |
| 203 | let staticToken = StaticToken.fromAddress(tokenAddress); |
| 204 | if (staticToken != null) { |
| 205 | return (staticToken as StaticToken).symbol; |
| 206 | } |
| 207 | |
| 208 | let contract = ERC20.bind(tokenAddress); |
| 209 | let contractSymbolBytes = ERC20SymbolBytes.bind(tokenAddress); |
| 210 | |
| 211 | // try types string and bytes32 for symbol |
| 212 | let symbolValue = 'unknown'; |
| 213 | let symbolResult = contract.try_symbol(); |
| 214 | if (symbolResult.reverted) { |
| 215 | let symbolResultBytes = contractSymbolBytes.try_symbol(); |
| 216 | if (!symbolResultBytes.reverted) { |
| 217 | // for token that has no symbol function exposed |
| 218 | if (!isNullEthValue(symbolResultBytes.value.toHexString())) { |
| 219 | symbolValue = symbolResultBytes.value.toString(); |
| 220 | } |
| 221 | } |
| 222 | } else { |
| 223 | symbolValue = symbolResult.value; |
| 224 | } |
| 225 | |
| 226 | return symbolValue; |
| 227 | } |
| 228 | |
| 229 | function fetchTokenName(tokenAddress: Address): string { |
| 230 | let staticToken = StaticToken.fromAddress(tokenAddress); |
no test coverage detected