Files
assets/internal/info/external/spl.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

38 lines
737 B
Go

package external
import (
"fmt"
"github.com/trustwallet/assets-go-libs/http"
)
const splAPIURL = "https://public-api.solscan.io/token/holders?tokenAddress=%s"
type TokenInfoSPL struct {
Data []Data `json:"data"`
HoldersCount int `json:"total"`
}
type Data struct {
Decimals int `json:"decimals"`
}
func GetTokenInfoForSPL(tokenID string) (*TokenInfo, error) {
url := fmt.Sprintf(splAPIURL, tokenID)
var result TokenInfoSPL
err := http.GetHTTPResponse(url, &result)
if err != nil {
return nil, err
}
if len(result.Data) == 0 {
return nil, fmt.Errorf("failed to get token info for SPL token")
}
return &TokenInfo{
Decimals: result.Data[0].Decimals,
HoldersCount: result.HoldersCount,
}, nil
}