Skip to content

Commit

Permalink
[CL] chore: abstract module package from keeper (#4075)
Browse files Browse the repository at this point in the history
* module package abstracted

* fixed linter
  • Loading branch information
stackman27 committed Jan 23, 2023
1 parent 08dc27b commit f26ceb9
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 11 deletions.
2 changes: 1 addition & 1 deletion app/keepers/modules.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion app/modules.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package concentrated_liquidity
package concentrated_liquidity_module

import (
"context"
Expand All @@ -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"
)

Expand Down Expand Up @@ -76,20 +81,20 @@ 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,
}
}

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) {
Expand Down Expand Up @@ -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),
// }
// }
6 changes: 3 additions & 3 deletions x/concentrated-liquidity/genesis_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand Down Expand Up @@ -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)
Expand All @@ -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)
})
}
17 changes: 17 additions & 0 deletions x/concentrated-liquidity/simulation/sim_msgs.go
Original file line number Diff line number Diff line change
@@ -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
// }

0 comments on commit f26ceb9

Please sign in to comment.