Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix custom staking keeper msg server issue with nil keeper #289

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions app/keepers/keepers.go
Original file line number Diff line number Diff line change
Expand Up @@ -185,15 +185,15 @@ func (appKeepers *AppKeepers) InitNormalKeepers(
appCodec, appKeepers.keys[stakingtypes.StoreKey], appKeepers.AccountKeeper, appKeepers.BankKeeper, authtypes.NewModuleAddress(govtypes.ModuleName).String(),
)

appKeepers.CustomStakingKeeper = customstaking.NewBaseKeeper(
appCodec /*appKeepers.keys[customstakingtypes.StoreKey],*/, *appKeepers.StakingKeeper, appKeepers.AccountKeeper, appKeepers.MintKeeper, authtypes.NewModuleAddress(govtypes.ModuleName).String(),
)

appKeepers.MintKeeper = mintkeeper.NewKeeper(
appCodec, appKeepers.keys[minttypes.StoreKey], appKeepers.StakingKeeper,
appKeepers.AccountKeeper, appKeepers.BankKeeper, authtypes.FeeCollectorName, authtypes.NewModuleAddress(govtypes.ModuleName).String(),
)

appKeepers.CustomStakingKeeper = customstaking.NewKeeper(
appCodec /*appKeepers.keys[stakingtypes.StoreKey],*/, *appKeepers.StakingKeeper, appKeepers.AccountKeeper, &appKeepers.MintKeeper, authtypes.NewModuleAddress(govtypes.ModuleName).String(),
)

appKeepers.DistrKeeper = distrkeeper.NewKeeper(
appCodec, appKeepers.keys[distrtypes.StoreKey], appKeepers.AccountKeeper, appKeepers.BankKeeper,
appKeepers.StakingKeeper, authtypes.FeeCollectorName, authtypes.NewModuleAddress(govtypes.ModuleName).String(),
Expand Down
10 changes: 4 additions & 6 deletions custom/staking/keeper/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package keeper

import (
"github.com/cosmos/cosmos-sdk/codec"
storetypes "github.com/cosmos/cosmos-sdk/store/types"
accountkeeper "github.com/cosmos/cosmos-sdk/x/auth/keeper"
stakingkeeper "github.com/cosmos/cosmos-sdk/x/staking/keeper"

Expand All @@ -12,9 +11,8 @@ import (
type Keeper struct {
stakingkeeper.Keeper
cdc codec.BinaryCodec
storeKey storetypes.StoreKey
acck accountkeeper.AccountKeeper
mintkeeper mintkeeper.Keeper
mintkeeper *mintkeeper.Keeper
authority string
}

Expand All @@ -33,19 +31,19 @@ type Keeper struct {
// return keeper
// }

func NewBaseKeeper(
func NewKeeper(
cdc codec.BinaryCodec,
// keys storetypes.StoreKey,
staking stakingkeeper.Keeper,
acck accountkeeper.AccountKeeper,
mintkeeper mintkeeper.Keeper,
mintkeeper *mintkeeper.Keeper,
authority string,
) Keeper {
keeper := Keeper{
Keeper: staking,
acck: acck,
authority: authority,
mintkeeper: mintkeeper,
cdc: cdc,
}
return keeper
}
Expand Down
4 changes: 2 additions & 2 deletions custom/staking/keeper/msg_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@

var _ types.MsgServer = msgServer{}

func NewMsgServerImpl(stakingKeeper stakingkeeper.Keeper) types.MsgServer {
return &msgServer{msgServer: stakingkeeper.NewMsgServerImpl(&stakingKeeper)}
func NewMsgServerImpl(stakingKeeper stakingkeeper.Keeper, customstakingkeeper Keeper) types.MsgServer {
return &msgServer{Keeper: customstakingkeeper, msgServer: stakingkeeper.NewMsgServerImpl(&stakingKeeper)}
}

func (k msgServer) CreateValidator(goCtx context.Context, msg *types.MsgCreateValidator) (*types.MsgCreateValidatorResponse, error) {
Expand All @@ -29,7 +29,7 @@
}

func (k msgServer) Delegate(goCtx context.Context, msg *types.MsgDelegate) (*types.MsgDelegateResponse, error) {

Check failure on line 32 in custom/staking/keeper/msg_server.go

View workflow job for this annotation

GitHub Actions / lint

File is not `gofumpt`-ed with `-extra` (gofumpt)
ctx := sdk.UnwrapSDKContext(goCtx)

// bondDenom := k.BondDenom(ctx)
Expand Down
2 changes: 1 addition & 1 deletion custom/staking/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
"github.com/cosmos/cosmos-sdk/types/module"
stakingmodule "github.com/cosmos/cosmos-sdk/x/staking"
"github.com/cosmos/cosmos-sdk/x/staking/exported"
"github.com/cosmos/cosmos-sdk/x/staking/keeper"

Check failure on line 10 in custom/staking/module.go

View workflow job for this annotation

GitHub Actions / lint

ST1019: package "github.com/cosmos/cosmos-sdk/x/staking/keeper" is being imported more than once (stylecheck)
stakingkeeper "github.com/cosmos/cosmos-sdk/x/staking/keeper"

Check failure on line 11 in custom/staking/module.go

View workflow job for this annotation

GitHub Actions / lint

ST1019(related information): other import of "github.com/cosmos/cosmos-sdk/x/staking/keeper" (stylecheck)
"github.com/cosmos/cosmos-sdk/x/staking/types"

// custombankkeeper "github.com/notional-labs/composable/v6/custom/bank/keeper"
Expand Down Expand Up @@ -37,7 +37,7 @@
// when trying to force this custom keeper into a bankkeeper.BaseKeeper
func (am AppModule) RegisterServices(cfg module.Configurator) {
// types.RegisterMsgServer(cfg.MsgServer(), keeper.NewMsgServerImpl(&am.keeper))
types.RegisterMsgServer(cfg.MsgServer(), customstakingkeeper.NewMsgServerImpl(am.keeper.Keeper))
types.RegisterMsgServer(cfg.MsgServer(), customstakingkeeper.NewMsgServerImpl(am.keeper.Keeper, am.keeper))
querier := keeper.Querier{Keeper: &am.keeper.Keeper}
types.RegisterQueryServer(cfg.QueryServer(), querier)

Expand Down
6 changes: 3 additions & 3 deletions x/mint/keeper/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ func (k Keeper) StoreDelegation(ctx sdk.Context, delegation stakingtypes.Delegat

// SetLastTotalPower Set the last total validator power.
func (k Keeper) SetLastTotalPower(ctx sdk.Context, power math.Int) {
// store := ctx.KVStore(k.storeKey)
// bz := k.cdc.MustMarshal(&sdk.IntProto{Int: power})
// store.Set(types.DelegationKey, bz)
store := ctx.KVStore(k.storeKey)
bz := k.cdc.MustMarshal(&sdk.IntProto{Int: power})
store.Set(types.DelegationKey, bz)
}
Loading