@@ -7,7 +7,10 @@ import { useWalletClient, usePublicClient } from "wagmi";
77
88import { Button } from "@kleros/ui-components-library" ;
99
10- import { useSimulateDisputeKitShutterCastVoteShutter } from "hooks/contracts/generated" ;
10+ import {
11+ useSimulateDisputeKitGatedShutterCastVoteShutter ,
12+ useSimulateDisputeKitShutterCastVoteShutter ,
13+ } from "hooks/contracts/generated" ;
1114import { isUndefined } from "utils/index" ;
1215import { wrapWithToast } from "utils/wrapWithToast" ;
1316
@@ -22,9 +25,10 @@ const Container = styled.div`
2225interface IReveal {
2326 voteIDs : string [ ] ;
2427 setIsOpen : ( val : boolean ) => void ;
28+ isGated : boolean ;
2529}
2630
27- const Reveal : React . FC < IReveal > = ( { voteIDs, setIsOpen } ) => {
31+ const Reveal : React . FC < IReveal > = ( { voteIDs, setIsOpen, isGated } ) => {
2832 const { id } = useParams ( ) ;
2933 const parsedDisputeID = useMemo ( ( ) => BigInt ( id ?? 0 ) , [ id ] ) ;
3034 const parsedVoteIDs = useMemo ( ( ) => voteIDs . map ( ( voteID ) => BigInt ( voteID ) ) , [ voteIDs ] ) ;
@@ -52,12 +56,12 @@ const Reveal: React.FC<IReveal> = ({ voteIDs, setIsOpen }) => {
5256 } , [ storedData ] ) ;
5357
5458 const {
55- data : simulateData ,
56- isLoading : isSimulating ,
57- error : simulateError ,
59+ data : simulateDefaultData ,
60+ isLoading : isSimulatingDefault ,
61+ error : simulateDefaultError ,
5862 } = useSimulateDisputeKitShutterCastVoteShutter ( {
5963 query : {
60- enabled : ! isUndefined ( parsedStoredData ) ,
64+ enabled : ! isUndefined ( parsedStoredData ) && ! isGated ,
6165 } ,
6266 args : [
6367 parsedDisputeID ,
@@ -68,6 +72,27 @@ const Reveal: React.FC<IReveal> = ({ voteIDs, setIsOpen }) => {
6872 ] ,
6973 } ) ;
7074
75+ const {
76+ data : simulateGatedData ,
77+ isLoading : isSimulatingGated ,
78+ error : simulateGatedError ,
79+ } = useSimulateDisputeKitGatedShutterCastVoteShutter ( {
80+ query : {
81+ enabled : ! isUndefined ( parsedStoredData ) && isGated ,
82+ } ,
83+ args : [
84+ parsedDisputeID ,
85+ parsedVoteIDs ,
86+ BigInt ( parsedStoredData ?. choice ?? 0 ) ,
87+ BigInt ( parsedStoredData ?. salt ?? 0 ) ,
88+ parsedStoredData ?. justification ?? "" ,
89+ ] ,
90+ } ) ;
91+
92+ const isSimulating = isGated ? isSimulatingGated : isSimulatingDefault ;
93+ const simulateData = isGated ? simulateGatedData : simulateDefaultData ;
94+ const simulateError = isGated ? simulateGatedError : simulateDefaultError ;
95+
7196 const handleReveal = useCallback ( async ( ) => {
7297 if ( isUndefined ( parsedStoredData ) || isUndefined ( simulateData ) ) {
7398 console . error ( "No committed vote found or simulation not ready." ) ;
0 commit comments