From 140968b78463e5d4de0ab8cc778fefeb278e8e16 Mon Sep 17 00:00:00 2001 From: Julien Robert Date: Thu, 20 Jun 2024 21:44:41 +0200 Subject: [PATCH 1/2] refactor(templates): Set and seal SDK global config in `app/config.go` --- changelog.md | 1 + .../{{binaryNamePrefix}}d/cmd/root.go.plush | 2 -- .../templates/app/files/app/config.go.plush | 19 +++++++++++++++++++ .../{{binaryNamePrefix}}d/cmd/config.go.plush | 16 ---------------- .../{{binaryNamePrefix}}d/cmd/root.go.plush | 2 -- 5 files changed, 20 insertions(+), 20 deletions(-) create mode 100644 ignite/templates/app/files/app/config.go.plush diff --git a/changelog.md b/changelog.md index c4cc87c390..423d23e600 100644 --- a/changelog.md +++ b/changelog.md @@ -52,6 +52,7 @@ - [#4091](https://github.com/ignite/cli/pull/4091) Fix race conditions in the plugin logic - [#4128](https://github.com/ignite/cli/pull/4128) Check for duplicate proto fields in config - [#4184](https://github.com/ignite/cli/pull/4184) Set custom `InitChainer` because of manually registered modules +- [#4199](https://github.com/ignite/cli/pull/4199) Set and seal SDK global config in `app/config.go` ## [`v28.4.0`](https://github.com/ignite/cli/releases/tag/v28.4.0) diff --git a/ignite/templates/app/files-consumer/cmd/{{binaryNamePrefix}}d/cmd/root.go.plush b/ignite/templates/app/files-consumer/cmd/{{binaryNamePrefix}}d/cmd/root.go.plush index 72ade797d1..d0935d9bad 100644 --- a/ignite/templates/app/files-consumer/cmd/{{binaryNamePrefix}}d/cmd/root.go.plush +++ b/ignite/templates/app/files-consumer/cmd/{{binaryNamePrefix}}d/cmd/root.go.plush @@ -26,8 +26,6 @@ import ( // NewRootCmd creates a new root command for <%= BinaryNamePrefix %>d. It is called once in the main function. func NewRootCmd() *cobra.Command { - initSDKConfig() - var ( autoCliOpts autocli.AppOptions moduleBasicManager module.BasicManager diff --git a/ignite/templates/app/files/app/config.go.plush b/ignite/templates/app/files/app/config.go.plush new file mode 100644 index 0000000000..a36981bf73 --- /dev/null +++ b/ignite/templates/app/files/app/config.go.plush @@ -0,0 +1,19 @@ +package app + +import sdk "github.com/cosmos/cosmos-sdk/types" + +func init() { + // Set prefixes + accountPubKeyPrefix := AccountAddressPrefix + "pub" + validatorAddressPrefix := AccountAddressPrefix + "valoper" + validatorPubKeyPrefix := AccountAddressPrefix + "valoperpub" + consNodeAddressPrefix := AccountAddressPrefix + "valcons" + consNodePubKeyPrefix := AccountAddressPrefix + "valconspub" + + // Set and seal config + config := sdk.GetConfig() + config.SetBech32PrefixForAccount(AccountAddressPrefix, accountPubKeyPrefix) + config.SetBech32PrefixForValidator(validatorAddressPrefix, validatorPubKeyPrefix) + config.SetBech32PrefixForConsensusNode(consNodeAddressPrefix, consNodePubKeyPrefix) + config.Seal() +} \ No newline at end of file diff --git a/ignite/templates/app/files/cmd/{{binaryNamePrefix}}d/cmd/config.go.plush b/ignite/templates/app/files/cmd/{{binaryNamePrefix}}d/cmd/config.go.plush index 87989cd04d..cade265e4c 100644 --- a/ignite/templates/app/files/cmd/{{binaryNamePrefix}}d/cmd/config.go.plush +++ b/ignite/templates/app/files/cmd/{{binaryNamePrefix}}d/cmd/config.go.plush @@ -8,22 +8,6 @@ import ( "<%= ModulePath %>/app" ) -func initSDKConfig() { - // Set prefixes - accountPubKeyPrefix := app.AccountAddressPrefix + "pub" - validatorAddressPrefix := app.AccountAddressPrefix + "valoper" - validatorPubKeyPrefix := app.AccountAddressPrefix + "valoperpub" - consNodeAddressPrefix := app.AccountAddressPrefix + "valcons" - consNodePubKeyPrefix := app.AccountAddressPrefix + "valconspub" - - // Set and seal config - config := sdk.GetConfig() - config.SetBech32PrefixForAccount(app.AccountAddressPrefix, accountPubKeyPrefix) - config.SetBech32PrefixForValidator(validatorAddressPrefix, validatorPubKeyPrefix) - config.SetBech32PrefixForConsensusNode(consNodeAddressPrefix, consNodePubKeyPrefix) - config.Seal() -} - // initCometBFTConfig helps to override default CometBFT Config values. // return cmtcfg.DefaultConfig if no custom configuration is required for the application. func initCometBFTConfig() *cmtcfg.Config { diff --git a/ignite/templates/app/files/cmd/{{binaryNamePrefix}}d/cmd/root.go.plush b/ignite/templates/app/files/cmd/{{binaryNamePrefix}}d/cmd/root.go.plush index d169668b63..b70ceeb846 100644 --- a/ignite/templates/app/files/cmd/{{binaryNamePrefix}}d/cmd/root.go.plush +++ b/ignite/templates/app/files/cmd/{{binaryNamePrefix}}d/cmd/root.go.plush @@ -25,8 +25,6 @@ import ( // NewRootCmd creates a new root command for <%= BinaryNamePrefix %>d. It is called once in the main function. func NewRootCmd() *cobra.Command { - initSDKConfig() - var ( autoCliOpts autocli.AppOptions moduleBasicManager module.BasicManager From 2d89a8debf369f9d4a3f428ccc9baa8746491cf2 Mon Sep 17 00:00:00 2001 From: Julien Robert Date: Thu, 20 Jun 2024 21:51:10 +0200 Subject: [PATCH 2/2] updates --- .../app/files/cmd/{{binaryNamePrefix}}d/cmd/config.go.plush | 3 --- 1 file changed, 3 deletions(-) diff --git a/ignite/templates/app/files/cmd/{{binaryNamePrefix}}d/cmd/config.go.plush b/ignite/templates/app/files/cmd/{{binaryNamePrefix}}d/cmd/config.go.plush index cade265e4c..a14ebc57c3 100644 --- a/ignite/templates/app/files/cmd/{{binaryNamePrefix}}d/cmd/config.go.plush +++ b/ignite/templates/app/files/cmd/{{binaryNamePrefix}}d/cmd/config.go.plush @@ -3,9 +3,6 @@ package cmd import ( cmtcfg "github.com/cometbft/cometbft/config" serverconfig "github.com/cosmos/cosmos-sdk/server/config" - sdk "github.com/cosmos/cosmos-sdk/types" - - "<%= ModulePath %>/app" ) // initCometBFTConfig helps to override default CometBFT Config values.