diff --git a/components/portfolio/CurrenciesTable.tsx b/components/portfolio/CurrenciesTable.tsx index 22fee932d..60d0fb550 100644 --- a/components/portfolio/CurrenciesTable.tsx +++ b/components/portfolio/CurrenciesTable.tsx @@ -16,7 +16,6 @@ import { ChainName, CHAIN_IMAGES } from "lib/constants/chains"; import TransferButton from "./TransferButton"; import { AssetId } from "@zeitgeistpm/sdk"; import { convertDecimals } from "lib/util/convert-decimals"; -import { isWSX } from "lib/constants"; import { useMemo } from "react"; import { usePrevious } from "lib/hooks/usePrevious"; import { isNotNull } from "@zeitgeistpm/utility/dist/null"; @@ -125,16 +124,10 @@ const MoveButton = ({ }; const CurrenciesTable = ({ address }: { address: string }) => { - const { data: allBalances, isFetched } = useCurrencyBalances(address); + const { data: balances, isFetched } = useCurrencyBalances(address); const { data: constants } = useChainConstants(); const wasFetched = usePrevious(isFetched); - const balances = useMemo(() => { - return isWSX - ? allBalances?.filter((b) => b.symbol === "WSX") - : allBalances?.filter((b) => b.symbol !== "WSX"); - }, [isWSX, allBalances]); - // set sort order only once when data is first fetched // sort by balance descending, but keep sorting on subsequent renders/balance updates. const sorting = useMemo(() => { diff --git a/lib/constants/foreign-asset.ts b/lib/constants/foreign-asset.ts index 05644eb3c..fa2c0ea8a 100644 --- a/lib/constants/foreign-asset.ts +++ b/lib/constants/foreign-asset.ts @@ -47,20 +47,6 @@ const BATTERY_STATION_FOREIGN_ASSET_METADATA: ForeignAssetMetadata = { coinGeckoId: "polkadot", tokenSymbol: "ROC", }, - 3: { - //todo: add WSX logo - image: "/currencies/ausd.jpg", - withdrawSupported: false, - coinGeckoId: "polkadot", - tokenSymbol: "WSX", - }, - 4: { - //todo: add NTT logo - image: "/currencies/ausd.jpg", - withdrawSupported: false, - coinGeckoId: "polkadot", - tokenSymbol: "NTT", - }, }; const PROD_FOREIGN_ASSET_METADATA: ForeignAssetMetadata = { diff --git a/lib/constants/index.ts b/lib/constants/index.ts index 10b02d362..d831c01ce 100644 --- a/lib/constants/index.ts +++ b/lib/constants/index.ts @@ -3,11 +3,10 @@ import resolveTailwindConfig from "tailwindcss/resolveConfig"; import tailwindConfig from "../../tailwind.config"; import { EndpointOption, Environment } from "../types"; -// IMPORTANT: this should be false for all other branches other than the wsx branch. -export const isWSX = false; - -export const wsxID = process.env.NEXT_PUBLIC_VERCEL_ENV === "staging" ? 3 : 2; -export const wsxAssetIdString = `{"foreignAsset":${wsxID}}`; +//for campaign assets +export const campaignAssetID = + process.env.NEXT_PUBLIC_VERCEL_ENV === "staging" ? 0 : 0; //may need to change ID on mainnet +export const campaignAssetIdString = `{"foreignAsset":${campaignAssetID}}`; export const ZTG = 10 ** 10; diff --git a/lib/constants/supported-currencies.ts b/lib/constants/supported-currencies.ts index bfa872352..4e7a8b2b6 100644 --- a/lib/constants/supported-currencies.ts +++ b/lib/constants/supported-currencies.ts @@ -35,6 +35,16 @@ export const supportedCurrencies = [ } satisfies CurrencyMetadata, ] as const; +export const supportedCurrenciesFilter = supportedCurrencies.map((currency) => { + const assetKey = Object.keys(currency.assetId)[0]; + const assetValue = currency.assetId[assetKey]; + return assetValue === null + ? assetKey + : `{ "${assetKey.charAt(0).toLowerCase()}${assetKey.slice( + 1, + )}": ${assetValue} }`; +}); + export type SupportedCurrencyTag = Unpacked< typeof supportedCurrencies >[number]["name"]; diff --git a/lib/gql/constants.ts b/lib/gql/constants.ts index a1623b780..f8fd663a8 100644 --- a/lib/gql/constants.ts +++ b/lib/gql/constants.ts @@ -1,5 +1,5 @@ -import { isWSX, wsxID } from "lib/constants"; +import { supportedCurrenciesFilter } from "lib/constants/supported-currencies"; -export const marketMetaFilter = isWSX - ? `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}}"`; +export const marketMetaFilter = `question_not_eq: "", question_isNull: false, categories_isNull: false, hasValidMetaCategories_eq: true, scoringRule_not_eq: Parimutuel, baseAsset_in: ${JSON.stringify( + supportedCurrenciesFilter, +)}`; diff --git a/lib/hooks/queries/constants.ts b/lib/hooks/queries/constants.ts index 32f58ead1..253accc6c 100644 --- a/lib/hooks/queries/constants.ts +++ b/lib/hooks/queries/constants.ts @@ -2,25 +2,16 @@ import { MarketWhereInput, HistoricalSwapWhereInput, } from "@zeitgeistpm/indexer"; -import { isWSX, wsxAssetIdString, wsxID } from "lib/constants"; +import { supportedCurrenciesFilter } from "../../constants/supported-currencies"; export const marketMetaFilter: MarketWhereInput = { question_isNull: false, question_not_eq: "", categories_isNull: false, hasValidMetaCategories_eq: true, - ...(isWSX ? { baseAsset_eq: wsxAssetIdString } : {}), - ...(!isWSX ? { baseAsset_not_eq: wsxAssetIdString } : {}), + baseAsset_in: supportedCurrenciesFilter, }; export const swapsMetaFilter: HistoricalSwapWhereInput = { - ...(isWSX - ? { - assetIn_eq: wsxAssetIdString, - assetOut_eq: wsxAssetIdString, - } - : { - assetIn_not_eq: wsxAssetIdString, - assetOut_not_eq: wsxAssetIdString, - }), + assetIn_in: supportedCurrenciesFilter, }; diff --git a/lib/hooks/queries/useInfiniteMarkets.ts b/lib/hooks/queries/useInfiniteMarkets.ts index ae93bd716..1fee07024 100644 --- a/lib/hooks/queries/useInfiniteMarkets.ts +++ b/lib/hooks/queries/useInfiniteMarkets.ts @@ -18,8 +18,8 @@ import { FullCmsMarketMetadata } from "lib/cms/markets"; import { marketCmsDatakeyForMarket } from "./cms/useMarketCmsMetadata"; import { marketMetaFilter } from "./constants"; import { marketsRootQuery } from "./useMarket"; +import { supportedCurrenciesFilter } from "../../constants/supported-currencies"; -import { tryCatch } from "@zeitgeistpm/utility/dist/either"; import { WHITELISTED_TRUSTED_CREATORS } from "lib/constants/whitelisted-trusted-creators"; export const rootKey = "markets-filtered"; @@ -77,7 +77,8 @@ export const useInfiniteMarkets = ( status_not_in: [MarketStatus.Destroyed], status_in: statuses.length === 0 ? undefined : statuses, tags_containsAny: tags?.length === 0 ? undefined : tags, - baseAsset_in: currencies?.length !== 0 ? currencies : undefined, + baseAsset_in: + currencies?.length !== 0 ? currencies : supportedCurrenciesFilter, scoringRule_not_eq: ScoringRule.Parimutuel, }, { diff --git a/lib/hooks/queries/useMarketSearch.ts b/lib/hooks/queries/useMarketSearch.ts index 0569b3373..b51ead7d3 100644 --- a/lib/hooks/queries/useMarketSearch.ts +++ b/lib/hooks/queries/useMarketSearch.ts @@ -2,9 +2,9 @@ import { useQuery } from "@tanstack/react-query"; import { MarketOrderByInput, ZeitgeistIndexer } from "@zeitgeistpm/indexer"; import { isIndexedSdk } from "@zeitgeistpm/sdk"; import Fuse from "fuse.js"; -import { isWSX, wsxID } from "lib/constants"; import { useDebounce } from "use-debounce"; import { useSdkv2 } from "../useSdkv2"; +import { supportedCurrenciesFilter } from "lib/constants/supported-currencies"; export const marketSearchKey = "market-search"; @@ -41,8 +41,7 @@ export const searchMarketsText = async ( where: { AND: [ { - baseAsset_eq: isWSX ? `{"foreignAsset":${wsxID}}` : undefined, - baseAsset_not_eq: !isWSX ? `{"foreignAsset":${wsxID}}` : undefined, + baseAsset_in: supportedCurrenciesFilter, }, { OR: search,