mirror of
https://github.com/Instadapp/trustwallet-assets.git
synced 2024-07-29 22:37:31 +00:00
Fix update-auto & upgrade assets-go-libs (#21016)
This commit is contained in:
parent
f0a07c4c58
commit
989189e9d2
2
go.mod
2
go.mod
|
@ -5,7 +5,7 @@ go 1.18
|
|||
require (
|
||||
github.com/sirupsen/logrus v1.8.1
|
||||
github.com/spf13/cobra v1.4.0
|
||||
github.com/trustwallet/assets-go-libs v0.2.0
|
||||
github.com/trustwallet/assets-go-libs v0.3.0
|
||||
github.com/trustwallet/go-libs v0.3.13
|
||||
github.com/trustwallet/go-primitives v0.0.50
|
||||
)
|
||||
|
|
2
go.sum
2
go.sum
|
@ -51,6 +51,8 @@ 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/trustwallet/assets-go-libs v0.2.0 h1:TUBlCnbbJ55Sa4c2uG3amvAnxuzSRlgSj1GzlnOFav0=
|
||||
github.com/trustwallet/assets-go-libs v0.2.0/go.mod h1:IW7K3aJcVlsXnQWD61KyQ46Nvb5iIPrptsKuSDFYbj8=
|
||||
github.com/trustwallet/assets-go-libs v0.3.0 h1:roDXZaUciPbTfwTbCQRajcDFwrFGkVhhCAxGelztjvU=
|
||||
github.com/trustwallet/assets-go-libs v0.3.0/go.mod h1:IW7K3aJcVlsXnQWD61KyQ46Nvb5iIPrptsKuSDFYbj8=
|
||||
github.com/trustwallet/go-libs v0.3.13 h1:zB30WfP6Do+5Cf3+HgkUhawBf1fnOdvvC/eBfCHKBEw=
|
||||
github.com/trustwallet/go-libs v0.3.13/go.mod h1:FuDoyKxhE1IgLPWMfU1PFok87MqfYm/spJJx1QziWe8=
|
||||
github.com/trustwallet/go-primitives v0.0.45 h1:SFeAUgFc4slZGA26pcEGGaCKrqHvmZa5CFvSjbmv4KM=
|
||||
|
|
|
@ -118,13 +118,18 @@ func AddTokenToTokenListJSON(chain coin.Coin, assetID, tokenID string, tokenList
|
|||
}
|
||||
list.Tokens = append(list.Tokens, newToken)
|
||||
|
||||
return libFile.CreateJSONFile(tokenListPath, &tokenlist.Model{
|
||||
data, err := libFile.PrepareJSONData(&tokenlist.Model{
|
||||
Name: fmt.Sprintf("Trust Wallet: %s", coin.Coins[chain.ID].Name),
|
||||
LogoURI: config.Default.URLs.Logo,
|
||||
Timestamp: time.Now().Format(config.Default.TimeFormat),
|
||||
Tokens: list.Tokens,
|
||||
Version: tokenlist.Version{Major: list.Version.Major + 1},
|
||||
})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return libFile.CreateJSONFile(tokenListPath, data)
|
||||
}
|
||||
|
||||
func getAssetInfo(chain coin.Coin, tokenID string) (*info.AssetModel, error) {
|
||||
|
|
|
@ -111,7 +111,12 @@ func (s *Service) FixChainInfoJSON(f *file.AssetFile) error {
|
|||
if chainInfo.Type == nil || *chainInfo.Type != expectedType {
|
||||
chainInfo.Type = &expectedType
|
||||
|
||||
return file.CreateJSONFile(f.Path(), &chainInfo)
|
||||
data, err := file.PrepareJSONData(&chainInfo)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return file.CreateJSONFile(f.Path(), data)
|
||||
}
|
||||
|
||||
return nil
|
||||
|
@ -165,7 +170,12 @@ func (s *Service) FixAssetInfo(f *file.AssetFile) error {
|
|||
}
|
||||
|
||||
if isModified {
|
||||
return file.CreateJSONFile(f.Path(), &assetInfo)
|
||||
data, err := file.PrepareJSONData(&assetInfo)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return file.CreateJSONFile(f.Path(), data)
|
||||
}
|
||||
|
||||
return nil
|
||||
|
|
|
@ -130,7 +130,12 @@ func createInfoJSON(chain coin.Coin, a explorer.Bep2Asset) error {
|
|||
|
||||
assetInfoPath := path.GetAssetInfoPath(chain.Handle, a.Asset)
|
||||
|
||||
return fileLib.CreateJSONFile(assetInfoPath, &assetInfo)
|
||||
data, err := fileLib.PrepareJSONData(&assetInfo)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return fileLib.CreateJSONFile(assetInfoPath, data)
|
||||
}
|
||||
|
||||
func createTokenListJSON(chain coin.Coin, tokens []tokenlist.Token) error {
|
||||
|
@ -150,16 +155,21 @@ func createTokenListJSON(chain coin.Coin, tokens []tokenlist.Token) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
log.Debugf("Tokenlist: list with %d tokens and %d pairs written to %s.",
|
||||
len(tokens), countTotalPairs(tokens), tokenListPath)
|
||||
|
||||
return fileLib.CreateJSONFile(tokenListPath, &tokenlist.Model{
|
||||
data, err := fileLib.PrepareJSONData(&tokenlist.Model{
|
||||
Name: fmt.Sprintf("Trust Wallet: %s", coin.Coins[chain.ID].Name),
|
||||
LogoURI: config.Default.URLs.Logo,
|
||||
Timestamp: time.Now().Format(config.Default.TimeFormat),
|
||||
Tokens: tokens,
|
||||
Version: tokenlist.Version{Major: oldTokenList.Version.Major + 1},
|
||||
})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
log.Debugf("Tokenlist: list with %d tokens and %d pairs written to %s.",
|
||||
len(tokens), countTotalPairs(tokens), tokenListPath)
|
||||
|
||||
return fileLib.CreateJSONFile(tokenListPath, data)
|
||||
}
|
||||
|
||||
func countTotalPairs(tokens []tokenlist.Token) int {
|
||||
|
@ -227,12 +237,6 @@ func generateTokenList(marketPairs []binance.MarketPair, tokenList binance.Token
|
|||
for pair := range pairsList {
|
||||
token := tokensMap[pair]
|
||||
|
||||
var pairs []tokenlist.Pair
|
||||
pairs, exists := pairsMap[token.Symbol]
|
||||
if !exists {
|
||||
pairs = make([]tokenlist.Pair, 0)
|
||||
}
|
||||
|
||||
tokenItems = append(tokenItems, tokenlist.Token{
|
||||
Asset: getAssetIDSymbol(token.Symbol, coin.Coins[coin.BINANCE].Symbol, coin.BINANCE),
|
||||
Type: getTokenType(token.Symbol, coin.Coins[coin.BINANCE].Symbol, types.BEP2),
|
||||
|
@ -241,7 +245,7 @@ func generateTokenList(marketPairs []binance.MarketPair, tokenList binance.Token
|
|||
Symbol: token.OriginalSymbol,
|
||||
Decimals: coin.Coins[coin.BINANCE].Decimals,
|
||||
LogoURI: getLogoURI(token.Symbol, coin.Coins[coin.BINANCE].Handle, coin.Coins[coin.BINANCE].Symbol),
|
||||
Pairs: pairs,
|
||||
Pairs: pairsMap[token.Symbol],
|
||||
})
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user