Skip to content

Commit

Permalink
Problem: scaffolding is not up-to-date (#1)
Browse files Browse the repository at this point in the history
- seal CapabilityKeeper
- seal sdk config
- call UpgradeKeeper.SetModuleVersionMap
- keep prefixes and coin type the same as ethermint
  • Loading branch information
yihuang authored Aug 11, 2021
1 parent 8248acf commit a62f309
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 16 deletions.
5 changes: 5 additions & 0 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
}

Expand Down
19 changes: 4 additions & 15 deletions app/prefix.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
6 changes: 5 additions & 1 deletion cmd/cronosd/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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",
Expand Down Expand Up @@ -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(
Expand Down

0 comments on commit a62f309

Please sign in to comment.