Skip to content

Commit

Permalink
chore: rename SubmitTx to SendTx (backport #2255) (#2262)
Browse files Browse the repository at this point in the history
* chore: rename `SubmitTx` to `SendTx` (#2255)

* updating naming of submit tx to send tx

* use struct embedding

(cherry picked from commit a4be561)

# Conflicts:
#	docs/ibc/proto-docs.md
#	modules/apps/27-interchain-accounts/controller/client/cli/cli.go
#	modules/apps/27-interchain-accounts/controller/keeper/msg_server.go
#	modules/apps/27-interchain-accounts/controller/keeper/msg_server_test.go
#	modules/apps/27-interchain-accounts/controller/types/codec.go
#	modules/apps/27-interchain-accounts/controller/types/tx.pb.go
#	proto/ibc/applications/interchain_accounts/controller/v1/tx.proto

* fix conflicts

* chore: fixing test failures

Co-authored-by: Damian Nolan <[email protected]>
Co-authored-by: crodriguezvega <[email protected]>
Co-authored-by: Cian Hatton <[email protected]>
  • Loading branch information
4 people authored Sep 16, 2022
1 parent b6418c6 commit 1b103bd
Show file tree
Hide file tree
Showing 10 changed files with 150 additions and 150 deletions.
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)
- [MsgRegisterInterchainAccount](#ibc.applications.interchain_accounts.controller.v1.MsgRegisterInterchainAccount)
- [MsgRegisterInterchainAccountResponse](#ibc.applications.interchain_accounts.controller.v1.MsgRegisterInterchainAccountResponse)
- [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 @@ -1617,7 +1617,7 @@ host
<a name="ibc.applications.interchain_accounts.controller.v1.MsgRegisterInterchainAccount"></a>

### MsgRegisterInterchainAccount
MsgRegisterInterchainAccount defines the payload for Msg/RegisterAccount
MsgRegisterInterchainAccount defines the payload for Msg/MsgRegisterInterchainAccount


| Field | Type | Label | Description |
Expand All @@ -1634,7 +1634,7 @@ MsgRegisterInterchainAccount defines the payload for Msg/RegisterAccount
<a name="ibc.applications.interchain_accounts.controller.v1.MsgRegisterInterchainAccountResponse"></a>

### MsgRegisterInterchainAccountResponse
MsgRegisterInterchainAccountResponse defines the response for Msg/RegisterAccount
MsgRegisterInterchainAccountResponse defines the response for Msg/MsgRegisterInterchainAccountResponse


| Field | Type | Label | Description |
Expand All @@ -1646,10 +1646,10 @@ MsgRegisterInterchainAccountResponse defines the response for Msg/RegisterAccoun



<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 @@ -1665,10 +1665,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 @@ -1694,7 +1694,7 @@ Msg defines the 27-interchain-accounts/controller Msg service.
| Method Name | Request Type | Response Type | Description | HTTP Verb | Endpoint |
| ----------- | ------------ | ------------- | ------------| ------- | -------- |
| `RegisterInterchainAccount` | [MsgRegisterInterchainAccount](#ibc.applications.interchain_accounts.controller.v1.MsgRegisterInterchainAccount) | [MsgRegisterInterchainAccountResponse](#ibc.applications.interchain_accounts.controller.v1.MsgRegisterInterchainAccountResponse) | RegisterInterchainAccount defines a rpc handler for MsgRegisterInterchainAccount. | |
| `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
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ func NewTxCmd() *cobra.Command {

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

return cmd
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,10 @@ the associated capability.`),
return cmd
}

func newSubmitTxCmd() *cobra.Command {
func newSendTxCmd() *cobra.Command {
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 @@ -108,7 +108,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 @@ -25,15 +25,15 @@ func NewMsgServerImpl(keeper *Keeper) types.MsgServer {
}

// RegisterInterchainAccount defines a rpc handler for MsgRegisterInterchainAccount
func (k msgServer) RegisterInterchainAccount(goCtx context.Context, msg *types.MsgRegisterInterchainAccount) (*types.MsgRegisterInterchainAccountResponse, error) {
func (s msgServer) RegisterInterchainAccount(goCtx context.Context, msg *types.MsgRegisterInterchainAccount) (*types.MsgRegisterInterchainAccountResponse, error) {
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.registerInterchainAccount(ctx, msg.ConnectionId, portID, msg.Version)
if err != nil {
return nil, err
}
Expand All @@ -43,29 +43,29 @@ func (k msgServer) RegisterInterchainAccount(goCtx context.Context, msg *types.M
}, 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 @@ -98,7 +98,7 @@ func (suite *KeeperTestSuite) TestRegisterInterchainAccount_MsgServer() {
func (suite *KeeperTestSuite) TestSubmitTx() {
var (
path *ibctesting.Path
msg *controllertypes.MsgSubmitTx
msg *controllertypes.MsgSendTx
)

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

msg = controllertypes.NewMsgSubmitTx(owner, connectionID, clienttypes.ZeroHeight(), timeoutTimestamp, packetData)
msg = controllertypes.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),
&MsgRegisterInterchainAccount{},
&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 MsgRegisterInterchainAccount) 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 TestMsgRegisterInterchainAccountGetSigners(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

0 comments on commit 1b103bd

Please sign in to comment.