Skip to content

Commit

Permalink
Add scoped keeper interface for interchain app (backport #2035) (#2361)
Browse files Browse the repository at this point in the history
* Add scoped keeper interface for interchain app (#2035)

## Description

Add scoped keeper interface for interchain app

Part of: #2020

---

Before we can merge this PR, please make sure that all the following items have been
checked off. If any of the checklist items are not applicable, please leave them but
write a little note why.

- [ ] Targeted PR against correct branch (see [CONTRIBUTING.md](https://github.com/cosmos/ibc-go/blob/master/CONTRIBUTING.md#pr-targeting))
- [ ] Linked to Github issue with discussion and accepted design OR link to spec that describes this work.
- [ ] Code follows the [module structure standards](https://github.com/cosmos/cosmos-sdk/blob/master/docs/building-modules/structure.md).
- [ ] Wrote unit and integration [tests](https://github.com/cosmos/ibc-go/blob/master/CONTRIBUTING.md#testing)
- [ ] Updated relevant documentation (`docs/`) or specification (`x/<module>/spec/`)
- [ ] Added relevant `godoc` [comments](https://blog.golang.org/godoc-documenting-go-code).
- [ ] Added a relevant changelog entry to the `Unreleased` section in `CHANGELOG.md`
- [ ] Re-reviewed `Files changed` in the Github PR explorer
- [ ] Review `Codecov Report` in the comment section below once CI passes

(cherry picked from commit af96d43)

# Conflicts:
#	CHANGELOG.md
#	modules/apps/27-interchain-accounts/controller/keeper/keeper.go
#	modules/apps/27-interchain-accounts/host/keeper/keeper.go

* resolving conflicts

Co-authored-by: Anmol <[email protected]>
Co-authored-by: Damian Nolan <[email protected]>
  • Loading branch information
3 people authored Sep 21, 2022
1 parent 8c11ca1 commit e4ff2c6
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 6 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ Ref: https://keepachangelog.com/en/1.0.0/
* (core/ante) [\#1820](https://github.com/cosmos/ibc-go/pull/1418) `RedundancyDecorator` has been renamed to `RedundantRelayDecorator` to make the name for explicit.
* (testing) [\#1418](https://github.com/cosmos/ibc-go/pull/1418) `MockIBCApp` has been renamed to `IBCApp` and `MockEmptyAcknowledgement` has been renamed to `EmptyAcknowledgement` to comply with go linting rules
* (apps/27-interchain-accounts) [\#2058](https://github.com/cosmos/ibc-go/pull/2058) Added `MessageRouter` interface and replaced `*baseapp.MsgServiceRouter` with it. The controller and host keepers of apps/27-interchain-accounts have been updated to use it.
* (apps/27-interchain-accounts) [\#2035](https://github.com/cosmos/ibc-go/pull/2035) Interchain accounts host and controller Keepers now expects a keeper which fulfills the expected `ScopedKeeper` interface for the capability keeper.

### State Machine Breaking

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ import (
"fmt"
"strings"

"github.com/cosmos/cosmos-sdk/baseapp"
"github.com/cosmos/cosmos-sdk/codec"
storetypes "github.com/cosmos/cosmos-sdk/store/types"
sdk "github.com/cosmos/cosmos-sdk/types"
capabilitykeeper "github.com/cosmos/cosmos-sdk/x/capability/keeper"
capabilitytypes "github.com/cosmos/cosmos-sdk/x/capability/types"
paramtypes "github.com/cosmos/cosmos-sdk/x/params/types"
"github.com/tendermint/tendermint/libs/log"
Expand All @@ -28,7 +28,7 @@ type Keeper struct {
channelKeeper icatypes.ChannelKeeper
portKeeper icatypes.PortKeeper

scopedKeeper capabilitykeeper.ScopedKeeper
scopedKeeper icatypes.ScopedKeeper

msgRouter icatypes.MessageRouter
}
Expand All @@ -37,7 +37,7 @@ type Keeper struct {
func NewKeeper(
cdc codec.BinaryCodec, key storetypes.StoreKey, paramSpace paramtypes.Subspace,
ics4Wrapper icatypes.ICS4Wrapper, channelKeeper icatypes.ChannelKeeper, portKeeper icatypes.PortKeeper,
scopedKeeper capabilitykeeper.ScopedKeeper, msgRouter icatypes.MessageRouter,
scopedKeeper icatypes.ScopedKeeper, msgRouter *baseapp.MsgServiceRouter,
) Keeper {
// set KeyTable if it has not already been set
if !paramSpace.HasKeyTable() {
Expand Down
6 changes: 3 additions & 3 deletions modules/apps/27-interchain-accounts/host/keeper/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ import (
"fmt"
"strings"

"github.com/cosmos/cosmos-sdk/baseapp"
"github.com/cosmos/cosmos-sdk/codec"
storetypes "github.com/cosmos/cosmos-sdk/store/types"
sdk "github.com/cosmos/cosmos-sdk/types"
capabilitykeeper "github.com/cosmos/cosmos-sdk/x/capability/keeper"
capabilitytypes "github.com/cosmos/cosmos-sdk/x/capability/types"
paramtypes "github.com/cosmos/cosmos-sdk/x/params/types"
"github.com/tendermint/tendermint/libs/log"
Expand All @@ -28,7 +28,7 @@ type Keeper struct {
portKeeper icatypes.PortKeeper
accountKeeper icatypes.AccountKeeper

scopedKeeper capabilitykeeper.ScopedKeeper
scopedKeeper icatypes.ScopedKeeper

msgRouter icatypes.MessageRouter
}
Expand All @@ -37,7 +37,7 @@ type Keeper struct {
func NewKeeper(
cdc codec.BinaryCodec, key storetypes.StoreKey, paramSpace paramtypes.Subspace,
channelKeeper icatypes.ChannelKeeper, portKeeper icatypes.PortKeeper,
accountKeeper icatypes.AccountKeeper, scopedKeeper capabilitykeeper.ScopedKeeper, msgRouter icatypes.MessageRouter,
accountKeeper icatypes.AccountKeeper, scopedKeeper icatypes.ScopedKeeper, msgRouter *baseapp.MsgServiceRouter,
) Keeper {
// ensure ibc interchain accounts module account is set
if addr := accountKeeper.GetModuleAddress(icatypes.ModuleName); addr == nil {
Expand Down
8 changes: 8 additions & 0 deletions modules/apps/27-interchain-accounts/types/expected_keepers.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,11 @@ type PortKeeper interface {
BindPort(ctx sdk.Context, portID string) *capabilitytypes.Capability
IsBound(ctx sdk.Context, portID string) bool
}

// ScopedKeeper defines the expected x/capability scoped keeper interface
type ScopedKeeper interface {
GetCapability(ctx sdk.Context, name string) (*capabilitytypes.Capability, bool)
AuthenticateCapability(ctx sdk.Context, cap *capabilitytypes.Capability, name string) bool
LookupModules(ctx sdk.Context, name string) ([]string, *capabilitytypes.Capability, error)
ClaimCapability(ctx sdk.Context, cap *capabilitytypes.Capability, name string) error
}

0 comments on commit e4ff2c6

Please sign in to comment.