/
genesis.go
46 lines (36 loc) · 1.81 KB
/
genesis.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
// Copyright [2021] - [2022], AssetMantle Pte. Ltd. and the code contributors
// SPDX-License-Identifier: Apache-2.0
package simulator
import (
"math/rand"
sdkTypes "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/module"
"github.com/AssetMantle/modules/modules/metas/internal/common"
"github.com/AssetMantle/modules/modules/metas/internal/key"
"github.com/AssetMantle/modules/modules/metas/internal/mappable"
metasModule "github.com/AssetMantle/modules/modules/metas/internal/module"
"github.com/AssetMantle/modules/modules/metas/internal/parameters"
"github.com/AssetMantle/modules/modules/metas/internal/parameters/dummy"
"github.com/AssetMantle/modules/schema/data"
baseData "github.com/AssetMantle/modules/schema/data/base"
"github.com/AssetMantle/modules/schema/helpers"
baseHelpers "github.com/AssetMantle/modules/schema/helpers/base"
parameters2 "github.com/AssetMantle/modules/schema/parameters"
baseSimulation "github.com/AssetMantle/modules/simulation/schema/types/base"
)
func (simulator) RandomizedGenesisState(simulationState *module.SimulationState) {
var Data data.Data
simulationState.AppParams.GetOrGenerate(
simulationState.Cdc,
dummy.ID.String(),
&Data,
simulationState.Rand,
func(rand *rand.Rand) { Data = baseData.NewDecData(sdkTypes.NewDecWithPrec(int64(rand.Intn(99)), 2)) },
)
mappableList := make([]helpers.Mappable, simulationState.Rand.Intn(99))
for i := range mappableList {
mappableList[i] = mappable.NewMappable(baseSimulation.GenerateRandomData(simulationState.Rand))
}
genesisState := baseHelpers.NewGenesis(key.Prototype, mappable.Prototype, nil, parameters.Prototype().GetList()).Initialize(mappableList, []parameters2.Parameter{dummy.Parameter.Mutate(Data)})
simulationState.GenState[metasModule.Name] = common.Codec.MustMarshalJSON(genesisState)
}