Documentation
¶
Overview ¶
Package config handles configurations.
Index ¶
Constants ¶
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 ¶
var DefaultNetworks = Networks{ Default: "mainnet", All: map[string]*Network{ "mainnet": { ChainContext: "bb3d748def55bdfb797a2ac53ee6ee141e54cd2ab2dc2375f4a0703a178e6e55", RPC: "grpc.oasis.io:443", Denomination: DenominationInfo{ Symbol: symbolROSE, Decimals: 9, }, ParaTimes: ParaTimes{ Default: paratimeSapphire, All: map[string]*ParaTime{ // contains filtered or unexported fields }, }, }, "testnet": { ChainContext: "0b91b8e4e44b2003a7c5e23ddadb5e14ef5345c0ebcb3ddcae07fa2f244cab76", RPC: "testnet.grpc.oasis.io:443", Denomination: DenominationInfo{ Symbol: symbolTEST, Decimals: 9, }, ParaTimes: ParaTimes{ Default: paratimeSapphire, All: map[string]*ParaTime{ // contains filtered or unexported fields }, }, }, "localnet": { ChainContext: "0000000000000000000000000000000000000000000000000000000000000000", RPC: "localhost:8544", Denomination: DenominationInfo{ Symbol: symbolTEST, Decimals: 9, }, ParaTimes: ParaTimes{ Default: paratimeSapphire, All: map[string]*ParaTime{ // contains filtered or unexported fields }, }, }, }, }
DefaultNetworks is the default config containing known networks.
Functions ¶
func ValidateIdentifier ¶
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.
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) SetDefault ¶
SetDefault sets the given network as the default one.
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.
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) SetDefault ¶
SetDefault sets the given paratime as the default one.