Skip to content

Commit f4ccaac

Browse files
committed
fix(web): invalid-dispute-vote-reveal
1 parent 1c19cad commit f4ccaac

File tree

1 file changed

+9
-3
lines changed
  • web/src/pages/Cases/CaseDetails/Voting/Classic

1 file changed

+9
-3
lines changed

web/src/pages/Cases/CaseDetails/Voting/Classic/Reveal.tsx

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { useLocalStorage } from "react-use";
77
import { encodePacked, keccak256, PrivateKeyAccount } from "viem";
88
import { useWalletClient, usePublicClient, useConfig } from "wagmi";
99

10+
import { Answer } from "@kleros/kleros-sdk";
1011
import { Button } from "@kleros/ui-components-library";
1112

1213
import { simulateDisputeKitClassicCastVote } from "hooks/contracts/generated";
@@ -17,11 +18,10 @@ import { wrapWithToast, catchShortMessage } from "utils/wrapWithToast";
1718

1819
import { useDisputeDetailsQuery } from "queries/useDisputeDetailsQuery";
1920

21+
import { EnsureChain } from "components/EnsureChain";
2022
import InfoCard from "components/InfoCard";
2123

2224
import JustificationArea from "./JustificationArea";
23-
import { Answer } from "@kleros/kleros-sdk";
24-
import { EnsureChain } from "components/EnsureChain";
2525

2626
const Container = styled.div`
2727
width: 100%;
@@ -145,7 +145,13 @@ const getSaltAndChoice = async (
145145
if (isUndefined(rawSalt)) return;
146146
const salt = keccak256(rawSalt);
147147

148-
const { choice } = answers.reduce<{ found: boolean; choice: bigint }>(
148+
// when dispute is invalid, just add RFA to the answers array
149+
const candidates =
150+
answers?.length > 0
151+
? answers
152+
: [{ id: "0x0", title: "Refuse To Arbitrate", description: "Refuse To Arbitrate" } as Answer];
153+
154+
const { choice } = candidates.reduce<{ found: boolean; choice: bigint }>(
149155
(acc, answer) => {
150156
if (acc.found) return acc;
151157
const innerCommit = keccak256(encodePacked(["uint256", "uint256"], [BigInt(answer.id), BigInt(salt)]));

0 commit comments

Comments
 (0)