@@ -2,9 +2,10 @@ package keeper
2
2
3
3
import (
4
4
"context"
5
+ "fmt"
5
6
6
7
"cosmossdk.io/collections"
7
- "cosmossdk.io/core/store"
8
+ storetypes "cosmossdk.io/core/store"
8
9
"cosmossdk.io/log"
9
10
"cosmossdk.io/math"
10
11
@@ -14,25 +15,27 @@ import (
14
15
"github.com/axone-protocol/axoned/v8/x/mint/types"
15
16
)
16
17
17
- // Keeper of the mint store.
18
+ // Keeper of the mint store
18
19
type Keeper struct {
19
- cdc codec.BinaryCodec
20
- storeService store.KVStoreService
21
- // the address capable of executing a MsgUpdateParams message. Typically, this should be the x/gov module account.
22
- authority string
20
+ cdc codec.BinaryCodec
21
+ storeService storetypes.KVStoreService
23
22
stakingKeeper types.StakingKeeper
24
23
bankKeeper types.BankKeeper
25
24
feeCollectorName string
26
25
26
+ // the address capable of executing a MsgUpdateParams message. Typically, this
27
+ // should be the x/gov module account.
28
+ authority string
29
+
27
30
Schema collections.Schema
28
31
Params collections.Item [types.Params ]
29
32
Minter collections.Item [types.Minter ]
30
33
}
31
34
32
- // NewKeeper creates a new mint Keeper instance.
35
+ // NewKeeper creates a new mint Keeper instance
33
36
func NewKeeper (
34
37
cdc codec.BinaryCodec ,
35
- storeService store .KVStoreService ,
38
+ storeService storetypes .KVStoreService ,
36
39
sk types.StakingKeeper ,
37
40
ak types.AccountKeeper ,
38
41
bk types.BankKeeper ,
@@ -41,17 +44,17 @@ func NewKeeper(
41
44
) Keeper {
42
45
// ensure mint module account is set
43
46
if addr := ak .GetModuleAddress (types .ModuleName ); addr == nil {
44
- panic ("the mint module account has not been set" )
47
+ panic (fmt . Sprintf ( "the x/%s module account has not been set" , types . ModuleName ) )
45
48
}
46
49
47
50
sb := collections .NewSchemaBuilder (storeService )
48
51
k := Keeper {
49
52
cdc : cdc ,
50
53
storeService : storeService ,
51
- authority : authority ,
52
54
stakingKeeper : sk ,
53
55
bankKeeper : bk ,
54
56
feeCollectorName : feeCollectorName ,
57
+ authority : authority ,
55
58
Params : collections .NewItem (sb , types .ParamsKey , "params" , codec.CollValue [types.Params ](cdc )),
56
59
Minter : collections .NewItem (sb , types .MinterKey , "minter" , codec.CollValue [types.Minter ](cdc )),
57
60
}
@@ -61,17 +64,16 @@ func NewKeeper(
61
64
panic (err )
62
65
}
63
66
k .Schema = schema
64
-
65
67
return k
66
68
}
67
69
68
70
// GetAuthority returns the x/mint module's authority.
69
- func (keeper Keeper ) GetAuthority () string {
70
- return keeper .authority
71
+ func (k Keeper ) GetAuthority () string {
72
+ return k .authority
71
73
}
72
74
73
75
// Logger returns a module-specific logger.
74
- func (keeper Keeper ) Logger (ctx context.Context ) log.Logger {
76
+ func (k Keeper ) Logger (ctx context.Context ) log.Logger {
75
77
sdkCtx := sdk .UnwrapSDKContext (ctx )
76
78
return sdkCtx .Logger ().With ("module" , "x/" + types .ModuleName )
77
79
}
@@ -84,29 +86,29 @@ func (keeper Keeper) TokenSupply(ctx context.Context, denom string) math.Int {
84
86
85
87
// StakingTokenSupply implements an alias call to the underlying staking keeper's
86
88
// StakingTokenSupply to be used in BeginBlocker.
87
- func (keeper Keeper ) StakingTokenSupply (ctx context.Context ) (math.Int , error ) {
88
- return keeper .stakingKeeper .StakingTokenSupply (ctx )
89
+ func (k Keeper ) StakingTokenSupply (ctx context.Context ) (math.Int , error ) {
90
+ return k .stakingKeeper .StakingTokenSupply (ctx )
89
91
}
90
92
91
93
// BondedRatio implements an alias call to the underlying staking keeper's
92
94
// BondedRatio to be used in BeginBlocker.
93
- func (keeper Keeper ) BondedRatio (ctx context.Context ) (math.LegacyDec , error ) {
94
- return keeper .stakingKeeper .BondedRatio (ctx )
95
+ func (k Keeper ) BondedRatio (ctx context.Context ) (math.LegacyDec , error ) {
96
+ return k .stakingKeeper .BondedRatio (ctx )
95
97
}
96
98
97
99
// MintCoins implements an alias call to the underlying supply keeper's
98
100
// MintCoins to be used in BeginBlocker.
99
- func (keeper Keeper ) MintCoins (ctx context.Context , newCoins sdk.Coins ) error {
101
+ func (k Keeper ) MintCoins (ctx context.Context , newCoins sdk.Coins ) error {
100
102
if newCoins .Empty () {
101
103
// skip as no coins need to be minted
102
104
return nil
103
105
}
104
106
105
- return keeper .bankKeeper .MintCoins (ctx , types .ModuleName , newCoins )
107
+ return k .bankKeeper .MintCoins (ctx , types .ModuleName , newCoins )
106
108
}
107
109
108
110
// AddCollectedFees implements an alias call to the underlying supply keeper's
109
111
// AddCollectedFees to be used in BeginBlocker.
110
- func (keeper Keeper ) AddCollectedFees (ctx context.Context , fees sdk.Coins ) error {
111
- return keeper .bankKeeper .SendCoinsFromModuleToModule (ctx , types .ModuleName , keeper .feeCollectorName , fees )
112
+ func (k Keeper ) AddCollectedFees (ctx context.Context , fees sdk.Coins ) error {
113
+ return k .bankKeeper .SendCoinsFromModuleToModule (ctx , types .ModuleName , k .feeCollectorName , fees )
112
114
}
0 commit comments