Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(templates): Set and seal SDK global config in app/config.go #4199

Merged
merged 4 commits into from
Jun 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
- [#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
- [#4198](https://github.com/ignite/cli/pull/4198) Set correct prefix overwriting in `buf.gen.pulsar.yaml`
- [#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)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
19 changes: 19 additions & 0 deletions ignite/templates/app/files/app/config.go.plush
Original file line number Diff line number Diff line change
@@ -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()
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,27 +3,8 @@ 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"
)

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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading