Skip to content

Commit 7a74cf8

Browse files
committed
feat: extra _arbitrable parameter for the Evidence event
1 parent 4d14f47 commit 7a74cf8

File tree

4 files changed

+29
-12
lines changed

4 files changed

+29
-12
lines changed

contracts/src/arbitration/evidence/EvidenceModule.sol

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,10 +58,12 @@ contract EvidenceModule is IEvidence, Initializable, UUPSProxiable {
5858
// ************************************* //
5959

6060
/// @notice Submits evidence for a dispute.
61+
/// @dev This function is intended for end users, not for arbitrable contracts which should emit their own events.
62+
/// @param _arbitrable The arbitrable contract address.
6163
/// @param _externalDisputeID Unique identifier for this dispute outside Kleros. It's the submitter responsibility to submit the right evidence group ID.
6264
/// @param _evidence Stringified evidence object, example: `{"name" : "Justification", "description" : "Description", "fileURI" : "/ipfs/QmWQV5ZFFhEJiW8Lm7ay2zLxC2XS4wx1b2W7FfdrLMyQQc"}`.
63-
function submitEvidence(uint256 _externalDisputeID, string calldata _evidence) external {
64-
emit Evidence(_externalDisputeID, msg.sender, _evidence);
65+
function submitEvidence(address _arbitrable, uint256 _externalDisputeID, string calldata _evidence) external {
66+
emit Evidence(_arbitrable, _externalDisputeID, msg.sender, _evidence);
6567
}
6668

6769
// ************************************* //

contracts/src/arbitration/evidence/ModeratedEvidenceModule.sol

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,13 +72,15 @@ contract ModeratedEvidenceModule is IArbitrableV2 {
7272

7373
/// @notice To be raised when a moderated evidence is submitted. Should point to the resource (evidences are not to be stored on chain due to gas considerations).
7474
/// @param _arbitrator The arbitrator of the contract.
75+
/// @param _arbitrable The arbitrable contract address.
7576
/// @param _externalDisputeID Unique identifier for this dispute outside Kleros. It's the submitter responsibility to submit the right evidence group ID.
7677
/// @param _party The address of the party submiting the evidence. Note that 0x0 refers to evidence not submitted by any party.
7778
/// @param _evidence Stringified evidence object, example: '{"name" : "Justification", "description" : "Description", "fileURI" : "/ipfs/QmWQV5ZFFhEJiW8Lm7ay2zLxC2XS4wx1b2W7FfdrLMyQQc"}'.
7879
event ModeratedEvidence(
7980
IArbitratorV2 indexed _arbitrator,
81+
address indexed _arbitrable,
8082
uint256 indexed _externalDisputeID,
81-
address indexed _party,
83+
address _party,
8284
string _evidence
8385
);
8486

@@ -190,9 +192,10 @@ contract ModeratedEvidenceModule is IArbitrableV2 {
190192
// ************************************* //
191193

192194
/// @notice Submits evidence.
195+
/// @param _arbitrable The arbitrable contract address for this evidence.
193196
/// @param _evidenceGroupID Unique identifier of the evidence group the evidence belongs to. It's the submitter responsibility to submit the right evidence group ID.
194197
/// @param _evidence Stringified evidence object, example: '{"name" : "Justification", "description" : "Description", "fileURI" : "/ipfs/QmWQV5ZFFhEJiW8Lm7ay2zLxC2XS4wx1b2W7FfdrLMyQQc"}'.
195-
function submitEvidence(uint256 _evidenceGroupID, string calldata _evidence) external payable {
198+
function submitEvidence(address _arbitrable, uint256 _evidenceGroupID, string calldata _evidence) external payable {
196199
// Optimization opportunity: map evidenceID to an incremental index that can be safely assumed to be less than a small uint.
197200
bytes32 evidenceID = keccak256(abi.encodePacked(_evidenceGroupID, _evidence));
198201
EvidenceData storage evidenceData = evidences[evidenceID];
@@ -214,7 +217,7 @@ contract ModeratedEvidenceModule is IArbitrableV2 {
214217
moderation.arbitratorDataID = arbitratorDataList.length - 1;
215218

216219
// When evidence is submitted for a foreign arbitrable, the arbitrator field of Evidence is ignored.
217-
emit ModeratedEvidence(arbitrator, _evidenceGroupID, msg.sender, _evidence);
220+
emit ModeratedEvidence(arbitrator, _arbitrable, _evidenceGroupID, msg.sender, _evidence);
218221
}
219222

220223
/// @notice Moderates an evidence submission. Requires the contester to at least double the accumulated stake of the oposing party.

contracts/src/arbitration/interfaces/IEvidence.sol

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,15 @@ pragma solidity >=0.8.0 <0.9.0;
55
/// @title IEvidence
66
interface IEvidence {
77
/// @notice To be raised when evidence is submitted. Should point to the resource (evidences are not to be stored on chain due to gas considerations).
8+
/// @dev This event is intended for end users submitting evidence, not for arbitrable contracts.
9+
/// @param _arbitrable The arbitrable contract address.
810
/// @param _externalDisputeID Unique identifier for this dispute outside Kleros. It's the submitter responsibility to submit the right external dispute ID.
911
/// @param _party The address of the party submitting the evidence.
1012
/// @param _evidence Stringified evidence object, example: '{"name" : "Justification", "description" : "Description", "fileURI" : "/ipfs/QmWQV5ZFFhEJiW8Lm7ay2zLxC2XS4wx1b2W7FfdrLMyQQc"}'.
11-
event Evidence(uint256 indexed _externalDisputeID, address indexed _party, string _evidence);
13+
event Evidence(
14+
address indexed _arbitrable,
15+
uint256 indexed _externalDisputeID,
16+
address indexed _party,
17+
string _evidence
18+
);
1219
}

contracts/test/evidence/index.ts

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ describe("Home Evidence contract", async () => {
2323
["uint256", "uint256"],
2424
[1, 1] // courtId 1, minJurors 1
2525
);
26+
const arbitrable = "0x1234567890123456789012345678901234567890"; // Dummy arbitrable address
2627
const appealTimeout = 100;
2728
const bondTimeout = 60 * 10;
2829
const totalCostMultiplier = 15000n;
@@ -147,15 +148,19 @@ describe("Home Evidence contract", async () => {
147148
describe("Evidence Submission", () => {
148149
it("Should submit evidence correctly.", async () => {
149150
const newEvidence = "Irrefutable evidence";
150-
const tx = await evidenceModule.connect(user1).submitEvidence(1234, newEvidence, {
151+
const tx = await evidenceModule.connect(user1).submitEvidence(arbitrable, 1234, newEvidence, {
151152
value: minRequiredDeposit,
152153
}); // id: 0
153154
const receipt = await tx.wait();
154155
if (receipt === null) throw new Error("Receipt is null");
155156
const evidenceID = ethers.solidityPackedKeccak256(["uint", "string"], [1234, newEvidence]);
156157

157-
const [_arbitrator, _externalDisputeID, _party, _evidence] = getEmittedEvent("ModeratedEvidence", receipt).args;
158+
const [_arbitrator, _arbitrable, _externalDisputeID, _party, _evidence] = getEmittedEvent(
159+
"ModeratedEvidence",
160+
receipt
161+
).args;
158162
expect(_arbitrator).to.equal(arbitrator.target, "Wrong arbitrator.");
163+
expect(_arbitrable).to.equal(arbitrable, "Wrong arbitrable.");
159164
expect(_externalDisputeID).to.equal(1234, "Wrong external dispute ID.");
160165
expect(_party).to.equal(user1.address, "Wrong submitter.");
161166
expect(_evidence).to.equal(newEvidence, "Wrong evidence message.");
@@ -169,11 +174,11 @@ describe("Home Evidence contract", async () => {
169174

170175
it("Should not allowed the same evidence twice for the same external dispute id.", async () => {
171176
const newEvidence = "Irrefutable evidence";
172-
await evidenceModule.submitEvidence(1234, newEvidence, {
177+
await evidenceModule.submitEvidence(arbitrable, 1234, newEvidence, {
173178
value: minRequiredDeposit,
174179
});
175180
await expect(
176-
evidenceModule.submitEvidence(1234, newEvidence, {
181+
evidenceModule.submitEvidence(arbitrable, 1234, newEvidence, {
177182
value: minRequiredDeposit,
178183
})
179184
).to.be.revertedWith("Evidence already submitted.");
@@ -182,7 +187,7 @@ describe("Home Evidence contract", async () => {
182187
it("Should revert if deposit is too low.", async () => {
183188
const newEvidence = "Irrefutable evidence";
184189
await expect(
185-
evidenceModule.submitEvidence(1234, newEvidence, {
190+
evidenceModule.submitEvidence(arbitrable, 1234, newEvidence, {
186191
value: minRequiredDeposit - 1n,
187192
})
188193
).to.be.revertedWith("Insufficient funding.");
@@ -192,7 +197,7 @@ describe("Home Evidence contract", async () => {
192197
describe("Moderation", () => {
193198
beforeEach("Initialize posts and comments", async () => {
194199
const newEvidence = "Irrefutable evidence";
195-
await evidenceModule.connect(user1).submitEvidence(1234, newEvidence, {
200+
await evidenceModule.connect(user1).submitEvidence(arbitrable, 1234, newEvidence, {
196201
value: minRequiredDeposit,
197202
});
198203
evidenceID = ethers.solidityPackedKeccak256(["uint", "string"], [1234, newEvidence]);

0 commit comments

Comments
 (0)