diff --git a/apps/web/src/data/subgraph/requests/daoQuery.ts b/apps/web/src/data/subgraph/requests/daoQuery.ts index 0645190b..77398e8f 100644 --- a/apps/web/src/data/subgraph/requests/daoQuery.ts +++ b/apps/web/src/data/subgraph/requests/daoQuery.ts @@ -21,7 +21,7 @@ export const myDaosRequest = async ( ): Promise => { let daos: MyDaosResponse = [] - if (!memberAddress) return + if (!memberAddress) throw new Error('No user address provided') try { const data = await Promise.all( diff --git a/apps/web/src/data/subgraph/requests/exploreQueries.ts b/apps/web/src/data/subgraph/requests/exploreQueries.ts index 73532969..9e887e8b 100644 --- a/apps/web/src/data/subgraph/requests/exploreQueries.ts +++ b/apps/web/src/data/subgraph/requests/exploreQueries.ts @@ -12,34 +12,41 @@ import { } from '../sdk.generated' import { MyDaosResponse } from './daoQuery' -export type ExploreDaoWithChainId = ExploreDaoFragment & { chainId?: CHAIN_ID } +export type ExploreDaoWithChainId = ExploreDaoFragment & { chainId: CHAIN_ID } export interface ExploreDaosResponse { daos: ExploreDaoWithChainId[] hasNextPage: boolean } -export const userDaosFilter = async ( +export const exploreMyDaosRequest = async ( memberAddress: string ): Promise => { - const userDaos = await axios - .get(`/api/daos/${memberAddress}`) - .then((x) => x.data) - - const daoChains = new Set(userDaos.map((x) => x.chainId)) - - const data = await Promise.all( - Array.from(daoChains).map(async (chainId) => { - const daosByChain = userDaos - .filter((x) => x.chainId === chainId) - .map((x) => x.collectionAddress) - const res = await SDK.connect(chainId).myDaosPage({ daos: daosByChain }) - return res.auctions.map((x) => ({ ...x, chainId })) - }) - ) + try { + const userDaos = await axios + .get(`/api/daos/${memberAddress}`) + .then((x) => x.data) + + const daoChains = new Set(userDaos.map((x) => x.chainId)) + + const data = await Promise.all( + Array.from(daoChains).map(async (chainId) => { + const daosByChain = userDaos + .filter((x) => x.chainId === chainId) + .map((x) => x.collectionAddress) + const res = await SDK.connect(chainId).myDaosPage({ daos: daosByChain }) + return res.auctions.map((x) => ({ ...x, chainId })) + }) + ) - const auctions = data.flat().sort((a, b) => a.dao.name.localeCompare(b.dao.name)) - return { daos: auctions, hasNextPage: false } + const auctions = data.flat().sort((a, b) => a.dao.name.localeCompare(b.dao.name)) + return { daos: auctions, hasNextPage: false } + } catch (error) { + console.error(error) + Sentry.captureException(error) + await Sentry.flush(2000) + return undefined + } } export const exploreDaosRequest = async ( @@ -86,7 +93,10 @@ export const exploreDaosRequest = async ( }) if (!data.auctions) return undefined - return { daos: data.auctions, hasNextPage: data.auctions.length === first } + return { + daos: data.auctions.map((x) => ({ ...x, chainId })), + hasNextPage: data.auctions.length === first, + } } catch (error) { console.error(error) Sentry.captureException(error) diff --git a/apps/web/src/modules/dao/components/About/About.tsx b/apps/web/src/modules/dao/components/About/About.tsx index ab3908ff..0a945f47 100644 --- a/apps/web/src/modules/dao/components/About/About.tsx +++ b/apps/web/src/modules/dao/components/About/About.tsx @@ -169,7 +169,7 @@ export const About: React.FC = () => { Founders - {typeof founders !== 'undefined' && founders?.length > 0 ? ( + {founders && founders?.length > 0 ? ( {founders .filter((founder) => founder.ownershipPct > 0) diff --git a/apps/web/src/modules/dao/components/Explore/ExploreMyDaos.tsx b/apps/web/src/modules/dao/components/Explore/ExploreMyDaos.tsx index 73d2c58c..d3818172 100644 --- a/apps/web/src/modules/dao/components/Explore/ExploreMyDaos.tsx +++ b/apps/web/src/modules/dao/components/Explore/ExploreMyDaos.tsx @@ -4,7 +4,7 @@ import React from 'react' import useSWR from 'swr' import SWR_KEYS from 'src/constants/swrKeys' -import { userDaosFilter } from 'src/data/subgraph/requests/exploreQueries' +import { exploreMyDaosRequest } from 'src/data/subgraph/requests/exploreQueries' import { useLayoutStore } from 'src/stores' import { DaoCard } from '../DaoCard' @@ -18,7 +18,7 @@ export const ExploreMyDaos = () => { const { data, error, isValidating } = useSWR( signerAddress ? [SWR_KEYS.DYNAMIC.MY_DAOS_PAGE(signerAddress as string)] : null, - () => userDaosFilter(signerAddress as string), + () => exploreMyDaosRequest(signerAddress as string), { revalidateOnFocus: false } ) @@ -35,11 +35,9 @@ export const ExploreMyDaos = () => { const bid = dao.highestBid?.amount ?? undefined const bidInEth = bid ? ethers.utils.formatEther(bid) : undefined - if (!dao.chainId) return null - return (