Repository: trustwallet/blockatlas
Pull request #1379 (2021-01-22 04:14:33)

Add GetTokenListIdsByAddress to TokensAPI

codecov[bot]: # [Codecov](https://codecov.io/gh/trustwallet/blockatlas/pull/1379?src=pr&el=h1) Report
> Merging [#1379](https://codecov.io/gh/trustwallet/blockatlas/pull/1379?src=pr&el=desc) (eff638b) into [master](https://codecov.io/gh/trustwallet/blockatlas/commit/a722330b69138ada884ee03f362dd79fbdf874e6?el=desc) (a722330) will **decrease** coverage by `0%`.
> The diff coverage is `48%`.

[![Impacted file tree graph](https://codecov.io/gh/trustwallet/blockatlas/pull/1379/graphs/tree.svg?width=650&height=150&src=pr&token=jnrjoEQAqv)](https://codecov.io/gh/trustwallet/blockatlas/pull/1379?src=pr&el=tree)

```diff
@@          Coverage Diff           @@
##           master   #1379   +/-   ##
======================================
- Coverage      44%     44%   -1%     
======================================
  Files         145     146    +1     
  Lines        4148    4164   +16     
======================================
+ Hits         1864    1868    +4     
- Misses       2115    2127   +12     
  Partials      169     169           
```


| [Impacted Files](https://codecov.io/gh/trustwallet/blockatlas/pull/1379?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [pkg/blockatlas/models.go](https://codecov.io/gh/trustwallet/blockatlas/pull/1379/diff?src=pr&el=tree#diff-cGtnL2Jsb2NrYXRsYXMvbW9kZWxzLmdv) | `0% <0%> (ø)` | |
| [pkg/blockatlas/platform.go](https://codecov.io/gh/trustwallet/blockatlas/pull/1379/diff?src=pr&el=tree#diff-cGtnL2Jsb2NrYXRsYXMvcGxhdGZvcm0uZ28=) | `100% <ø> (ø)` | |
| [platform/binance/token.go](https://codecov.io/gh/trustwallet/blockatlas/pull/1379/diff?src=pr&el=tree#diff-cGxhdGZvcm0vYmluYW5jZS90b2tlbi5nbw==) | `27% <0%> (-16%)` | :arrow_down: |
| [platform/ethereum/transaction.go](https://codecov.io/gh/trustwallet/blockatlas/pull/1379/diff?src=pr&el=tree#diff-cGxhdGZvcm0vZXRoZXJldW0vdHJhbnNhY3Rpb24uZ28=) | `28% <0%> (-39%)` | :arrow_down: |
| [platform/ethereum/trustray/token.go](https://codecov.io/gh/trustwallet/blockatlas/pull/1379/diff?src=pr&el=tree#diff-cGxhdGZvcm0vZXRoZXJldW0vdHJ1c3RyYXkvdG9rZW4uZ28=) | `50% <0%> (ø)` | |
| [platform/tron/token.go](https://codecov.io/gh/trustwallet/blockatlas/pull/1379/diff?src=pr&el=tree#diff-cGxhdGZvcm0vdHJvbi90b2tlbi5nbw==) | `44% <50%> (-23%)` | :arrow_down: |
| [platform/binance/model.go](https://codecov.io/gh/trustwallet/blockatlas/pull/1379/diff?src=pr&el=tree#diff-cGxhdGZvcm0vYmluYW5jZS9tb2RlbC5nbw==) | `72% <100%> (ø)` | |
| [platform/bitcoin/blockbook/token.go](https://codecov.io/gh/trustwallet/blockatlas/pull/1379/diff?src=pr&el=tree#diff-cGxhdGZvcm0vYml0Y29pbi9ibG9ja2Jvb2svdG9rZW4uZ28=) | `76% <100%> (+20%)` | :arrow_up: |

------

[Continue to review full report at Codecov](https://codecov.io/gh/trustwallet/blockatlas/pull/1379?src=pr&el=continue).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/trustwallet/blockatlas/pull/1379?src=pr&el=footer). Last update [a722330...eff638b](https://codecov.io/gh/trustwallet/blockatlas/pull/1379?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).


Patch:
diff --git a/api/endpoint/token.go b/api/endpoint/token.go
index dfdb975..8df391f 100644
--- a/api/endpoint/token.go
+++ b/api/endpoint/token.go
@@ -37,6 +37,21 @@ func GetTokensByAddress(c *gin.Context, tokenAPI blockatlas.TokensAPI) {
 	c.JSON(http.StatusOK, result)
 }
 
+func GetTokensIdsByAddress(c *gin.Context, tokenAPI blockatlas.TokensAPI) {
+	address := c.Param("address")
+	if address == "" {
+		c.JSON(http.StatusOK, types.TxPage{})
+		return
+	}
+
+	result, err := tokenAPI.GetTokenListIdsByAddress(address)
+	if err != nil {
+		c.AbortWithStatusJSON(http.StatusInternalServerError, errorResponse(err))
+		return
+	}
+	c.JSON(http.StatusOK, result)
+}
+
 func GetTokensByAddressV3(c *gin.Context, instance tokenindexer.Instance) {
 	var query tokenindexer.GetTokensByAddressRequest
 	if err := c.Bind(&query); err != nil {
diff --git a/api/registry.go b/api/registry.go
index 48f5fee..9534656 100644
--- a/api/registry.go
+++ b/api/registry.go
@@ -56,6 +56,9 @@ func RegisterTokensAPI(router gin.IRouter, api blockatlas.Platform) {
 	router.GET("/v2/"+handle+"/tokens/:address", func(c *gin.Context) {
 		endpoint.GetTokensByAddress(c, tokenAPI)
 	})
+	router.GET("/v2/"+handle+"/tokens/:address/ids", func(c *gin.Context) {
+		endpoint.GetTokensIdsByAddress(c, tokenAPI)
+	})
 }
 
 func RegisterStakeAPI(router gin.IRouter, api blockatlas.Platform) {
diff --git a/go.mod b/go.mod
index fc88b66..1d356bd 100644
--- a/go.mod
+++ b/go.mod
@@ -24,7 +24,7 @@ require (
 	github.com/stretchr/testify v1.7.0
 	github.com/swaggo/gin-swagger v1.3.0
 	github.com/swaggo/swag v1.7.0
-	github.com/trustwallet/golibs v0.0.39
+	github.com/trustwallet/golibs v0.0.40
 	github.com/trustwallet/golibs/network v0.0.0-20210121062720-6eaa67ade593
 	golang.org/x/crypto v0.0.0-20201124201722-c8d3bf9c5392
 	golang.org/x/net v0.0.0-20201224014010-6772e930b67b // indirect
diff --git a/go.sum b/go.sum
index 25c6291..939b672 100644
--- a/go.sum
+++ b/go.sum
@@ -418,14 +418,10 @@ github.com/swaggo/swag v1.5.1/go.mod h1:1Bl9F/ZBpVWh22nY0zmYyASPO1lI/zIwRDrpZU+t
 github.com/swaggo/swag v1.7.0 h1:5bCA/MTLQoIqDXXyHfOpMeDvL9j68OY/udlK4pQoo4E=
 github.com/swaggo/swag v1.7.0/go.mod h1:BdPIL73gvS9NBsdi7M1JOxLvlbfvNRaBP8m6WT6Aajo=
 github.com/tmc/grpc-websocket-proxy v0.0.0-20190109142713-0ad062ec5ee5/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U=
-github.com/trustwallet/golibs v0.0.34 h1:/6XobjSYf2YZ5tqJLf4ZqhNZGNuXsRyM61ZCwt5tuxo=
-github.com/trustwallet/golibs v0.0.34/go.mod h1:VI0APImKAYxvJ8MnMD6aHSKvnArXUd3NgNEghX5P+K8=
 github.com/trustwallet/golibs v0.0.35 h1:VqWInO5s4Zg6XyCmqro8/xrEViOedZ3oYtBq/kn4fBg=
 github.com/trustwallet/golibs v0.0.35/go.mod h1:VI0APImKAYxvJ8MnMD6aHSKvnArXUd3NgNEghX5P+K8=
-github.com/trustwallet/golibs v0.0.39 h1:OQ+zkc6mr266e3BCXwxg8NppkyDPKpvTHVJS7ejVML4=
-github.com/trustwallet/golibs v0.0.39/go.mod h1:SQ3mijAuOTX9GRyaqph3NY2ox04JD5WQ6PkWqX2NB8w=
-github.com/trustwallet/golibs/network v0.0.0-20210119064642-74e68ef98cfe h1:nQGIQUV8JQzYZLN0jNRW8v+p6+UlC83ikNGZCsrEHl8=
-github.com/trustwallet/golibs/network v0.0.0-20210119064642-74e68ef98cfe/go.mod h1:RMMyjp4qUcVhWidjE+XYzQgOtSXuhIKSB5pnLCA3WqY=
+github.com/trustwallet/golibs v0.0.40 h1:9zWFFQNaCHSQfEyPQ6gD9Wdq4NL0du9ERbHVDKK58rM=
+github.com/trustwallet/golibs v0.0.40/go.mod h1:SQ3mijAuOTX9GRyaqph3NY2ox04JD5WQ6PkWqX2NB8w=
 github.com/trustwallet/golibs/network v0.0.0-20210121062720-6eaa67ade593 h1:J+nbswDE9lS2ITYW4SgFxTvo8lz+LEwIokyZZaC58Ps=
 github.com/trustwallet/golibs/network v0.0.0-20210121062720-6eaa67ade593/go.mod h1:LDMLFnOnwmC30WuCCIJ56TWeXxwCVcrMFJYeC6GEnxY=
 github.com/ugorji/go v1.1.4/go.mod h1:uQMGLiO92mf5W77hV/PUCpI3pbzQx3CRekS0kk+RGrc=
diff --git a/pkg/blockatlas/platform.go b/pkg/blockatlas/platform.go
index 5e718b5..001201c 100644
--- a/pkg/blockatlas/platform.go
+++ b/pkg/blockatlas/platform.go
@@ -39,7 +39,8 @@ type (
 	// TokensAPI provides token lookups
 	TokensAPI interface {
 		Platform
-		GetTokenListByAddress(address string) ([]string, error)
+		GetTokenListByAddress(address string) ([]types.Token, error)
+		GetTokenListIdsByAddress(address string) ([]string, error)
 	}
 
 	// StakingAPI provides staking information
diff --git a/platform/binance/mocks/tokens.json b/platform/binance/mocks/tokens.json
index c165618..8f8d1bc 100644
--- a/platform/binance/mocks/tokens.json
+++ b/platform/binance/mocks/tokens.json
@@ -1,5 +1,26 @@
 [
-  "c714_tAVA-645",
-  "c714_tBNB",
-  "c714_tBUSD-BD1"
+  {
+    "name": "Travala.com Token",
+    "symbol": "AVA",
+    "decimals": 8,
+    "token_id": "AVA-645",
+    "coin": 714,
+    "type": "BEP2"
+  },
+  {
+    "name": "Binance Chain Native Token",
+    "symbol": "BNB",
+    "decimals": 8,
+    "token_id": "BNB",
+    "coin": 714,
+    "type": "BEP2"
+  },
+  {
+    "name": "Binance USD",
+    "symbol": "BUSD",
+    "decimals": 8,
+    "token_id": "BUSD-BD1",
+    "coin": 714,
+    "type": "BEP2"
+  }
 ]
diff --git a/platform/binance/model.go b/platform/binance/model.go
index dfa2c2b..e653955 100644
--- a/platform/binance/model.go
+++ b/platform/binance/model.go
@@ -215,14 +215,12 @@ func normalizeBaseOfTransaction(t Tx) types.Tx {
 	}
 }
 
-func normalizeTokens(srcBalance []TokenBalance, tokens Tokens) []string {
-	assetIds := make([]string, 0)
+func normalizeTokens(srcBalance []TokenBalance, tokens Tokens) []types.Token {
+	assetIds := make([]types.Token, 0)
 	for _, srcToken := range srcBalance {
-		token, ok := normalizeToken(srcToken, tokens)
-		if !ok {
-			continue
+		if token, ok := normalizeToken(srcToken, tokens); ok {
+			assetIds = append(assetIds, token)
 		}
-		assetIds = append(assetIds, token.AssetId())
 	}
 	return assetIds
 }
@@ -250,20 +248,6 @@ func normalizeToken(srcToken TokenBalance, tokens Tokens) (types.Token, bool) {
 	return result, true
 }
 
-//func getTransactionData(rawOrderData string) (TransactionData, error) {
-//	var result TransactionData
-//	err := json.Unmarshal([]byte(rawOrderData), &result)
-//	return result, err
-//}
-//
-//func getTokenIDsFromPair(pair string) (string, string) {
-//	result := strings.Split(pair, "_")
-//	if len(result) == 1 || len(result) == 0 {
-//		return pair, pair
-//	}
-//	return result[0], result[1]
-//}
-
 func getTokenSymbolFromID(tokenID string) string {
 	s := strings.Split(tokenID, "-")
 	if len(s) > 1 {
diff --git a/platform/binance/token.go b/platform/binance/token.go
index 2989314..4ae4ac7 100644
--- a/platform/binance/token.go
+++ b/platform/binance/token.go
@@ -1,6 +1,10 @@
 package binance
 
-func (p *Platform) GetTokenListByAddress(address string) ([]string, error) {
+import (
+	"github.com/trustwallet/golibs/types"
+)
+
+func (p *Platform) GetTokenListByAddress(address string) ([]types.Token, error) {
 	account, err := p.client.FetchAccountMeta(address)
 	if err != nil || len(account.Balances) == 0 {
 		return nil, nil
@@ -11,3 +15,11 @@ func (p *Platform) GetTokenListByAddress(address string) ([]string, error) {
 	}
 	return normalizeTokens(account.Balances, tokens), nil
 }
+
+func (p *Platform) GetTokenListIdsByAddress(address string) ([]string, error) {
+	assets, err := p.GetTokenListByAddress(address)
+	if err != nil {
+		return []string{}, err
+	}
+	return types.GetAssetsIds(assets), nil
+}
diff --git a/platform/bitcoin/blockbook/token.go b/platform/bitcoin/blockbook/token.go
index 429faa9..da04de1 100644
--- a/platform/bitcoin/blockbook/token.go
+++ b/platform/bitcoin/blockbook/token.go
@@ -1,10 +1,10 @@
 package blockbook
 
 import (
-	"github.com/trustwallet/golibs/asset"
+	"github.com/trustwallet/golibs/types"
 )
 
-func (c *Client) GetTokenList(address string, coinIndex uint) ([]string, error) {
+func (c *Client) GetTokenList(address string, coinIndex uint) ([]types.Token, error) {
 	tokens, err := c.GetTokens(address)
 	if err != nil {
 		return nil, err
@@ -12,13 +12,25 @@ func (c *Client) GetTokenList(address string, coinIndex uint) ([]string, error)
 	return NormalizeTokens(tokens, coinIndex), nil
 }
 
-func NormalizeTokens(srcTokens []Token, coinIndex uint) []string {
-	tokenPage := make([]string, 0)
-	for _, srcToken := range srcTokens {
+func NormalizeTokens(tokens []Token, coinIndex uint) []types.Token {
+	assets := make([]types.Token, 0)
+	for _, srcToken := range tokens {
 		if srcToken.Balance == "0" || srcToken.Balance == "" {
 			continue
 		}
-		tokenPage = append(tokenPage, asset.BuildID(coinIndex, srcToken.Contract))
+		token := NormalizeToken(&srcToken, coinIndex)
+		assets = append(assets, token)
+	}
+	return assets
+}
+
+func NormalizeToken(srcToken *Token, coinIndex uint) types.Token {
+	return types.Token{
+		Name:     srcToken.Name,
+		Symbol:   srcToken.Symbol,
+		TokenID:  srcToken.Contract,
+		Coin:     coinIndex,
+		Decimals: srcToken.Decimals,
+		Type:     types.GetEthereumTokenTypeByIndex(coinIndex),
 	}
-	return tokenPage
 }
diff --git a/platform/ethereum/client.go b/platform/ethereum/client.go
index 020345c..1a81fa9 100644
--- a/platform/ethereum/client.go
+++ b/platform/ethereum/client.go
@@ -5,7 +5,7 @@ import "github.com/trustwallet/golibs/types"
 type EthereumClient interface {
 	GetTransactions(address string, coinIndex uint) (types.TxPage, error)
 	GetTokenTxs(address, token string, coinIndex uint) (types.TxPage, error)
-	GetTokenList(address string, coinIndex uint) ([]string, error)
+	GetTokenList(address string, coinIndex uint) ([]types.Token, error)
 	GetCurrentBlockNumber() (int64, error)
 	GetBlockByNumber(num int64, coinIndex uint) (*types.Block, error)
 }
diff --git a/platform/ethereum/transaction.go b/platform/ethereum/transaction.go
index 89348a5..564cf7c 100644
--- a/platform/ethereum/transaction.go
+++ b/platform/ethereum/transaction.go
@@ -1,6 +1,8 @@
 package ethereum
 
-import "github.com/trustwallet/golibs/types"
+import (
+	"github.com/trustwallet/golibs/types"
+)
 
 func (p *Platform) GetTxsByAddress(address string) (types.TxPage, error) {
 	return p.client.GetTransactions(address, p.CoinIndex)
@@ -10,6 +12,14 @@ func (p *Platform) GetTokenTxsByAddress(address string, token string) (types.TxP
 	return p.client.GetTokenTxs(address, token, p.CoinIndex)
 }
 
-func (p *Platform) GetTokenListByAddress(address string) ([]string, error) {
+func (p *Platform) GetTokenListByAddress(address string) ([]types.Token, error) {
 	return p.client.GetTokenList(address, p.CoinIndex)
 }
+
+func (p *Platform) GetTokenListIdsByAddress(address string) ([]string, error) {
+	assets, err := p.GetTokenListByAddress(address)
+	if err != nil {
+		return []string{}, err
+	}
+	return types.GetAssetsIds(assets), nil
+}
diff --git a/platform/ethereum/trustray/token.go b/platform/ethereum/trustray/token.go
index 78b07d5..c2d7732 100644
--- a/platform/ethereum/trustray/token.go
+++ b/platform/ethereum/trustray/token.go
@@ -4,7 +4,7 @@ import (
 	"github.com/trustwallet/golibs/types"
 )
 
-func (c *Client) GetTokenList(address string, coinIndex uint) ([]string, error) {
+func (c *Client) GetTokenList(address string, coinIndex uint) ([]types.Token, error) {
 	account, err := c.GetTokens(address)
 	if err != nil {
 		return nil, err
@@ -27,11 +27,11 @@ func NormalizeToken(srcToken *Contract, coinIndex uint) types.Token {
 }
 
 // NormalizeTxs converts multiple Ethereum tokens
-func NormalizeTokens(srcTokens []Contract, coinIndex uint) []string {
-	assetIds := make([]string, 0)
+func NormalizeTokens(srcTokens []Contract, coinIndex uint) []types.Token {
+	assets := make([]types.Token, 0)
 	for _, srcToken := range srcTokens {
 		token := NormalizeToken(&srcToken, coinIndex)
-		assetIds = append(assetIds, token.AssetId())
+		assets = append(assets, token)
 	}
-	return assetIds
+	return assets
 }
diff --git a/platform/tron/mocks/tokens/tokens_response.json b/platform/tron/mocks/tokens/tokens_response.json
index 36caf40..da85d07 100644
--- a/platform/tron/mocks/tokens/tokens_response.json
+++ b/platform/tron/mocks/tokens/tokens_response.json
@@ -1,5 +1,4 @@
 [
-  "c195_t1000567",
   "c195_tTCFLL5dx5ZJdKnWuesXxi1VPwjLVmWZZy9",
   "c195_tTCRhVHPv6efvXgogNMhiunAMXFKcMmv2pF",
   "c195_tTG7Z1ptC7nRkaniDVRhHSyLycaroaS5PdK",
diff --git a/platform/tron/token.go b/platform/tron/token.go
index 9c19291..105a502 100644
--- a/platform/tron/token.go
+++ b/platform/tron/token.go
@@ -2,9 +2,14 @@ package tron
 
 import (
 	"github.com/trustwallet/golibs/asset"
+	"github.com/trustwallet/golibs/types"
 )
 
-func (p *Platform) GetTokenListByAddress(address string) ([]string, error) {
+func (p *Platform) GetTokenListByAddress(address string) ([]types.Token, error) {
+	return []types.Token{}, nil
+}
+
+func (p *Platform) GetTokenListIdsByAddress(address string) ([]string, error) {
 	assetIds := make([]string, 0)
 	tokens, err := p.gridClient.fetchAccount(address)
 	if err != nil {
@@ -13,20 +18,11 @@ func (p *Platform) GetTokenListByAddress(address string) ([]string, error) {
 	if len(tokens.Data) == 0 {
 		return assetIds, nil
 	}
-	data := tokens.Data[0]
-
-	var tokenIds []string
-	for _, v := range data.AssetsV2 {
-		tokenIds = append(assetIds, v.Key)
-	}
-	for _, trc20Tokens := range data.Trc20 {
-		for key := range trc20Tokens {
-			tokenIds = append(tokenIds, key)
+	for _, trc20Tokens := range tokens.Data[0].Trc20 {
+		for assetId := range trc20Tokens {
+			assetIds = append(assetIds, asset.BuildID(p.Coin().ID, assetId))
 		}
 	}
-	for _, tokenId := range tokenIds {
-		assetIds = append(assetIds, asset.BuildID(p.Coin().ID, tokenId))
-	}
 
 	return assetIds, nil
 }
diff --git a/services/tokenindexer/indexer_subscribe.go b/services/tokenindexer/indexer_subscribe.go
index bb87414..8ccdfa9 100644
--- a/services/tokenindexer/indexer_subscribe.go
+++ b/services/tokenindexer/indexer_subscribe.go
@@ -45,7 +45,7 @@ func RunTokenIndexerSubscribe(database *db.Instance, apis map[uint]blockatlas.To
 			if !ok {
 				continue
 			}
-			assetIds, err := api.GetTokenListByAddress(coinAddress.Address)
+			assetIds, err := api.GetTokenListIdsByAddress(coinAddress.Address)
 			if err != nil {
 				continue
 			}


Test patch:
diff --git a/platform/bitcoin/blockbook/token_test.go b/platform/bitcoin/blockbook/token_test.go
index a1a1ed0..1355277 100644
--- a/platform/bitcoin/blockbook/token_test.go
+++ b/platform/bitcoin/blockbook/token_test.go
@@ -3,6 +3,8 @@ package blockbook
 import (
 	"reflect"
 	"testing"
+
+	"github.com/trustwallet/golibs/types"
 )
 
 func TestNormalizeToken(t *testing.T) {
@@ -13,42 +15,53 @@ func TestNormalizeToken(t *testing.T) {
 	tests := []struct {
 		name string
 		args args
-		want []string
+		want []types.Token
 	}{
 		{
 			name: "Should normalize and return token with balance",
 			args: args{srcToken: Token{
 				Balance:  "100",
 				Type:     "ERC20",
-				Name:     "USD//C",
+				Name:     "USD Coin",
 				Contract: "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
 				Symbol:   "USDC",
 				Decimals: 6},
 				coinIndex: 60},
-			want: []string{"c60_t0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48"},
+			want: []types.Token{
+				{
+					Type:     "ERC20",
+					Name:     "USD Coin",
+					TokenID:  "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
+					Symbol:   "USDC",
+					Decimals: 6,
+					Coin:     60,
+				},
+			},
 		},
 		{
 			name: "Should not return token with zero balance",
 			args: args{srcToken: Token{
 				Balance:  "0",
 				Type:     "ERC20",
-				Name:     "USD//C",
+				Name:     "USD Coin",
 				Contract: "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
 				Symbol:   "USDC",
 				Decimals: 6},
-				coinIndex: 60},
-			want: []string{},
+				coinIndex: 60,
+			},
+			want: []types.Token{},
 		}, {
 			name: "Should not return token with zero balance",
 			args: args{srcToken: Token{
 				Balance:  "",
 				Type:     "ERC20",
-				Name:     "USD//C",
+				Name:     "USD Coin",
 				Contract: "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
 				Symbol:   "USDC",
 				Decimals: 6},
-				coinIndex: 60},
-			want: []string{},
+				coinIndex: 60,
+			},
+			want: []types.Token{},
 		},
 	}
 	for _, tt := range tests {
diff --git a/platform/ethereum/transaction_test.go b/platform/ethereum/transaction_test.go
index 5c846ba..b7d697b 100644
--- a/platform/ethereum/transaction_test.go
+++ b/platform/ethereum/transaction_test.go
@@ -55,8 +55,8 @@ func (c Client) GetTokenTxs(address, token string, coinIndex uint) (types.TxPage
 	return txs, nil
 }
 
-func (c Client) GetTokenList(address string, coinIndex uint) ([]string, error) {
-	return []string{}, nil
+func (c Client) GetTokenList(address string, coinIndex uint) ([]types.Token, error) {
+	return []types.Token{}, nil
 }
 
 func (c Client) GetCurrentBlockNumber() (int64, error) {
diff --git a/platform/tron/token_test.go b/platform/tron/token_test.go
index 8ccde95..f7af4dd 100644
--- a/platform/tron/token_test.go
+++ b/platform/tron/token_test.go
@@ -17,7 +17,7 @@ func TestPlatform_GetTokenListByAddress(t *testing.T) {
 	defer server.Close()
 
 	p := Init(server.URL, server.URL)
-	res, err := p.GetTokenListByAddress("TM1zzNDZD2DPASbKcgdVoTYhfmYgtfwx9R")
+	res, err := p.GetTokenListIdsByAddress("TM1zzNDZD2DPASbKcgdVoTYhfmYgtfwx9R")
 	assert.Nil(t, err)
 	sort.Slice(res, func(i, j int) bool {
 		return res[i] < res[j]