Skip to content

Commit 50a5f0a

Browse files
authored
Merge pull request #420 from kleros/feat/verification-started-event-handler
Feat/verification started event handler & renamed var taken
2 parents a169262 + 22fdfb6 commit 50a5f0a

File tree

19 files changed

+245
-170
lines changed

19 files changed

+245
-170
lines changed

relayer-subgraph-inbox/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@kleros/vea-relayer-subgraph-inbox",
3-
"version": "0.2.3",
3+
"version": "0.2.4",
44
"license": "MIT",
55
"engines": {
66
"node": ">=18.0.0"

relayer-subgraph-inbox/subgraph.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,9 @@ dataSources:
3232
name: VeaInboxArbToEthTestnet
3333
network: arbitrum-sepolia
3434
source:
35-
address: "0xE12daFE59Bc3A996362d54b37DFd2BA9279cAd06"
35+
address: "0xAA4F00c86bf956C0Fae603D030CBc2dA7f8B7C5B"
3636
abi: VeaInboxArbToEthTestnet
37-
startBlock: 77452741
37+
startBlock: 139057282
3838
mapping:
3939
kind: ethereum/events
4040
apiVersion: 0.0.7
@@ -88,9 +88,9 @@ dataSources:
8888
name: VeaInboxArbToGnosisTestnet
8989
network: arbitrum-sepolia
9090
source:
91-
address: "0x62403e9Fbac618301175C89fb21920e4FF235A6a"
91+
address: "0xa0d410b202D69C36871d5135ce42fC7D379BBB1c"
9292
abi: VeaInboxArbToGnosisTestnet
93-
startBlock: 129094170
93+
startBlock: 139057386
9494
mapping:
9595
kind: ethereum/events
9696
apiVersion: 0.0.7

veascan-subgraph-inbox/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@kleros/veascan-subgraph-inbox",
3-
"version": "0.2.1",
3+
"version": "0.2.3",
44
"license": "MIT",
55
"engines": {
66
"node": ">=18.0.0"

veascan-subgraph-inbox/schema.graphql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ type Snapshot @entity {
3434
stateRootString: String
3535
messages: [Message!]! @derivedFrom(field: "snapshot")
3636
numberMessages: BigInt!
37-
taken: Boolean!
37+
saved: Boolean!
3838
resolving: Boolean!
3939
fallback: [Fallback!]! @derivedFrom(field: "snapshot")
4040
}

veascan-subgraph-inbox/src/VeaInbox.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ function getCurrentSnapshot(inboxAddress: Address): Snapshot {
6161
const snapshot = new Snapshot(snapshotId);
6262
snapshot.inbox = inboxAddress;
6363
snapshot.numberMessages = BigInt.fromI32(0);
64-
snapshot.taken = false;
64+
snapshot.saved = false;
6565
snapshot.resolving = false;
6666
snapshot.epoch = BigInt.fromI32(0);
6767
snapshot.epochString = "0";
@@ -84,7 +84,7 @@ function getCurrentSnapshot(inboxAddress: Address): Snapshot {
8484
);
8585
snapshot.inbox = inboxAddress;
8686
snapshot.numberMessages = BigInt.fromI32(0);
87-
snapshot.taken = false;
87+
snapshot.saved = false;
8888
snapshot.resolving = false;
8989
snapshot.epoch = BigInt.fromI32(0);
9090
snapshot.epochString = "0";
@@ -127,7 +127,7 @@ export function handleSnapshotSaved(event: SnapshotSaved): void {
127127
const epoch = event.block.timestamp.div(epochPeriod);
128128
const stateRoot = contract.snapshots(epoch);
129129
const currentSnapshot = getCurrentSnapshot(event.address);
130-
currentSnapshot.taken = true;
130+
currentSnapshot.saved = true;
131131
currentSnapshot.caller = event.transaction.from;
132132
currentSnapshot.stateRoot = stateRoot;
133133
currentSnapshot.stateRootString = stateRoot.toHexString();
@@ -147,7 +147,7 @@ export function handleSnapshotSaved(event: SnapshotSaved): void {
147147
const newSnapshot = new Snapshot(snapshotId);
148148
newSnapshot.inbox = event.address;
149149
newSnapshot.numberMessages = BigInt.fromI32(0);
150-
newSnapshot.taken = false;
150+
newSnapshot.saved = false;
151151
newSnapshot.resolving = false;
152152
newSnapshot.save();
153153

@@ -204,7 +204,7 @@ export function handleSnapshotSent(event: SnapshotSent): void {
204204
const inbox = VeaInboxArbToEthDevnet.bind(event.address);
205205

206206
let currentSnapshot = getCurrentSnapshot(event.address);
207-
currentSnapshot.taken = false;
207+
currentSnapshot.saved = false;
208208
currentSnapshot.resolving = true;
209209
currentSnapshot.timestamp = epochSent.times(inbox.epochPeriod());
210210
currentSnapshot.stateRoot = Bytes.fromHexString(
@@ -225,7 +225,7 @@ export function handleSnapshotSent(event: SnapshotSent): void {
225225
const newSnapshot = new Snapshot(newSnapshotId);
226226
newSnapshot.inbox = event.address;
227227
newSnapshot.numberMessages = BigInt.fromI32(0);
228-
newSnapshot.taken = false;
228+
newSnapshot.saved = false;
229229
newSnapshot.resolving = false;
230230
// Initialize new snapshot fields with defaults.
231231
newSnapshot.epoch = BigInt.fromI32(0);

veascan-subgraph-inbox/subgraph.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ dataSources:
88
name: VeaInboxArbToEthTestnet
99
network: arbitrum-sepolia
1010
source:
11-
address: "0xE12daFE59Bc3A996362d54b37DFd2BA9279cAd06"
11+
address: "0xAA4F00c86bf956C0Fae603D030CBc2dA7f8B7C5B"
1212
abi: VeaInboxArbToEthTestnet
13-
startBlock: 77452741
13+
startBlock: 139057282
1414
mapping:
1515
kind: ethereum/events
1616
apiVersion: 0.0.7

veascan-subgraph-outbox/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@kleros/veascan-subgraph-outbox",
3-
"version": "0.2.3",
3+
"version": "0.2.4",
44
"license": "MIT",
55
"engines": {
66
"node": ">=18.0.0"

veascan-subgraph-outbox/schema.graphql

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,12 @@ type Challenge @entity {
3030
type Verification @entity {
3131
id: ID!
3232
claim: Claim!
33-
timestamp: BigInt!
34-
caller: Bytes! # address
35-
txHash: Bytes!
33+
startTimestamp: BigInt
34+
startCaller: Bytes # address
35+
startTxHash: Bytes
36+
verifiedTimestamp: BigInt
37+
verifiedCaller: Bytes # address
38+
verifiedTxHash: Bytes
3639
}
3740

3841
type Message @entity {

veascan-subgraph-outbox/src/VeaOutbox.ts

Lines changed: 31 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import {
44
Claimed,
55
MessageRelayed,
66
Verified,
7+
VerificationStarted,
78
} from "../generated/VeaOutboxArbToEthDevnet/VeaOutboxArbToEthDevnet";
89
import {
910
Challenge,
@@ -68,6 +69,27 @@ export function handleChallenged(event: Challenged): void {
6869
}
6970
}
7071

72+
export function handleVerificationStarted(event: VerificationStarted): void {
73+
const ref = getRef(event.address);
74+
for (
75+
let i = ref.totalClaims.minus(BigInt.fromI32(1));
76+
i.ge(BigInt.fromI32(0));
77+
i = i.minus(BigInt.fromI32(1))
78+
) {
79+
const claimId = event.address.toHexString() + "-" + i.toString();
80+
const claim = Claim.load(claimId);
81+
if (claim?.epoch.equals(event.params._epoch)) {
82+
const verification = new Verification(claim.id);
83+
verification.claim = claim.id;
84+
verification.startTimestamp = event.block.timestamp;
85+
verification.startCaller = event.transaction.from;
86+
verification.startTxHash = event.transaction.hash;
87+
verification.save();
88+
break;
89+
}
90+
}
91+
}
92+
7193
export function handleVerified(event: Verified): void {
7294
const ref = getRef(event.address);
7395
for (
@@ -77,15 +99,18 @@ export function handleVerified(event: Verified): void {
7799
) {
78100
const claimId = event.address.toHexString() + "-" + i.toString();
79101
const claim = Claim.load(claimId);
80-
if (claim && claim.epoch.equals(event.params._epoch)) {
102+
if (claim?.epoch.equals(event.params._epoch)) {
81103
claim.verified = true;
82104
claim.save();
83105

84-
const verification = new Verification(claim.id);
85-
verification.claim = claim.id;
86-
verification.timestamp = event.block.timestamp;
87-
verification.caller = event.transaction.from;
88-
verification.txHash = event.transaction.hash;
106+
let verification = Verification.load(claim.id);
107+
if (!verification) {
108+
verification = new Verification(claim.id);
109+
verification.claim = claim.id;
110+
}
111+
verification.verifiedTimestamp = event.block.timestamp;
112+
verification.verifiedCaller = event.transaction.from;
113+
verification.verifiedTxHash = event.transaction.hash;
89114
verification.save();
90115
break;
91116
}

veascan-subgraph-outbox/subgraph.yaml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ dataSources:
66
name: VeaOutboxArbToEthTestnet
77
network: sepolia
88
source:
9-
address: "0x209BFdC6B7c66b63A8382196Ba3d06619d0F12c9"
9+
address: "0xC0574e973059e727E5E4bEB2e04F1D69F627faab"
1010
abi: VeaOutboxArbToEthTestnet
11-
startBlock: 6636625
11+
startBlock: 8047848
1212
mapping:
1313
kind: ethereum/events
1414
apiVersion: 0.0.7
@@ -18,6 +18,7 @@ dataSources:
1818
- Claimed
1919
- MessageRelayed
2020
- Verified
21+
- VerificationStarted
2122
abis:
2223
- name: VeaOutboxArbToEthTestnet
2324
file: ../contracts/deployments/sepolia/VeaOutboxArbToEthTestnet.json
@@ -30,6 +31,8 @@ dataSources:
3031
handler: handleMessageRelayed
3132
- event: Verified(uint256)
3233
handler: handleVerified
34+
- event: VerificationStarted(indexed uint256)
35+
handler: handleVerificationStarted
3336
file: ./src/VeaOutbox.ts
3437
- kind: ethereum
3538
name: VeaOutboxArbToEthDevnet
@@ -47,6 +50,7 @@ dataSources:
4750
- Claimed
4851
- MessageRelayed
4952
- Verified
53+
- VerificationStarted
5054
abis:
5155
- name: VeaOutboxArbToEthDevnet
5256
file: ../contracts/deployments/sepolia/VeaOutboxArbToEthDevnet.json
@@ -59,4 +63,6 @@ dataSources:
5963
handler: handleMessageRelayed
6064
- event: Verified(uint256)
6165
handler: handleVerified
66+
- event: VerificationStarted(indexed uint256)
67+
handler: handleVerificationStarted
6268
file: ./src/VeaOutbox.ts

0 commit comments

Comments
 (0)