diff --git a/app/genesis.go b/app/genesis.go index 3d41728..38dae6f 100644 --- a/app/genesis.go +++ b/app/genesis.go @@ -15,7 +15,6 @@ import ( opchildtypes "github.com/initia-labs/OPinit/x/opchild/types" movetypes "github.com/initia-labs/initia/x/move/types" "github.com/initia-labs/initiavm/precompile" - "github.com/initia-labs/minimove/types" auctiontypes "github.com/skip-mev/block-sdk/x/auction/types" ) @@ -30,20 +29,20 @@ 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). ConfigureMoveStdlib(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 c83d3fc..ba83ccc 100644 --- a/app/test_helpers.go +++ b/app/test_helpers.go @@ -21,6 +21,7 @@ import ( authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" opchildtypes "github.com/initia-labs/OPinit/x/opchild/types" + "github.com/initia-labs/minimove/types" moveconfig "github.com/initia-labs/initia/x/move/config" ) @@ -63,7 +64,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{} @@ -77,6 +78,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) @@ -93,13 +101,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 9ac0e8c..4e43de4 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/minimove/app" + "github.com/initia-labs/minimove/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 04f7686..4508498 100644 --- a/cmd/minitiad/root.go +++ b/cmd/minitiad/root.go @@ -34,9 +34,6 @@ import ( "github.com/initia-labs/minimove/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) {