Documentation ¶
Overview ¶
Package cosmos provides an implementation of ibc.Chain backed by Cosmos-based blockchains.
Index ¶
- Constants
- Variables
- func BroadcastTx(ctx context.Context, broadcaster *Broadcaster, broadcastingUser User, ...) (sdk.TxResponse, error)
- func CondenseMoniker(m string) string
- func DefaultEncoding() simappparams.EncodingConfig
- func ModifyGenesis(genesisKV []GenesisKV) func(ibc.ChainConfig, []byte) ([]byte, error)
- func NewCosmosHeighlinerChainConfig(name string, binary string, bech32Prefix string, denom string, ...) ibc.ChainConfig
- func NewWallet(keyname string, address []byte, mnemonic string, chainCfg ibc.ChainConfig) ibc.Wallet
- func OsmosisCreatePool(c *CosmosChain, ctx context.Context, keyName string, params OsmosisPoolParams) (string, error)
- func OsmosisSwapExactAmountIn(c *CosmosChain, ctx context.Context, keyName string, coinIn string, ...) (string, error)
- func PollForBalance(ctx context.Context, chain *CosmosChain, deltaBlocks uint64, ...) error
- func PollForMessage[T any](ctx context.Context, chain *CosmosChain, registry codectypes.InterfaceRegistry, ...) (T, error)
- type Broadcaster
- func (b *Broadcaster) ConfigureClientContextOptions(opts ...ClientContextOpt)
- func (b *Broadcaster) ConfigureFactoryOptions(opts ...FactoryOpt)
- func (b *Broadcaster) GetClientContext(ctx context.Context, user User) (client.Context, error)
- func (b *Broadcaster) GetFactory(ctx context.Context, user User) (tx.Factory, error)
- func (b *Broadcaster) GetTxResponseBytes(ctx context.Context, user User) ([]byte, error)
- func (b *Broadcaster) UnmarshalTxResponseBytes(ctx context.Context, bytes []byte) (sdk.TxResponse, error)
- type ChainNode
- func (tn *ChainNode) AccountKeyBech32(ctx context.Context, name string) (string, error)
- func (tn *ChainNode) AddGenesisAccount(ctx context.Context, address string, genesisAmount []types.Coin) error
- func (tn *ChainNode) BinCommand(command ...string) []string
- func (tn *ChainNode) Bind() []string
- func (tn *ChainNode) CliContext() client.Context
- func (tn *ChainNode) CollectGentxs(ctx context.Context) error
- func (tn *ChainNode) ConsumerAdditionProposal(ctx context.Context, keyName string, ...) (string, error)
- func (tn *ChainNode) ContainerID() string
- func (tn *ChainNode) CopyFile(ctx context.Context, srcPath, dstPath string) error
- func (tn *ChainNode) CreateKey(ctx context.Context, name string) error
- func (tn *ChainNode) CreateNodeContainer(ctx context.Context) error
- func (tn *ChainNode) DumpContractState(ctx context.Context, contractAddress string, height int64) (*DumpContractStateResponse, error)
- func (tn *ChainNode) Exec(ctx context.Context, cmd []string, env []string) ([]byte, []byte, error)
- func (tn *ChainNode) ExecBin(ctx context.Context, command ...string) ([]byte, []byte, error)
- func (tn *ChainNode) ExecQuery(ctx context.Context, command ...string) ([]byte, []byte, error)
- func (tn *ChainNode) ExecTx(ctx context.Context, keyName string, command ...string) (string, error)
- func (tn *ChainNode) ExecuteContract(ctx context.Context, keyName string, contractAddress string, message string) (txHash string, err error)
- func (tn *ChainNode) ExportState(ctx context.Context, height int64) (string, error)
- func (tn *ChainNode) FindTxs(ctx context.Context, height uint64) ([]blockdb.Tx, error)
- func (tn *ChainNode) GenesisFileContent(ctx context.Context) ([]byte, error)
- func (tn *ChainNode) Gentx(ctx context.Context, name string, genesisSelfDelegation types.Coin) error
- func (tn *ChainNode) Height(ctx context.Context) (uint64, error)
- func (tn *ChainNode) HomeDir() string
- func (tn *ChainNode) HostName() string
- func (tn *ChainNode) InitFullNodeFiles(ctx context.Context) error
- func (tn *ChainNode) InitHomeFolder(ctx context.Context) error
- func (tn *ChainNode) InitValidatorGenTx(ctx context.Context, chainType *ibc.ChainConfig, genesisAmounts []types.Coin, ...) error
- func (tn *ChainNode) InstantiateContract(ctx context.Context, keyName string, codeID string, initMessage string, ...) (string, error)
- func (tn *ChainNode) KeyBech32(ctx context.Context, name string, bech string) (string, error)
- func (tn *ChainNode) Name() string
- func (tn *ChainNode) NewClient(addr string) error
- func (tn *ChainNode) NodeCommand(command ...string) []string
- func (tn *ChainNode) NodeID(ctx context.Context) (string, error)
- func (tn *ChainNode) OverwriteGenesisFile(ctx context.Context, content []byte) error
- func (tn *ChainNode) OverwritePrivValFile(ctx context.Context, content []byte) error
- func (tn *ChainNode) ParamChangeProposal(ctx context.Context, keyName string, prop *paramsutils.ParamChangeProposalJSON) (string, error)
- func (tn *ChainNode) PrivValFileContent(ctx context.Context) ([]byte, error)
- func (tn *ChainNode) QueryClientContractCode(ctx context.Context, codeHash string, response any) error
- func (tn *ChainNode) QueryCommand(command ...string) []string
- func (tn *ChainNode) QueryContract(ctx context.Context, contractAddress string, queryMsg any, response any) error
- func (tn *ChainNode) QueryICA(ctx context.Context, connectionID, address string) (string, error)
- func (tn *ChainNode) QueryParam(ctx context.Context, subspace, key string) (*ParamChange, error)
- func (tn *ChainNode) QueryProposal(ctx context.Context, proposalID string) (*ProposalResponse, error)
- func (tn *ChainNode) ReadFile(ctx context.Context, relPath string) ([]byte, error)
- func (tn *ChainNode) RecoverKey(ctx context.Context, keyName, mnemonic string) error
- func (tn *ChainNode) RegisterICA(ctx context.Context, keyName, connectionID string) (string, error)
- func (tn *ChainNode) RemoveContainer(ctx context.Context) error
- func (tn *ChainNode) SendFunds(ctx context.Context, keyName string, amount ibc.WalletAmount) error
- func (tn *ChainNode) SendIBCTransfer(ctx context.Context, channelID string, keyName string, amount ibc.WalletAmount, ...) (string, error)
- func (tn *ChainNode) SendICABankTransfer(ctx context.Context, connectionID, fromAddr string, amount ibc.WalletAmount) error
- func (tn *ChainNode) SetPeers(ctx context.Context, peers string) error
- func (tn *ChainNode) SetTestConfig(ctx context.Context) error
- func (tn *ChainNode) StartContainer(ctx context.Context) error
- func (tn *ChainNode) StopContainer(ctx context.Context) error
- func (tn *ChainNode) StoreClientContract(ctx context.Context, keyName string, fileName string) (string, error)
- func (tn *ChainNode) StoreContract(ctx context.Context, keyName string, fileName string) (string, error)
- func (tn *ChainNode) SubmitProposal(ctx context.Context, keyName string, prop TxProposalv1) (string, error)
- func (tn *ChainNode) TextProposal(ctx context.Context, keyName string, prop TextProposal) (string, error)
- func (tn *ChainNode) TxCommand(keyName string, command ...string) []string
- func (tn *ChainNode) UnsafeResetAll(ctx context.Context) error
- func (tn *ChainNode) UpgradeProposal(ctx context.Context, keyName string, prop SoftwareUpgradeProposal) (string, error)
- func (tn *ChainNode) VoteOnProposal(ctx context.Context, keyName string, proposalID string, vote string) error
- func (tn *ChainNode) WriteFile(ctx context.Context, content []byte, relPath string) error
- type ChainNodes
- type ClientContextOpt
- type CodeInfo
- type CodeInfosResponse
- type ContractStateModels
- type CosmosChain
- func (c *CosmosChain) Acknowledgements(ctx context.Context, height uint64) ([]ibc.PacketAcknowledgement, error)
- func (c *CosmosChain) AddFullNodes(ctx context.Context, configFileOverrides map[string]any, inc int) error
- func (c *CosmosChain) AllBalances(ctx context.Context, address string) (types.Coins, error)
- func (c *CosmosChain) BuildRelayerWallet(ctx context.Context, keyName string) (ibc.Wallet, error)
- func (c *CosmosChain) BuildWallet(ctx context.Context, keyName string, mnemonic string) (ibc.Wallet, error)
- func (c *CosmosChain) Config() ibc.ChainConfig
- func (c *CosmosChain) ConsumerAdditionProposal(ctx context.Context, keyName string, ...) (tx TxProposal, _ error)
- func (c *CosmosChain) CreateKey(ctx context.Context, keyName string) error
- func (c *CosmosChain) DumpContractState(ctx context.Context, contractAddress string, height int64) (*DumpContractStateResponse, error)
- func (c *CosmosChain) Exec(ctx context.Context, cmd []string, env []string) (stdout, stderr []byte, err error)
- func (c *CosmosChain) ExecuteContract(ctx context.Context, keyName string, contractAddress string, message string) (txHash string, err error)
- func (c *CosmosChain) ExportState(ctx context.Context, height int64) (string, error)
- func (c *CosmosChain) FindTxs(ctx context.Context, height uint64) ([]blockdb.Tx, error)
- func (c *CosmosChain) GetAddress(ctx context.Context, keyName string) ([]byte, error)
- func (c *CosmosChain) GetBalance(ctx context.Context, address string, denom string) (int64, error)
- func (c *CosmosChain) GetGRPCAddress() string
- func (c *CosmosChain) GetGasFeesInNativeDenom(gasPaid int64) int64
- func (c *CosmosChain) GetHostGRPCAddress() string
- func (c *CosmosChain) GetHostRPCAddress() string
- func (c *CosmosChain) GetRPCAddress() string
- func (c *CosmosChain) Height(ctx context.Context) (uint64, error)
- func (c *CosmosChain) HomeDir() string
- func (c *CosmosChain) Initialize(ctx context.Context, testName string, cli *client.Client, networkID string) error
- func (c *CosmosChain) InstantiateContract(ctx context.Context, keyName string, codeID string, initMessage string, ...) (string, error)
- func (c *CosmosChain) NewChainNode(ctx context.Context, testName string, cli *client.Client, networkID string, ...) (*ChainNode, error)
- func (c *CosmosChain) Nodes() ChainNodes
- func (c *CosmosChain) ParamChangeProposal(ctx context.Context, keyName string, prop *paramsutils.ParamChangeProposalJSON) (tx TxProposal, _ error)
- func (c *CosmosChain) QueryClientContractCode(ctx context.Context, codeHash string, response any) error
- func (c *CosmosChain) QueryContract(ctx context.Context, contractAddress string, query any, response any) error
- func (c *CosmosChain) QueryParam(ctx context.Context, subspace, key string) (*ParamChange, error)
- func (c *CosmosChain) QueryProposal(ctx context.Context, proposalID string) (*ProposalResponse, error)
- func (c *CosmosChain) RecoverKey(ctx context.Context, keyName, mnemonic string) error
- func (c *CosmosChain) SendFunds(ctx context.Context, keyName string, amount ibc.WalletAmount) error
- func (c *CosmosChain) SendIBCTransfer(ctx context.Context, channelID string, keyName string, amount ibc.WalletAmount, ...) (tx ibc.Tx, _ error)
- func (c *CosmosChain) Start(testName string, ctx context.Context, ...) error
- func (c *CosmosChain) StartAllNodes(ctx context.Context) error
- func (c *CosmosChain) StartConsumer(testName string, ctx context.Context, ...) error
- func (c *CosmosChain) StartProvider(testName string, ctx context.Context, ...) error
- func (c *CosmosChain) StopAllNodes(ctx context.Context) error
- func (c *CosmosChain) StoreClientContract(ctx context.Context, keyName string, fileName string) (string, error)
- func (c *CosmosChain) StoreContract(ctx context.Context, keyName string, fileName string) (string, error)
- func (c *CosmosChain) TextProposal(ctx context.Context, keyName string, prop TextProposal) (tx TxProposal, _ error)
- func (c *CosmosChain) Timeouts(ctx context.Context, height uint64) ([]ibc.PacketTimeout, error)
- func (c *CosmosChain) UpgradeProposal(ctx context.Context, keyName string, prop SoftwareUpgradeProposal) (tx TxProposal, _ error)
- func (c *CosmosChain) UpgradeVersion(ctx context.Context, cli *client.Client, containerRepo, version string)
- func (c *CosmosChain) VoteOnProposalAllValidators(ctx context.Context, proposalID string, vote string) error
- type CosmosTx
- type CosmosWallet
- type DumpContractStateResponse
- type FactoryOpt
- type GenesisFile
- type GenesisKV
- type GenesisValidatorPubKey
- type GenesisValidators
- type InstantiateContractAttribute
- type InstantiateContractEvent
- type InstantiateContractLog
- type InstantiateContractResponse
- type OsmosisPoolParams
- type ParamChange
- type PrivValidatorKey
- type PrivValidatorKeyFile
- type ProposalContent
- type ProposalDeposit
- type ProposalFinalTallyResult
- type ProposalResponse
- type QueryContractResponse
- type SoftwareUpgradeProposal
- type TextProposal
- type TxProposal
- type TxProposalv1
- type User
- type ValidatorWithIntPower
Constants ¶
const ( ProposalVoteYes = "yes" ProposalVoteNo = "no" ProposalVoteNoWithVeto = "noWithVeto" ProposalVoteAbstain = "abstain" ProposalStatusUnspecified = "PROPOSAL_STATUS_UNSPECIFIED" ProposalStatusPassed = "PROPOSAL_STATUS_PASSED" ProposalStatusFailed = "PROPOSAL_STATUS_FAILED" ProposalStatusRejected = "PROPOSAL_STATUS_REJECTED" ProposalStatusVotingPeriod = "PROPOSAL_STATUS_VOTING_PERIOD" ProposalStatusDepositPeriod = "PROPOSAL_STATUS_DEPOSIT_PERIOD" )
Variables ¶
var (
DefaultProviderUnbondingPeriod = 504 * time.Hour
)
Functions ¶
func BroadcastTx ¶
func BroadcastTx(ctx context.Context, broadcaster *Broadcaster, broadcastingUser User, msgs ...sdk.Msg) (sdk.TxResponse, error)
BroadcastTx uses the provided Broadcaster to broadcast all the provided messages which will be signed by the User provided. The sdk.TxResponse and an error are returned.
func CondenseMoniker ¶
CondenseMoniker fits a moniker into the cosmos character limit for monikers. If the moniker already fits, it is returned unmodified. Otherwise, the middle is truncated, and a hash is appended to the end in case the only unique data was in the middle.
func DefaultEncoding ¶
func DefaultEncoding() simappparams.EncodingConfig
func ModifyGenesis ¶
func OsmosisCreatePool ¶
func OsmosisCreatePool(c *CosmosChain, ctx context.Context, keyName string, params OsmosisPoolParams) (string, error)
func PollForBalance ¶
func PollForBalance(ctx context.Context, chain *CosmosChain, deltaBlocks uint64, balance ibc.WalletAmount) error
PollForBalance polls until the balance matches
func PollForMessage ¶
func PollForMessage[T any](ctx context.Context, chain *CosmosChain, registry codectypes.InterfaceRegistry, startHeight, maxHeight uint64, fn func(found T) bool) (T, error)
PollForMessage searches every transaction for a message. Must pass a coded registry capable of decoding the cosmos transaction. fn is optional. Return true from the fn to stop polling and return the found message. If fn is nil, returns the first message to match type T.
Types ¶
type Broadcaster ¶
type Broadcaster struct {
// contains filtered or unexported fields
}
func NewBroadcaster ¶
func NewBroadcaster(t *testing.T, chain *CosmosChain) *Broadcaster
NewBroadcaster returns a instance of Broadcaster which can be used with broadcast.Tx to broadcast messages sdk messages.
func (*Broadcaster) ConfigureClientContextOptions ¶
func (b *Broadcaster) ConfigureClientContextOptions(opts ...ClientContextOpt)
ConfigureClientContextOptions ensure the given configuration functions are run when calling GetClientContext after all default options have been applied.
func (*Broadcaster) ConfigureFactoryOptions ¶
func (b *Broadcaster) ConfigureFactoryOptions(opts ...FactoryOpt)
ConfigureFactoryOptions ensure the given configuration functions are run when calling GetFactory after all default options have been applied.
func (*Broadcaster) GetClientContext ¶
GetClientContext returns a client context that is configured with this Broadcaster's CosmosChain and the provided user. ConfigureClientContextOptions can be used to configure arbitrary options to configure the returned client.Context.
func (*Broadcaster) GetFactory ¶
GetFactory returns an instance of tx.Factory that is configured with this Broadcaster's CosmosChain and the provided user. ConfigureFactoryOptions can be used to specify arbitrary options to configure the returned factory.
func (*Broadcaster) GetTxResponseBytes ¶
GetTxResponseBytes returns the sdk.TxResponse bytes which returned from broadcast.Tx.
func (*Broadcaster) UnmarshalTxResponseBytes ¶
func (b *Broadcaster) UnmarshalTxResponseBytes(ctx context.Context, bytes []byte) (sdk.TxResponse, error)
UnmarshalTxResponseBytes accepts the sdk.TxResponse bytes and unmarshalls them into an instance of sdk.TxResponse.
type ChainNode ¶
type ChainNode struct { VolumeName string Index int Chain ibc.Chain Validator bool NetworkID string DockerClient *dockerclient.Client Client rpcclient.Client TestName string Image ibc.DockerImage // contains filtered or unexported fields }
ChainNode represents a node in the test network that is being created
func NewChainNode ¶
func NewChainNode(log *zap.Logger, validator bool, chain *CosmosChain, dockerClient *dockerclient.Client, networkID string, testName string, image ibc.DockerImage, index int) *ChainNode
func (*ChainNode) AccountKeyBech32 ¶
AccountKeyBech32 retrieves the named key's address in bech32 account format.
func (*ChainNode) AddGenesisAccount ¶
func (tn *ChainNode) AddGenesisAccount(ctx context.Context, address string, genesisAmount []types.Coin) error
AddGenesisAccount adds a genesis account for each key
func (*ChainNode) BinCommand ¶
BinCommand is a helper to retrieve a full command for a chain node binary. For example, if chain node binary is `gaiad`, and desired command is `gaiad keys show key1`, pass ("keys", "show", "key1") for command to return the full command. Will include additional flags for home directory and chain ID.
func (*ChainNode) CliContext ¶
CliContext creates a new Cosmos SDK client context
func (*ChainNode) CollectGentxs ¶
CollectGentxs runs collect gentxs on the node's home folders
func (*ChainNode) ConsumerAdditionProposal ¶
func (*ChainNode) ContainerID ¶
func (*ChainNode) CopyFile ¶
CopyFile adds a file from the host filesystem to the docker filesystem relPath describes the location of the file in the docker volume relative to the home directory
func (*ChainNode) CreateKey ¶
CreateKey creates a key in the keyring backend test for the given node
func (*ChainNode) CreateNodeContainer ¶
func (*ChainNode) DumpContractState ¶
func (tn *ChainNode) DumpContractState(ctx context.Context, contractAddress string, height int64) (*DumpContractStateResponse, error)
DumpContractState dumps the state of a contract at a block height.
func (*ChainNode) ExecBin ¶
ExecBin is a helper to execute a command for a chain node binary. For example, if chain node binary is `gaiad`, and desired command is `gaiad keys show key1`, pass ("keys", "show", "key1") for command to execute the command against the node. Will include additional flags for home directory and chain ID.
func (*ChainNode) ExecQuery ¶
ExecQuery is a helper to execute a query command. For example, if chain node binary is gaiad, and desired command is `gaiad query gov params`, pass ("gov", "params") for command to execute the query against the node. Returns response in json format.
func (*ChainNode) ExecTx ¶
ExecTx executes a transaction, waits for 2 blocks if successful, then returns the tx hash.
func (*ChainNode) ExecuteContract ¶
func (tn *ChainNode) ExecuteContract(ctx context.Context, keyName string, contractAddress string, message string) (txHash string, err error)
ExecuteContract executes a contract transaction with a message using it's address.
func (*ChainNode) ExportState ¶
func (*ChainNode) GenesisFileContent ¶
func (*ChainNode) Gentx ¶
func (tn *ChainNode) Gentx(ctx context.Context, name string, genesisSelfDelegation types.Coin) error
Gentx generates the gentx for a given node
func (*ChainNode) InitFullNodeFiles ¶
func (*ChainNode) InitHomeFolder ¶
InitHomeFolder initializes a home folder for the given node
func (*ChainNode) InitValidatorGenTx ¶
func (tn *ChainNode) InitValidatorGenTx( ctx context.Context, chainType *ibc.ChainConfig, genesisAmounts []types.Coin, genesisSelfDelegation types.Coin, ) error
InitValidatorFiles creates the node files and signs a genesis transaction
func (*ChainNode) InstantiateContract ¶
func (tn *ChainNode) InstantiateContract(ctx context.Context, keyName string, codeID string, initMessage string, needsNoAdminFlag bool, extraExecTxArgs ...string) (string, error)
InstantiateContract takes a code id for a smart contract and initialization message and returns the instantiated contract address.
func (*ChainNode) KeyBech32 ¶
KeyBech32 retrieves the named key's address in bech32 format from the node. bech is the bech32 prefix (acc|val|cons). If empty, defaults to the account key (same as "acc").
func (*ChainNode) NewClient ¶
NewClient creates and assigns a new Tendermint RPC client to the ChainNode
func (*ChainNode) NodeCommand ¶
NodeCommand is a helper to retrieve a full command for a chain node binary. when interactions with the RPC endpoint are necessary. For example, if chain node binary is `gaiad`, and desired command is `gaiad keys show key1`, pass ("keys", "show", "key1") for command to return the full command. Will include additional flags for node URL, home directory, and chain ID.
func (*ChainNode) OverwriteGenesisFile ¶
func (*ChainNode) OverwritePrivValFile ¶
func (*ChainNode) ParamChangeProposal ¶
func (tn *ChainNode) ParamChangeProposal(ctx context.Context, keyName string, prop *paramsutils.ParamChangeProposalJSON) (string, error)
ParamChangeProposal submits a param change proposal to the chain, signed by keyName.
func (*ChainNode) PrivValFileContent ¶
func (*ChainNode) QueryClientContractCode ¶
func (tn *ChainNode) QueryClientContractCode(ctx context.Context, codeHash string, response any) error
QueryClientContractCode performs a query with the contract codeHash as the input and code as the output
func (*ChainNode) QueryCommand ¶
QueryCommand is a helper to retrieve the full query command. For example, if chain node binary is gaiad, and desired command is `gaiad query gov params`, pass ("gov", "params") for command to return the full command with all necessary flags to query the specific node.
func (*ChainNode) QueryContract ¶
func (tn *ChainNode) QueryContract(ctx context.Context, contractAddress string, queryMsg any, response any) error
QueryContract performs a smart query, taking in a query struct and returning a error with the response struct populated.
func (*ChainNode) QueryICA ¶
QueryICA will query for an interchain account controlled by the specified address on the counterparty chain.
func (*ChainNode) QueryParam ¶
QueryParam returns the state and details of a subspace param.
func (*ChainNode) QueryProposal ¶
func (tn *ChainNode) QueryProposal(ctx context.Context, proposalID string) (*ProposalResponse, error)
QueryProposal returns the state and details of a governance proposal.
func (*ChainNode) ReadFile ¶
ReadFile reads the contents of a single file at the specified path in the docker filesystem. relPath describes the location of the file in the docker volume relative to the home directory.
func (*ChainNode) RecoverKey ¶
RecoverKey restores a key from a given mnemonic.
func (*ChainNode) RegisterICA ¶
RegisterICA will attempt to register an interchain account on the counterparty chain.
func (*ChainNode) SendIBCTransfer ¶
func (*ChainNode) SendICABankTransfer ¶
func (tn *ChainNode) SendICABankTransfer(ctx context.Context, connectionID, fromAddr string, amount ibc.WalletAmount) error
SendICABankTransfer builds a bank transfer message for a specified address and sends it to the specified interchain account.
func (*ChainNode) SetTestConfig ¶
SetTestConfig modifies the config to reasonable values for use within interchaintest.
func (*ChainNode) StoreClientContract ¶
func (tn *ChainNode) StoreClientContract(ctx context.Context, keyName string, fileName string) (string, error)
StoreClientContract takes a file path to a client smart contract and stores it on-chain. Returns the contracts code id.
func (*ChainNode) StoreContract ¶
func (tn *ChainNode) StoreContract(ctx context.Context, keyName string, fileName string) (string, error)
StoreContract takes a file path to smart contract and stores it on-chain. Returns the contracts code id.
func (*ChainNode) SubmitProposal ¶
func (tn *ChainNode) SubmitProposal(ctx context.Context, keyName string, prop TxProposalv1) (string, error)
SubmitProposal submits a gov v1 proposal to the chain.
func (*ChainNode) TextProposal ¶
func (tn *ChainNode) TextProposal(ctx context.Context, keyName string, prop TextProposal) (string, error)
TextProposal submits a text governance proposal to the chain.
func (*ChainNode) TxCommand ¶
TxCommand is a helper to retrieve a full command for broadcasting a tx with the chain node binary.
func (*ChainNode) UpgradeProposal ¶
func (tn *ChainNode) UpgradeProposal(ctx context.Context, keyName string, prop SoftwareUpgradeProposal) (string, error)
UpgradeProposal submits a software-upgrade governance proposal to the chain.
func (*ChainNode) VoteOnProposal ¶
func (tn *ChainNode) VoteOnProposal(ctx context.Context, keyName string, proposalID string, vote string) error
VoteOnProposal submits a vote for the specified proposal.
type ChainNodes ¶
type ChainNodes []*ChainNode
ChainNodes is a collection of ChainNode
func (ChainNodes) LogGenesisHashes ¶
func (nodes ChainNodes) LogGenesisHashes(ctx context.Context) error
LogGenesisHashes logs the genesis hashes for the various nodes
func (ChainNodes) PeerString ¶
func (nodes ChainNodes) PeerString(ctx context.Context) string
PeerString returns the string for connecting the nodes passed in
type CodeInfosResponse ¶
type CodeInfosResponse struct {
CodeInfos []CodeInfo `json:"code_infos"`
}
type ContractStateModels ¶
type CosmosChain ¶
type CosmosChain struct { NumValidators int NumFullNodes int Validators ChainNodes FullNodes ChainNodes Provider *CosmosChain Consumers []*CosmosChain // contains filtered or unexported fields }
CosmosChain is a local docker testnet for a Cosmos SDK chain. Implements the ibc.Chain interface.
func NewCosmosChain ¶
func NewCosmosChain(testName string, chainConfig ibc.ChainConfig, numValidators int, numFullNodes int, log *zap.Logger) *CosmosChain
func (*CosmosChain) Acknowledgements ¶
func (c *CosmosChain) Acknowledgements(ctx context.Context, height uint64) ([]ibc.PacketAcknowledgement, error)
Acknowledgements implements ibc.Chain, returning all acknowledgments in block at height
func (*CosmosChain) AddFullNodes ¶
func (c *CosmosChain) AddFullNodes(ctx context.Context, configFileOverrides map[string]any, inc int) error
AddFullNodes adds new fullnodes to the network, peering with the existing nodes.
func (*CosmosChain) AllBalances ¶
AllBalances fetches an account address's balance for all denoms it holds
func (*CosmosChain) BuildRelayerWallet ¶
BuildRelayerWallet will return a Cosmos wallet populated with the mnemonic so that the wallet can be restored in the relayer node using the mnemonic. After it is built, that address is included in genesis with some funds.
func (*CosmosChain) BuildWallet ¶
func (c *CosmosChain) BuildWallet(ctx context.Context, keyName string, mnemonic string) (ibc.Wallet, error)
BuildWallet will return a Cosmos wallet If mnemonic != "", it will restore using that mnemonic If mnemonic == "", it will create a new key
func (*CosmosChain) Config ¶
func (c *CosmosChain) Config() ibc.ChainConfig
Implements Chain interface
func (*CosmosChain) ConsumerAdditionProposal ¶
func (c *CosmosChain) ConsumerAdditionProposal(ctx context.Context, keyName string, prop ccvclient.ConsumerAdditionProposalJSON) (tx TxProposal, _ error)
TextProposal submits a text governance proposal to the chain.
func (*CosmosChain) CreateKey ¶
func (c *CosmosChain) CreateKey(ctx context.Context, keyName string) error
Implements Chain interface
func (*CosmosChain) DumpContractState ¶
func (c *CosmosChain) DumpContractState(ctx context.Context, contractAddress string, height int64) (*DumpContractStateResponse, error)
DumpContractState dumps the state of a contract at a block height.
func (*CosmosChain) Exec ¶
func (c *CosmosChain) Exec(ctx context.Context, cmd []string, env []string) (stdout, stderr []byte, err error)
Exec implements ibc.Chain.
func (*CosmosChain) ExecuteContract ¶
func (c *CosmosChain) ExecuteContract(ctx context.Context, keyName string, contractAddress string, message string) (txHash string, err error)
ExecuteContract executes a contract transaction with a message using it's address.
func (*CosmosChain) ExportState ¶
ExportState exports the chain state at specific height. Implements Chain interface
func (*CosmosChain) GetAddress ¶
Implements Chain interface
func (*CosmosChain) GetBalance ¶
GetBalance fetches the current balance for a specific account address and denom. Implements Chain interface
func (*CosmosChain) GetGRPCAddress ¶
func (c *CosmosChain) GetGRPCAddress() string
Implements Chain interface
func (*CosmosChain) GetGasFeesInNativeDenom ¶
func (c *CosmosChain) GetGasFeesInNativeDenom(gasPaid int64) int64
func (*CosmosChain) GetHostGRPCAddress ¶
func (c *CosmosChain) GetHostGRPCAddress() string
GetHostGRPCAddress returns the address of the gRPC server accessible by the host. This will not return a valid address until the chain has been started.
func (*CosmosChain) GetHostRPCAddress ¶
func (c *CosmosChain) GetHostRPCAddress() string
GetHostRPCAddress returns the address of the RPC server accessible by the host. This will not return a valid address until the chain has been started.
func (*CosmosChain) GetRPCAddress ¶
func (c *CosmosChain) GetRPCAddress() string
Implements Chain interface
func (*CosmosChain) Height ¶
func (c *CosmosChain) Height(ctx context.Context) (uint64, error)
Height implements ibc.Chain
func (*CosmosChain) Initialize ¶
func (c *CosmosChain) Initialize(ctx context.Context, testName string, cli *client.Client, networkID string) error
Implements Chain interface
func (*CosmosChain) InstantiateContract ¶
func (c *CosmosChain) InstantiateContract(ctx context.Context, keyName string, codeID string, initMessage string, needsNoAdminFlag bool, extraExecTxArgs ...string) (string, error)
InstantiateContract takes a code id for a smart contract and initialization message and returns the instantiated contract address.
func (*CosmosChain) NewChainNode ¶
func (c *CosmosChain) NewChainNode( ctx context.Context, testName string, cli *client.Client, networkID string, image ibc.DockerImage, validator bool, index int, ) (*ChainNode, error)
NewChainNode constructs a new cosmos chain node with a docker volume.
func (*CosmosChain) Nodes ¶
func (c *CosmosChain) Nodes() ChainNodes
Nodes returns all nodes, including validators and fullnodes.
func (*CosmosChain) ParamChangeProposal ¶
func (c *CosmosChain) ParamChangeProposal(ctx context.Context, keyName string, prop *paramsutils.ParamChangeProposalJSON) (tx TxProposal, _ error)
ParamChangeProposal submits a param change proposal to the chain, signed by keyName.
func (*CosmosChain) QueryClientContractCode ¶
func (c *CosmosChain) QueryClientContractCode(ctx context.Context, codeHash string, response any) error
QueryClientContractCode performs a query with the contract codeHash as the input and code as the output
func (*CosmosChain) QueryContract ¶
func (c *CosmosChain) QueryContract(ctx context.Context, contractAddress string, query any, response any) error
QueryContract performs a smart query, taking in a query struct and returning a error with the response struct populated.
func (*CosmosChain) QueryParam ¶
func (c *CosmosChain) QueryParam(ctx context.Context, subspace, key string) (*ParamChange, error)
QueryParam returns the param state of a given key.
func (*CosmosChain) QueryProposal ¶
func (c *CosmosChain) QueryProposal(ctx context.Context, proposalID string) (*ProposalResponse, error)
QueryProposal returns the state and details of a governance proposal.
func (*CosmosChain) RecoverKey ¶
func (c *CosmosChain) RecoverKey(ctx context.Context, keyName, mnemonic string) error
Implements Chain interface
func (*CosmosChain) SendFunds ¶
func (c *CosmosChain) SendFunds(ctx context.Context, keyName string, amount ibc.WalletAmount) error
Implements Chain interface
func (*CosmosChain) SendIBCTransfer ¶
func (c *CosmosChain) SendIBCTransfer( ctx context.Context, channelID string, keyName string, amount ibc.WalletAmount, options ibc.TransferOptions, ) (tx ibc.Tx, _ error)
Implements Chain interface
func (*CosmosChain) Start ¶
func (c *CosmosChain) Start(testName string, ctx context.Context, additionalGenesisWallets ...ibc.WalletAmount) error
Bootstraps the chain and starts it from genesis
func (*CosmosChain) StartAllNodes ¶
func (c *CosmosChain) StartAllNodes(ctx context.Context) error
StartAllNodes creates and starts new containers for each node. Should only be used if the chain has previously been started with .Start.
func (*CosmosChain) StartConsumer ¶
func (c *CosmosChain) StartConsumer(testName string, ctx context.Context, additionalGenesisWallets ...ibc.WalletAmount) error
Bootstraps the consumer chain and starts it from genesis
func (*CosmosChain) StartProvider ¶
func (c *CosmosChain) StartProvider(testName string, ctx context.Context, additionalGenesisWallets ...ibc.WalletAmount) error
Bootstraps the provider chain and starts it from genesis It also alters genesis file: voting_params, deposit_params, and min_deposit in the gov module
func (*CosmosChain) StopAllNodes ¶
func (c *CosmosChain) StopAllNodes(ctx context.Context) error
StopAllNodes stops and removes all long running containers (validators and full nodes)
func (*CosmosChain) StoreClientContract ¶
func (c *CosmosChain) StoreClientContract(ctx context.Context, keyName string, fileName string) (string, error)
StoreClientContract takes a file path to a client smart contract and stores it on-chain. Returns the contracts code id.
func (*CosmosChain) StoreContract ¶
func (c *CosmosChain) StoreContract(ctx context.Context, keyName string, fileName string) (string, error)
StoreContract takes a file path to smart contract and stores it on-chain. Returns the contracts code id.
func (*CosmosChain) TextProposal ¶
func (c *CosmosChain) TextProposal(ctx context.Context, keyName string, prop TextProposal) (tx TxProposal, _ error)
TextProposal submits a text governance proposal to the chain.
func (*CosmosChain) Timeouts ¶
func (c *CosmosChain) Timeouts(ctx context.Context, height uint64) ([]ibc.PacketTimeout, error)
Timeouts implements ibc.Chain, returning all timeouts in block at height
func (*CosmosChain) UpgradeProposal ¶
func (c *CosmosChain) UpgradeProposal(ctx context.Context, keyName string, prop SoftwareUpgradeProposal) (tx TxProposal, _ error)
UpgradeProposal submits a software-upgrade governance proposal to the chain.
func (*CosmosChain) UpgradeVersion ¶
func (*CosmosChain) VoteOnProposalAllValidators ¶
type CosmosWallet ¶
type CosmosWallet struct {
// contains filtered or unexported fields
}
func (*CosmosWallet) Address ¶
func (w *CosmosWallet) Address() []byte
Get Address with chain's prefix
func (*CosmosWallet) FormattedAddress ¶
func (w *CosmosWallet) FormattedAddress() string
Get formatted address, passing in a prefix
func (*CosmosWallet) FormattedAddressWithPrefix ¶
func (w *CosmosWallet) FormattedAddressWithPrefix(prefix string) string
func (*CosmosWallet) KeyName ¶
func (w *CosmosWallet) KeyName() string
func (*CosmosWallet) Mnemonic ¶
func (w *CosmosWallet) Mnemonic() string
Get mnemonic, only used for relayer wallets
type DumpContractStateResponse ¶
type DumpContractStateResponse struct {
Models []ContractStateModels `json:"models"`
}
type GenesisFile ¶
type GenesisFile struct {
Validators []GenesisValidators `json:"validators"`
}
type GenesisValidatorPubKey ¶
type GenesisValidators ¶
type GenesisValidators struct { Address string `json:"address"` Name string `json:"name"` Power string `json:"power"` PubKey GenesisValidatorPubKey `json:"pub_key"` }
type InstantiateContractAttribute ¶
type InstantiateContractAttribute struct {
Value string `json:"value"`
}
type InstantiateContractEvent ¶
type InstantiateContractEvent struct {
Attributes []InstantiateContractAttribute `json:"attributes"`
}
type InstantiateContractLog ¶
type InstantiateContractLog struct {
Events []InstantiateContractEvent `json:"event"`
}
type InstantiateContractResponse ¶
type InstantiateContractResponse struct {
Logs []InstantiateContractLog `json:"log"`
}
type OsmosisPoolParams ¶
type OsmosisPoolParams struct { Weights string `json:"weights"` InitialDeposit string `json:"initial-deposit"` SwapFee string `json:"swap-fee"` ExitFee string `json:"exit-fee"` FutureGovernor string `json:"future-governor"` }
OsmosisPoolParams defines parameters for creating an osmosis gamm liquidity pool
type ParamChange ¶
type PrivValidatorKey ¶
type PrivValidatorKeyFile ¶
type PrivValidatorKeyFile struct { Address string `json:"address"` PubKey PrivValidatorKey `json:"pub_key"` PrivKey PrivValidatorKey `json:"priv_key"` }
type ProposalContent ¶
type ProposalDeposit ¶
type ProposalResponse ¶
type ProposalResponse struct { ProposalID string `json:"proposal_id"` Content ProposalContent `json:"content"` Status string `json:"status"` FinalTallyResult ProposalFinalTallyResult `json:"final_tally_result"` SubmitTime string `json:"submit_time"` DepositEndTime string `json:"deposit_end_time"` TotalDeposit []ProposalDeposit `json:"total_deposit"` VotingStartTime string `json:"voting_start_time"` VotingEndTime string `json:"voting_end_time"` }
ProposalResponse is the proposal query response.
func PollForProposalStatus ¶
func PollForProposalStatus(ctx context.Context, chain *CosmosChain, startHeight, maxHeight uint64, proposalID string, status string) (ProposalResponse, error)
PollForProposalStatus attempts to find a proposal with matching ID and status.
type QueryContractResponse ¶
type QueryContractResponse struct {
Contracts []string `json:"contracts"`
}
type SoftwareUpgradeProposal ¶
type SoftwareUpgradeProposal struct { Deposit string Title string Name string Description string Height uint64 Info string // optional }
SoftwareUpgradeProposal defines the required and optional parameters for submitting a software-upgrade proposal.
type TextProposal ¶
SoftwareUpgradeProposal defines the required and optional parameters for submitting a software-upgrade proposal.
type TxProposal ¶
type TxProposal struct { // The block height. Height uint64 // The transaction hash. TxHash string // Amount of gas charged to the account. GasSpent int64 // Amount deposited for proposal. DepositAmount string // ID of proposal. ProposalID string // Type of proposal. ProposalType string }
TxProposal contains chain proposal transaction details.
type TxProposalv1 ¶
type TxProposalv1 struct { Messages []json.RawMessage `json:"messages"` Metadata string `json:"metadata"` Deposit string `json:"deposit"` Title string `json:"title"` Summary string `json:"summary"` }
TxProposalv1 contains chain proposal transaction detail for gov module v1 (sdk v0.46.0+)