diff --git a/app/genesis.go b/app/genesis.go index 2e7a7fa..0a9a792 100644 --- a/app/genesis.go +++ b/app/genesis.go @@ -13,7 +13,6 @@ import ( ibctypes "github.com/cosmos/ibc-go/v7/modules/core/types" opchildtypes "github.com/initia-labs/OPinit/x/opchild/types" - "github.com/initia-labs/miniwasm/types" auctiontypes "github.com/skip-mev/block-sdk/x/auction/types" ) @@ -28,19 +27,19 @@ import ( type GenesisState map[string]json.RawMessage // NewDefaultGenesisState generates the default state for the application. -func NewDefaultGenesisState(cdc codec.JSONCodec, mbm module.BasicManager) GenesisState { +func NewDefaultGenesisState(cdc codec.JSONCodec, mbm module.BasicManager, denom string) GenesisState { return GenesisState(mbm.DefaultGenesis(cdc)). ConfigureMinGasPrices(cdc). ConfigureICA(cdc). ConfigureIBCAllowedClients(cdc). - ConfigureAuctionFee(cdc) + ConfigureAuctionFee(cdc, denom) } -func (genState GenesisState) ConfigureAuctionFee(cdc codec.JSONCodec) GenesisState { +func (genState GenesisState) ConfigureAuctionFee(cdc codec.JSONCodec, denom string) GenesisState { var auctionGenState auctiontypes.GenesisState cdc.MustUnmarshalJSON(genState[auctiontypes.ModuleName], &auctionGenState) - auctionGenState.Params.ReserveFee.Denom = types.BaseDenom - auctionGenState.Params.MinBidIncrement.Denom = types.BaseDenom + auctionGenState.Params.ReserveFee.Denom = denom + auctionGenState.Params.MinBidIncrement.Denom = denom genState[auctiontypes.ModuleName] = cdc.MustMarshalJSON(&auctionGenState) return genState diff --git a/app/test_helpers.go b/app/test_helpers.go index 3501a7d..30c9092 100644 --- a/app/test_helpers.go +++ b/app/test_helpers.go @@ -22,6 +22,7 @@ import ( banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" opchildtypes "github.com/initia-labs/OPinit/x/opchild/types" + "github.com/initia-labs/miniwasm/types" wasmkeeper "github.com/CosmWasm/wasmd/x/wasm/keeper" ) @@ -64,7 +65,7 @@ func setup(db *dbm.DB, withGenesis bool) (*MinitiaApp, GenesisState) { ) if withGenesis { - return app, NewDefaultGenesisState(encCdc.Marshaler, ModuleBasics) + return app, NewDefaultGenesisState(encCdc.Marshaler, ModuleBasics, types.BaseDenom) } return app, GenesisState{} @@ -78,6 +79,13 @@ func SetupWithGenesisAccounts( ) *MinitiaApp { app, genesisState := setup(nil, true) + if len(genAccs) == 0 { + privAcc := secp256k1.GenPrivKey() + genAccs = []authtypes.GenesisAccount{ + authtypes.NewBaseAccount(privAcc.PubKey().Address().Bytes(), privAcc.PubKey(), 0, 0), + } + } + // set genesis accounts authGenesis := authtypes.NewGenesisState(authtypes.DefaultParams(), genAccs) genesisState[authtypes.ModuleName] = app.AppCodec().MustMarshalJSON(authGenesis) @@ -94,13 +102,6 @@ func SetupWithGenesisAccounts( valSet = tmtypes.NewValidatorSet([]*tmtypes.Validator{validator}) } - if genAccs == nil || len(genAccs) == 0 { - privAcc := secp256k1.GenPrivKey() - genAccs = []authtypes.GenesisAccount{ - authtypes.NewBaseAccount(privAcc.PubKey().Address().Bytes(), privAcc.PubKey(), 0, 0), - } - } - validators := make([]opchildtypes.Validator, 0, len(valSet.Validators)) for _, val := range valSet.Validators { diff --git a/cmd/minitiad/init.go b/cmd/minitiad/init.go index 6d89d60..3998c5e 100644 --- a/cmd/minitiad/init.go +++ b/cmd/minitiad/init.go @@ -25,6 +25,7 @@ import ( "github.com/cosmos/cosmos-sdk/x/genutil" minitiaapp "github.com/initia-labs/miniwasm/app" + "github.com/initia-labs/miniwasm/types" ) const ( @@ -33,6 +34,9 @@ const ( // FlagRecover defines a flag to initialize the private validator key from a specific seed. FlagRecover = "recover" + + // FlagDenom defines a flag to set default denom a chain operator want to use. + FlagDenom = "denom" ) type printInfo struct { @@ -85,6 +89,11 @@ func InitCmd(mbm module.BasicManager, defaultNodeHome string) *cobra.Command { chainID = fmt.Sprintf("test-chain-%v", cometrand.Str(6)) } + denom, err := cmd.Flags().GetString(FlagDenom) + if err != nil { + return err + } + // Get bip39 mnemonic var mnemonic string recover, _ := cmd.Flags().GetBool(FlagRecover) @@ -116,7 +125,7 @@ func InitCmd(mbm module.BasicManager, defaultNodeHome string) *cobra.Command { } appState, err := json.MarshalIndent( - minitiaapp.NewDefaultGenesisState(cdc, mbm), "", " ", + minitiaapp.NewDefaultGenesisState(cdc, mbm, denom), "", " ", ) if err != nil { return errors.Wrap(err, "Failed to marshall default genesis state") @@ -153,6 +162,7 @@ func InitCmd(mbm module.BasicManager, defaultNodeHome string) *cobra.Command { cmd.Flags().BoolP(FlagOverwrite, "o", false, "overwrite the genesis.json file") cmd.Flags().Bool(FlagRecover, false, "provide seed phrase to recover existing key instead of creating") cmd.Flags().String(flags.FlagChainID, "", "genesis file chain-id, if left blank will be randomly created") + cmd.Flags().String(FlagDenom, types.BaseDenom, "genesis file default denom") return cmd } diff --git a/cmd/minitiad/root.go b/cmd/minitiad/root.go index bf4bfb0..2ca8193 100644 --- a/cmd/minitiad/root.go +++ b/cmd/minitiad/root.go @@ -40,9 +40,6 @@ import ( "github.com/initia-labs/miniwasm/app/params" ) -// missing flag from cosmos-sdk -const flagIAVLCacheSize = "iavl-cache-size" - // NewRootCmd creates a new root command for initiad. It is called once in the // main function. func NewRootCmd() (*cobra.Command, params.EncodingConfig) {