@@ -5,9 +5,13 @@ import { Address } from "viem";
55
66import { DEFAULT_CHAIN } from "consts/chains" ;
77import { klerosCoreAddress } from "hooks/contracts/generated" ;
8+ import { useSupportedDisputeKits } from "hooks/queries/useSupportedDisputeKits" ;
9+ import { useDisputeKitAddressesAll } from "hooks/useDisputeKitAddresses" ;
810import { useLocalStorage } from "hooks/useLocalStorage" ;
911import { isEmpty , isUndefined } from "utils/index" ;
1012
13+ import { DisputeKits } from "src/consts" ;
14+
1115export const MIN_DISPUTE_BATCH_SIZE = 2 ;
1216
1317export type Answer = {
@@ -24,6 +28,12 @@ export type AliasArray = {
2428 isValid ?: boolean ;
2529} ;
2630
31+ export type DisputeKitOption = {
32+ text : DisputeKits ;
33+ value : number ;
34+ gated : boolean ;
35+ } ;
36+
2737export type Alias = Record < string , string > ;
2838export interface IDisputeTemplate {
2939 answers : Answer [ ] ;
@@ -83,6 +93,7 @@ interface INewDisputeContext {
8393 setIsBatchCreation : ( isBatchCreation : boolean ) => void ;
8494 batchSize : number ;
8595 setBatchSize : ( batchSize ?: number ) => void ;
96+ disputeKitOptions : DisputeKitOption [ ] ;
8697}
8798
8899const getInitialDisputeData = ( ) : IDisputeData => ( {
@@ -137,6 +148,22 @@ export const NewDisputeProvider: React.FC<{ children: React.ReactNode }> = ({ ch
137148 // eslint-disable-next-line react-hooks/exhaustive-deps
138149 } , [ location . pathname ] ) ;
139150
151+ const { data : supportedDisputeKits } = useSupportedDisputeKits ( disputeData . courtId ) ;
152+ const { availableDisputeKits } = useDisputeKitAddressesAll ( ) ;
153+
154+ const disputeKitOptions : DisputeKitOption [ ] = useMemo ( ( ) => {
155+ return (
156+ supportedDisputeKits ?. court ?. supportedDisputeKits . map ( ( dk ) => {
157+ const text = availableDisputeKits [ dk . address . toLowerCase ( ) ] ?? "" ;
158+ return {
159+ text,
160+ value : Number ( dk . id ) ,
161+ gated : text === DisputeKits . Gated || text === DisputeKits . GatedShutter ,
162+ } ;
163+ } ) || [ ]
164+ ) ;
165+ } , [ supportedDisputeKits , availableDisputeKits ] ) ;
166+
140167 const contextValues = useMemo (
141168 ( ) => ( {
142169 disputeData,
@@ -151,6 +178,7 @@ export const NewDisputeProvider: React.FC<{ children: React.ReactNode }> = ({ ch
151178 setIsBatchCreation,
152179 batchSize,
153180 setBatchSize,
181+ disputeKitOptions,
154182 } ) ,
155183 [
156184 disputeData ,
@@ -163,6 +191,7 @@ export const NewDisputeProvider: React.FC<{ children: React.ReactNode }> = ({ ch
163191 setIsBatchCreation ,
164192 batchSize ,
165193 setBatchSize ,
194+ disputeKitOptions ,
166195 ]
167196 ) ;
168197
0 commit comments