Skip to content

Commit

Permalink
chore: rename RegisterAccount rpc and msgs to `RegisterInterchainAc…
Browse files Browse the repository at this point in the history
…count` (#2253)

* adding msgServer struct to ics27 controller

* updating the RegisterAccount rpc and msgs to RegisterInterchainAccount, reodering fields

(cherry picked from commit f8f226d)

# Conflicts:
#	modules/apps/27-interchain-accounts/controller/client/cli/cli.go
#	modules/apps/27-interchain-accounts/controller/client/cli/tx.go
#	modules/apps/27-interchain-accounts/controller/keeper/msg_server.go
#	modules/apps/27-interchain-accounts/controller/keeper/msg_server_test.go
  • Loading branch information
damiannolan authored and mergify[bot] committed Sep 9, 2022
1 parent 550c692 commit 71257ef
Show file tree
Hide file tree
Showing 12 changed files with 199 additions and 156 deletions.
24 changes: 12 additions & 12 deletions docs/ibc/proto-docs.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,8 @@
- [Type](#ibc.applications.interchain_accounts.v1.Type)

- [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)
- [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)

Expand Down Expand Up @@ -1614,27 +1614,27 @@ host



<a name="ibc.applications.interchain_accounts.controller.v1.MsgRegisterAccount"></a>
<a name="ibc.applications.interchain_accounts.controller.v1.MsgRegisterInterchainAccount"></a>

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


| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| `connection_id` | [string](#string) | | |
| `owner` | [string](#string) | | |
| `connection_id` | [string](#string) | | |
| `version` | [string](#string) | | |






<a name="ibc.applications.interchain_accounts.controller.v1.MsgRegisterAccountResponse"></a>
<a name="ibc.applications.interchain_accounts.controller.v1.MsgRegisterInterchainAccountResponse"></a>

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


| Field | Type | Label | Description |
Expand Down Expand Up @@ -1693,7 +1693,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. | |
| `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. | |

<!-- end services -->
Expand Down Expand Up @@ -1743,8 +1743,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
21 changes: 21 additions & 0 deletions modules/apps/27-interchain-accounts/controller/client/cli/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,24 @@ func GetQueryCmd() *cobra.Command {

return queryCmd
}
<<<<<<< HEAD
=======

// NewTxCmd creates and returns the tx command
func NewTxCmd() *cobra.Command {
cmd := &cobra.Command{
Use: "controller",
Short: "ica controller transactions subcommands",
DisableFlagParsing: true,
SuggestionsMinimumDistance: 2,
RunE: client.ValidateCmd,
}

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

return cmd
}
>>>>>>> f8f226d (chore: rename `RegisterAccount` rpc and msgs to `RegisterInterchainAccount` (#2253))
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ const (
flagPacketTimeoutTimestamp = "packet-timeout-timestamp"
)

<<<<<<< HEAD
// NewTxCmd creates and returns the tx command
func NewTxCmd() *cobra.Command {
cmd := &cobra.Command{
Expand All @@ -42,6 +43,9 @@ func NewTxCmd() *cobra.Command {
}

func newRegisterAccountCmd() *cobra.Command {
=======
func newRegisterInterchainAccountCmd() *cobra.Command {
>>>>>>> f8f226d (chore: rename `RegisterAccount` rpc and msgs to `RegisterInterchainAccount` (#2253))
cmd := &cobra.Command{
Use: "register [connection-id]",
Short: "Register an interchain account on the provided connection.",
Expand All @@ -65,7 +69,7 @@ the associated capability.`),
return err
}

msg := types.NewMsgRegisterAccount(connectionID, owner, version)
msg := types.NewMsgRegisterInterchainAccount(connectionID, owner, version)

return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg)
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,13 @@ import (

var _ types.MsgServer = Keeper{}

<<<<<<< HEAD
// RegisterAccount defines a rpc handler for MsgRegisterAccount
func (k Keeper) RegisterAccount(goCtx context.Context, msg *types.MsgRegisterAccount) (*types.MsgRegisterAccountResponse, error) {
=======
// RegisterInterchainAccount defines a rpc handler for MsgRegisterInterchainAccount
func (k msgServer) RegisterInterchainAccount(goCtx context.Context, msg *types.MsgRegisterInterchainAccount) (*types.MsgRegisterInterchainAccountResponse, error) {
>>>>>>> f8f226d (chore: rename `RegisterAccount` rpc and msgs to `RegisterInterchainAccount` (#2253))
ctx := sdk.UnwrapSDKContext(goCtx)

portID, err := icatypes.NewControllerPortID(msg.Owner)
Expand All @@ -28,7 +33,7 @@ func (k Keeper) RegisterAccount(goCtx context.Context, msg *types.MsgRegisterAcc
return nil, err
}

return &types.MsgRegisterAccountResponse{
return &types.MsgRegisterInterchainAccountResponse{
ChannelId: channelID,
}, nil
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,13 @@ import (
ibctesting "github.com/cosmos/ibc-go/v5/testing"
)

func (suite *KeeperTestSuite) TestRegisterAccount() {
func (suite *KeeperTestSuite) TestRegisterInterchainAccount_MsgServer() {
var (
<<<<<<< HEAD
msg *controllertypes.MsgRegisterAccount
=======
msg *types.MsgRegisterInterchainAccount
>>>>>>> f8f226d (chore: rename `RegisterAccount` rpc and msgs to `RegisterInterchainAccount` (#2253))
expectedChannelID = "channel-0"
)
Expand Down Expand Up @@ -70,12 +74,21 @@ func (suite *KeeperTestSuite) TestRegisterAccount() {
path := NewICAPath(suite.chainA, suite.chainB)
suite.coordinator.SetupConnections(path)
<<<<<<< HEAD
msg = controllertypes.NewMsgRegisterAccount(ibctesting.FirstConnectionID, ibctesting.TestAccAddress, "")
=======
msg = types.NewMsgRegisterInterchainAccount(ibctesting.FirstConnectionID, ibctesting.TestAccAddress, "")
>>>>>>> f8f226d (chore: rename `RegisterAccount` rpc and msgs to `RegisterInterchainAccount` (#2253))
tc.malleate()
ctx := suite.chainA.GetContext()
<<<<<<< HEAD
res, err := suite.chainA.GetSimApp().ICAControllerKeeper.RegisterAccount(ctx, msg)
=======
msgServer := keeper.NewMsgServerImpl(&suite.chainA.GetSimApp().ICAControllerKeeper)
res, err := msgServer.RegisterInterchainAccount(ctx, msg)
>>>>>>> f8f226d (chore: rename `RegisterAccount` rpc and msgs to `RegisterInterchainAccount` (#2253))

if tc.expPass {
suite.Require().NoError(err)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
func RegisterInterfaces(registry codectypes.InterfaceRegistry) {
registry.RegisterImplementations(
(*sdk.Msg)(nil),
&MsgRegisterAccount{},
&MsgRegisterInterchainAccount{},
&MsgSubmitTx{},
)
}
12 changes: 6 additions & 6 deletions modules/apps/27-interchain-accounts/controller/types/msgs.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,19 @@ import (
host "github.com/cosmos/ibc-go/v5/modules/core/24-host"
)

var _ sdk.Msg = &MsgRegisterAccount{}
var _ sdk.Msg = &MsgRegisterInterchainAccount{}

// NewMsgRegisterAccount creates a new instance of MsgRegisterAccount
func NewMsgRegisterAccount(connectionID, owner, version string) *MsgRegisterAccount {
return &MsgRegisterAccount{
// NewMsgRegisterInterchainAccount creates a new instance of MsgRegisterInterchainAccount
func NewMsgRegisterInterchainAccount(connectionID, owner, version string) *MsgRegisterInterchainAccount {
return &MsgRegisterInterchainAccount{
ConnectionId: connectionID,
Owner: owner,
Version: version,
}
}

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

// GetSigners implements sdk.Msg
func (msg MsgRegisterAccount) GetSigners() []sdk.AccAddress {
func (msg MsgRegisterInterchainAccount) 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 @@ -15,8 +15,8 @@ import (
"github.com/cosmos/ibc-go/v5/testing/simapp"
)

func TestMsgRegisterAccountValidateBasic(t *testing.T) {
var msg *types.MsgRegisterAccount
func TestMsgRegisterInterchainAccountValidateBasic(t *testing.T) {
var msg *types.MsgRegisterInterchainAccount

testCases := []struct {
name string
Expand Down Expand Up @@ -73,7 +73,7 @@ func TestMsgRegisterAccountValidateBasic(t *testing.T) {

for i, tc := range testCases {

msg = types.NewMsgRegisterAccount(
msg = types.NewMsgRegisterInterchainAccount(
ibctesting.FirstConnectionID,
ibctesting.TestAccAddress,
icatypes.NewDefaultMetadataString(ibctesting.FirstConnectionID, ibctesting.FirstConnectionID),
Expand All @@ -90,11 +90,11 @@ func TestMsgRegisterAccountValidateBasic(t *testing.T) {
}
}

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

msg := types.NewMsgRegisterAccount(ibctesting.FirstConnectionID, ibctesting.TestAccAddress, "")
msg := types.NewMsgRegisterInterchainAccount(ibctesting.FirstConnectionID, ibctesting.TestAccAddress, "")
require.Equal(t, []sdk.AccAddress{expSigner}, msg.GetSigners())
}

Expand Down
Loading

0 comments on commit 71257ef

Please sign in to comment.