Documentation ¶
Overview ¶
Package context provides global app context for ZetaClient
Index ¶
- Variables
- func Copy(from, to goctx.Context) goctx.Context
- func WithAppContext(ctx goctx.Context, app *AppContext) goctx.Context
- type AppContext
- func (a *AppContext) Config() config.Config
- func (a *AppContext) FilterChains(filter func(Chain) bool) []Chain
- func (a *AppContext) GetChain(chainID int64) (Chain, error)
- func (a *AppContext) GetCrossChainFlags() observertypes.CrosschainFlags
- func (a *AppContext) IsInboundObservationEnabled() bool
- func (a *AppContext) IsOutboundObservationEnabled() bool
- func (a *AppContext) ListChainIDs() []int64
- func (a *AppContext) ListChains() []Chain
- func (a *AppContext) Update(freshChains, additionalChains []chains.Chain, ...) error
- type Chain
- func (c Chain) ID() int64
- func (c Chain) IsBitcoin() bool
- func (c Chain) IsEVM() bool
- func (c Chain) IsSolana() bool
- func (c Chain) IsTON() bool
- func (c Chain) IsZeta() bool
- func (c Chain) Name() string
- func (c Chain) Params() *observer.ChainParams
- func (c Chain) RawChain() *chains.Chain
- func (c Chain) RelayerKeyPassword() string
- type ChainRegistry
- func (cr *ChainRegistry) All() []Chain
- func (cr *ChainRegistry) ChainIDs() []int64
- func (cr *ChainRegistry) Delete(chainIDs ...int64)
- func (cr *ChainRegistry) Get(chainID int64) (Chain, error)
- func (cr *ChainRegistry) Has(chainID int64) bool
- func (cr *ChainRegistry) Set(chainID int64, chain *chains.Chain, params *observer.ChainParams) error
- func (cr *ChainRegistry) SetAdditionalChains(chains []chains.Chain)
Constants ¶
This section is empty.
Variables ¶
var ( ErrChainNotFound = errors.New("chain not found") ErrChainNotSupported = errors.New("chain not supported") )
var ErrNotSet = errors.New("AppContext is not set in the context.Context")
Functions ¶
func Copy ¶
Copy copies AppContext from one context to another (is present). This is useful when you want to drop timeouts and deadlines from the context (e.g. run something in another goroutine).
func WithAppContext ¶
func WithAppContext(ctx goctx.Context, app *AppContext) goctx.Context
WithAppContext applied AppContext to standard Go context.Context.
Types ¶
type AppContext ¶
type AppContext struct {
// contains filtered or unexported fields
}
AppContext represents application (zetaclient) context.
func FromContext ¶
func FromContext(ctx goctx.Context) (*AppContext, error)
FromContext extracts AppContext from context.Context
func New ¶
func New(cfg config.Config, relayerKeyPasswords map[string]string, logger zerolog.Logger) *AppContext
New creates and returns new empty AppContext
func (*AppContext) Config ¶
func (a *AppContext) Config() config.Config
Config returns the config of the app
func (*AppContext) FilterChains ¶
func (a *AppContext) FilterChains(filter func(Chain) bool) []Chain
FilterChains returns the list of chains that satisfy the filter
func (*AppContext) GetChain ¶
func (a *AppContext) GetChain(chainID int64) (Chain, error)
GetChain returns the chain by ID.
func (*AppContext) GetCrossChainFlags ¶
func (a *AppContext) GetCrossChainFlags() observertypes.CrosschainFlags
GetCrossChainFlags returns crosschain flags
func (*AppContext) IsInboundObservationEnabled ¶
func (a *AppContext) IsInboundObservationEnabled() bool
IsInboundObservationEnabled returns true if inbound flag is enabled
func (*AppContext) IsOutboundObservationEnabled ¶
func (a *AppContext) IsOutboundObservationEnabled() bool
IsOutboundObservationEnabled returns true if outbound flag is enabled
func (*AppContext) ListChainIDs ¶
func (a *AppContext) ListChainIDs() []int64
ListChainIDs returns the list of existing chain ids in the registry.
func (*AppContext) ListChains ¶
func (a *AppContext) ListChains() []Chain
ListChains returns the list of existing chains in the registry.
func (*AppContext) Update ¶
func (a *AppContext) Update( freshChains, additionalChains []chains.Chain, freshChainParams map[int64]*observertypes.ChainParams, crosschainFlags observertypes.CrosschainFlags, ) error
Update updates AppContext and params for all chains this must be the ONLY function that writes to AppContext
type Chain ¶
type Chain struct {
// contains filtered or unexported fields
}
Chain represents chain with its parameters
func (Chain) Params ¶
func (c Chain) Params() *observer.ChainParams
func (Chain) RelayerKeyPassword ¶
RelayerKeyPassword returns the relayer key password for the chain
type ChainRegistry ¶
type ChainRegistry struct {
// contains filtered or unexported fields
}
ChainRegistry is a registry of supported chains
func NewChainRegistry ¶
func NewChainRegistry(relayerKeyPasswords map[string]string) *ChainRegistry
NewChainRegistry constructs a new ChainRegistry
func (*ChainRegistry) All ¶
func (cr *ChainRegistry) All() []Chain
All returns all chains in the registry sorted by chain ID.
func (*ChainRegistry) ChainIDs ¶
func (cr *ChainRegistry) ChainIDs() []int64
ChainIDs returns a list of chain IDs in the registry
func (*ChainRegistry) Delete ¶
func (cr *ChainRegistry) Delete(chainIDs ...int64)
Delete deletes one or more chains from the registry
func (*ChainRegistry) Get ¶
func (cr *ChainRegistry) Get(chainID int64) (Chain, error)
Get returns a chain by ID.
func (*ChainRegistry) Has ¶
func (cr *ChainRegistry) Has(chainID int64) bool
Has checks if the chain is in the registry
func (*ChainRegistry) Set ¶
func (cr *ChainRegistry) Set(chainID int64, chain *chains.Chain, params *observer.ChainParams) error
Set sets a chain in the registry. A chain must be SUPPORTED; otherwise returns ErrChainNotSupported
func (*ChainRegistry) SetAdditionalChains ¶
func (cr *ChainRegistry) SetAdditionalChains(chains []chains.Chain)
SetAdditionalChains sets additional chains to the registry