Skip to content

Commit

Permalink
fix: use getter to read first config validator (#3969)
Browse files Browse the repository at this point in the history
* fix: use getter to read first config validator

Getter checks that there is at least a validator configured and
otherwise returns a proper error

* chore: update changelog
  • Loading branch information
jeronimoalbi committed Feb 15, 2024
1 parent f86fa97 commit 55ad250
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
1 change: 1 addition & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

- [#3953](https://github.com/ignite/cli/pull/3953) Fix apps `Stdout` is redirected to `Stderr`
- [#3863](https://github.com/ignite/cli/pull/3963) Fix breaking issue for app client API when reading app chain info
- [#3969](https://github.com/ignite/cli/pull/3969) Get first config validator using a getter to avoid index errors

## [`v28.2.0`](https://github.com/ignite/cli/releases/tag/v28.2.0)

Expand Down
8 changes: 6 additions & 2 deletions ignite/cmd/chain_debug.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"github.com/spf13/cobra"

cmdmodel "github.com/ignite/cli/v28/ignite/cmd/model"
chainconfig "github.com/ignite/cli/v28/ignite/config/chain"
"github.com/ignite/cli/v28/ignite/pkg/chaincmd"
"github.com/ignite/cli/v28/ignite/pkg/cliui"
"github.com/ignite/cli/v28/ignite/pkg/cliui/icons"
Expand Down Expand Up @@ -117,8 +118,11 @@ func chainDebug(cmd *cobra.Command, session *cliui.Session) error {
return err
}

// TODO: Replace by config.FirstValidator when PR #3199 is merged
validator := cfg.Validators[0]
validator, err := chainconfig.FirstValidator(cfg)
if err != nil {
return err
}

servers, err := validator.GetServers()
if err != nil {
return err
Expand Down
7 changes: 6 additions & 1 deletion ignite/services/chain/chain.go
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,12 @@ func (c *Chain) RPCPublicAddress() (string, error) {
if err != nil {
return "", err
}
validator := conf.Validators[0]

validator, err := chainconfig.FirstValidator(conf)
if err != nil {
return "", err
}

servers, err := validator.GetServers()
if err != nil {
return "", err
Expand Down

0 comments on commit 55ad250

Please sign in to comment.