From 87bd3f1e05bf8c01d06e88c66809ae5b4fe3412b Mon Sep 17 00:00:00 2001 From: Danilo Pantani Date: Fri, 24 Feb 2023 03:30:56 -0300 Subject: [PATCH 1/2] fix query contexts --- .../x/{{moduleName}}/client/cli/query_params.go.plush | 5 ++++- .../client/cli/query_{{typeName}}.go.plush | 10 ++++++++-- .../client/cli/query_{{typeName}}.go.plush | 10 ++++++++-- .../client/cli/query_{{typeName}}.go.plush | 5 ++++- 4 files changed, 24 insertions(+), 6 deletions(-) diff --git a/ignite/templates/module/create/files/base/x/{{moduleName}}/client/cli/query_params.go.plush b/ignite/templates/module/create/files/base/x/{{moduleName}}/client/cli/query_params.go.plush index 612273344f..9f4994869a 100644 --- a/ignite/templates/module/create/files/base/x/{{moduleName}}/client/cli/query_params.go.plush +++ b/ignite/templates/module/create/files/base/x/{{moduleName}}/client/cli/query_params.go.plush @@ -15,7 +15,10 @@ func CmdQueryParams() *cobra.Command { Short: "shows the parameters of the module", Args: cobra.NoArgs, RunE: func(cmd *cobra.Command, args []string) error { - clientCtx := client.GetClientContextFromCmd(cmd) + clientCtx, err := client.GetClientQueryContext(cmd) + if err != nil { + return err + } queryClient := types.NewQueryClient(clientCtx) diff --git a/ignite/templates/typed/list/files/component/x/{{moduleName}}/client/cli/query_{{typeName}}.go.plush b/ignite/templates/typed/list/files/component/x/{{moduleName}}/client/cli/query_{{typeName}}.go.plush index 38b2cc3c98..71d6b43670 100644 --- a/ignite/templates/typed/list/files/component/x/{{moduleName}}/client/cli/query_{{typeName}}.go.plush +++ b/ignite/templates/typed/list/files/component/x/{{moduleName}}/client/cli/query_{{typeName}}.go.plush @@ -15,7 +15,10 @@ func CmdList<%= TypeName.UpperCamel %>() *cobra.Command { Use: "list-<%= TypeName.Kebab %>", Short: "list all <%= TypeName.Original %>", RunE: func(cmd *cobra.Command, args []string) error { - clientCtx := client.GetClientContextFromCmd(cmd) + clientCtx, err := client.GetClientQueryContext(cmd) + if err != nil { + return err + } pageReq, err := client.ReadPageRequest(cmd.Flags()) if err != nil { @@ -49,7 +52,10 @@ func CmdShow<%= TypeName.UpperCamel %>() *cobra.Command { Short: "shows a <%= TypeName.Original %>", Args: cobra.ExactArgs(1), RunE: func(cmd *cobra.Command, args []string) error { - clientCtx := client.GetClientContextFromCmd(cmd) + clientCtx, err := client.GetClientQueryContext(cmd) + if err != nil { + return err + } queryClient := types.NewQueryClient(clientCtx) diff --git a/ignite/templates/typed/map/files/component/x/{{moduleName}}/client/cli/query_{{typeName}}.go.plush b/ignite/templates/typed/map/files/component/x/{{moduleName}}/client/cli/query_{{typeName}}.go.plush index 96afb9b5bb..989bee6f81 100644 --- a/ignite/templates/typed/map/files/component/x/{{moduleName}}/client/cli/query_{{typeName}}.go.plush +++ b/ignite/templates/typed/map/files/component/x/{{moduleName}}/client/cli/query_{{typeName}}.go.plush @@ -15,7 +15,10 @@ func CmdList<%= TypeName.UpperCamel %>() *cobra.Command { Use: "list-<%= TypeName.Kebab %>", Short: "list all <%= TypeName.Original %>", RunE: func(cmd *cobra.Command, args []string) error { - clientCtx := client.GetClientContextFromCmd(cmd) + clientCtx, err := client.GetClientQueryContext(cmd) + if err != nil { + return err + } pageReq, err := client.ReadPageRequest(cmd.Flags()) if err != nil { @@ -49,7 +52,10 @@ func CmdShow<%= TypeName.UpperCamel %>() *cobra.Command { Short: "shows a <%= TypeName.Original %>", Args: cobra.ExactArgs(<%= len(Indexes) %>), RunE: func(cmd *cobra.Command, args []string) (err error) { - clientCtx := client.GetClientContextFromCmd(cmd) + clientCtx, err := client.GetClientQueryContext(cmd) + if err != nil { + return err + } queryClient := types.NewQueryClient(clientCtx) diff --git a/ignite/templates/typed/singleton/files/component/x/{{moduleName}}/client/cli/query_{{typeName}}.go.plush b/ignite/templates/typed/singleton/files/component/x/{{moduleName}}/client/cli/query_{{typeName}}.go.plush index aa3ed4ca56..1b12770127 100644 --- a/ignite/templates/typed/singleton/files/component/x/{{moduleName}}/client/cli/query_{{typeName}}.go.plush +++ b/ignite/templates/typed/singleton/files/component/x/{{moduleName}}/client/cli/query_{{typeName}}.go.plush @@ -15,7 +15,10 @@ func CmdShow<%= TypeName.UpperCamel %>() *cobra.Command { Short: "shows <%= TypeName.Original %>", Args: cobra.NoArgs, RunE: func(cmd *cobra.Command, args []string) error { - clientCtx := client.GetClientContextFromCmd(cmd) + clientCtx, err := client.GetClientQueryContext(cmd) + if err != nil { + return err + } queryClient := types.NewQueryClient(clientCtx) From bf4b36ed319572b2c49ebb940c24fe72cdcd9216 Mon Sep 17 00:00:00 2001 From: Danilo Pantani Date: Fri, 24 Feb 2023 03:59:11 -0300 Subject: [PATCH 2/2] add changelog --- changelog.md | 1 + 1 file changed, 1 insertion(+) diff --git a/changelog.md b/changelog.md index f2eafd176d..b3baa6a555 100644 --- a/changelog.md +++ b/changelog.md @@ -74,6 +74,7 @@ - [#3327](https://github.com/ignite/cli/issues/3327) Scaffolding messages with same name leads to aliasing. - [#3383](https://github.com/ignite/cli/pull/3383) State error and info are now displayed when using serve UI. - [#3379](https://github.com/ignite/cli/issues/3379) Fix `ignite docs` issue by disabling mouse support. +- [#3435](https://github.com/ignite/cli/issues/3435) Fix wrong client context for cmd query methods. ## [`v0.25.2`](https://github.com/ignite/cli/releases/tag/v0.25.1)