diff --git a/app/app.go b/app/app.go index 0bce4540..c22a97ae 100644 --- a/app/app.go +++ b/app/app.go @@ -334,6 +334,7 @@ func NewApp(logger log.Logger, db dbm.DB, traceStore io.Writer, loadLatest bool, cdp.NewAppModule(app.cdpKeeper, app.pricefeedKeeper, app.supplyKeeper), // TODO how is the order be decided here? Is this order correct? pricefeed.NewAppModule(app.pricefeedKeeper), auction.NewAppModule(app.auctionKeeper, app.supplyKeeper), + bep3.NewAppModule(app.bep3Keeper, app.supplyKeeper), kavadist.NewAppModule(app.kavadistKeeper, app.supplyKeeper), ) diff --git a/x/bep3/module.go b/x/bep3/module.go index 65db1b6a..c11054c3 100644 --- a/x/bep3/module.go +++ b/x/bep3/module.go @@ -2,22 +2,26 @@ package bep3 import ( "encoding/json" + "math/rand" "github.com/cosmos/cosmos-sdk/client/context" "github.com/cosmos/cosmos-sdk/codec" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/module" + sim "github.com/cosmos/cosmos-sdk/x/simulation" "github.com/gorilla/mux" "github.com/spf13/cobra" abci "github.com/tendermint/tendermint/abci/types" "github.com/kava-labs/kava/x/bep3/client/cli" "github.com/kava-labs/kava/x/bep3/client/rest" + "github.com/kava-labs/kava/x/bep3/simulation" ) var ( - _ module.AppModule = AppModule{} - _ module.AppModuleBasic = AppModuleBasic{} + _ module.AppModule = AppModule{} + _ module.AppModuleBasic = AppModuleBasic{} + _ module.AppModuleSimulation = AppModuleSimulation{} ) // AppModuleBasic defines the basic application module used by the bep3 module. @@ -64,9 +68,32 @@ func (AppModuleBasic) GetQueryCmd(cdc *codec.Codec) *cobra.Command { return cli.GetQueryCmd(StoreKey, cdc) } +//____________________________________________________________________________ + +// AppModuleSimulation defines the module simulation functions used by the auction module. +type AppModuleSimulation struct{} + +// RegisterStoreDecoder registers a decoder for auction module's types +func (AppModuleSimulation) RegisterStoreDecoder(sdr sdk.StoreDecoderRegistry) { + sdr[StoreKey] = simulation.DecodeStore +} + +// GenerateGenesisState creates a randomized GenState of the auction module +func (AppModuleSimulation) GenerateGenesisState(simState *module.SimulationState) { + simulation.RandomizedGenState(simState) +} + +// RandomizedParams creates randomized auction param changes for the simulator. +func (AppModuleSimulation) RandomizedParams(r *rand.Rand) []sim.ParamChange { + return simulation.ParamChanges(r) +} + +//____________________________________________________________________________ + // AppModule implements the sdk.AppModule interface. type AppModule struct { AppModuleBasic + AppModuleSimulation keeper Keeper supplyKeeper SupplyKeeper diff --git a/x/bep3/simulation/decoder.go b/x/bep3/simulation/decoder.go new file mode 100644 index 00000000..6c35c157 --- /dev/null +++ b/x/bep3/simulation/decoder.go @@ -0,0 +1,12 @@ +package simulation + +import ( + "github.com/cosmos/cosmos-sdk/codec" + cmn "github.com/tendermint/tendermint/libs/common" +) + +// DecodeStore unmarshals the KVPair's Value to the module's corresponding type +func DecodeStore(cdc *codec.Codec, kvA, kvB cmn.KVPair) string { + // TODO implement this + return "" +} diff --git a/x/bep3/simulation/genesis.go b/x/bep3/simulation/genesis.go new file mode 100644 index 00000000..5daaab0e --- /dev/null +++ b/x/bep3/simulation/genesis.go @@ -0,0 +1,22 @@ +package simulation + +import ( + "fmt" + + "github.com/cosmos/cosmos-sdk/codec" + "github.com/cosmos/cosmos-sdk/types/module" + + "github.com/kava-labs/kava/x/bep3/types" +) + +// RandomizedGenState generates a random GenesisState +func RandomizedGenState(simState *module.SimulationState) { + + // TODO implement this fully + // - randomly generating the genesis params + // - overwriting with genesis provided to simulation + genesisState := types.DefaultGenesisState() + + fmt.Printf("Selected randomly generated %s parameters:\n%s\n", types.ModuleName, codec.MustMarshalJSONIndent(simState.Cdc, genesisState)) + simState.GenState[types.ModuleName] = simState.Cdc.MustMarshalJSON(genesisState) +} diff --git a/x/bep3/simulation/params.go b/x/bep3/simulation/params.go new file mode 100644 index 00000000..8c1f7aff --- /dev/null +++ b/x/bep3/simulation/params.go @@ -0,0 +1,14 @@ +package simulation + +import ( + "math/rand" + + "github.com/cosmos/cosmos-sdk/x/simulation" +) + +// ParamChanges defines the parameters that can be modified by param change proposals +// on the simulation +func ParamChanges(r *rand.Rand) []simulation.ParamChange { + // TODO implement this + return []simulation.ParamChange{} +}