-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathoptimisticOracleV3.ts
More file actions
112 lines (92 loc) · 3.9 KB
/
optimisticOracleV3.ts
File metadata and controls
112 lines (92 loc) · 3.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
import {
AssertionDisputed,
AssertionMade,
AssertionSettled,
} from "../../generated/OptimisticOracleV3/OptimisticOracleV3";
import { getAssertionId, getOrCreateAssertion } from "../utils/helpers";
import { log } from "@graphprotocol/graph-ts";
// - event: AssertionMade(indexed bytes32,bytes32,bytes,indexed address,address,indexed address,address,uint64,address,uint256)
// handler: handleAssertionMade
// event AssertionMade(
// bytes32 indexed assertionId,
// bytes32 domainId,
// bytes claim,
// address indexed asserter,
// address callbackRecipient,
// address indexed escalationManager,
// address caller,
// uint64 expirationTime,
// IERC20 currency,
// uint256 bond
// );
export function handleAssertionMade(event: AssertionMade): void {
log.warning(`Assertion params: {},{},{}`, [
event.params.assertionId.toHexString(),
event.params.domainId.toHexString(),
event.params.claim.toHexString(),
]);
let assertionId = getAssertionId(event.params.assertionId);
let assertion = getOrCreateAssertion(assertionId);
assertion.assertionId = event.params.assertionId.toHexString();
assertion.domainId = event.params.domainId.toHexString();
assertion.claim = event.params.claim.toHexString();
assertion.asserter = event.params.asserter;
assertion.callbackRecipient = event.params.callbackRecipient;
assertion.escalationManager = event.params.escalationManager;
assertion.caller = event.params.caller;
assertion.expirationTime = event.params.expirationTime;
assertion.currency = event.params.currency;
assertion.bond = event.params.bond;
assertion.identifier = event.params.identifier.toHexString();
assertion.assertionTimestamp = event.block.timestamp;
assertion.assertionBlockNumber = event.block.number;
assertion.assertionHash = event.transaction.hash;
assertion.assertionLogIndex = event.logIndex;
assertion.lastUpdated = event.block.timestamp;
assertion.save();
}
// - event: AssertionDisputed(indexed bytes32,indexed address,indexed address)
// handler: handleAssertionDisputed
// event AssertionDisputed(bytes32 indexed assertionId, address indexed caller, address indexed disputer)
export function handleAssertionDisputed(event: AssertionDisputed): void {
log.warning(`Assertion disputed params: {},{},{}`, [
event.params.assertionId.toHexString(),
event.params.caller.toHexString(),
event.params.disputer.toHexString(),
]);
let assertionId = getAssertionId(event.params.assertionId);
let assertion = getOrCreateAssertion(assertionId);
assertion.disputer = event.params.disputer;
assertion.disputeTimestamp = event.block.timestamp;
assertion.disputeBlockNumber = event.block.number;
assertion.disputeLogIndex = event.logIndex;
assertion.disputeHash = event.transaction.hash;
assertion.lastUpdated = event.block.timestamp;
assertion.save();
}
// - event: AssertionSettled(indexed bytes32,indexed address,bool,bool,address)
// handler: handleAssertionSettled
// event AssertionSettled(
// bytes32 indexed assertionId,
// address indexed bondRecipient,
// bool disputed,
// bool settlementResolution,
// address settleCaller
// );
export function handleAssertionSettled(event: AssertionSettled): void {
log.warning(`Assertion settled params: {},{},{}`, [
event.params.assertionId.toHexString(),
event.params.settlementResolution.toString(),
event.params.settleCaller.toHexString(),
]);
let assertionId = getAssertionId(event.params.assertionId);
let assertion = getOrCreateAssertion(assertionId);
assertion.settlementRecipient = event.params.bondRecipient;
assertion.settlementResolution = event.params.settlementResolution;
assertion.settlementTimestamp = event.block.timestamp;
assertion.settlementBlockNumber = event.block.number;
assertion.settlementLogIndex = event.logIndex;
assertion.settlementHash = event.transaction.hash;
assertion.lastUpdated = event.block.timestamp;
assertion.save();
}