mirror of
https://github.com/Instadapp/trustwallet-assets.git
synced 2024-07-29 22:37:31 +00:00
Update assets-go-libs version (#16703)
This commit is contained in:
parent
31eeb8e1b7
commit
675478e122
2
go.mod
2
go.mod
|
@ -4,7 +4,7 @@ go 1.17
|
||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/sirupsen/logrus v1.8.1
|
github.com/sirupsen/logrus v1.8.1
|
||||||
github.com/trustwallet/assets-go-libs v0.0.16
|
github.com/trustwallet/assets-go-libs v0.0.17
|
||||||
github.com/trustwallet/go-libs v0.2.21-0.20211217144209-59d4828f9793
|
github.com/trustwallet/go-libs v0.2.21-0.20211217144209-59d4828f9793
|
||||||
github.com/trustwallet/go-primitives v0.0.17
|
github.com/trustwallet/go-primitives v0.0.17
|
||||||
)
|
)
|
||||||
|
|
8
go.sum
8
go.sum
|
@ -42,6 +42,14 @@ github.com/subosito/gotenv v1.2.0 h1:Slr1R9HxAlEKefgq5jn9U+DnETlIUa6HfgEzj0g5d7s
|
||||||
github.com/subosito/gotenv v1.2.0/go.mod h1:N0PQaV/YGNqwC0u51sEeR/aUtSLEXKX9iv69rRypqCw=
|
github.com/subosito/gotenv v1.2.0/go.mod h1:N0PQaV/YGNqwC0u51sEeR/aUtSLEXKX9iv69rRypqCw=
|
||||||
github.com/trustwallet/assets-go-libs v0.0.16 h1:nbKrf/pHKQCut4Q5Mdg5BinLdFxOqvzEeAgIgzX0/P8=
|
github.com/trustwallet/assets-go-libs v0.0.16 h1:nbKrf/pHKQCut4Q5Mdg5BinLdFxOqvzEeAgIgzX0/P8=
|
||||||
github.com/trustwallet/assets-go-libs v0.0.16/go.mod h1:agKWTQ9ECSzQ++7P/9viSxJnG1Kp+WhfDyI3pAmtnVM=
|
github.com/trustwallet/assets-go-libs v0.0.16/go.mod h1:agKWTQ9ECSzQ++7P/9viSxJnG1Kp+WhfDyI3pAmtnVM=
|
||||||
|
github.com/trustwallet/assets-go-libs v0.0.17-0.20211220141041-3b3a722649fa h1:d+FAYtxmN8mJK9jobkzOotwSEU2KPZ9H4gmuBg6dv3M=
|
||||||
|
github.com/trustwallet/assets-go-libs v0.0.17-0.20211220141041-3b3a722649fa/go.mod h1:agKWTQ9ECSzQ++7P/9viSxJnG1Kp+WhfDyI3pAmtnVM=
|
||||||
|
github.com/trustwallet/assets-go-libs v0.0.17-0.20211220141745-408afc4f7467 h1:JYCmTXnQfR/RElBY9aFppwLVwvy7wuBNbtW5f31j1Vs=
|
||||||
|
github.com/trustwallet/assets-go-libs v0.0.17-0.20211220141745-408afc4f7467/go.mod h1:agKWTQ9ECSzQ++7P/9viSxJnG1Kp+WhfDyI3pAmtnVM=
|
||||||
|
github.com/trustwallet/assets-go-libs v0.0.17-0.20211220144503-44a66d3a5e92 h1:TT3IFY3cBZBQAMdoVA8bzdH8q58d8hkiiVpBAmZJ+J8=
|
||||||
|
github.com/trustwallet/assets-go-libs v0.0.17-0.20211220144503-44a66d3a5e92/go.mod h1:agKWTQ9ECSzQ++7P/9viSxJnG1Kp+WhfDyI3pAmtnVM=
|
||||||
|
github.com/trustwallet/assets-go-libs v0.0.17 h1:s/XF4C7peyFuKadoRr9YhjfMoWAx9yKzk2IFmtT5ZpM=
|
||||||
|
github.com/trustwallet/assets-go-libs v0.0.17/go.mod h1:agKWTQ9ECSzQ++7P/9viSxJnG1Kp+WhfDyI3pAmtnVM=
|
||||||
github.com/trustwallet/go-libs v0.2.21-0.20211217144209-59d4828f9793 h1:KFtyLpBPbMyUdeCth/Zcej/SSgAFIo6fxdS2eEPEg3I=
|
github.com/trustwallet/go-libs v0.2.21-0.20211217144209-59d4828f9793 h1:KFtyLpBPbMyUdeCth/Zcej/SSgAFIo6fxdS2eEPEg3I=
|
||||||
github.com/trustwallet/go-libs v0.2.21-0.20211217144209-59d4828f9793/go.mod h1:7QdAp1lcteKKI0DYqGoaO8KO4eTNYjGmg8vHy0YXkKc=
|
github.com/trustwallet/go-libs v0.2.21-0.20211217144209-59d4828f9793/go.mod h1:7QdAp1lcteKKI0DYqGoaO8KO4eTNYjGmg8vHy0YXkKc=
|
||||||
github.com/trustwallet/go-primitives v0.0.17 h1:1fBxZMKGCHdHtgdUzsqdFlD21+1GneIk/sxN6jxYBds=
|
github.com/trustwallet/go-primitives v0.0.17 h1:1fBxZMKGCHdHtgdUzsqdFlD21+1GneIk/sxN6jxYBds=
|
||||||
|
|
|
@ -1,12 +1,11 @@
|
||||||
package file
|
package file
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"regexp"
|
"regexp"
|
||||||
|
|
||||||
"github.com/trustwallet/assets-go-libs/pkg"
|
"github.com/trustwallet/assets-go-libs/strings"
|
||||||
"github.com/trustwallet/go-primitives/coin"
|
"github.com/trustwallet/go-primitives/coin"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -144,11 +143,11 @@ func ReadLocalFileStructure(root string, filesToSkip []string) ([]string, error)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
if pkg.Contains(path, filesToSkip) {
|
if strings.Contains(path, filesToSkip) {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
paths = append(paths, fmt.Sprintf("./%s", path))
|
paths = append(paths, path)
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
})
|
})
|
||||||
|
|
|
@ -6,9 +6,11 @@ import (
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/trustwallet/assets-go-libs/pkg"
|
fileLib "github.com/trustwallet/assets-go-libs/file"
|
||||||
"github.com/trustwallet/assets-go-libs/pkg/validation"
|
"github.com/trustwallet/assets-go-libs/image"
|
||||||
"github.com/trustwallet/assets-go-libs/pkg/validation/info"
|
"github.com/trustwallet/assets-go-libs/path"
|
||||||
|
"github.com/trustwallet/assets-go-libs/validation"
|
||||||
|
"github.com/trustwallet/assets-go-libs/validation/info"
|
||||||
"github.com/trustwallet/assets/internal/file"
|
"github.com/trustwallet/assets/internal/file"
|
||||||
"github.com/trustwallet/go-primitives/address"
|
"github.com/trustwallet/go-primitives/address"
|
||||||
"github.com/trustwallet/go-primitives/coin"
|
"github.com/trustwallet/go-primitives/coin"
|
||||||
|
@ -18,7 +20,7 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
func (s *Service) FixJSON(f *file.AssetFile) error {
|
func (s *Service) FixJSON(f *file.AssetFile) error {
|
||||||
return pkg.FormatJSONFile(f.Path())
|
return fileLib.FormatJSONFile(f.Path())
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Service) FixETHAddressChecksum(f *file.AssetFile) error {
|
func (s *Service) FixETHAddressChecksum(f *file.AssetFile) error {
|
||||||
|
@ -35,7 +37,7 @@ func (s *Service) FixETHAddressChecksum(f *file.AssetFile) error {
|
||||||
return fmt.Errorf("failed to get checksum: %s", e)
|
return fmt.Errorf("failed to get checksum: %s", e)
|
||||||
}
|
}
|
||||||
|
|
||||||
newName := fmt.Sprintf("blockchains/%s/assets/%s", f.Chain().Handle, checksum)
|
newName := path.GetAssetPath(f.Chain().Handle, checksum)
|
||||||
|
|
||||||
if e = os.Rename(f.Path(), newName); e != nil {
|
if e = os.Rename(f.Path(), newName); e != nil {
|
||||||
return fmt.Errorf("failed to rename dir: %s", e)
|
return fmt.Errorf("failed to rename dir: %s", e)
|
||||||
|
@ -52,7 +54,7 @@ func (s *Service) FixETHAddressChecksum(f *file.AssetFile) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Service) FixLogo(f *file.AssetFile) error {
|
func (s *Service) FixLogo(f *file.AssetFile) error {
|
||||||
width, height, err := pkg.GetPNGImageDimensions(f.Path())
|
width, height, err := image.GetPNGImageDimensions(f.Path())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -67,7 +69,7 @@ func (s *Service) FixLogo(f *file.AssetFile) error {
|
||||||
|
|
||||||
targetW, targetH := calculateTargetDimension(width, height)
|
targetW, targetH := calculateTargetDimension(width, height)
|
||||||
|
|
||||||
err = pkg.ResizePNG(f.Path(), targetW, targetH)
|
err = image.ResizePNG(f.Path(), targetW, targetH)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -101,7 +103,7 @@ func calculateTargetDimension(width, height int) (targetW, targetH int) {
|
||||||
func (s *Service) FixChainInfoJSON(f *file.AssetFile) error {
|
func (s *Service) FixChainInfoJSON(f *file.AssetFile) error {
|
||||||
chainInfo := info.CoinModel{}
|
chainInfo := info.CoinModel{}
|
||||||
|
|
||||||
err := pkg.ReadJSONFile(f.Path(), &chainInfo)
|
err := fileLib.ReadJSONFile(f.Path(), &chainInfo)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -110,7 +112,7 @@ func (s *Service) FixChainInfoJSON(f *file.AssetFile) error {
|
||||||
if chainInfo.Type == nil || *chainInfo.Type != expectedType {
|
if chainInfo.Type == nil || *chainInfo.Type != expectedType {
|
||||||
chainInfo.Type = &expectedType
|
chainInfo.Type = &expectedType
|
||||||
|
|
||||||
return pkg.CreateJSONFile(f.Path(), &chainInfo)
|
return fileLib.CreateJSONFile(f.Path(), &chainInfo)
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
@ -119,7 +121,7 @@ func (s *Service) FixChainInfoJSON(f *file.AssetFile) error {
|
||||||
func (s *Service) FixAssetInfoJSON(file *file.AssetFile) error {
|
func (s *Service) FixAssetInfoJSON(file *file.AssetFile) error {
|
||||||
assetInfo := info.AssetModel{}
|
assetInfo := info.AssetModel{}
|
||||||
|
|
||||||
err := pkg.ReadJSONFile(file.Path(), &assetInfo)
|
err := fileLib.ReadJSONFile(file.Path(), &assetInfo)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -164,7 +166,7 @@ func (s *Service) FixAssetInfoJSON(file *file.AssetFile) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
if isModified {
|
if isModified {
|
||||||
return pkg.CreateJSONFile(file.Path(), &assetInfo)
|
return fileLib.CreateJSONFile(file.Path(), &assetInfo)
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
|
|
@ -12,7 +12,6 @@ func NewService(fileProvider *file.Service) *Service {
|
||||||
return &Service{fileService: fileProvider}
|
return &Service{fileService: fileProvider}
|
||||||
}
|
}
|
||||||
|
|
||||||
// nolint:funlen
|
|
||||||
func (s *Service) GetValidator(f *file.AssetFile) *Validator {
|
func (s *Service) GetValidator(f *file.AssetFile) *Validator {
|
||||||
switch f.Type() {
|
switch f.Type() {
|
||||||
case file.TypeRootFolder:
|
case file.TypeRootFolder:
|
||||||
|
|
|
@ -7,9 +7,10 @@ import (
|
||||||
"strconv"
|
"strconv"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/trustwallet/assets-go-libs/pkg"
|
fileLib "github.com/trustwallet/assets-go-libs/file"
|
||||||
"github.com/trustwallet/assets-go-libs/pkg/asset"
|
"github.com/trustwallet/assets-go-libs/image"
|
||||||
"github.com/trustwallet/assets-go-libs/pkg/validation/info"
|
"github.com/trustwallet/assets-go-libs/path"
|
||||||
|
"github.com/trustwallet/assets-go-libs/validation/info"
|
||||||
"github.com/trustwallet/assets/internal/config"
|
"github.com/trustwallet/assets/internal/config"
|
||||||
"github.com/trustwallet/go-libs/blockchain/binance"
|
"github.com/trustwallet/go-libs/blockchain/binance"
|
||||||
"github.com/trustwallet/go-libs/blockchain/binance/explorer"
|
"github.com/trustwallet/go-libs/blockchain/binance/explorer"
|
||||||
|
@ -68,8 +69,8 @@ func fetchMissingAssets(chain coin.Coin, assets []explorer.Bep2Asset) error {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
assetLogoPath := asset.GetAssetLogoPath(chain.Handle, a.Asset)
|
assetLogoPath := path.GetAssetLogoPath(chain.Handle, a.Asset)
|
||||||
if pkg.FileExists(assetLogoPath) {
|
if fileLib.FileExists(assetLogoPath) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -86,12 +87,12 @@ func fetchMissingAssets(chain coin.Coin, assets []explorer.Bep2Asset) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
func createLogo(assetLogoPath string, a explorer.Bep2Asset) error {
|
func createLogo(assetLogoPath string, a explorer.Bep2Asset) error {
|
||||||
err := pkg.CreateDirPath(assetLogoPath)
|
err := fileLib.CreateDirPath(assetLogoPath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
return pkg.CreatePNGFromURL(a.AssetImg, assetLogoPath)
|
return image.CreatePNGFromURL(a.AssetImg, assetLogoPath)
|
||||||
}
|
}
|
||||||
|
|
||||||
func createInfoJSON(chain coin.Coin, a explorer.Bep2Asset) error {
|
func createInfoJSON(chain coin.Coin, a explorer.Bep2Asset) error {
|
||||||
|
@ -117,9 +118,9 @@ func createInfoJSON(chain coin.Coin, a explorer.Bep2Asset) error {
|
||||||
ID: &a.Asset,
|
ID: &a.Asset,
|
||||||
}
|
}
|
||||||
|
|
||||||
assetInfoPath := asset.GetAssetInfoPath(chain.Handle, a.Asset)
|
assetInfoPath := path.GetAssetInfoPath(chain.Handle, a.Asset)
|
||||||
|
|
||||||
return pkg.CreateJSONFile(assetInfoPath, &assetInfo)
|
return fileLib.CreateJSONFile(assetInfoPath, &assetInfo)
|
||||||
}
|
}
|
||||||
|
|
||||||
func createTokenListJSON(chain coin.Coin, marketPairs []binance.MarketPair, tokenList binance.Tokens) error {
|
func createTokenListJSON(chain coin.Coin, marketPairs []binance.MarketPair, tokenList binance.Tokens) error {
|
||||||
|
@ -128,10 +129,10 @@ func createTokenListJSON(chain coin.Coin, marketPairs []binance.MarketPair, toke
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
tokenListPath := fmt.Sprintf("blockchains/%s/tokenlist.json", chain.Handle)
|
tokenListPath := path.GetTokenListPath(chain.Handle)
|
||||||
|
|
||||||
var oldTokenList TokenList
|
var oldTokenList TokenList
|
||||||
err = pkg.ReadJSONFile(tokenListPath, &oldTokenList)
|
err = fileLib.ReadJSONFile(tokenListPath, &oldTokenList)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
@ -143,7 +144,7 @@ func createTokenListJSON(chain coin.Coin, marketPairs []binance.MarketPair, toke
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(tokens) > 0 {
|
if len(tokens) > 0 {
|
||||||
return pkg.CreateJSONFile(tokenListPath, &TokenList{
|
return fileLib.CreateJSONFile(tokenListPath, &TokenList{
|
||||||
Name: fmt.Sprintf("Trust Wallet: %s", coin.Coins[coin.BINANCE].Symbol),
|
Name: fmt.Sprintf("Trust Wallet: %s", coin.Coins[coin.BINANCE].Symbol),
|
||||||
LogoURI: twLogoURL,
|
LogoURI: twLogoURL,
|
||||||
Timestamp: time.Now().Format(timestampFormat),
|
Timestamp: time.Now().Format(timestampFormat),
|
||||||
|
@ -254,8 +255,8 @@ func getTokenType(symbol string, nativeCoinSymbol string, tokenType string) stri
|
||||||
|
|
||||||
func getLogoURI(id, githubChainFolder, nativeCoinSymbol string) string {
|
func getLogoURI(id, githubChainFolder, nativeCoinSymbol string) string {
|
||||||
if id == nativeCoinSymbol {
|
if id == nativeCoinSymbol {
|
||||||
return fmt.Sprintf("%s/blockchains/%s/info/logo.png", config.Default.URLs.TWAssetsApp, githubChainFolder)
|
return path.GetChainLogoURL(config.Default.URLs.TWAssetsApp, githubChainFolder)
|
||||||
}
|
}
|
||||||
|
|
||||||
return fmt.Sprintf("%s/blockchains/%s/assets/%s/logo.png", config.Default.URLs.TWAssetsApp, githubChainFolder, id)
|
return path.GetAssetLogoURL(config.Default.URLs.TWAssetsApp, githubChainFolder, id)
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,14 +2,14 @@ package processor
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
|
|
||||||
"github.com/trustwallet/assets-go-libs/pkg"
|
fileLib "github.com/trustwallet/assets-go-libs/file"
|
||||||
"github.com/trustwallet/assets-go-libs/pkg/asset"
|
"github.com/trustwallet/assets-go-libs/http"
|
||||||
|
"github.com/trustwallet/assets-go-libs/path"
|
||||||
"github.com/trustwallet/assets/internal/config"
|
"github.com/trustwallet/assets/internal/config"
|
||||||
"github.com/trustwallet/go-libs/client/api/backend"
|
"github.com/trustwallet/go-libs/client/api/backend"
|
||||||
"github.com/trustwallet/go-primitives/address"
|
"github.com/trustwallet/go-primitives/address"
|
||||||
|
@ -205,7 +205,7 @@ func fetchTradingPairs(url string, query map[string]string) (*TradingPairs, erro
|
||||||
log.WithField("url", url).Debug("Retrieving trading pair infos")
|
log.WithField("url", url).Debug("Retrieving trading pair infos")
|
||||||
|
|
||||||
var result TradingPairs
|
var result TradingPairs
|
||||||
err = pkg.PostHTTPResponse(url, jsonValue, &result)
|
err = http.PostHTTPResponse(url, jsonValue, &result)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -411,10 +411,10 @@ func rebuildTokenList(chain coin.Coin, pairs [][]TokenItem, forceExcludeList []s
|
||||||
|
|
||||||
log.Debugf("%d unsupported tokens filtered out, %d pairs", filteredCount, len(pairs2))
|
log.Debugf("%d unsupported tokens filtered out, %d pairs", filteredCount, len(pairs2))
|
||||||
|
|
||||||
tokenListPath := fmt.Sprintf("blockchains/%s/tokenlist.json", chain.Handle)
|
tokenListPath := path.GetTokenListPath(chain.Handle)
|
||||||
|
|
||||||
var list TokenList
|
var list TokenList
|
||||||
err := pkg.ReadJSONFile(tokenListPath, &list)
|
err := fileLib.ReadJSONFile(tokenListPath, &list)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
@ -439,13 +439,13 @@ func rebuildTokenList(chain coin.Coin, pairs [][]TokenItem, forceExcludeList []s
|
||||||
log.Debugf("Tokenlist: list with %d tokens and %d pairs written to %s.",
|
log.Debugf("Tokenlist: list with %d tokens and %d pairs written to %s.",
|
||||||
len(list.Tokens), totalPairs, tokenListPath)
|
len(list.Tokens), totalPairs, tokenListPath)
|
||||||
|
|
||||||
return pkg.CreateJSONFile(tokenListPath, list)
|
return fileLib.CreateJSONFile(tokenListPath, list)
|
||||||
}
|
}
|
||||||
|
|
||||||
func checkTokenExists(chain, tokenID string) bool {
|
func checkTokenExists(chain, tokenID string) bool {
|
||||||
logoPath := asset.GetAssetLogoPath(chain, tokenID)
|
logoPath := path.GetAssetLogoPath(chain, tokenID)
|
||||||
|
|
||||||
return pkg.FileExists(logoPath)
|
return fileLib.FileExists(logoPath)
|
||||||
}
|
}
|
||||||
|
|
||||||
func removeAllPairs(list *TokenList) {
|
func removeAllPairs(list *TokenList) {
|
||||||
|
|
|
@ -7,9 +7,10 @@ import (
|
||||||
"io"
|
"io"
|
||||||
"os"
|
"os"
|
||||||
|
|
||||||
"github.com/trustwallet/assets-go-libs/pkg/validation"
|
"github.com/trustwallet/assets-go-libs/path"
|
||||||
"github.com/trustwallet/assets-go-libs/pkg/validation/info"
|
"github.com/trustwallet/assets-go-libs/validation"
|
||||||
"github.com/trustwallet/assets-go-libs/pkg/validation/list"
|
"github.com/trustwallet/assets-go-libs/validation/info"
|
||||||
|
"github.com/trustwallet/assets-go-libs/validation/list"
|
||||||
"github.com/trustwallet/assets/internal/config"
|
"github.com/trustwallet/assets/internal/config"
|
||||||
"github.com/trustwallet/assets/internal/file"
|
"github.com/trustwallet/assets/internal/file"
|
||||||
"github.com/trustwallet/go-primitives/coin"
|
"github.com/trustwallet/go-primitives/coin"
|
||||||
|
@ -121,9 +122,7 @@ func (s *Service) ValidateAssetFolder(f *file.AssetFile) error {
|
||||||
errLogo := validation.ValidateHasFiles(dirFiles, []string{"logo.png"})
|
errLogo := validation.ValidateHasFiles(dirFiles, []string{"logo.png"})
|
||||||
|
|
||||||
if errLogo != nil || errInfo != nil {
|
if errLogo != nil || errInfo != nil {
|
||||||
infoFile := s.fileService.GetAssetFile(fmt.Sprintf("%s/info.json", f.Path()))
|
file2, err := os.Open(path.GetAssetInfoPath(f.Chain().Handle, f.Asset()))
|
||||||
|
|
||||||
file2, err := os.Open(infoFile.Path())
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -304,7 +303,7 @@ func (s *Service) ValidateValidatorsListFile(f *file.AssetFile) error {
|
||||||
listIDs[i] = *listItem.ID
|
listIDs[i] = *listItem.ID
|
||||||
}
|
}
|
||||||
|
|
||||||
assetsPath := fmt.Sprintf("blockchains/%s/validators/assets", f.Chain().Handle)
|
assetsPath := path.GetValidatorAssetsPath(f.Chain().Handle)
|
||||||
assetFolder := s.fileService.GetAssetFile(assetsPath)
|
assetFolder := s.fileService.GetAssetFile(assetsPath)
|
||||||
|
|
||||||
file2, err := os.Open(assetFolder.Path())
|
file2, err := os.Open(assetFolder.Path())
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
package service
|
package service
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/trustwallet/assets-go-libs/pkg/validation"
|
"github.com/trustwallet/assets-go-libs/validation"
|
||||||
"github.com/trustwallet/assets/internal/file"
|
"github.com/trustwallet/assets/internal/file"
|
||||||
"github.com/trustwallet/assets/internal/processor"
|
"github.com/trustwallet/assets/internal/processor"
|
||||||
|
|
||||||
|
@ -71,19 +71,13 @@ func HandleError(err error, info *file.AssetFile, valName string) {
|
||||||
errors := UnwrapComposite(err)
|
errors := UnwrapComposite(err)
|
||||||
|
|
||||||
for _, err := range errors {
|
for _, err := range errors {
|
||||||
logFields := log.Fields{
|
log.WithFields(log.Fields{
|
||||||
"type": info.Type(),
|
"type": info.Type(),
|
||||||
"chain": info.Chain().Handle,
|
"chain": info.Chain().Handle,
|
||||||
"asset": info.Asset(),
|
"asset": info.Asset(),
|
||||||
"path": info.Path(),
|
"path": info.Path(),
|
||||||
"validation": valName,
|
"validation": valName,
|
||||||
}
|
}).Error(err)
|
||||||
|
|
||||||
if warn, ok := err.(*validation.Warning); ok {
|
|
||||||
log.WithFields(logFields).Warning(warn)
|
|
||||||
} else {
|
|
||||||
log.WithFields(logFields).Error(err)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user