From 734ff4b1a13e4fcb8df19f959fef876c51144bbb Mon Sep 17 00:00:00 2001 From: rustdev Date: Tue, 12 Dec 2023 23:35:23 +0000 Subject: [PATCH] substitute staking module --- app/app.go | 4 +++- app/keepers/keepers.go | 2 ++ custom/staking/module.go | 12 ++++++------ 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/app/app.go b/app/app.go index 37e064616..bdd0dcda2 100644 --- a/app/app.go +++ b/app/app.go @@ -76,6 +76,7 @@ import ( "github.com/cosmos/cosmos-sdk/x/slashing" slashingtypes "github.com/cosmos/cosmos-sdk/x/slashing/types" "github.com/cosmos/cosmos-sdk/x/staking" + stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" "github.com/cosmos/cosmos-sdk/x/upgrade" upgradeclient "github.com/cosmos/cosmos-sdk/x/upgrade/client" @@ -89,6 +90,7 @@ import ( ibcclientclient "github.com/cosmos/ibc-go/v7/modules/core/02-client/client" ibchost "github.com/cosmos/ibc-go/v7/modules/core/exported" ibckeeper "github.com/cosmos/ibc-go/v7/modules/core/keeper" + customstaking "github.com/notional-labs/composable/v6/custom/staking" "github.com/spf13/cast" icq "github.com/strangelove-ventures/async-icq/v7" icqtypes "github.com/strangelove-ventures/async-icq/v7/types" @@ -356,7 +358,7 @@ func NewComposableApp( mint.NewAppModule(appCodec, app.MintKeeper, app.AccountKeeper, nil), slashing.NewAppModule(appCodec, app.SlashingKeeper, app.AccountKeeper, app.BankKeeper, app.StakingKeeper, app.GetSubspace(slashingtypes.ModuleName)), distr.NewAppModule(appCodec, app.DistrKeeper, app.AccountKeeper, app.BankKeeper, app.StakingKeeper, app.GetSubspace(distrtypes.ModuleName)), - staking.NewAppModule(appCodec, app.StakingKeeper, app.AccountKeeper, app.BankKeeper, app.GetSubspace(stakingtypes.ModuleName)), + customstaking.NewAppModule(appCodec, *&app.Customstaking, app.AccountKeeper, app.BankKeeper, app.GetSubspace(stakingtypes.ModuleName)), authzmodule.NewAppModule(appCodec, app.AuthzKeeper, app.AccountKeeper, app.BankKeeper, app.interfaceRegistry), upgrade.NewAppModule(app.UpgradeKeeper), evidence.NewAppModule(app.EvidenceKeeper), diff --git a/app/keepers/keepers.go b/app/keepers/keepers.go index b1a36db04..a91b0664e 100644 --- a/app/keepers/keepers.go +++ b/app/keepers/keepers.go @@ -47,6 +47,7 @@ import ( stakingkeeper "github.com/cosmos/cosmos-sdk/x/staking/keeper" stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" + customstaking "github.com/notional-labs/composable/v6/custom/staking/keeper" "github.com/cosmos/cosmos-sdk/x/upgrade" upgradekeeper "github.com/cosmos/cosmos-sdk/x/upgrade/keeper" @@ -116,6 +117,7 @@ type AppKeepers struct { BankKeeper custombankkeeper.Keeper CapabilityKeeper *capabilitykeeper.Keeper StakingKeeper *stakingkeeper.Keeper + Customstaking customstaking.Keeper SlashingKeeper slashingkeeper.Keeper MintKeeper mintkeeper.Keeper DistrKeeper distrkeeper.Keeper diff --git a/custom/staking/module.go b/custom/staking/module.go index 48abb9f18..5697a6a58 100644 --- a/custom/staking/module.go +++ b/custom/staking/module.go @@ -18,13 +18,13 @@ import ( // AppModule wraps around the bank module and the bank keeper to return the right total supply type AppModule struct { stakingmodule.AppModule - keeper keeper.Keeper + keeper customstakingkeeper.Keeper subspace exported.Subspace } // NewAppModule creates a new AppModule object -func NewAppModule(cdc codec.Codec, keeper keeper.Keeper, accountKeeper types.AccountKeeper, bankKeeper types.BankKeeper, ss exported.Subspace) AppModule { - stakingModule := stakingmodule.NewAppModule(cdc, &keeper, accountKeeper, bankKeeper, ss) +func NewAppModule(cdc codec.Codec, keeper customstakingkeeper.Keeper, accountKeeper types.AccountKeeper, bankKeeper types.BankKeeper, ss exported.Subspace) AppModule { + stakingModule := stakingmodule.NewAppModule(cdc, &keeper.Keeper, accountKeeper, bankKeeper, ss) return AppModule{ AppModule: stakingModule, keeper: keeper, @@ -37,11 +37,11 @@ func NewAppModule(cdc codec.Codec, keeper keeper.Keeper, accountKeeper types.Acc // 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)) - querier := keeper.Querier{Keeper: &am.keeper} + types.RegisterMsgServer(cfg.MsgServer(), customstakingkeeper.NewMsgServerImpl(am.keeper.Keeper)) + querier := keeper.Querier{Keeper: &am.keeper.Keeper} types.RegisterQueryServer(cfg.QueryServer(), querier) - m := stakingkeeper.NewMigrator(&am.keeper, am.subspace) + m := stakingkeeper.NewMigrator(&am.keeper.Keeper, am.subspace) if err := cfg.RegisterMigration(types.ModuleName, 1, m.Migrate1to2); err != nil { panic(fmt.Sprintf("failed to migrate x/staking from version 1 to 2: %v", err)) }