cosmos

package
v0.0.0-...-267a06d Latest Latest
Warning

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

Go to latest
Published: Feb 13, 2025 License: Apache-2.0 Imports: 26 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewCosmosRemotenet

func NewCosmosRemotenet(testName string, log *zap.Logger, chainConfig chains.ChainConfig, client *dockerClient.Client, network string, testconfig *testconfig.Chain) (chains.Chain, error)

func RlpEncodeRequest

func RlpEncodeRequest(request CallServiceMessageRequest, callType CallServiceMessageType) ([]byte, error)

Types

type CSMessageResponseType

type CSMessageResponseType int64
const (
	SUCCESS   CSMessageResponseType = 0
	FAILURE   CSMessageResponseType = -1
	IBC_ERROR CSMessageResponseType = -2
)

type CallServiceMessage

type CallServiceMessage struct {
	MessageType CallServiceMessageType
	Payload     []byte
}

func RlpDecode

func RlpDecode(raw_data []byte) (CallServiceMessage, error)

type CallServiceMessageRequest

type CallServiceMessageRequest struct {
	From       string `json:"from"`
	To         string `json:"to"`
	SequenceNo uint64 `json:"sequence_no"`
	Rollback   bool   `json:"rollback"`
	Data       []byte `json:"data"`
}

func (*CallServiceMessageRequest) RlpEncode

func (cr *CallServiceMessageRequest) RlpEncode() ([]byte, error)

type CallServiceMessageResponse

type CallServiceMessageResponse struct {
	SequenceNo uint64
	Code       CSMessageResponseType
	Msg        string
}

func (*CallServiceMessageResponse) RlpEncode

func (csr *CallServiceMessageResponse) RlpEncode() ([]byte, error)

type CallServiceMessageType

type CallServiceMessageType int64
const (
	CallServiceRequest  CallServiceMessageType = 0
	CallServiceResponse CallServiceMessageType = 1
)

type CodeInfo

type CodeInfo struct {
	CodeID string `json:"code_id"`
}

type CodeInfosResponse

type CodeInfosResponse struct {
	CodeInfos []CodeInfo `json:"code_infos"`
}

type CosmosRemotenet

type CosmosRemotenet struct {
	IBCAddresses map[string]string     `json:"addresses"`
	Wallets      map[string]ibc.Wallet `json:"wallets"`

	DockerClient *client.Client
	Network      string

	GrpcConn  *grpc.ClientConn
	Rpcclient *rpchttp.HTTP
	// contains filtered or unexported fields
}

func (*CosmosRemotenet) BinCommand

func (c *CosmosRemotenet) BinCommand(command ...string) []string

func (*CosmosRemotenet) Config

func (c *CosmosRemotenet) Config() chains.ChainConfig

func (*CosmosRemotenet) DeployXCallMockApp

func (c *CosmosRemotenet) DeployXCallMockApp(ctx context.Context, keyname string, connections []chains.XCallConnection) error

func (*CosmosRemotenet) Exec

func (an *CosmosRemotenet) Exec(ctx context.Context, cmd []string, env []string) (stdout []byte, stderr []byte, err error)

func (*CosmosRemotenet) ExecBin

func (c *CosmosRemotenet) ExecBin(ctx context.Context, command ...string) ([]byte, []byte, error)

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 (*CosmosRemotenet) ExecQuery

func (c *CosmosRemotenet) ExecQuery(ctx context.Context, command ...string) ([]byte, []byte, error)

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 (*CosmosRemotenet) ExecTx

func (c *CosmosRemotenet) ExecTx(ctx context.Context, command ...string) (string, error)

func (*CosmosRemotenet) ExecuteContractRemote

func (c *CosmosRemotenet) ExecuteContractRemote(ctx context.Context, contractAddress string, methodName, message string, extraExecTxArgs ...string) (res *TxResul, err error)

ExecuteContract executes a contract transaction with a message using it's address.

func (*CosmosRemotenet) FindCallMessage

func (c *CosmosRemotenet) FindCallMessage(ctx context.Context, startHeight uint64, from, to, sn string) (string, string, error)

func (*CosmosRemotenet) FindCallResponse

func (c *CosmosRemotenet) FindCallResponse(ctx context.Context, startHeight uint64, sn string) (string, error)

func (*CosmosRemotenet) FindEvent

func (c *CosmosRemotenet) FindEvent(ctx context.Context, startHeight uint64, contract, index string) (*ctypes.ResultEvent, error)

func (*CosmosRemotenet) FindRollbackExecutedMessage

func (c *CosmosRemotenet) FindRollbackExecutedMessage(ctx context.Context, startHeight uint64, sn string) (string, error)

func (*CosmosRemotenet) FindTargetXCallMessage

func (c *CosmosRemotenet) FindTargetXCallMessage(ctx context.Context, target chains.Chain, height uint64, to string) (*chains.XCallResponse, error)

FindTargetXCallMessage returns the request id and the data of the message sent to the target chain

func (*CosmosRemotenet) GetAPIAddress

func (c *CosmosRemotenet) GetAPIAddress() string

Implements Chain interface

func (*CosmosRemotenet) GetCommonArgs

func (c *CosmosRemotenet) GetCommonArgs() []string

func (*CosmosRemotenet) GetContractAddress

func (c *CosmosRemotenet) GetContractAddress(key string) string

func (*CosmosRemotenet) GetGRPCAddress

func (c *CosmosRemotenet) GetGRPCAddress() string

Implements Chain interface

func (*CosmosRemotenet) GetHostRPCAddress

func (c *CosmosRemotenet) 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 (*CosmosRemotenet) GetIBCAddress

func (c *CosmosRemotenet) GetIBCAddress(key string) string

func (*CosmosRemotenet) GetRPCAddress

func (c *CosmosRemotenet) GetRPCAddress() string

func (*CosmosRemotenet) GetRelayConfig

func (c *CosmosRemotenet) GetRelayConfig(ctx context.Context, rlyHome string, keyName string) ([]byte, error)

func (*CosmosRemotenet) Height

func (c *CosmosRemotenet) Height(ctx context.Context) (uint64, error)

func (*CosmosRemotenet) InstantiateContractRemote

func (c *CosmosRemotenet) InstantiateContractRemote(ctx context.Context, 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 (*CosmosRemotenet) NodeCommand

func (c *CosmosRemotenet) NodeCommand(command ...string) []string

func (*CosmosRemotenet) QueryCommand

func (c *CosmosRemotenet) QueryCommand(command ...string) []string

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 (*CosmosRemotenet) QueryContractRemote

func (c *CosmosRemotenet) QueryContractRemote(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 (*CosmosRemotenet) SendPacketXCall

func (c *CosmosRemotenet) SendPacketXCall(ctx context.Context, keyName, _to string, data, rollback []byte) (context.Context, error)

func (*CosmosRemotenet) SetupConnection

func (c *CosmosRemotenet) SetupConnection(ctx context.Context, target chains.Chain) error

func (*CosmosRemotenet) SetupXCall

func (c *CosmosRemotenet) SetupXCall(ctx context.Context) error

func (*CosmosRemotenet) StoreContractRemote

func (c *CosmosRemotenet) StoreContractRemote(ctx context.Context, fileName string, extraExecTxArgs ...string) (string, error)

func (*CosmosRemotenet) TxCommand

func (c *CosmosRemotenet) TxCommand(command ...string) []string

func (*CosmosRemotenet) TxHashToResponse

func (c *CosmosRemotenet) TxHashToResponse(ctx context.Context, txHash string) (*sdk.TxResponse, error)

TxHashToResponse returns the sdk transaction response struct for a given transaction hash.

func (*CosmosRemotenet) XCall

func (c *CosmosRemotenet) XCall(ctx context.Context, targetChain chains.Chain, keyName, to string, data, rollback []byte) (*chains.XCallResponse, error)

type CosmosTx

type CosmosTx struct {
	TxHash string `json:"txhash"`
	Code   int    `json:"code"`
	RawLog string `json:"raw_log"`
}

type DappInit

type DappInit struct {
	Address string `json:"address"`
}

type GetAdmin

type GetAdmin struct{}

type GetProtocolFee

type GetProtocolFee struct{}

type LogEvent

type LogEvent struct {
	MsgIndex int    `json:"msg_index"`
	Log      string `json:"log"`
	Events   []struct {
		Type       string `json:"type"`
		Attributes []struct {
			Key   string `json:"key"`
			Value string `json:"value"`
			Index bool   `json:"index"`
		} `json:"attributes"`
	} `json:"events"`
}

type MinimumGasPriceEntity

type MinimumGasPriceEntity struct {
	Denom  string `json:"denom"`
	Amount string `json:"amount"`
}

type MockAppInit

type MockAppInit struct {
	IBCHost int    `json:"ibc_host"`
	PortId  string `json:"port_id"`
	Order   string `json:"order"`
	Denom   string `json:"denom"`
}

type Query

type Query struct {
	GetClientState            *map[string]interface{} `json:"get_client_state,omitempty"`
	GetAdmin                  *GetAdmin               `json:"get_admin,omitempty"`
	GetProtocolFee            *GetProtocolFee         `json:"get_protocol_fee,omitempty"`
	GetNextClientSequence     *map[string]interface{} `json:"get_next_client_sequence,omitempty"`
	HasPacketReceipt          *map[string]interface{} `json:"has_packet_receipt,omitempty"`
	GetNextSequenceReceive    *map[string]interface{} `json:"get_next_sequence_receive,omitempty"`
	GetConnection             *map[string]interface{} `json:"get_connection,omitempty"`
	GetChannel                *map[string]interface{} `json:"get_channel,omitempty"`
	GetNextConnectionSequence *map[string]interface{} `json:"get_next_connection_sequence,omitempty"`
	GetNextChannelSequence    *map[string]interface{} `json:"get_next_channel_sequence,omitempty"`
}

type QueryContractResponse

type QueryContractResponse struct {
	Contracts []string `json:"contracts"`
}

type Result

type Result struct {
	NodeInfo struct {
		ProtocolVersion struct {
			P2P   string `json:"p2p"`
			Block string `json:"block"`
			App   string `json:"app"`
		} `json:"protocol_version"`
		ID         string `json:"id"`
		ListenAddr string `json:"listen_addr"`
		Network    string `json:"network"`
		Version    string `json:"version"`
		Channels   string `json:"channels"`
		Moniker    string `json:"moniker"`
		Other      struct {
			TxIndex    string `json:"tx_index"`
			RPCAddress string `json:"rpc_address"`
		} `json:"other"`
	} `json:"NodeInfo"`
	SyncInfo struct {
		LatestBlockHash     string    `json:"latest_block_hash"`
		LatestAppHash       string    `json:"latest_app_hash"`
		LatestBlockHeight   string    `json:"latest_block_height"`
		LatestBlockTime     time.Time `json:"latest_block_time"`
		EarliestBlockHash   string    `json:"earliest_block_hash"`
		EarliestAppHash     string    `json:"earliest_app_hash"`
		EarliestBlockHeight string    `json:"earliest_block_height"`
		EarliestBlockTime   time.Time `json:"earliest_block_time"`
		CatchingUp          bool      `json:"catching_up"`
	} `json:"SyncInfo"`
	ValidatorInfo struct {
		Address string `json:"Address"`
		PubKey  struct {
			Type  string `json:"type"`
			Value string `json:"value"`
		} `json:"PubKey"`
		VotingPower string `json:"VotingPower"`
	} `json:"ValidatorInfo"`
}

type SetAdmin

type SetAdmin struct {
	SetAdmin struct {
		Address string `json:"address"`
	} `json:"set_admin"`
}

type TxResul

type TxResul struct {
	Height    string        `json:"height"`
	Txhash    string        `json:"txhash"`
	Codespace string        `json:"codespace"`
	Code      int           `json:"code"`
	Data      string        `json:"data"`
	RawLog    string        `json:"raw_log"`
	Logs      []interface{} `json:"logs"`
	Info      string        `json:"info"`
	GasWanted string        `json:"gas_wanted"`
	GasUsed   string        `json:"gas_used"`
	Tx        interface{}   `json:"tx"`
	Timestamp string        `json:"timestamp"`
	Events    []struct {
		Type       string `json:"type"`
		Attributes []struct {
			Key   string `json:"key"`
			Value string `json:"value"`
			Index bool   `json:"index"`
		} `json:"attributes"`
	} `json:"events"`
}

type UpdateAdmin

type UpdateAdmin struct {
	UpdateAdmin struct {
		Address string `json:"address"`
	} `json:"update_admin"`
}

type XcallInit

type XcallInit struct {
	TimeoutHeight int    `json:"timeout_height"`
	IbcHost       string `json:"ibc_host"`
}

Jump to

Keyboard shortcuts

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