Skip to content

Commit

Permalink
Merge branch 'dev' into feat/devtools
Browse files Browse the repository at this point in the history
  • Loading branch information
nikhilverma360 committed Aug 12, 2024
2 parents dc25764 + 740193d commit 61c07b9
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

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

pragma solidity 0.8.18;
pragma solidity 0.8.24;

interface IKlerosCoreRulerFragment {
function getNextDisputeID() external view returns (uint256);
Expand Down
31 changes: 15 additions & 16 deletions contracts/src/arbitration/devtools/KlerosCoreRuler.sol
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
// SPDX-License-Identifier: MIT

pragma solidity 0.8.18;
pragma solidity 0.8.24;

import {IArbitrableV2, IArbitratorV2} from "../interfaces/IArbitratorV2.sol";
import {SafeERC20, IERC20} from "../../libraries/SafeERC20.sol";
import {Constants} from "../../libraries/Constants.sol";
import {OnError} from "../../libraries/Types.sol";
import {UUPSProxiable} from "../../proxy/UUPSProxiable.sol";
import {Initializable} from "../../proxy/Initializable.sol";
import "../../libraries/Constants.sol";

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

// GENERAL_COURT
Court storage court = courts.push();
court.parent = Constants.FORKING_COURT;
court.parent = FORKING_COURT;
court.children = new uint256[](0);
court.hiddenVotes = false;
court.minStake = _courtParameters[0];
Expand Down Expand Up @@ -262,7 +261,7 @@ contract KlerosCoreRuler is IArbitratorV2, UUPSProxiable, Initializable {
uint256 _jurorsForCourtJump,
uint256[4] memory _timesPerPeriod
) external onlyByGovernor {
if (_parent == Constants.FORKING_COURT) revert InvalidForkingCourtAsParent();
if (_parent == FORKING_COURT) revert InvalidForkingCourtAsParent();

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

return _createDispute(_numberOfChoices, _extraData, Constants.NATIVE_CURRENCY, msg.value);
return _createDispute(_numberOfChoices, _extraData, NATIVE_CURRENCY, msg.value);
}

/// @inheritdoc IArbitratorV2
Expand Down Expand Up @@ -516,7 +515,7 @@ contract KlerosCoreRuler is IArbitratorV2, UUPSProxiable, Initializable {
Round storage round = dispute.rounds[_round];
uint256 feeReward = round.totalFeesForJurors;
round.sumFeeRewardPaid += feeReward;
if (round.feeToken == Constants.NATIVE_CURRENCY) {
if (round.feeToken == NATIVE_CURRENCY) {
// The dispute fees were paid in ETH
payable(account).send(feeReward);
} else {
Expand Down Expand Up @@ -573,7 +572,7 @@ contract KlerosCoreRuler is IArbitratorV2, UUPSProxiable, Initializable {
uint256 nbVotes = round.totalFeesForJurors / court.feeForJuror;
if (_jump) {
// Jump to parent court.
if (dispute.courtID == Constants.GENERAL_COURT) {
if (dispute.courtID == GENERAL_COURT) {
// TODO: Handle the forking when appealed in General court.
cost = NON_PAYABLE_AMOUNT; // Get the cost of the parent court.
} else {
Expand Down Expand Up @@ -648,19 +647,19 @@ contract KlerosCoreRuler is IArbitratorV2, UUPSProxiable, Initializable {
minJurors := mload(add(_extraData, 0x40))
disputeKitID := mload(add(_extraData, 0x60))
}
if (courtID == Constants.FORKING_COURT || courtID >= courts.length) {
courtID = Constants.GENERAL_COURT;
if (courtID == FORKING_COURT || courtID >= courts.length) {
courtID = GENERAL_COURT;
}
if (minJurors == 0) {
minJurors = Constants.DEFAULT_NB_OF_JURORS;
minJurors = DEFAULT_NB_OF_JURORS;
}
if (disputeKitID == Constants.NULL_DISPUTE_KIT) {
disputeKitID = Constants.DISPUTE_KIT_CLASSIC; // 0 index is not used.
if (disputeKitID == NULL_DISPUTE_KIT) {
disputeKitID = DISPUTE_KIT_CLASSIC; // 0 index is not used.
}
} else {
courtID = Constants.GENERAL_COURT;
minJurors = Constants.DEFAULT_NB_OF_JURORS;
disputeKitID = Constants.DISPUTE_KIT_CLASSIC;
courtID = GENERAL_COURT;
minJurors = DEFAULT_NB_OF_JURORS;
disputeKitID = DISPUTE_KIT_CLASSIC;
}
}

Expand Down
21 changes: 12 additions & 9 deletions web/src/pages/Cases/CaseDetails/MaintenanceButtons/DrawButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,16 @@ import { usePublicClient } from "wagmi";
import { Button } from "@kleros/ui-components-library";

import { useSimulateKlerosCoreDraw, useWriteKlerosCoreDraw } from "hooks/contracts/generated";
import { useSortitionModulePhase } from "hooks/useSortitionModulePhase";
import { wrapWithToast } from "utils/wrapWithToast";

import useDisputeMaintenanceQuery from "queries/useDisputeMaintenanceQuery";

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

import { Phases } from "components/Phase";

import { IBaseMaintenanceButton } from ".";

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

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

const canDraw = useMemo(
() => !isUndefined(maintenanceData) && !isDrawn && period === Period.Evidence && phase === Phases.drawing,
[maintenanceData, isDrawn, phase, period]
);

const {
data: drawConfig,
isLoading: isLoadingConfig,
isError,
} = useSimulateKlerosCoreDraw({
query: {
enabled:
!isUndefined(id) &&
!isUndefined(numberOfVotes) &&
!isUndefined(period) &&
period === Period.Evidence &&
!isDrawn,
enabled: !isUndefined(id) && !isUndefined(numberOfVotes) && !isUndefined(period) && canDraw,
},
args: [BigInt(id ?? 0), BigInt(numberOfVotes ?? 0)],
});
Expand All @@ -51,9 +55,8 @@ const DrawButton: React.FC<IDrawButton> = ({ id, numberOfVotes, setIsOpen, perio

const isLoading = useMemo(() => isLoadingConfig || isSending, [isLoadingConfig, isSending]);
const isDisabled = useMemo(
() =>
isUndefined(id) || isUndefined(numberOfVotes) || isError || isLoading || period !== Period.Evidence || isDrawn,
[id, numberOfVotes, isError, isLoading, period, isDrawn]
() => isUndefined(id) || isUndefined(numberOfVotes) || isError || isLoading || !canDraw,
[id, numberOfVotes, isError, isLoading, canDraw]
);
const handleClick = () => {
if (!drawConfig || !publicClient) return;
Expand Down

0 comments on commit 61c07b9

Please sign in to comment.