mirror of
https://github.com/0glabs/0g-chain.git
synced 2024-12-27 00:35:18 +00:00
Merge branch 'master' into develop
This commit is contained in:
commit
ac8787b6ed
@ -304,6 +304,9 @@ func NewApp(logger log.Logger, db dbm.DB, traceStore io.Writer, loadLatest bool,
|
|||||||
distr.NewAppModule(app.distrKeeper, app.supplyKeeper),
|
distr.NewAppModule(app.distrKeeper, app.supplyKeeper),
|
||||||
staking.NewAppModule(app.stakingKeeper, app.accountKeeper, app.supplyKeeper),
|
staking.NewAppModule(app.stakingKeeper, app.accountKeeper, app.supplyKeeper),
|
||||||
slashing.NewAppModule(app.slashingKeeper, app.stakingKeeper),
|
slashing.NewAppModule(app.slashingKeeper, app.stakingKeeper),
|
||||||
|
cdp.NewAppModule(app.cdpKeeper, app.pricefeedKeeper), // TODO how is the order be decided here? Is this order correct?
|
||||||
|
pricefeed.NewAppModule(app.pricefeedKeeper),
|
||||||
|
auction.NewAppModule(app.auctionKeeper, app.supplyKeeper),
|
||||||
)
|
)
|
||||||
|
|
||||||
app.sm.RegisterStoreDecoders()
|
app.sm.RegisterStoreDecoders()
|
||||||
|
@ -3,23 +3,28 @@ package auction
|
|||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"math/rand"
|
||||||
|
|
||||||
|
"github.com/gorilla/mux"
|
||||||
|
"github.com/spf13/cobra"
|
||||||
|
|
||||||
"github.com/cosmos/cosmos-sdk/client/context"
|
"github.com/cosmos/cosmos-sdk/client/context"
|
||||||
"github.com/cosmos/cosmos-sdk/codec"
|
"github.com/cosmos/cosmos-sdk/codec"
|
||||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||||
"github.com/cosmos/cosmos-sdk/types/module"
|
"github.com/cosmos/cosmos-sdk/types/module"
|
||||||
"github.com/gorilla/mux"
|
sim "github.com/cosmos/cosmos-sdk/x/simulation"
|
||||||
"github.com/spf13/cobra"
|
|
||||||
abci "github.com/tendermint/tendermint/abci/types"
|
abci "github.com/tendermint/tendermint/abci/types"
|
||||||
|
|
||||||
"github.com/kava-labs/kava/x/auction/client/cli"
|
"github.com/kava-labs/kava/x/auction/client/cli"
|
||||||
"github.com/kava-labs/kava/x/auction/client/rest"
|
"github.com/kava-labs/kava/x/auction/client/rest"
|
||||||
|
"github.com/kava-labs/kava/x/auction/simulation"
|
||||||
"github.com/kava-labs/kava/x/auction/types"
|
"github.com/kava-labs/kava/x/auction/types"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
_ module.AppModule = AppModule{}
|
_ module.AppModule = AppModule{}
|
||||||
_ module.AppModuleBasic = AppModuleBasic{}
|
_ module.AppModuleBasic = AppModuleBasic{}
|
||||||
|
_ module.AppModuleSimulation = AppModuleSimulation{}
|
||||||
)
|
)
|
||||||
|
|
||||||
// AppModuleBasic implements the sdk.AppModuleBasic interface.
|
// AppModuleBasic implements the sdk.AppModuleBasic interface.
|
||||||
@ -65,9 +70,32 @@ func (AppModuleBasic) GetQueryCmd(cdc *codec.Codec) *cobra.Command {
|
|||||||
return cli.GetQueryCmd(StoreKey, cdc)
|
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.
|
// AppModule implements the sdk.AppModule interface.
|
||||||
type AppModule struct {
|
type AppModule struct {
|
||||||
AppModuleBasic
|
AppModuleBasic
|
||||||
|
AppModuleSimulation
|
||||||
|
|
||||||
keeper Keeper
|
keeper Keeper
|
||||||
supplyKeeper types.SupplyKeeper
|
supplyKeeper types.SupplyKeeper
|
||||||
|
12
x/auction/simulation/decoder.go
Normal file
12
x/auction/simulation/decoder.go
Normal file
@ -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 corresponding auction type
|
||||||
|
func DecodeStore(cdc *codec.Codec, kvA, kvB cmn.KVPair) string {
|
||||||
|
// TODO implement this
|
||||||
|
return ""
|
||||||
|
}
|
22
x/auction/simulation/genesis.go
Normal file
22
x/auction/simulation/genesis.go
Normal file
@ -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/auction/types"
|
||||||
|
)
|
||||||
|
|
||||||
|
// RandomizedGenState generates a random GenesisState for auction
|
||||||
|
func RandomizedGenState(simState *module.SimulationState) {
|
||||||
|
|
||||||
|
// TODO implement this fully
|
||||||
|
// - randomly generating the genesis params
|
||||||
|
// - overwriting with genesis provided to simulation
|
||||||
|
auctionGenesis := types.DefaultGenesisState()
|
||||||
|
|
||||||
|
fmt.Printf("Selected randomly generated %s parameters:\n%s\n", types.ModuleName, codec.MustMarshalJSONIndent(simState.Cdc, auctionGenesis))
|
||||||
|
simState.GenState[types.ModuleName] = simState.Cdc.MustMarshalJSON(auctionGenesis)
|
||||||
|
}
|
14
x/auction/simulation/params.go
Normal file
14
x/auction/simulation/params.go
Normal file
@ -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{}
|
||||||
|
}
|
@ -78,6 +78,7 @@ var (
|
|||||||
ErrBelowDebtFloor = types.ErrBelowDebtFloor
|
ErrBelowDebtFloor = types.ErrBelowDebtFloor
|
||||||
ErrPaymentExceedsDebt = types.ErrPaymentExceedsDebt
|
ErrPaymentExceedsDebt = types.ErrPaymentExceedsDebt
|
||||||
ErrLoadingAugmentedCDP = types.ErrLoadingAugmentedCDP
|
ErrLoadingAugmentedCDP = types.ErrLoadingAugmentedCDP
|
||||||
|
NewGenesisState = types.NewGenesisState
|
||||||
DefaultGenesisState = types.DefaultGenesisState
|
DefaultGenesisState = types.DefaultGenesisState
|
||||||
GetCdpIDBytes = types.GetCdpIDBytes
|
GetCdpIDBytes = types.GetCdpIDBytes
|
||||||
GetCdpIDFromBytes = types.GetCdpIDFromBytes
|
GetCdpIDFromBytes = types.GetCdpIDFromBytes
|
||||||
|
@ -64,19 +64,26 @@ func InitGenesis(ctx sdk.Context, k Keeper, pk PricefeedKeeper, gs GenesisState)
|
|||||||
// ExportGenesis export genesis state for cdp module
|
// ExportGenesis export genesis state for cdp module
|
||||||
func ExportGenesis(ctx sdk.Context, k Keeper) GenesisState {
|
func ExportGenesis(ctx sdk.Context, k Keeper) GenesisState {
|
||||||
params := k.GetParams(ctx)
|
params := k.GetParams(ctx)
|
||||||
cdps := k.GetAllCdps(ctx)
|
|
||||||
|
cdps := CDPs{}
|
||||||
|
deposits := Deposits{}
|
||||||
|
k.IterateAllCdps(ctx, func(cdp CDP) (stop bool) {
|
||||||
|
cdps = append(cdps, cdp)
|
||||||
|
k.IterateDeposits(ctx, cdp.ID, func(deposit Deposit) (stop bool) {
|
||||||
|
deposits = append(deposits, deposit)
|
||||||
|
return false
|
||||||
|
})
|
||||||
|
return false
|
||||||
|
})
|
||||||
|
|
||||||
cdpID := k.GetNextCdpID(ctx)
|
cdpID := k.GetNextCdpID(ctx)
|
||||||
|
debtDenom := k.GetDebtDenom(ctx)
|
||||||
|
govDenom := k.GetGovDenom(ctx)
|
||||||
|
|
||||||
previousBlockTime, found := k.GetPreviousBlockTime(ctx)
|
previousBlockTime, found := k.GetPreviousBlockTime(ctx)
|
||||||
if !found {
|
if !found {
|
||||||
previousBlockTime = DefaultPreviousBlockTime
|
previousBlockTime = DefaultPreviousBlockTime
|
||||||
}
|
}
|
||||||
debtDenom := k.GetDebtDenom(ctx)
|
|
||||||
|
|
||||||
return GenesisState{
|
return NewGenesisState(params, cdps, deposits, cdpID, debtDenom, govDenom, previousBlockTime)
|
||||||
Params: params,
|
|
||||||
StartingCdpID: cdpID,
|
|
||||||
CDPs: cdps,
|
|
||||||
PreviousBlockTime: previousBlockTime,
|
|
||||||
DebtDenom: debtDenom,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,7 @@ package cdp
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
"math/rand"
|
||||||
|
|
||||||
"github.com/gorilla/mux"
|
"github.com/gorilla/mux"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
@ -10,15 +11,18 @@ import (
|
|||||||
"github.com/cosmos/cosmos-sdk/codec"
|
"github.com/cosmos/cosmos-sdk/codec"
|
||||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||||
"github.com/cosmos/cosmos-sdk/types/module"
|
"github.com/cosmos/cosmos-sdk/types/module"
|
||||||
|
sim "github.com/cosmos/cosmos-sdk/x/simulation"
|
||||||
abci "github.com/tendermint/tendermint/abci/types"
|
abci "github.com/tendermint/tendermint/abci/types"
|
||||||
|
|
||||||
"github.com/kava-labs/kava/x/cdp/client/cli"
|
"github.com/kava-labs/kava/x/cdp/client/cli"
|
||||||
"github.com/kava-labs/kava/x/cdp/client/rest"
|
"github.com/kava-labs/kava/x/cdp/client/rest"
|
||||||
|
"github.com/kava-labs/kava/x/cdp/simulation"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
_ module.AppModule = AppModule{}
|
_ module.AppModule = AppModule{}
|
||||||
_ module.AppModuleBasic = AppModuleBasic{}
|
_ module.AppModuleBasic = AppModuleBasic{}
|
||||||
|
_ module.AppModuleSimulation = AppModuleSimulation{}
|
||||||
)
|
)
|
||||||
|
|
||||||
// AppModuleBasic app module basics object
|
// AppModuleBasic app module basics object
|
||||||
@ -64,9 +68,33 @@ func (AppModuleBasic) GetQueryCmd(cdc *codec.Codec) *cobra.Command {
|
|||||||
return cli.GetQueryCmd(StoreKey, cdc)
|
return cli.GetQueryCmd(StoreKey, cdc)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//____________________________________________________________________________
|
||||||
|
|
||||||
|
// AppModuleSimulation defines the module simulation functions used by the cdp module.
|
||||||
|
type AppModuleSimulation struct{}
|
||||||
|
|
||||||
|
// RegisterStoreDecoder registers a decoder for cdp module's types
|
||||||
|
func (AppModuleSimulation) RegisterStoreDecoder(sdr sdk.StoreDecoderRegistry) {
|
||||||
|
sdr[StoreKey] = simulation.DecodeStore
|
||||||
|
}
|
||||||
|
|
||||||
|
// GenerateGenesisState creates a randomized GenState of the cdp module
|
||||||
|
func (AppModuleSimulation) GenerateGenesisState(simState *module.SimulationState) {
|
||||||
|
simulation.RandomizedGenState(simState)
|
||||||
|
}
|
||||||
|
|
||||||
|
// RandomizedParams creates randomized cdp param changes for the simulator.
|
||||||
|
func (AppModuleSimulation) RandomizedParams(r *rand.Rand) []sim.ParamChange {
|
||||||
|
return simulation.ParamChanges(r)
|
||||||
|
}
|
||||||
|
|
||||||
|
//____________________________________________________________________________
|
||||||
|
|
||||||
// AppModule app module type
|
// AppModule app module type
|
||||||
type AppModule struct {
|
type AppModule struct {
|
||||||
AppModuleBasic
|
AppModuleBasic
|
||||||
|
AppModuleSimulation
|
||||||
|
|
||||||
keeper Keeper
|
keeper Keeper
|
||||||
pricefeedKeeper PricefeedKeeper
|
pricefeedKeeper PricefeedKeeper
|
||||||
}
|
}
|
||||||
|
12
x/cdp/simulation/decoder.go
Normal file
12
x/cdp/simulation/decoder.go
Normal file
@ -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 corresponding cdp type
|
||||||
|
func DecodeStore(cdc *codec.Codec, kvA, kvB cmn.KVPair) string {
|
||||||
|
// TODO implement this
|
||||||
|
return ""
|
||||||
|
}
|
22
x/cdp/simulation/genesis.go
Normal file
22
x/cdp/simulation/genesis.go
Normal file
@ -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/cdp/types"
|
||||||
|
)
|
||||||
|
|
||||||
|
// RandomizedGenState generates a random GenesisState for cdp
|
||||||
|
func RandomizedGenState(simState *module.SimulationState) {
|
||||||
|
|
||||||
|
// TODO implement this fully
|
||||||
|
// - randomly generating the genesis params
|
||||||
|
// - overwriting with genesis provided to simulation
|
||||||
|
cdpGenesis := types.DefaultGenesisState()
|
||||||
|
|
||||||
|
fmt.Printf("Selected randomly generated %s parameters:\n%s\n", types.ModuleName, codec.MustMarshalJSONIndent(simState.Cdc, cdpGenesis))
|
||||||
|
simState.GenState[types.ModuleName] = simState.Cdc.MustMarshalJSON(cdpGenesis)
|
||||||
|
}
|
14
x/cdp/simulation/params.go
Normal file
14
x/cdp/simulation/params.go
Normal file
@ -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{}
|
||||||
|
}
|
@ -17,6 +17,19 @@ type GenesisState struct {
|
|||||||
PreviousBlockTime time.Time `json:"previous_block_time" yaml:"previous_block_time"`
|
PreviousBlockTime time.Time `json:"previous_block_time" yaml:"previous_block_time"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// NewGenesisState returns a new genesis state
|
||||||
|
func NewGenesisState(params Params, cdps CDPs, deposits Deposits, startingCdpID uint64, debtDenom, govDenom string, previousBlockTime time.Time) GenesisState {
|
||||||
|
return GenesisState{
|
||||||
|
Params: params,
|
||||||
|
CDPs: cdps,
|
||||||
|
Deposits: deposits,
|
||||||
|
StartingCdpID: startingCdpID,
|
||||||
|
DebtDenom: debtDenom,
|
||||||
|
GovDenom: govDenom,
|
||||||
|
PreviousBlockTime: previousBlockTime,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// DefaultGenesisState returns a default genesis state
|
// DefaultGenesisState returns a default genesis state
|
||||||
func DefaultGenesisState() GenesisState {
|
func DefaultGenesisState() GenesisState {
|
||||||
return GenesisState{
|
return GenesisState{
|
||||||
|
@ -48,8 +48,5 @@ func ExportGenesis(ctx sdk.Context, keeper Keeper) GenesisState {
|
|||||||
postedPrices = append(postedPrices, pp...)
|
postedPrices = append(postedPrices, pp...)
|
||||||
}
|
}
|
||||||
|
|
||||||
return GenesisState{
|
return NewGenesisState(params, postedPrices)
|
||||||
Params: params,
|
|
||||||
PostedPrices: postedPrices,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -2,23 +2,27 @@ package pricefeed
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
"math/rand"
|
||||||
|
|
||||||
"github.com/gorilla/mux"
|
"github.com/gorilla/mux"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
|
|
||||||
"github.com/cosmos/cosmos-sdk/client/context"
|
"github.com/cosmos/cosmos-sdk/client/context"
|
||||||
"github.com/cosmos/cosmos-sdk/codec"
|
"github.com/cosmos/cosmos-sdk/codec"
|
||||||
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||||
"github.com/cosmos/cosmos-sdk/types/module"
|
"github.com/cosmos/cosmos-sdk/types/module"
|
||||||
|
sim "github.com/cosmos/cosmos-sdk/x/simulation"
|
||||||
|
abci "github.com/tendermint/tendermint/abci/types"
|
||||||
|
|
||||||
"github.com/kava-labs/kava/x/pricefeed/client/cli"
|
"github.com/kava-labs/kava/x/pricefeed/client/cli"
|
||||||
"github.com/kava-labs/kava/x/pricefeed/client/rest"
|
"github.com/kava-labs/kava/x/pricefeed/client/rest"
|
||||||
|
"github.com/kava-labs/kava/x/pricefeed/simulation"
|
||||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
|
||||||
abci "github.com/tendermint/tendermint/abci/types"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
_ module.AppModule = AppModule{}
|
_ module.AppModule = AppModule{}
|
||||||
_ module.AppModuleBasic = AppModuleBasic{}
|
_ module.AppModuleBasic = AppModuleBasic{}
|
||||||
|
_ module.AppModuleSimulation = AppModuleSimulation{}
|
||||||
)
|
)
|
||||||
|
|
||||||
// AppModuleBasic app module basics object
|
// AppModuleBasic app module basics object
|
||||||
@ -64,9 +68,33 @@ func (AppModuleBasic) GetQueryCmd(cdc *codec.Codec) *cobra.Command {
|
|||||||
return cli.GetQueryCmd(StoreKey, cdc)
|
return cli.GetQueryCmd(StoreKey, cdc)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//____________________________________________________________________________
|
||||||
|
|
||||||
|
// AppModuleSimulation defines the module simulation functions used by the pricefeed module.
|
||||||
|
type AppModuleSimulation struct{}
|
||||||
|
|
||||||
|
// RegisterStoreDecoder registers a decoder for pricefeed module's types
|
||||||
|
func (AppModuleSimulation) RegisterStoreDecoder(sdr sdk.StoreDecoderRegistry) {
|
||||||
|
sdr[StoreKey] = simulation.DecodeStore
|
||||||
|
}
|
||||||
|
|
||||||
|
// GenerateGenesisState creates a randomized GenState of the pricefeed module
|
||||||
|
func (AppModuleSimulation) GenerateGenesisState(simState *module.SimulationState) {
|
||||||
|
simulation.RandomizedGenState(simState)
|
||||||
|
}
|
||||||
|
|
||||||
|
// RandomizedParams creates randomized pricefeed param changes for the simulator.
|
||||||
|
func (AppModuleSimulation) RandomizedParams(r *rand.Rand) []sim.ParamChange {
|
||||||
|
return simulation.ParamChanges(r)
|
||||||
|
}
|
||||||
|
|
||||||
|
//____________________________________________________________________________
|
||||||
|
|
||||||
// AppModule app module type
|
// AppModule app module type
|
||||||
type AppModule struct {
|
type AppModule struct {
|
||||||
AppModuleBasic
|
AppModuleBasic
|
||||||
|
AppModuleSimulation
|
||||||
|
|
||||||
keeper Keeper
|
keeper Keeper
|
||||||
}
|
}
|
||||||
|
|
||||||
|
12
x/pricefeed/simulation/decoder.go
Normal file
12
x/pricefeed/simulation/decoder.go
Normal file
@ -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 corresponding pricefeed type
|
||||||
|
func DecodeStore(cdc *codec.Codec, kvA, kvB cmn.KVPair) string {
|
||||||
|
// TODO implement this
|
||||||
|
return ""
|
||||||
|
}
|
22
x/pricefeed/simulation/genesis.go
Normal file
22
x/pricefeed/simulation/genesis.go
Normal file
@ -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/pricefeed/types"
|
||||||
|
)
|
||||||
|
|
||||||
|
// RandomizedGenState generates a random GenesisState for pricefeed
|
||||||
|
func RandomizedGenState(simState *module.SimulationState) {
|
||||||
|
|
||||||
|
// TODO implement this fully
|
||||||
|
// - randomly generating the genesis params
|
||||||
|
// - overwriting with genesis provided to simulation
|
||||||
|
pricefeedGenesis := types.DefaultGenesisState()
|
||||||
|
|
||||||
|
fmt.Printf("Selected randomly generated %s parameters:\n%s\n", types.ModuleName, codec.MustMarshalJSONIndent(simState.Cdc, pricefeedGenesis))
|
||||||
|
simState.GenState[types.ModuleName] = simState.Cdc.MustMarshalJSON(pricefeedGenesis)
|
||||||
|
}
|
14
x/pricefeed/simulation/params.go
Normal file
14
x/pricefeed/simulation/params.go
Normal file
@ -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{}
|
||||||
|
}
|
@ -22,5 +22,5 @@ func InitGenesis(ctx sdk.Context, keeper Keeper, accountKeeper types.AccountKeep
|
|||||||
// ExportGenesis returns empty genesis state because auth exports all the genesis state we need.
|
// ExportGenesis returns empty genesis state because auth exports all the genesis state we need.
|
||||||
func ExportGenesis(ctx sdk.Context, keeper Keeper) types.GenesisState {
|
func ExportGenesis(ctx sdk.Context, keeper Keeper) types.GenesisState {
|
||||||
prevBlockTime := keeper.GetPreviousBlockTime(ctx)
|
prevBlockTime := keeper.GetPreviousBlockTime(ctx)
|
||||||
return GenesisState{PreviousBlockTime: prevBlockTime}
|
return NewGenesisState(prevBlockTime)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user