2021-12-19 21:39:53 +00:00
|
|
|
package config
|
|
|
|
|
|
|
|
import (
|
|
|
|
"path/filepath"
|
|
|
|
|
|
|
|
"github.com/trustwallet/go-libs/config/viper"
|
|
|
|
)
|
|
|
|
|
|
|
|
type (
|
|
|
|
Config struct {
|
2022-01-20 13:51:37 +00:00
|
|
|
App App `mapstructure:"app"`
|
|
|
|
ClientURLs ClientURLs `mapstructure:"client_urls"`
|
|
|
|
URLs URLs `mapstructure:"urls"`
|
2022-01-27 23:59:22 +00:00
|
|
|
TimeFormat string `mapstructure:"time_format"`
|
2022-01-20 13:51:37 +00:00
|
|
|
ValidatorsSettings ValidatorsSettings `mapstructure:"validators_settings"`
|
2021-12-19 21:39:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
App struct {
|
|
|
|
LogLevel string `mapstructure:"log_level"`
|
|
|
|
}
|
|
|
|
|
2022-01-20 13:51:37 +00:00
|
|
|
ClientURLs struct {
|
2021-12-19 21:39:53 +00:00
|
|
|
Binance struct {
|
|
|
|
Dex string `mapstructure:"dex"`
|
|
|
|
Explorer string `mapstructure:"explorer"`
|
|
|
|
} `mapstructure:"binance"`
|
2022-01-20 13:51:37 +00:00
|
|
|
AssetsManagerAPI string `mapstructure:"assets_manager_api"`
|
2021-12-19 21:39:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
URLs struct {
|
2022-01-27 23:59:22 +00:00
|
|
|
AssetsApp string `mapstructure:"assets_app"`
|
|
|
|
Logo string `mapstructure:"logo"`
|
2021-12-19 21:39:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
ValidatorsSettings struct {
|
|
|
|
RootFolder RootFolder `mapstructure:"root_folder"`
|
|
|
|
ChainFolder ChainFolder `mapstructure:"chain_folder"`
|
|
|
|
AssetFolder AssetFolder `mapstructure:"asset_folder"`
|
|
|
|
ChainInfoFolder ChainInfoFolder `mapstructure:"chain_info_folder"`
|
|
|
|
ChainValidatorsAssetFolder ChainValidatorsAssetFolder `mapstructure:"chain_validators_asset_folder"`
|
|
|
|
DappsFolder DappsFolder `mapstructure:"dapps_folder"`
|
2021-12-27 21:44:12 +00:00
|
|
|
}
|
2021-12-19 21:39:53 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
// Default is a configuration instance.
|
|
|
|
var Default = Config{} // nolint:gochecknoglobals // config must be global
|
|
|
|
|
|
|
|
// SetConfig reads a config file and returs an initialized config instance.
|
|
|
|
func SetConfig(confPath string) error {
|
|
|
|
confPath, err := filepath.Abs(confPath)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
viper.Load(confPath, &Default)
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|