config

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Feb 6, 2023 License: Apache-2.0 Imports: 7 Imported by: 21

Documentation

Index

Constants

View Source
const NativeDenominationKey = "_"

NativeDenominationKey is the key used to signify the native denomination.

Variables

View Source
var DefaultNetworks = Networks{
	Default: "mainnet",
	All: map[string]*Network{

		"mainnet": {
			ChainContext: "b11b369e0da5bb230b220127f5e7b242d385ef8c6f54906243f30af63c815535",
			RPC:          "grpc.oasis.dev:443",
			Denomination: DenominationInfo{
				Symbol:   "ROSE",
				Decimals: 9,
			},
			ParaTimes: ParaTimes{
				Default: "emerald",
				All: map[string]*ParaTime{

					"cipher": {
						ID: "000000000000000000000000000000000000000000000000e199119c992377cb",
						Denominations: map[string]*DenominationInfo{
							NativeDenominationKey: {
								Symbol:   "ROSE",
								Decimals: 9,
							},
						},
					},

					"emerald": {
						ID: "000000000000000000000000000000000000000000000000e2eaa99fc008f87f",
						Denominations: map[string]*DenominationInfo{
							NativeDenominationKey: {
								Symbol:   "ROSE",
								Decimals: 18,
							},
						},
					},

					"sapphire": {
						ID: "000000000000000000000000000000000000000000000000f80306c9858e7279",
						Denominations: map[string]*DenominationInfo{
							NativeDenominationKey: {
								Symbol:   "ROSE",
								Decimals: 18,
							},
						},
					},
				},
			},
		},

		"testnet": {
			ChainContext: "50304f98ddb656620ea817cc1446c401752a05a249b36c9b90dba4616829977a",
			RPC:          "testnet.grpc.oasis.dev:443",
			Denomination: DenominationInfo{
				Symbol:   "TEST",
				Decimals: 9,
			},
			ParaTimes: ParaTimes{
				Default: "emerald",
				All: map[string]*ParaTime{

					"cipher": {
						ID: "0000000000000000000000000000000000000000000000000000000000000000",
						Denominations: map[string]*DenominationInfo{
							NativeDenominationKey: {
								Symbol:   "TEST",
								Decimals: 9,
							},
						},
					},

					"emerald": {
						ID: "00000000000000000000000000000000000000000000000072c8215e60d5bca7",
						Denominations: map[string]*DenominationInfo{
							NativeDenominationKey: {
								Symbol:   "TEST",
								Decimals: 18,
							},
						},
					},

					"sapphire": {
						ID: "000000000000000000000000000000000000000000000000a6d1e3ebf60dff6c",
						Denominations: map[string]*DenominationInfo{
							NativeDenominationKey: {
								Symbol:   "TEST",
								Decimals: 18,
							},
						},
					},
				},
			},
		},
	},
}

DefaultNetworks is the default config containing known networks.

Functions

func ValidateIdentifier

func ValidateIdentifier(id string) error

ValidateIdentifier makes sure the given string is a valid identifier.

Types

type DenominationInfo

type DenominationInfo struct {
	Symbol   string `mapstructure:"symbol"`
	Decimals uint8  `mapstructure:"decimals"`
}

DenominationInfo is the denomination information for the given denomination.

func (*DenominationInfo) Validate

func (di *DenominationInfo) Validate() error

Validate performs config validation.

type Network

type Network struct {
	Description  string `mapstructure:"description"`
	ChainContext string `mapstructure:"chain_context"`
	RPC          string `mapstructure:"rpc"`

	Denomination DenominationInfo `mapstructure:"denomination"`

	ParaTimes ParaTimes `mapstructure:"paratimes"`
}

Network contains the configuration parameters of a network.

func (*Network) IsLocalRPC

func (n *Network) IsLocalRPC() bool

IsLocalRPC checks whether the RPC endpoint points to a local UNIX socket.

func (*Network) Validate

func (n *Network) Validate() error

Validate performs config validation.

type Networks

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

	// All is a map of all configured networks.
	All map[string]*Network `mapstructure:",remain"`
}

Networks contains the configuration of supported networks.

func (*Networks) Add

func (n *Networks) Add(name string, net *Network) error

Add adds a new network.

func (*Networks) Remove

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

Remove removes an existing network.

func (*Networks) SetDefault

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

SetDefault sets the given network as the default one.

func (*Networks) Validate

func (n *Networks) Validate() error

Validate performs config validation.

type ParaTime

type ParaTime struct {
	Description string `mapstructure:"description"`
	ID          string `mapstructure:"id"`

	Denominations map[string]*DenominationInfo `mapstructure:"denominations,omitempty"`
}

ParaTime contains the configuration parameters of a network.

func (*ParaTime) GetDenominationInfo

func (p *ParaTime) GetDenominationInfo(d types.Denomination) *DenominationInfo

GetDenominationInfo returns the denomination information for the given denomination.

In case the given denomination does not exist, it provides sane defaults.

func (*ParaTime) Namespace

func (p *ParaTime) Namespace() common.Namespace

Namespace returns the parsed ID of the ParaTime.

Panics if the ID is not valid.

func (*ParaTime) Validate

func (p *ParaTime) Validate() error

Validate performs config validation.

type ParaTimes

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

	// All is a map of all configured paratimes.
	All map[string]*ParaTime `mapstructure:",remain"`
}

ParaTimes contains the configuration of supported paratimes.

func (*ParaTimes) Add

func (p *ParaTimes) Add(name string, pt *ParaTime) error

Add adds a new paratime.

func (*ParaTimes) Remove

func (p *ParaTimes) Remove(name string) error

Remove removes an existing paratime.

func (*ParaTimes) SetDefault

func (p *ParaTimes) SetDefault(name string) error

SetDefault sets the given paratime as the default one.

func (*ParaTimes) Validate

func (p *ParaTimes) Validate() error

Validate performs config validation.

Jump to

Keyboard shortcuts

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