From f26ceb958adaaf31510e17ed88f5eab47e2bac03 Mon Sep 17 00:00:00 2001 From: Sishir Giri Date: Mon, 23 Jan 2023 02:14:44 -0800 Subject: [PATCH] [CL] chore: abstract module package from keeper (#4075) * module package abstracted * fixed linter --- app/keepers/modules.go | 2 +- app/modules.go | 2 +- .../{ => clmodule}/module.go | 35 +++++++++++++++---- x/concentrated-liquidity/genesis_test.go | 6 ++-- .../simulation/sim_msgs.go | 17 +++++++++ 5 files changed, 51 insertions(+), 11 deletions(-) rename x/concentrated-liquidity/{ => clmodule}/module.go (73%) create mode 100644 x/concentrated-liquidity/simulation/sim_msgs.go diff --git a/app/keepers/modules.go b/app/keepers/modules.go index 4e8c4c39585..c5e5813f0ee 100644 --- a/app/keepers/modules.go +++ b/app/keepers/modules.go @@ -28,7 +28,7 @@ import ( ica "github.com/cosmos/ibc-go/v4/modules/apps/27-interchain-accounts" _ "github.com/osmosis-labs/osmosis/v14/client/docs/statik" - concentratedliquidity "github.com/osmosis-labs/osmosis/v14/x/concentrated-liquidity" + concentratedliquidity "github.com/osmosis-labs/osmosis/v14/x/concentrated-liquidity/clmodule" downtimemodule "github.com/osmosis-labs/osmosis/v14/x/downtime-detector/module" "github.com/osmosis-labs/osmosis/v14/x/epochs" "github.com/osmosis-labs/osmosis/v14/x/gamm" diff --git a/app/modules.go b/app/modules.go index 37f985943a7..aa0e294c619 100644 --- a/app/modules.go +++ b/app/modules.go @@ -55,7 +55,7 @@ import ( appparams "github.com/osmosis-labs/osmosis/v14/app/params" _ "github.com/osmosis-labs/osmosis/v14/client/docs/statik" "github.com/osmosis-labs/osmosis/v14/simulation/simtypes" - concentratedliquidity "github.com/osmosis-labs/osmosis/v14/x/concentrated-liquidity" + concentratedliquidity "github.com/osmosis-labs/osmosis/v14/x/concentrated-liquidity/clmodule" concentratedliquiditytypes "github.com/osmosis-labs/osmosis/v14/x/concentrated-liquidity/types" "github.com/osmosis-labs/osmosis/v14/x/epochs" epochstypes "github.com/osmosis-labs/osmosis/v14/x/epochs/types" diff --git a/x/concentrated-liquidity/module.go b/x/concentrated-liquidity/clmodule/module.go similarity index 73% rename from x/concentrated-liquidity/module.go rename to x/concentrated-liquidity/clmodule/module.go index d7fd989671a..9da506bfb3f 100644 --- a/x/concentrated-liquidity/module.go +++ b/x/concentrated-liquidity/clmodule/module.go @@ -1,4 +1,4 @@ -package concentrated_liquidity +package concentrated_liquidity_module import ( "context" @@ -16,8 +16,13 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/module" + "github.com/osmosis-labs/osmosis/v14/simulation/simtypes" "github.com/osmosis-labs/osmosis/v14/x/concentrated-liquidity/client/cli" clmodel "github.com/osmosis-labs/osmosis/v14/x/concentrated-liquidity/model" + + // simulation "github.com/osmosis-labs/osmosis/v14/x/concentrated-liquidity/simulation" + + clkeeper "github.com/osmosis-labs/osmosis/v14/x/concentrated-liquidity" "github.com/osmosis-labs/osmosis/v14/x/concentrated-liquidity/types" ) @@ -76,10 +81,10 @@ func (AppModuleBasic) RegisterInterfaces(registry codectypes.InterfaceRegistry) type AppModule struct { AppModuleBasic - keeper Keeper + keeper clkeeper.Keeper } -func NewAppModule(cdc codec.Codec, keeper Keeper) AppModule { +func NewAppModule(cdc codec.Codec, keeper clkeeper.Keeper) AppModule { return AppModule{ AppModuleBasic: AppModuleBasic{cdc: cdc}, keeper: keeper, @@ -87,9 +92,9 @@ func NewAppModule(cdc codec.Codec, keeper Keeper) AppModule { } func (am AppModule) RegisterServices(cfg module.Configurator) { - types.RegisterMsgServer(cfg.MsgServer(), NewMsgServerImpl(&am.keeper)) - clmodel.RegisterMsgCreatorServer(cfg.MsgServer(), NewMsgCreatorServerImpl(&am.keeper)) - types.RegisterQueryServer(cfg.QueryServer(), NewQuerier(am.keeper)) + types.RegisterMsgServer(cfg.MsgServer(), clkeeper.NewMsgServerImpl(&am.keeper)) + clmodel.RegisterMsgCreatorServer(cfg.MsgServer(), clkeeper.NewMsgCreatorServerImpl(&am.keeper)) + types.RegisterQueryServer(cfg.QueryServer(), clkeeper.NewQuerier(am.keeper)) } func (am AppModule) RegisterInvariants(ir sdk.InvariantRegistry) { @@ -138,3 +143,21 @@ func (am AppModule) EndBlock(ctx sdk.Context, _ abci.RequestEndBlock) []abci.Val // ConsensusVersion implements AppModule/ConsensusVersion. func (AppModule) ConsensusVersion() uint64 { return 1 } + +// ___________________________________________________________________________ + +// AppModuleSimulation functions + +// GenerateGenesisState creates a randomized GenState of the valset module. +func (am AppModule) GenerateGenesisState(simState *module.SimulationState, s *simtypes.SimCtx) { +} + +// WeightedOperations returns the all the valset module operations with their respective weights. +// func (am AppModule) Actions() []simtypes.Action { +// return []simtypes.Action{ +// simtypes.NewMsgBasedAction("CreateConcentratedPool", am.keeper, simulation.RandomMsgCreateConcentratedPool), +// simtypes.NewMsgBasedAction("CreatePosition", am.keeper, simulation.RandMsgCreatePosition), +// simtypes.NewMsgBasedAction("WithdrawPositioj", am.keeper, simulation.RandMsgWithdrawPosition), +// simtypes.NewMsgBasedAction("CollectFees", am.keeper, simulation.RandMsgCollectFees), +// } +// } diff --git a/x/concentrated-liquidity/genesis_test.go b/x/concentrated-liquidity/genesis_test.go index 37521594807..b7a0842c311 100644 --- a/x/concentrated-liquidity/genesis_test.go +++ b/x/concentrated-liquidity/genesis_test.go @@ -12,7 +12,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" osmoapp "github.com/osmosis-labs/osmosis/v14/app" - cl "github.com/osmosis-labs/osmosis/v14/x/concentrated-liquidity" + clmodule "github.com/osmosis-labs/osmosis/v14/x/concentrated-liquidity/clmodule" "github.com/osmosis-labs/osmosis/v14/x/concentrated-liquidity/model" "github.com/osmosis-labs/osmosis/v14/x/concentrated-liquidity/types" ) @@ -99,7 +99,7 @@ func TestMarshalUnmarshalGenesis(t *testing.T) { // Create an app module for the ConcentratedLiquidityKeeper encodingConfig := osmoapp.MakeEncodingConfig() appCodec := encodingConfig.Marshaler - appModule := cl.NewAppModule(appCodec, *app.ConcentratedLiquidityKeeper) + appModule := clmodule.NewAppModule(appCodec, *app.ConcentratedLiquidityKeeper) // Export the genesis state genesisExported := appModule.ExportGenesis(ctx, appCodec) @@ -109,7 +109,7 @@ func TestMarshalUnmarshalGenesis(t *testing.T) { app := osmoapp.Setup(false) ctx := app.BaseApp.NewContext(false, tmproto.Header{}) ctx = ctx.WithBlockTime(now.Add(time.Second)) - am := cl.NewAppModule(appCodec, *app.ConcentratedLiquidityKeeper) + am := clmodule.NewAppModule(appCodec, *app.ConcentratedLiquidityKeeper) am.InitGenesis(ctx, appCodec, genesisExported) }) } diff --git a/x/concentrated-liquidity/simulation/sim_msgs.go b/x/concentrated-liquidity/simulation/sim_msgs.go new file mode 100644 index 00000000000..9cb1722b95e --- /dev/null +++ b/x/concentrated-liquidity/simulation/sim_msgs.go @@ -0,0 +1,17 @@ +package simulation + +// func RandomMsgCreateConcentratedPool(k clkeeper.Keeper, sim *osmosimtypes.SimCtx, ctx sdk.Context) (*clmodeltypes.MsgCreateConcentratedPool, error) { +// return nil, nil +// } + +// func RandMsgCreatePosition(k clkeeper.Keeper, sim *osmosimtypes.SimCtx, ctx sdk.Context) (*cltypes.MsgCreatePosition, error) { +// return nil, nil +// } + +// func RandMsgWithdrawPosition(k clkeeper.Keeper, sim *osmosimtypes.SimCtx, ctx sdk.Context) (*cltypes.MsgWithdrawPosition, error) { +// return nil, nil +// } + +// func RandMsgCollectFees(k clkeeper.Keeper, sim *osmosimtypes.SimCtx, ctx sdk.Context) (*cltypes.MsgCollectFees, error) { +// return nil, nil +// }