Skip to content

Commit

Permalink
add denom flag
Browse files Browse the repository at this point in the history
  • Loading branch information
beer-1 committed Dec 12, 2023
1 parent 8e6c32d commit c4fdf2a
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 8 deletions.
11 changes: 5 additions & 6 deletions app/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand All @@ -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
Expand Down
3 changes: 2 additions & 1 deletion app/test_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand Down Expand Up @@ -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{}
Expand Down
12 changes: 11 additions & 1 deletion cmd/minitiad/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand All @@ -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 {
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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")
Expand Down Expand Up @@ -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
}

0 comments on commit c4fdf2a

Please sign in to comment.