Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions subgraph/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,3 +65,5 @@ Pick the appropriate network. There should be a corresponding yarn script in the

Then reach out to a maintainer and request his approval.
<img width="1265" alt="image" src="https://github.com/kleros/gtcr-subgraph/assets/22213980/3cea54fb-8382-42c4-a44a-37b4bfbeecee">

x
12 changes: 9 additions & 3 deletions web/src/pages/Cases/CaseDetails/Voting/Classic/Reveal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { useLocalStorage } from "react-use";
import { encodePacked, keccak256, PrivateKeyAccount } from "viem";
import { useWalletClient, usePublicClient, useConfig } from "wagmi";

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

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

import { useDisputeDetailsQuery } from "queries/useDisputeDetailsQuery";

import { EnsureChain } from "components/EnsureChain";
import InfoCard from "components/InfoCard";

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

const Container = styled.div`
width: 100%;
Expand Down Expand Up @@ -145,7 +145,13 @@ const getSaltAndChoice = async (
if (isUndefined(rawSalt)) return;
const salt = keccak256(rawSalt);

const { choice } = answers.reduce<{ found: boolean; choice: bigint }>(
// when dispute is invalid, just add RFA to the answers array
const candidates =
answers?.length > 0
? answers
: [{ id: "0x0", title: "Refuse To Arbitrate", description: "Refuse To Arbitrate" } as Answer];
Comment on lines +148 to +152
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🔴 Critical

🧩 Analysis chain

Verify the hardcoded RFA ID and consider type safety.

The fallback logic handles empty answers by creating a "Refuse To Arbitrate" candidate with ID "0x0". Consider these concerns:

  1. Comment accuracy: The comment says "add RFA to the answers array" but the code creates a new candidates array rather than modifying answers.
  2. Type cast safety: The as Answer cast assumes the object shape matches the Answer interface from @kleros/kleros-sdk. If Answer requires additional fields beyond id, title, and description, this could cause runtime issues.
  3. Hardcoded ID verification: Ensure "0x0" is the correct ID for "Refuse To Arbitrate" in invalid dispute scenarios within your system's conventions.

Run the following script to verify the Answer type structure and search for other RFA ID usage patterns:


🏁 Script executed:

#!/bin/bash # Search for Answer type definition and RFA ID patterns # Find the Answer type definition in kleros-sdk echo "=== Searching for Answer type definition ===" fd -e ts -e tsx . | xargs rg -n "type Answer|interface Answer" -A 10 # Search for "Refuse To Arbitrate" usage patterns echo -e "\n=== Searching for Refuse To Arbitrate patterns ===" rg -n "Refuse To Arbitrate|RefuseToArbitrate|RFA" -C 3 # Search for 0x0 ID usage in answer contexts echo -e "\n=== Searching for 0x0 ID usage ===" rg -n 'id.*["\']0x0["\']|["\']0x0["\'].*id' -C 3

Length of output: 11494


Use RefuseToArbitrateAnswer constant and fix title/description text.

The fallback RFA object has incorrect title and description values. The code should import and use the RefuseToArbitrateAnswer constant from the kleros-sdk rather than hardcoding, which is already used elsewhere in the codebase (e.g., OptionsContainer.tsx).

Update line 152 to:

: [RefuseToArbitrateAnswer];

This ensures consistency with the SDK's standard RFA definition where title and description are "Refuse to Arbitrate / Invalid", not "Refuse To Arbitrate". You'll need to add the import:

import { RefuseToArbitrateAnswer } from "@kleros/kleros-sdk/src/dataMappings/utils/disputeDetailsSchema";

Additionally, update the comment on line 148 to clarify that a new candidates array is created (not modifying answers).

🤖 Prompt for AI Agents
In web/src/pages/Cases/CaseDetails/Voting/Classic/Reveal.tsx around lines 148 to 152, the fallback RFA object is hardcoded with incorrect title/description and mutates/uses answers; replace the fallback with the SDK constant and adjust the comment: import RefuseToArbitrateAnswer from "@kleros/kleros-sdk/src/dataMappings/utils/disputeDetailsSchema", change the comment to say a new candidates array is created (not modifying answers), and replace the ternary fallback to use [RefuseToArbitrateAnswer] instead of the manually constructed object to ensure correct title/description and consistency. 

const { choice } = candidates.reduce<{ found: boolean; choice: bigint }>(
(acc, answer) => {
if (acc.found) return acc;
const innerCommit = keccak256(encodePacked(["uint256", "uint256"], [BigInt(answer.id), BigInt(salt)]));
Expand Down