Files
assets/internal/info/external/trc10.go
T
2204745e34 Add Injective assets (#27191)
* Create logo .png

* Create logo.png

* Create info.json

* Create logo.png

* Create info.json

* Create info.json

* Create logo.png

* Create info.json

* Create logo.png

* Create info.json

* Update info.json

* Update info.json

* Update info.json

* Update info.json

* Update info.json

* Create logo.png

* Delete logo .png

* tokens

* tokens

* tokens

* tokens

* tokens

* tokens

---------

Co-authored-by: Denis <136321897+defisaur@users.noreply.github.com>
2024-01-12 15:49:54 +04:00

39 lines
785 B
Go

package external
import (
"errors"
"fmt"
"github.com/trustwallet/assets-go-libs/http"
)
const trc10APIURL = "https://apilist.tronscan.io/api/token?id=%s"
type TRC10TokensResponse struct {
Data []struct {
Symbol string `json:"abbr"`
Decimals int `json:"precision"`
HoldersCount int `json:"nrOfTokenHolders"`
} `json:"data"`
}
func GetTokenInfoForTRC10(tokenID string) (*TokenInfo, error) {
url := fmt.Sprintf(trc10APIURL, tokenID)
var res TRC10TokensResponse
err := http.GetHTTPResponse(url, &res)
if err != nil {
return nil, err
}
if len(res.Data) == 0 {
return nil, errors.New("not found")
}
return &TokenInfo{
Symbol: res.Data[0].Symbol,
Decimals: res.Data[0].Decimals,
HoldersCount: res.Data[0].HoldersCount,
}, nil
}