Skip to content

Commit c8863a7

Browse files
authored
Add assets-manager client (#68)
1 parent a5c15bb commit c8863a7

File tree

4 files changed

+89
-6
lines changed

4 files changed

+89
-6
lines changed

client/assets-manager/client.go

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
package assetsmanager
2+
3+
import (
4+
"time"
5+
6+
"github.com/trustwallet/go-libs/client"
7+
)
8+
9+
type Client struct {
10+
req client.Request
11+
}
12+
13+
func InitClient(url string, errorHandler client.HttpErrorHandler) Client {
14+
return Client{
15+
req: client.InitJSONClient(url, errorHandler),
16+
}
17+
}
18+
19+
func (c *Client) ValidateAssetInfo(req *AssetValidationReq) (result AssetValidationResp, err error) {
20+
err = c.req.Post(&result, "/v1/validate/asset_info", req)
21+
22+
return result, err
23+
}
24+
25+
func (c *Client) GetTagValues() (result TagValuesResp, err error) {
26+
err = c.req.GetWithCache(&result, "/v1/values/tags", nil, time.Hour)
27+
28+
return result, err
29+
}

client/assets-manager/model.go

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
package assetsmanager
2+
3+
type (
4+
AssetValidationReq struct {
5+
Name *string `json:"name,omitempty"`
6+
Symbol *string `json:"symbol,omitempty"`
7+
Type *string `json:"type,omitempty"`
8+
Decimals *int `json:"decimals,omitempty"`
9+
Description *string `json:"description,omitempty"`
10+
Website *string `json:"website,omitempty"`
11+
Explorer *string `json:"explorer,omitempty"`
12+
Research string `json:"research,omitempty"`
13+
Status *string `json:"status,omitempty"`
14+
ID *string `json:"id,omitempty"`
15+
Links []Link `json:"links,omitempty"`
16+
ShortDesc *string `json:"short_desc,omitempty"`
17+
Audit *string `json:"audit,omitempty"`
18+
AuditReport *string `json:"audit_report,omitempty"`
19+
Tags []string `json:"tags,omitempty"`
20+
Code *string `json:"code,omitempty"`
21+
Ticker *string `json:"ticker,omitempty"`
22+
ExplorerEth *string `json:"explorer-ETH,omitempty"`
23+
Address *string `json:"address,omitempty"`
24+
Twitter *string `json:"twitter,omitempty"`
25+
CoinMarketcap *string `json:"coinmarketcap,omitempty"`
26+
DataSource *string `json:"data_source,omitempty"`
27+
}
28+
29+
AssetValidationResp struct {
30+
Status string `json:"status"`
31+
Errors []Error `json:"errors"`
32+
}
33+
34+
Link struct {
35+
Name *string `json:"name,omitempty"`
36+
URL *string `json:"url,omitempty"`
37+
}
38+
39+
Error struct {
40+
Message string `json:"message"`
41+
}
42+
)
43+
44+
type (
45+
TagValuesResp struct {
46+
Tags []Tag `json:"tags"`
47+
}
48+
49+
Tag struct {
50+
ID string `json:"id"`
51+
Name string `json:"name"`
52+
Description string `json:"description"`
53+
}
54+
)

go.mod

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,11 @@ go 1.17
44

55
require github.com/trustwallet/go-primitives v0.0.24
66

7-
require (
8-
github.com/davecgh/go-spew v1.1.1 // indirect
9-
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b // indirect
10-
)
7+
require github.com/patrickmn/go-cache v2.1.0+incompatible // indirect
118

129
require (
1310
github.com/deckarep/golang-set v1.7.1 // indirect
11+
github.com/trustwallet/go-libs v0.2.25
1412
golang.org/x/crypto v0.0.0-20211209193657-4570a0811e8b // indirect
1513
golang.org/x/image v0.0.0-20211028202545-6944b10bf410
1614
golang.org/x/sys v0.0.0-20211213223007-03aa0b5f6827 // indirect

go.sum

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
2-
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
32
github.com/deckarep/golang-set v1.7.1 h1:SCQV0S6gTtp6itiFrTqI+pfmJ4LN85S1YzhDf9rTHJQ=
43
github.com/deckarep/golang-set v1.7.1/go.mod h1:93vsz/8Wt4joVM7c2AVqh+YRMiUSc14yDtF28KmMOgQ=
4+
github.com/patrickmn/go-cache v2.1.0+incompatible h1:HRMgzkcYKYpi3C8ajMPV8OFXaaRUnok+kx1WdO15EQc=
5+
github.com/patrickmn/go-cache v2.1.0+incompatible/go.mod h1:3Qf8kWWT7OJRJbdiICTKqZju1ZixQ/KpMGzzAfe6+WQ=
56
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
67
github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY=
8+
github.com/trustwallet/go-libs v0.2.25 h1:V/cRI70vHMcRIUI75W34bpw8JeMTu1CQDfHAhIUWWO0=
9+
github.com/trustwallet/go-libs v0.2.25/go.mod h1:7QdAp1lcteKKI0DYqGoaO8KO4eTNYjGmg8vHy0YXkKc=
710
github.com/trustwallet/go-primitives v0.0.24 h1:C1QGcX3dRL7gS2miJvSrRT732zRjob1Gd4D4dJvVwq8=
811
github.com/trustwallet/go-primitives v0.0.24/go.mod h1:jLqd7rm+4EYG5JdpxhngM9HwbqfEXzKy/wK4vUB7STs=
912
golang.org/x/crypto v0.0.0-20211209193657-4570a0811e8b h1:QAqMVf3pSa6eeTsuklijukjXBlj7Es2QQplab+/RbQ4=
@@ -19,4 +22,3 @@ gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8
1922
gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
2023
gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
2124
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b h1:h8qDotaEPuJATrMmW04NCwg7v22aHH28wwpauUhK9Oo=
22-
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=

0 commit comments

Comments
 (0)