-
Notifications
You must be signed in to change notification settings - Fork 15
/
keeper.go
78 lines (64 loc) · 2.21 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
package keeper
import (
wasmtypes "github.com/CosmWasm/wasmd/x/wasm/types"
"github.com/cometbft/cometbft/libs/log"
"cosmossdk.io/math"
"github.com/cosmos/cosmos-sdk/codec"
storetypes "github.com/cosmos/cosmos-sdk/store/types"
sdktypes "github.com/cosmos/cosmos-sdk/types"
paramtypes "github.com/cosmos/cosmos-sdk/x/params/types"
"github.com/burnt-labs/xion/x/xion/types"
)
type Keeper struct {
cdc codec.BinaryCodec
storeKey storetypes.StoreKey
paramSpace paramtypes.Subspace
bankKeeper types.BankKeeper
accountKeeper types.AccountKeeper
ContractOpsKeeper wasmtypes.ContractOpsKeeper
ContractViewKeeper wasmtypes.ViewKeeper
AAKeeper types.AbstractAccountKeeper
// the address capable of executing a MsgSetPlatformPercentage message.
// Typically, this should be the x/gov module account
authority string
}
func NewKeeper(cdc codec.BinaryCodec,
key storetypes.StoreKey,
paramSpace paramtypes.Subspace,
bankKeeper types.BankKeeper,
accountKeeper types.AccountKeeper,
wasmOpsKeeper wasmtypes.ContractOpsKeeper,
wasmViewKeeper wasmtypes.ViewKeeper,
aaKeeper types.AbstractAccountKeeper,
authority string,
) Keeper {
return Keeper{
storeKey: key,
cdc: cdc,
paramSpace: paramSpace,
bankKeeper: bankKeeper,
accountKeeper: accountKeeper,
ContractOpsKeeper: wasmOpsKeeper,
ContractViewKeeper: wasmViewKeeper,
AAKeeper: aaKeeper,
authority: authority,
}
}
// Logger returns a module-specific logger.
func (k Keeper) Logger(ctx sdktypes.Context) log.Logger {
return ctx.Logger().With("module", "x/"+types.ModuleName)
}
// Platform Percentage
func (k Keeper) GetPlatformPercentage(ctx sdktypes.Context) math.Int {
bz := ctx.KVStore(k.storeKey).Get(types.PlatformPercentageKey)
percentage := sdktypes.BigEndianToUint64(bz)
return math.NewIntFromUint64(percentage)
}
func (k Keeper) OverwritePlatformPercentage(ctx sdktypes.Context, percentage uint32) {
ctx.KVStore(k.storeKey).Set(types.PlatformPercentageKey, sdktypes.Uint64ToBigEndian(uint64(percentage)))
}
// Authority
// GetAuthority returns the x/xion module's authority.
func (k Keeper) GetAuthority() string {
return k.authority
}