-
Notifications
You must be signed in to change notification settings - Fork 7
/
keeper.go
50 lines (43 loc) · 1.64 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
package keeper
import (
"fmt"
"github.com/cosmos/cosmos-sdk/codec"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/x/params"
"github.com/anathatech/project-anatha/x/hra"
"github.com/anathatech/project-anatha/x/staking"
"github.com/cosmos/cosmos-sdk/x/supply"
"github.com/anathatech/project-anatha/x/distribution/internal/types"
"github.com/tendermint/tendermint/libs/log"
)
type Keeper struct {
cdc *codec.Codec
storeKey sdk.StoreKey
paramSpace params.Subspace
supplyKeeper supply.Keeper
stakingKeeper *staking.Keeper
HraKeeper *hra.Keeper
}
func NewKeeper(cdc *codec.Codec, key sdk.StoreKey, paramSpace params.Subspace, supplyKeeper supply.Keeper, stakingKeeper *staking.Keeper, hraKeeper *hra.Keeper) Keeper {
AccountMustBePresent(&supplyKeeper, types.AmcModuleName)
AccountMustBePresent(&supplyKeeper, types.NvrpModuleName)
AccountMustBePresent(&supplyKeeper, types.HRAHolderRewardModuleName)
AccountMustBePresent(&supplyKeeper, types.DevelopmentFundModuleName)
AccountMustBePresent(&supplyKeeper, types.SecurityTokenFundModuleName)
return Keeper{
cdc: cdc,
storeKey: key,
paramSpace: paramSpace.WithKeyTable(types.ParamKeyTable()),
supplyKeeper: supplyKeeper,
stakingKeeper: stakingKeeper,
HraKeeper: hraKeeper,
}
}
func (k Keeper) Logger(ctx sdk.Context) log.Logger {
return ctx.Logger().With("module", fmt.Sprintf("x/%s", types.ModuleName))
}
func AccountMustBePresent(supplyKeeper *supply.Keeper, accountName string) {
if addr := supplyKeeper.GetModuleAddress(accountName); addr == nil {
panic(fmt.Sprintf("the %s module account has not been set", accountName))
}
}