From b6d7e0531583acdfa6d7fdb27a984d2d1419f572 Mon Sep 17 00:00:00 2001 From: ltacker Date: Sun, 27 Nov 2022 22:42:20 -0500 Subject: [PATCH 01/15] init config optional --- ignite/services/chain/init.go | 56 +++++++++++++++++++++-------------- 1 file changed, 33 insertions(+), 23 deletions(-) diff --git a/ignite/services/chain/init.go b/ignite/services/chain/init.go index 3e3b3870c5..fdb18200b1 100644 --- a/ignite/services/chain/init.go +++ b/ignite/services/chain/init.go @@ -19,35 +19,33 @@ const ( moniker = "mynode" ) -// Init initializes the chain and applies all optional configurations. -func (c *Chain) Init(ctx context.Context, initAccounts bool) error { - conf, err := c.Config() - if err != nil { - return &CannotBuildAppError{err} - } - - if err := c.InitChain(ctx); err != nil { +// Init initializes the chain +// initAccounts true intializes accounts for the chain from Ignite the config +// initConfiguration initilizes node configuration from the Ignite config +// initGenesis initializes genesis state for the chain from Ignite config +func (c *Chain) Init(ctx context.Context, initAccounts, initConfiguration, initGenesis bool) error { + if err := c.InitChain(ctx, initConfiguration, initGenesis); err != nil { return err } if initAccounts { + conf, err := c.Config() + if err != nil { + return &CannotBuildAppError{err} + } + return c.InitAccounts(ctx, conf) } return nil } // InitChain initializes the chain. -func (c *Chain) InitChain(ctx context.Context) error { +func (c *Chain) InitChain(ctx context.Context, initConfiguration, initGenesis bool) error { chainID, err := c.ID() if err != nil { return err } - conf, err := c.Config() - if err != nil { - return err - } - // cleanup persistent data from previous `serve`. home, err := c.Home() if err != nil { @@ -67,19 +65,31 @@ func (c *Chain) InitChain(ctx context.Context) error { return err } - // ovewrite app config files with the values defined in Ignite's config file - if err := c.Configure(home, conf); err != nil { - return err + var conf *chainconfig.Config + if initConfiguration || initGenesis { + conf, err = c.Config() + if err != nil { + return err + } } - // make sure that chain id given during chain.New() has the most priority. - if conf.Genesis != nil { - conf.Genesis["chain_id"] = chainID + // ovewrite app config files with the values defined in Ignite's config file + if initConfiguration { + if err := c.Configure(home, conf); err != nil { + return err + } } - // update genesis file with the genesis values defined in the config - if err := c.UpdateGenesisFile(conf.Genesis); err != nil { - return err + if initGenesis { + // make sure that chain id given during chain.New() has the most priority. + if conf.Genesis != nil { + conf.Genesis["chain_id"] = chainID + } + + // update genesis file with the genesis values defined in the config + if err := c.UpdateGenesisFile(conf.Genesis); err != nil { + return err + } } return nil From d5810d79519c03e2bbfadf8189f70a8e5c4e9055 Mon Sep 17 00:00:00 2001 From: ltacker Date: Sun, 27 Nov 2022 22:42:34 -0500 Subject: [PATCH 02/15] option change --- ignite/cmd/chain_init.go | 2 +- ignite/services/chain/serve.go | 2 +- ignite/services/network/networkchain/init.go | 2 +- ignite/services/network/networkchain/networkchain.go | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/ignite/cmd/chain_init.go b/ignite/cmd/chain_init.go index 1c6cb789d1..d5ef033fbe 100644 --- a/ignite/cmd/chain_init.go +++ b/ignite/cmd/chain_init.go @@ -122,7 +122,7 @@ func chainInitHandler(cmd *cobra.Command, _ []string) error { return err } - if err := c.Init(cmd.Context(), true); err != nil { + if err := c.Init(cmd.Context(), true, true, true); err != nil { return err } diff --git a/ignite/services/chain/serve.go b/ignite/services/chain/serve.go index 61aae8f29e..d55ba2d717 100644 --- a/ignite/services/chain/serve.go +++ b/ignite/services/chain/serve.go @@ -387,7 +387,7 @@ func (c *Chain) serve( if !isInit || (appModified && !exportGenesisExists) { c.ev.Send("Initializing the app...", events.ProgressUpdate()) - if err := c.Init(ctx, true); err != nil { + if err := c.Init(ctx, true, true, true); err != nil { return err } } else if appModified { diff --git a/ignite/services/network/networkchain/init.go b/ignite/services/network/networkchain/init.go index 719a52705a..f1ff033075 100644 --- a/ignite/services/network/networkchain/init.go +++ b/ignite/services/network/networkchain/init.go @@ -33,7 +33,7 @@ func (c *Chain) Init(ctx context.Context, cacheStorage cache.Storage) error { c.ev.Send("Initializing the blockchain", events.ProgressStart()) - if err = c.chain.Init(ctx, false); err != nil { + if err = c.chain.Init(ctx, false, false, false); err != nil { return err } diff --git a/ignite/services/network/networkchain/networkchain.go b/ignite/services/network/networkchain/networkchain.go index a832360651..20910986c7 100644 --- a/ignite/services/network/networkchain/networkchain.go +++ b/ignite/services/network/networkchain/networkchain.go @@ -287,7 +287,7 @@ func (c Chain) NodeID(ctx context.Context) (string, error) { func (c Chain) CheckConfigVersion() error { configPath := c.chain.ConfigPath() if configPath == "" { - return chainconfig.ErrConfigNotFound + return nil } file, err := os.Open(configPath) From 1e236751deec80f462d49e52c950505591c2245a Mon Sep 17 00:00:00 2001 From: ltacker Date: Sun, 27 Nov 2022 22:42:50 -0500 Subject: [PATCH 03/15] fix validator --- ignite/services/chain/chain.go | 37 ++++++++++++++++++++++------------ 1 file changed, 24 insertions(+), 13 deletions(-) diff --git a/ignite/services/chain/chain.go b/ignite/services/chain/chain.go index 6cc878c2c7..44949e2b8c 100644 --- a/ignite/services/chain/chain.go +++ b/ignite/services/chain/chain.go @@ -2,6 +2,7 @@ package chain import ( "context" + "errors" "os" "path/filepath" @@ -186,6 +187,9 @@ func (c *Chain) RPCPublicAddress() (string, error) { if err != nil { return "", err } + if len(conf.Validators) == 0 { + return "", errors.New("no validator in config") + } validator := conf.Validators[0] servers, err := validator.GetServers() if err != nil { @@ -295,9 +299,11 @@ func (c *Chain) DefaultHome() (string, error) { if err != nil { return "", err } - validator := config.Validators[0] - if validator.Home != "" { - return validator.Home, nil + if len(config.Validators) > 0 { + validator := config.Validators[0] + if validator.Home != "" { + return validator.Home, nil + } } return c.appHome(), nil @@ -369,17 +375,19 @@ func (c *Chain) KeyringBackend() (chaincmd.KeyringBackend, error) { return "", err } - // 2nd. - validator := config.Validators[0] - if validator.KeyringBackend != "" { - return chaincmd.KeyringBackendFromString(validator.KeyringBackend) - } + if len(config.Validators) > 0 { + // 2nd. + validator := config.Validators[0] + if validator.KeyringBackend != "" { + return chaincmd.KeyringBackendFromString(validator.KeyringBackend) + } - // 3rd. - if validator.Client != nil { - if backend, ok := validator.Client["keyring-backend"]; ok { - if backendStr, ok := backend.(string); ok { - return chaincmd.KeyringBackendFromString(backendStr) + // 3rd. + if validator.Client != nil { + if backend, ok := validator.Client["keyring-backend"]; ok { + if backendStr, ok := backend.(string); ok { + return chaincmd.KeyringBackendFromString(backendStr) + } } } } @@ -436,6 +444,9 @@ func (c *Chain) Commands(ctx context.Context) (chaincmdrunner.Runner, error) { return chaincmdrunner.Runner{}, err } + if len(config.Validators) == 0 { + return chaincmdrunner.Runner{}, errors.New("no validator in config") + } validator := config.Validators[0] servers, err := validator.GetServers() if err != nil { From 27fca5a378839288cff92491dbb5c65821e6487f Mon Sep 17 00:00:00 2001 From: ltacker Date: Sun, 27 Nov 2022 22:57:08 -0500 Subject: [PATCH 04/15] fix chain --- ignite/services/chain/chain.go | 35 +++++++++++++++++++++------------- 1 file changed, 22 insertions(+), 13 deletions(-) diff --git a/ignite/services/chain/chain.go b/ignite/services/chain/chain.go index 44949e2b8c..f54e9ea21a 100644 --- a/ignite/services/chain/chain.go +++ b/ignite/services/chain/chain.go @@ -2,7 +2,6 @@ package chain import ( "context" - "errors" "os" "path/filepath" @@ -11,6 +10,8 @@ import ( "github.com/tendermint/spn/pkg/chainid" "github.com/ignite/cli/ignite/chainconfig" + chainconfigv1 "github.com/ignite/cli/ignite/chainconfig/v1" + "github.com/ignite/cli/ignite/pkg/chaincmd" chaincmdrunner "github.com/ignite/cli/ignite/pkg/chaincmd/runner" uilog "github.com/ignite/cli/ignite/pkg/cliui/log" @@ -187,14 +188,19 @@ func (c *Chain) RPCPublicAddress() (string, error) { if err != nil { return "", err } + + var servers chainconfigv1.Servers + if len(conf.Validators) == 0 { - return "", errors.New("no validator in config") - } - validator := conf.Validators[0] - servers, err := validator.GetServers() - if err != nil { - return "", err + servers = chainconfigv1.DefaultServers() + } else { + validator := conf.Validators[0] + servers, err = validator.GetServers() + if err != nil { + return "", err + } } + rpcAddress = servers.RPC.Address } return rpcAddress, nil @@ -444,13 +450,16 @@ func (c *Chain) Commands(ctx context.Context) (chaincmdrunner.Runner, error) { return chaincmdrunner.Runner{}, err } + var servers chainconfigv1.Servers + if len(config.Validators) == 0 { - return chaincmdrunner.Runner{}, errors.New("no validator in config") - } - validator := config.Validators[0] - servers, err := validator.GetServers() - if err != nil { - return chaincmdrunner.Runner{}, err + servers = chainconfigv1.DefaultServers() + } else { + validator := config.Validators[0] + servers, err = validator.GetServers() + if err != nil { + return chaincmdrunner.Runner{}, err + } } nodeAddr, err := xurl.TCP(servers.RPC.Address) From 31601492a5c297c3f7811050696c770679b67201 Mon Sep 17 00:00:00 2001 From: ltacker Date: Sun, 27 Nov 2022 22:57:22 -0500 Subject: [PATCH 05/15] changelog --- changelog.md | 1 + 1 file changed, 1 insertion(+) diff --git a/changelog.md b/changelog.md index 6c71a83674..70eea57a2d 100644 --- a/changelog.md +++ b/changelog.md @@ -13,6 +13,7 @@ - [#3105](https://github.com/ignite/cli/pull/3105) Addition of `ignite plugin describe ` command - [#2995](https://github.com/ignite/cli/pull/2995/) Add `ignite network request remove-validator` command. - [#2999](https://github.com/ignite/cli/pull/2999/) Add `ignite network request remove-account` command. +- [#3183](https://github.com/ignite/cli/pull/3183/) Make config optional for init phase. ### Changes From d6631a3d6b3f7ee2e36d4bcf81460e4a097cc8cf Mon Sep 17 00:00:00 2001 From: ltacker Date: Mon, 28 Nov 2022 15:53:32 -0500 Subject: [PATCH 06/15] fix some errors --- ignite/services/chain/init.go | 2 +- ignite/services/network/networkchain/networkchain.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/ignite/services/chain/init.go b/ignite/services/chain/init.go index f87ac7794a..8ac96a0c75 100644 --- a/ignite/services/chain/init.go +++ b/ignite/services/chain/init.go @@ -65,7 +65,7 @@ func (c *Chain) InitChain(ctx context.Context, initConfiguration, initGenesis bo return err } - var conf *chainconfig.Config + var conf *config.ChainConfig if initConfiguration || initGenesis { conf, err = c.Config() if err != nil { diff --git a/ignite/services/network/networkchain/networkchain.go b/ignite/services/network/networkchain/networkchain.go index 2f2d8e51e1..7de9723453 100644 --- a/ignite/services/network/networkchain/networkchain.go +++ b/ignite/services/network/networkchain/networkchain.go @@ -287,7 +287,7 @@ func (c Chain) NodeID(ctx context.Context) (string, error) { func (c Chain) CheckConfigVersion() error { configPath := c.chain.ConfigPath() if configPath == "" { - return config.ErrConfigNotFound + return nil } file, err := os.Open(configPath) From 54b9b703278b21f2b58437d518f94a72fcf70ae9 Mon Sep 17 00:00:00 2001 From: ltacker Date: Mon, 28 Nov 2022 17:42:50 -0500 Subject: [PATCH 07/15] fix keyring backend --- ignite/cmd/network_chain_init.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/ignite/cmd/network_chain_init.go b/ignite/cmd/network_chain_init.go index f3da6c7079..3826a313b2 100644 --- a/ignite/cmd/network_chain_init.go +++ b/ignite/cmd/network_chain_init.go @@ -7,6 +7,7 @@ import ( "github.com/manifoldco/promptui" "github.com/spf13/cobra" + "github.com/ignite/cli/ignite/pkg/chaincmd" "github.com/ignite/cli/ignite/pkg/cliui" "github.com/ignite/cli/ignite/pkg/cliui/cliquiz" "github.com/ignite/cli/ignite/pkg/cliui/icons" @@ -141,7 +142,9 @@ func networkChainInitHandler(cmd *cobra.Command, args []string) error { return err } - var networkOptions []networkchain.Option + networkOptions := []networkchain.Option{ + networkchain.WithKeyringBackend(chaincmd.KeyringBackendTest), + } if flagGetCheckDependencies(cmd) { networkOptions = append(networkOptions, networkchain.CheckDependencies()) From f632cf410f130044e81ba36a52b227d3bb0de554 Mon Sep 17 00:00:00 2001 From: ltacker Date: Mon, 28 Nov 2022 18:01:10 -0500 Subject: [PATCH 08/15] fix prepare --- ignite/cmd/network_chain_prepare.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/ignite/cmd/network_chain_prepare.go b/ignite/cmd/network_chain_prepare.go index c5d6268c94..79330ae51a 100644 --- a/ignite/cmd/network_chain_prepare.go +++ b/ignite/cmd/network_chain_prepare.go @@ -7,6 +7,7 @@ import ( "github.com/spf13/cobra" "github.com/ignite/cli/ignite/pkg/cache" + "github.com/ignite/cli/ignite/pkg/chaincmd" "github.com/ignite/cli/ignite/pkg/cliui" "github.com/ignite/cli/ignite/pkg/cliui/colors" "github.com/ignite/cli/ignite/pkg/cliui/icons" @@ -98,7 +99,9 @@ func networkChainPrepareHandler(cmd *cobra.Command, args []string) error { return fmt.Errorf("chain %d launch has not been triggered yet. use --force to prepare anyway", launchID) } - var networkOptions []networkchain.Option + networkOptions := []networkchain.Option{ + networkchain.WithKeyringBackend(chaincmd.KeyringBackendTest), + } if flagGetCheckDependencies(cmd) { networkOptions = append(networkOptions, networkchain.CheckDependencies()) From 38d013b412a8f1812a9c4002cd582c74173b74cd Mon Sep 17 00:00:00 2001 From: Lucas Bertrand Date: Tue, 29 Nov 2022 17:06:08 +0100 Subject: [PATCH 09/15] Update ignite/services/chain/init.go MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Jerónimo Albi --- ignite/services/chain/init.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ignite/services/chain/init.go b/ignite/services/chain/init.go index 8ac96a0c75..9941a4efe0 100644 --- a/ignite/services/chain/init.go +++ b/ignite/services/chain/init.go @@ -20,8 +20,8 @@ const ( ) // Init initializes the chain -// initAccounts true intializes accounts for the chain from Ignite the config -// initConfiguration initilizes node configuration from the Ignite config +// initAccounts initializes chain accounts from the Ignite config +// initConfiguration initializes node configuration from the Ignite config // initGenesis initializes genesis state for the chain from Ignite config func (c *Chain) Init(ctx context.Context, initAccounts, initConfiguration, initGenesis bool) error { if err := c.InitChain(ctx, initConfiguration, initGenesis); err != nil { From a70132327321fd884e6d407e2fcd39002e7b92b9 Mon Sep 17 00:00:00 2001 From: ltacker Date: Fri, 2 Dec 2022 15:30:23 -0500 Subject: [PATCH 10/15] refactor error --- ignite/services/network/networkchain/networkchain.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ignite/services/network/networkchain/networkchain.go b/ignite/services/network/networkchain/networkchain.go index 7de9723453..1cc216f8f5 100644 --- a/ignite/services/network/networkchain/networkchain.go +++ b/ignite/services/network/networkchain/networkchain.go @@ -287,7 +287,7 @@ func (c Chain) NodeID(ctx context.Context) (string, error) { func (c Chain) CheckConfigVersion() error { configPath := c.chain.ConfigPath() if configPath == "" { - return nil + return config.ErrConfigNotFound } file, err := os.Open(configPath) @@ -303,7 +303,7 @@ func (c Chain) CheckConfigVersion() error { // Build builds chain sources, also checks if source was already built func (c *Chain) Build(ctx context.Context, cacheStorage cache.Storage) (binaryName string, err error) { // Check that the config version is the latest before building the binary - if err = c.CheckConfigVersion(); err != nil { + if err = c.CheckConfigVersion(); err != nil && err != config.ErrConfigNotFound { return } From ebb0a8abb8505e457abe7b21102894315758fba6 Mon Sep 17 00:00:00 2001 From: ltacker Date: Fri, 2 Dec 2022 15:47:39 -0500 Subject: [PATCH 11/15] remove rpc address --- ignite/services/chain/chain.go | 27 --------------------------- 1 file changed, 27 deletions(-) diff --git a/ignite/services/chain/chain.go b/ignite/services/chain/chain.go index 9b87ae1c9f..61fe52e28a 100644 --- a/ignite/services/chain/chain.go +++ b/ignite/services/chain/chain.go @@ -178,33 +178,6 @@ func (c *Chain) appVersion() (v version, err error) { return v, nil } -// RPCPublicAddress points to the public address of Tendermint RPC, this is shared by -// other chains for relayer related actions. -func (c *Chain) RPCPublicAddress() (string, error) { - rpcAddress := os.Getenv("RPC_ADDRESS") - if rpcAddress == "" { - conf, err := c.Config() - if err != nil { - return "", err - } - - var servers chainconfigv1.Servers - - if len(conf.Validators) == 0 { - servers = chainconfigv1.DefaultServers() - } else { - validator := conf.Validators[0] - servers, err = validator.GetServers() - if err != nil { - return "", err - } - } - - rpcAddress = servers.RPC.Address - } - return rpcAddress, nil -} - // ConfigPath returns the config path of the chain // Empty string means that the chain has no defined config func (c *Chain) ConfigPath() string { From 6c30deb43eb94daf684c94603c5e03c5bc8d7321 Mon Sep 17 00:00:00 2001 From: ltacker Date: Mon, 5 Dec 2022 16:06:07 -0500 Subject: [PATCH 12/15] add init args --- ignite/cmd/chain_init.go | 2 +- ignite/services/chain/init.go | 37 ++++++++++++++++---- ignite/services/chain/serve.go | 2 +- ignite/services/network/networkchain/init.go | 3 +- 4 files changed, 35 insertions(+), 9 deletions(-) diff --git a/ignite/cmd/chain_init.go b/ignite/cmd/chain_init.go index d5ef033fbe..25beff1c54 100644 --- a/ignite/cmd/chain_init.go +++ b/ignite/cmd/chain_init.go @@ -122,7 +122,7 @@ func chainInitHandler(cmd *cobra.Command, _ []string) error { return err } - if err := c.Init(cmd.Context(), true, true, true); err != nil { + if err := c.Init(cmd.Context(), chain.InitArgsAll); err != nil { return err } diff --git a/ignite/services/chain/init.go b/ignite/services/chain/init.go index 763c811997..5cdb71f418 100644 --- a/ignite/services/chain/init.go +++ b/ignite/services/chain/init.go @@ -15,20 +15,45 @@ import ( "github.com/ignite/cli/ignite/pkg/events" ) +type ( + // InitArgs represents argument to add additional initialization for the chain + // InitAccounts initializes chain accounts from the Ignite config + // InitConfiguration initializes node configuration from the Ignite config + // InitGenesis initializes genesis state for the chain from Ignite config + InitArgs struct { + InitAccounts bool + InitConfiguration bool + InitGenesis bool + } +) + const ( moniker = "mynode" ) +var ( + // InitArgsAll performs all initialization for the chain + InitArgsAll = InitArgs{ + true, + true, + true, + } + + // InitArgsNone performs minimal initialization for the chain by only initializating a node + InitArgsNone = InitArgs{ + false, + false, + false, + } +) + // Init initializes the chain -// initAccounts initializes chain accounts from the Ignite config -// initConfiguration initializes node configuration from the Ignite config -// initGenesis initializes genesis state for the chain from Ignite config -func (c *Chain) Init(ctx context.Context, initAccounts, initConfiguration, initGenesis bool) error { - if err := c.InitChain(ctx, initConfiguration, initGenesis); err != nil { +func (c *Chain) Init(ctx context.Context, initArgs InitArgs) error { + if err := c.InitChain(ctx, initArgs.InitConfiguration, initArgs.InitGenesis); err != nil { return err } - if initAccounts { + if initArgs.InitAccounts { conf, err := c.Config() if err != nil { return &CannotBuildAppError{err} diff --git a/ignite/services/chain/serve.go b/ignite/services/chain/serve.go index 19e73138ef..51487ffa6c 100644 --- a/ignite/services/chain/serve.go +++ b/ignite/services/chain/serve.go @@ -401,7 +401,7 @@ func (c *Chain) serve( if initApp { c.ev.Send("Initializing the app...", events.ProgressUpdate()) - if err := c.Init(ctx, true, true, true); err != nil { + if err := c.Init(ctx, InitArgsAll); err != nil { return err } } else if appModified { diff --git a/ignite/services/network/networkchain/init.go b/ignite/services/network/networkchain/init.go index a991d8cf46..e4b02a389f 100644 --- a/ignite/services/network/networkchain/init.go +++ b/ignite/services/network/networkchain/init.go @@ -11,6 +11,7 @@ import ( "github.com/ignite/cli/ignite/pkg/cache" cosmosgenesis "github.com/ignite/cli/ignite/pkg/cosmosutil/genesis" "github.com/ignite/cli/ignite/pkg/events" + "github.com/ignite/cli/ignite/services/chain" ) // Init initializes blockchain by building the binaries and running the init command and @@ -33,7 +34,7 @@ func (c *Chain) Init(ctx context.Context, cacheStorage cache.Storage) error { c.ev.Send("Initializing the blockchain", events.ProgressStart()) - if err = c.chain.Init(ctx, false, false, false); err != nil { + if err = c.chain.Init(ctx, chain.InitArgsNone); err != nil { return err } From 2f1659afa83123c30dd8e6237501c0b89bbe4573 Mon Sep 17 00:00:00 2001 From: ltacker Date: Mon, 5 Dec 2022 16:07:30 -0500 Subject: [PATCH 13/15] thomas simplification --- ignite/services/chain/chain.go | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/ignite/services/chain/chain.go b/ignite/services/chain/chain.go index c4d7e8935d..7c5e43d124 100644 --- a/ignite/services/chain/chain.go +++ b/ignite/services/chain/chain.go @@ -429,11 +429,8 @@ func (c *Chain) Commands(ctx context.Context) (chaincmdrunner.Runner, error) { return chaincmdrunner.Runner{}, err } - var servers chainconfigv1.Servers - - if len(config.Validators) == 0 { - servers = chainconfigv1.DefaultServers() - } else { + servers := chainconfigv1.DefaultServers() + if len(config.Validators) > 0 { validator := config.Validators[0] servers, err = validator.GetServers() if err != nil { From afcb6c27d46a6cfc78b26c751bd7bbd69b685ba9 Mon Sep 17 00:00:00 2001 From: ltacker Date: Wed, 7 Dec 2022 14:44:13 -0500 Subject: [PATCH 14/15] comments --- ignite/services/chain/init.go | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/ignite/services/chain/init.go b/ignite/services/chain/init.go index 5cdb71f418..8527533fd2 100644 --- a/ignite/services/chain/init.go +++ b/ignite/services/chain/init.go @@ -34,26 +34,26 @@ const ( var ( // InitArgsAll performs all initialization for the chain InitArgsAll = InitArgs{ - true, - true, - true, + InitAccounts: true, + InitConfiguration: true, + InitGenesis: true, } // InitArgsNone performs minimal initialization for the chain by only initializating a node InitArgsNone = InitArgs{ - false, - false, - false, + InitAccounts: false, + InitConfiguration: false, + InitGenesis: false, } ) // Init initializes the chain -func (c *Chain) Init(ctx context.Context, initArgs InitArgs) error { - if err := c.InitChain(ctx, initArgs.InitConfiguration, initArgs.InitGenesis); err != nil { +func (c *Chain) Init(ctx context.Context, args InitArgs) error { + if err := c.InitChain(ctx, args.InitConfiguration, args.InitGenesis); err != nil { return err } - if initArgs.InitAccounts { + if args.InitAccounts { conf, err := c.Config() if err != nil { return &CannotBuildAppError{err} From 6783accba792393f4797c421f31139f910baff2e Mon Sep 17 00:00:00 2001 From: ltacker Date: Thu, 8 Dec 2022 16:16:05 -0500 Subject: [PATCH 15/15] fix keyring backend genesis show --- ignite/cmd/network_chain_show_genesis.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/ignite/cmd/network_chain_show_genesis.go b/ignite/cmd/network_chain_show_genesis.go index 5baba69ee0..39241d06c2 100644 --- a/ignite/cmd/network_chain_show_genesis.go +++ b/ignite/cmd/network_chain_show_genesis.go @@ -6,6 +6,7 @@ import ( "github.com/spf13/cobra" + "github.com/ignite/cli/ignite/pkg/chaincmd" "github.com/ignite/cli/ignite/pkg/cliui" "github.com/ignite/cli/ignite/pkg/cliui/icons" "github.com/ignite/cli/ignite/pkg/xos" @@ -51,7 +52,11 @@ func networkChainShowGenesisHandler(cmd *cobra.Command, args []string) error { return err } - c, err := nb.Chain(networkchain.SourceLaunch(chainLaunch)) + networkOptions := []networkchain.Option{ + networkchain.WithKeyringBackend(chaincmd.KeyringBackendTest), + } + + c, err := nb.Chain(networkchain.SourceLaunch(chainLaunch), networkOptions...) if err != nil { return err }