Skip to content

Commit

Permalink
feat(services): set default chain-id in client.toml (#4183)
Browse files Browse the repository at this point in the history
* feat(services): set default chain-id in client.toml

* changelog

(cherry picked from commit 27930b1)
  • Loading branch information
julienrbrt authored and mergify[bot] committed Jun 12, 2024
1 parent 944283b commit 33e1913
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 13 deletions.
21 changes: 21 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,27 @@

## Unreleased

### Features

- [#3707](https://github.com/ignite/cli/pull/3707) and [#4094](https://github.com/ignite/cli/pull/4094) Add collections support.
- [#3977](https://github.com/ignite/cli/pull/3977) Add `chain lint` command to lint the chain's codebase using `golangci-lint`
- [#3770](https://github.com/ignite/cli/pull/3770) Add `scaffold configs` and `scaffold params` commands
- [#4001](https://github.com/ignite/cli/pull/4001) Improve `xgenny` dry run
- [#3967](https://github.com/ignite/cli/issues/3967) Add HD wallet parameters `address index` and `account number` to the chain account config
- [#4004](https://github.com/ignite/cli/pull/4004) Remove all import placeholders using the `xast` pkg
- [#4076](https://github.com/ignite/cli/pull/4076) Remove the ignite `relayer` and `tools` commands with all ts-relayer logic
- [#4071](https://github.com/ignite/cli/pull/4071) Support custom proto path
- [#3718](https://github.com/ignite/cli/pull/3718) Add `gen-mig-diffs` tool app to compare scaffold output of two versions of ignite
- [#4077](https://github.com/ignite/cli/pull/4077) Merge the swagger files manually instead use nodetime `swagger-combine`
- [#4090](https://github.com/ignite/cli/pull/4090) Remove `protoc` pkg and also nodetime helpers `ts-proto` and `sta`
- [#4100](https://github.com/ignite/cli/pull/4100) Set the `proto-dir` flag only for the `scaffold chain` command and use the proto path from the config
- [#4111](https://github.com/ignite/cli/pull/4111) Remove vuex generation
- [#4133](https://github.com/ignite/cli/pull/4133) Improve buf rate limit
- [#4113](https://github.com/ignite/cli/pull/4113) Generate chain config documentation automatically
- [#4131](https://github.com/ignite/cli/pull/4131) Support `bytes` as data type in the `scaffold` commands
- [#4095](https://github.com/ignite/cli/pull/4095) Migrate to matomo analytics
- [#4183](https://github.com/ignite/cli/pull/4183) Set `chain-id` in the client.toml

### Changes

- [#4149](https://github.com/ignite/cli/pull/4149) Bump cometbft to `v0.38.7`
Expand Down
2 changes: 1 addition & 1 deletion ignite/services/chain/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ func (c *Chain) InitChain(ctx context.Context, initConfiguration, initGenesis bo

// ovewrite app config files with the values defined in Ignite's config file
if initConfiguration {
if err := c.Configure(home, conf); err != nil {
if err := c.Configure(home, chainID, conf); err != nil {
return err
}
}
Expand Down
25 changes: 13 additions & 12 deletions ignite/services/chain/runtime.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,17 +54,17 @@ func (c Chain) Start(ctx context.Context, runner chaincmdrunner.Runner, cfg *cha
}

// Configure sets the runtime configurations files for a chain (app.toml, client.toml, config.toml).
func (c Chain) Configure(homePath string, cfg *chainconfig.Config) error {
if err := c.appTOML(homePath, cfg); err != nil {
func (c Chain) Configure(homePath, chainID string, cfg *chainconfig.Config) error {
if err := appTOML(homePath, cfg); err != nil {
return err
}
if err := c.clientTOML(homePath, cfg); err != nil {
if err := clientTOML(homePath, chainID, cfg); err != nil {
return err
}
return c.configTOML(homePath, cfg)
return configTOML(homePath, cfg)
}

func (c Chain) appTOML(homePath string, cfg *chainconfig.Config) error {
func appTOML(homePath string, cfg *chainconfig.Config) error {
validator, err := chainconfig.FirstValidator(cfg)
if err != nil {
return err
Expand Down Expand Up @@ -117,7 +117,7 @@ func (c Chain) appTOML(homePath string, cfg *chainconfig.Config) error {
return err
}

func (c Chain) configTOML(homePath string, cfg *chainconfig.Config) error {
func configTOML(homePath string, cfg *chainconfig.Config) error {
validator, err := chainconfig.FirstValidator(cfg)
if err != nil {
return err
Expand Down Expand Up @@ -170,14 +170,14 @@ func (c Chain) configTOML(homePath string, cfg *chainconfig.Config) error {
return err
}

func (c Chain) clientTOML(homePath string, cfg *chainconfig.Config) error {
func clientTOML(homePath, chainID string, cfg *chainconfig.Config) error {
validator, err := chainconfig.FirstValidator(cfg)
if err != nil {
return err
}

path := filepath.Join(homePath, "config/client.toml")
tmConfig, err := toml.LoadFile(path)
clientConfig, err := toml.LoadFile(path)
if os.IsNotExist(err) {
return nil
}
Expand All @@ -187,11 +187,12 @@ func (c Chain) clientTOML(homePath string, cfg *chainconfig.Config) error {
}

// Set default config values
tmConfig.Set("keyring-backend", "test")
tmConfig.Set("broadcast-mode", "sync")
clientConfig.Set("chain-id", chainID)
clientConfig.Set("keyring-backend", "test")
clientConfig.Set("broadcast-mode", "sync")

// Update config values with the validator's client config
if err := updateTomlTreeValues(tmConfig, validator.Client); err != nil {
if err := updateTomlTreeValues(clientConfig, validator.Client); err != nil {
return err
}

Expand All @@ -201,7 +202,7 @@ func (c Chain) clientTOML(homePath string, cfg *chainconfig.Config) error {
}
defer file.Close()

_, err = tmConfig.WriteTo(file)
_, err = clientConfig.WriteTo(file)
return err
}

Expand Down

0 comments on commit 33e1913

Please sign in to comment.