fix(simapp): fix default home (#19393)
This commit is contained in:
+2
-1
@@ -91,7 +91,8 @@ Every module contains its own CHANGELOG.md. Please refer to the module you are i
|
||||
* (abci): [#19200](https://github.com/cosmos/cosmos-sdk/pull/19200) Ensure that sdk side ve math matches cometbft
|
||||
* (server) [#18994](https://github.com/cosmos/cosmos-sdk/pull/18994) Update server context directly rather than a reference to a sub-object
|
||||
* (crypto) [#19371](https://github.com/cosmos/cosmos-sdk/pull/19371) Avoid cli redundant log in stdout, log to stderr instead.
|
||||
|
||||
* (client) [#19393](https://github.com/cosmos/cosmos-sdk/pull/19393/) Add `ReadDefaultValuesFromDefaultClientConfig` to populate the default values from the default client config in client.Context without creating a app folder.
|
||||
|
||||
### API Breaking Changes
|
||||
|
||||
* (server) [#18303](https://github.com/cosmos/cosmos-sdk/pull/18303) `x/genutil` now handles the application export. `server.AddCommands` does not take an `AppExporter` but instead `genutilcli.Commands` does.
|
||||
|
||||
@@ -36,10 +36,31 @@ type Config struct {
|
||||
|
||||
// ReadFromClientConfig reads values from client.toml file and updates them in client.Context
|
||||
// It uses CreateClientConfig internally with no custom template and custom config.
|
||||
// Deprecated: use CreateClientConfig instead.
|
||||
func ReadFromClientConfig(ctx client.Context) (client.Context, error) {
|
||||
return CreateClientConfig(ctx, "", nil)
|
||||
}
|
||||
|
||||
// ReadDefaultValuesFromDefaultClientConfig reads default values from default client.toml file and updates them in client.Context
|
||||
// The client.toml is then discarded.
|
||||
func ReadDefaultValuesFromDefaultClientConfig(ctx client.Context, customClientTemplate string, customConfig interface{}) (client.Context, error) {
|
||||
prevHomeDir := ctx.HomeDir
|
||||
dir, err := os.MkdirTemp("", "simapp")
|
||||
if err != nil {
|
||||
return ctx, fmt.Errorf("couldn't create temp dir: %w", err)
|
||||
}
|
||||
defer os.RemoveAll(dir)
|
||||
|
||||
ctx.HomeDir = dir
|
||||
ctx, err = CreateClientConfig(ctx, customClientTemplate, customConfig)
|
||||
if err != nil {
|
||||
return ctx, fmt.Errorf("couldn't create client config: %w", err)
|
||||
}
|
||||
|
||||
ctx.HomeDir = prevHomeDir
|
||||
return ctx, nil
|
||||
}
|
||||
|
||||
// CreateClientConfig reads the client.toml file and returns a new populated client.Context
|
||||
// If the client.toml file does not exist, it creates one with default values.
|
||||
// It takes a customClientTemplate and customConfig as input that can be used to overwrite the default config and enhance the client.toml file.
|
||||
|
||||
@@ -108,7 +108,7 @@ func NewRootCmd() *cobra.Command {
|
||||
// autocli opts
|
||||
customClientTemplate, customClientConfig := initClientConfig()
|
||||
var err error
|
||||
initClientCtx, err = config.CreateClientConfig(initClientCtx, customClientTemplate, customClientConfig)
|
||||
initClientCtx, err = config.ReadDefaultValuesFromDefaultClientConfig(initClientCtx, customClientTemplate, customClientConfig)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
@@ -120,7 +120,7 @@ func ProvideClientContext(
|
||||
|
||||
// Read the config to overwrite the default values with the values from the config file
|
||||
customClientTemplate, customClientConfig := initClientConfig()
|
||||
clientCtx, err = config.CreateClientConfig(clientCtx, customClientTemplate, customClientConfig)
|
||||
clientCtx, err = config.ReadDefaultValuesFromDefaultClientConfig(clientCtx, customClientTemplate, customClientConfig)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user