From a62f30908032c48c76c82276fd3211befa6cbdff Mon Sep 17 00:00:00 2001 From: yihuang Date: Wed, 11 Aug 2021 09:47:37 +0800 Subject: [PATCH] Problem: scaffolding is not up-to-date (#1) - seal CapabilityKeeper - seal sdk config - call UpgradeKeeper.SetModuleVersionMap - keep prefixes and coin type the same as ethermint --- app/app.go | 5 +++++ app/prefix.go | 19 ++++--------------- cmd/cronosd/cmd/root.go | 6 +++++- 3 files changed, 14 insertions(+), 16 deletions(-) diff --git a/app/app.go b/app/app.go index a50e3202c2..641ec28ddc 100644 --- a/app/app.go +++ b/app/app.go @@ -297,6 +297,10 @@ func New( // grant capabilities for the ibc and ibc-transfer modules scopedIBCKeeper := app.CapabilityKeeper.ScopeToModule(ibchost.ModuleName) scopedTransferKeeper := app.CapabilityKeeper.ScopeToModule(ibctransfertypes.ModuleName) + // Applications that wish to enforce statically created ScopedKeepers should call `Seal` after creating + // their scoped modules in `NewApp` with `ScopeToModule` + app.CapabilityKeeper.Seal() + // this line is used by starport scaffolding # stargate/app/scopedKeeper // add keepers @@ -525,6 +529,7 @@ func (app *App) InitChainer(ctx sdk.Context, req abci.RequestInitChain) abci.Res if err := tmjson.Unmarshal(req.AppStateBytes, &genesisState); err != nil { panic(err) } + app.UpgradeKeeper.SetModuleVersionMap(ctx, app.mm.GetVersionMap()) return app.mm.InitGenesis(ctx, app.appCodec, genesisState) } diff --git a/app/prefix.go b/app/prefix.go index ec83c9cb8f..b898d5fcb4 100644 --- a/app/prefix.go +++ b/app/prefix.go @@ -2,24 +2,13 @@ package app import ( sdk "github.com/cosmos/cosmos-sdk/types" -) - -const ( - AccountAddressPrefix = "cosmos" -) - -var ( - AccountPubKeyPrefix = AccountAddressPrefix + "pub" - ValidatorAddressPrefix = AccountAddressPrefix + "valoper" - ValidatorPubKeyPrefix = AccountAddressPrefix + "valoperpub" - ConsNodeAddressPrefix = AccountAddressPrefix + "valcons" - ConsNodePubKeyPrefix = AccountAddressPrefix + "valconspub" + cmdcfg "github.com/tharsis/ethermint/cmd/config" ) func SetConfig() { config := sdk.GetConfig() - config.SetBech32PrefixForAccount(AccountAddressPrefix, AccountPubKeyPrefix) - config.SetBech32PrefixForValidator(ValidatorAddressPrefix, ValidatorPubKeyPrefix) - config.SetBech32PrefixForConsensusNode(ConsNodeAddressPrefix, ConsNodePubKeyPrefix) + // use the configurations from ethermint + cmdcfg.SetBech32Prefixes(config) + cmdcfg.SetBip44CoinType(config) config.Seal() } diff --git a/cmd/cronosd/cmd/root.go b/cmd/cronosd/cmd/root.go index e1d8d6d4c7..458d6c9130 100644 --- a/cmd/cronosd/cmd/root.go +++ b/cmd/cronosd/cmd/root.go @@ -44,6 +44,8 @@ import ( // this line is used by starport scaffolding # stargate/root/import ) +const EnvPrefix = "CRONOS" + var ChainID string // NewRootCmd creates a new root command for simd. It is called once in the @@ -63,7 +65,7 @@ func NewRootCmd() (*cobra.Command, params.EncodingConfig) { WithBroadcastMode(flags.BroadcastBlock). WithHomeDir(app.DefaultNodeHome). WithKeyringOptions(hd.EthSecp256k1Option()). - WithViper("CRONOS") // In simapp, we don't use any prefix for env variables. + WithViper(EnvPrefix) rootCmd := &cobra.Command{ Use: app.Name + "d", @@ -100,6 +102,8 @@ func NewRootCmd() (*cobra.Command, params.EncodingConfig) { } func initRootCmd(rootCmd *cobra.Command, encodingConfig params.EncodingConfig) { + cfg := sdk.GetConfig() + cfg.Seal() rootCmd.AddCommand( ethermintclient.ValidateChainID(