Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type BaseChainProvider ¶
type BaseChainProvider struct {
Config ChainProviderConfig
ChainName string
ChainID string
// contains filtered or unexported fields
}
BaseChainProvider is a base object for connecting with the chain network.
type BaseChainProviderConfig ¶
type BaseChainProviderConfig struct {
Endpoints []string `mapstructure:"endpoints" toml:"endpoints"`
ChainType ChainType `mapstructure:"chain_type" toml:"chain_type"`
MaxRetry int `mapstructure:"max_retry" toml:"max_retry"`
QueryTimeout time.Duration `mapstructure:"query_timeout" toml:"query_timeout"`
ExecuteTimeout time.Duration `mapstructure:"execute_timeout" toml:"execute_timeout"`
ChainID uint64 `mapstructure:"chain_id" toml:"chain_id"`
TunnelRouterAddress string `mapstructure:"tunnel_router_address" toml:"tunnel_router_address"`
}
BaseChainProviderConfig contains common field for particular chain provider.
type ChainProvider ¶
type ChainProvider interface {
KeyProvider
// Init initialize to the chain.
Init(ctx context.Context) error
// QueryTunnelInfo queries the tunnel information from the destination chain.
QueryTunnelInfo(
ctx context.Context,
tunnelID uint64,
tunnelDestinationAddr string,
) (*chainstypes.Tunnel, error)
// RelayPacket relays the packet from the source chain to the destination chain.
RelayPacket(ctx context.Context, packet *bandtypes.Packet) error
// QueryBalance queries balance by given key name from the destination chain.
QueryBalance(ctx context.Context, keyName string) (*big.Int, error)
// GetChainName retrieves the chain name from the chain provider.
GetChainName() string
}
ChainProvider defines the interface for the chain interaction with the destination chain.
type ChainProviderConfig ¶
type ChainProviderConfig interface {
NewChainProvider(
chainName string,
log *zap.Logger,
debug bool,
wallet wallet.Wallet,
) (ChainProvider, error)
GetChainType() ChainType
Validate() error
}
ChainProviderConfig defines the interface for creating a chain provider object.
type ChainProviderConfigs ¶
type ChainProviderConfigs map[string]ChainProviderConfig
ChainProviderConfigs is a collection of ChainProviderConfig interfaces (mapped by chainName)
type ChainProviders ¶
type ChainProviders map[string]ChainProvider
ChainProviders is a collection of ChainProvider interfaces (mapped by chainName)
type ChainType ¶
type ChainType int
ChainType represents the type of chain.
func ToChainType ¶
ToChainType converts a string to a ChainType.
func (ChainType) MarshalText ¶
MarshalText is used for toml encoding.
func (*ChainType) UnmarshalText ¶
UnmarshalText is used for toml decoding.
type Client ¶
type Client interface {
// GetNonce returns the nonce of the given address
GetNonce(address string) (uint64, error)
// BroadcastTx broadcasts the given raw transaction
BroadcastTx(rawTx string) (string, error)
// GetBalances returns the balances of the given accounts
GetBalances(accounts []string) ([]*big.Int, error)
// GetTunnelNonce returns the nonce of the given tunnel
GetTunnelNonce(targetAddress string, tunnelID uint64) (uint64, error)
}
Client defines the interface for the target chain client
type KeyProvider ¶
type KeyProvider interface {
// AddKeyByMnemonic adds a key using a mnemonic phrase.
AddKeyByMnemonic(
keyName string,
mnemonic string,
coinType uint32,
account uint,
index uint,
) (*chainstypes.Key, error)
// AddKeyByPrivateKey adds a key using a private key.
AddKeyByPrivateKey(keyName string, privateKeyHex string) (*chainstypes.Key, error)
// DeleteKey deletes the key information and private key
DeleteKey(keyName string) error
// ExportPrivateKey exports private key of specified key name.
ExportPrivateKey(keyName string) (string, error)
// ListKeys lists all keys
ListKeys() []*chainstypes.Key
// ShowKey shows the address of the given key
ShowKey(keyName string) (string, error)
// LoadFreeSenders loads key info to prepare to relay the packet
LoadFreeSenders() error
}
KeyProvider defines the interface for the key interaction with destination chain