Skip to content

Commit

Permalink
fix(services): allow tilde and env in config validator home path (#4532)
Browse files Browse the repository at this point in the history
* fix(services): allow tilde and env in config validator home path

* updates

* up
  • Loading branch information
julienrbrt authored Feb 23, 2025
1 parent 63b69a7 commit ff663c9
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 6 deletions.
1 change: 1 addition & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@
- [#4474](https://github.com/ignite/cli/pull/4474) Fix issue in `build --release` command
- [#4479](https://github.com/ignite/cli/pull/4479) Scaffold an `uint64 type crashs Ignite
- [#4483](https://github.com/ignite/cli/pull/4483) Fix default flag parser for apps
- [#4532](https://github.com/ignite/cli/pull/4532) Fix non working _shortcuts_ in validator home config

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

Expand Down
3 changes: 0 additions & 3 deletions ignite/config/chain/v1/validator.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,6 @@ type Gentx struct {
// Moniker is the validator's (optional) moniker.
Moniker string `yaml:"moniker" doc:"Optional moniker for the validator."`

// Home is directory for config and data.
Home string `yaml:"home" doc:"Directory for configuration and data."`

// KeyringBackend is keyring's backend.
KeyringBackend string `yaml:"keyring-backend" doc:"Backend for the keyring."`

Expand Down
19 changes: 19 additions & 0 deletions ignite/services/chain/chain.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"os"
"path/filepath"
"strings"

"github.com/go-git/go-git/v5"
"github.com/spf13/cobra"
Expand Down Expand Up @@ -351,6 +352,11 @@ func (c *Chain) DefaultHome() (string, error) {
}
validator, _ := chainconfig.FirstValidator(cfg)
if validator.Home != "" {
expandedHome, err := expandHome(validator.Home)
if err != nil {
return "", err
}
validator.Home = expandedHome
return validator.Home, nil
}

Expand Down Expand Up @@ -534,3 +540,16 @@ func appBackendSourceWatchPaths(protoDir string) []string {
protoDir,
}
}

// expandHome expands a path that may start with "~" and may contain environment variables.
func expandHome(path string) (string, error) {
if strings.HasPrefix(path, "~") {
home, err := os.UserHomeDir()
if err != nil {
return "", err
}
// Only replace the first occurrence at the start.
path = home + strings.TrimPrefix(path, "~")
}
return os.ExpandEnv(path), nil
}
2 changes: 0 additions & 2 deletions ignite/templates/app/files/go.mod.plush
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ go 1.23.6

replace (
github.com/cosmos/ibc-go/v10 => github.com/cosmos/ibc-go/v10 v10.0.0-beta.0
github.com/cosmos/cosmos-sdk => github.com/cosmos/cosmos-sdk v0.50.11
cosmossdk.io/core => cosmossdk.io/core v0.11.2
)

replace (
Expand Down
2 changes: 1 addition & 1 deletion ignite/templates/typed/simulation.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"github.com/ignite/cli/v29/ignite/pkg/multiformatname"
)

// TODO(@julienrbrt): remove this line when simulation is brought back
// TODO(@julienrbrt): remove this line when simulation is brought back.
func ModuleSimulationMsgModify(
content string,
_, _ multiformatname.Name,
Expand Down

0 comments on commit ff663c9

Please sign in to comment.