config

package
v0.0.114 Latest Latest
Warning

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

Go to latest
Published: Mar 9, 2023 License: MIT Imports: 20 Imported by: 0

Documentation

Overview

Package config contains the config for different kinds of agents

Index

Constants

This section is empty.

Variables

View Source
var AllSignerTypes []SignerType

AllSignerTypes is a list of all contract types. Since we use stringer and this is a testing library, instead of manually copying all these out we pull the names out of stringer. In order to make sure stringer is updated, we panic on any method called where the index is higher than the stringer array length.

View Source
var ErrInvalidChainType error

ErrInvalidChainType indicates chain type was invalid.

View Source
var ErrInvalidDomainID = errors.New("domain ID invalid")

ErrInvalidDomainID indicates domain id is invalid.

View Source
var ErrRequiredField = errors.New("field is required")

ErrRequiredField indicates a required field was left blank.

View Source
var ErrUnsupportedSignerType = errors.New("unsupported signer type")

ErrUnsupportedSignerType indicates the signer type being used is unsupported.

Functions

func SignerFromConfig

func SignerFromConfig(ctx context.Context, config SignerConfig) (signer.Signer, error)

SignerFromConfig creates a new signer from a signer config. TODO: this needs to be moved to some kind of common package. in the old code configs were split into responsible packages. Maybe something like that works here?

Types

type AWSConfig added in v0.0.102

type AWSConfig struct {
	// Region is the region the signer is in.
	Region string `yaml:"region"`
	// AccessKey is the access key for the signer.
	AccessKey string `yaml:"access_key"`
	// AccessSecret is the access secret for the signer.
	AccessSecret string `yaml:"access_secret"`
	// KeyID is the key id for the signer.
	KeyID string `yaml:"key_id"`
}

AWSConfig is the config for an AWS signer. this should match the schema of the file passed in.

func DecodeAWSConfig added in v0.0.102

func DecodeAWSConfig(filePath string) (cfg AWSConfig, err error)

DecodeAWSConfig decodes the config from a file.

func (AWSConfig) Encode added in v0.0.102

func (a AWSConfig) Encode() ([]byte, error)

Encode encodes the config to yaml.

type Config

type Config struct {
	// Domains stores all domains
	Domains DomainConfigs `yaml:"domains"`
	// Signer contains the signer config for agents
	Signer SignerConfig `yaml:"signer"`
	// DbConfig is the database config
	Database DBConfig `yaml:"database"`
}

Config is used for configuring the application. It stores the configurations defined in each module.

func (*Config) IsValid

func (c *Config) IsValid(ctx context.Context) (ok bool, err error)

IsValid makes sure the config is valid. This is done by calling IsValid() on each submodule. If any method returns an error that is returned here and the entirety of IsValid returns false. Any warnings are logged by the submodules respective loggers.

type DBConfig

type DBConfig struct {
	// Type of the database to use for sql. This does not affect hte pebble db
	Type string `yaml:"type"`
	// DBPath is the db path used for the pebble db
	DBPath string `yaml:"db_path"`
	// ConnString is the connection string used for mysql
	ConnString string `yaml:"conn_string"`
}

DBConfig is used for configuring the.

func (*DBConfig) IsValid

func (d *DBConfig) IsValid(_ context.Context) (ok bool, err error)

IsValid asserts the database connection is valid.

type DomainConfig

type DomainConfig struct {
	// DomainID is the domain of the chain
	DomainID uint32 `yaml:"domain_id"`
	// Type of the chain (e.g. evm)
	Type string `yaml:"type"`
	// RequiredConfirmations is the number of confirmations to way
	RequiredConfirmations uint32 `yaml:"required_confirmations"`
	// OriginAddress gets origin contract address
	OriginAddress string `yaml:"origin_address"`
	// AttestationCollectorAddress contains the attestation collector address (if present)
	AttestationCollectorAddress string `yaml:"attestation_collector_address"`
	// DestinationAddress gets destination contract address
	DestinationAddress string `yaml:"destination_address"`
	// RPCUrl to use for the chain
	RPCUrl string `yaml:"rpc_url"`
	// Minimum start height
	StartHeight uint32 `yaml:"start_height"`
}

DomainConfig defines the config for a specific domain.

func (DomainConfig) IsValid

func (d DomainConfig) IsValid(_ context.Context) (ok bool, err error)

IsValid validates the domain config.

type DomainConfigs

type DomainConfigs map[string]DomainConfig

DomainConfigs contains a map of name->domain config.

func (DomainConfigs) IsValid

func (d DomainConfigs) IsValid(ctx context.Context) (ok bool, err error)

IsValid validates the domain configs by asserting no two domains appear twice it also calls IsValid on each individual DomainConfig.

type GCPConfig added in v0.0.102

type GCPConfig struct {
	// KeyName is the name of the key to use.
	KeyName string `yaml:"key_name"`
	// CredentialFile is the path to the credentials file.
	// note: this is not recommended for production use.
	// workload identity federation is recommended.
	CredentialFile string `yaml:"credential_file"`
	// Endpoint is the endpoint to use. This is useful for testing.
	Endpoint string `yaml:"endpoint"`
}

GCPConfig is the config for a GCP signer.

func DecodeGCPConfig added in v0.0.102

func DecodeGCPConfig(filePath string) (cfg GCPConfig, err error)

DecodeGCPConfig decodes the config from a file.

func (GCPConfig) Encode added in v0.0.102

func (a GCPConfig) Encode() ([]byte, error)

Encode encodes the config to yaml.

type GuardConfig added in v0.0.68

type GuardConfig struct {
	// OriginDomains stores all origin domains
	OriginDomains DomainConfigs `yaml:"origin_domains"`
	// AttestationDomain stores the attestation domain
	AttestationDomain DomainConfig `yaml:"attestation_domain"`
	// DestinationDomains stores all destination domains
	DestinationDomains DomainConfigs `yaml:"destination_domains"`
	// UnbondedSigner contains the unbonded signer config for agents
	// (this is signer used to submit transactions)
	UnbondedSigner SignerConfig `yaml:"unbonded_signer"`
	// BondedSigner contains the bonded signer config for agents
	BondedSigner SignerConfig `yaml:"bonded_signer"`
	// DbConfig is the database config
	Database DBConfig `yaml:"database"`
	// RefreshIntervalInSeconds is how long to wait before refreshing the Notary state
	RefreshIntervalInSeconds int64 `yaml:"refresh_interval_in_seconds"`
	// DBPrefix is the table prefix in the database
	DBPrefix string `yaml:"db_prefix"`
}

GuardConfig is used for configuring the guard.

func DecodeGuardConfig added in v0.0.84

func DecodeGuardConfig(filePath string) (cfg GuardConfig, err error)

DecodeGuardConfig parses in a config from a file.

func (GuardConfig) Encode added in v0.0.84

func (c GuardConfig) Encode() ([]byte, error)

Encode gets the encoded config.yaml file.

func (*GuardConfig) IsValid added in v0.0.68

func (c *GuardConfig) IsValid(ctx context.Context) (ok bool, err error)

IsValid makes sure the config is valid. This is done by calling IsValid() on each submodule. If any method returns an error that is returned here and the entirety of IsValid returns false. Any warnings are logged by the submodules respective loggers.

type NotaryConfig added in v0.0.58

type NotaryConfig struct {
	// OriginDomains stores all origin domains
	OriginDomains DomainConfigs `yaml:"origin_domains"`
	// AttestationDomain stores the attestaion domain
	AttestationDomain DomainConfig `yaml:"attestation_domain"`
	// DestinationDomain stores  the destination domain
	DestinationDomain DomainConfig `yaml:"destination_domain"`
	// UnbondedSigner contains the unbonded signer config for agents
	// (this is signer used to submit transactions)
	UnbondedSigner SignerConfig `yaml:"unbonded_signer"`
	// BondedSigner contains the bonded signer config for agents
	BondedSigner SignerConfig `yaml:"bonded_signer"`
	// DbConfig is the database config
	Database DBConfig `yaml:"database"`
	// RefreshIntervalInSeconds is how long to wait before refreshing the Notary state
	RefreshIntervalInSeconds int64 `yaml:"refresh_interval_in_seconds"`
	// DBPrefix is the table prefix in the database
	DBPrefix string `yaml:"db_prefix"`
}

NotaryConfig is used for configuring the notary.

func DecodeNotaryConfig added in v0.0.83

func DecodeNotaryConfig(filePath string) (cfg NotaryConfig, err error)

DecodeNotaryConfig parses in a notary config from a file.

func (NotaryConfig) Encode added in v0.0.83

func (c NotaryConfig) Encode() ([]byte, error)

Encode gets the encoded config.yaml file.

func (*NotaryConfig) IsValid added in v0.0.58

func (c *NotaryConfig) IsValid(ctx context.Context) (ok bool, err error)

IsValid makes sure the config is valid. This is done by calling IsValid() on each submodule. If any method returns an error that is returned here and the entirety of IsValid returns false. Any warnings are logged by the submodules respective loggers.

type SignerConfig

type SignerConfig struct {
	// Type is the driver used for the signer
	Type string
	// File is the file used for the key.
	File string
}

SignerConfig contains a signer config. Currently this config only supports local based signers due to a lack of isomorphic types when we parse yaml.

func (SignerConfig) IsValid

func (s SignerConfig) IsValid(_ context.Context) (ok bool, err error)

IsValid determines if the config is valid.

type SignerType

type SignerType int

SignerType is the signer type

const (
	// FileType is a file-based signer.
	FileType SignerType = iota + 1 // File
	// AWSType is an aws kms based signer.
	AWSType // AWS
	// GCPType is a gcp cloud based signer.
	GCPType // GCP
)

func (SignerType) String

func (i SignerType) String() string

Jump to

Keyboard shortcuts

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