diff --git a/wasmbinding/message_plugin.go b/wasmbinding/message_plugin.go index 81e05eed0..89307562a 100644 --- a/wasmbinding/message_plugin.go +++ b/wasmbinding/message_plugin.go @@ -7,7 +7,7 @@ import ( "strings" "time" - types1 "github.com/cosmos/ibc-go/v8/modules/core/04-channel/types" + channeltypes "github.com/cosmos/ibc-go/v8/modules/core/04-channel/types" "github.com/cosmos/gogoproto/proto" @@ -868,15 +868,16 @@ func (m *CustomMessenger) registerInterchainAccount(ctx sdk.Context, contractAdd func (m *CustomMessenger) performRegisterInterchainAccount(ctx sdk.Context, contractAddr sdk.AccAddress, reg *bindings.RegisterInterchainAccount) (*ictxtypes.MsgRegisterInterchainAccountResponse, error) { // parse incoming ordering. If nothing passed, use ORDERED by default - var orderValue types1.Order + var orderValue channeltypes.Order if reg.Ordering == "" { - orderValue = types1.ORDERED + orderValue = channeltypes.ORDERED } else { - orderValueInt, ok := types1.Order_value[reg.Ordering] + orderValueInt, ok := channeltypes.Order_value[reg.Ordering] + if !ok { return nil, fmt.Errorf("failed to register interchain account: incorrect order value passed: %s", reg.Ordering) } - orderValue = types1.Order(orderValueInt) + orderValue = channeltypes.Order(orderValueInt) } msg := ictxtypes.MsgRegisterInterchainAccount{ diff --git a/wasmbinding/test/custom_message_test.go b/wasmbinding/test/custom_message_test.go index 760417c16..b63240921 100644 --- a/wasmbinding/test/custom_message_test.go +++ b/wasmbinding/test/custom_message_test.go @@ -102,13 +102,23 @@ func (suite *CustomMessengerTestSuite) TestRegisterInterchainAccount() { } bankKeeper := suite.neutron.BankKeeper + channelKeeper := suite.neutron.IBCKeeper.ChannelKeeper senderAddress := suite.ChainA.SenderAccounts[0].SenderAccount.GetAddress() err = bankKeeper.SendCoins(suite.ctx, senderAddress, suite.contractAddress, sdk.NewCoins(sdk.NewCoin(params.DefaultDenom, math.NewInt(1_000_000)))) suite.NoError(err) // Dispatch RegisterInterchainAccount message - _, err = suite.executeNeutronMsg(suite.contractAddress, msg) + data, err := suite.executeNeutronMsg(suite.contractAddress, msg) + suite.NoError(err) + suite.NotEmpty(data) + + // default method should be ordered + var response ictxtypes.MsgRegisterInterchainAccountResponse + err = response.Unmarshal(data) suite.NoError(err) + channel, found := channelKeeper.GetChannel(suite.ctx, response.PortId, response.ChannelId) + suite.True(found) + suite.Equal(channel.Ordering, ibcchanneltypes.ORDERED) } func (suite *CustomMessengerTestSuite) TestRegisterInterchainAccountLongID() { @@ -130,6 +140,43 @@ func (suite *CustomMessengerTestSuite) TestRegisterInterchainAccountLongID() { suite.ErrorIs(err, ictxtypes.ErrLongInterchainAccountID) } +func (suite *CustomMessengerTestSuite) TestRegisterInterchainAccountUnordered() { + err := suite.neutron.FeeBurnerKeeper.SetParams(suite.ctx, feeburnertypes.Params{ + NeutronDenom: "untrn", + TreasuryAddress: "neutron13jrwrtsyjjuynlug65r76r2zvfw5xjcq6532h2", + }) + suite.Require().NoError(err) + + // Craft RegisterInterchainAccount message + msg := bindings.NeutronMsg{ + RegisterInterchainAccount: &bindings.RegisterInterchainAccount{ + ConnectionId: suite.Path.EndpointA.ConnectionID, + InterchainAccountId: testutil.TestInterchainID, + RegisterFee: sdk.NewCoins(sdk.NewCoin(params.DefaultDenom, math.NewInt(1_000_000))), + Ordering: ibcchanneltypes.Order_name[int32(ibcchanneltypes.UNORDERED)], + }, + } + + bankKeeper := suite.neutron.BankKeeper + channelKeeper := suite.neutron.IBCKeeper.ChannelKeeper + senderAddress := suite.ChainA.SenderAccounts[0].SenderAccount.GetAddress() + err = bankKeeper.SendCoins(suite.ctx, senderAddress, suite.contractAddress, sdk.NewCoins(sdk.NewCoin(params.DefaultDenom, math.NewInt(1_000_000)))) + suite.NoError(err) + + // Dispatch RegisterInterchainAccount message + data, err := suite.executeNeutronMsg(suite.contractAddress, msg) + suite.NoError(err) + suite.NotEmpty(data) + + // default method should be ordered + var response ictxtypes.MsgRegisterInterchainAccountResponse + err = response.Unmarshal(data) + suite.NoError(err) + channel, found := channelKeeper.GetChannel(suite.ctx, response.PortId, response.ChannelId) + suite.True(found) + suite.Equal(channel.Ordering, ibcchanneltypes.UNORDERED) +} + func (suite *CustomMessengerTestSuite) TestRegisterInterchainQuery() { err := testutil.SetupICAPath(suite.Path, suite.contractAddress.String()) suite.Require().NoError(err) @@ -777,6 +824,8 @@ func (suite *CustomMessengerTestSuite) executeNeutronMsg(contractAddress sdk.Acc fullMsgBz, err := json.Marshal(fullMsg) suite.NoError(err) + fmt.Printf("Marshalled msg: %s\n", string(fullMsgBz)) + return suite.executeCustomMsg(contractAddress, fullMsgBz) } diff --git a/wasmbinding/testdata/reflect.wasm b/wasmbinding/testdata/reflect.wasm index 174232f4b..df893365f 100644 Binary files a/wasmbinding/testdata/reflect.wasm and b/wasmbinding/testdata/reflect.wasm differ