Skip to content

Commit

Permalink
Support ics20 transfer msg memo field without changing cosmwasm-std.
Browse files Browse the repository at this point in the history
Cosmwasm does not support a memo field in IBCMsg.TransferMsg and won't
until cosmwasm v2. This patch allows using the channel id as an optional
comma delimited string to piggyback a memo string. See:
CosmWasm/cosmwasm#1477
  • Loading branch information
misko9 committed Jun 27, 2023
1 parent 55655c2 commit c2681dc
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion x/wasm/keeper/handler_plugin_encoders.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package keeper
import (
"encoding/json"
"fmt"
"strings"

wasmvmtypes "github.com/CosmWasm/wasmvm/types"
codectypes "github.com/cosmos/cosmos-sdk/codec/types"
Expand Down Expand Up @@ -277,14 +278,16 @@ func EncodeIBCMsg(portSource types.ICS20TransferPortSource) func(ctx sdk.Context
if err != nil {
return nil, sdkerrors.Wrap(err, "amount")
}
channelID, memo, _ := strings.Cut(msg.Transfer.ChannelID, ",")
msg := &ibctransfertypes.MsgTransfer{
SourcePort: portSource.GetPort(ctx),
SourceChannel: msg.Transfer.ChannelID,
SourceChannel: channelID,
Token: amount,
Sender: sender.String(),
Receiver: msg.Transfer.ToAddress,
TimeoutHeight: ConvertWasmIBCTimeoutHeightToCosmosHeight(msg.Transfer.Timeout.Block),
TimeoutTimestamp: msg.Transfer.Timeout.Timestamp,
Memo: memo,
}
return []sdk.Msg{msg}, nil
default:
Expand Down

0 comments on commit c2681dc

Please sign in to comment.