-
Notifications
You must be signed in to change notification settings - Fork 40
/
keeper.go
85 lines (74 loc) · 2.92 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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
package keeper
import (
"fmt"
"github.com/cosmos/cosmos-sdk/codec"
sdk "github.com/cosmos/cosmos-sdk/types"
depositkeeper "github.com/sentinel-official/hub/x/deposit/keeper"
nodekeeper "github.com/sentinel-official/hub/x/node/keeper"
nodetypes "github.com/sentinel-official/hub/x/node/types"
plankeeper "github.com/sentinel-official/hub/x/plan/keeper"
providerkeeper "github.com/sentinel-official/hub/x/provider/keeper"
providertypes "github.com/sentinel-official/hub/x/provider/types"
sessionkeeper "github.com/sentinel-official/hub/x/session/keeper"
sessiontypes "github.com/sentinel-official/hub/x/session/types"
subscriptionkeeper "github.com/sentinel-official/hub/x/subscription/keeper"
subscriptiontypes "github.com/sentinel-official/hub/x/subscription/types"
"github.com/sentinel-official/hub/x/vpn/expected"
"github.com/sentinel-official/hub/x/vpn/types"
)
type Keeper struct {
Deposit depositkeeper.Keeper
Provider providerkeeper.Keeper
Node nodekeeper.Keeper
Plan plankeeper.Keeper
Subscription subscriptionkeeper.Keeper
Session sessionkeeper.Keeper
}
func NewKeeper(
cdc codec.BinaryCodec,
key sdk.StoreKey,
paramsKeeper expected.ParamsKeeper,
accountKeeper expected.AccountKeeper,
bankKeeper expected.BankKeeper,
distributionKeeper expected.DistributionKeeper,
feeCollectorName string,
) (k Keeper) {
k.Deposit = depositkeeper.NewKeeper(cdc, key)
k.Deposit.WithBankKeeper(bankKeeper)
k.Provider = providerkeeper.NewKeeper(
cdc, key, paramsKeeper.Subspace(fmt.Sprintf("%s/%s", types.ModuleName, providertypes.ModuleName)),
)
k.Provider.WithDistributionKeeper(distributionKeeper)
k.Node = nodekeeper.NewKeeper(
cdc, key, paramsKeeper.Subspace(fmt.Sprintf("%s/%s", types.ModuleName, nodetypes.ModuleName)),
)
k.Node.WithDistributionKeeper(distributionKeeper)
k.Node.WithProviderKeeper(&k.Provider)
k.Node.WithSubscriptionKeeper(&k.Subscription)
k.Plan = plankeeper.NewKeeper(cdc, key)
k.Plan.WithBankKeeper(bankKeeper)
k.Plan.WithProviderKeeper(&k.Provider)
k.Plan.WithNodeKeeper(&k.Node)
k.Plan.WithSubscriptionKeeper(&k.Subscription)
k.Subscription = subscriptionkeeper.NewKeeper(
cdc, key, paramsKeeper.Subspace(fmt.Sprintf("%s/%s", types.ModuleName, subscriptiontypes.ModuleName)),
feeCollectorName,
)
k.Subscription.WithBankKeeper(bankKeeper)
k.Subscription.WithDepositKeeper(&k.Deposit)
k.Subscription.WithProviderKeeper(&k.Provider)
k.Subscription.WithNodeKeeper(&k.Node)
k.Subscription.WithPlanKeeper(&k.Plan)
k.Subscription.WithSessionKeeper(&k.Session)
k.Session = sessionkeeper.NewKeeper(
cdc, key, paramsKeeper.Subspace(fmt.Sprintf("%s/%s", types.ModuleName, sessiontypes.ModuleName)),
feeCollectorName,
)
k.Session.WithAccountKeeper(accountKeeper)
k.Session.WithBankKeeper(bankKeeper)
k.Session.WithDepositKeeper(&k.Deposit)
k.Session.WithNodeKeeper(&k.Node)
k.Session.WithPlanKeeper(&k.Plan)
k.Session.WithSubscriptionKeeper(&k.Subscription)
return k
}