-
Notifications
You must be signed in to change notification settings - Fork 3.6k
/
keeper.go
65 lines (56 loc) · 2.19 KB
/
keeper.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
package keeper
import (
"github.com/cosmos/cosmos-sdk/codec"
sdk "github.com/cosmos/cosmos-sdk/types"
capabilitykeeper "github.com/cosmos/cosmos-sdk/x/capability/keeper"
clientkeeper "github.com/cosmos/cosmos-sdk/x/ibc/core/02-client/keeper"
clienttypes "github.com/cosmos/cosmos-sdk/x/ibc/core/02-client/types"
connectionkeeper "github.com/cosmos/cosmos-sdk/x/ibc/core/03-connection/keeper"
channelkeeper "github.com/cosmos/cosmos-sdk/x/ibc/core/04-channel/keeper"
portkeeper "github.com/cosmos/cosmos-sdk/x/ibc/core/05-port/keeper"
porttypes "github.com/cosmos/cosmos-sdk/x/ibc/core/05-port/types"
"github.com/cosmos/cosmos-sdk/x/ibc/core/types"
paramtypes "github.com/cosmos/cosmos-sdk/x/params/types"
)
var _ types.QueryServer = (*Keeper)(nil)
// Keeper defines each ICS keeper for IBC
type Keeper struct {
// implements gRPC QueryServer interface
types.QueryServer
cdc codec.BinaryMarshaler
ClientKeeper clientkeeper.Keeper
ConnectionKeeper connectionkeeper.Keeper
ChannelKeeper channelkeeper.Keeper
PortKeeper portkeeper.Keeper
Router *porttypes.Router
}
// NewKeeper creates a new ibc Keeper
func NewKeeper(
cdc codec.BinaryMarshaler, key sdk.StoreKey, paramSpace paramtypes.Subspace,
stakingKeeper clienttypes.StakingKeeper, scopedKeeper capabilitykeeper.ScopedKeeper,
) *Keeper {
clientKeeper := clientkeeper.NewKeeper(cdc, key, paramSpace, stakingKeeper)
connectionKeeper := connectionkeeper.NewKeeper(cdc, key, clientKeeper)
portKeeper := portkeeper.NewKeeper(scopedKeeper)
channelKeeper := channelkeeper.NewKeeper(cdc, key, clientKeeper, connectionKeeper, portKeeper, scopedKeeper)
return &Keeper{
cdc: cdc,
ClientKeeper: clientKeeper,
ConnectionKeeper: connectionKeeper,
ChannelKeeper: channelKeeper,
PortKeeper: portKeeper,
}
}
// Codec returns the IBC module codec.
func (k Keeper) Codec() codec.BinaryMarshaler {
return k.cdc
}
// SetRouter sets the Router in IBC Keeper and seals it. The method panics if
// there is an existing router that's already sealed.
func (k *Keeper) SetRouter(rtr *porttypes.Router) {
if k.Router != nil && k.Router.Sealed() {
panic("cannot reset a sealed router")
}
k.Router = rtr
k.Router.Seal()
}