diff --git a/app/app_config.go b/app/app_config.go index a6c5811932..ba9996c6bf 100644 --- a/app/app_config.go +++ b/app/app_config.go @@ -10,7 +10,6 @@ import ( evidencetypes "cosmossdk.io/x/evidence/types" "cosmossdk.io/x/feegrant" "github.com/cosmos/cosmos-sdk/runtime" - sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/x/auth/vesting" vestingtypes "github.com/cosmos/cosmos-sdk/x/auth/vesting/types" "github.com/cosmos/cosmos-sdk/x/authz" @@ -348,17 +347,6 @@ func init() { DefaultNodeHome = filepath.Join(userHomeDir, ".desmos") } -// SetupConfig sets up the given config as it should be for Desmos -func SetupConfig(config *sdk.Config) { - config.SetBech32PrefixForAccount(Bech32MainPrefix, Bech32MainPrefix+sdk.PrefixPublic) - config.SetBech32PrefixForValidator(Bech32MainPrefix+sdk.PrefixValidator+sdk.PrefixOperator, Bech32MainPrefix+sdk.PrefixValidator+sdk.PrefixOperator+sdk.PrefixPublic) - config.SetBech32PrefixForConsensusNode(Bech32MainPrefix+sdk.PrefixValidator+sdk.PrefixConsensus, Bech32MainPrefix+sdk.PrefixValidator+sdk.PrefixConsensus+sdk.PrefixPublic) - - // 852 is the international dialing code of Hong Kong - // Following the coin type registered at https://github.com/satoshilabs/slips/blob/master/slip-0044.md - config.SetCoinType(CoinType) -} - // MakeCodecs constructs the *std.Codec and *codec.LegacyAmino instances used by // DesmosApp. It is useful for tests and clients who do not want to construct the // full DesmosApp diff --git a/app/app_module_config.go b/app/app_module_config.go index 546a224c9d..7c6e49f27f 100644 --- a/app/app_module_config.go +++ b/app/app_module_config.go @@ -139,7 +139,7 @@ var ( { Name: authtypes.ModuleName, Config: appconfig.WrapAny(&authmodulev1.Module{ - Bech32Prefix: sdk.Bech32MainPrefix, + Bech32Prefix: sdk.GetConfig().GetBech32AccountAddrPrefix(), ModuleAccountPermissions: maccPerms, // By default modules authority is the governance module. This is configurable with the following: // Authority: "group", // A custom module authority can be set using a module name diff --git a/app/desmos/cmd/commands.go b/app/desmos/cmd/commands.go index 22fc11d4cb..b725cf98c5 100644 --- a/app/desmos/cmd/commands.go +++ b/app/desmos/cmd/commands.go @@ -20,7 +20,6 @@ import ( "github.com/cosmos/cosmos-sdk/server" serverconfig "github.com/cosmos/cosmos-sdk/server/config" servertypes "github.com/cosmos/cosmos-sdk/server/types" - sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/module" authcmd "github.com/cosmos/cosmos-sdk/x/auth/client/cli" banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" @@ -108,11 +107,6 @@ func initRootCmd( txConfig client.TxConfig, basicManager module.BasicManager, ) { - // Read in the configuration file for the sdk - cfg := sdk.GetConfig() - app.SetupConfig(cfg) - cfg.Seal() - rootCmd.AddCommand( genutilcli.InitCmd(basicManager, app.DefaultNodeHome), genesisCommand(txConfig, basicManager), diff --git a/app/desmos/cmd/root.go b/app/desmos/cmd/root.go index 79a2389af6..982872a8d7 100644 --- a/app/desmos/cmd/root.go +++ b/app/desmos/cmd/root.go @@ -24,6 +24,7 @@ import ( "github.com/cosmos/cosmos-sdk/x/auth/types" "github.com/desmos-labs/desmos/v6/app" + _ "github.com/desmos-labs/desmos/v6/app/desmos/cmd/setup" // import side-effect ) // NewRootCmd creates a new root command for desmos. It is called once in the diff --git a/app/desmos/cmd/setup/setup.go b/app/desmos/cmd/setup/setup.go new file mode 100644 index 0000000000..fc4b28cf8d --- /dev/null +++ b/app/desmos/cmd/setup/setup.go @@ -0,0 +1,27 @@ +package setup + +import sdk "github.com/cosmos/cosmos-sdk/types" + +const ( + Bech32MainPrefix = "desmos" + CoinType = 852 +) + +func init() { + // Read in the configuration file for the sdk + cfg := sdk.GetConfig() + SetupConfig(cfg) + cfg.Seal() + +} + +// SetupConfig sets up the given config as it should be for Desmos +func SetupConfig(config *sdk.Config) { + config.SetBech32PrefixForAccount(Bech32MainPrefix, Bech32MainPrefix+sdk.PrefixPublic) + config.SetBech32PrefixForValidator(Bech32MainPrefix+sdk.PrefixValidator+sdk.PrefixOperator, Bech32MainPrefix+sdk.PrefixValidator+sdk.PrefixOperator+sdk.PrefixPublic) + config.SetBech32PrefixForConsensusNode(Bech32MainPrefix+sdk.PrefixValidator+sdk.PrefixConsensus, Bech32MainPrefix+sdk.PrefixValidator+sdk.PrefixConsensus+sdk.PrefixPublic) + + // 852 is the international dialing code of Hong Kong + // Following the coin type registered at https://github.com/satoshilabs/slips/blob/master/slip-0044.md + config.SetCoinType(CoinType) +}