From 5999fc45c0856ef885353ad9776c82d0acaefffb Mon Sep 17 00:00:00 2001 From: Christoph Otter Date: Thu, 1 Feb 2024 18:39:09 +0100 Subject: [PATCH] Add Payload fields --- types/submessages.go | 34 ++++++++++++++++++++++++++++++---- 1 file changed, 30 insertions(+), 4 deletions(-) diff --git a/types/submessages.go b/types/submessages.go index faaa14a5..4965027d 100644 --- a/types/submessages.go +++ b/types/submessages.go @@ -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. @@ -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.