Skip to content

Commit c043dbd

Browse files
authored
imp(api)!: make HasCapability private (#3303)
1 parent b26e928 commit c043dbd

File tree

11 files changed

+13
-39
lines changed

11 files changed

+13
-39
lines changed

docs/ibc/apps/bindports.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ Currently, ports must be bound on app initialization. In order to bind modules t
7979

8080
// Only try to bind to port if it is not already bound, since we may already own
8181
// port capability from capability InitGenesis
82-
if !k.HasCapability(ctx, state.PortId) {
82+
if !k.hasCapability(ctx, state.PortId) {
8383
// transfer module binds to the transfer port on InitChain
8484
// and claims the returned capability
8585
err := k.BindPort(ctx, state.PortId)

docs/ibc/apps/keeper.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@ func NewKeeper(
4848
}
4949
}
5050

51-
// HasCapability checks if the IBC app module owns the port capability for the desired port
52-
func (k Keeper) HasCapability(ctx sdk.Context, portID string) bool {
51+
// hasCapability checks if the IBC app module owns the port capability for the desired port
52+
func (k Keeper) hasCapability(ctx sdk.Context, portID string) bool {
5353
_, ok := k.scopedKeeper.GetCapability(ctx, host.PortPath(portID))
5454
return ok
5555
}

modules/apps/27-interchain-accounts/controller/keeper/account.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ func (k Keeper) registerInterchainAccount(ctx sdk.Context, connectionID, portID,
5858
}
5959

6060
switch {
61-
case k.portKeeper.IsBound(ctx, portID) && !k.HasCapability(ctx, portID):
61+
case k.portKeeper.IsBound(ctx, portID) && !k.hasCapability(ctx, portID):
6262
return "", errorsmod.Wrapf(icatypes.ErrPortAlreadyBound, "another module has claimed capability for and bound port with portID: %s", portID)
6363
case !k.portKeeper.IsBound(ctx, portID):
6464
capability := k.BindPort(ctx, portID)

modules/apps/27-interchain-accounts/controller/keeper/genesis.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import (
1212
// InitGenesis initializes the interchain accounts controller application state from a provided genesis state
1313
func InitGenesis(ctx sdk.Context, keeper Keeper, state genesistypes.ControllerGenesisState) {
1414
for _, portID := range state.Ports {
15-
if !keeper.HasCapability(ctx, portID) {
15+
if !keeper.hasCapability(ctx, portID) {
1616
capability := keeper.BindPort(ctx, portID)
1717
if err := keeper.ClaimCapability(ctx, capability, host.PortPath(portID)); err != nil {
1818
panic(fmt.Sprintf("could not claim port capability: %v", err))

modules/apps/27-interchain-accounts/controller/keeper/keeper.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,8 @@ func (k Keeper) BindPort(ctx sdk.Context, portID string) *capabilitytypes.Capabi
9898
return k.portKeeper.BindPort(ctx, portID)
9999
}
100100

101-
// HasCapability checks if the interchain account controller module owns the port capability for the desired port
102-
func (k Keeper) HasCapability(ctx sdk.Context, portID string) bool {
101+
// hasCapability checks if the interchain account controller module owns the port capability for the desired port
102+
func (k Keeper) hasCapability(ctx sdk.Context, portID string) bool {
103103
_, ok := k.scopedKeeper.GetCapability(ctx, host.PortPath(portID))
104104
return ok
105105
}

modules/apps/27-interchain-accounts/controller/keeper/keeper_test.go

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -102,19 +102,6 @@ func TestKeeperTestSuite(t *testing.T) {
102102
suite.Run(t, new(KeeperTestSuite))
103103
}
104104

105-
func (suite *KeeperTestSuite) TestHasCapability() {
106-
suite.SetupTest()
107-
108-
path := NewICAPath(suite.chainA, suite.chainB)
109-
suite.coordinator.SetupConnections(path)
110-
111-
err := SetupICAPath(path, TestOwnerAddress)
112-
suite.Require().NoError(err)
113-
114-
hasCapability := suite.chainA.GetSimApp().ICAControllerKeeper.HasCapability(suite.chainA.GetContext(), path.EndpointA.ChannelConfig.PortID)
115-
suite.Require().True(hasCapability)
116-
}
117-
118105
func (suite *KeeperTestSuite) TestGetAllPorts() {
119106
suite.SetupTest()
120107

modules/apps/27-interchain-accounts/host/keeper/genesis.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import (
1212

1313
// InitGenesis initializes the interchain accounts host application state from a provided genesis state
1414
func InitGenesis(ctx sdk.Context, keeper Keeper, state genesistypes.HostGenesisState) {
15-
if !keeper.HasCapability(ctx, state.Port) {
15+
if !keeper.hasCapability(ctx, state.Port) {
1616
capability := keeper.BindPort(ctx, state.Port)
1717
if err := keeper.ClaimCapability(ctx, capability, host.PortPath(state.Port)); err != nil {
1818
panic(fmt.Sprintf("could not claim port capability: %v", err))

modules/apps/27-interchain-accounts/host/keeper/keeper.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,8 @@ func (k Keeper) BindPort(ctx sdk.Context, portID string) *capabilitytypes.Capabi
7878
return k.portKeeper.BindPort(ctx, portID)
7979
}
8080

81-
// HasCapability checks if the interchain account host module owns the port capability for the desired port
82-
func (k Keeper) HasCapability(ctx sdk.Context, portID string) bool {
81+
// hasCapability checks if the interchain account host module owns the port capability for the desired port
82+
func (k Keeper) hasCapability(ctx sdk.Context, portID string) bool {
8383
_, ok := k.scopedKeeper.GetCapability(ctx, host.PortPath(portID))
8484
return ok
8585
}

modules/apps/27-interchain-accounts/host/keeper/keeper_test.go

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -102,19 +102,6 @@ func TestKeeperTestSuite(t *testing.T) {
102102
suite.Run(t, new(KeeperTestSuite))
103103
}
104104

105-
func (suite *KeeperTestSuite) TestHasCapability() {
106-
suite.SetupTest()
107-
108-
path := NewICAPath(suite.chainA, suite.chainB)
109-
suite.coordinator.SetupConnections(path)
110-
111-
err := SetupICAPath(path, TestOwnerAddress)
112-
suite.Require().NoError(err)
113-
114-
hasCapability := suite.chainB.GetSimApp().ICAHostKeeper.HasCapability(suite.chainB.GetContext(), path.EndpointB.ChannelConfig.PortID)
115-
suite.Require().True(hasCapability)
116-
}
117-
118105
func (suite *KeeperTestSuite) TestGetInterchainAccountAddress() {
119106
suite.SetupTest()
120107

modules/apps/transfer/keeper/genesis.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ func (k Keeper) InitGenesis(ctx sdk.Context, state types.GenesisState) {
1818

1919
// Only try to bind to port if it is not already bound, since we may already own
2020
// port capability from capability InitGenesis
21-
if !k.HasCapability(ctx, state.PortId) {
21+
if !k.hasCapability(ctx, state.PortId) {
2222
// transfer module binds to the transfer port on InitChain
2323
// and claims the returned capability
2424
err := k.BindPort(ctx, state.PortId)

0 commit comments

Comments
 (0)