Skip to content

Commit 4c25bfe

Browse files
committed
feat: migrated all the interfaces to the new v2 ones)
1 parent d66cf9d commit 4c25bfe

19 files changed

+286
-287
lines changed

contracts/deploy/00-home-chain-arbitrable.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { HardhatRuntimeEnvironment } from "hardhat/types";
22
import { DeployFunction } from "hardhat-deploy/types";
3+
import disputeTemplate from "../../kleros-sdk/config/v2-disputetemplate/simple/NewDisputeTemplate.simple.json";
34

45
enum HomeChains {
56
ARBITRUM_ONE = 42161,
@@ -20,10 +21,7 @@ const deployArbitration: DeployFunction = async (hre: HardhatRuntimeEnvironment)
2021

2122
await deploy("ArbitrableExampleEthFee", {
2223
from: deployer,
23-
args: [
24-
klerosCore.address,
25-
"https://cloudflare-ipfs.com/ipfs/bafkreifteme6tusnjwyzajk75fyvzdmtyycxctf7yhfijb6rfigz3n4lvq",
26-
],
24+
args: [klerosCore.address, disputeTemplate],
2725
log: true,
2826
});
2927

contracts/deploy/01-foreign-gateway-on-ethereum.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { HardhatRuntimeEnvironment } from "hardhat/types";
22
import { DeployFunction } from "hardhat-deploy/types";
33
import getContractAddress from "../deploy-helpers/getContractAddress";
4+
import disputeTemplate from "../../kleros-sdk/config/v2-disputetemplate/simple/NewDisputeTemplate.simple.json";
45

56
enum ForeignChains {
67
ETHEREUM_MAINNET = 1,
@@ -52,11 +53,10 @@ const deployForeignGateway: DeployFunction = async (hre: HardhatRuntimeEnvironme
5253
ethers.BigNumber.from(10).pow(17)
5354
);
5455

55-
const metaEvidenceUri = `https://raw.githubusercontent.com/kleros/kleros-v2/master/contracts/deployments/${hre.network.name}/MetaEvidence_ArbitrableExample.json`;
56-
5756
await deploy("ArbitrableExample", {
5857
from: deployer,
59-
args: [foreignGateway.address, metaEvidenceUri],
58+
contract: "ArbitrableExampleEthFee",
59+
args: [foreignGateway.address, disputeTemplate],
6060
log: true,
6161
});
6262
};

contracts/deploy/03-vea-mock.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { HardhatRuntimeEnvironment } from "hardhat/types";
22
import { DeployFunction } from "hardhat-deploy/types";
3-
import { ethers } from "hardhat";
43
import getContractAddress from "../deploy-helpers/getContractAddress";
4+
import disputeTemplate from "../../kleros-sdk/config/v2-disputetemplate/simple/NewDisputeTemplate.simple.json";
55

66
const HARDHAT_NETWORK = 31337;
77

@@ -52,11 +52,9 @@ const deployHomeGateway: DeployFunction = async (hre: HardhatRuntimeEnvironment)
5252
ethers.BigNumber.from(10).pow(17)
5353
);
5454

55-
const metaEvidenceUri = `https://raw.githubusercontent.com/kleros/kleros-v2/master/contracts/deployments/goerli/MetaEvidence_ArbitrableExample.json`;
56-
5755
await deploy("ArbitrableExampleEthFee", {
5856
from: deployer,
59-
args: [foreignGateway.address, metaEvidenceUri],
57+
args: [foreignGateway.address, disputeTemplate],
6058
log: true,
6159
});
6260
};

contracts/deploy/04-klerosliquid-to-v2-gnosis.ts

Lines changed: 2 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { parseUnits, parseEther } from "ethers/lib/utils";
22
import { HardhatRuntimeEnvironment } from "hardhat/types";
33
import { DeployFunction } from "hardhat-deploy/types";
4+
import disputeTemplate from "../../kleros-sdk/config/v2-disputetemplate/simple/NewDisputeTemplate.simple.json";
45

56
enum ForeignChains {
67
GNOSIS_MAINNET = 100,
@@ -104,29 +105,11 @@ const deployKlerosLiquid: DeployFunction = async (hre: HardhatRuntimeEnvironment
104105
// const xKlerosLiquidV2 = await deployments.get("xKlerosLiquidV2");
105106
await deploy("ArbitrableExample", {
106107
from: deployer,
107-
args: [
108-
xKlerosLiquidV2.address,
109-
0,
110-
"/ipfs/bafkreifteme6tusnjwyzajk75fyvzdmtyycxctf7yhfijb6rfigz3n4lvq", // PoH registration
111-
weth.address,
112-
],
108+
args: [xKlerosLiquidV2.address, 0, disputeTemplate, weth.address],
113109
log: true,
114110
maxFeePerGas: ONE_GWEI,
115111
maxPriorityFeePerGas: ONE_GWEI,
116112
});
117-
118-
await execute(
119-
"ArbitrableExample",
120-
{
121-
from: deployer,
122-
log: true,
123-
maxFeePerGas: ONE_GWEI,
124-
maxPriorityFeePerGas: ONE_GWEI,
125-
},
126-
"changeMetaEvidence",
127-
1,
128-
"/ipfs/bafkreibiuxwejijwg4pxco7fqszawcwmpt26itbdxeqgh7cvpeuwtmlhoa" // PoH clearing
129-
);
130113
};
131114

132115
// TODO: mock deployment on the hardhat network

contracts/src/arbitration/IArbitrableV2.sol

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ interface IArbitrableV2 {
1313
/// @dev To be emitted when a new dispute template is created.
1414
/// @param _templateId The identifier of the dispute template.
1515
/// @param _templateTag An optional tag for the dispute template, such as "registration" or "removal".
16-
/// @param data The template data.
17-
event DisputeTemplate(uint256 indexed _templateId, string indexed _templateTag, string data);
16+
/// @param _templateData The template data.
17+
event DisputeTemplate(uint256 indexed _templateId, string indexed _templateTag, string _templateData);
1818

1919
/// @dev To be emitted when a dispute is created to link the correct meta-evidence to the disputeID.
2020
/// @param _arbitrator The arbitrator of the contract.

contracts/src/arbitration/KlerosGovernor.sol

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,11 @@
77

88
pragma solidity 0.8.18;
99

10-
import "./IArbitrable.sol";
11-
import "../evidence/IMetaEvidence.sol";
10+
import {IArbitrableV2, IArbitratorV2} from "./IArbitrableV2.sol";
1211
import "../libraries/CappedMath.sol";
1312

1413
/// @title KlerosGovernor for V2. Note that appeal functionality and evidence submission will be handled by the court.
15-
contract KlerosGovernor is IArbitrable, IMetaEvidence {
14+
contract KlerosGovernor is IArbitrableV2 {
1615
using CappedMath for uint256;
1716

1817
// ************************************* //
@@ -52,9 +51,9 @@ contract KlerosGovernor is IArbitrable, IMetaEvidence {
5251
uint256 approvalTime; // The time when the list was approved.
5352
}
5453

55-
IArbitrator public arbitrator; // Arbitrator contract.
54+
IArbitratorV2 public arbitrator; // Arbitrator contract.
5655
bytes public arbitratorExtraData; // Extra data for arbitrator.
57-
uint256 public metaEvidenceUpdates; // The number of times the meta evidence has been updated. Used to track the latest meta evidence ID.
56+
uint256 public disputeTemplates; // The number of dispute templates created.
5857

5958
uint256 public submissionBaseDeposit; // The base deposit in wei that needs to be paid in order to submit the list.
6059
uint256 public submissionTimeout; // Time in seconds allowed for submitting the lists. Once it's passed the contract enters the approval period.
@@ -115,15 +114,15 @@ contract KlerosGovernor is IArbitrable, IMetaEvidence {
115114
/// @dev Constructor.
116115
/// @param _arbitrator The arbitrator of the contract.
117116
/// @param _arbitratorExtraData Extra data for the arbitrator.
118-
/// @param _metaEvidence The URI of the meta evidence file.
117+
/// @param _templateData The dispute template data.
119118
/// @param _submissionBaseDeposit The base deposit required for submission.
120119
/// @param _submissionTimeout Time in seconds allocated for submitting transaction list.
121120
/// @param _executionTimeout Time in seconds after approval that allows to execute transactions of the approved list.
122121
/// @param _withdrawTimeout Time in seconds after submission that allows to withdraw submitted list.
123122
constructor(
124-
IArbitrator _arbitrator,
123+
IArbitratorV2 _arbitrator,
125124
bytes memory _arbitratorExtraData,
126-
string memory _metaEvidence,
125+
string memory _templateData,
127126
uint256 _submissionBaseDeposit,
128127
uint256 _submissionTimeout,
129128
uint256 _executionTimeout,
@@ -139,7 +138,7 @@ contract KlerosGovernor is IArbitrable, IMetaEvidence {
139138
withdrawTimeout = _withdrawTimeout;
140139
sessions.push();
141140

142-
emit MetaEvidence(metaEvidenceUpdates, _metaEvidence);
141+
emit DisputeTemplate(disputeTemplates++, "", _templateData);
143142
}
144143

145144
/// @dev Changes the value of the base deposit required for submitting a list.
@@ -171,18 +170,17 @@ contract KlerosGovernor is IArbitrable, IMetaEvidence {
171170
/// @param _arbitrator The new trusted arbitrator.
172171
/// @param _arbitratorExtraData The extra data used by the new arbitrator.
173172
function changeArbitrator(
174-
IArbitrator _arbitrator,
173+
IArbitratorV2 _arbitrator,
175174
bytes memory _arbitratorExtraData
176175
) external onlyByGovernor duringSubmissionPeriod {
177176
arbitrator = _arbitrator;
178177
arbitratorExtraData = _arbitratorExtraData;
179178
}
180179

181-
/// @dev Update the meta evidence used for disputes.
182-
/// @param _metaEvidence URI to the new meta evidence file.
183-
function changeMetaEvidence(string memory _metaEvidence) external onlyByGovernor {
184-
metaEvidenceUpdates++;
185-
emit MetaEvidence(metaEvidenceUpdates, _metaEvidence);
180+
/// @dev Update the dispute template data.
181+
/// @param _templateData The new dispute template data.
182+
function changeDisputeTemplate(string memory _templateData) external onlyByGovernor {
183+
emit DisputeTemplate(disputeTemplates++, "", _templateData);
186184
}
187185

188186
/// @dev Creates transaction list based on input parameters and submits it for potential approval and execution.
@@ -296,7 +294,7 @@ contract KlerosGovernor is IArbitrable, IMetaEvidence {
296294
session.sumDeposit = session.sumDeposit.subCap(arbitrationCost);
297295

298296
reservedETH = reservedETH.subCap(arbitrationCost);
299-
emit Dispute(arbitrator, session.disputeID, metaEvidenceUpdates, sessions.length - 1);
297+
emit DisputeRequest(arbitrator, session.disputeID, sessions.length - 1, disputeTemplates, "");
300298
}
301299
}
302300

@@ -325,7 +323,7 @@ contract KlerosGovernor is IArbitrable, IMetaEvidence {
325323
session.ruling = _ruling;
326324
sessions.push();
327325

328-
emit Ruling(IArbitrator(msg.sender), _disputeID, _ruling);
326+
emit Ruling(IArbitratorV2(msg.sender), _disputeID, _ruling);
329327
}
330328

331329
/// @dev Executes selected transactions of the list.

contracts/src/arbitration/arbitrables/ArbitrableExample.sol

Lines changed: 24 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -3,61 +3,63 @@
33
pragma solidity 0.8.18;
44

55
import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
6-
import "../IArbitrable.sol";
7-
import "../../evidence/IMetaEvidence.sol";
6+
import {IArbitrableV2, IArbitratorV2} from "../IArbitrableV2.sol";
87

98
/// @title ArbitrableExample
109
/// An example of an arbitrable contract which connects to the arbitator that implements the updated interface.
11-
contract ArbitrableExample is IArbitrable, IMetaEvidence {
10+
contract ArbitrableExample is IArbitrableV2 {
1211
struct DisputeStruct {
1312
bool isRuled; // Whether the dispute has been ruled or not.
1413
uint256 ruling; // Ruling given by the arbitrator.
1514
uint256 numberOfRulingOptions; // The number of choices the arbitrator can give.
1615
}
1716

17+
event Action(string indexed _action);
18+
1819
address public immutable governor;
19-
IArbitrator public arbitrator; // Arbitrator is set in constructor and never changed.
20+
IArbitratorV2 public arbitrator; // Arbitrator is set in constructor.
21+
uint256 public disputeTemplates; // The number of dispute templates created.
2022
ERC20 public immutable weth; // The WETH token.
2123
mapping(uint256 => uint256) public externalIDtoLocalID; // Maps external (arbitrator side) dispute IDs to local dispute IDs.
2224
DisputeStruct[] public disputes; // Stores the disputes' info. disputes[disputeID].
2325

2426
/// @dev Constructor
2527
/// @param _arbitrator The arbitrator to rule on created disputes.
26-
/// @param _metaEvidenceID Unique identifier of meta-evidence.
27-
/// @param _metaEvidence The URI of the meta evidence object for evidence submissions requests.
28-
constructor(IArbitrator _arbitrator, uint256 _metaEvidenceID, string memory _metaEvidence, ERC20 _weth) {
28+
/// @param _templateData The dispute template data.
29+
/// @param _weth The WETH token.
30+
constructor(IArbitratorV2 _arbitrator, string memory _templateData, ERC20 _weth) {
2931
governor = msg.sender;
3032
arbitrator = _arbitrator;
3133
weth = _weth;
32-
emit MetaEvidence(_metaEvidenceID, _metaEvidence);
34+
emit DisputeTemplate(disputeTemplates++, "", _templateData);
3335
}
3436

3537
/// @dev Calls createDispute function of the specified arbitrator to create a dispute.
3638
/// Note that we don’t need to check that msg.value is enough to pay arbitration fees as it’s the responsibility of the arbitrator contract.
37-
/// @param _numberOfRulingOptions Number of ruling options. Must be greater than 1, otherwise there is nothing to choose from.
39+
/// @param _templateId The identifier of the dispute template. Should not be used with _templateUri.
40+
/// @param _action The action that requires arbitration.
3841
/// @param _arbitratorExtraData Extra data for the arbitrator.
39-
/// @param _metaEvidenceID Unique identifier of meta-evidence.
40-
/// @param _evidenceGroupID Unique identifier of the evidence group that is linked to this dispute.
4142
/// @param _feeInWeth Amount of fees in WETH for the arbitrator.
4243
/// @return disputeID Dispute id (on arbitrator side) of the dispute created.
4344
function createDispute(
44-
uint256 _numberOfRulingOptions,
45+
uint256 _templateId,
46+
string calldata _action,
4547
bytes calldata _arbitratorExtraData,
46-
uint256 _metaEvidenceID,
47-
uint256 _evidenceGroupID,
4848
uint256 _feeInWeth
4949
) external payable returns (uint256 disputeID) {
50-
require(_numberOfRulingOptions > 1, "Incorrect number of choices");
50+
emit Action(_action);
5151

52+
uint256 numberOfRulingOptions = 2;
5253
uint256 localDisputeID = disputes.length;
53-
disputes.push(DisputeStruct({isRuled: false, ruling: 0, numberOfRulingOptions: _numberOfRulingOptions}));
54+
disputes.push(DisputeStruct({isRuled: false, ruling: 0, numberOfRulingOptions: numberOfRulingOptions}));
5455

5556
require(weth.transferFrom(msg.sender, address(this), _feeInWeth), "Not enough WETH for arbitration");
5657
weth.increaseAllowance(address(arbitrator), _feeInWeth);
57-
disputeID = arbitrator.createDispute(_numberOfRulingOptions, _arbitratorExtraData);
58+
disputeID = arbitrator.createDispute(numberOfRulingOptions, _arbitratorExtraData);
5859
externalIDtoLocalID[disputeID] = localDisputeID;
5960

60-
emit Dispute(arbitrator, disputeID, _metaEvidenceID, _evidenceGroupID);
61+
uint256 externalDisputeID = uint256(keccak256(abi.encodePacked(_action)));
62+
emit DisputeRequest(arbitrator, disputeID, externalDisputeID, _templateId, "");
6163
}
6264

6365
/// @dev To be called by the arbitrator of the dispute, to declare the winning ruling.
@@ -73,15 +75,15 @@ contract ArbitrableExample is IArbitrable, IMetaEvidence {
7375
dispute.isRuled = true;
7476
dispute.ruling = _ruling;
7577

76-
emit Ruling(IArbitrator(msg.sender), _externalDisputeID, dispute.ruling);
78+
emit Ruling(IArbitratorV2(msg.sender), _externalDisputeID, dispute.ruling);
7779
}
7880

79-
function changeMetaEvidence(uint256 _metaEvidenceID, string memory _metaEvidence) external {
81+
function changeDisputeTemplate(string memory _templateData) external {
8082
require(msg.sender == governor, "Not authorized: governor only.");
81-
emit MetaEvidence(_metaEvidenceID, _metaEvidence);
83+
emit DisputeTemplate(disputeTemplates++, "", _templateData);
8284
}
8385

84-
function changeArbitrator(IArbitrator _arbitrator) external {
86+
function changeArbitrator(IArbitratorV2 _arbitrator) external {
8587
require(msg.sender == governor, "Not authorized: governor only.");
8688
arbitrator = _arbitrator;
8789
}

0 commit comments

Comments
 (0)