Skip to content

Commit

Permalink
fix: correctly generate simulation genesis (#6)
Browse files Browse the repository at this point in the history
* chore: init module

* chore: add protobuf tooling

* chore: add golang tooling

* chore: add test tooling

* chore: add release tooling

* fix: correctly generate simulation genesis
  • Loading branch information
johnletey committed Oct 23, 2023
1 parent 5c05160 commit 33b30a6
Showing 1 changed file with 46 additions and 7 deletions.
53 changes: 46 additions & 7 deletions x/fiattokenfactory/module_simulation.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 33b30a6

Please sign in to comment.