context

package
v0.0.0-...-495235e Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2024 License: MIT Imports: 13 Imported by: 0

Documentation

Overview

Package context provides global app context for ZetaClient

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrChainNotFound     = errors.New("chain not found")
	ErrChainNotSupported = errors.New("chain not supported")
)
View Source
var ErrNotSet = errors.New("AppContext is not set in the context.Context")

Functions

func Copy

func Copy(from, to goctx.Context) goctx.Context

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) GetCurrentTssPubKey

func (a *AppContext) GetCurrentTssPubKey() string

GetCurrentTssPubKey returns the current tss pubKey.

func (*AppContext) GetKeygen

func (a *AppContext) GetKeygen() observertypes.Keygen

GetKeygen returns the current keygen

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(
	keygen observertypes.Keygen,
	freshChains, additionalChains []chains.Chain,
	freshChainParams map[int64]*observertypes.ChainParams,
	tssPubKey string,
	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) ID

func (c Chain) ID() int64

func (Chain) IsBitcoin

func (c Chain) IsBitcoin() bool

func (Chain) IsEVM

func (c Chain) IsEVM() bool

func (Chain) IsSolana

func (c Chain) IsSolana() bool

func (Chain) IsTON

func (c Chain) IsTON() bool

func (Chain) IsZeta

func (c Chain) IsZeta() bool

func (Chain) Name

func (c Chain) Name() string

func (Chain) Params

func (c Chain) Params() *observer.ChainParams

func (Chain) RawChain

func (c Chain) RawChain() *chains.Chain

RawChain returns the underlying Chain object. Better not to use this method

func (Chain) RelayerKeyPassword

func (c Chain) RelayerKeyPassword() string

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

Jump to

Keyboard shortcuts

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