Skip to content

Commit f370669

Browse files
committed
fix(subgraph): handle-batched-disputes-request-events
1 parent 349783f commit f370669

File tree

2 files changed

+29
-3
lines changed

2 files changed

+29
-3
lines changed

subgraph/core/src/entities/Dispute.ts

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,36 @@ export const updateDisputeRequestData = (event: DisputeCreation): void => {
5757
if (!receipt) return;
5858

5959
const logs = receipt.logs;
60+
const coreDisputeId = event.params._disputeID;
6061

6162
// note that the topic at 0th index is always the event signature
62-
const disputeRequestEventIndex = logs.findIndex((log) => log.topics[0] == DisputeRequestSignature);
63-
const crossChainDisputeEventIndex = logs.findIndex((log) => log.topics[0] == CrossChainDisputeIncomingSignature);
63+
// For DisputeRequestSignature
64+
let disputeRequestEventIndex = -1;
65+
for (let i = 0; i < logs.length; i++) {
66+
let log = logs[i];
67+
if (log.topics.length > 2 && log.topics[0] == DisputeRequestSignature) {
68+
// 3rd indexed argument in event is _arbitratorDisputeId
69+
let decodedId = ethereum.decode("uint256", log.topics[2]);
70+
if (decodedId != null && coreDisputeId.equals(decodedId.toBigInt())) {
71+
disputeRequestEventIndex = i;
72+
break;
73+
}
74+
}
75+
}
76+
77+
// For CrossChainDisputeIncomingSignature
78+
let crossChainDisputeEventIndex = -1;
79+
for (let i = 0; i < logs.length; i++) {
80+
let log = logs[i];
81+
if (log.topics.length > 3 && log.topics[0] == CrossChainDisputeIncomingSignature) {
82+
// 4th indexed argument in event is _arbitratorDisputeId
83+
let decodedId = ethereum.decode("uint256", log.topics[3]);
84+
if (decodedId != null && coreDisputeId.equals(decodedId.toBigInt())) {
85+
crossChainDisputeEventIndex = i;
86+
break;
87+
}
88+
}
89+
}
6490

6591
if (crossChainDisputeEventIndex !== -1) {
6692
const crossChainDisputeEvent = logs[crossChainDisputeEventIndex];

subgraph/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@kleros/kleros-v2-subgraph",
3-
"version": "0.15.2",
3+
"version": "0.15.3",
44
"drtVersion": "0.12.0",
55
"license": "MIT",
66
"scripts": {

0 commit comments

Comments
 (0)