From d03955a2c0b5019d1f92a60b07d2f76b12557d83 Mon Sep 17 00:00:00 2001 From: vuong Date: Mon, 30 Jan 2023 00:38:15 +0700 Subject: [PATCH 1/3] override QueryFnName --- x/gamm/client/cli/query.go | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/x/gamm/client/cli/query.go b/x/gamm/client/cli/query.go index 533a7e88a8d..aa21cfecc08 100644 --- a/x/gamm/client/cli/query.go +++ b/x/gamm/client/cli/query.go @@ -203,8 +203,9 @@ func GetCmdEstimateSwapExactAmountIn() (*osmocli.QueryDescriptor, *types.QuerySw Short: "Query estimate-swap-exact-amount-in", Long: `Query estimate-swap-exact-amount-in.{{.ExampleHeader}} {{.CommandPrefix}} estimate-swap-exact-amount-in 1 osm11vmx8jtggpd9u7qr0t8vxclycz85u925sazglr7 stake --swap-route-pool-ids=2 --swap-route-pool-ids=3`, - ParseQuery: EstimateSwapExactAmountInParseArgs, - Flags: osmocli.FlagDesc{RequiredFlags: []*flag.FlagSet{FlagSetMultihopSwapRoutes()}}, + ParseQuery: EstimateSwapExactAmountInParseArgs, + Flags: osmocli.FlagDesc{RequiredFlags: []*flag.FlagSet{FlagSetMultihopSwapRoutes()}}, + QueryFnName: "EstimateSwapExactAmountIn", }, &types.QuerySwapExactAmountInRequest{} } @@ -216,8 +217,9 @@ func GetCmdEstimateSwapExactAmountOut() (*osmocli.QueryDescriptor, *types.QueryS Short: "Query estimate-swap-exact-amount-out", Long: `Query estimate-swap-exact-amount-out.{{.ExampleHeader}} {{.CommandPrefix}} estimate-swap-exact-amount-out 1 osm11vmx8jtggpd9u7qr0t8vxclycz85u925sazglr7 stake --swap-route-pool-ids=2 --swap-route-pool-ids=3`, - ParseQuery: EstimateSwapExactAmountOutParseArgs, - Flags: osmocli.FlagDesc{RequiredFlags: []*flag.FlagSet{FlagSetMultihopSwapRoutes()}}, + ParseQuery: EstimateSwapExactAmountOutParseArgs, + Flags: osmocli.FlagDesc{RequiredFlags: []*flag.FlagSet{FlagSetMultihopSwapRoutes()}}, + QueryFnName: "EstimateSwapExactAmountIn", }, &types.QuerySwapExactAmountOutRequest{} } From d390e7b6e81f40d03e79629edfa2e62e18aa1bcf Mon Sep 17 00:00:00 2001 From: vuong Date: Mon, 30 Jan 2023 00:40:23 +0700 Subject: [PATCH 2/3] duplicate prepareDescriptor --- osmoutils/osmocli/query_cmd_wrap.go | 1 - 1 file changed, 1 deletion(-) diff --git a/osmoutils/osmocli/query_cmd_wrap.go b/osmoutils/osmocli/query_cmd_wrap.go index af727553408..86c8e777b2b 100644 --- a/osmoutils/osmocli/query_cmd_wrap.go +++ b/osmoutils/osmocli/query_cmd_wrap.go @@ -48,7 +48,6 @@ func QueryIndexCmd(moduleName string) *cobra.Command { func AddQueryCmd[Q proto.Message, querier any](cmd *cobra.Command, newQueryClientFn func(grpc1.ClientConn) querier, f func() (*QueryDescriptor, Q)) { desc, _ := f() - prepareDescriptor[Q](desc) subCmd := BuildQueryCli[Q](desc, newQueryClientFn) cmd.AddCommand(subCmd) } From 4e919b71fb10a34218289bb7bfb1465994bb6440 Mon Sep 17 00:00:00 2001 From: vuong Date: Mon, 30 Jan 2023 17:38:01 +0700 Subject: [PATCH 3/3] add CustomFlagOverrides && make change for poolmanager cli --- x/gamm/client/cli/query.go | 18 ++++++++++++------ x/poolmanager/client/cli/query.go | 16 ++++++++++++---- 2 files changed, 24 insertions(+), 10 deletions(-) diff --git a/x/gamm/client/cli/query.go b/x/gamm/client/cli/query.go index aa21cfecc08..edf08391c4f 100644 --- a/x/gamm/client/cli/query.go +++ b/x/gamm/client/cli/query.go @@ -41,6 +41,10 @@ func GetQueryCmd() *cobra.Command { return cmd } +var customRouterFlagOverride = map[string]string{ + "router": FlagSwapRouteDenoms, +} + func GetCmdPool() (*osmocli.QueryDescriptor, *types.QueryPoolRequest) { return &osmocli.QueryDescriptor{ Use: "pool [poolID]", @@ -203,9 +207,10 @@ func GetCmdEstimateSwapExactAmountIn() (*osmocli.QueryDescriptor, *types.QuerySw Short: "Query estimate-swap-exact-amount-in", Long: `Query estimate-swap-exact-amount-in.{{.ExampleHeader}} {{.CommandPrefix}} estimate-swap-exact-amount-in 1 osm11vmx8jtggpd9u7qr0t8vxclycz85u925sazglr7 stake --swap-route-pool-ids=2 --swap-route-pool-ids=3`, - ParseQuery: EstimateSwapExactAmountInParseArgs, - Flags: osmocli.FlagDesc{RequiredFlags: []*flag.FlagSet{FlagSetMultihopSwapRoutes()}}, - QueryFnName: "EstimateSwapExactAmountIn", + ParseQuery: EstimateSwapExactAmountInParseArgs, + Flags: osmocli.FlagDesc{RequiredFlags: []*flag.FlagSet{FlagSetMultihopSwapRoutes()}}, + QueryFnName: "EstimateSwapExactAmountIn", + CustomFlagOverrides: customRouterFlagOverride, }, &types.QuerySwapExactAmountInRequest{} } @@ -217,9 +222,10 @@ func GetCmdEstimateSwapExactAmountOut() (*osmocli.QueryDescriptor, *types.QueryS Short: "Query estimate-swap-exact-amount-out", Long: `Query estimate-swap-exact-amount-out.{{.ExampleHeader}} {{.CommandPrefix}} estimate-swap-exact-amount-out 1 osm11vmx8jtggpd9u7qr0t8vxclycz85u925sazglr7 stake --swap-route-pool-ids=2 --swap-route-pool-ids=3`, - ParseQuery: EstimateSwapExactAmountOutParseArgs, - Flags: osmocli.FlagDesc{RequiredFlags: []*flag.FlagSet{FlagSetMultihopSwapRoutes()}}, - QueryFnName: "EstimateSwapExactAmountIn", + ParseQuery: EstimateSwapExactAmountOutParseArgs, + Flags: osmocli.FlagDesc{RequiredFlags: []*flag.FlagSet{FlagSetMultihopSwapRoutes()}}, + QueryFnName: "EstimateSwapExactAmountOut", + CustomFlagOverrides: customRouterFlagOverride, }, &types.QuerySwapExactAmountOutRequest{} } diff --git a/x/poolmanager/client/cli/query.go b/x/poolmanager/client/cli/query.go index f2e836d97e1..6472b206fe7 100644 --- a/x/poolmanager/client/cli/query.go +++ b/x/poolmanager/client/cli/query.go @@ -12,6 +12,10 @@ import ( "github.com/osmosis-labs/osmosis/v14/x/poolmanager/types" ) +var customRouterFlagOverride = map[string]string{ + "router": FlagSwapRouteDenoms, +} + // GetQueryCmd returns the cli query commands for this module. func GetQueryCmd() *cobra.Command { cmd := osmocli.QueryIndexCmd(types.ModuleName) @@ -30,8 +34,10 @@ func GetCmdEstimateSwapExactAmountIn() (*osmocli.QueryDescriptor, *queryproto.Es Short: "Query estimate-swap-exact-amount-in", Long: `Query estimate-swap-exact-amount-in.{{.ExampleHeader}} {{.CommandPrefix}} estimate-swap-exact-amount-in 1 osm11vmx8jtggpd9u7qr0t8vxclycz85u925sazglr7 stake --swap-route-pool-ids=2 --swap-route-pool-ids=3`, - ParseQuery: EstimateSwapExactAmountInParseArgs, - Flags: osmocli.FlagDesc{RequiredFlags: []*flag.FlagSet{FlagSetMultihopSwapRoutes()}}, + ParseQuery: EstimateSwapExactAmountInParseArgs, + Flags: osmocli.FlagDesc{RequiredFlags: []*flag.FlagSet{FlagSetMultihopSwapRoutes()}}, + QueryFnName: "EstimateSwapExactAmountIn", + CustomFlagOverrides: customRouterFlagOverride, }, &queryproto.EstimateSwapExactAmountInRequest{} } @@ -42,8 +48,10 @@ func GetCmdEstimateSwapExactAmountOut() (*osmocli.QueryDescriptor, *queryproto.E Short: "Query estimate-swap-exact-amount-out", Long: `Query estimate-swap-exact-amount-out.{{.ExampleHeader}} {{.CommandPrefix}} estimate-swap-exact-amount-out 1 osm11vmx8jtggpd9u7qr0t8vxclycz85u925sazglr7 stake --swap-route-pool-ids=2 --swap-route-pool-ids=3`, - ParseQuery: EstimateSwapExactAmountOutParseArgs, - Flags: osmocli.FlagDesc{RequiredFlags: []*flag.FlagSet{FlagSetMultihopSwapRoutes()}}, + ParseQuery: EstimateSwapExactAmountOutParseArgs, + Flags: osmocli.FlagDesc{RequiredFlags: []*flag.FlagSet{FlagSetMultihopSwapRoutes()}}, + QueryFnName: "EstimateSwapExactAmountOut", + CustomFlagOverrides: customRouterFlagOverride, }, &queryproto.EstimateSwapExactAmountOutRequest{} }