From 33b30a6cf87eba20874df84fa93dd100f71ed512 Mon Sep 17 00:00:00 2001 From: John Letey Date: Mon, 23 Oct 2023 20:30:04 +0200 Subject: [PATCH] fix: correctly generate simulation genesis (#6) * chore: init module * chore: add protobuf tooling * chore: add golang tooling * chore: add test tooling * chore: add release tooling * fix: correctly generate simulation genesis --- x/fiattokenfactory/module_simulation.go | 53 +++++++++++++++++++++---- 1 file changed, 46 insertions(+), 7 deletions(-) diff --git a/x/fiattokenfactory/module_simulation.go b/x/fiattokenfactory/module_simulation.go index 72aafa9..d7edb3d 100644 --- a/x/fiattokenfactory/module_simulation.go +++ b/x/fiattokenfactory/module_simulation.go @@ -11,6 +11,8 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/module" simtypes "github.com/cosmos/cosmos-sdk/types/simulation" + authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" + banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" "github.com/cosmos/cosmos-sdk/x/simulation" ) @@ -83,14 +85,51 @@ const ( // GenerateGenesisState creates a randomized GenState of the module func (AppModule) GenerateGenesisState(simState *module.SimulationState) { - accs := make([]string, len(simState.Accounts)) - for i, acc := range simState.Accounts { - accs[i] = acc.Address.String() - } - tokenfactoryGenesis := types.GenesisState{ - Params: types.DefaultParams(), + // x/fiattokenfactory + + genesis := types.GenesisState{ + MintersList: []types.Minters{ + { + Address: authtypes.NewModuleAddress("cctp").String(), + }, + }, + MinterControllerList: []types.MinterController{ + { + Minter: authtypes.NewModuleAddress("cctp").String(), + }, + }, + MintingDenom: &types.MintingDenom{Denom: "uusdc"}, } - simState.GenState[types.ModuleName] = simState.Cdc.MustMarshalJSON(&tokenfactoryGenesis) + + simState.GenState[types.ModuleName] = simState.Cdc.MustMarshalJSON(&genesis) + + // x/bank + + bankGenesisBz := simState.GenState[banktypes.ModuleName] + var bankGenesis banktypes.GenesisState + simState.Cdc.MustUnmarshalJSON(bankGenesisBz, &bankGenesis) + + bankGenesis.DenomMetadata = append(bankGenesis.DenomMetadata, banktypes.Metadata{ + Description: "USD Coin", + DenomUnits: []*banktypes.DenomUnit{ + { + Denom: "uusdc", + Exponent: 0, + Aliases: []string{"microusdc"}, + }, + { + Denom: "usdc", + Exponent: 6, + Aliases: []string{}, + }, + }, + Base: "uusdc", + Display: "usdc", + Name: "usdc", + Symbol: "USDC", + }) + + simState.GenState[banktypes.ModuleName] = simState.Cdc.MustMarshalJSON(&bankGenesis) } // ProposalContents doesn't return any content functions for governance proposals