Skip to content

Commit 61c07b9

Browse files
Merge branch 'dev' into feat/devtools
2 parents dc25764 + 740193d commit 61c07b9

File tree

3 files changed

+28
-26
lines changed

3 files changed

+28
-26
lines changed

contracts/src/arbitration/devtools/DisputeResolverRuler.sol

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
import {DisputeResolver, IArbitratorV2, IDisputeTemplateRegistry} from "../arbitrables/DisputeResolver.sol";
99

10-
pragma solidity 0.8.18;
10+
pragma solidity 0.8.24;
1111

1212
interface IKlerosCoreRulerFragment {
1313
function getNextDisputeID() external view returns (uint256);

contracts/src/arbitration/devtools/KlerosCoreRuler.sol

+15-16
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
// SPDX-License-Identifier: MIT
22

3-
pragma solidity 0.8.18;
3+
pragma solidity 0.8.24;
44

55
import {IArbitrableV2, IArbitratorV2} from "../interfaces/IArbitratorV2.sol";
66
import {SafeERC20, IERC20} from "../../libraries/SafeERC20.sol";
7-
import {Constants} from "../../libraries/Constants.sol";
8-
import {OnError} from "../../libraries/Types.sol";
97
import {UUPSProxiable} from "../../proxy/UUPSProxiable.sol";
108
import {Initializable} from "../../proxy/Initializable.sol";
9+
import "../../libraries/Constants.sol";
1110

1211
/// @title KlerosCoreRuler
1312
/// Core arbitrator contract for development and testing purposes.
@@ -188,7 +187,7 @@ contract KlerosCoreRuler is IArbitratorV2, UUPSProxiable, Initializable {
188187

189188
// GENERAL_COURT
190189
Court storage court = courts.push();
191-
court.parent = Constants.FORKING_COURT;
190+
court.parent = FORKING_COURT;
192191
court.children = new uint256[](0);
193192
court.hiddenVotes = false;
194193
court.minStake = _courtParameters[0];
@@ -262,7 +261,7 @@ contract KlerosCoreRuler is IArbitratorV2, UUPSProxiable, Initializable {
262261
uint256 _jurorsForCourtJump,
263262
uint256[4] memory _timesPerPeriod
264263
) external onlyByGovernor {
265-
if (_parent == Constants.FORKING_COURT) revert InvalidForkingCourtAsParent();
264+
if (_parent == FORKING_COURT) revert InvalidForkingCourtAsParent();
266265

267266
uint256 courtID = courts.length;
268267
Court storage court = courts.push();
@@ -387,7 +386,7 @@ contract KlerosCoreRuler is IArbitratorV2, UUPSProxiable, Initializable {
387386
) external payable override returns (uint256 disputeID) {
388387
if (msg.value < arbitrationCost(_extraData)) revert ArbitrationFeesNotEnough();
389388

390-
return _createDispute(_numberOfChoices, _extraData, Constants.NATIVE_CURRENCY, msg.value);
389+
return _createDispute(_numberOfChoices, _extraData, NATIVE_CURRENCY, msg.value);
391390
}
392391

393392
/// @inheritdoc IArbitratorV2
@@ -516,7 +515,7 @@ contract KlerosCoreRuler is IArbitratorV2, UUPSProxiable, Initializable {
516515
Round storage round = dispute.rounds[_round];
517516
uint256 feeReward = round.totalFeesForJurors;
518517
round.sumFeeRewardPaid += feeReward;
519-
if (round.feeToken == Constants.NATIVE_CURRENCY) {
518+
if (round.feeToken == NATIVE_CURRENCY) {
520519
// The dispute fees were paid in ETH
521520
payable(account).send(feeReward);
522521
} else {
@@ -573,7 +572,7 @@ contract KlerosCoreRuler is IArbitratorV2, UUPSProxiable, Initializable {
573572
uint256 nbVotes = round.totalFeesForJurors / court.feeForJuror;
574573
if (_jump) {
575574
// Jump to parent court.
576-
if (dispute.courtID == Constants.GENERAL_COURT) {
575+
if (dispute.courtID == GENERAL_COURT) {
577576
// TODO: Handle the forking when appealed in General court.
578577
cost = NON_PAYABLE_AMOUNT; // Get the cost of the parent court.
579578
} else {
@@ -648,19 +647,19 @@ contract KlerosCoreRuler is IArbitratorV2, UUPSProxiable, Initializable {
648647
minJurors := mload(add(_extraData, 0x40))
649648
disputeKitID := mload(add(_extraData, 0x60))
650649
}
651-
if (courtID == Constants.FORKING_COURT || courtID >= courts.length) {
652-
courtID = Constants.GENERAL_COURT;
650+
if (courtID == FORKING_COURT || courtID >= courts.length) {
651+
courtID = GENERAL_COURT;
653652
}
654653
if (minJurors == 0) {
655-
minJurors = Constants.DEFAULT_NB_OF_JURORS;
654+
minJurors = DEFAULT_NB_OF_JURORS;
656655
}
657-
if (disputeKitID == Constants.NULL_DISPUTE_KIT) {
658-
disputeKitID = Constants.DISPUTE_KIT_CLASSIC; // 0 index is not used.
656+
if (disputeKitID == NULL_DISPUTE_KIT) {
657+
disputeKitID = DISPUTE_KIT_CLASSIC; // 0 index is not used.
659658
}
660659
} else {
661-
courtID = Constants.GENERAL_COURT;
662-
minJurors = Constants.DEFAULT_NB_OF_JURORS;
663-
disputeKitID = Constants.DISPUTE_KIT_CLASSIC;
660+
courtID = GENERAL_COURT;
661+
minJurors = DEFAULT_NB_OF_JURORS;
662+
disputeKitID = DISPUTE_KIT_CLASSIC;
664663
}
665664
}
666665

web/src/pages/Cases/CaseDetails/MaintenanceButtons/DrawButton.tsx

+12-9
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,16 @@ import { usePublicClient } from "wagmi";
66
import { Button } from "@kleros/ui-components-library";
77

88
import { useSimulateKlerosCoreDraw, useWriteKlerosCoreDraw } from "hooks/contracts/generated";
9+
import { useSortitionModulePhase } from "hooks/useSortitionModulePhase";
910
import { wrapWithToast } from "utils/wrapWithToast";
1011

1112
import useDisputeMaintenanceQuery from "queries/useDisputeMaintenanceQuery";
1213

1314
import { Period } from "src/graphql/graphql";
1415
import { isUndefined } from "src/utils";
1516

17+
import { Phases } from "components/Phase";
18+
1619
import { IBaseMaintenanceButton } from ".";
1720

1821
const StyledButton = styled(Button)`
@@ -28,21 +31,22 @@ const DrawButton: React.FC<IDrawButton> = ({ id, numberOfVotes, setIsOpen, perio
2831
const [isSending, setIsSending] = useState(false);
2932
const publicClient = usePublicClient();
3033
const { data: maintenanceData } = useDisputeMaintenanceQuery(id);
34+
const { data: phase } = useSortitionModulePhase();
3135

3236
const isDrawn = useMemo(() => maintenanceData?.dispute?.currentRound.jurorsDrawn, [maintenanceData]);
3337

38+
const canDraw = useMemo(
39+
() => !isUndefined(maintenanceData) && !isDrawn && period === Period.Evidence && phase === Phases.drawing,
40+
[maintenanceData, isDrawn, phase, period]
41+
);
42+
3443
const {
3544
data: drawConfig,
3645
isLoading: isLoadingConfig,
3746
isError,
3847
} = useSimulateKlerosCoreDraw({
3948
query: {
40-
enabled:
41-
!isUndefined(id) &&
42-
!isUndefined(numberOfVotes) &&
43-
!isUndefined(period) &&
44-
period === Period.Evidence &&
45-
!isDrawn,
49+
enabled: !isUndefined(id) && !isUndefined(numberOfVotes) && !isUndefined(period) && canDraw,
4650
},
4751
args: [BigInt(id ?? 0), BigInt(numberOfVotes ?? 0)],
4852
});
@@ -51,9 +55,8 @@ const DrawButton: React.FC<IDrawButton> = ({ id, numberOfVotes, setIsOpen, perio
5155

5256
const isLoading = useMemo(() => isLoadingConfig || isSending, [isLoadingConfig, isSending]);
5357
const isDisabled = useMemo(
54-
() =>
55-
isUndefined(id) || isUndefined(numberOfVotes) || isError || isLoading || period !== Period.Evidence || isDrawn,
56-
[id, numberOfVotes, isError, isLoading, period, isDrawn]
58+
() => isUndefined(id) || isUndefined(numberOfVotes) || isError || isLoading || !canDraw,
59+
[id, numberOfVotes, isError, isLoading, canDraw]
5760
);
5861
const handleClick = () => {
5962
if (!drawConfig || !publicClient) return;

0 commit comments

Comments
 (0)