diff --git a/.prettierrc.json b/.prettierrc.json new file mode 100644 index 0000000000..757fd64caa --- /dev/null +++ b/.prettierrc.json @@ -0,0 +1,3 @@ +{ + "trailingComma": "es5" +} diff --git a/packages/grant-explorer/src/features/round/ViewCartPage/RoundInCart.tsx b/packages/grant-explorer/src/features/round/ViewCartPage/RoundInCart.tsx index 7576c76539..3e000d8116 100644 --- a/packages/grant-explorer/src/features/round/ViewCartPage/RoundInCart.tsx +++ b/packages/grant-explorer/src/features/round/ViewCartPage/RoundInCart.tsx @@ -45,13 +45,16 @@ export function RoundInCart( roundId: getAddress(round?.id ?? zeroAddress), chainId: props.roundCart[0].chainId, potentialVotes: props.roundCart.map((proj) => ({ + roundId: getAddress(round?.id ?? zeroAddress), + projectId: proj.projectRegistryId, amount: parseUnits( proj.amount ?? "0", votingTokenForChain.decimal ?? 18 ), - recipient: proj.recipient, - contributor: address ?? zeroAddress, + grantAddress: proj.recipient, + voter: address ?? zeroAddress, token: votingTokenForChain.address.toLowerCase(), + applicationId: proj.grantApplicationId, })), }, ]); diff --git a/packages/grant-explorer/src/features/round/ViewCartPage/SummaryContainer.tsx b/packages/grant-explorer/src/features/round/ViewCartPage/SummaryContainer.tsx index 52be5e662c..ebd779e2a3 100644 --- a/packages/grant-explorer/src/features/round/ViewCartPage/SummaryContainer.tsx +++ b/packages/grant-explorer/src/features/round/ViewCartPage/SummaryContainer.tsx @@ -295,11 +295,14 @@ export function SummaryContainer() { proj.amount ?? "0", getVotingTokenForChain(parseChainId(proj.chainId)).decimal ?? 18 ), - recipient: proj.recipient, - contributor: address as Address, + grantAddress: proj.recipient, + voter: address as Address, token: getVotingTokenForChain( parseChainId(proj.chainId) ).address.toLowerCase(), + projectId: proj.projectRegistryId, + applicationId: proj.grantApplicationId, + roundId: getAddress(round.id ?? ""), })), }; }) ?? []; diff --git a/packages/grant-explorer/src/hooks/matchingEstimate.ts b/packages/grant-explorer/src/hooks/matchingEstimate.ts index 40967c3ed6..92250ea846 100644 --- a/packages/grant-explorer/src/hooks/matchingEstimate.ts +++ b/packages/grant-explorer/src/hooks/matchingEstimate.ts @@ -21,10 +21,13 @@ type UseMatchingEstimatesParams = { roundId: Address; chainId: ChainId; potentialVotes: { - contributor: string; - recipient: string; - amount: bigint; + projectId: string; + roundId: string; + applicationId: string; token: string; + voter: string; + grantAddress: string; + amount: bigint; }[]; }; @@ -35,11 +38,19 @@ interface JSONObject { } function getMatchingEstimates( - params: UseMatchingEstimatesParams, + params: UseMatchingEstimatesParams ): Promise { const replacer = (_key: string, value: JSONValue) => typeof value === "bigint" ? value.toString() : value; + /* The indexer wants just the application id number, not the whole application */ + const fixedApplicationId = params.potentialVotes.map((vote) => ({ + ...vote, + applicationId: vote.applicationId.includes("-") + ? vote.applicationId.split("-")[1] + : vote.applicationId, + })); + return fetch( `${process.env.REACT_APP_ALLO_API_URL}/api/v1/chains/${params.chainId}/rounds/${params.roundId}/estimate`, { @@ -47,9 +58,9 @@ function getMatchingEstimates( Accept: "application/json", "content-type": "application/json", }, - body: JSON.stringify({ potentialVotes: params.potentialVotes }, replacer), + body: JSON.stringify({ potentialVotes: fixedApplicationId }, replacer), method: "POST", - }, + } ).then((r) => r.json()); } @@ -59,12 +70,12 @@ function getMatchingEstimates( */ export function useMatchingEstimates(params: UseMatchingEstimatesParams[]) { return useSWR(params, (params) => - Promise.all(params.map((params) => getMatchingEstimates(params))), + Promise.all(params.map((params) => getMatchingEstimates(params))) ); } export function matchingEstimatesToText( - matchingEstimates?: MatchingEstimateResult[][], + matchingEstimates?: MatchingEstimateResult[][] ) { return matchingEstimates ?.flat()