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

chore: rename SubmitTx to SendTx #2255

Merged
merged 4 commits into from
Sep 9, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
22 changes: 11 additions & 11 deletions docs/ibc/proto-docs.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,8 @@
- [ibc/applications/interchain_accounts/controller/v1/tx.proto](#ibc/applications/interchain_accounts/controller/v1/tx.proto)
- [MsgRegisterAccount](#ibc.applications.interchain_accounts.controller.v1.MsgRegisterAccount)
- [MsgRegisterAccountResponse](#ibc.applications.interchain_accounts.controller.v1.MsgRegisterAccountResponse)
- [MsgSubmitTx](#ibc.applications.interchain_accounts.controller.v1.MsgSubmitTx)
- [MsgSubmitTxResponse](#ibc.applications.interchain_accounts.controller.v1.MsgSubmitTxResponse)
- [MsgSendTx](#ibc.applications.interchain_accounts.controller.v1.MsgSendTx)
- [MsgSendTxResponse](#ibc.applications.interchain_accounts.controller.v1.MsgSendTxResponse)

- [Msg](#ibc.applications.interchain_accounts.controller.v1.Msg)

Expand Down Expand Up @@ -1653,10 +1653,10 @@ MsgRegisterAccountResponse defines the response for Msg/RegisterAccount



<a name="ibc.applications.interchain_accounts.controller.v1.MsgSubmitTx"></a>
<a name="ibc.applications.interchain_accounts.controller.v1.MsgSendTx"></a>

### MsgSubmitTx
MsgSubmitTx defines the payload for MsgSubmitTx
### MsgSendTx
MsgSendTx defines the payload for Msg/SendTx


| Field | Type | Label | Description |
Expand All @@ -1672,10 +1672,10 @@ MsgSubmitTx defines the payload for MsgSubmitTx



<a name="ibc.applications.interchain_accounts.controller.v1.MsgSubmitTxResponse"></a>
<a name="ibc.applications.interchain_accounts.controller.v1.MsgSendTxResponse"></a>

### MsgSubmitTxResponse
MsgSubmitTxResponse defines the response for MsgSubmitTx
### MsgSendTxResponse
MsgSendTxResponse defines the response for MsgSendTx


| Field | Type | Label | Description |
Expand All @@ -1701,7 +1701,7 @@ Msg defines the 27-interchain-accounts/controller Msg service.
| Method Name | Request Type | Response Type | Description | HTTP Verb | Endpoint |
| ----------- | ------------ | ------------- | ------------| ------- | -------- |
| `RegisterAccount` | [MsgRegisterAccount](#ibc.applications.interchain_accounts.controller.v1.MsgRegisterAccount) | [MsgRegisterAccountResponse](#ibc.applications.interchain_accounts.controller.v1.MsgRegisterAccountResponse) | RegisterAccount defines a rpc handler for MsgRegisterAccount. | |
| `SubmitTx` | [MsgSubmitTx](#ibc.applications.interchain_accounts.controller.v1.MsgSubmitTx) | [MsgSubmitTxResponse](#ibc.applications.interchain_accounts.controller.v1.MsgSubmitTxResponse) | SubmitTx defines a rpc handler for MsgSubmitTx. | |
| `SendTx` | [MsgSendTx](#ibc.applications.interchain_accounts.controller.v1.MsgSendTx) | [MsgSendTxResponse](#ibc.applications.interchain_accounts.controller.v1.MsgSendTxResponse) | SendTx defines a rpc handler for MsgSendTx. | |

<!-- end services -->

Expand Down Expand Up @@ -1750,8 +1750,8 @@ The following parameters may be used to disable the host submodule.
<a name="ibc.applications.interchain_accounts.genesis.v1.ActiveChannel"></a>

### ActiveChannel
ActiveChannel contains a connection ID, port ID and associated active channel ID, as well as boolean flag to indicate
if the channel is middleware enabled
ActiveChannel contains a connection ID, port ID and associated active channel ID, as well as a boolean flag to
indicate if the channel is middleware enabled


| Field | Type | Label | Description |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ func NewTxCmd() *cobra.Command {

cmd.AddCommand(
newRegisterAccountCmd(),
newSubmitTxCmd(),
newSendTxCmd(),
)

return cmd
Expand Down Expand Up @@ -77,10 +77,10 @@ the associated capability.`),
return cmd
}

func newSubmitTxCmd() *cobra.Command {
func newSendTxCmd() *cobra.Command {
Copy link
Contributor

Choose a reason for hiding this comment

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

Sorry, this is probably a bit nitpicking, but I was just thinking that what we send to the host chain is a message, right? Or is message and transaction something that mean the same thing? For me I thought that a transaction was the execution of the message, but maybe I am just mistaken... Saying this because maybe this could be renamed to SendMsg...

Copy link
Member Author

Choose a reason for hiding this comment

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

I think we should just stick with the naming used in the spec. I see your reasoning but the InterchainAccountPacketData type may be composed of one or many sdk.Msgs encoded into the []byte field.

cmd := &cobra.Command{
Use: "submit [connection-id] [path/to/packet_msg.json]",
Short: "Submit an interchain account txn on the provided connection.",
Use: "send-tx [connection-id] [path/to/packet_msg.json]",
Short: "Send an interchain account tx on the provided connection.",
Long: strings.TrimSpace(`Submits pre-built packet data containing messages to be executed on the host chain
and attempts to send the packet. Packet data is provided as json, file or string. An
appropriate relative timeoutTimestamp must be provided with flag {packet-timeout-timestamp}, along with a timeoutHeight
Expand Down Expand Up @@ -126,7 +126,7 @@ via {packet-timeout-timestamp}`),
return err
}

msg := types.NewMsgSubmitTx(owner, connectionID, timeoutHeight, timeoutTimestamp, icaMsgData)
msg := types.NewMsgSendTx(owner, connectionID, timeoutHeight, timeoutTimestamp, icaMsgData)

return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg)
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import (
var _ types.MsgServer = msgServer{}

type msgServer struct {
*Keeper
Keeper *Keeper
}

// NewMsgServerImpl returns an implementation of the ICS27 MsgServer interface
Expand All @@ -25,15 +25,15 @@ func NewMsgServerImpl(keeper *Keeper) types.MsgServer {
}

// RegisterAccount defines a rpc handler for MsgRegisterAccount
func (k msgServer) RegisterAccount(goCtx context.Context, msg *types.MsgRegisterAccount) (*types.MsgRegisterAccountResponse, error) {
func (s msgServer) RegisterAccount(goCtx context.Context, msg *types.MsgRegisterAccount) (*types.MsgRegisterAccountResponse, error) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Ah, nice I see that you're renaming it here now... So forget about my comment here.

ctx := sdk.UnwrapSDKContext(goCtx)

portID, err := icatypes.NewControllerPortID(msg.Owner)
if err != nil {
return nil, err
}

channelID, err := k.registerInterchainAccount(ctx, msg.ConnectionId, portID, msg.Version)
channelID, err := s.Keeper.registerInterchainAccount(ctx, msg.ConnectionId, portID, msg.Version)
if err != nil {
return nil, err
}
Expand All @@ -43,29 +43,29 @@ func (k msgServer) RegisterAccount(goCtx context.Context, msg *types.MsgRegister
}, nil
}

// SubmitTx defines a rpc handler for MsgSubmitTx
func (k msgServer) SubmitTx(goCtx context.Context, msg *types.MsgSubmitTx) (*types.MsgSubmitTxResponse, error) {
// SendTx defines a rpc handler for MsgSendTx
func (s msgServer) SendTx(goCtx context.Context, msg *types.MsgSendTx) (*types.MsgSendTxResponse, error) {
ctx := sdk.UnwrapSDKContext(goCtx)

portID, err := icatypes.NewControllerPortID(msg.Owner)
if err != nil {
return nil, err
}

channelID, found := k.GetActiveChannelID(ctx, msg.ConnectionId, portID)
channelID, found := s.Keeper.GetActiveChannelID(ctx, msg.ConnectionId, portID)
if !found {
return nil, sdkerrors.Wrapf(icatypes.ErrActiveChannelNotFound, "failed to retrieve active channel for port %s", portID)
}

chanCap, found := k.scopedKeeper.GetCapability(ctx, host.ChannelCapabilityPath(portID, channelID))
chanCap, found := s.Keeper.scopedKeeper.GetCapability(ctx, host.ChannelCapabilityPath(portID, channelID))
if !found {
return nil, sdkerrors.Wrap(channeltypes.ErrChannelCapabilityNotFound, "module does not own channel capability")
}

seq, err := k.SendTx(ctx, chanCap, msg.ConnectionId, portID, msg.PacketData, msg.TimeoutTimestamp)
seq, err := s.Keeper.SendTx(ctx, chanCap, msg.ConnectionId, portID, msg.PacketData, msg.TimeoutTimestamp)
if err != nil {
return nil, err
}

return &types.MsgSubmitTxResponse{Sequence: seq}, nil
return &types.MsgSendTxResponse{Sequence: seq}, nil
}
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ func (suite *KeeperTestSuite) TestRegisterAccount() {
func (suite *KeeperTestSuite) TestSubmitTx() {
var (
path *ibctesting.Path
msg *types.MsgSubmitTx
msg *types.MsgSendTx
)

testCases := []struct {
Expand Down Expand Up @@ -180,13 +180,13 @@ func (suite *KeeperTestSuite) TestSubmitTx() {
timeoutTimestamp := uint64(suite.chainA.GetContext().BlockTime().Add(time.Minute).UnixNano())
connectionID := path.EndpointA.ConnectionID

msg = types.NewMsgSubmitTx(owner, connectionID, clienttypes.ZeroHeight(), timeoutTimestamp, packetData)
msg = types.NewMsgSendTx(owner, connectionID, clienttypes.ZeroHeight(), timeoutTimestamp, packetData)

tc.malleate() // malleate mutates test data

ctx := suite.chainA.GetContext()
msgServer := keeper.NewMsgServerImpl(&suite.chainA.GetSimApp().ICAControllerKeeper)
res, err := msgServer.SubmitTx(ctx, msg)
res, err := msgServer.SendTx(ctx, msg)

if tc.expPass {
suite.Require().NoError(err)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@ func RegisterInterfaces(registry codectypes.InterfaceRegistry) {
registry.RegisterImplementations(
(*sdk.Msg)(nil),
&MsgRegisterAccount{},
&MsgSubmitTx{},
&MsgSendTx{},
)
}
10 changes: 5 additions & 5 deletions modules/apps/27-interchain-accounts/controller/types/msgs.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,9 @@ func (msg MsgRegisterAccount) GetSigners() []sdk.AccAddress {
return []sdk.AccAddress{accAddr}
}

// NewMsgSubmitTx creates a new instance of MsgSubmitTx
func NewMsgSubmitTx(owner, connectionID string, timeoutHeight clienttypes.Height, timeoutTimestamp uint64, packetData icatypes.InterchainAccountPacketData) *MsgSubmitTx {
return &MsgSubmitTx{
// NewMsgSendTx creates a new instance of MsgSendTx
func NewMsgSendTx(owner, connectionID string, timeoutHeight clienttypes.Height, timeoutTimestamp uint64, packetData icatypes.InterchainAccountPacketData) *MsgSendTx {
return &MsgSendTx{
ConnectionId: connectionID,
Owner: owner,
TimeoutHeight: timeoutHeight,
Expand All @@ -62,7 +62,7 @@ func NewMsgSubmitTx(owner, connectionID string, timeoutHeight clienttypes.Height
}

// ValidateBasic implements sdk.Msg
func (msg MsgSubmitTx) ValidateBasic() error {
func (msg MsgSendTx) ValidateBasic() error {
if err := host.ConnectionIdentifierValidator(msg.ConnectionId); err != nil {
return sdkerrors.Wrap(err, "invalid connection ID")
}
Expand All @@ -87,7 +87,7 @@ func (msg MsgSubmitTx) ValidateBasic() error {
}

// GetSigners implements sdk.Msg
func (msg MsgSubmitTx) GetSigners() []sdk.AccAddress {
func (msg MsgSendTx) GetSigners() []sdk.AccAddress {
accAddr, err := sdk.AccAddressFromBech32(msg.Owner)
if err != nil {
panic(err)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,8 @@ func TestMsgRegisterAccountGetSigners(t *testing.T) {
require.Equal(t, []sdk.AccAddress{expSigner}, msg.GetSigners())
}

func TestMsgSubmitTxValidateBasic(t *testing.T) {
var msg *types.MsgSubmitTx
func TestMsgSendTxValidateBasic(t *testing.T) {
var msg *types.MsgSendTx

testCases := []struct {
name string
Expand Down Expand Up @@ -164,7 +164,7 @@ func TestMsgSubmitTxValidateBasic(t *testing.T) {
Data: data,
}

msg = types.NewMsgSubmitTx(
msg = types.NewMsgSendTx(
ibctesting.TestAccAddress,
ibctesting.FirstConnectionID,
clienttypes.ZeroHeight(),
Expand All @@ -183,7 +183,7 @@ func TestMsgSubmitTxValidateBasic(t *testing.T) {
}
}

func TestMsgSubmitTxGetSigners(t *testing.T) {
func TestMsgSendTxGetSigners(t *testing.T) {
expSigner, err := sdk.AccAddressFromBech32(ibctesting.TestAccAddress)
require.NoError(t, err)

Expand All @@ -201,7 +201,7 @@ func TestMsgSubmitTxGetSigners(t *testing.T) {
Data: data,
}

msg := types.NewMsgSubmitTx(
msg := types.NewMsgSendTx(
ibctesting.TestAccAddress,
ibctesting.FirstConnectionID,
clienttypes.ZeroHeight(),
Expand Down
Loading