Skip to content

Commit

Permalink
chore: rename SubmitTx to SendTx (#2255)
Browse files Browse the repository at this point in the history
* updating naming of submit tx to send tx

* use struct embedding
  • Loading branch information
damiannolan authored Sep 9, 2022
1 parent f8f226d commit a4be561
Show file tree
Hide file tree
Showing 10 changed files with 144 additions and 144 deletions.
18 changes: 9 additions & 9 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 @@ -1653,10 +1653,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 @@ -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 |
| ----------- | ------------ | ------------- | ------------| ------- | -------- |
| `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 @@ -96,7 +96,7 @@ func (suite *KeeperTestSuite) TestRegisterInterchainAccount_MsgServer() {
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),
&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 a4be561

Please sign in to comment.