config

package
v0.0.0-...-19ae9e6 Latest Latest
Warning

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

Go to latest
Published: Jan 9, 2023 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Default = Config{
	Networks: config.DefaultNetworks,
}

Default is the default config that should be used in case no configuration file exists.

Functions

func Directory

func Directory() string

Directory returns the path to the configuration directory.

func Load

func Load(v *viper.Viper) error

Load loads the global configuration structure from viper.

func ResetDefaults

func ResetDefaults()

ResetDefaults resets the global configuration to defaults.

func Save

func Save(v *viper.Viper) error

Save saves the global configuration structure to viper.

Types

type Account

type Account struct {
	Description string `mapstructure:"description"`
	Kind        string `mapstructure:"kind"`
	Address     string `mapstructure:"address"`

	// Config contains kind-specific configuration for this wallet.
	Config map[string]interface{} `mapstructure:",remain"`
}

Account is an account configuration object.

func (*Account) GetAddress

func (a *Account) GetAddress() types.Address

GetAddress returns the parsed account address.

func (*Account) HasConsensusSigner

func (a *Account) HasConsensusSigner() bool

HasConsensusSigner returns true, iff there is a consensus layer signer associated with this account.

func (*Account) LoadFactory

func (a *Account) LoadFactory() (wallet.Factory, error)

LoadFactory loads the account factory corresponding to this account's kind.

func (*Account) PrettyKind

func (a *Account) PrettyKind() string

PrettyKind returns a human-friendly account kind.

func (*Account) SetConfigFromFlags

func (a *Account) SetConfigFromFlags() error

SetConfigFromFlags populates the kind-specific configuration from CLI flags.

func (*Account) Validate

func (a *Account) Validate() error

Validate performs config validation.

type AddressBook

type AddressBook struct {
	// All is a map of all configured address entries in the address book.
	All map[string]*AddressBookEntry `mapstructure:",remain"`
}

AddressBook contains the configuration of the address book.

func (*AddressBook) Add

func (ab *AddressBook) Add(name string, address string) error

Add adds new address book entry.

func (*AddressBook) Remove

func (ab *AddressBook) Remove(name string) error

Remove removes the given address book entry.

func (*AddressBook) Rename

func (ab *AddressBook) Rename(old, new string) error

Rename renames an existing address book entry.

func (*AddressBook) Validate

func (ab *AddressBook) Validate() error

Validate performs config validation.

type AddressBookEntry

type AddressBookEntry struct {
	Description string `mapstructure:"description"`
	Address     string `mapstructure:"address"`
	EthAddress  string `mapstructure:"eth_address,omitempty"`
}

AddressBookEntry is a configuration object for a single entry in the address book.

func (*AddressBookEntry) GetAddress

func (a *AddressBookEntry) GetAddress() types.Address

GetAddress returns the native address object.

func (*AddressBookEntry) GetEthAddress

func (a *AddressBookEntry) GetEthAddress() *ethCommon.Address

GetEthAddress returns the Ethereum address object, if set.

func (*AddressBookEntry) Validate

func (a *AddressBookEntry) Validate() error

Validate performs config validation.

type Config

type Config struct {
	Networks    config.Networks `mapstructure:"networks"`
	Wallet      Wallet          `mapstructure:"wallets"`
	AddressBook AddressBook     `mapstructure:"address_book"`
	// contains filtered or unexported fields
}

Config contains the CLI configuration.

func Global

func Global() *Config

Global returns the global configuration structure.

func (*Config) Load

func (cfg *Config) Load(v *viper.Viper) error

Load loads the configuration structure from viper.

func (*Config) Save

func (cfg *Config) Save() error

Save saves the configuration structure to viper.

func (*Config) Validate

func (cfg *Config) Validate() error

Validate performs config validation.

type Wallet

type Wallet struct {
	// Default is the name of the default account.
	Default string `mapstructure:"default"`

	// All is a map of all configured accounts in the wallet.
	All map[string]*Account `mapstructure:",remain"`
}

Wallet contains the configuration of the wallet.

func (*Wallet) Create

func (w *Wallet) Create(name string, passphrase string, nw *Account) error

Create creates a new account.

func (*Wallet) Import

func (w *Wallet) Import(name string, passphrase string, nw *Account, src *wallet.ImportSource) error

Import imports an existing account.

func (*Wallet) Load

func (w *Wallet) Load(name string, passphrase string) (wallet.Account, error)

Load loads the given account.

func (*Wallet) Remove

func (w *Wallet) Remove(name string) error

Remove removes the given account.

func (*Wallet) Rename

func (w *Wallet) Rename(old, new string) error

Rename renames an existing account.

func (*Wallet) SetDefault

func (w *Wallet) SetDefault(name string) error

SetDefault marks the given account as default.

func (*Wallet) Validate

func (w *Wallet) Validate() error

Validate performs config validation.

Jump to

Keyboard shortcuts

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