Skip to content

Refactor/dispute kit registry#2267

Draft
tractorss wants to merge 2 commits intodevfrom
refactor/dispute-kit-registry
Draft

Refactor/dispute kit registry#2267
tractorss wants to merge 2 commits intodevfrom
refactor/dispute-kit-registry

Conversation

@tractorss
Copy link
Copy Markdown
Contributor

@tractorss tractorss commented Mar 26, 2026

Summary by CodeRabbit

Release Notes

  • Refactor
    • Reorganized internal dispute kit configuration and routing to use a dedicated module structure.
    • Renamed internal parameter field across dispute actions for improved clarity and consistency.
    • Simplified dispute kit selection logic to use a centralized registry approach.

@netlify
Copy link
Copy Markdown

netlify bot commented Mar 26, 2026

Deploy Preview for kleros-v2-testnet-devtools failed. Why did it fail? →

Name Link
🔨 Latest commit cca2a13
🔍 Latest deploy log https://app.netlify.com/projects/kleros-v2-testnet-devtools/deploys/69c529be84f8be000881bfc2

@netlify
Copy link
Copy Markdown

netlify bot commented Mar 26, 2026

Deploy Preview for kleros-v2-neo failed. Why did it fail? →

Name Link
🔨 Latest commit cca2a13
🔍 Latest deploy log https://app.netlify.com/projects/kleros-v2-neo/deploys/69c529bea5ec1c00072a8ebe

@netlify
Copy link
Copy Markdown

netlify bot commented Mar 26, 2026

Deploy Preview for kleros-v2-testnet ready!

Name Link
🔨 Latest commit cca2a13
🔍 Latest deploy log https://app.netlify.com/projects/kleros-v2-testnet/deploys/69c529bec09da50008224634
😎 Deploy Preview https://deploy-preview-2267--kleros-v2-testnet.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@sonarqubecloud
Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
0.0% Coverage on New Code (required ≥ 80%)

See analysis details on SonarQube Cloud

@tractorss
Copy link
Copy Markdown
Contributor Author

@coderabbitai review

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Mar 26, 2026

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Mar 26, 2026

Walkthrough

The pull request refactors dispute kit identification and configuration across the codebase by moving the DisputeKits enum to a new src/dispute-kits module, renaming the discriminator field from type to disputeKitId in all action parameters, introducing a centralized dispute kit registry with configuration lookup helpers, and replacing the useDisputeKitAddresses hook with a new useDisputeKitInfo hook.

Changes

Cohort / File(s) Summary
DisputeKits Enum Relocation
web/src/dispute-kits/disputeKits.ts, web/src/consts/index.ts
Created new DisputeKits enum file with numeric values for each kit variant and removed the enum from consts.
Dispute Kits Module Infrastructure
web/src/dispute-kits/index.ts, web/src/dispute-kits/types.ts, web/src/dispute-kits/registry.ts
Established centralized module API exporting the enum, created shared prop/config type definitions, and built a registry mapping kit IDs to configurations with lookup helpers.
Action Parameter Field Rename: Commit
web/src/actions/commit/params.ts, web/src/actions/commit/builders/*, web/src/actions/commit/execute.ts
Renamed type field to disputeKitId in all commit parameter interfaces and updated builder selection logic and JSDoc.
Action Parameter Field Rename: Reveal
web/src/actions/reveal/params.ts, web/src/actions/reveal/builders/*, web/src/actions/reveal/execute.ts, web/src/actions/reveal/resolveRevealInputs.*.ts
Renamed type field to disputeKitId in all reveal parameter interfaces and updated builder selection logic and test fixtures.
Action Parameter Field Rename: Vote
web/src/actions/vote/params.ts, web/src/actions/vote/builders/*, web/src/actions/vote/execute.ts
Renamed type field to disputeKitId in all vote parameter interfaces and updated builder selection logic.
Action Parameter Field Rename: Fund Appeal
web/src/actions/fundAppeal/params.ts, web/src/actions/fundAppeal/builders/*, web/src/actions/fundAppeal/execute.ts
Renamed type field to disputeKitId in all fund appeal parameter interfaces and updated builder selection logic.
Dispute Feature Configuration Updates
web/src/dispute-kits/disputeFeature.ts, web/src/components/DisputeFeatures/Features/*
Updated dispute kit IDs from numeric literals to enum values, changed type alias to direct DisputeKit[] usage, and relocated Features import source across multiple feature components.
Dispute Kit Info Hook Replacement
web/src/hooks/useDisputeKitInfo.ts, web/src/hooks/useDisputeKitAddresses.ts, web/src/hooks/useGatedTokenInfo.ts
Added new useDisputeKitInfo hook with registry-based lookup, removed useDisputeKitAddresses, and refactored useGatedTokenInfo with required parameters.
Voting Context Refactoring
web/src/hooks/useVotingContext.tsx, web/src/pages/Cases/CaseDetails/Voting/*
Updated hook to use single registry-based contract read instead of multiple kit-specific hooks; updated Classic/Shutter voting components to use new DisputeKitVotingProps and disputeKitId prop.
Appeal UI Refactoring
web/src/pages/Cases/CaseDetails/Appeal/index.tsx, web/src/pages/Cases/CaseDetails/Appeal/Classic/*, web/src/pages/Cases/CaseDetails/Appeal/Shutter/*
Consolidated appeal rendering using dynamic AppealComponent from registry; removed Shutter-specific implementation files and replaced hardcoded kit checks with useDisputeKitInfo.
Overview UI Updates
web/src/pages/Cases/CaseDetails/Overview/index.tsx, web/src/pages/Cases/CaseDetails/Overview/DisputeKitOverviewExtraInfo/gated.tsx
Updated gated token display component to use OverviewExtraInfoProps interface and derive data from useGatedTokenInfo with new required parameters.
Maintenance and Navigation Button Updates
web/src/pages/Cases/CaseDetails/MaintenanceButtons/DrawButton.tsx, web/src/pages/Resolver/NavigationButtons/*.tsx, web/src/pages/Resolver/Landing/index.tsx
Updated dispute kit lookups to use new registry-based useDisputeKitInfo and replaced numeric fallbacks with DisputeKits.Classic enum constant.
Court Feature Selection Import Updates
web/src/pages/Resolver/Parameters/Court/FeatureSelection/index.tsx, web/src/context/NewDisputeContext.tsx
Relocated function and type imports from consts to dispute-kits module; updated initial dispute kit value to use enum instead of numeric literal.
Configuration Comment Update
web/wagmi.config.ts
Updated inline comment to reflect new filter location for university dispute kit.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Possibly related PRs

Suggested labels

Type: Feature🗿, Package: Web

Poem

🐰 The dispute kits hop to a brand new home,
From consts they roam, to dispute-kits they've flown,
With a disputeKitId renaming spree,
And a registry for all to see—
No more hardcoded paths, just clean and lean! 🌱

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The pull request title 'Refactor/dispute kit registry' accurately describes the main objective: refactoring dispute kit handling by moving DisputeKits enum, associated functions, and dispute kit configurations to a new dedicated src/dispute-kits module.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch refactor/dispute-kit-registry

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 7

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (2)
web/src/pages/Cases/CaseDetails/index.tsx (1)

3-3: ⚠️ Potential issue | 🔴 Critical

Remove duplicate import of Address.

The file imports Address from "viem" twice: once as a runtime import (line 3) and once as a type-only import (line 7). This creates a duplicate identifier and will cause a TypeScript compilation error. Since Address is only used as a type (line 62), keep only the type-only import.

🐛 Proposed fix to remove the duplicate import
-import { Address } from "viem";
-
 import { useTranslation } from "react-i18next";
 import { Route, Routes, useParams, Navigate } from "react-router-dom";
 import type { Address } from "viem";

Also applies to: 7-7

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@web/src/pages/Cases/CaseDetails/index.tsx` at line 3, There is a duplicate
import of Address—remove the runtime import import { Address } from "viem"; and
keep the type-only import (e.g., import type { Address } from "viem";) since
Address is used only as a type (see its usage in the CaseDetails component/props
on line referencing the Address type). Update the imports so only the type-only
import remains to avoid the duplicate identifier and TypeScript compile error.
web/src/pages/Cases/CaseDetails/Appeal/Classic/index.tsx (1)

25-26: ⚠️ Potential issue | 🟠 Major

Remove the as NumberString assertion or widen the type to NumberString | "".

amount starts as "". After the 500ms debounce, useParsedAmount will call parseUnits("", 18), which throws because empty strings are not valid numeric values. The disabled button doesn't prevent this render-time error. Either use NumberString | "" as the Fund prop type, or guard the empty case before passing to useParsedAmount.

Also applies to: 51

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@web/src/pages/Cases/CaseDetails/Appeal/Classic/index.tsx` around lines 25 -
26, The component initializes amount as "" but later casts it to NumberString
when passed into useParsedAmount, causing parseUnits("", 18) to throw; update
the Fund prop/type usage or guard the empty string: either widen the type to
NumberString | "" for the Fund prop or check amount before calling
useParsedAmount (e.g., short-circuit when amount === "") so parseUnits is never
invoked with an empty string; adjust references in this file to amount,
setAmount and the useParsedAmount call (and any prop expecting NumberString)
accordingly and apply the same fix at the other occurrence around line 51.
🧹 Nitpick comments (2)
web/src/context/NewDisputeContext.tsx (1)

104-104: Tighten disputeKitId typing to the enum for stronger safety.

Now that initialization uses DisputeKits, consider narrowing IDisputeData.disputeKitId from number to DisputeKits to avoid accidental invalid IDs.

Suggested type-tightening diff
 interface IDisputeData extends IDisputeTemplate {
   courtId?: string;
   numberOfJurors: number;
   arbitrationCost?: string;
   aliasesArray?: AliasArray[];
-  disputeKitId?: number;
+  disputeKitId?: DisputeKits;
   disputeKitData?: IDisputeKitData;
 }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@web/src/context/NewDisputeContext.tsx` at line 104, The
IDisputeData.disputeKitId should be narrowed from number to the DisputeKits enum
to enforce valid IDs: update the IDisputeData type declaration to use
disputeKitId: DisputeKits, adjust the initial state in NewDisputeContext (where
disputeKitId: DisputeKits.Classic is set) and update any places that construct
or read IDisputeData to use DisputeKits values (or cast/convert inputs) so
callers no longer rely on raw numbers; ensure imports reference the DisputeKits
enum and run type checks to correct any mismatches.
web/src/pages/Cases/CaseDetails/Voting/index.tsx (1)

81-84: Address the TODO: Consider a loading/error state instead of empty fragment.

Returning an empty fragment when disputeKitInfo is undefined may cause layout shifts or confusing UX. Consider rendering a loading skeleton or an error message for unrecognized dispute kits.

Would you like me to suggest a loading state implementation, or should this be tracked as a separate issue?

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@web/src/pages/Cases/CaseDetails/Voting/index.tsx` around lines 81 - 84,
Replace the empty fragment return for the undefined disputeKitInfo with an
explicit loading or error UI: instead of "if (!disputeKitInfo) return <>;</>",
render a small LoadingSkeleton or a clear error/placeholder message (e.g.,
"Loading dispute kit…" or "Unknown dispute kit") and ensure the branch
distinguishes loading vs unrecoverable error; update the component that reads
disputeKitInfo and the subsequent VotingComponent usage so consumers see a
stable placeholder while disputeKitInfo resolves and an error state when it
truly cannot be loaded.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@web/src/actions/commit/params.ts`:
- Line 1: The code imports DisputeKits from the dispute-kits barrel; change
those imports to pull DisputeKits from the leaf disputeKits module (i.e. import
the specific disputeKits module rather than the barrel) so the registry isn't
loaded transitively; update the import in params.ts (and all other action-layer
files that import DisputeKits) to reference the leaf module instead of the
barrel.

In `@web/src/dispute-kits/disputeFeature.ts`:
- Around line 55-56: The TODO in disputeFeature.ts about moving disputekit data
and the 'type' handling to a dk config registry must be resolved: either
implement the registry now (create a DisputeKitConfigRegistry module, move the
disputekit structure and 'type' ownership into
registerDisputeKit/getDisputeKitConfig APIs and update disputeFeature.ts to read
from that registry instead of an inline TODO), or replace the TODO with a clear
linked issue reference (e.g. GH/JIRA ID) that describes the migration,
acceptance criteria, and owner; update the comment to include that issue link
and close the TODO to eliminate open static-analysis debt.

In `@web/src/dispute-kits/registry.ts`:
- Around line 106-107: getDisputeKitConfigByKitId currently calls
BigInt(disputeKitId) directly which will throw for non-integer strings; add
defensive validation so invalid inputs return undefined instead of throwing.
Update getDisputeKitConfigByKitId to: if disputeKitId is a number or bigint,
coerce to BigInt; if it is a string, validate it matches an integer pattern
(e.g. /^\d+$/) before converting or alternatively wrap BigInt(disputeKitId) in a
try/catch and return undefined on error; then use the validated BigInt value to
compare against BigInt(kit.id) while keeping DISPUTE_KIT_REGISTRY lookup logic
unchanged.

In `@web/src/hooks/useDisputeKitInfo.ts`:
- Around line 18-28: The useMemo for disputeKit unnecessarily lists props in its
dependency array causing re-renders; update the disputeKit useMemo (the function
that calls getDisputeKitConfigByAddress and getDisputeKitConfigByKitId) to
remove props from the dependency array and only include disputeKitAddress and
disputeKitId so the memo only recomputes when those specific values change.

In `@web/src/hooks/useVotingContext.tsx`:
- Around line 47-53: The read is being enabled with a fallback to
disputeKitClassicAbi even when useDisputeKitInfo returned undefined, causing
queries against unknown kits; update the useReadContract call in
useVotingContext (referencing useReadContract, disputeKitInfo,
disputeKitClassicAbi, disputeKitAddress, and functionName "isVoteActive") so the
query is only enabled when disputeKitInfo exists and provides a disputeKitAbi
(i.e., include disputeKitInfo != null && disputeKitInfo.disputeKitAbi in the
query.enabled condition) and only pass disputeKitInfo.disputeKitAbi to the abi
parameter instead of falling back to disputeKitClassicAbi.

In `@web/src/pages/Cases/CaseDetails/Appeal/index.tsx`:
- Around line 53-67: The current early return shows "Unable to load dispute kit"
before the dispute query resolves because disputeKitAddress is async; change the
guard so you only show the unsupported-kit state when you actually requested a
kit and it failed to resolve: remove the top-level if
(isUndefined(disputeKitInfo)) return ... and instead, inside the Periods.appeal
=== currentPeriodIndex branch before rendering <AppealComponent>, check that
disputeKitAddress (from disputeData?.dispute?.currentRound?.disputeKit?.address)
is defined and disputeKitInfo is undefined and only then render the "Unable to
load dispute kit" fallback; otherwise, when not in appeal period render
AppealHistory as before and allow useDisputeKitInfo (the hook) to resolve
without short-circuiting the entire component.

In `@web/src/pages/Cases/CaseDetails/Voting/Classic/Commit.tsx`:
- Around line 45-47: This component uses castCommit with a union-typed
disputeKitId causing a suppressed type error; narrow the commit payload so
TypeScript knows it's the Classic variant by ensuring the disputeKitId is typed
as DisputeKits.Classic (e.g., update the Commit component/prop type or the local
ICommit variable to ICommit & { disputeKitId: DisputeKits.Classic } or use the
ClassicCommitParams variant), then remove the // `@ts-expect-error` and let
castCommit accept the correctly discriminated Classic params; references:
castCommit, ICommit, DisputeKits, ClassicCommitParams, Commit (Commit.tsx).

---

Outside diff comments:
In `@web/src/pages/Cases/CaseDetails/Appeal/Classic/index.tsx`:
- Around line 25-26: The component initializes amount as "" but later casts it
to NumberString when passed into useParsedAmount, causing parseUnits("", 18) to
throw; update the Fund prop/type usage or guard the empty string: either widen
the type to NumberString | "" for the Fund prop or check amount before calling
useParsedAmount (e.g., short-circuit when amount === "") so parseUnits is never
invoked with an empty string; adjust references in this file to amount,
setAmount and the useParsedAmount call (and any prop expecting NumberString)
accordingly and apply the same fix at the other occurrence around line 51.

In `@web/src/pages/Cases/CaseDetails/index.tsx`:
- Line 3: There is a duplicate import of Address—remove the runtime import
import { Address } from "viem"; and keep the type-only import (e.g., import type
{ Address } from "viem";) since Address is used only as a type (see its usage in
the CaseDetails component/props on line referencing the Address type). Update
the imports so only the type-only import remains to avoid the duplicate
identifier and TypeScript compile error.

---

Nitpick comments:
In `@web/src/context/NewDisputeContext.tsx`:
- Line 104: The IDisputeData.disputeKitId should be narrowed from number to the
DisputeKits enum to enforce valid IDs: update the IDisputeData type declaration
to use disputeKitId: DisputeKits, adjust the initial state in NewDisputeContext
(where disputeKitId: DisputeKits.Classic is set) and update any places that
construct or read IDisputeData to use DisputeKits values (or cast/convert
inputs) so callers no longer rely on raw numbers; ensure imports reference the
DisputeKits enum and run type checks to correct any mismatches.

In `@web/src/pages/Cases/CaseDetails/Voting/index.tsx`:
- Around line 81-84: Replace the empty fragment return for the undefined
disputeKitInfo with an explicit loading or error UI: instead of "if
(!disputeKitInfo) return <>;</>", render a small LoadingSkeleton or a clear
error/placeholder message (e.g., "Loading dispute kit…" or "Unknown dispute
kit") and ensure the branch distinguishes loading vs unrecoverable error; update
the component that reads disputeKitInfo and the subsequent VotingComponent usage
so consumers see a stable placeholder while disputeKitInfo resolves and an error
state when it truly cannot be loaded.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 6750d44f-1c9e-47de-8282-c05b56762643

📥 Commits

Reviewing files that changed from the base of the PR and between 766aaca and cca2a13.

📒 Files selected for processing (62)
  • web/src/actions/commit/builders/classic.builder.test.ts
  • web/src/actions/commit/builders/gated.builder.test.ts
  • web/src/actions/commit/builders/index.ts
  • web/src/actions/commit/builders/shutter.builder.test.ts
  • web/src/actions/commit/execute.ts
  • web/src/actions/commit/params.ts
  • web/src/actions/fundAppeal/builders/classic.builder.test.ts
  • web/src/actions/fundAppeal/builders/index.ts
  • web/src/actions/fundAppeal/execute.ts
  • web/src/actions/fundAppeal/params.ts
  • web/src/actions/reveal/builders/classic.builder.test.ts
  • web/src/actions/reveal/builders/gated.builder.test.ts
  • web/src/actions/reveal/builders/index.ts
  • web/src/actions/reveal/builders/shutter.builder.test.ts
  • web/src/actions/reveal/execute.ts
  • web/src/actions/reveal/params.ts
  • web/src/actions/reveal/resolveRevealInputs.integration.test.ts
  • web/src/actions/reveal/resolveRevealInputs.test.ts
  • web/src/actions/vote/builders/classic.builder.test.ts
  • web/src/actions/vote/builders/index.ts
  • web/src/actions/vote/execute.ts
  • web/src/actions/vote/params.ts
  • web/src/components/DisputeFeatures/Features/ArgentinaConsumerProtection.tsx
  • web/src/components/DisputeFeatures/Features/ClassicVote.tsx
  • web/src/components/DisputeFeatures/Features/GatedErc1155.tsx
  • web/src/components/DisputeFeatures/Features/GatedErc20.tsx
  • web/src/components/DisputeFeatures/Features/UniversityVote.tsx
  • web/src/components/DisputeFeatures/Features/index.tsx
  • web/src/components/DisputeFeatures/GroupsUI.tsx
  • web/src/consts/index.ts
  • web/src/context/NewDisputeContext.tsx
  • web/src/dispute-kits/disputeFeature.ts
  • web/src/dispute-kits/disputeKits.ts
  • web/src/dispute-kits/index.ts
  • web/src/dispute-kits/registry.ts
  • web/src/dispute-kits/types.ts
  • web/src/hooks/useDisputeKitAddresses.ts
  • web/src/hooks/useDisputeKitInfo.ts
  • web/src/hooks/useGatedTokenInfo.ts
  • web/src/hooks/useVotingContext.tsx
  • web/src/pages/Cases/CaseDetails/Appeal/Classic/Fund.tsx
  • web/src/pages/Cases/CaseDetails/Appeal/Classic/index.tsx
  • web/src/pages/Cases/CaseDetails/Appeal/Shutter/Fund.tsx
  • web/src/pages/Cases/CaseDetails/Appeal/Shutter/index.tsx
  • web/src/pages/Cases/CaseDetails/Appeal/index.tsx
  • web/src/pages/Cases/CaseDetails/MaintenanceButtons/DrawButton.tsx
  • web/src/pages/Cases/CaseDetails/Overview/DisputeKitOverviewExtraInfo/gated.tsx
  • web/src/pages/Cases/CaseDetails/Overview/index.tsx
  • web/src/pages/Cases/CaseDetails/Voting/Classic/Commit.tsx
  • web/src/pages/Cases/CaseDetails/Voting/Classic/Reveal.tsx
  • web/src/pages/Cases/CaseDetails/Voting/Classic/Vote.tsx
  • web/src/pages/Cases/CaseDetails/Voting/Classic/index.tsx
  • web/src/pages/Cases/CaseDetails/Voting/Shutter/Commit.tsx
  • web/src/pages/Cases/CaseDetails/Voting/Shutter/Reveal.tsx
  • web/src/pages/Cases/CaseDetails/Voting/Shutter/index.tsx
  • web/src/pages/Cases/CaseDetails/Voting/index.tsx
  • web/src/pages/Cases/CaseDetails/index.tsx
  • web/src/pages/Resolver/Landing/index.tsx
  • web/src/pages/Resolver/NavigationButtons/SubmitBatchDisputesButton.tsx
  • web/src/pages/Resolver/NavigationButtons/SubmitDisputeButton.tsx
  • web/src/pages/Resolver/Parameters/Court/FeatureSelection/index.tsx
  • web/wagmi.config.ts
💤 Files with no reviewable changes (4)
  • web/src/pages/Cases/CaseDetails/Appeal/Shutter/index.tsx
  • web/src/pages/Cases/CaseDetails/Appeal/Shutter/Fund.tsx
  • web/src/hooks/useDisputeKitAddresses.ts
  • web/src/consts/index.ts

@@ -1,40 +1,40 @@
import { DisputeKits } from "src/consts";
import { DisputeKits } from "src/dispute-kits";
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "DisputeKits declaration:"
fd '^disputeKits\.ts$' web/src/dispute-kits --exec sed -n '1,120p' {}

echo
echo "dispute-kits barrel exports:"
fd '^index\.ts$' web/src/dispute-kits --exec sed -n '1,120p' {}

echo
echo "registry imports that make the barrel heavy:"
fd '^registry\.ts$' web/src/dispute-kits --exec sed -n '1,160p' {}

echo
echo "action-layer imports of the barrel:"
rg -n 'from "src/dispute-kits"' web/src/actions

Repository: kleros/kleros-v2

Length of output: 5542


Import DisputeKits from the leaf module, not the dispute-kits barrel.

The src/dispute-kits barrel includes an explicit warning against this pattern: its own comment states that imports should come directly from ./disputeKits "so the registry is not loaded before mocks." The registry loads UI components and contract dependencies that action-layer code should not transitively depend on. This affects more than the three params.ts files mentioned; update all action-layer imports of DisputeKits to import from src/dispute-kits/disputeKits instead.

Proposed change
-import { DisputeKits } from "src/dispute-kits";
+import { DisputeKits } from "src/dispute-kits/disputeKits";
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
import { DisputeKits } from "src/dispute-kits";
import { DisputeKits } from "src/dispute-kits/disputeKits";
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@web/src/actions/commit/params.ts` at line 1, The code imports DisputeKits
from the dispute-kits barrel; change those imports to pull DisputeKits from the
leaf disputeKits module (i.e. import the specific disputeKits module rather than
the barrel) so the registry isn't loaded transitively; update the import in
params.ts (and all other action-layer files that import DisputeKits) to
reference the leaf module instead of the barrel.

Comment on lines +55 to +56
// TODO: move to dk cofig registry, issue: cannot figure out the correct usage of 'type' yet,
// we need this to structure disputekit data for the dispute, not sure how to move this to config yet
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Resolve the open TODO before merge (or track it with a linked issue).

Line 55 and Line 56 leave unresolved behavior around type/registry ownership, and this keeps static analysis debt open. Please either implement the move now or attach an issue reference in the comment so ownership is explicit.

If you want, I can draft a scoped follow-up issue with acceptance criteria for the registry migration.

🧰 Tools
🪛 GitHub Check: SonarCloud Code Analysis

[warning] 55-55: Complete the task associated to this "TODO" comment.

See more on https://sonarcloud.io/project/issues?id=kleros_kleros-v2&issues=AZ0qLSClWI1lSSkCvWpA&open=AZ0qLSClWI1lSSkCvWpA&pullRequest=2267

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@web/src/dispute-kits/disputeFeature.ts` around lines 55 - 56, The TODO in
disputeFeature.ts about moving disputekit data and the 'type' handling to a dk
config registry must be resolved: either implement the registry now (create a
DisputeKitConfigRegistry module, move the disputekit structure and 'type'
ownership into registerDisputeKit/getDisputeKitConfig APIs and update
disputeFeature.ts to read from that registry instead of an inline TODO), or
replace the TODO with a clear linked issue reference (e.g. GH/JIRA ID) that
describes the migration, acceptance criteria, and owner; update the comment to
include that issue link and close the TODO to eliminate open static-analysis
debt.

Comment on lines +106 to +107
export function getDisputeKitConfigByKitId(disputeKitId: number | string | bigint) {
return Object.values(DISPUTE_KIT_REGISTRY).find((kit) => BigInt(kit.id) === BigInt(disputeKitId));
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "JavaScript BigInt behaviour on representative string inputs:"
node - <<'NODE'
for (const value of ["1", "Classic", "1-2", "NaN"]) {
  try {
    console.log(JSON.stringify(value), "=>", BigInt(value).toString());
  } catch (error) {
    console.log(JSON.stringify(value), "=> throws", error.name);
  }
}
NODE

echo
echo "Call sites of dispute-kit lookup helpers:"
rg -n '\b(getDisputeKitConfigByKitId|useDisputeKitInfo)\s*\('

Repository: kleros/kleros-v2

Length of output: 1075


🏁 Script executed:

cat -n web/src/hooks/useDisputeKitInfo.ts | head -40

Repository: kleros/kleros-v2

Length of output: 1374


🏁 Script executed:

rg "disputeKitId" --type-list | head -20

Repository: kleros/kleros-v2

Length of output: 449


🏁 Script executed:

rg -n "useDisputeKitInfo\s*\(\s*\{\s*disputeKitId" web/

Repository: kleros/kleros-v2

Length of output: 42


🏁 Script executed:

rg -n "getDisputeKitConfigByKitId\(" --context=3 | grep -v "export function"

Repository: kleros/kleros-v2

Length of output: 807


🏁 Script executed:

rg "disputeKitId" web/src --type-list

Repository: kleros/kleros-v2

Length of output: 449


🏁 Script executed:

rg "disputeKitId\s*:" web/src -A 2 -B 2

Repository: kleros/kleros-v2

Length of output: 18307


🏁 Script executed:

fd "\.graphql$|gql\." web/src | head -10

Repository: kleros/kleros-v2

Length of output: 42


Add error handling to getDisputeKitConfigByKitId for defensive string validation.

The function accepts string but BigInt(disputeKitId) throws on non-integer values instead of returning undefined. While the string parameter is currently unused in the codebase (all callers pass parsed numbers), the exported function signature permits it, so defensive error handling is warranted.

Proposed hardening
 export function getDisputeKitConfigByKitId(disputeKitId: number | string | bigint) {
-  return Object.values(DISPUTE_KIT_REGISTRY).find((kit) => BigInt(kit.id) === BigInt(disputeKitId));
+  try {
+    const normalizedId = BigInt(disputeKitId);
+    return Object.values(DISPUTE_KIT_REGISTRY).find((kit) => BigInt(kit.id) === normalizedId);
+  } catch {
+    return undefined;
+  }
 }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
export function getDisputeKitConfigByKitId(disputeKitId: number | string | bigint) {
return Object.values(DISPUTE_KIT_REGISTRY).find((kit) => BigInt(kit.id) === BigInt(disputeKitId));
export function getDisputeKitConfigByKitId(disputeKitId: number | string | bigint) {
try {
const normalizedId = BigInt(disputeKitId);
return Object.values(DISPUTE_KIT_REGISTRY).find((kit) => BigInt(kit.id) === normalizedId);
} catch {
return undefined;
}
}
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@web/src/dispute-kits/registry.ts` around lines 106 - 107,
getDisputeKitConfigByKitId currently calls BigInt(disputeKitId) directly which
will throw for non-integer strings; add defensive validation so invalid inputs
return undefined instead of throwing. Update getDisputeKitConfigByKitId to: if
disputeKitId is a number or bigint, coerce to BigInt; if it is a string,
validate it matches an integer pattern (e.g. /^\d+$/) before converting or
alternatively wrap BigInt(disputeKitId) in a try/catch and return undefined on
error; then use the validated BigInt value to compare against BigInt(kit.id)
while keeping DISPUTE_KIT_REGISTRY lookup logic unchanged.

Comment on lines +18 to +28
const disputeKit = useMemo(() => {
if ("disputeKitAddress" in props && !isUndefined(disputeKitAddress)) {
return getDisputeKitConfigByAddress(disputeKitAddress);
}

if ("disputeKitId" in props && !isUndefined(disputeKitId)) {
return getDisputeKitConfigByKitId(disputeKitId);
}

return undefined;
}, [props, disputeKitAddress, disputeKitId]);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Remove props from the dependency array to prevent unnecessary recomputation.

Including props in the useMemo dependency array causes recomputation on every render since props is a new object reference each time. The individual disputeKitAddress and disputeKitId dependencies are sufficient.

🔧 Proposed fix
   const disputeKit = useMemo(() => {
     if ("disputeKitAddress" in props && !isUndefined(disputeKitAddress)) {
       return getDisputeKitConfigByAddress(disputeKitAddress);
     }

     if ("disputeKitId" in props && !isUndefined(disputeKitId)) {
       return getDisputeKitConfigByKitId(disputeKitId);
     }

     return undefined;
-  }, [props, disputeKitAddress, disputeKitId]);
+  }, [disputeKitAddress, disputeKitId]);
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@web/src/hooks/useDisputeKitInfo.ts` around lines 18 - 28, The useMemo for
disputeKit unnecessarily lists props in its dependency array causing re-renders;
update the disputeKit useMemo (the function that calls
getDisputeKitConfigByAddress and getDisputeKitConfigByKitId) to remove props
from the dependency array and only include disputeKitAddress and disputeKitId so
the memo only recomputes when those specific values change.

Comment on lines +47 to +53
const voteResult = useReadContract({
address: disputeKitAddress as Address | undefined,
abi: disputeKitInfo?.disputeKitAbi ?? disputeKitClassicAbi,
functionName: "isVoteActive",
args: [BigInt(id ?? 0), BigInt(roundId ?? 0), BigInt(voteId ?? 0)],
query: {
enabled: isEnabled && disputeKitName === DisputeKits.ClassicUniversity,
enabled: !isUndefined(disputeKitAddress) && !isUndefined(roundId) && !isUndefined(voteId) && !isUndefined(id),
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

Don't query unknown kits with the Classic ABI.

If useDisputeKitInfo misses this address, the read still gets enabled and polls isVoteActive against that contract using disputeKitClassicAbi. Unsupported or misconfigured kits should short-circuit here, otherwise this can surface false vote state or repeated read errors.

Proposed guard
+  const canReadVoteStatus =
+    !isUndefined(disputeKitInfo) &&
+    !isUndefined(disputeKitAddress) &&
+    !isUndefined(roundId) &&
+    !isUndefined(voteId) &&
+    !isUndefined(id);
+
   const voteResult = useReadContract({
     address: disputeKitAddress as Address | undefined,
     abi: disputeKitInfo?.disputeKitAbi ?? disputeKitClassicAbi,
     functionName: "isVoteActive",
     args: [BigInt(id ?? 0), BigInt(roundId ?? 0), BigInt(voteId ?? 0)],
     query: {
-      enabled: !isUndefined(disputeKitAddress) && !isUndefined(roundId) && !isUndefined(voteId) && !isUndefined(id),
+      enabled: canReadVoteStatus,
       refetchInterval: REFETCH_INTERVAL,
     },
   });
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
const voteResult = useReadContract({
address: disputeKitAddress as Address | undefined,
abi: disputeKitInfo?.disputeKitAbi ?? disputeKitClassicAbi,
functionName: "isVoteActive",
args: [BigInt(id ?? 0), BigInt(roundId ?? 0), BigInt(voteId ?? 0)],
query: {
enabled: isEnabled && disputeKitName === DisputeKits.ClassicUniversity,
enabled: !isUndefined(disputeKitAddress) && !isUndefined(roundId) && !isUndefined(voteId) && !isUndefined(id),
const canReadVoteStatus =
!isUndefined(disputeKitInfo) &&
!isUndefined(disputeKitAddress) &&
!isUndefined(roundId) &&
!isUndefined(voteId) &&
!isUndefined(id);
const voteResult = useReadContract({
address: disputeKitAddress as Address | undefined,
abi: disputeKitInfo?.disputeKitAbi ?? disputeKitClassicAbi,
functionName: "isVoteActive",
args: [BigInt(id ?? 0), BigInt(roundId ?? 0), BigInt(voteId ?? 0)],
query: {
enabled: canReadVoteStatus,
refetchInterval: REFETCH_INTERVAL,
},
});
🧰 Tools
🪛 GitHub Check: SonarCloud Code Analysis

[warning] 48-48: This assertion is unnecessary since it does not change the type of the expression.

See more on https://sonarcloud.io/project/issues?id=kleros_kleros-v2&issues=AZ0qLSBxWI1lSSkCvWo_&open=AZ0qLSBxWI1lSSkCvWo_&pullRequest=2267

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@web/src/hooks/useVotingContext.tsx` around lines 47 - 53, The read is being
enabled with a fallback to disputeKitClassicAbi even when useDisputeKitInfo
returned undefined, causing queries against unknown kits; update the
useReadContract call in useVotingContext (referencing useReadContract,
disputeKitInfo, disputeKitClassicAbi, disputeKitAddress, and functionName
"isVoteActive") so the query is only enabled when disputeKitInfo exists and
provides a disputeKitAbi (i.e., include disputeKitInfo != null &&
disputeKitInfo.disputeKitAbi in the query.enabled condition) and only pass
disputeKitInfo.disputeKitAbi to the abi parameter instead of falling back to
disputeKitClassicAbi.

Comment on lines +53 to +67
const disputeKitAddress = disputeData?.dispute?.currentRound?.disputeKit?.address;
const disputeKitInfo = useDisputeKitInfo({ disputeKitAddress });
// TODO: return a proper message
if (isUndefined(disputeKitInfo)) return <>Unable to load dispute kit</>;

const AppealComponent = disputeKitInfo.AppealComponent;
return (
<Container>
{Periods.appeal === currentPeriodIndex ? (
<>
{isClassicDisputeKit && (
<Classic
isAppealMiniGuideOpen={isAppealMiniGuideOpen}
toggleAppealMiniGuide={toggleAppealMiniGuide}
{...{ disputeKitName }}
/>
)}
{isShutterDisputeKit && (
<Shutter
isAppealMiniGuideOpen={isAppealMiniGuideOpen}
toggleAppealMiniGuide={toggleAppealMiniGuide}
{...{ disputeKitName }}
/>
)}
<AppealComponent
isAppealMiniGuideOpen={isAppealMiniGuideOpen}
toggleAppealMiniGuide={toggleAppealMiniGuide}
disputeKitId={disputeKitInfo.id}
/>
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

Don't return the unsupported-kit state before the dispute query resolves.

Because disputeKitAddress comes from async data, this branch can show Unable to load dispute kit on the first paint. Since the return happens before the period switch, it also hides AppealHistory outside the appeal period until the lookup finishes.

💡 Suggested guard placement
   const disputeKitAddress = disputeData?.dispute?.currentRound?.disputeKit?.address;
   const disputeKitInfo = useDisputeKitInfo({ disputeKitAddress });
-  // TODO: return a proper message
-  if (isUndefined(disputeKitInfo)) return <>Unable to load dispute kit</>;
-
-  const AppealComponent = disputeKitInfo.AppealComponent;
+  const AppealComponent = disputeKitInfo?.AppealComponent;
   return (
     <Container>
       {Periods.appeal === currentPeriodIndex ? (
         <>
-          <AppealComponent
-            isAppealMiniGuideOpen={isAppealMiniGuideOpen}
-            toggleAppealMiniGuide={toggleAppealMiniGuide}
-            disputeKitId={disputeKitInfo.id}
-          />
+          {!isUndefined(AppealComponent) ? (
+            <AppealComponent
+              isAppealMiniGuideOpen={isAppealMiniGuideOpen}
+              toggleAppealMiniGuide={toggleAppealMiniGuide}
+              disputeKitId={disputeKitInfo.id}
+            />
+          ) : !isUndefined(disputeKitAddress) ? (
+            <>Unable to load dispute kit</>
+          ) : null}
         </>
       ) : (
         <AppealHistory isAppealMiniGuideOpen={isAppealMiniGuideOpen} toggleAppealMiniGuide={toggleAppealMiniGuide} />
       )}
🧰 Tools
🪛 GitHub Check: SonarCloud Code Analysis

[warning] 55-55: Complete the task associated to this "TODO" comment.

See more on https://sonarcloud.io/project/issues?id=kleros_kleros-v2&issues=AZ0qLR_XWI1lSSkCvWo5&open=AZ0qLR_XWI1lSSkCvWo5&pullRequest=2267

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@web/src/pages/Cases/CaseDetails/Appeal/index.tsx` around lines 53 - 67, The
current early return shows "Unable to load dispute kit" before the dispute query
resolves because disputeKitAddress is async; change the guard so you only show
the unsupported-kit state when you actually requested a kit and it failed to
resolve: remove the top-level if (isUndefined(disputeKitInfo)) return ... and
instead, inside the Periods.appeal === currentPeriodIndex branch before
rendering <AppealComponent>, check that disputeKitAddress (from
disputeData?.dispute?.currentRound?.disputeKit?.address) is defined and
disputeKitInfo is undefined and only then render the "Unable to load dispute
kit" fallback; otherwise, when not in appeal period render AppealHistory as
before and allow useDisputeKitInfo (the hook) to resolve without
short-circuiting the entire component.

Comment on lines +45 to +47
// @ts-expect-error Typescript is unable to handle the union type here. TODO: fix
await castCommit({
type: disputeKitName ?? DisputeKits.Classic,
disputeKitId,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Expect: the commit param union is narrower than the broad `DisputeKits` prop,
# which explains the current `@ts-expect-error`.
sed -n '1,260p' web/src/actions/commit/params.ts
echo '---'
sed -n '1,260p' web/src/hooks/useCastCommit.tsx
echo '---'
sed -n '1,260p' web/src/dispute-kits/types.ts
echo '---'
sed -n '1,220p' web/src/pages/Cases/CaseDetails/Voting/Classic/index.tsx
echo '---'
sed -n '1,220p' web/src/pages/Cases/CaseDetails/Voting/Classic/Commit.tsx

Repository: kleros/kleros-v2

Length of output: 8348


Narrow the disputeKitId prop to DisputeKits.Classic in this component.

The @ts-expect-error suppresses the discriminated-union check on the castCommit payload. Since this component is exclusively in the Classic voting flow, ICommit.disputeKitId should be typed as DisputeKits.Classic instead of the broad DisputeKits enum. This allows TypeScript to discriminate the correct CommitParams variant (ClassicCommitParams) and removes the need for the suppression.

Suggested change
interface ICommit {
  arbitrable: Address;
  voteIDs: string[];
  setIsOpen: (val: boolean) => void;
- disputeKitId: DisputeKits;
+ disputeKitId: DisputeKits.Classic;
}

Then remove the @ts-expect-error comment from line 45.

🧰 Tools
🪛 GitHub Check: SonarCloud Code Analysis

[warning] 45-45: Complete the task associated to this "TODO" comment.

See more on https://sonarcloud.io/project/issues?id=kleros_kleros-v2&issues=AZ0qLR8HWI1lSSkCvWo3&open=AZ0qLR8HWI1lSSkCvWo3&pullRequest=2267

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@web/src/pages/Cases/CaseDetails/Voting/Classic/Commit.tsx` around lines 45 -
47, This component uses castCommit with a union-typed disputeKitId causing a
suppressed type error; narrow the commit payload so TypeScript knows it's the
Classic variant by ensuring the disputeKitId is typed as DisputeKits.Classic
(e.g., update the Commit component/prop type or the local ICommit variable to
ICommit & { disputeKitId: DisputeKits.Classic } or use the ClassicCommitParams
variant), then remove the // `@ts-expect-error` and let castCommit accept the
correctly discriminated Classic params; references: castCommit, ICommit,
DisputeKits, ClassicCommitParams, Commit (Commit.tsx).

Comment on lines +95 to +97
export function getDisputeKitConfig(id: DisputeKits) {
return DISPUTE_KIT_REGISTRY[id];
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

IIUC, this function provides a way to get a config where we are sure it won't be undefined. That said, it doesn't seem to be used anywhere. Should this function and getDisputeKitConfigByKitId be combined into one, which accepts all types as input? It will be slightly more expensive, but since this function isn't used, it should be the same.
Unless, of course, you're planning on using this function heavily later, in which case it might be useful to keep.

* @dev Assumes the DisputeKit is Gated, since it will only be called through gated kit routes
*/
export function useGatedTokenInfo(disputeId?: string, disputeKitAddress?: Address, currentRoundIndex?: number) {
export function useGatedTokenInfo(disputeId: string, disputeKitAddress: Address, currentRoundIndex: number) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

disputeKitAddress is unused. Maybe remove?

const { disputeKitName } = useDisputeKitAddresses({ disputeKitAddress });
const isClassicDisputeKit = isClassicLikeDisputeKit(disputeKitName);
const isShutterDisputeKit = isShutterLikeDisputeKit(disputeKitName);
const disputeKitAddress = disputeData?.dispute?.currentRound?.disputeKit?.address;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Removing the ?? undefined from this line causes a type error on the next one. Any particular reason to remove this?

import React, { useState } from "react";
import styled, { css } from "styled-components";

import { Address } from "viem";
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Unused import.

Comment on lines 177 to 192
const TokenImg: React.FC = () => {
if (isERC721 && imageUri && !imgError) {
return (
<ImageContainer>
<NFTImage src={imageUri} alt={nftName || displayName} onError={() => setImgError(true)} loading="lazy" />
</ImageContainer>
);
} else if (isERC721) {
return (
<ImageContainer>
<PlaceholderText>🖼️</PlaceholderText>
</ImageContainer>
);
}
return null;
};
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I normally don't define components inside other components to avoid unnecessary remounts.

interface IOverview {
arbitrable?: Address;
courtID?: string;
currentPeriodIndex: number;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Not sure if it's because of your changes, but this is unused.

parseInt(dispute?.dispute?.currentRoundIndex ?? "0", 10)
);
const disputeKitAddress = dispute?.dispute?.currentRound.disputeKit?.address;
const currentRoundIndex = dispute?.dispute?.currentRoundIndex ?? 0n;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Seems to me we are not handling types properly here. Recently, I changed the subgraph to map BigInt to string, so this comes as a string and we give it a BigInt fallback. However, the DisputeKitOverviewExtraInfoComponent expects it to be a number, which comes from the types file. We might want to consolidate this, wdyt?

@@ -43,10 +43,10 @@ const Vote: React.FC<IVote> = ({ arbitrable, voteIDs, setIsOpen, disputeKitName
choice: voteOption,
salt: BigInt(disputeData?.dispute?.currentRoundIndex),
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Not done on this PR, but here this can be undefined and there's a type error. We could implement the same guard that's on Commit.tsx and Reveal.tsx.

Note that this guard approach is also valid for the other type issues I mentioned above, related to the disputeKitAddress.

[currentPeriodIndex]
);

const disputeKitAddress = disputeData?.dispute?.currentRound?.disputeKit?.address;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Same type issue here.


import { useTranslation } from "react-i18next";
import { Route, Routes, useParams, Navigate } from "react-router-dom";
import type { Address } from "viem";
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

You probably meant to change the existing import :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants