Skip to content

Commit

Permalink
feat: don't display matching estimates for polygon
Browse files Browse the repository at this point in the history
  • Loading branch information
vacekj committed Nov 20, 2023
1 parent 3854896 commit ef17c25
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { CartProject, VotingToken } from "../../api/types";
import { useRoundById } from "../../../context/RoundContext";
import { ProjectInCart } from "./ProjectInCart";
import {
DISABLED_CHAINS_FOR_ESTIMATES,
matchingEstimatesToText,
useMatchingEstimates,
} from "../../../hooks/matchingEstimate";
Expand Down Expand Up @@ -36,7 +37,7 @@ export function RoundInCart(
);

const {
data: matchingEstimates,
data,
error: matchingEstimateError,
isLoading: matchingEstimateLoading,
} = useMatchingEstimates([
Expand All @@ -58,6 +59,11 @@ export function RoundInCart(
},
]);

const matchingEstimates = DISABLED_CHAINS_FOR_ESTIMATES.includes(
props.roundCart[0]?.chainId
)
? undefined
: data;
const estimateText = matchingEstimatesToText(matchingEstimates);

const { passportColor } = usePassport({
Expand Down
10 changes: 9 additions & 1 deletion packages/grant-explorer/src/hooks/matchingEstimate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,14 +64,22 @@ function getMatchingEstimates(
).then((r) => r.json());
}

export const DISABLED_CHAINS_FOR_ESTIMATES = [ChainId.POLYGON];

/**
* Fetches matching estimates for the given rounds, given potential votes, as an array
* For a single round, pass in an array with a single element
*/
export function useMatchingEstimates(params: UseMatchingEstimatesParams[]) {
const shouldFetch = params.every((param) => param.roundId !== zeroAddress);
return useSWRImmutable(shouldFetch ? params : null, (params) =>
Promise.all(params.map((params) => getMatchingEstimates(params)))
Promise.all(
params
.filter(
(param) => !DISABLED_CHAINS_FOR_ESTIMATES.includes(param.chainId)
)
.map((params) => getMatchingEstimates(params))
)
);
}

Expand Down

0 comments on commit ef17c25

Please sign in to comment.