Skip to content

Commit

Permalink
Fix poolmanager query (#4403) (#4409)
Browse files Browse the repository at this point in the history
* add NewQuerier func

* poolmanager regis query server

* lint

* check query not alter state

(cherry picked from commit 46530dc)

Co-authored-by: Hieu Vu <[email protected]>
  • Loading branch information
mergify[bot] and hieuvubk authored Feb 23, 2023
1 parent 930877b commit be72e17
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 0 deletions.
12 changes: 12 additions & 0 deletions x/poolmanager/client/cli/query_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
4 changes: 4 additions & 0 deletions x/poolmanager/client/query_proto_wrap.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
3 changes: 3 additions & 0 deletions x/poolmanager/module/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit be72e17

Please sign in to comment.