Skip to content

Commit

Permalink
change raw packet response to proto with seqnum
Browse files Browse the repository at this point in the history
  • Loading branch information
0xLaurenzo committed Jan 17, 2023
1 parent 2bef8ea commit 92009f6
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions x/wasm/keeper/handler_plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
codectypes "github.com/cosmos/cosmos-sdk/codec/types"
sdk "github.com/cosmos/cosmos-sdk/types"
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
ibctypes "github.com/cosmos/ibc-go/v5/modules/apps/transfer/types"
channeltypes "github.com/cosmos/ibc-go/v5/modules/core/04-channel/types"
host "github.com/cosmos/ibc-go/v5/modules/core/24-host"

Expand Down Expand Up @@ -192,8 +193,16 @@ func (h IBCRawPacketHandler) DispatchMsg(ctx sdk.Context, _ sdk.AccAddress, cont
return nil, nil, sdkerrors.Wrap(err, "failed to send packet")
}

// Encode the sequence in big endian order and append it to data so that it can be retrieved by contract
data = append(data, sdk.Uint64ToBigEndian(sequence))
// Encode the sequence in a struct and append it to data so that it can be retrieved by contract
// we're reusing MsgTransferResponse here because it's the same proto, but it would be cleaner to not do this
resp := &ibctypes.MsgTransferResponse { Sequence: sequence}
val, err := resp.Marshal()

if err != nil {
return nil, nil, sdkerrors.Wrap(err, "failed to marshal sequence response")
}

data = append(data, val)
return
}

Expand Down

0 comments on commit 92009f6

Please sign in to comment.