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

Testnets #110

Merged
merged 2 commits into from
Oct 23, 2024
Merged
Changes from all commits
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
50 changes: 45 additions & 5 deletions src/app/[pohid]/[chain]/[request]/Appeal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ interface SideFundingProps {
requesterFunds: bigint;
appealCost: bigint;
chainId: SupportedChainId;
loosingSideHasEnd: boolean;
}

const SideFunding: React.FC<SideFundingProps> = ({
Expand All @@ -43,6 +44,7 @@ const SideFunding: React.FC<SideFundingProps> = ({
requesterFunds,
appealCost,
chainId,
loosingSideHasEnd,
}) => {
const title = side === SideEnum.claimer ? "Claimer" : "Challenger";
const [requesterInput, setRequesterInput] = useState(0n);
Expand Down Expand Up @@ -92,11 +94,11 @@ const SideFunding: React.FC<SideFundingProps> = ({
/>
<button
className={`gradient rounded px-4 text-white ${
!contributor || errorRef.current
!contributor || errorRef.current || loosingSideHasEnd
? "cursor-not-allowed opacity-50"
: ""
}`}
disabled={!contributor || errorRef.current}
disabled={!contributor || errorRef.current || loosingSideHasEnd}
onClick={async () => {
prepareFundAppeal({
args: [arbitrator as Address, BigInt(disputeId), side],
Expand Down Expand Up @@ -148,6 +150,10 @@ const Appeal: React.FC<AppealProps> = ({
const [formatedCurrentRuling, setFormatedCurrentRuling] = useState("");
const defaultPeriod = [0n, 0n];
const [period, setPeriod] = useState(defaultPeriod);
const [loosingSideHasEnd, setLoosingSideHasEnd] = useState(false);
const [loosingSideDeadline, setLoosingSideDeadline] = useState(0);
const [currentRulingFormatted, setCurrentRulingFormatted] = useState(0);

const [disputeStatus, setDisputeStatus] = useState(
DisputeStatusEnum.Appealable,
);
Expand Down Expand Up @@ -244,11 +250,18 @@ const Appeal: React.FC<AppealProps> = ({
const currentRuling = arbitratorsData.currentRuling;

setPeriod(period!);
const loosingSideDeadline =
(parseInt(String(period![0])) + parseInt(String(period![1]))) / 2;

setLoosingSideHasEnd(loosingSideDeadline < Date.now() / 1000);
setLoosingSideDeadline(loosingSideDeadline);
setDisputeStatus(Number(status) as DisputeStatusEnum);
formatCurrentRuling(Number(currentRuling) as SideEnum);
const currentRulingFormatted = Number(currentRuling) as SideEnum;
setCurrentRulingFormatted(currentRulingFormatted);
formatCurrentRuling(currentRulingFormatted);
calculateTotalCost(
cost!,
Number(currentRuling) as SideEnum,
currentRulingFormatted,
Number(winnerMult),
Number(loserMult),
Number(sharedMult),
Expand All @@ -275,7 +288,7 @@ const Appeal: React.FC<AppealProps> = ({
header={`Appeal case #${disputeId}`}
trigger={
<button className="btn-sec h-[48px] rounded px-[24px]">
Fund Appeal (ends&nbsp;
Appeal (ends&nbsp;
<TimeAgo time={parseInt(String(period[1]))} />)
</button>
}
Expand All @@ -292,6 +305,23 @@ const Appeal: React.FC<AppealProps> = ({
in order not to lose the case.
</p>
<br />
<h1 className="mb-4 text-xl">Appeal timeframes</h1>
<p className="txt">
Appeal timeframe ends&nbsp;
<TimeAgo time={parseInt(String(period[1]))} />
</p>
{loosingSideHasEnd ? (
<p className="txt">
Loosing side ended&nbsp;
<TimeAgo time={loosingSideDeadline} />
</p>
) : (
<p className="txt">
Loosing side ends&nbsp;
<TimeAgo time={loosingSideDeadline} />
</p>
)}
<br />
<SideFunding
side={SideEnum.claimer}
disputeId={disputeId}
Expand All @@ -301,6 +331,11 @@ const Appeal: React.FC<AppealProps> = ({
requesterFunds={claimerFunds}
appealCost={totalClaimerCost}
chainId={chainId}
loosingSideHasEnd={
currentRulingFormatted === SideEnum.challenger
? loosingSideHasEnd
: false
}
/>
<br />
<SideFunding
Expand All @@ -312,6 +347,11 @@ const Appeal: React.FC<AppealProps> = ({
requesterFunds={challengerFunds}
appealCost={totalChallengerCost}
chainId={chainId}
loosingSideHasEnd={
currentRulingFormatted === SideEnum.claimer
? loosingSideHasEnd
: false
}
/>
</div>
</Modal>
Expand Down
Loading