Skip to content

Commit

Permalink
Unable to fetch token information (TRON TRC20 token)
Browse files Browse the repository at this point in the history
Closed #150
  • Loading branch information
furenster committed Feb 15, 2025
1 parent 3adc634 commit 803eaa0
Showing 1 changed file with 8 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,14 @@ class TronGetTokenClient(
private val rpcClient: TronRpcClient,
) : GetTokenClient {
override suspend fun getTokenData(tokenId: String): Asset? = withContext(Dispatchers.IO) {
if (!AnyAddress.isValid(tokenId, WCChainTypeProxy().invoke(chain))) {
val coinType = WCChainTypeProxy().invoke(chain)
if (!AnyAddress.isValid(tokenId, coinType)) {
return@withContext null
}
val getName = async { getName(tokenId) }
val getSymbol = async { getSymbol(tokenId) }
val getDecimals = async { getDecimals(tokenId) }
val contract = AnyAddress(tokenId, coinType).description()
val getName = async { getName(contract) }
val getSymbol = async { getSymbol(contract) }
val getDecimals = async { getDecimals(contract) }
val name = getName.await() ?: return@withContext null
val symbol = getSymbol.await() ?: return@withContext null
val decimals = getDecimals.await() ?: return@withContext null
Expand Down Expand Up @@ -65,8 +67,9 @@ class TronGetTokenClient(
}

private suspend fun smartContractCallFunction(contract: String, function: String): String? {
val contract = "41" + Base58.decode(contract).toHexString("").drop(2)
val result = rpcClient.triggerSmartContract(
contractAddress = "41" + Base58.decode(contract).toHexString("").drop(2),
contractAddress = contract,
functionSelector = function,
parameter = null,
feeLimit = null,
Expand Down

0 comments on commit 803eaa0

Please sign in to comment.