-
Notifications
You must be signed in to change notification settings - Fork 4
/
keeper.go
37 lines (31 loc) · 1.17 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
package keeper
import (
"fmt"
"github.com/cosmos/cosmos-sdk/codec"
storetypes "github.com/cosmos/cosmos-sdk/store/types"
sdk "github.com/cosmos/cosmos-sdk/types"
paramtypes "github.com/cosmos/cosmos-sdk/x/params/types"
"github.com/tendermint/tendermint/libs/log"
"github.com/unification-com/mainchain/x/wrkchain/types"
)
// Keeper maintains the link to data storage and exposes getter/setter methods for the various parts of the state machine
type Keeper struct {
storeKey storetypes.StoreKey // Unexposed key to access store from sdk.Context
paramSpace paramtypes.Subspace
cdc codec.BinaryCodec // The wire codec for binary encoding/decoding.
}
// NewKeeper creates new instances of the wrkchain Keeper
func NewKeeper(storeKey storetypes.StoreKey, paramSpace paramtypes.Subspace, cdc codec.BinaryCodec) Keeper {
return Keeper{
storeKey: storeKey,
paramSpace: paramSpace.WithKeyTable(types.ParamKeyTable()),
cdc: cdc,
}
}
// Logger returns a module-specific logger.
func (k Keeper) Logger(ctx sdk.Context) log.Logger {
return ctx.Logger().With("module", fmt.Sprintf("x/%s", types.ModuleName))
}
func (k Keeper) Cdc() codec.BinaryCodec {
return k.cdc
}