From 4c0cb6c2c42e25e421ccedd1d704005f85f77361 Mon Sep 17 00:00:00 2001 From: Prathamesh Musale Date: Tue, 16 Jul 2024 03:50:08 +0000 Subject: [PATCH] Unset home and keyring dir from depinject client config (#35) Part of #33 Follows PR #34 - With earlier workaround in root cmd (not passing `DefaultNodeHome` to depinject), it created a `config/client.toml` wherever the laconicd CLI was being run - Unset `clientCtx.HomeDir` and `clientCtx.KeyringDir` while providing client context to depinject instead to prevent this and still handle the `--home` flag precedence issue - When using default home directory, all commands still work as `DefaultNodeHome` is passed to the [command executor](https://git.vdb.to/cerc-io/laconic2d/src/branch/main/cmd/laconicd/main.go#L18) Reviewed-on: https://git.vdb.to/cerc-io/laconic2d/pulls/35 Co-authored-by: Prathamesh Musale Co-committed-by: Prathamesh Musale --- cmd/laconicd/cmd/root.go | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/cmd/laconicd/cmd/root.go b/cmd/laconicd/cmd/root.go index 638f554f..14e3f468 100644 --- a/cmd/laconicd/cmd/root.go +++ b/cmd/laconicd/cmd/root.go @@ -134,14 +134,17 @@ func ProvideClientContext( WithLegacyAmino(legacyAmino). WithInput(os.Stdin). WithAccountRetriever(types.AccountRetriever{}). - // Workaround: Avoid providing DefaultNodeHome to depinject as it is given precedence over the one passed using --home flag in some CLI commands - // TODO: Implement proper fix - // WithHomeDir(app.DefaultNodeHome). + WithHomeDir(app.DefaultNodeHome). WithViper(EnvPrefix) // env variable prefix // Read the config again to overwrite the default values with the values from the config file clientCtx, _ = config.ReadFromClientConfig(clientCtx) + // Workaround: Unset clientCtx.HomeDir and clientCtx.KeyringDir from depinject clientCtx as they are given precedence over the CLI args (--home flag) in some commands + // TODO: Implement proper fix + clientCtx.HomeDir = "" + clientCtx.KeyringDir = "" + return clientCtx }