From f326325ae18ec665639436d5c3b79aa9a2f227dd Mon Sep 17 00:00:00 2001 From: jaybuidl Date: Fri, 27 Jan 2023 16:42:13 +0000 Subject: [PATCH 1/2] feat: added ruling event on the arbitrator side to help with subgraph indexing --- contracts/src/arbitration/IArbitrator.sol | 8 ++++++++ contracts/src/arbitration/KlerosCore.sol | 1 + 2 files changed, 9 insertions(+) diff --git a/contracts/src/arbitration/IArbitrator.sol b/contracts/src/arbitration/IArbitrator.sol index 6d4e3953a..cc8abd1d9 100644 --- a/contracts/src/arbitration/IArbitrator.sol +++ b/contracts/src/arbitration/IArbitrator.sol @@ -21,6 +21,14 @@ interface IArbitrator { */ event DisputeCreation(uint256 indexed _disputeID, IArbitrable indexed _arbitrable); + /** + * @dev To be raised when a ruling is given. + * @param _arbitrable The arbitrable receiving the ruling. + * @param _disputeID ID of the dispute in the Arbitrator contract. + * @param _ruling The ruling which was given. + */ + event Ruling(IArbitrable indexed _arbitrable, uint256 indexed _disputeID, uint256 _ruling); + /** * @dev Create a dispute. Must be called by the arbitrable contract. * Must pay at least arbitrationCost(_extraData). diff --git a/contracts/src/arbitration/KlerosCore.sol b/contracts/src/arbitration/KlerosCore.sol index 747235db4..e62f7d1c7 100644 --- a/contracts/src/arbitration/KlerosCore.sol +++ b/contracts/src/arbitration/KlerosCore.sol @@ -866,6 +866,7 @@ contract KlerosCore is IArbitrator { (uint256 winningChoice, , ) = currentRuling(_disputeID); dispute.ruled = true; + emit Ruling(dispute.arbitrated, _disputeID, winningChoice); dispute.arbitrated.rule(_disputeID, winningChoice); } From 20a5eb68a887e4660a5549c84278ce33305bf5e1 Mon Sep 17 00:00:00 2001 From: jaybuidl Date: Fri, 27 Jan 2023 17:10:52 +0000 Subject: [PATCH 2/2] test: expecting a ruling event emitted by KlerosCore --- contracts/test/integration/index.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/contracts/test/integration/index.ts b/contracts/test/integration/index.ts index a36bf95ee..e609beedf 100644 --- a/contracts/test/integration/index.ts +++ b/contracts/test/integration/index.ts @@ -65,7 +65,7 @@ describe("Integration tests", async () => { homeGateway = (await ethers.getContract("HomeGatewayToEthereum")) as HomeGatewayToEthereum; }); - it("Honest Claim - No Challenge - Bridger paid", async () => { + it("Resolves a dispute on the home chain with no appeal", async () => { const arbitrationCost = ONE_TENTH_ETH.mul(3); const [bridger, challenger, relayer] = await ethers.getSigners(); @@ -170,7 +170,8 @@ describe("Integration tests", async () => { const tx4 = await core.executeRuling(0); console.log("Ruling executed on KlerosCore"); - expect(tx4).to.emit(arbitrable, "Ruling").withArgs(foreignGateway.address, 1, 0); + expect(tx4).to.emit(core, "Ruling").withArgs(homeGateway.address, 0, 0); + expect(tx4).to.emit(arbitrable, "Ruling").withArgs(foreignGateway.address, 1, 0); // The ForeignGateway starts counting disputeID from 1. }); async function mineBlocks(n) {