config

package
v1.18.0 Latest Latest
Warning

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

Go to latest
Published: May 14, 2024 License: Apache-2.0 Imports: 12 Imported by: 2

Documentation

Index

Constants

View Source
const (
	DefaultHashAlgo = crypto.SHA3_256
	DefaultSigAlgo  = crypto.ECDSA_P256
)
View Source
const DefaultPath = "flow.json"

Variables

View Source
var (
	DefaultEmulator = Emulator{
		Name:           "default",
		ServiceAccount: "emulator-account",
		Port:           3569,
	}
	DefaultEmulators = Emulators{DefaultEmulator}
)
View Source
var (
	EmptyNetwork    = Network{}
	EmulatorNetwork = Network{
		Name: "emulator",
		Host: "127.0.0.1:3569",
	}
	TestingNetwork = Network{
		Name: "testing",
		Host: "127.0.0.1:3569",
	}
	TestnetNetwork = Network{
		Name: "testnet",
		Host: "access.devnet.nodes.onflow.org:9000",
	}
	MainnetNetwork = Network{
		Name: "mainnet",
		Host: "access.mainnet.nodes.onflow.org:9000",
	}
	DefaultNetworks = Networks{
		EmulatorNetwork,
		TestingNetwork,
		TestnetNetwork,
		MainnetNetwork,
	}
)
View Source
var ErrDoesNotExist = errors.New("missing configuration")

ErrDoesNotExist is error to be returned when config file does not exists.

View Source
var ErrOutdatedFormat = errors.New("you are using old configuration format")

Functions

func DefaultPaths

func DefaultPaths() []string

DefaultPaths determines default paths for configuration.

func Exists

func Exists(path string) bool

Exists checks if file exists on the specified path.

func GlobalPath

func GlobalPath() string

GlobalPath gets global path based on home dir.

func IsDefaultPath

func IsDefaultPath(paths []string) bool

func ParseSourceString

func ParseSourceString(s string) (network, address, contractName string, err error)

Types

type Account

type Account struct {
	Name    string
	Address flow.Address
	Key     AccountKey
}

Account defines the configuration for a Flow account.

type AccountKey

type AccountKey struct {
	Type           KeyType
	Index          int
	SigAlgo        crypto.SignatureAlgorithm
	HashAlgo       crypto.HashAlgorithm
	ResourceID     string
	Mnemonic       string
	DerivationPath string
	PrivateKey     crypto.PrivateKey
	Location       string
	Env            string
}

AccountKey represents account key and all their possible configuration formats.

func NewDefaultAccountKey

func NewDefaultAccountKey(pkey crypto.PrivateKey) AccountKey

func (*AccountKey) IsDefault

func (a *AccountKey) IsDefault() bool

type Accounts

type Accounts []Account

func (*Accounts) AddOrUpdate

func (a *Accounts) AddOrUpdate(name string, account Account)

AddOrUpdate add new or update if already present.

func (*Accounts) ByName

func (a *Accounts) ByName(name string) (*Account, error)

ByName get account by name or error if not found.

func (*Accounts) Remove

func (a *Accounts) Remove(name string)

Remove account by name.

type Alias

type Alias struct {
	Network string
	Address flow.Address
}

Alias defines an existing pre-deployed contract address for specific network.

type Aliases

type Aliases []Alias

func (*Aliases) Add

func (a *Aliases) Add(network string, address flow.Address)

func (*Aliases) ByNetwork

func (a *Aliases) ByNetwork(network string) *Alias

type Config

type Config struct {
	Emulators    Emulators
	Contracts    Contracts
	Dependencies Dependencies
	Networks     Networks
	Accounts     Accounts
	Deployments  Deployments
}

Config contains all the configuration for CLI and implements getters and setters for properties. Config is agnostic to format from which it is built and it doesn't provide persistence functionality.

Emulators contains all the emulator config Contracts contains all contracts definitions and their sources Networks defines all the Flow networks addresses Accounts defines Flow accounts and their addresses, private key and more properties Deployments describes which contracts should be deployed to which accounts

func Default

func Default() *Config

Default returns the default configuration.

func (*Config) Validate

func (c *Config) Validate() error

Validate the configuration values.

type Contract

type Contract struct {
	Name         string
	Location     string
	Aliases      Aliases
	IsDependency bool
}

Contract defines the configuration for a Cadence contract.

func (*Contract) IsAliased

func (c *Contract) IsAliased() bool

IsAliased checks if contract has an alias.

type ContractDeployment

type ContractDeployment struct {
	Name string
	Args []cadence.Value
}

ContractDeployment defines the deployment of the contract with possible args.

type Contracts

type Contracts []Contract

func (*Contracts) AddDependencyAsContract

func (c *Contracts) AddDependencyAsContract(dependency Dependency, networkName string)

AddDependencyAsContract adds a dependency as a contract if it doesn't already exist.

func (*Contracts) AddOrUpdate

func (c *Contracts) AddOrUpdate(contract Contract)

AddOrUpdate add new or update if already present.

func (*Contracts) ByName

func (c *Contracts) ByName(name string) (*Contract, error)

ByName get contract by name or return an error if it doesn't exist.

func (*Contracts) DependencyContractByName

func (c *Contracts) DependencyContractByName(name string) *Contract

func (*Contracts) Remove

func (c *Contracts) Remove(name string) error

Remove contract by its name.

type Dependencies

type Dependencies []Dependency

func (*Dependencies) AddOrUpdate

func (d *Dependencies) AddOrUpdate(dep Dependency)

func (*Dependencies) ByName

func (d *Dependencies) ByName(name string) *Dependency

type Dependency

type Dependency struct {
	Name    string
	Source  Source
	Hash    string
	Aliases Aliases
}

type Deployment

type Deployment struct {
	Network   string               // network name to deploy to
	Account   string               // account name to which to deploy to
	Contracts []ContractDeployment // contracts to deploy
}

Deployment defines the configuration for a contract deployment.

func (*Deployment) AddContract

func (d *Deployment) AddContract(contract ContractDeployment)

AddContract to deployment list on the account name and network name.

func (*Deployment) RemoveContract

func (d *Deployment) RemoveContract(contractName string)

RemoveContract removes a specific contract by name from an existing deployment identified by account name and network name.

type Deployments

type Deployments []Deployment

func (*Deployments) AddOrUpdate

func (d *Deployments) AddOrUpdate(deployment Deployment)

AddOrUpdate add new or update if already present.

func (*Deployments) All

func (d *Deployments) All() Deployments

All returns a list of all deployments

func (*Deployments) ByAccountAndNetwork

func (d *Deployments) ByAccountAndNetwork(account string, network string) *Deployment

ByAccountAndNetwork get deploy by account and network.

func (*Deployments) ByNetwork

func (d *Deployments) ByNetwork(network string) Deployments

ByNetwork get all deployments by network.

func (*Deployments) Remove

func (d *Deployments) Remove(account string, network string) error

Remove removes deployment by account and network.

type Emulator

type Emulator struct {
	Name           string
	Port           int
	ServiceAccount string
}

Emulator defines the configuration for a Flow Emulator instance.

type Emulators

type Emulators []Emulator

func (*Emulators) AddOrUpdate

func (e *Emulators) AddOrUpdate(name string, emulator Emulator)

AddOrUpdate add new or update if already present.

func (*Emulators) Default

func (e *Emulators) Default() *Emulator

Default gets default emulator.

type KeyType

type KeyType string
const (
	KeyTypeHex       KeyType = "hex"
	KeyTypeGoogleKMS KeyType = "google-kms"
	KeyTypeBip44     KeyType = "bip44"
	KeyTypeFile      KeyType = "file"
)

type Loader

type Loader struct {
	LoadedLocations []string
	// contains filtered or unexported fields
}

Loader contains actions for composing and modifying configuration.

func NewLoader

func NewLoader(readerWriter ReaderWriter) *Loader

NewLoader returns a new loader.

func (*Loader) AddConfigParser

func (l *Loader) AddConfigParser(format Parser)

AddConfigParser adds a new configuration parser.

func (*Loader) Load

func (l *Loader) Load(paths []string) (*Config, error)

Load loads configuration from one or more file paths.

If more than one path is specified, their contents are merged together into on configuration object.

func (*Loader) Save

func (l *Loader) Save(conf *Config, path string) error

Save saves a configuration to a path with correct serializer.

type Network

type Network struct {
	Name string
	Host string
	Key  string
}

Network defines the configuration for a Flow network.

type Networks

type Networks []Network

func (*Networks) AddOrUpdate

func (n *Networks) AddOrUpdate(network Network)

AddOrUpdate add new network or update if already present.

func (*Networks) ByName

func (n *Networks) ByName(name string) (*Network, error)

ByName get network by name or return an error if not found.

func (*Networks) Remove

func (n *Networks) Remove(name string) error

Remove network by the name.

type Parser

type Parser interface {
	Serialize(*Config) ([]byte, error)
	Deserialize([]byte) (*Config, error)
	SupportsFormat(string) bool
}

Parser is interface for any configuration format parser to implement.

type Parsers

type Parsers []Parser

Parsers is a list of all configuration parsers.

func (*Parsers) FindForFormat

func (c *Parsers) FindForFormat(extension string) Parser

FindForFormat finds a parser that can parse a specific format based on extension.

type ReaderWriter

type ReaderWriter interface {
	ReadFile(source string) ([]byte, error)
	WriteFile(filename string, data []byte, perm os.FileMode) error
}

type Source

type Source struct {
	NetworkName  string
	Address      flow.Address
	ContractName string
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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