Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: ICS20 Transfer v2 message #2102

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module github.com/CosmWasm/wasmd
go 1.23.1

require (
github.com/CosmWasm/wasmvm/v2 v2.2.1
github.com/CosmWasm/wasmvm/v2 v2.2.2-0.20250129191107-3c641d99ee15
github.com/cosmos/cosmos-proto v1.0.0-beta.5
github.com/cosmos/cosmos-sdk v0.50.11
github.com/cosmos/gogogateway v1.2.0 // indirect
Expand Down
6 changes: 4 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -227,8 +227,10 @@ github.com/Azure/go-ansiterm v0.0.0-20230124172434-306776ec8161 h1:L/gRVlceqvL25
github.com/Azure/go-ansiterm v0.0.0-20230124172434-306776ec8161/go.mod h1:xomTg63KZ2rFqZQzSB4Vz2SUXa1BpHTVz9L5PTmPC4E=
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo=
github.com/CosmWasm/wasmvm/v2 v2.2.1 h1:cmOnM+TDfUl2VRugeo1eJBw4U/Lw0WLviuQHKSo9DVQ=
github.com/CosmWasm/wasmvm/v2 v2.2.1/go.mod h1:bMhLQL4Yp9CzJi9A83aR7VO9wockOsSlZbT4ztOl6bg=
github.com/CosmWasm/wasmvm/v2 v2.2.2-0.20250127092931-0322ca5cbd27 h1:E7YmMpKjj3wHvtxCesEoCNcg7ft502+U+QSUycqvkDM=
github.com/CosmWasm/wasmvm/v2 v2.2.2-0.20250127092931-0322ca5cbd27/go.mod h1:bMhLQL4Yp9CzJi9A83aR7VO9wockOsSlZbT4ztOl6bg=
github.com/CosmWasm/wasmvm/v2 v2.2.2-0.20250129191107-3c641d99ee15 h1:Bjd0MInujGk6AvWbjDnyCqCJh5UCAzRu7qqfuO+x7fI=
github.com/CosmWasm/wasmvm/v2 v2.2.2-0.20250129191107-3c641d99ee15/go.mod h1:bMhLQL4Yp9CzJi9A83aR7VO9wockOsSlZbT4ztOl6bg=
Comment on lines +230 to +233
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This needs a go mod tidy, but that can wait until the actual wasmvm release is ready.

github.com/DataDog/datadog-go v3.2.0+incompatible/go.mod h1:LButxg5PwREeZtORoXG3tL4fMGNddJ+vMq1mwgfaqoQ=
github.com/DataDog/datadog-go v4.8.3+incompatible h1:fNGaYSuObuQb5nzeTQqowRAd9bpDIRRV4/gUtIBjh8Q=
github.com/DataDog/datadog-go v4.8.3+incompatible/go.mod h1:LButxg5PwREeZtORoXG3tL4fMGNddJ+vMq1mwgfaqoQ=
Expand Down
3 changes: 3 additions & 0 deletions tests/e2e/ibc_callbacks_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ func TestIBCCallbacks(t *testing.T) {
ToAddress string `json:"to_address"`
ChannelID string `json:"channel_id"`
TimeoutSeconds uint32 `json:"timeout_seconds"`
ChannelVersion string `json:"channel_version"`
}
// ExecuteMsg is the ibc-callbacks contract's execute msg
type ExecuteMsg struct {
Expand All @@ -88,6 +89,7 @@ func TestIBCCallbacks(t *testing.T) {
Transfer: &TransferExecMsg{
ChannelID: path.EndpointA.ChannelID,
TimeoutSeconds: 100,
ChannelVersion: "V2",
},
},
expAck: true,
Expand All @@ -97,6 +99,7 @@ func TestIBCCallbacks(t *testing.T) {
Transfer: &TransferExecMsg{
ChannelID: path.EndpointA.ChannelID,
TimeoutSeconds: 1,
ChannelVersion: "V2",
},
},
expAck: false,
Expand Down
Binary file modified tests/e2e/testdata/ibc_callbacks.wasm
Binary file not shown.
2 changes: 1 addition & 1 deletion tests/integration/module_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ func setupTest(t *testing.T) testData {

ctx, keepers := keeper.CreateTestInput(t, false, []string{
"iterator", "staking", "stargate", "cosmwasm_1_1", "cosmwasm_1_2", "cosmwasm_1_3",
"cosmwasm_1_4", "cosmwasm_2_0", "cosmwasm_2_1", "cosmwasm_2_2",
"cosmwasm_1_4", "cosmwasm_2_0", "cosmwasm_2_1", "cosmwasm_2_2", "cosmwasm_3_0",
})
encConf := keeper.MakeEncodingConfig(t)
queryRouter := baseapp.NewGRPCQueryRouter()
Expand Down
1 change: 1 addition & 0 deletions x/wasm/keeper/capabilities.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,6 @@ func BuiltInCapabilities() []string {
"cosmwasm_2_0",
"cosmwasm_2_1",
"cosmwasm_2_2",
"cosmwasm_3_0",
}
}
29 changes: 29 additions & 0 deletions x/wasm/keeper/handler_plugin_encoders.go
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,35 @@ func EncodeIBCMsg(portSource types.ICS20TransferPortSource) func(ctx sdk.Context
Memo: msg.Transfer.Memo,
}
return []sdk.Msg{msg}, nil
case msg.TransferV2 != nil:
tokens := []sdk.Coin{}
for _, token := range msg.TransferV2.Tokens {
coin, err := ConvertWasmCoinToSdkCoin(token)
if err != nil {
return nil, errorsmod.Wrap(err, "amount")
}
tokens = append(tokens, coin)
}
Comment on lines +325 to +332
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it make sense to use ConvertWasmCoinsToSdkCoins here?

forwardingHops := []ibctransfertypes.Hop{}
for _, hop := range msg.TransferV2.Forwarding {
newHop := ibctransfertypes.NewHop(hop.PortID, hop.ChannelID)
forwardingHops = append(forwardingHops, newHop)
}
forwarding := ibctransfertypes.Forwarding{
Hops: forwardingHops,
}
msg := &ibctransfertypes.MsgTransfer{
SourcePort: portSource.GetPort(ctx),
SourceChannel: msg.TransferV2.ChannelID,
Tokens: tokens,
Sender: sender.String(),
Receiver: msg.TransferV2.ToAddress,
TimeoutHeight: ConvertWasmIBCTimeoutHeightToCosmosHeight(msg.TransferV2.Timeout.Block),
TimeoutTimestamp: msg.TransferV2.Timeout.Timestamp,
Memo: msg.TransferV2.Memo,
Forwarding: &forwarding,
}
return []sdk.Msg{msg}, nil
case msg.PayPacketFee != nil:
fee, err := ConvertIBCFee(&msg.PayPacketFee.Fee)
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion x/wasm/keeper/keeper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ var replierWasm []byte

var AvailableCapabilities = []string{
"iterator", "staking", "stargate", "cosmwasm_1_1", "cosmwasm_1_2", "cosmwasm_1_3",
"cosmwasm_1_4", "cosmwasm_2_0", "cosmwasm_2_1", "cosmwasm_2_2",
"cosmwasm_1_4", "cosmwasm_2_0", "cosmwasm_2_1", "cosmwasm_2_2", "cosmwasm_3_0",
}

func TestNewKeeper(t *testing.T) {
Expand Down