cosmos

package
v2.5.2 Latest Latest
Warning

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

Go to latest
Published: Feb 28, 2024 License: Apache-2.0 Imports: 108 Imported by: 6

Documentation

Index

Constants

View Source
const (
	ErrTimeoutAfterWaitingForTxBroadcast _err = "timed out after waiting for tx to get included in the block"
)
View Source
const PaginationDelay = 10 * time.Millisecond

Variables

View Source
var (
	// SupportedAlgorithms defines the list of signing algorithms used on Evmos:
	//  - secp256k1     (Cosmos)
	//  - sr25519		(Cosmos)
	//  - eth_secp256k1 (Ethereum, Injective)
	SupportedAlgorithms = keyring.SigningAlgoList{hd.Secp256k1, sr25519.Sr25519, ethermint.EthSecp256k1, injective.EthSecp256k1}
	// SupportedAlgorithmsLedger defines the list of signing algorithms used on Evmos for the Ledger device:
	//  - secp256k1     (Cosmos)
	//  - sr25519		(Cosmos)
	//  - eth_secp256k1 (Ethereum, Injective)
	SupportedAlgorithmsLedger = keyring.SigningAlgoList{hd.Secp256k1, sr25519.Sr25519, ethermint.EthSecp256k1, injective.EthSecp256k1}
)

Functions

func BuildSimTx added in v2.3.0

func BuildSimTx(info *keyring.Record, txf tx.Factory, msgs ...sdk.Msg) ([]byte, error)

BuildSimTx creates an unsigned tx with an empty single signature and returns the encoded transaction or an error if the unsigned transaction cannot be built.

func CosmosMsg

func CosmosMsg(rm provider.RelayerMessage) sdk.Msg

func CosmosMsgs

func CosmosMsgs(rm ...provider.RelayerMessage) []sdk.Msg

func CreateMnemonic added in v2.3.0

func CreateMnemonic() (string, error)

CreateMnemonic generates a new mnemonic.

func DefaultPageRequest

func DefaultPageRequest() *querytypes.PageRequest

func GetHeightFromMetadata added in v2.3.0

func GetHeightFromMetadata(md metadata.MD) (int64, error)

func GetProveFromMetadata added in v2.3.0

func GetProveFromMetadata(md metadata.MD) (bool, error)

func KeyringAlgoOptions added in v2.3.0

func KeyringAlgoOptions() keyring.Option

KeyringAlgoOptions defines a function keys options for the ethereum Secp256k1 curve. It supports secp256k1 and eth_secp256k1 keys for accounts.

func NewCosmosMessage

func NewCosmosMessage(msg sdk.Msg, optionalSetSigner func(string)) provider.RelayerMessage

func NewRPCClient added in v2.3.0

func NewRPCClient(addr string, timeout time.Duration) (*rpchttp.HTTP, error)

NewRPCClient initializes a new tendermint RPC client connected to the specified address.

func SetSDKConfigContext added in v2.5.0

func SetSDKConfigContext(prefix string) func()

SetSDKContext sets the SDK config to the given bech32 prefixes

Types

type Codec added in v2.3.0

type Codec struct {
	InterfaceRegistry types.InterfaceRegistry
	Marshaler         codec.Codec
	TxConfig          client.TxConfig
	Amino             *codec.LegacyAmino
}

func MakeCodec added in v2.3.0

func MakeCodec(moduleBasics []module.AppModuleBasic, extraCodecs []string, accBech32Prefix, valBech32Prefix string) Codec

func MakeCodecConfig added in v2.3.0

func MakeCodecConfig(accBech32Prefix, valBech32Prefix string) Codec

type CosmosChainProcessor

type CosmosChainProcessor struct {
	// contains filtered or unexported fields
}

func NewCosmosChainProcessor

func NewCosmosChainProcessor(
	log *zap.Logger,
	provider *CosmosProvider,
	metrics *processor.PrometheusMetrics,
) *CosmosChainProcessor

func (*CosmosChainProcessor) CollectMetrics

func (ccp *CosmosChainProcessor) CollectMetrics(ctx context.Context, persistence *queryCyclePersistence)

func (*CosmosChainProcessor) CurrentBlockHeight

func (ccp *CosmosChainProcessor) CurrentBlockHeight(ctx context.Context, persistence *queryCyclePersistence)

func (*CosmosChainProcessor) CurrentRelayerBalance

func (ccp *CosmosChainProcessor) CurrentRelayerBalance(ctx context.Context)

func (*CosmosChainProcessor) Provider

Provider returns the ChainProvider, which provides the methods for querying, assembling IBC messages, and sending transactions.

func (*CosmosChainProcessor) Run

func (ccp *CosmosChainProcessor) Run(ctx context.Context, initialBlockHistory uint64, stuckPacket *processor.StuckPacket) error

Run starts the query loop for the chain which will gather applicable ibc messages and push events out to the relevant PathProcessors. The initialBlockHistory parameter determines how many historical blocks should be fetched and processed before continuing with current blocks. ChainProcessors should obey the context and return upon context cancellation.

func (*CosmosChainProcessor) SetPathProcessors

func (ccp *CosmosChainProcessor) SetPathProcessors(pathProcessors processor.PathProcessors)

Set the PathProcessors that this ChainProcessor should publish relevant IBC events to. ChainProcessors need reference to their PathProcessors and vice-versa, handled by EventProcessorBuilder.Build().

type CosmosMessage

type CosmosMessage struct {
	Msg              sdk.Msg
	SetSigner        func(string) //callback to update the Msg Signer field
	FeegrantDisabled bool         //marks whether this message type should ALWAYS disable feegranting (use the default signer)
}

func (CosmosMessage) MarshalLogObject

func (cm CosmosMessage) MarshalLogObject(enc zapcore.ObjectEncoder) error

MarshalLogObject is used to encode cm to a zap logger with the zap.Object field type.

func (CosmosMessage) MsgBytes

func (cm CosmosMessage) MsgBytes() ([]byte, error)

func (CosmosMessage) Type

func (cm CosmosMessage) Type() string

type CosmosProvider

type CosmosProvider struct {
	PCfg           CosmosProviderConfig
	Keybase        keyring.Keyring
	KeyringOptions []keyring.Option
	RPCClient      cwrapper.RPCClient
	LightProvider  provtypes.Provider
	Input          io.Reader
	Output         io.Writer
	Cdc            Codec

	// metrics to monitor the provider
	TotalFees sdk.Coins
	// contains filtered or unexported fields
}

func (*CosmosProvider) AccountFromKeyOrAddress added in v2.4.0

func (cc *CosmosProvider) AccountFromKeyOrAddress(keyOrAddress string) (out sdk.AccAddress, err error)

AccountFromKeyOrAddress returns an account from either a key or an address. If 'keyOrAddress' is the empty string, this returns the default key's address.

func (*CosmosProvider) AcknowledgementFromSequence

func (cc *CosmosProvider) AcknowledgementFromSequence(ctx context.Context, dst provider.ChainProvider, dsth, seq uint64, dstChanId, dstPortId, srcChanId, srcPortId string) (provider.RelayerMessage, error)

AcknowledgementFromSequence relays an acknowledgement with a given seq on src, source is the sending chain, destination is the receiving chain

func (*CosmosProvider) AddKey

func (cc *CosmosProvider) AddKey(name string, coinType uint32, signingAlgorithm string) (output *provider.KeyOutput, err error)

AddKey generates a new mnemonic which is then converted to a private key and BIP-39 HD Path and persists it to the keystore. It fails if there is an existing key with the same address.

func (*CosmosProvider) Address

func (cc *CosmosProvider) Address() (string, error)

Address returns the chains configured address as a string

func (*CosmosProvider) AdjustEstimatedGas added in v2.4.0

func (cc *CosmosProvider) AdjustEstimatedGas(gasUsed uint64) (uint64, error)

AdjustEstimatedGas adjusts the estimated gas usage by multiplying it by the gas adjustment factor and return estimated gas is higher than max gas error. If the gas usage is zero, the adjusted gas is also zero.

func (*CosmosProvider) AwaitTx added in v2.4.0

func (cc *CosmosProvider) AwaitTx(txHash bytes.HexBytes, timeout time.Duration) (*txtypes.GetTxResponse, error)

Get the TX by hash, waiting for it to be included in a block

func (*CosmosProvider) BlockTime

func (cc *CosmosProvider) BlockTime(ctx context.Context, height int64) (time.Time, error)

func (*CosmosProvider) CalculateGas added in v2.3.0

func (cc *CosmosProvider) CalculateGas(ctx context.Context, txf tx.Factory, signingKey string, msgs ...sdk.Msg) (txtypes.SimulateResponse, uint64, error)

CalculateGas simulates a tx to generate the appropriate gas settings before broadcasting a tx.

func (*CosmosProvider) ChainId

func (cc *CosmosProvider) ChainId() string

func (*CosmosProvider) ChainName

func (cc *CosmosProvider) ChainName() string

func (*CosmosProvider) ChannelProof

func (cc *CosmosProvider) ChannelProof(
	ctx context.Context,
	msg provider.ChannelInfo,
	height uint64,
) (provider.ChannelProof, error)

func (*CosmosProvider) CommitmentPrefix added in v2.3.0

func (cc *CosmosProvider) CommitmentPrefix() commitmenttypes.MerklePrefix

CommitmentPrefix returns the commitment prefix for Cosmos

func (*CosmosProvider) ConfigureFeegrants added in v2.4.0

func (cc *CosmosProvider) ConfigureFeegrants(numGrantees int, granterKey string) error

func (*CosmosProvider) ConfigureWithExternalGranter added in v2.5.0

func (cc *CosmosProvider) ConfigureWithExternalGranter(grantees []string, granterAddr string) error

func (*CosmosProvider) ConfigureWithGrantees added in v2.4.0

func (cc *CosmosProvider) ConfigureWithGrantees(grantees []string, granterKey string) error

func (*CosmosProvider) ConnectionHandshakeProof

func (cc *CosmosProvider) ConnectionHandshakeProof(
	ctx context.Context,
	msgOpenInit provider.ConnectionInfo,
	height uint64,
) (provider.ConnectionProof, error)

func (*CosmosProvider) ConnectionProof

func (cc *CosmosProvider) ConnectionProof(
	ctx context.Context,
	msgOpenAck provider.ConnectionInfo,
	height uint64,
) (provider.ConnectionProof, error)

func (*CosmosProvider) CreateKeystore added in v2.3.0

func (cc *CosmosProvider) CreateKeystore(path string) error

CreateKeystore initializes a new instance of a keyring at the specified path in the local filesystem.

func (*CosmosProvider) DecodeBech32AccAddr added in v2.4.0

func (cc *CosmosProvider) DecodeBech32AccAddr(addr string) (sdk.AccAddress, error)

func (*CosmosProvider) DeleteKey added in v2.3.0

func (cc *CosmosProvider) DeleteKey(name string) error

DeleteKey removes a key from the keystore for the specified name.

func (*CosmosProvider) EncodeBech32AccAddr added in v2.3.0

func (cc *CosmosProvider) EncodeBech32AccAddr(addr sdk.AccAddress) (string, error)

EncodeBech32AccAddr returns the string bech32 representation for the specified account address. It returns an empty sting if the byte slice is 0-length. It returns an error if the bech32 conversion fails or the prefix is empty.

func (*CosmosProvider) EnsureBasicGrants added in v2.4.0

func (cc *CosmosProvider) EnsureBasicGrants(ctx context.Context, memo string, gas uint64) (*sdk.TxResponse, error)

Ensure all Basic Allowance grants are in place for the given ChainClient. This will query (RPC) for existing grants and create new grants if they don't exist.

func (*CosmosProvider) EnsureExists added in v2.3.0

func (cc *CosmosProvider) EnsureExists(clientCtx client.Context, addr sdk.AccAddress) error

EnsureExists returns an error if no account exists for the given address else nil.

func (*CosmosProvider) ExportPrivKeyArmor added in v2.3.0

func (cc *CosmosProvider) ExportPrivKeyArmor(keyName string) (armor string, err error)

ExportPrivKeyArmor returns a private key in ASCII armored format. It returns an error if the key does not exist or a wrong encryption passphrase is supplied.

func (*CosmosProvider) GenerateConnHandshakeProof

func (cc *CosmosProvider) GenerateConnHandshakeProof(ctx context.Context, height int64, clientId, connId string) (clientState ibcexported.ClientState, clientStateProof []byte, consensusProof []byte, connectionProof []byte, connectionProofHeight ibcexported.Height, err error)

GenerateConnHandshakeProof generates all the proofs needed to prove the existence of the connection state on this chain. A counterparty should use these generated proofs.

func (*CosmosProvider) GetAccount added in v2.3.0

func (cc *CosmosProvider) GetAccount(clientCtx client.Context, addr sdk.AccAddress) (client.Account, error)

GetAccount queries for an account given an address and a block height. An error is returned if the query or decoding fails.

func (*CosmosProvider) GetAccountNumberSequence added in v2.3.0

func (cc *CosmosProvider) GetAccountNumberSequence(clientCtx client.Context, addr sdk.AccAddress) (uint64, uint64, error)

GetAccountNumberSequence returns sequence and account number for the given address. It returns an error if the account couldn't be retrieved from the state.

func (*CosmosProvider) GetAccountWithHeight added in v2.3.0

func (cc *CosmosProvider) GetAccountWithHeight(_ client.Context, addr sdk.AccAddress) (client.Account, int64, error)

GetAccountWithHeight queries for an account given an address. Returns the height of the query with the account. An error is returned if the query or decoding fails.

func (*CosmosProvider) GetGranteeValidBasicGrants added in v2.4.0

func (cc *CosmosProvider) GetGranteeValidBasicGrants(granteeKey string) ([]*feegrant.Grant, error)

Searches for valid, existing BasicAllowance grants for the given grantee & ChainClient's configured granter. Expired grants are ignored. Other grant types are ignored.

func (*CosmosProvider) GetKeyAddress added in v2.3.0

func (cc *CosmosProvider) GetKeyAddress(key string) (sdk.AccAddress, error)

GetKeyAddress returns the account address representation for the currently configured key.

func (*CosmosProvider) GetKeyAddressForKey added in v2.4.0

func (cc *CosmosProvider) GetKeyAddressForKey(key string) (sdk.AccAddress, error)

func (*CosmosProvider) GetQueryContext added in v2.4.0

func (cc *CosmosProvider) GetQueryContext(height int64) (context.Context, context.CancelFunc)

GetQueryContext returns a context that includes the height and uses the timeout from the config

func (*CosmosProvider) GetTxFeeGrant added in v2.4.0

func (cc *CosmosProvider) GetTxFeeGrant() (txSignerKey string, feeGranterKeyOrAddr string)

Get the feegrant params to use for the next TX. If feegrants are not configured for the chain client, the default key will be used for TX signing. Otherwise, a configured feegrantee will be chosen for TX signing in round-robin fashion.

func (*CosmosProvider) GetValidBasicGrants added in v2.4.0

func (cc *CosmosProvider) GetValidBasicGrants() ([]*feegrant.Grant, error)

Searches for valid, existing BasicAllowance grants for the ChainClient's configured Feegranter. Expired grants are ignored. Other grant types are ignored.

func (*CosmosProvider) GrantAllGranteesBasicAllowance added in v2.4.0

func (cc *CosmosProvider) GrantAllGranteesBasicAllowance(ctx context.Context, gas uint64) error

GrantBasicAllowance Send a feegrant with the basic allowance type. This function does not check for existing feegrant authorizations. TODO: check for existing authorizations prior to attempting new one.

func (*CosmosProvider) GrantAllGranteesBasicAllowanceWithExpiration added in v2.4.0

func (cc *CosmosProvider) GrantAllGranteesBasicAllowanceWithExpiration(ctx context.Context, gas uint64, expiration time.Time) error

GrantBasicAllowance Send a feegrant with the basic allowance type. This function does not check for existing feegrant authorizations.

func (*CosmosProvider) GrantBasicAllowance added in v2.4.0

func (cc *CosmosProvider) GrantBasicAllowance(ctx context.Context, granter sdk.AccAddress, granterKeyName string, grantee sdk.AccAddress, gas uint64) (*txtypes.GetTxResponse, error)

func (*CosmosProvider) GrantBasicAllowanceWithExpiration added in v2.4.0

func (cc *CosmosProvider) GrantBasicAllowanceWithExpiration(ctx context.Context, granter sdk.AccAddress, granterKeyName string, grantee sdk.AccAddress, gas uint64, expiration time.Time) (*txtypes.GetTxResponse, error)

func (*CosmosProvider) Init added in v2.3.0

func (cc *CosmosProvider) Init(ctx context.Context) error

Init initializes the keystore, RPC client, amd light client provider. Once initialization is complete an attempt to query the underlying node's tendermint version is performed. NOTE: Init must be called after creating a new instance of CosmosProvider.

func (*CosmosProvider) InjectTrustedFields

func (cc *CosmosProvider) InjectTrustedFields(ctx context.Context, header ibcexported.ClientMessage, dst provider.ChainProvider, dstClientId string) (ibcexported.ClientMessage, error)

InjectTrustedFields injects the necessary trusted fields for a header to update a light client stored on the destination chain, using the information provided by the source chain. TrustedHeight is the latest height of the IBC client on dst TrustedValidators is the validator set of srcChain at the TrustedHeight InjectTrustedFields returns a copy of the header with TrustedFields modified

func (*CosmosProvider) Invoke added in v2.3.0

func (cc *CosmosProvider) Invoke(ctx context.Context, method string, req, reply interface{}, opts ...grpc.CallOption) (err error)

Invoke implements the grpc ClientConn.Invoke method

func (*CosmosProvider) Key

func (cc *CosmosProvider) Key() string

func (*CosmosProvider) KeyAddOrRestore added in v2.3.0

func (cc *CosmosProvider) KeyAddOrRestore(keyName string, coinType uint32, signingAlgorithm string, mnemonic ...string) (*provider.KeyOutput, error)

KeyAddOrRestore either generates a new mnemonic or uses the specified mnemonic and converts it to a private key and BIP-39 HD Path which is then persisted to the keystore. It fails if there is an existing key with the same address.

func (*CosmosProvider) KeyExists added in v2.3.0

func (cc *CosmosProvider) KeyExists(name string) bool

KeyExists returns true if a key with the specified name exists in the keystore, it returns false otherwise.

func (*CosmosProvider) KeyFromKeyOrAddress added in v2.4.0

func (cc *CosmosProvider) KeyFromKeyOrAddress(keyOrAddress string) (string, error)

func (*CosmosProvider) KeystoreCreated added in v2.3.0

func (cc *CosmosProvider) KeystoreCreated(path string) bool

KeystoreCreated returns true if there is an existing keystore instance at the specified path, it returns false otherwise.

func (*CosmosProvider) ListAddresses added in v2.3.0

func (cc *CosmosProvider) ListAddresses() (map[string]string, error)

ListAddresses returns a map of bech32 encoded strings representing all keys currently in the keystore.

func (*CosmosProvider) LogFailedTx

func (cc *CosmosProvider) LogFailedTx(res *provider.RelayerTxResponse, err error, msgs []provider.RelayerMessage)

LogFailedTx takes the transaction and the messages to create it and logs the appropriate data

func (*CosmosProvider) LogSuccessTx

func (cc *CosmosProvider) LogSuccessTx(res *sdk.TxResponse, msgs []provider.RelayerMessage)

LogSuccessTx take the transaction and the messages to create it and logs the appropriate data

func (*CosmosProvider) MsgAcknowledgement

func (cc *CosmosProvider) MsgAcknowledgement(
	msgRecvPacket provider.PacketInfo,
	proof provider.PacketProof,
) (provider.RelayerMessage, error)

func (*CosmosProvider) MsgChannelCloseConfirm

func (cc *CosmosProvider) MsgChannelCloseConfirm(msgCloseInit provider.ChannelInfo, proof provider.ChannelProof) (provider.RelayerMessage, error)

func (*CosmosProvider) MsgChannelCloseInit

func (cc *CosmosProvider) MsgChannelCloseInit(info provider.ChannelInfo, proof provider.ChannelProof) (provider.RelayerMessage, error)

func (*CosmosProvider) MsgChannelOpenAck

func (cc *CosmosProvider) MsgChannelOpenAck(msgOpenTry provider.ChannelInfo, proof provider.ChannelProof) (provider.RelayerMessage, error)

func (*CosmosProvider) MsgChannelOpenConfirm

func (cc *CosmosProvider) MsgChannelOpenConfirm(msgOpenAck provider.ChannelInfo, proof provider.ChannelProof) (provider.RelayerMessage, error)

func (*CosmosProvider) MsgChannelOpenInit

func (cc *CosmosProvider) MsgChannelOpenInit(info provider.ChannelInfo, proof provider.ChannelProof) (provider.RelayerMessage, error)

func (*CosmosProvider) MsgChannelOpenTry

func (cc *CosmosProvider) MsgChannelOpenTry(msgOpenInit provider.ChannelInfo, proof provider.ChannelProof) (provider.RelayerMessage, error)

func (*CosmosProvider) MsgConnectionOpenAck

func (cc *CosmosProvider) MsgConnectionOpenAck(msgOpenTry provider.ConnectionInfo, proof provider.ConnectionProof) (provider.RelayerMessage, error)

func (*CosmosProvider) MsgConnectionOpenConfirm

func (cc *CosmosProvider) MsgConnectionOpenConfirm(msgOpenAck provider.ConnectionInfo, proof provider.ConnectionProof) (provider.RelayerMessage, error)

func (*CosmosProvider) MsgConnectionOpenInit

func (cc *CosmosProvider) MsgConnectionOpenInit(info provider.ConnectionInfo, proof provider.ConnectionProof) (provider.RelayerMessage, error)

func (*CosmosProvider) MsgConnectionOpenTry

func (cc *CosmosProvider) MsgConnectionOpenTry(msgOpenInit provider.ConnectionInfo, proof provider.ConnectionProof) (provider.RelayerMessage, error)

func (*CosmosProvider) MsgCreateClient

func (cc *CosmosProvider) MsgCreateClient(
	clientState ibcexported.ClientState,
	consensusState ibcexported.ConsensusState,
) (provider.RelayerMessage, error)

MsgCreateClient creates an sdk.Msg to update the client on src with consensus state from dst

func (*CosmosProvider) MsgRecvPacket

func (cc *CosmosProvider) MsgRecvPacket(
	msgTransfer provider.PacketInfo,
	proof provider.PacketProof,
) (provider.RelayerMessage, error)

func (*CosmosProvider) MsgRegisterCounterpartyPayee added in v2.4.0

func (cc *CosmosProvider) MsgRegisterCounterpartyPayee(portID, channelID, relayerAddr, counterpartyPayee string) (provider.RelayerMessage, error)

MsgRegisterCounterpartyPayee creates an sdk.Msg to broadcast the counterparty address

func (*CosmosProvider) MsgSubmitMisbehaviour added in v2.3.0

func (cc *CosmosProvider) MsgSubmitMisbehaviour(clientID string, misbehaviour ibcexported.ClientMessage) (provider.RelayerMessage, error)

func (*CosmosProvider) MsgSubmitQueryResponse added in v2.3.0

func (cc *CosmosProvider) MsgSubmitQueryResponse(chainID string, queryID provider.ClientICQQueryID, proof provider.ICQProof) (provider.RelayerMessage, error)

func (*CosmosProvider) MsgTimeout

func (cc *CosmosProvider) MsgTimeout(msgTransfer provider.PacketInfo, proof provider.PacketProof) (provider.RelayerMessage, error)

func (*CosmosProvider) MsgTimeoutOnClose

func (cc *CosmosProvider) MsgTimeoutOnClose(msgTransfer provider.PacketInfo, proof provider.PacketProof) (provider.RelayerMessage, error)

func (*CosmosProvider) MsgTransfer

func (cc *CosmosProvider) MsgTransfer(
	dstAddr string,
	amount sdk.Coin,
	info provider.PacketInfo,
) (provider.RelayerMessage, error)

MsgTransfer creates a new transfer message

func (*CosmosProvider) MsgUpdateClient

func (cc *CosmosProvider) MsgUpdateClient(srcClientID string, dstHeader ibcexported.ClientMessage) (provider.RelayerMessage, error)

func (*CosmosProvider) MsgUpdateClientHeader

func (cc *CosmosProvider) MsgUpdateClientHeader(latestHeader provider.IBCHeader, trustedHeight clienttypes.Height, trustedHeader provider.IBCHeader) (ibcexported.ClientMessage, error)

func (*CosmosProvider) MsgUpgradeClient

func (*CosmosProvider) MustEncodeAccAddr added in v2.4.0

func (cc *CosmosProvider) MustEncodeAccAddr(addr sdk.AccAddress) string

func (*CosmosProvider) NewClientState

func (cc *CosmosProvider) NewClientState(
	dstChainID string,
	dstUpdateHeader provider.IBCHeader,
	dstTrustingPeriod,
	dstUbdPeriod,
	maxClockDrift time.Duration,
	allowUpdateAfterExpiry,
	allowUpdateAfterMisbehaviour bool,
) (ibcexported.ClientState, error)

NewClientState creates a new tendermint client state tracking the dst chain.

func (*CosmosProvider) NewStream added in v2.3.0

NewStream implements the grpc ClientConn.NewStream method

func (*CosmosProvider) NextSeqRecv

func (cc *CosmosProvider) NextSeqRecv(
	ctx context.Context,
	msgTransfer provider.PacketInfo,
	height uint64,
) (provider.PacketProof, error)

NextSeqRecv queries for the appropriate Tendermint proof required to prove the next expected packet sequence number for a given counterparty channel. This is used in ORDERED channels to ensure packets are being delivered in the exact same order as they were sent over the wire.

func (*CosmosProvider) PacketAcknowledgement

func (cc *CosmosProvider) PacketAcknowledgement(
	ctx context.Context,
	msgRecvPacket provider.PacketInfo,
	height uint64,
) (provider.PacketProof, error)

func (*CosmosProvider) PacketCommitment

func (cc *CosmosProvider) PacketCommitment(
	ctx context.Context,
	msgTransfer provider.PacketInfo,
	height uint64,
) (provider.PacketProof, error)

func (*CosmosProvider) PacketReceipt

func (cc *CosmosProvider) PacketReceipt(
	ctx context.Context,
	msgTransfer provider.PacketInfo,
	height uint64,
) (provider.PacketProof, error)

func (*CosmosProvider) PrepareFactory added in v2.3.0

func (cc *CosmosProvider) PrepareFactory(txf tx.Factory, signingKey string) (tx.Factory, error)

PrepareFactory mutates the tx factory with the appropriate account number, sequence number, and min gas settings.

func (*CosmosProvider) ProviderConfig

func (cc *CosmosProvider) ProviderConfig() provider.ProviderConfig

func (*CosmosProvider) QueryABCI added in v2.3.0

QueryABCI performs an ABCI query and returns the appropriate response and error sdk error code.

func (*CosmosProvider) QueryBalance

func (cc *CosmosProvider) QueryBalance(ctx context.Context, keyName string) (sdk.Coins, error)

QueryBalance returns the amount of coins in the relayer account

func (*CosmosProvider) QueryBalanceWithAddress

func (cc *CosmosProvider) QueryBalanceWithAddress(ctx context.Context, address string) (sdk.Coins, error)

QueryBalanceWithAddress returns the amount of coins in the relayer account with address as input

func (*CosmosProvider) QueryChannel

func (cc *CosmosProvider) QueryChannel(ctx context.Context, height int64, channelid, portid string) (chanRes *chantypes.QueryChannelResponse, err error)

QueryChannel returns the channel associated with a channelID

func (*CosmosProvider) QueryChannelClient

func (cc *CosmosProvider) QueryChannelClient(ctx context.Context, height int64, channelid, portid string) (*clienttypes.IdentifiedClientState, error)

QueryChannelClient returns the client state of the client supporting a given channel

func (*CosmosProvider) QueryChannels

func (cc *CosmosProvider) QueryChannels(ctx context.Context) ([]*chantypes.IdentifiedChannel, error)

QueryChannels returns all the channels that are registered on a chain.

func (*CosmosProvider) QueryChannelsPaginated added in v2.3.0

func (cc *CosmosProvider) QueryChannelsPaginated(
	ctx context.Context,
	pageRequest *querytypes.PageRequest,
) ([]*chantypes.IdentifiedChannel, []byte, error)

QueryChannelsPaginated returns all the channels for a particular paginated request that are registered on a chain.

func (*CosmosProvider) QueryClientConsensusState

func (cc *CosmosProvider) QueryClientConsensusState(ctx context.Context, chainHeight int64, clientid string, clientHeight ibcexported.Height) (*clienttypes.QueryConsensusStateResponse, error)

QueryClientConsensusState retrieves the latest consensus state for a client in state at a given height

func (*CosmosProvider) QueryClientState

func (cc *CosmosProvider) QueryClientState(ctx context.Context, height int64, clientid string) (ibcexported.ClientState, error)

QueryClientState retrieves the latest consensus state for a client in state at a given height and unpacks it to exported client state interface

func (*CosmosProvider) QueryClientStateResponse

func (cc *CosmosProvider) QueryClientStateResponse(ctx context.Context, height int64, srcClientId string) (*clienttypes.QueryClientStateResponse, error)

QueryClientStateResponse retrieves the latest consensus state for a client in state at a given height

func (*CosmosProvider) QueryClients

QueryClients queries all the clients!

func (*CosmosProvider) QueryConnection

func (cc *CosmosProvider) QueryConnection(ctx context.Context, height int64, connectionid string) (*conntypes.QueryConnectionResponse, error)

QueryConnection returns the remote end of a given connection

func (*CosmosProvider) QueryConnectionChannels

func (cc *CosmosProvider) QueryConnectionChannels(ctx context.Context, height int64, connectionid string) ([]*chantypes.IdentifiedChannel, error)

QueryConnectionChannels queries the channels associated with a connection

func (*CosmosProvider) QueryConnections

func (cc *CosmosProvider) QueryConnections(ctx context.Context) ([]*conntypes.IdentifiedConnection, error)

QueryConnections gets any connections on a chain

func (*CosmosProvider) QueryConnectionsUsingClient

func (cc *CosmosProvider) QueryConnectionsUsingClient(ctx context.Context, height int64, clientid string) (*conntypes.QueryConnectionsResponse, error)

QueryConnectionsUsingClient gets any connections that exist between chain and counterparty

func (*CosmosProvider) QueryConsensusState

func (cc *CosmosProvider) QueryConsensusState(ctx context.Context, height int64) (ibcexported.ConsensusState, int64, error)

QueryConsensusState returns a consensus state for a given chain to be used as a client in another chain, fetches latest height when passed 0 as arg

func (*CosmosProvider) QueryConsensusStateABCI

func (cc *CosmosProvider) QueryConsensusStateABCI(ctx context.Context, clientID string, height ibcexported.Height) (*clienttypes.QueryConsensusStateResponse, error)

func (*CosmosProvider) QueryDenomTrace

func (cc *CosmosProvider) QueryDenomTrace(ctx context.Context, denom string) (*transfertypes.DenomTrace, error)

QueryDenomTrace takes a denom from IBC and queries the information about it

func (*CosmosProvider) QueryDenomTraces

func (cc *CosmosProvider) QueryDenomTraces(ctx context.Context, offset, limit uint64, height int64) ([]transfertypes.DenomTrace, error)

QueryDenomTraces returns all the denom traces from a given chain

func (*CosmosProvider) QueryFeegrantsByGrantee added in v2.4.0

func (cc *CosmosProvider) QueryFeegrantsByGrantee(address string, paginator *querytypes.PageRequest) ([]*feegrant.Grant, error)

QueryFeegrantsByGrantee returns all requested grants for the given grantee. Default behavior will return all grants.

func (*CosmosProvider) QueryFeegrantsByGranter added in v2.4.0

func (cc *CosmosProvider) QueryFeegrantsByGranter(address string, paginator *querytypes.PageRequest) ([]*feegrant.Grant, error)

Feegrant_GrantsByGranterRPC returns all requested grants for the given Granter. Default behavior will return all grants.

func (*CosmosProvider) QueryIBCHeader

func (cc *CosmosProvider) QueryIBCHeader(ctx context.Context, h int64) (provider.IBCHeader, error)

QueryIBCHeader returns the IBC compatible block header (TendermintIBCHeader) at a specific height.

func (*CosmosProvider) QueryICQWithProof added in v2.3.0

func (cc *CosmosProvider) QueryICQWithProof(ctx context.Context, path string, request []byte, height uint64) (provider.ICQProof, error)

func (*CosmosProvider) QueryLatestHeight

func (cc *CosmosProvider) QueryLatestHeight(ctx context.Context) (int64, error)

func (*CosmosProvider) QueryNextSeqAck added in v2.4.0

func (cc *CosmosProvider) QueryNextSeqAck(ctx context.Context, height int64, channelid, portid string) (recvRes *chantypes.QueryNextSequenceReceiveResponse, err error)

QueryNextSeqAck returns the next seqAck for a configured channel

func (*CosmosProvider) QueryNextSeqRecv

func (cc *CosmosProvider) QueryNextSeqRecv(ctx context.Context, height int64, channelid, portid string) (recvRes *chantypes.QueryNextSequenceReceiveResponse, err error)

QueryNextSeqRecv returns the next seqRecv for a configured channel

func (*CosmosProvider) QueryPacketAcknowledgement

func (cc *CosmosProvider) QueryPacketAcknowledgement(ctx context.Context, height int64, channelid, portid string, seq uint64) (ackRes *chantypes.QueryPacketAcknowledgementResponse, err error)

QueryPacketAcknowledgement returns the packet ack proof at a given height

func (*CosmosProvider) QueryPacketAcknowledgements

func (cc *CosmosProvider) QueryPacketAcknowledgements(ctx context.Context, height uint64, channelid, portid string) ([]*chantypes.PacketState, error)

QueryPacketAcknowledgements returns an array of packet acks

func (*CosmosProvider) QueryPacketCommitment

func (cc *CosmosProvider) QueryPacketCommitment(ctx context.Context, height int64, channelid, portid string, seq uint64) (comRes *chantypes.QueryPacketCommitmentResponse, err error)

QueryPacketCommitment returns the packet commitment proof at a given height

func (*CosmosProvider) QueryPacketCommitments

func (cc *CosmosProvider) QueryPacketCommitments(ctx context.Context, height uint64, channelid, portid string) (*chantypes.QueryPacketCommitmentsResponse, error)

QueryPacketCommitments returns an array of packet commitments

func (*CosmosProvider) QueryPacketReceipt

func (cc *CosmosProvider) QueryPacketReceipt(ctx context.Context, height int64, channelid, portid string, seq uint64) (recRes *chantypes.QueryPacketReceiptResponse, err error)

QueryPacketReceipt returns the packet receipt proof at a given height

func (*CosmosProvider) QueryRecvPacket

func (cc *CosmosProvider) QueryRecvPacket(
	ctx context.Context,
	dstChanID,
	dstPortID string,
	sequence uint64,
) (provider.PacketInfo, error)

func (*CosmosProvider) QuerySendPacket

func (cc *CosmosProvider) QuerySendPacket(
	ctx context.Context,
	srcChanID,
	srcPortID string,
	sequence uint64,
) (provider.PacketInfo, error)

func (*CosmosProvider) QueryStakingParams

func (cc *CosmosProvider) QueryStakingParams(ctx context.Context) (*stakingtypes.Params, error)

func (*CosmosProvider) QueryStatus added in v2.3.0

func (cc *CosmosProvider) QueryStatus(ctx context.Context) (*coretypes.ResultStatus, error)

Query current node status

func (*CosmosProvider) QueryTendermintProof

func (cc *CosmosProvider) QueryTendermintProof(ctx context.Context, height int64, key []byte) ([]byte, []byte, clienttypes.Height, error)

QueryTendermintProof performs an ABCI query with the given key and returns the value of the query, the proto encoded merkle proof, and the height of the Tendermint block containing the state root. The desired tendermint height to perform the query should be set in the client context. The query will be performed at one below this height (at the IAVL version) in order to obtain the correct merkle proof. Proof queries at height less than or equal to 2 are not supported. Queries with a client context height of 0 will perform a query at the latest state available. Issue: https://github.com/cosmos/cosmos-sdk/issues/6567

func (*CosmosProvider) QueryTx

func (cc *CosmosProvider) QueryTx(ctx context.Context, hashHex string) (*provider.RelayerTxResponse, error)

QueryTx takes a transaction hash and returns the transaction

func (*CosmosProvider) QueryTxs

func (cc *CosmosProvider) QueryTxs(ctx context.Context, page, limit int, events []string) ([]*provider.RelayerTxResponse, error)

QueryTxs returns an array of transactions given a tag

func (*CosmosProvider) QueryUnbondingPeriod

func (cc *CosmosProvider) QueryUnbondingPeriod(ctx context.Context) (time.Duration, error)

QueryUnbondingPeriod returns the unbonding period of the chain

func (*CosmosProvider) QueryUnreceivedAcknowledgements

func (cc *CosmosProvider) QueryUnreceivedAcknowledgements(ctx context.Context, height uint64, channelid, portid string, seqs []uint64) ([]uint64, error)

QueryUnreceivedAcknowledgements returns a list of unrelayed packet acks

func (*CosmosProvider) QueryUnreceivedPackets

func (cc *CosmosProvider) QueryUnreceivedPackets(ctx context.Context, height uint64, channelid, portid string, seqs []uint64) ([]uint64, error)

QueryUnreceivedPackets returns a list of unrelayed packet commitments

func (*CosmosProvider) QueryUpgradeProof

func (cc *CosmosProvider) QueryUpgradeProof(ctx context.Context, key []byte, height uint64) ([]byte, clienttypes.Height, error)

QueryUpgradeProof performs an abci query with the given key and returns the proto encoded merkle proof for the query and the height at which the proof will succeed on a tendermint verifier.

func (*CosmosProvider) QueryUpgradedClient

func (cc *CosmosProvider) QueryUpgradedClient(ctx context.Context, height int64) (*clienttypes.QueryClientStateResponse, error)

QueryUpgradedClient returns upgraded client info

func (*CosmosProvider) QueryUpgradedConsState

func (cc *CosmosProvider) QueryUpgradedConsState(ctx context.Context, height int64) (*clienttypes.QueryConsensusStateResponse, error)

QueryUpgradedConsState returns upgraded consensus state and height of client

func (*CosmosProvider) RelayPacketFromSequence

func (cc *CosmosProvider) RelayPacketFromSequence(
	ctx context.Context,
	src provider.ChainProvider,
	srch, dsth, seq uint64,
	srcChanID, srcPortID string,
	order chantypes.Order,
) (provider.RelayerMessage, provider.RelayerMessage, error)

RelayPacketFromSequence relays a packet with a given seq on src and returns recvPacket msgs, timeoutPacketmsgs and error

func (*CosmosProvider) RestoreKey added in v2.3.0

func (cc *CosmosProvider) RestoreKey(name, mnemonic string, coinType uint32, signingAlgorithm string) (address string, err error)

RestoreKey converts a mnemonic to a private key and BIP-39 HD Path and persists it to the keystore. It fails if there is an existing key with the same address.

func (*CosmosProvider) RunGRPCQuery added in v2.3.0

func (cc *CosmosProvider) RunGRPCQuery(ctx context.Context, method string, req interface{}, md metadata.MD) (abci.ResponseQuery, metadata.MD, error)

RunGRPCQuery runs a gRPC query from the clientCtx, given all necessary arguments for the gRPC method, and returns the ABCI response. It is used to factorize code between client (Invoke) and server (RegisterGRPCServer) gRPC handlers.

func (*CosmosProvider) SendMessage

SendMessage attempts to sign, encode & send a RelayerMessage This is used extensively in the relayer as an extension of the Provider interface

func (*CosmosProvider) SendMessages

SendMessages attempts to sign, encode, & send a slice of RelayerMessages This is used extensively in the relayer as an extension of the Provider interface

NOTE: An error is returned if there was an issue sending the transaction. A successfully sent, but failed transaction will not return an error. If a transaction is successfully sent, the result of the execution of that transaction will be logged. A boolean indicating if a transaction was successfully sent and executed successfully is returned.

func (*CosmosProvider) SendMessagesToMempool added in v2.3.0

func (cc *CosmosProvider) SendMessagesToMempool(
	ctx context.Context,
	msgs []provider.RelayerMessage,
	memo string,

	asyncCtx context.Context,
	asyncCallbacks []func(*provider.RelayerTxResponse, error),
) error

SendMessagesToMempool simulates and broadcasts a transaction with the given msgs and memo. This method will return once the transaction has entered the mempool. In an async goroutine, will wait for the tx to be included in the block unless asyncCtx exits. If there is no error broadcasting, the asyncCallback will be called with success/failure of the wait for block inclusion.

func (*CosmosProvider) SendMsgsWith added in v2.4.0

func (cc *CosmosProvider) SendMsgsWith(ctx context.Context, msgs []sdk.Msg, memo string, gas uint64, signingKey string, feegranterKey string) (*coretypes.ResultBroadcastTx, error)

SendMsgs wraps the msgs in a StdTx, signs and sends it. An error is returned if there was an issue sending the transaction. A successfully sent, but failed transaction will not return an error. If a transaction is successfully sent, the result of the execution of that transaction will be logged. A boolean indicating if a transaction was successfully sent and executed successfully is returned.

feegranterKey - key name of the address set as the feegranter, empty string will not feegrant

func (*CosmosProvider) SetMetrics

func (cc *CosmosProvider) SetMetrics(m *processor.PrometheusMetrics)

func (*CosmosProvider) SetRpcAddr added in v2.5.0

func (cc *CosmosProvider) SetRpcAddr(rpcAddr string) error

SetPCAddr sets the rpc-addr for the chain. It will fail if the rpcAddr is invalid(not a url).

func (*CosmosProvider) SetSDKContext added in v2.3.0

func (cc *CosmosProvider) SetSDKContext() func()

SetSDKContext sets the SDK config to the proper bech32 prefixes. Don't use this unless you know what you're doing. TODO: :dagger: :knife: :chainsaw: remove this function

func (*CosmosProvider) SetWithExtensionOptions added in v2.4.0

func (cc *CosmosProvider) SetWithExtensionOptions(txf tx.Factory) (tx.Factory, error)

SetWithExtensionOptions sets the dynamic fee extension options on the given transaction factory using the configuration options from the CosmosProvider. The function creates an extension option for each configuration option and serializes it into a byte slice before adding it to the list of extension options. The function returns the updated transaction factory with the new extension options or an error if the serialization fails or an invalid option value is encountered.

func (*CosmosProvider) ShowAddress added in v2.3.0

func (cc *CosmosProvider) ShowAddress(name string) (address string, err error)

ShowAddress retrieves a key by name from the keystore and returns the bech32 encoded string representation of that key.

func (*CosmosProvider) Sprint

func (cc *CosmosProvider) Sprint(toPrint proto.Message) (string, error)

Sprint returns the json representation of the specified proto message.

func (*CosmosProvider) SubmitTxAwaitResponse added in v2.4.0

func (cc *CosmosProvider) SubmitTxAwaitResponse(ctx context.Context, msgs []sdk.Msg, memo string, gas uint64, signingKeyName string) (*txtypes.GetTxResponse, error)

func (*CosmosProvider) Timeout

func (cc *CosmosProvider) Timeout() string

func (*CosmosProvider) TrustingPeriod

func (cc *CosmosProvider) TrustingPeriod(ctx context.Context, overrideUnbondingPeriod time.Duration, percentage int64) (time.Duration, error)

func (*CosmosProvider) TxFactory added in v2.3.0

func (cc *CosmosProvider) TxFactory() tx.Factory

TxFactory instantiates a new tx factory with the appropriate configuration settings for this chain.

func (*CosmosProvider) TxServiceBroadcast added in v2.3.0

func (cc *CosmosProvider) TxServiceBroadcast(ctx context.Context, req *tx.BroadcastTxRequest) (*tx.BroadcastTxResponse, error)

TxServiceBroadcast is a helper function to broadcast a Tx with the correct gRPC types from the tx service. Calls `clientCtx.BroadcastTx` under the hood.

func (*CosmosProvider) Type

func (cc *CosmosProvider) Type() string

func (*CosmosProvider) UpdateFeesSpent

func (cc *CosmosProvider) UpdateFeesSpent(chain, key, address string, fees sdk.Coins)

func (*CosmosProvider) UseKey added in v2.4.2

func (cc *CosmosProvider) UseKey(key string) error

Updates config.yaml chain with the specified key. It fails config is already using the same key or if the key does not exist

func (*CosmosProvider) ValidatePacket

func (cc *CosmosProvider) ValidatePacket(msgTransfer provider.PacketInfo, latest provider.LatestBlock) error

func (*CosmosProvider) WaitForNBlocks

func (cc *CosmosProvider) WaitForNBlocks(ctx context.Context, n int64) error

WaitForNBlocks blocks until the next block on a given chain

type CosmosProviderConfig

type CosmosProviderConfig struct {
	KeyDirectory     string                     `json:"key-directory" yaml:"key-directory"`
	Key              string                     `json:"key" yaml:"key"`
	ChainName        string                     `json:"-" yaml:"-"`
	ChainID          string                     `json:"chain-id" yaml:"chain-id"`
	RPCAddr          string                     `json:"rpc-addr" yaml:"rpc-addr"`
	AccountPrefix    string                     `json:"account-prefix" yaml:"account-prefix"`
	KeyringBackend   string                     `json:"keyring-backend" yaml:"keyring-backend"`
	GasAdjustment    float64                    `json:"gas-adjustment" yaml:"gas-adjustment"`
	GasPrices        string                     `json:"gas-prices" yaml:"gas-prices"`
	MinGasAmount     uint64                     `json:"min-gas-amount" yaml:"min-gas-amount"`
	MaxGasAmount     uint64                     `json:"max-gas-amount" yaml:"max-gas-amount"`
	Debug            bool                       `json:"debug" yaml:"debug"`
	Timeout          string                     `json:"timeout" yaml:"timeout"`
	BlockTimeout     string                     `json:"block-timeout" yaml:"block-timeout"`
	OutputFormat     string                     `json:"output-format" yaml:"output-format"`
	SignModeStr      string                     `json:"sign-mode" yaml:"sign-mode"`
	ExtraCodecs      []string                   `json:"extra-codecs" yaml:"extra-codecs"`
	Modules          []module.AppModuleBasic    `json:"-" yaml:"-"`
	Slip44           *int                       `json:"coin-type" yaml:"coin-type"`
	SigningAlgorithm string                     `json:"signing-algorithm" yaml:"signing-algorithm"`
	Broadcast        provider.BroadcastMode     `json:"broadcast-mode" yaml:"broadcast-mode"`
	MinLoopDuration  time.Duration              `json:"min-loop-duration" yaml:"min-loop-duration"`
	ExtensionOptions []provider.ExtensionOption `json:"extension-options" yaml:"extension-options"`

	// If FeeGrantConfiguration is set, TXs submitted by the ChainClient will be signed by the FeeGrantees in a round-robin fashion by default.
	FeeGrants *FeeGrantConfiguration `json:"feegrants" yaml:"feegrants"`
}

func (CosmosProviderConfig) BroadcastMode added in v2.3.0

func (pc CosmosProviderConfig) BroadcastMode() provider.BroadcastMode

func (CosmosProviderConfig) NewProvider

func (pc CosmosProviderConfig) NewProvider(log *zap.Logger, homepath string, debug bool, chainName string) (provider.ChainProvider, error)

NewProvider validates the CosmosProviderConfig, instantiates a ChainClient and then instantiates a CosmosProvider

func (*CosmosProviderConfig) SignMode added in v2.3.0

func (pc *CosmosProviderConfig) SignMode() signing.SignMode

SignMode returns the SDK sign mode type reflective of the specified sign mode in the config file.

func (CosmosProviderConfig) Validate

func (pc CosmosProviderConfig) Validate() error

type FeeGrantConfiguration added in v2.4.0

type FeeGrantConfiguration struct {
	GranteesWanted int `json:"num_grantees" yaml:"num_grantees"`
	// Normally this is the default ChainClient key
	GranterKeyOrAddr string `json:"granter" yaml:"granter"`
	// Whether we control the granter private key (if not, someone else must authorize our feegrants)
	IsExternalGranter bool `json:"external_granter" yaml:"external_granter"`
	// List of keys (by name) that this FeeGranter manages
	ManagedGrantees []string `json:"grantees" yaml:"grantees"`
	// Last checked on chain (0 means grants never checked and may not exist)
	BlockHeightVerified int64 `json:"block_last_verified" yaml:"block_last_verified"`
	// Index of the last ManagedGrantee used as a TX signer
	GranteeLastSignerIndex int
}

By default, TXs will be signed by the feegrantees 'ManagedGrantees' keys in a round robin fashion. Clients can use other signing keys by invoking 'tx.SendMsgsWith' and specifying the signing key.

func (*FeeGrantConfiguration) AddGranteeKeys added in v2.4.0

func (fg *FeeGrantConfiguration) AddGranteeKeys(cc *CosmosProvider) error

type WalletState added in v2.4.0

type WalletState struct {
	NextAccountSequence uint64
	Mu                  sync.Mutex
}

Directories

Path Synopsis
keys

Jump to

Keyboard shortcuts

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