-
Notifications
You must be signed in to change notification settings - Fork 52
/
keeper.go
70 lines (62 loc) · 1.85 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
// Package keeper contains dao module keeper.
package keeper
import (
"fmt"
"github.com/cosmos/cosmos-sdk/codec"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/tendermint/tendermint/libs/log"
"github.com/onomyprotocol/onomy/x/dao/types"
)
type (
// Keeper is a dao keeper struct.
Keeper struct {
cdc codec.BinaryCodec
storeKey sdk.StoreKey
memKey sdk.StoreKey
ps types.ParamSubspace
bankKeeper types.BankKeeper
accountKeeper types.AccountKeeper
distributionKeeper types.DistributionKeeper
govKeeper types.GovKeeper
mintKeeper types.MintKeeper
stakingKeeper types.StakingKeeper
}
)
// NewKeeper creates new dao keeper.
func NewKeeper(
cdc codec.BinaryCodec,
storeKey,
memKey sdk.StoreKey,
ps types.ParamSubspace,
bankKeeper types.BankKeeper,
accountKeeper types.AccountKeeper,
distributionKeeper types.DistributionKeeper,
govKeeper types.GovKeeper,
mintKeeper types.MintKeeper,
stakingKeeper types.StakingKeeper,
) *Keeper {
// set KeyTable if it has not already been set
if !ps.HasKeyTable() {
ps = ps.WithKeyTable(types.ParamKeyTable())
}
// ensure dao module account is set
if addr := accountKeeper.GetModuleAddress(types.ModuleName); addr == nil {
panic(fmt.Sprintf("%s module account has not been set", types.ModuleName))
}
return &Keeper{
cdc: cdc,
storeKey: storeKey,
memKey: memKey,
ps: ps,
bankKeeper: bankKeeper,
accountKeeper: accountKeeper,
distributionKeeper: distributionKeeper,
govKeeper: govKeeper,
mintKeeper: mintKeeper,
stakingKeeper: stakingKeeper,
}
}
// Logger returns keeper logger.
func (k Keeper) Logger(ctx sdk.Context) log.Logger {
return ctx.Logger().With("module", fmt.Sprintf("x/%s", types.ModuleName))
}