Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: lowercase roundId on round page & application page #3418

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,12 @@ import {
VerifiableCredential,
} from "@gitcoinco/passport-sdk-types";
import { ShieldCheckIcon } from "@heroicons/react/24/solid";
import { PassportVerifierWithExpiration, formatDateWithOrdinal, renderToHTML, useParams } from "common";
import {
PassportVerifierWithExpiration,
formatDateWithOrdinal,
renderToHTML,
useParams,
} from "common";
import { getAlloVersion } from "common/src/config";
import { formatDistanceToNowStrict } from "date-fns";
import React, {
Expand Down Expand Up @@ -91,12 +96,13 @@ export default function ViewProjectDetails() {
datadogLogs.logger.info(`====> URL: ${window.location.href}`);
const {
chainId,
roundId,
roundId: paramRoundId,
applicationId: paramApplicationId,
} = useProjectDetailsParams();
const dataLayer = useDataLayer();
const { address: walletAddress } = useAccount();

const roundId = paramRoundId.toLowerCase();
let applicationId: string;

/// handle URLs where the application ID is ${roundId}-${applicationId}
Expand All @@ -122,7 +128,9 @@ export default function ViewProjectDetails() {
round?.roundMetadata?.quadraticFundingConfig?.sybilDefense === true;

const { grants } = useGap(projectToRender?.projectRegistryId as string);
const { stats } = useOSO(projectToRender?.projectMetadata.projectGithub as string);
const { stats } = useOSO(
projectToRender?.projectMetadata.projectGithub as string
);

const currentTime = new Date();
const isAfterRoundEndDate =
Expand Down Expand Up @@ -537,12 +545,12 @@ function Sidebar(props: {

export function ProjectStats() {
const { chainId, roundId, applicationId } = useProjectDetailsParams();
const { round } = useRoundById(Number(chainId), roundId);
const { round } = useRoundById(Number(chainId), roundId.toLowerCase());
const dataLayer = useDataLayer();
const { data: application } = useApplication(
{
chainId: Number(chainId as string),
roundId,
roundId: roundId.toLowerCase(),
applicationId: applicationId,
},
dataLayer
Expand Down Expand Up @@ -670,7 +678,8 @@ async function isVerified(args: {
const { verifiableCredential, provider, project } = args;

const passportVerifier = new PassportVerifierWithExpiration();
const vcHasValidProof = await passportVerifier.verifyCredential(verifiableCredential);
const vcHasValidProof =
await passportVerifier.verifyCredential(verifiableCredential);

const vcIssuedByValidIAMServer = verifiableCredential.issuer === IAM_SERVER;
const providerMatchesProject = vcProviderMatchesProject(
Expand Down
19 changes: 9 additions & 10 deletions packages/grant-explorer/src/features/round/ViewRoundPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
useMemo,
useState,
} from "react";
import { payoutTokens, PayoutToken } from "common/src/payoutTokens";
import {
CalendarIcon,
ChainId,
Expand All @@ -18,7 +19,6 @@ import {
renderToPlainText,
truncateDescription,
useTokenPrice,
VotingToken,
} from "common";
import { Button, Input } from "common/src/styles";
import AlloV1 from "common/src/icons/AlloV1";
Expand All @@ -37,7 +37,6 @@ import {
getDaysLeft,
isDirectRound,
isInfiniteDate,
votingTokens,
} from "../api/utils";
import { PassportWidget } from "../common/PassportWidget";

Expand Down Expand Up @@ -124,15 +123,15 @@ export default function ViewRound() {
<BeforeRoundStart
round={round}
chainId={chainId}
roundId={roundId}
roundId={roundId.toLowerCase()}
/>
)}

{isAfterRoundStartDate && (
<AfterRoundStart
round={round}
chainId={Number(chainId)}
roundId={roundId}
roundId={roundId.toLowerCase()}
isBeforeRoundEndDate={isBeforeRoundEndDate}
isAfterRoundEndDate={isAfterRoundEndDate}
/>
Expand Down Expand Up @@ -295,10 +294,10 @@ function AfterRoundStart(props: {
chainId: Number(props.chainId),
});

const nativePayoutToken = votingTokens.find(
const nativePayoutToken = payoutTokens.find(
(t) =>
t.chainId === Number(props.chainId) &&
t.address === getAddress(props.round.token)
t.address.toLowerCase() === getAddress(props.round.token).toLowerCase()
);

const tokenData = data ?? {
Expand Down Expand Up @@ -869,7 +868,7 @@ const RoundStatsTabContent = ({
roundId: string;
round: Round;
chainId: ChainId;
token?: VotingToken;
token?: PayoutToken;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why did the type change here?

Copy link
Contributor Author

@cristinalare cristinalare May 8, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

because ARBITRUM_TOKENS from votingTokens (which was used before) don't have GTC - see here

so i switched to using payoutTokens

export const payoutTokens = [

let me know if im missing smth/this has any side effects

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The types are different and we should consider adding GTC to votingToken. Maybe you can change it back and raise an additional PR?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done! 3e331af

here's the additional PR: #3425

tokenSymbol?: string;
}): JSX.Element => {
const [isShareModalOpen, setIsShareModalOpen] = useState(false);
Expand Down Expand Up @@ -994,7 +993,7 @@ const Stats = ({
totalCrowdfunded: number;
totalProjects: number;
chainId: number;
token?: VotingToken;
token?: PayoutToken;
tokenSymbol?: string;
totalDonations: number;
totalDonors: number;
Expand Down Expand Up @@ -1204,10 +1203,10 @@ function PreRoundPage(props: {
chainId: Number(chainId),
});

const nativePayoutToken = votingTokens.find(
const nativePayoutToken = payoutTokens.find(
(t) =>
t.chainId === Number(chainId) &&
t.address === getAddress(props.round.token)
t.address.toLowerCase() === getAddress(props.round.token).toLowerCase()
);

const tokenData = data ?? {
Expand Down
Loading