Skip to content

Commit

Permalink
fix: add pool manager spot price query to stargate whitelist (#5503)
Browse files Browse the repository at this point in the history
* Fix stargate whitelist

* Fix query pulgin test

* Bring back spot price
  • Loading branch information
mattverse authored Jun 13, 2023
1 parent 1d7fedd commit 4abfde5
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ and control over token transfers.
* [#5138](https://github.com/osmosis-labs/osmosis/pull/5138) refactor: rename swap fee to spread factor
* [#5020](https://github.com/osmosis-labs/osmosis/pull/5020) Add gas config to the client.toml
* [#5459](https://github.com/osmosis-labs/osmosis/pull/5459) Create locktypes.LockQueryType.NoLock gauge. MsgCreateGauge takes pool id for new gauge type.
* [#5503](https://github.com/osmosis-labs/osmosis/pull/5503) Deprecate gamm spot price query and add pool manager spot price query to stargate query whitelist.

## State Breaking
* [#5380](https://github.com/osmosis-labs/osmosis/pull/5380) feat: add ica authorized messages in upgrade handler
Expand Down
31 changes: 30 additions & 1 deletion wasmbinding/query_plugin_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ func (suite *StargateTestSuite) TestStargateQuerier() {
responseProtoStruct: &epochtypes.QueryEpochsInfoResponse{},
},
{
name: "happy path gamm",
name: "happy path gamm spot price",
path: "/osmosis.gamm.v2.Query/SpotPrice",
testSetup: func() {
pk := ed25519.GenPrivKey().PubKey()
Expand Down Expand Up @@ -98,6 +98,35 @@ func (suite *StargateTestSuite) TestStargateQuerier() {
SpotPrice: sdk.NewDecWithPrec(5, 1).String(),
},
},
{
name: "happy path pool manager",
path: "/osmosis.poolmanager.v1beta1.Query/SpotPrice",
testSetup: func() {
pk := ed25519.GenPrivKey().PubKey()
sender := sdk.AccAddress(pk.Address())
err := simapp.FundAccount(suite.app.BankKeeper, suite.ctx, sender, apptesting.DefaultAcctFunds)
suite.Require().NoError(err)
msg := balancer.NewMsgCreateBalancerPool(sender,
balancer.NewPoolParams(sdk.ZeroDec(), sdk.ZeroDec(), nil),
apptesting.DefaultPoolAssets, "")
_, err = suite.app.PoolManagerKeeper.CreatePool(suite.ctx, msg)
suite.NoError(err)
},
requestData: func() []byte {
queryrequest := gammv2types.QuerySpotPriceRequest{ //nolint:staticcheck // we're intentionally using this deprecated package for testing
PoolId: 1,
BaseAssetDenom: "bar",
QuoteAssetDenom: "uosmo",
}
bz, err := proto.Marshal(&queryrequest)
suite.Require().NoError(err)
return bz
},
checkResponseStruct: true,
responseProtoStruct: &gammv2types.QuerySpotPriceResponse{ //nolint:staticcheck // we're intentionally using this deprecated package for testing
SpotPrice: sdk.NewDecWithPrec(5, 1).String(),
},
},
{
name: "unregistered path(not whitelisted)",
path: "/osmosis.lockup.Query/AccountLockedLongerDuration",
Expand Down
4 changes: 3 additions & 1 deletion wasmbinding/stargate_whitelist.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,11 @@ import (
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
ibctransfertypes "github.com/cosmos/ibc-go/v4/modules/apps/transfer/types"

gammv2types "github.com/osmosis-labs/osmosis/v16/x/gamm/v2types"

concentratedliquidityquery "github.com/osmosis-labs/osmosis/v16/x/concentrated-liquidity/client/queryproto"
downtimequerytypes "github.com/osmosis-labs/osmosis/v16/x/downtime-detector/client/queryproto"
gammtypes "github.com/osmosis-labs/osmosis/v16/x/gamm/types"
gammv2types "github.com/osmosis-labs/osmosis/v16/x/gamm/v2types"
incentivestypes "github.com/osmosis-labs/osmosis/v16/x/incentives/types"
lockuptypes "github.com/osmosis-labs/osmosis/v16/x/lockup/types"
minttypes "github.com/osmosis-labs/osmosis/v16/x/mint/types"
Expand Down Expand Up @@ -131,6 +132,7 @@ func init() {
setWhitelistedQuery("/osmosis.poolmanager.v1beta1.Query/EstimateSinglePoolSwapExactAmountIn", &poolmanagerqueryproto.EstimateSwapExactAmountInResponse{})
setWhitelistedQuery("/osmosis.poolmanager.v1beta1.Query/EstimateSinglePoolSwapExactAmountOut", &poolmanagerqueryproto.EstimateSwapExactAmountOutResponse{})
setWhitelistedQuery("/osmosis.poolmanager.v1beta1.Query/Pool", &poolmanagerqueryproto.PoolResponse{})
setWhitelistedQuery("/osmosis.poolmanager.v1beta1.Query/SpotPrice", &poolmanagerqueryproto.SpotPriceResponse{})

// txfees
setWhitelistedQuery("/osmosis.txfees.v1beta1.Query/FeeTokens", &txfeestypes.QueryFeeTokensResponse{})
Expand Down

0 comments on commit 4abfde5

Please sign in to comment.