Skip to content

Commit

Permalink
Update types to cosmwasm 2.0 version
Browse files Browse the repository at this point in the history
  • Loading branch information
chipshort committed Jan 31, 2024
1 parent 6c016ab commit 5518d23
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 2 deletions.
25 changes: 25 additions & 0 deletions types/ibc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,3 +92,28 @@ func TestIbcTimeoutDeserialization(t *testing.T) {
Timestamp: 0,
}, timeout4)
}

func TestIbcReceiveResponseDeserialization(t *testing.T) {
var err error

// without acknowledgement
var resp IBCReceiveResponse
err = json.Unmarshal([]byte(`{"acknowledgement":null,"messages":[],"attributes":[],"events":[]}`), &resp)
require.NoError(t, err)
assert.Equal(t, IBCReceiveResponse{
Acknowledgement: nil,
Messages: []SubMsg{},
Attributes: []EventAttribute{},
Events: []Event{},
}, resp)

// with acknowledgement
err = json.Unmarshal([]byte(`{"acknowledgement":"YWNr","messages":[],"attributes":[],"events":[]}`), &resp)
require.NoError(t, err)
assert.Equal(t, IBCReceiveResponse{
Acknowledgement: []byte("ack"),
Messages: []SubMsg{},
Attributes: []EventAttribute{},
Events: []Event{},
}, resp)
}
1 change: 1 addition & 0 deletions types/msg.go
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,7 @@ type TransferMsg struct {
ToAddress string `json:"to_address"`
Amount Coin `json:"amount"`
Timeout IBCTimeout `json:"timeout"`
Memo string `json:"memo,omitempty"`
}

type SendPacketMsg struct {
Expand Down
10 changes: 8 additions & 2 deletions types/submessages.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,12 @@ type SubMsgResult struct {
// with full Cosmos SDK events.
// This mirrors Rust's SubMsgResponse.
type SubMsgResponse struct {
Events Events `json:"events"`
Data []byte `json:"data,omitempty"`
Events Events `json:"events"`
Data []byte `json:"data,omitempty"`
MsgResponses []MsgResponse `json:"msg_responses"`
}

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

0 comments on commit 5518d23

Please sign in to comment.