config

package
v0.0.0-...-cda3398 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 22, 2024 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package config provides functions to load and save ZetaClient config

Index

Constants

View Source
const (
	MaxBlocksPerPeriod = 100
)

Variables

This section is empty.

Functions

func ContainRestrictedAddress

func ContainRestrictedAddress(addrs ...string) bool

ContainRestrictedAddress returns true if any one of the addresses is restricted Note: the addrs can contains both ETH and BTC addresses

func GetPath

func GetPath(inputPath string) string

GetPath returns the absolute path of the input path

func LoadComplianceConfig

func LoadComplianceConfig(cfg Config)

LoadComplianceConfig loads compliance data (restricted addresses) from config

func Save

func Save(config *Config, path string) error

Save saves ZetaClient config

Types

type BTCConfig

type BTCConfig struct {
	// the following are rpcclient ConnConfig fields
	RPCUsername     string `mask:"filled"`
	RPCPassword     string `mask:"filled"`
	RPCHost         string `mask:"filled"`
	RPCParams       string // "regtest", "mainnet", "testnet3" , "signet", "testnet4"
	RPCAlertLatency int64
}

BTCConfig is the config for Bitcoin chain

func (BTCConfig) Empty

func (c BTCConfig) Empty() bool

type ClientConfiguration

type ClientConfiguration struct {
	ChainHost       string `json:"chain_host"        mapstructure:"chain_host"`
	ChainRPC        string `json:"chain_rpc"         mapstructure:"chain_rpc"`
	ChainHomeFolder string `json:"chain_home_folder" mapstructure:"chain_home_folder"`
	SignerName      string `json:"signer_name"       mapstructure:"signer_name"`
	SignerPasswd    string `json:"signer_passwd"`
}

ClientConfiguration is a subset of zetaclient config that is used by zetacore client

type ComplianceConfig

type ComplianceConfig struct {
	LogPath             string   `json:"LogPath"`
	RestrictedAddresses []string `json:"RestrictedAddresses"`
}

ComplianceConfig is the config for compliance

type Config

type Config struct {
	Peer                string         `json:"Peer"`
	PublicIP            string         `json:"PublicIP"`
	LogFormat           string         `json:"LogFormat"`
	LogLevel            int8           `json:"LogLevel"`
	LogSampler          bool           `json:"LogSampler"`
	PreParamsPath       string         `json:"PreParamsPath"`
	ZetaCoreHome        string         `json:"ZetaCoreHome"`
	ChainID             string         `json:"ChainID"`
	ZetaCoreURL         string         `json:"ZetaCoreURL"`
	AuthzGranter        string         `json:"AuthzGranter"`
	AuthzHotkey         string         `json:"AuthzHotkey"`
	P2PDiagnostic       bool           `json:"P2PDiagnostic"`
	ConfigUpdateTicker  uint64         `json:"ConfigUpdateTicker"`
	P2PDiagnosticTicker uint64         `json:"P2PDiagnosticTicker"`
	TssPath             string         `json:"TssPath"`
	TestTssKeysign      bool           `json:"TestTssKeysign"`
	KeyringBackend      KeyringBackend `json:"KeyringBackend"`
	RelayerKeyPath      string         `json:"RelayerKeyPath"`

	// chain configs
	EVMChainConfigs map[int64]EVMConfig `json:"EVMChainConfigs"`
	BTCChainConfigs map[int64]BTCConfig `json:"BTCChainConfigs"`
	// Deprecated: the 'BitcoinConfig' will be removed once the 'BTCChainConfigs' is fully adopted
	BitcoinConfig BTCConfig    `json:"BitcoinConfig"`
	SolanaConfig  SolanaConfig `json:"SolanaConfig"`
	TONConfig     TONConfig    `json:"TONConfig"`

	// compliance config
	ComplianceConfig ComplianceConfig `json:"ComplianceConfig"`
	// contains filtered or unexported fields
}

Config is the config for ZetaClient TODO: use snake case for json fields https://github.com/zeta-chain/node/issues/1020

func Load

func Load(path string) (Config, error)

Load loads ZetaClient config from a filepath

func New

func New(setDefaults bool) Config

New constructs Config optionally with default values.

func (Config) GetAllEVMConfigs

func (c Config) GetAllEVMConfigs() map[int64]EVMConfig

GetAllEVMConfigs returns a map of all EVM configs

func (Config) GetBTCConfig

func (c Config) GetBTCConfig(chainID int64) (BTCConfig, bool)

GetBTCConfig returns the BTC config for the given chain ID

func (Config) GetEVMConfig

func (c Config) GetEVMConfig(chainID int64) (EVMConfig, bool)

GetEVMConfig returns the EVM config for the given chain ID

func (Config) GetKeyringBackend

func (c Config) GetKeyringBackend() KeyringBackend

GetKeyringBackend returns the keyring backend

func (Config) GetRelayerKeyPath

func (c Config) GetRelayerKeyPath() string

GetRelayerKeyPath returns the relayer key path

func (Config) GetRestrictedAddressBook

func (c Config) GetRestrictedAddressBook() map[string]bool

GetRestrictedAddressBook returns a map of restricted addresses Note: the restricted address book contains both ETH and BTC addresses

func (Config) GetSolanaConfig

func (c Config) GetSolanaConfig() (SolanaConfig, bool)

GetSolanaConfig returns the Solana config

func (Config) GetTONConfig

func (c Config) GetTONConfig() (TONConfig, bool)

GetTONConfig returns the TONConfig and a bool indicating if it's present.

func (Config) StringMasked

func (c Config) StringMasked() string

StringMasked returns the string representation of the config with sensitive fields masked. Currently only the endpoints and bitcoin credentials are masked.

type EVMConfig

type EVMConfig struct {
	Endpoint        string `mask:"filled"`
	RPCAlertLatency int64
}

EVMConfig is the config for EVM chain

func (EVMConfig) Empty

func (c EVMConfig) Empty() bool

type KeyringBackend

type KeyringBackend string

KeyringBackend is the type of keyring backend to use for the hotkey

const (
	// KeyringBackendUndefined is undefined keyring backend
	KeyringBackendUndefined KeyringBackend = ""

	// KeyringBackendTest is the test Cosmos keyring backend
	KeyringBackendTest KeyringBackend = "test"

	// KeyringBackendFile is the file Cosmos keyring backend
	KeyringBackendFile KeyringBackend = "file"

	DefaultRelayerDir = "relayer-keys"

	// DefaultRelayerKeyPath is the default path that relayer keys are stored
	DefaultRelayerKeyPath = "~/.zetacored/" + DefaultRelayerDir
)

type SolanaConfig

type SolanaConfig struct {
	Endpoint        string `mask:"filled"`
	RPCAlertLatency int64
}

SolanaConfig is the config for Solana chain

type TONConfig

type TONConfig struct {
	// Can be either URL of local file path
	LiteClientConfigURL string `json:"liteClientConfigURL"`
	RPCAlertLatency     int64  `json:"rpcAlertLatency"`
}

TONConfig is the config for TON chain

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL