Update config, make tag values central (#17535)

This commit is contained in:
Daniel 2022-01-20 16:51:37 +03:00 committed by GitHub
parent a915edc893
commit c6f7f83e06
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 23 additions and 100 deletions

View File

@ -5,7 +5,7 @@ client_urls:
binance:
dex: https://dex.binance.org
explorer: https://explorer.binance.org
backend_api: https://api.trustwallet.com
assets_manager_api: "https://assets-manager-api.herokuapp.com"
urls:
tw_assets_app: https://assets.trustwalletapp.com
@ -64,74 +64,3 @@ validators_settings:
dapps_folder:
ext: ".png"
coin_info_file:
tags:
- id: stablecoin
name: Stablecoin
description: Tokens that are fixed to an external asset, e.g. the US dollar.
- id: wrapped
name: Wrapped
description: Tokens that are wrapped or peg representation of digital assets. Excluded
stablecoins
- id: synthetics
name: Synthetics
description: Synthetic assets created to track the value of another asset
- id: nft
name: NFT
description: Non-fungible tokens or tokens associated with the NFT ecosystem.
- id: governance
name: Governance
description: Tokens that used to participate in the governance process of the project.
- id: defi
name: DeFi
description: Tokens that are used for variety of decentralized financial applications.
- id: staking
name: Staking
description: Tokens that are used for staking to receive rewards.
- id: privacy
name: Privacy
description: Privacy tokens.
- id: nsfw
name: NSFW
description: Content Not suitable for work.
- id: binance-peg
name: Binance-Peg
description: Binance-Peg tokens.
- id: deflationary
name: Deflationary
description: Tokens that are deflationary or use mechanism to burn a token on transfer/swap.
- id: memes
name: Memes
description: A cryptocurrency that is associated with some theme, often as a joke rather than a serious product.
- id: gamefi
name: GameFi
description: Combination of gaming and DeFi, is the intersection of blockchain-based gaming and DeFi services.
# TW Specific
- id: staking-native
name: Staking Native
description: Coins/Blockchains that are used for staking to secure the network to
receive rewards. Supported by Trust Wallet.
trading_pair_settings:
uniswap:
url: https://api.thegraph.com/subgraphs/name/uniswap/uniswap-v2
primary_tokens: "WETH,ETH"
force_include_list: "TUSD,STAKE,YFI,BAT,MANA,1INCH,REP,KP3R,UNI,WBTC,HEX,CREAM,SLP,REN,XOR,Link,sUSD,HEGIC,RLC,DAI,SUSHI,FYZ,DYT,AAVE,LEND,UBT,DIA,RSR,SXP,OCEAN,MKR,USDC,CEL,BAL,BAND,COMP,SNX,OMG,AMPL,USDT,KNC,ZRX,AXS,ENJ,STMX,DPX,FTT,DPI,PAX"
force_exclude_list: "STARL,UFO"
min_liquidity: 2000000
min_vol_24: 1000000
min_tx_count_24: 480
pancakeswap:
url: https://api.bscgraph.org/subgraphs/name/cakeswap
primary_tokens: "WBNB,BNB"
force_include_list: "Cake,DAI,ETH,TWT,VAI,USDT,BLINK,BTCB,ALPHA,INJ,CTK,UNI,XVS,BUSD,HARD,BIFI,FRONT"
force_exclude_list:
min_liquidity: 1000000
min_vol_24: 500000
min_tx_count_24: 288

View File

@ -9,22 +9,21 @@ import (
type (
Config struct {
App App `mapstructure:"app"`
ClientURLs ClientsURLs `mapstructure:"client_urls"`
ClientURLs ClientURLs `mapstructure:"client_urls"`
URLs URLs `mapstructure:"urls"`
ValidatorsSettings ValidatorsSettings `mapstructure:"validators_settings"`
TradingPairSettings TradingPairSettings `mapstructure:"trading_pair_settings"`
}
App struct {
LogLevel string `mapstructure:"log_level"`
}
ClientsURLs struct {
ClientURLs struct {
Binance struct {
Dex string `mapstructure:"dex"`
Explorer string `mapstructure:"explorer"`
} `mapstructure:"binance"`
BackendAPI string `mapstructure:"backend_api"`
AssetsManagerAPI string `mapstructure:"assets_manager_api"`
}
URLs struct {
@ -38,22 +37,6 @@ type (
ChainInfoFolder ChainInfoFolder `mapstructure:"chain_info_folder"`
ChainValidatorsAssetFolder ChainValidatorsAssetFolder `mapstructure:"chain_validators_asset_folder"`
DappsFolder DappsFolder `mapstructure:"dapps_folder"`
CoinInfoFile CoinInfoFile `mapstructure:"coin_info_file"`
}
TradingPairSettings struct {
Uniswap TradingPairSetting `mapstructure:"uniswap"`
Pancakeswap TradingPairSetting `mapstructure:"pancakeswap"`
}
TradingPairSetting struct {
URL string `mapstructure:"url"`
PrimaryTokens string `mapstructure:"primary_tokens"`
ForceIncludeList string `mapstructure:"force_include_list"`
ForceExcludeList string `mapstructure:"force_exclude_list"`
MinLiquidity int `mapstructure:"min_liquidity"`
MinVol24 int `mapstructure:"min_vol_24"`
MinTxCount24 int `mapstructure:"min_tx_count_24"`
}
)

View File

@ -1,15 +1,21 @@
package processor
import (
"github.com/trustwallet/assets/internal/config"
"github.com/trustwallet/assets/internal/file"
assetsmanager "github.com/trustwallet/go-libs/client/api/assets-manager"
)
type Service struct {
fileService *file.Service
assetsManager assetsmanager.Client
}
func NewService(fileProvider *file.Service) *Service {
return &Service{fileService: fileProvider}
return &Service{
fileService: fileProvider,
assetsManager: assetsmanager.InitClient(config.Default.ClientURLs.AssetsManagerAPI, nil),
}
}
func (s *Service) GetValidator(f *file.AssetFile) []Validator {

View File

@ -234,8 +234,13 @@ func (s *Service) ValidateChainInfoFile(f *file.AssetFile) error {
return fmt.Errorf("%w: failed to decode", err)
}
tags := make([]string, len(config.Default.ValidatorsSettings.CoinInfoFile.Tags))
for i, t := range config.Default.ValidatorsSettings.CoinInfoFile.Tags {
receivedTags, err := s.assetsManager.GetTagValues()
if err != nil {
return fmt.Errorf("failed to get tag values: %w", err)
}
tags := make([]string, len(receivedTags.Tags))
for i, t := range receivedTags.Tags {
tags[i] = t.ID
}