From be72e1749714fb4ad222c1291a99f77c1eecf8b3 Mon Sep 17 00:00:00 2001 From: "mergify[bot]" <37929162+mergify[bot]@users.noreply.github.com> Date: Thu, 23 Feb 2023 14:00:29 -0500 Subject: [PATCH] Fix poolmanager query (#4403) (#4409) * add NewQuerier func * poolmanager regis query server * lint * check query not alter state (cherry picked from commit 46530dc1fd1d9a35bb50d445c9dedf29a611dcba) Co-authored-by: Hieu Vu <72878483+hieuvubk@users.noreply.github.com> --- x/poolmanager/client/cli/query_test.go | 12 ++++++++++++ x/poolmanager/client/query_proto_wrap.go | 4 ++++ x/poolmanager/module/module.go | 3 +++ 3 files changed, 19 insertions(+) diff --git a/x/poolmanager/client/cli/query_test.go b/x/poolmanager/client/cli/query_test.go index 4ec586966e3..ec975f62617 100644 --- a/x/poolmanager/client/cli/query_test.go +++ b/x/poolmanager/client/cli/query_test.go @@ -36,6 +36,18 @@ func (s *QueryTestSuite) TestQueriesNeverAlterState() { &poolmanagerqueryproto.NumPoolsRequest{}, &poolmanagerqueryproto.NumPoolsResponse{}, }, + { + "Query estimate swap in", + "/osmosis.poolmanager.v1beta1.Query/EstimateSwapExactAmountIn", + &poolmanagerqueryproto.EstimateSwapExactAmountInRequest{}, + &poolmanagerqueryproto.EstimateSwapExactAmountInResponse{}, + }, + { + "Query estimate swap out", + "/osmosis.poolmanager.v1beta1.Query/EstimateSwapExactAmountOut", + &poolmanagerqueryproto.EstimateSwapExactAmountOutRequest{}, + &poolmanagerqueryproto.EstimateSwapExactAmountOutResponse{}, + }, } for _, tc := range testCases { diff --git a/x/poolmanager/client/query_proto_wrap.go b/x/poolmanager/client/query_proto_wrap.go index 3c96d829cb9..18300e5a08c 100644 --- a/x/poolmanager/client/query_proto_wrap.go +++ b/x/poolmanager/client/query_proto_wrap.go @@ -16,6 +16,10 @@ type Querier struct { K poolmanager.Keeper } +func NewQuerier(k poolmanager.Keeper) Querier { + return Querier{k} +} + func (q Querier) Params(ctx sdk.Context, req queryproto.ParamsRequest, ) (*queryproto.ParamsResponse, error) { diff --git a/x/poolmanager/module/module.go b/x/poolmanager/module/module.go index 4bfd595139c..aeca4d26a00 100644 --- a/x/poolmanager/module/module.go +++ b/x/poolmanager/module/module.go @@ -18,7 +18,9 @@ import ( "github.com/osmosis-labs/osmosis/v14/simulation/simtypes" gammsimulation "github.com/osmosis-labs/osmosis/v14/x/gamm/simulation" "github.com/osmosis-labs/osmosis/v14/x/poolmanager" + pmclient "github.com/osmosis-labs/osmosis/v14/x/poolmanager/client" "github.com/osmosis-labs/osmosis/v14/x/poolmanager/client/cli" + "github.com/osmosis-labs/osmosis/v14/x/poolmanager/client/grpc" "github.com/osmosis-labs/osmosis/v14/x/poolmanager/client/queryproto" "github.com/osmosis-labs/osmosis/v14/x/poolmanager/types" ) @@ -82,6 +84,7 @@ type AppModule struct { func (am AppModule) RegisterServices(cfg module.Configurator) { types.RegisterMsgServer(cfg.MsgServer(), poolmanager.NewMsgServerImpl(&am.k)) + queryproto.RegisterQueryServer(cfg.QueryServer(), grpc.Querier{Q: pmclient.NewQuerier(am.k)}) } func NewAppModule(poolmanagerKeeper poolmanager.Keeper, gammKeeper types.SwapI) AppModule {