Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix ListPoolsByDenom method #7341

Merged
merged 4 commits into from
Feb 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Bug Fixes

* [#7360](https://github.com/osmosis-labs/osmosis/pull/7360) fix: use gov type for SetScalingFactorController
* [#7341](https://github.com/osmosis-labs/osmosis/pull/7341) fix: support CosmWasm pools in ListPoolsByDenom method

### Misc Improvements

Expand Down
5 changes: 4 additions & 1 deletion x/poolmanager/router.go
Original file line number Diff line number Diff line change
Expand Up @@ -577,7 +577,10 @@ func (k Keeper) ListPoolsByDenom(

var poolsByDenom []types.PoolI
for _, pool := range currentModulePools {
poolDenoms := pool.GetPoolDenoms(ctx)
poolDenoms, err := poolModule.GetPoolDenoms(ctx, pool.GetId())
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we add test case where we have error from this?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have been thinking about this logic and I wonder if instead of returning an error should any pools that dont expose the denoms be skipped? considering the case for future cosm wasm pools, we would be relying that every single potential contract has the query implemented (correctly)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I think they should be skipped, filing as a new issue!

if err != nil {
return nil, err
}
if osmoutils.Contains(poolDenoms, denom) {
poolsByDenom = append(poolsByDenom, pool)
}
Expand Down
8 changes: 8 additions & 0 deletions x/poolmanager/router_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3870,6 +3870,14 @@ func (suite *KeeperTestSuite) TestListPoolsByDenom() {
denom: BAR,
expectedNumPools: 2,
},
"A cosmwasm pool": {
poolType: []types.PoolType{types.CosmWasm},
poolCoins: []sdk.Coins{
sdk.NewCoins(sdk.NewCoin(BAR, defaultInitPoolAmount), sdk.NewCoin(UOSMO, defaultInitPoolAmount)), // pool 1 bar-uosmo
},
denom: BAR,
expectedNumPools: 1,
},
}

for name, tc := range tests {
Expand Down