cli icon indicating copy to clipboard operation
cli copied to clipboard

fix(template): remove `client.ReadPersistentCommandFlags`

Open islishude opened this issue 1 year ago • 2 comments

The client.SetCmdClientContextHandler has the client.ReadPersistentCommandFlags

https://github.com/cosmos/cosmos-sdk/blob/0c91044220403e7b899ad0e51ccd2d4e5d66a901/client/cmd.go#L30-L37

islishude avatar May 12 '24 04:05 islishude

Now that your changes (https://github.com/cosmos/cosmos-sdk/pull/20356) have been merged and backported to v0.50 in the SDK, let me check if this works now.

julienrbrt avatar May 15 '24 14:05 julienrbrt

the steps to initialize the client instance:

  1. use the depinject
  2. add cobra cmd
  3. read the flags (I removed this)
  4. read the config file
  5. add tx config (it doesn't depend on step 3)
  6. read the flags again in the SetCmdClientContextHandler

I don't think the step 3 is necessary.

and by the way, refer to the viper documentation, the flag has higher priority

https://github.com/spf13/viper?tab=readme-ov-file#why-viper

islishude avatar May 15 '24 15:05 islishude

This is required, otherwise ReadFromClientConfig will have a client context with possibly wrong values (such as the home) or the output.

julienrbrt avatar May 23 '24 09:05 julienrbrt