From f9aa59f0b92ad22f4bf33c8c70205310ca341753 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rn=20Andre=20Tangen=20=40gorillatron?= Date: Tue, 20 Feb 2024 10:35:02 +0100 Subject: [PATCH 1/2] filter parimituel apps + filter trusted markets(except whitelisted) for recommended markets --- lib/constants/whitelisted-trusted-creators.ts | 5 ++++ lib/hooks/queries/useInfiniteMarkets.ts | 6 ++--- lib/hooks/queries/useRecommendedMarkets.ts | 26 ++++++++++++++++--- 3 files changed, 29 insertions(+), 8 deletions(-) create mode 100644 lib/constants/whitelisted-trusted-creators.ts 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/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 { From bbabdf8eb67033b33e9a92d93f48b8d77c832d32 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rn=20Andre=20Tangen=20=40gorillatron?= Date: Wed, 21 Feb 2024 10:46:23 +0100 Subject: [PATCH 2/2] add parimutuel filtering to market meta filters --- lib/gql/constants.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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}}"`;