2022-08-25 16:51:14 -07:00
|
|
|
package keeper
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
|
|
|
|
"github.com/tendermint/tendermint/libs/log"
|
|
|
|
|
|
|
|
"cosmos-test/x/cosmostest/types"
|
2022-08-31 23:09:36 -07:00
|
|
|
|
2022-08-25 16:51:14 -07:00
|
|
|
"github.com/cosmos/cosmos-sdk/codec"
|
|
|
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
|
|
|
paramtypes "github.com/cosmos/cosmos-sdk/x/params/types"
|
|
|
|
)
|
|
|
|
|
|
|
|
type (
|
|
|
|
Keeper struct {
|
|
|
|
cdc codec.BinaryCodec
|
|
|
|
storeKey sdk.StoreKey
|
|
|
|
memKey sdk.StoreKey
|
|
|
|
paramstore paramtypes.Subspace
|
2022-08-31 23:09:36 -07:00
|
|
|
bank types.BankKeeper
|
2022-08-25 16:51:14 -07:00
|
|
|
}
|
|
|
|
)
|
|
|
|
|
|
|
|
func NewKeeper(
|
|
|
|
cdc codec.BinaryCodec,
|
|
|
|
storeKey,
|
|
|
|
memKey sdk.StoreKey,
|
|
|
|
ps paramtypes.Subspace,
|
2022-08-31 23:09:36 -07:00
|
|
|
bank types.BankKeeper,
|
2022-08-25 16:51:14 -07:00
|
|
|
) *Keeper {
|
|
|
|
// set KeyTable if it has not already been set
|
|
|
|
if !ps.HasKeyTable() {
|
|
|
|
ps = ps.WithKeyTable(types.ParamKeyTable())
|
|
|
|
}
|
|
|
|
|
|
|
|
return &Keeper{
|
|
|
|
cdc: cdc,
|
|
|
|
storeKey: storeKey,
|
|
|
|
memKey: memKey,
|
|
|
|
paramstore: ps,
|
2022-08-31 23:09:36 -07:00
|
|
|
bank: bank,
|
2022-08-25 16:51:14 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func (k Keeper) Logger(ctx sdk.Context) log.Logger {
|
|
|
|
return ctx.Logger().With("module", fmt.Sprintf("x/%s", types.ModuleName))
|
|
|
|
}
|