v1types

package
v1.4.1-beta.9 Latest Latest
Warning

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

Go to latest
Published: Oct 26, 2022 License: AGPL-3.0, Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ReplyAlways replyOn = iota
	ReplySuccess
	ReplyError
	ReplyNever
)
View Source
const Ordered = "ORDER_ORDERED"
View Source
const Unordered = "ORDER_UNORDERED"

These are the only two valid values for IbcOrder

Variables

View Source
var ToVoteOption = map[string]VoteOption{
	"yes":          Yes,
	"no":           No,
	"abstain":      Abstain,
	"no_with_veto": NoWithVeto,
}

Functions

This section is empty.

Types

type AnalysisReport

type AnalysisReport struct {
	HasIBCEntryPoints bool
	RequiredFeatures  string
}

Contains static analysis info of the contract (the Wasm code to be precise). This type is returned by VM.AnalyzeCode().

type BankMsg

type BankMsg struct {
	Send *SendMsg `json:"send,omitempty"`
	Burn *BurnMsg `json:"burn,omitempty"`
}

type BurnMsg

type BurnMsg struct {
	Amount types.Coins `json:"amount"`
}

BurnMsg will burn the given coins from the contract's account. There is no Cosmos SDK message that performs this, but it can be done by calling the bank keeper. Important if a contract controls significant token supply that must be retired.

type CloseChannelMsg

type CloseChannelMsg struct {
	ChannelID string `json:"channel_id"`
}

type ContractResult

type ContractResult struct {
	Ok  *Response `json:"ok,omitempty"`
	Err string    `json:"error,omitempty"`
}

ContractResult is the raw response from the instantiate/execute/migrate calls. This is mirrors Rust's ContractResult<Response>.

type CosmosMsg

type CosmosMsg struct {
	Bank         *BankMsg         `json:"bank,omitempty"`
	Custom       json.RawMessage  `json:"custom,omitempty"`
	Distribution *DistributionMsg `json:"distribution,omitempty"`
	Gov          *GovMsg          `json:"gov,omitempty"`
	IBC          *IBCMsg          `json:"ibc,omitempty"`
	Staking      *StakingMsg      `json:"staking,omitempty"`
	Stargate     *StargateMsg     `json:"stargate,omitempty"`
	Wasm         *WasmMsg         `json:"wasm,omitempty"`
}

CosmosMsg is an rust enum and only (exactly) one of the fields should be set Should we do a cleaner approach in Go? (type/data?)

type DataWithInternalReplyInfo

type DataWithInternalReplyInfo struct {
	InternaReplyEnclaveSig []byte `json:"internal_reply_enclave_sig"`
	InternalMsgId          []byte `json:"internal_msg_id"`
	Data                   []byte `json:"data,omitempty"`
}

Used to serialize both the data and the internal reply information in order to keep the api without changes

type DistributionMsg

type DistributionMsg struct {
	SetWithdrawAddress      *SetWithdrawAddressMsg      `json:"set_withdraw_address,omitempty"`
	WithdrawDelegatorReward *WithdrawDelegatorRewardMsg `json:"withdraw_delegator_reward,omitempty"`
}

type Event

type Event struct {
	Type       string        `json:"type"`
	Attributes LogAttributes `json:"attributes"`
}

type Events

type Events []Event

Events must encode empty array as []

func (Events) MarshalJSON

func (e Events) MarshalJSON() ([]byte, error)

MarshalJSON ensures that we get [] for empty arrays

func (*Events) UnmarshalJSON

func (e *Events) UnmarshalJSON(data []byte) error

UnmarshalJSON ensures that we get [] for empty arrays

type GovMsg

type GovMsg struct {
	// This maps directly to [MsgVote](https://github.com/cosmos/cosmos-sdk/blob/v0.42.5/proto/cosmos/gov/v1beta1/tx.proto#L46-L56) in the Cosmos SDK with voter set to the contract address.
	Vote *VoteMsg `json:"vote,omitempty"`
}

type IBC3ChannelOpenResponse

type IBC3ChannelOpenResponse struct {
	Version string `json:"version"`
}

IBC3ChannelOpenResponse is version negotiation data for the handshake

type IBCAcknowledgement

type IBCAcknowledgement struct {
	Data []byte `json:"data"`
}

type IBCBasicResponse

type IBCBasicResponse struct {
	// Messages comes directly from the contract and is its request for action.
	// If the ReplyOn value matches the result, the runtime will invoke this
	// contract's `reply` entry point after execution. Otherwise, this is all
	// "fire and forget".
	Messages []SubMsg `json:"messages"`
	// attributes for a log event to return over abci interface
	Attributes []v010msgtypes.LogAttribute `json:"attributes"`
	// custom events (separate from the main one that contains the attributes
	// above)
	Events []Event `json:"events"`
}

IBCBasicResponse defines the return value on a successful processing. This is the counterpart of [IbcBasicResponse](https://github.com/CosmWasm/cosmwasm/blob/v0.14.0-beta1/packages/std/src/ibc.rs#L194-L216).

type IBCBasicResult

type IBCBasicResult struct {
	Ok  *IBCBasicResponse `json:"ok,omitempty"`
	Err *types.StdError   `json:"Err,omitempty"`
}

This is the return value for the majority of the ibc handlers. That are able to dispatch messages / events on their own, but have no meaningful return value to the calling code.

Callbacks that have return values (like ibc_receive_packet) or that cannot redispatch messages (like ibc_channel_open) will use other Response types

type IBCChannel

type IBCChannel struct {
	Endpoint             IBCEndpoint `json:"endpoint"`
	CounterpartyEndpoint IBCEndpoint `json:"counterparty_endpoint"`
	Order                IBCOrder    `json:"order"`
	Version              string      `json:"version"`
	ConnectionID         string      `json:"connection_id"`
}

type IBCChannelCloseMsg

type IBCChannelCloseMsg struct {
	CloseInit    *IBCCloseInit    `json:"close_init,omitempty"`
	CloseConfirm *IBCCloseConfirm `json:"close_confirm,omitempty"`
}

func (IBCChannelCloseMsg) GetChannel

func (msg IBCChannelCloseMsg) GetChannel() IBCChannel

GetChannel returns the IBCChannel in this message.

type IBCChannelConnectMsg

type IBCChannelConnectMsg struct {
	OpenAck     *IBCOpenAck     `json:"open_ack,omitempty"`
	OpenConfirm *IBCOpenConfirm `json:"open_confirm,omitempty"`
}

func (IBCChannelConnectMsg) GetChannel

func (msg IBCChannelConnectMsg) GetChannel() IBCChannel

GetChannel returns the IBCChannel in this message.

func (IBCChannelConnectMsg) GetCounterVersion

func (msg IBCChannelConnectMsg) GetCounterVersion() (ver string, ok bool)

GetCounterVersion checks if the message has a counterparty version and returns it if so.

type IBCChannelOpenMsg

type IBCChannelOpenMsg struct {
	OpenInit *IBCOpenInit `json:"open_init,omitempty"`
	OpenTry  *IBCOpenTry  `json:"open_try,omitempty"`
}

func (IBCChannelOpenMsg) GetChannel

func (msg IBCChannelOpenMsg) GetChannel() IBCChannel

GetChannel returns the IBCChannel in this message.

func (IBCChannelOpenMsg) GetCounterVersion

func (msg IBCChannelOpenMsg) GetCounterVersion() (ver string, ok bool)

GetCounterVersion checks if the message has a counterparty version and returns it if so.

type IBCChannelOpenResult

type IBCChannelOpenResult struct {
	Ok  *IBC3ChannelOpenResponse `json:"ok,omitempty"`
	Err string                   `json:"error,omitempty"`
}

IBCChannelOpenResult is the raw response from the ibc_channel_open call. This is mirrors Rust's ContractResult<()>. Check if Err == "" to see if this is success On Success, IBCV3ChannelOpenResponse *may* be set if the contract is ibcv3 compatible and wishes to define a custom version in the handshake.

type IBCCloseConfirm

type IBCCloseConfirm struct {
	Channel IBCChannel `json:"channel"`
}

func (*IBCCloseConfirm) ToMsg

type IBCCloseInit

type IBCCloseInit struct {
	Channel IBCChannel `json:"channel"`
}

func (*IBCCloseInit) ToMsg

func (m *IBCCloseInit) ToMsg() IBCChannelCloseMsg

type IBCEndpoint

type IBCEndpoint struct {
	PortID    string `json:"port_id"`
	ChannelID string `json:"channel_id"`
}

type IBCMsg

type IBCMsg struct {
	Transfer     *TransferMsg     `json:"transfer,omitempty"`
	SendPacket   *SendPacketMsg   `json:"send_packet,omitempty"`
	CloseChannel *CloseChannelMsg `json:"close_channel,omitempty"`
}

type IBCOpenAck

type IBCOpenAck struct {
	Channel             IBCChannel `json:"channel"`
	CounterpartyVersion string     `json:"counterparty_version"`
}

func (*IBCOpenAck) ToMsg

func (m *IBCOpenAck) ToMsg() IBCChannelConnectMsg

type IBCOpenChannelResult

type IBCOpenChannelResult struct {
	Ok  *string         `json:"ok,omitempty"`
	Err *types.StdError `json:"Err,omitempty"`
}

type IBCOpenConfirm

type IBCOpenConfirm struct {
	Channel IBCChannel `json:"channel"`
}

func (*IBCOpenConfirm) ToMsg

type IBCOpenInit

type IBCOpenInit struct {
	Channel IBCChannel `json:"channel"`
}

func (*IBCOpenInit) ToMsg

func (m *IBCOpenInit) ToMsg() IBCChannelOpenMsg

type IBCOpenTry

type IBCOpenTry struct {
	Channel             IBCChannel `json:"channel"`
	CounterpartyVersion string     `json:"counterparty_version"`
}

func (*IBCOpenTry) ToMsg

func (m *IBCOpenTry) ToMsg() IBCChannelOpenMsg

type IBCPacket

type IBCPacket struct {
	Data     []byte      `json:"data"`
	Src      IBCEndpoint `json:"src"`
	Dest     IBCEndpoint `json:"dest"`
	Sequence uint64      `json:"sequence"`
	Timeout  IBCTimeout  `json:"timeout"`
}

type IBCPacketAckMsg

type IBCPacketAckMsg struct {
	Acknowledgement IBCAcknowledgement `json:"acknowledgement"`
	OriginalPacket  IBCPacket          `json:"original_packet"`
	Relayer         string             `json:"relayer"`
}

type IBCPacketReceiveMsg

type IBCPacketReceiveMsg struct {
	Packet  IBCPacket `json:"packet"`
	Relayer string    `json:"relayer"`
}

type IBCPacketTimeoutMsg

type IBCPacketTimeoutMsg struct {
	Packet  IBCPacket `json:"packet"`
	Relayer string    `json:"relayer"`
}

type IBCReceiveResponse

type IBCReceiveResponse struct {
	// binary encoded data to be returned to calling chain as the acknowledgement
	Acknowledgement []byte `json:"acknowledgement"`
	// Messages comes directly from the contract and is it's request for action.
	// If the ReplyOn value matches the result, the runtime will invoke this
	// contract's `reply` entry point after execution. Otherwise, this is all
	// "fire and forget".
	Messages   []SubMsg                    `json:"messages"`
	Attributes []v010msgtypes.LogAttribute `json:"attributes"`
	// custom events (separate from the main one that contains the attributes
	// above)
	Events []Event `json:"events"`
}

IBCReceiveResponse defines the return value on packet response processing. This "success" case should be returned even in application-level errors, Where the Acknowledgement bytes contain an encoded error message to be returned to the calling chain. (Returning IBCReceiveResult::Err will abort processing of this packet and not inform the calling chain). This is the counterpart of (IbcReceiveResponse)(https://github.com/CosmWasm/cosmwasm/blob/v0.15.0/packages/std/src/ibc.rs#L247-L267).

type IBCReceiveResult

type IBCReceiveResult struct {
	Ok  *IBCReceiveResponse `json:"ok,omitempty"`
	Err *types.StdError     `json:"Err,omitempty"`
}

This is the return value for the majority of the ibc handlers. That are able to dispatch messages / events on their own, but have no meaningful return value to the calling code.

Callbacks that have return values (like receive_packet) or that cannot redispatch messages (like the handshake callbacks) will use other Response types

type IBCTimeout

type IBCTimeout struct {
	Block *IBCTimeoutBlock `json:"block"`
	// Nanoseconds since UNIX epoch
	Timestamp uint64 `json:"timestamp,string,omitempty"`
}

IBCTimeout is the timeout for an IBC packet. At least one of block and timestamp is required.

type IBCTimeoutBlock

type IBCTimeoutBlock struct {
	// the version that the client is currently on
	// (eg. after reseting the chain this could increment 1 as height drops to 0)
	Revision uint64 `json:"revision"`
	// block height after which the packet times out.
	// the height within the given revision
	Height uint64 `json:"height"`
}

IBCTimeoutBlock Height is a monotonically increasing data type that can be compared against another Height for the purposes of updating and freezing clients. Ordering is (revision_number, timeout_height)

func (IBCTimeoutBlock) IsZero

func (t IBCTimeoutBlock) IsZero() bool

type LogAttributes

type LogAttributes []v010msgtypes.LogAttribute

LogAttributes must encode empty array as []

func (LogAttributes) MarshalJSON

func (a LogAttributes) MarshalJSON() ([]byte, error)

MarshalJSON ensures that we get [] for empty arrays

func (*LogAttributes) UnmarshalJSON

func (a *LogAttributes) UnmarshalJSON(data []byte) error

UnmarshalJSON ensures that we get [] for empty arrays

type Reply

type Reply struct {
	ID                  []byte       `json:"id"`
	Result              SubMsgResult `json:"result"`
	WasOrigMsgEncrypted bool         `json:"was_orig_msg_encrypted"`
	IsEncrypted         bool         `json:"is_encrypted"`
}

type Response

type Response struct {
	// Messages comes directly from the contract and is its request for action.
	// If the ReplyOn value matches the result, the runtime will invoke this
	// contract's `reply` entry point after execution. Otherwise, this is all
	// "fire and forget".
	Messages []SubMsg `json:"messages"`
	// base64-encoded bytes to return as ABCI.Data field
	Data []byte `json:"data"`
	// attributes for a log event to return over abci interface
	Attributes []v010msgtypes.LogAttribute `json:"attributes"`
	// custom events (separate from the main one that contains the attributes
	// above)
	Events []Event `json:"events"`
}

Response defines the return value on a successful instantiate/execute/migrate. This is the counterpart of Response(https://github.com/CosmWasm/cosmwasm/blob/v0.14.0-beta1/packages/std/src/results/response.rs#L73-L88)

type SendMsg

type SendMsg struct {
	ToAddress string      `json:"to_address"`
	Amount    types.Coins `json:"amount"`
}

SendMsg contains instructions for a Cosmos-SDK/SendMsg It has a fixed interface here and should be converted into the proper SDK format before dispatching

type SendPacketMsg

type SendPacketMsg struct {
	ChannelID string     `json:"channel_id"`
	Data      []byte     `json:"data"`
	Timeout   IBCTimeout `json:"timeout"`
}

type SetWithdrawAddressMsg

type SetWithdrawAddressMsg struct {
	// Address contains the `delegator_address` of a MsgSetWithdrawAddress
	Address string `json:"address"`
}

SetWithdrawAddressMsg is translated to a [MsgSetWithdrawAddress](https://github.com/cosmos/cosmos-sdk/blob/v0.42.4/proto/cosmos/distribution/v1beta1/tx.proto#L29-L37). `delegator_address` is automatically filled with the current contract's address.

type StakingMsg

type StakingMsg struct {
	Delegate   *v010msgtypes.DelegateMsg   `json:"delegate,omitempty"`
	Undelegate *v010msgtypes.UndelegateMsg `json:"undelegate,omitempty"`
	Redelegate *v010msgtypes.RedelegateMsg `json:"redelegate,omitempty"`
	Withdraw   *v010msgtypes.WithdrawMsg   `json:"withdraw,omitempty"`
}

type StargateMsg

type StargateMsg struct {
	TypeURL string `json:"type_url"`
	Value   []byte `json:"value"`
}

StargateMsg is encoded the same way as a protobof [Any](https://github.com/protocolbuffers/protobuf/blob/master/src/google/protobuf/any.proto). This is the same structure as messages in `TxBody` from [ADR-020](https://github.com/cosmos/cosmos-sdk/blob/master/docs/architecture/adr-020-protobuf-transaction-encoding.md)

type SubMsg

type SubMsg struct {
	ID              uint64    `json:"id"`
	Msg             CosmosMsg `json:"msg"`
	GasLimit        *uint64   `json:"gas_limit,omitempty"`
	ReplyOn         replyOn   `json:"reply_on"`
	WasMsgEncrypted bool      `json:"was_msg_encrypted"`
}

SubMsg wraps a CosmosMsg with some metadata for handling replies (ID) and optionally limiting the gas usage (GasLimit)

type SubMsgResponse

type SubMsgResponse struct {
	Events Events `json:"events"`
	Data   []byte `json:"data,omitempty"`
}

type SubMsgResult

type SubMsgResult struct {
	Ok  *SubMsgResponse `json:"ok,omitempty"`
	Err string          `json:"error,omitempty"`
}

SubMsgResult is the raw response we return from wasmd after executing a SubMsg. This mirrors Rust's SubMsgResult.

type SubcallResponse

type SubcallResponse struct {
	Events Events `json:"events"`
	Data   []byte `json:"data,omitempty"`
}

type SubcallResult

type SubcallResult struct {
	Ok  *SubcallResponse `json:"ok,omitempty"`
	Err string           `json:"error,omitempty"`
}

SubcallResult is the raw response we return from the sdk -> reply after executing a SubMsg. This is mirrors Rust's ContractResult<SubcallResponse>.

type TransferMsg

type TransferMsg struct {
	ChannelID string     `json:"channel_id"`
	ToAddress string     `json:"to_address"`
	Amount    types.Coin `json:"amount"`
	Timeout   IBCTimeout `json:"timeout"`
}

type VoteMsg

type VoteMsg struct {
	ProposalId uint64     `json:"proposal_id"`
	Vote       VoteOption `json:"vote"`
}

type VoteOption

type VoteOption int
const (
	Yes VoteOption = iota
	No
	Abstain
	NoWithVeto
)

func (VoteOption) MarshalJSON

func (v VoteOption) MarshalJSON() ([]byte, error)

func (VoteOption) String

func (v VoteOption) String() string

func (*VoteOption) UnmarshalJSON

func (v *VoteOption) UnmarshalJSON(b []byte) error

type WasmMsg

type WasmMsg struct {
	Execute     *v010msgtypes.ExecuteMsg     `json:"execute,omitempty"`
	Instantiate *v010msgtypes.InstantiateMsg `json:"instantiate,omitempty"`
}

type WithdrawDelegatorRewardMsg

type WithdrawDelegatorRewardMsg struct {
	// Validator contains `validator_address` of a MsgWithdrawDelegatorReward
	Validator string `json:"validator"`
}

WithdrawDelegatorRewardMsg is translated to a [MsgWithdrawDelegatorReward](https://github.com/cosmos/cosmos-sdk/blob/v0.42.4/proto/cosmos/distribution/v1beta1/tx.proto#L42-L50). `delegator_address` is automatically filled with the current contract's address.

Jump to

Keyboard shortcuts

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