Skip to content

Commit b5fff19

Browse files
committed
fix(web): reveal-shutter-gated
1 parent ce63962 commit b5fff19

File tree

2 files changed

+32
-7
lines changed

2 files changed

+32
-7
lines changed

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

Lines changed: 31 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,10 @@ import { useWalletClient, usePublicClient } from "wagmi";
77

88
import { 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";
1114
import { isUndefined } from "utils/index";
1215
import { wrapWithToast } from "utils/wrapWithToast";
1316

@@ -22,9 +25,10 @@ const Container = styled.div`
2225
interface 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.");

web/src/pages/Cases/CaseDetails/Voting/Shutter/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ const Shutter: React.FC<IShutter> = ({ arbitrable, setIsOpen, dispute, currentPe
2929
return id && isCommitPeriod && !commited ? (
3030
<ShutterCommit {...{ arbitrable, setIsOpen, voteIDs, refetch, dispute, currentPeriodIndex, isGated }} />
3131
) : id && isVotingPeriod ? (
32-
<Reveal {...{ setIsOpen, voteIDs }} />
32+
<Reveal {...{ setIsOpen, voteIDs, isGated }} />
3333
) : null;
3434
};
3535

0 commit comments

Comments
 (0)