-
Notifications
You must be signed in to change notification settings - Fork 0
/
keeper.go
55 lines (48 loc) · 1.3 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
package keeper
import (
"github.com/cosmos/cosmos-sdk/codec"
sdk "github.com/cosmos/cosmos-sdk/types"
paramtypes "github.com/cosmos/cosmos-sdk/x/params/types"
stakingkeeper "github.com/cosmos/cosmos-sdk/x/staking/keeper"
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
"github.com/petri-labs/kaiju/x/staking/types"
)
type Keeper struct {
stakingkeeper.Keeper
storeKey sdk.StoreKey
cdc codec.BinaryCodec
bankKeeper stakingtypes.BankKeeper
nftKeeper types.NftKeeper
veKeeper types.VeKeeper
}
func NewKeeper(
cdc codec.BinaryCodec,
key sdk.StoreKey,
ps paramtypes.Subspace,
ak stakingtypes.AccountKeeper,
bk stakingtypes.BankKeeper,
nk types.NftKeeper,
vk types.VeKeeper,
) Keeper {
keeper := Keeper{
Keeper: stakingkeeper.NewKeeper(cdc, key, ak, bk, ps),
storeKey: key,
cdc: cdc,
bankKeeper: bk,
nftKeeper: nk,
veKeeper: vk,
}
keeper.veKeeper.SetGetDelegatedAmountByUser(func(ctx sdk.Context, veID uint64) sdk.Int {
return keeper.GetVeDelegatedAmount(ctx, veID)
})
return keeper
}
func (k *Keeper) SetHooks(sh stakingtypes.StakingHooks) *Keeper {
k.Keeper = *k.Keeper.SetHooks(sh)
return k
}
func (k *Keeper) CheckDenom(ctx sdk.Context) {
if k.veKeeper.LockDenom(ctx) != k.BondDenom(ctx) {
panic("bond denom is different from ve lock denom")
}
}