From 33e1913e8ee9ac31ecd06bd580ea8e06b5b6ec97 Mon Sep 17 00:00:00 2001 From: Julien Robert Date: Wed, 12 Jun 2024 17:28:11 +0200 Subject: [PATCH 1/2] feat(services): set default chain-id in client.toml (#4183) * feat(services): set default chain-id in client.toml * changelog (cherry picked from commit 27930b18e47811fb26df54bd2c377d9b2e62f2e5) --- changelog.md | 21 +++++++++++++++++++++ ignite/services/chain/init.go | 2 +- ignite/services/chain/runtime.go | 25 +++++++++++++------------ 3 files changed, 35 insertions(+), 13 deletions(-) diff --git a/changelog.md b/changelog.md index 19efa55afe..29d1f29952 100644 --- a/changelog.md +++ b/changelog.md @@ -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` diff --git a/ignite/services/chain/init.go b/ignite/services/chain/init.go index 98e076fe6d..c681acc645 100644 --- a/ignite/services/chain/init.go +++ b/ignite/services/chain/init.go @@ -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 } } diff --git a/ignite/services/chain/runtime.go b/ignite/services/chain/runtime.go index bcbfa157c4..8e44db7d84 100644 --- a/ignite/services/chain/runtime.go +++ b/ignite/services/chain/runtime.go @@ -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 @@ -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 @@ -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 } @@ -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 } @@ -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 } From 180fb10048a71d9fe9fdd0156d00e3c750431293 Mon Sep 17 00:00:00 2001 From: Julien Robert Date: Thu, 13 Jun 2024 10:55:53 +0200 Subject: [PATCH 2/2] fix changelog --- changelog.md | 17 ----------------- 1 file changed, 17 deletions(-) diff --git a/changelog.md b/changelog.md index 29d1f29952..ad6321e4b0 100644 --- a/changelog.md +++ b/changelog.md @@ -4,23 +4,6 @@ ### 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