Skip to content

Commit

Permalink
Use bountyIndex instead of bountyId
Browse files Browse the repository at this point in the history
  • Loading branch information
guidanoli committed Jun 20, 2024
1 parent 89199d0 commit 2f08918
Showing 1 changed file with 23 additions and 15 deletions.
38 changes: 23 additions & 15 deletions frontend/src/app/bounty/[bountyId]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import { SendExploit } from "../../../model/inputs";
import { usePrepareWithdrawSponsorship } from "../../../hooks/bug-buster";
import { useInputBoxAddInput } from "../../../hooks/contracts";

import { BountyParams } from "./utils";
import { BountyParams, ConcreteBountyParams } from "./utils";
import { useBlockTimestamp } from "../../../hooks/block";
import { BountyStatus } from "../../../model/bountyStatus";
import { getBountyStatus } from "../../../utils/bounty";
Expand All @@ -36,10 +36,9 @@ import { LinkButton } from "../../../components/linkbtn";
import { HasConnectedAccount } from "../../../components/hasConnectedAccount";

const WithdrawButton: FC<{
bountyId: string;
bountyIndex: number;
disabled: boolean;
}> = ({ bountyId, disabled }) => {
const bountyIndex = Number(bountyId);
}> = ({ bountyIndex, disabled }) => {
const config = usePrepareWithdrawSponsorship({ bountyIndex });
const { data, write } = useInputBoxAddInput(config);
const { isLoading, isSuccess } = useWaitForTransaction({
Expand All @@ -62,29 +61,35 @@ const WithdrawButton: FC<{
};

const ButtonsBox: FC<{
bountyId: string;
bountyIndex: number;
bountyStatus: BountyStatus;
}> = ({ bountyId, bountyStatus }) => {
}> = ({ bountyIndex, bountyStatus }) => {
const isOpen = bountyStatus.kind == "open";
const enableWithdrawals =
bountyStatus.kind == "expired" && !bountyStatus.withdrawn;
return (
<Group justify="left">
<LinkButton href={`/bounty/${bountyId}/sponsor`} disabled={!isOpen}>
<LinkButton
href={`/bounty/${bountyIndex}/sponsor`}
disabled={!isOpen}
>
Sponsor
</LinkButton>
<LinkButton href={`/bounty/${bountyId}/exploit`} disabled={!isOpen}>
<LinkButton
href={`/bounty/${bountyIndex}/exploit`}
disabled={!isOpen}
>
Submit exploit
</LinkButton>
<WithdrawButton bountyId={bountyId} disabled={!enableWithdrawals} />
<WithdrawButton
bountyIndex={bountyIndex}
disabled={!enableWithdrawals}
/>
</Group>
);
};

const BountyBox: FC<{
bountyId: string;
bounty: AppBounty;
}> = ({ bountyId, bounty }) => {
const BountyBox: FC<ConcreteBountyParams> = ({ bountyIndex, bounty }) => {
const blockTimestamp = useBlockTimestamp();
const bountyStatus = getBountyStatus(bounty, blockTimestamp);
const totalPrize = getBountyTotalPrize(bounty);
Expand All @@ -105,7 +110,10 @@ const BountyBox: FC<{
</Text>
<Title order={3}>Total Prize: {formatEther(totalPrize)} ETH</Title>
<HasConnectedAccount>
<ButtonsBox bountyId={bountyId} bountyStatus={bountyStatus} />
<ButtonsBox
bountyIndex={bountyIndex}
bountyStatus={bountyStatus}
/>
</HasConnectedAccount>
</Stack>
);
Expand Down Expand Up @@ -208,7 +216,7 @@ const BountyInfoPage: FC<BountyParams> = ({ params: { bountyId } }) => {
return (
<Center p={20} mt={20}>
<Stack w={800} gap={50} align="center" justify="center">
<BountyBox bountyId={bountyId} bounty={bounty} />
<BountyBox bountyIndex={bountyIndex} bounty={bounty} />
<ExploitCodeBox exploitCode={exploitCode} />
<ParticipantsBox bounty={bounty} />
</Stack>
Expand Down

0 comments on commit 2f08918

Please sign in to comment.