diff --git a/lib/constants/whitelisted-trusted-creators.ts b/lib/constants/whitelisted-trusted-creators.ts new file mode 100644 index 000000000..eb6ce7e25 --- /dev/null +++ b/lib/constants/whitelisted-trusted-creators.ts @@ -0,0 +1,5 @@ +import { tryCatch } from "@zeitgeistpm/utility/dist/either"; + +export const WHITELISTED_TRUSTED_CREATORS: string[] = tryCatch(() => + JSON.parse(process.env.NEXT_PUBLIC_WHITELISTED_TRUSTED_CREATORS as string), +).unwrapOr([]); diff --git a/lib/gql/constants.ts b/lib/gql/constants.ts index 7ff35ef4c..a1623b780 100644 --- a/lib/gql/constants.ts +++ b/lib/gql/constants.ts @@ -1,5 +1,5 @@ import { isWSX, wsxID } from "lib/constants"; export const marketMetaFilter = isWSX - ? `question_not_eq: "", question_isNull: false, categories_isNull: false, hasValidMetaCategories_eq: true, baseAsset_eq: "{\\"foreignAsset\\":${wsxID}}"` - : `question_not_eq: "", question_isNull: false, categories_isNull: false, hasValidMetaCategories_eq: true, baseAsset_not_eq: "{\\"foreignAsset\\":${wsxID}}"`; + ? `question_not_eq: "", question_isNull: false, categories_isNull: false, hasValidMetaCategories_eq: true, scoringRule_not_eq: Parimutuel, baseAsset_eq: "{\\"foreignAsset\\":${wsxID}}"` + : `question_not_eq: "", question_isNull: false, categories_isNull: false, hasValidMetaCategories_eq: true, scoringRule_not_eq: Parimutuel, baseAsset_not_eq: "{\\"foreignAsset\\":${wsxID}}"`; diff --git a/lib/hooks/queries/useInfiniteMarkets.ts b/lib/hooks/queries/useInfiniteMarkets.ts index 858489e88..286d0dcb9 100644 --- a/lib/hooks/queries/useInfiniteMarkets.ts +++ b/lib/hooks/queries/useInfiniteMarkets.ts @@ -20,6 +20,7 @@ import { marketMetaFilter } from "./constants"; import { marketsRootQuery } from "./useMarket"; import { tryCatch } from "@zeitgeistpm/utility/dist/either"; +import { WHITELISTED_TRUSTED_CREATORS } from "lib/constants/whitelisted-trusted-creators"; export const rootKey = "markets-filtered"; @@ -40,10 +41,6 @@ export type QueryMarketData = Market & { prediction: { name: string; price: number }; }; -const WHITELISTED_TRUSTED_CREATORS: string[] = tryCatch(() => - JSON.parse(process.env.NEXT_PUBLIC_WHITELISTED_TRUSTED_CREATORS as string), -).unwrapOr([]); - export const useInfiniteMarkets = ( orderBy: MarketsOrderBy, withLiquidityOnly = false, @@ -81,6 +78,7 @@ export const useInfiniteMarkets = ( status_in: statuses.length === 0 ? undefined : statuses, tags_containsAny: tags?.length === 0 ? undefined : tags, baseAsset_in: currencies?.length !== 0 ? currencies : undefined, + scoringRule_not_eq: ScoringRule.Parimutuel, }, { disputeMechanism_isNull: false, diff --git a/lib/hooks/queries/useRecommendedMarkets.ts b/lib/hooks/queries/useRecommendedMarkets.ts index 2d002de59..e9712dce6 100644 --- a/lib/hooks/queries/useRecommendedMarkets.ts +++ b/lib/hooks/queries/useRecommendedMarkets.ts @@ -1,9 +1,14 @@ import { useQuery } from "@tanstack/react-query"; -import { MarketOrderByInput, MarketStatus } from "@zeitgeistpm/indexer"; +import { + MarketOrderByInput, + MarketStatus, + ScoringRule, +} from "@zeitgeistpm/indexer"; import { isIndexedSdk } from "@zeitgeistpm/sdk"; import { useSdkv2 } from "../useSdkv2"; import { useMarket } from "./useMarket"; import { searchMarketsText } from "./useMarketSearch"; +import { WHITELISTED_TRUSTED_CREATORS } from "lib/constants/whitelisted-trusted-creators"; export const recommendedMarketsRootKey = "recommended-markets"; @@ -34,9 +39,22 @@ export const useRecommendedMarkets = (marketId?: number, limit = 2) => { limit, order: [MarketOrderByInput.VolumeDesc], where: { - status_eq: MarketStatus.Active, - marketId_not_eq: marketId, - volume_gt: "0", + AND: [ + { + status_eq: MarketStatus.Active, + marketId_not_eq: marketId, + volume_gt: "0", + scoringRule_not_eq: ScoringRule.Parimutuel, + }, + { + disputeMechanism_isNull: false, + OR: [ + { + creator_in: WHITELISTED_TRUSTED_CREATORS, + }, + ], + }, + ], }, }); return {