From 569d3cc325cf571c980c353a09daf72a19a5cea8 Mon Sep 17 00:00:00 2001 From: Deividas Petraitis Date: Wed, 4 Dec 2024 14:24:14 +0200 Subject: [PATCH] BE-636 | Fix search bug (#588) Fixes a bug when searching pool by pair of tokens for /pools endpoint (cherry picked from commit 9262f8090a7e753d35ce3539b28090abe670f9c2) --- pools/usecase/pools_usecase.go | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/pools/usecase/pools_usecase.go b/pools/usecase/pools_usecase.go index 6dfd9bc6..82ebfd13 100644 --- a/pools/usecase/pools_usecase.go +++ b/pools/usecase/pools_usecase.go @@ -405,7 +405,14 @@ var filterExactMatchSearch = func(tokenMetadataHolder TokenMetadataHolder, searc return func(pool sqsdomain.PoolI) bool { var coinDenoms []string - for _, denom := range pool.GetSQSPoolModel().PoolDenoms { + var denoms []string + if pool.GetSQSPoolModel().CosmWasmPoolModel != nil { + denoms = pool.GetPoolDenoms() + } else { + denoms = pool.GetUnderlyingPool().GetPoolDenoms(sdk.Context{}) + } + + for _, denom := range denoms { token, err := tokenMetadataHolder.GetMetadataByChainDenom(denom) if err != nil { continue @@ -432,7 +439,14 @@ var filterPartialMatchSearch = func(tokenMetadataHolder TokenMetadataHolder, sea var poolNameByDenom string var coinnames []string - for _, denom := range pool.GetSQSPoolModel().PoolDenoms { + var denoms []string + if pool.GetSQSPoolModel().CosmWasmPoolModel != nil { + denoms = pool.GetPoolDenoms() + } else { + denoms = pool.GetUnderlyingPool().GetPoolDenoms(sdk.Context{}) + } + + for _, denom := range denoms { token, err := tokenMetadataHolder.GetMetadataByChainDenom(denom) if err != nil { continue