config

package
v0.8.2 Latest Latest
Warning

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

Go to latest
Published: Mar 27, 2024 License: Apache-2.0 Imports: 6 Imported by: 18

Documentation

Index

Constants

View Source
const (
	// NativeDenominationKey is the key used to signify the native denomination.
	NativeDenominationKey = "_"

	// ContextKeyParaTimeCfg is the key to retrieve the current ParaTime config from a context.
	ContextKeyParaTimeCfg = contextKey("runtime/paratime-cfg")
)

Variables

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

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

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

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

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

		"testnet": {
			ChainContext: "0b91b8e4e44b2003a7c5e23ddadb5e14ef5345c0ebcb3ddcae07fa2f244cab76",
			RPC:          "testnet.grpc.oasis.io:443",
			Denomination: DenominationInfo{
				Symbol:   "TEST",
				Decimals: 9,
			},
			ParaTimes: ParaTimes{
				Default: "sapphire",
				All: map[string]*ParaTime{

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

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

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

					"pontusx": {
						Description: "Pontus-X Testnet",
						ID:          "0000000000000000000000000000000000000000000000004febe52eb412b421",
						Denominations: map[string]*DenominationInfo{
							NativeDenominationKey: {
								Symbol:   "EUROe",
								Decimals: 18,
							},

							"TEST": {
								Symbol:   "TEST",
								Decimals: 18,
							},
						},
						ConsensusDenomination: "TEST",
					},
				},
			},
		},
	},
}

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 is a map of denominations supported by the ParaTime.
	Denominations map[string]*DenominationInfo `mapstructure:"denominations,omitempty"`
	// ConsensusDenomination is the denomination that represents the consensus layer denomination.
	// If empty, it means that the ParaTime does not support consensus layer transfers.
	ConsensusDenomination string `mapstructure:"consensus_denomination,omitempty"`
}

ParaTime contains the configuration parameters of a ParaTime.

func (*ParaTime) GetDenominationInfo

func (p *ParaTime) GetDenominationInfo(d string) *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