Skip to content

Commit

Permalink
Add Payload fields
Browse files Browse the repository at this point in the history
  • Loading branch information
chipshort committed Feb 1, 2024
1 parent 313e5c3 commit 5999fc4
Showing 1 changed file with 30 additions and 4 deletions.
34 changes: 30 additions & 4 deletions types/submessages.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,29 @@ func (s *replyOn) UnmarshalJSON(b []byte) error {
// SubMsg wraps a CosmosMsg with some metadata for handling replies (ID) and optionally
// limiting the gas usage (GasLimit)
type SubMsg struct {
ID uint64 `json:"id"`
Msg CosmosMsg `json:"msg"`
GasLimit *uint64 `json:"gas_limit,omitempty"`
ReplyOn replyOn `json:"reply_on"`
// An arbitrary ID chosen by the contract.
// This is typically used to match `Reply`s in the `reply` entry point to the submessage.
ID uint64 `json:"id"`
Msg CosmosMsg `json:"msg"`
// Some arbitrary data that the contract can set in an application specific way.
// This is just passed into the `reply` entry point and is not stored to state.
// Any encoding can be used. If `id` is used to identify a particular action,
// the encoding can also be different for each of those actions since you can match `id`
// first and then start processing the `payload`.
//
// The environment restricts the length of this field in order to avoid abuse. The limit
// is environment specific and can change over time. The initial default is 128 KiB.
//
// Unset/nil/null cannot be differentiated from empty data.
//
// On chains running CosmWasm 1.x this field will be ignored.
Payload []byte `json:"payload"`
// Gas limit measured in [Cosmos SDK gas](https://github.com/CosmWasm/cosmwasm/blob/main/docs/GAS.md).
//
// Setting this to `None` means unlimited. Then the submessage execution can consume all gas of
// the current execution context.
GasLimit *uint64 `json:"gas_limit,omitempty"`
ReplyOn replyOn `json:"reply_on"`
}

// The result object returned to `reply`. We always get the ID from the submessage back and then must handle success and error cases ourselves.
Expand All @@ -68,6 +87,13 @@ type Reply struct {
// The ID that the contract set when emitting the `SubMsg`. Use this to identify which submessage triggered the `reply`.
ID uint64 `json:"id"`
Result SubMsgResult `json:"result"`
// Some arbitrary data that the contract set when emitting the `SubMsg`.
// This is just passed into the `reply` entry point and is not stored to state.
//
// Unset/nil/null cannot be differentiated from empty data.
//
// On chains running CosmWasm 1.x this field is never filled.
Payload []byte `json:"payload"`
}

// SubMsgResult is the raw response we return from wasmd after executing a SubMsg.
Expand Down

0 comments on commit 5999fc4

Please sign in to comment.