@reality.eth/graph 0.4.1 → 0.4.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/changelog.txt ADDED
@@ -0,0 +1,3 @@
1
+ Breaking changes
2
+
3
+ 2022-01-29: Question templateId replaced with template
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@reality.eth/graph",
3
- "version": "0.4.1",
3
+ "version": "0.4.4",
4
4
  "scripts": {
5
5
  "create-local": "graph create realityeth/realityeth --node http://127.0.0.1:8020",
6
6
  "remove-local": "graph remove realityeth/realityeth --node http://127.0.0.1:8020",
@@ -13,16 +13,18 @@
13
13
  "deploy:bsc": "yarn prepare:bsc && graph deploy --ipfs https://api.thegraph.com/ipfs/ --node https://api.thegraph.com/deploy/ realityeth/realityeth-bsc",
14
14
  "deploy:kovan": "yarn prepare:kovan && graph deploy --ipfs https://api.thegraph.com/ipfs/ --node https://api.thegraph.com/deploy/ realityeth/realityeth-kovan",
15
15
  "deploy:mainnet": "yarn prepare:mainnet && graph deploy --ipfs https://api.thegraph.com/ipfs/ --node https://api.thegraph.com/deploy/ realityeth/realityeth",
16
+ "deploy:optimism": "yarn prepare:optimism && graph deploy --ipfs https://api.thegraph.com/ipfs/ --node https://api.thegraph.com/deploy/ realityeth/realityeth-optimism",
16
17
  "deploy:polygon": "yarn prepare:polygon && graph deploy --ipfs https://api.thegraph.com/ipfs/ --node https://api.thegraph.com/deploy/ realityeth/realityeth-polygon",
17
18
  "deploy:rinkeby": "yarn prepare:rinkeby && graph deploy --ipfs https://api.thegraph.com/ipfs/ --node https://api.thegraph.com/deploy/ realityeth/realityeth-rinkeby",
18
19
  "deploy:sokol": "yarn prepare:sokol && graph deploy --ipfs https://api.thegraph.com/ipfs/ --node https://api.thegraph.com/deploy/ realityeth/realityeth-sokol",
19
20
  "deploy:xdai": "yarn prepare:xdai && graph deploy --ipfs https://api.thegraph.com/ipfs/ --node https://api.thegraph.com/deploy/ realityeth/realityeth-xdai",
20
- "deploy:all": "yarn deploy:ava && yarn deploy:bsc && yarn deploy:kovan && yarn deploy::mainnet && yarn deploy:mainnet && yarn deploy:polygon && yarn deploy:rinkeby && yarn deploy:sokol && yarn deploy:xdai",
21
+ "deploy:all": "yarn deploy:arbitrum && yarn deploy:ava && yarn deploy:bsc && yarn deploy:kovan && yarn deploy:mainnet && yarn deploy:mainnet && yarn deploy:optimism && yarn deploy:polygon && yarn deploy:rinkeby && yarn deploy:sokol && yarn deploy:xdai",
21
22
  "prepare:arbitrum": "yarn clean && node render-templates.js 42161 && graph codegen",
22
23
  "prepare:ava": "yarn clean && node render-templates.js 43114 && graph codegen",
23
24
  "prepare:bsc": "yarn clean && node render-templates.js 56 && graph codegen",
24
25
  "prepare:kovan": "yarn clean && node render-templates.js 42 && graph codegen",
25
26
  "prepare:mainnet": "yarn clean && node render-templates.js 1 && graph codegen",
27
+ "prepare:optimism": "yarn clean && node render-templates.js 10 && graph codegen",
26
28
  "prepare:polygon": "yarn clean && node render-templates.js 137 && graph codegen",
27
29
  "prepare:rinkeby": "yarn clean && node render-templates.js 4 && graph codegen",
28
30
  "prepare:sokol": "yarn clean && node render-templates.js 77 && graph codegen",
@@ -38,11 +40,11 @@
38
40
  "@graphprotocol/graph-ts": "^0.20.0"
39
41
  },
40
42
  "dependencies": {
41
- "@reality.eth/contracts": "^3.0.1",
43
+ "@reality.eth/contracts": "^3.0.4",
42
44
  "babel-polyfill": "^6.26.0",
43
45
  "babel-register": "^6.26.0",
44
46
  "mustache": "^4.2.0",
45
47
  "truffle-hdwallet-provider": "^1.0.4"
46
48
  },
47
- "gitHead": "ec3439b604fe5fc18f20ad26cb30f2e511629a71"
49
+ "gitHead": "585f419ceedf800c2f6bfed357f31bb7fbb3bbcc"
48
50
  }
package/schema.graphql CHANGED
@@ -7,8 +7,8 @@ type _Schema_
7
7
  {
8
8
  entity: "Question",
9
9
  fields: [
10
- { name: "q_title" },
11
- { name: "q_category" }
10
+ { name: "qTitle" },
11
+ { name: "qCategory" }
12
12
  ]
13
13
  }
14
14
  ]
@@ -21,16 +21,20 @@ type Question @entity {
21
21
 
22
22
  createdBlock: BigInt!
23
23
  createdTimestamp: BigInt!
24
+ updatedBlock: BigInt!
25
+ updatedTimestamp: BigInt!
26
+
27
+ template: Template
24
28
 
25
- templateId: BigInt!
26
29
  data: String!
27
- json_str: String
28
30
 
29
- q_title: String
30
- q_category: String
31
- q_lang: String
32
- q_type: String
31
+ qJsonStr: String
32
+ qTitle: String
33
+ qCategory: String
34
+ qLang: String
35
+ qType: String
33
36
 
37
+ user: Bytes!
34
38
  arbitrator: Bytes!
35
39
  openingTimestamp: BigInt!
36
40
  timeout: BigInt!
@@ -41,6 +45,10 @@ type Question @entity {
41
45
  currentAnswerBond: BigInt!
42
46
  currentAnswerTimestamp: BigInt
43
47
 
48
+ contentHash: Bytes
49
+ historyHash: Bytes
50
+
51
+ minBond: BigInt!
44
52
  lastBond: BigInt!
45
53
  cumulativeBonds: BigInt!
46
54
 
@@ -51,6 +59,8 @@ type Question @entity {
51
59
  answerFinalizedTimestamp: BigInt
52
60
 
53
61
  currentScheduledFinalizationTimestamp: BigInt!
62
+ reopens: Question
63
+ reopenedBy: Question
54
64
 
55
65
  outcomes: [Outcome!] @derivedFrom(field: "question")
56
66
  answers: [Answer!] @derivedFrom(field: "question")
@@ -71,8 +81,11 @@ type Response @entity {
71
81
  isCommitment: Boolean!
72
82
  commitmentId: Bytes
73
83
  bond: BigInt!
74
- answerer: Bytes!
84
+ user: Bytes!
85
+ historyHash: Bytes!
75
86
  question: Question!
87
+ createdBlock: BigInt!
88
+ revealedBlock: BigInt
76
89
  }
77
90
 
78
91
  type Answer @entity {
@@ -82,6 +95,7 @@ type Answer @entity {
82
95
  lastBond: BigInt!
83
96
  bondAggregate: BigInt!
84
97
  question: Question!
98
+ createdBlock: BigInt!
85
99
  }
86
100
 
87
101
  type Category @entity {
@@ -93,6 +107,46 @@ type Category @entity {
93
107
 
94
108
  type Template @entity {
95
109
  id: ID!
110
+ templateId: BigInt!
111
+ contract: Bytes!
96
112
  user: Bytes!
97
- question_text: String
113
+ questionText: String
114
+ createdBlock: BigInt!
115
+ }
116
+
117
+ type Claim @entity {
118
+ id: ID!
119
+ question: Question!
120
+ user: Bytes!
121
+ amount: BigInt!
122
+ createdBlock: BigInt!
123
+ }
124
+
125
+ type Fund @entity {
126
+ id: ID!
127
+ question: Question!
128
+ user: Bytes!
129
+ amount: BigInt!
130
+ createdBlock: BigInt!
131
+ }
132
+
133
+ type Withdrawal @entity {
134
+ id: ID!
135
+ user: Bytes!
136
+ amount: BigInt!
137
+ createdBlock: BigInt!
138
+ }
139
+
140
+ type UserAction @entity {
141
+ id: ID!
142
+ actionType: String!
143
+ user: Bytes!
144
+ question: Question
145
+ response: Response
146
+ claim: Claim
147
+ withdrawal: Withdrawal
148
+ fund: Fund
149
+ template: Template
150
+ createdBlock: BigInt!
151
+ createdTimestamp: BigInt!
98
152
  }
package/src/mapping.ts CHANGED
@@ -11,23 +11,44 @@ import {
11
11
  Answer,
12
12
  Category,
13
13
  Template,
14
+ Claim,
15
+ Withdrawal,
16
+ Fund,
17
+ UserAction,
14
18
  } from '../generated/schema'
15
19
 
16
20
  import {
21
+ RealityETH,
17
22
  LogNewTemplate,
18
23
  LogNewQuestion,
19
24
  LogNewAnswer,
20
25
  LogNotifyOfArbitrationRequest,
21
26
  LogFinalize,
22
27
  LogAnswerReveal,
23
- LogFundAnswerBounty
28
+ LogFundAnswerBounty,
29
+ LogClaim,
30
+ LogWithdraw,
31
+ LogMinimumBond,
32
+ LogReopenQuestion
24
33
  } from '../generated/RealityETH/RealityETH'
25
34
 
26
35
  export function handleNewTemplate(event: LogNewTemplate): void {
27
- let tmpl = new Template(event.params.template_id.toHexString());
36
+ let contractTemplateId = event.address.toHexString() + '-' + event.params.template_id.toHexString();
37
+ let tmpl = new Template(contractTemplateId);
38
+ tmpl.templateId = event.params.template_id;
39
+ tmpl.contract = event.address;
28
40
  tmpl.user = event.params.user;
29
- tmpl.question_text = event.params.question_text;
41
+ tmpl.questionText = event.params.question_text;
42
+ tmpl.createdBlock = event.block.number;
30
43
  tmpl.save()
44
+
45
+ let ua = new UserAction(event.transaction.hash.toHex() + "-" + event.logIndex.toString());
46
+ ua.actionType = 'CreateTemplate';
47
+ ua.user = event.params.user;
48
+ ua.template = contractTemplateId;
49
+ ua.createdBlock = event.block.number;
50
+ ua.createdTimestamp = event.block.timestamp;
51
+ ua.save();
31
52
  }
32
53
 
33
54
  export function handleNewQuestion(event: LogNewQuestion): void {
@@ -36,41 +57,39 @@ export function handleNewQuestion(event: LogNewQuestion): void {
36
57
  let question = new Question(contractQuestionId);
37
58
  question.questionId = event.params.question_id;
38
59
 
39
- let templateId = event.params.template_id
40
- let templateIdI32 = templateId.toI32();
60
+ let contractTemplateId = event.address.toHexString() + '-' + event.params.template_id.toHexString();
61
+ let tmpl = Template.load(contractTemplateId);
62
+ question.template = contractTemplateId;
41
63
 
42
- let tmpl = Template.load(templateId.toHexString());
43
- let question_text = tmpl.question_text;
64
+ let questionText = tmpl.questionText;
44
65
 
45
66
  let data = event.params.question;
46
67
  let fields = data.split('\u241f');
47
68
 
48
- let json_str = sprintf(question_text, fields)
49
-
50
- question.templateId = templateId;
69
+ let qJsonStr = sprintf(questionText, fields)
51
70
 
52
- let tryData = json.try_fromBytes(ByteArray.fromUTF8(json_str) as Bytes)
71
+ let tryData = json.try_fromBytes(ByteArray.fromUTF8(qJsonStr) as Bytes)
53
72
  if (tryData.isOk) {
54
73
  let json_dict = tryData.value.toObject()
55
74
 
56
- let q_title = json_dict.get('title')
57
- if (q_title != null && q_title.kind === JSONValueKind.STRING) {
58
- question.q_title = q_title.toString()
75
+ let qTitle = json_dict.get('title')
76
+ if (qTitle != null && qTitle.kind === JSONValueKind.STRING) {
77
+ question.qTitle = qTitle.toString()
59
78
  }
60
79
 
61
- let q_category = json_dict.get('category')
62
- if (q_category != null && q_category.kind == JSONValueKind.STRING) {
63
- question.q_category = q_category.toString();
80
+ let qCategory = json_dict.get('category')
81
+ if (qCategory != null && qCategory.kind == JSONValueKind.STRING) {
82
+ question.qCategory = qCategory.toString();
64
83
  }
65
84
 
66
- let q_lang = json_dict.get('lang')
67
- if (q_lang != null && q_lang.kind == JSONValueKind.STRING) {
68
- question.q_lang = q_lang.toString();
85
+ let qLang = json_dict.get('lang')
86
+ if (qLang != null && qLang.kind == JSONValueKind.STRING) {
87
+ question.qLang = qLang.toString();
69
88
  }
70
89
 
71
- let q_type = json_dict.get('type')
72
- if (q_type != null && q_type.kind == JSONValueKind.STRING) {
73
- question.q_type = q_type.toString();
90
+ let qType = json_dict.get('type')
91
+ if (qType != null && qType.kind == JSONValueKind.STRING) {
92
+ question.qType = qType.toString();
74
93
  }
75
94
 
76
95
  let q_outcomes_val = json_dict.get('outcomes')
@@ -91,11 +110,16 @@ export function handleNewQuestion(event: LogNewQuestion): void {
91
110
  question.contract = contract;
92
111
 
93
112
  question.data = data
94
- question.json_str = json_str
113
+ question.contentHash = event.params.content_hash;
114
+
115
+ question.qJsonStr = qJsonStr
95
116
 
96
117
  question.createdBlock = event.block.number;
97
118
  question.createdTimestamp = event.params.created;
119
+ question.updatedBlock = event.block.number;
120
+ question.updatedTimestamp = event.block.timestamp;
98
121
 
122
+ question.user = event.params.user;
99
123
  question.arbitrator = event.params.arbitrator;
100
124
  question.openingTimestamp = event.params.opening_ts;
101
125
  question.timeout = event.params.timeout;
@@ -107,12 +131,27 @@ export function handleNewQuestion(event: LogNewQuestion): void {
107
131
  question.lastBond = new BigInt(0);
108
132
  question.cumulativeBonds = new BigInt(0);
109
133
 
134
+ question.minBond = new BigInt(0);
135
+
110
136
  question.currentScheduledFinalizationTimestamp = BigInt.fromI32(I32.MAX_VALUE);
111
137
 
112
- // TODO: This may theoretically be wrong if the arbitrator snaffled part of the transaction value
113
- question.bounty = event.transaction.value;
138
+ // In version 3 and above the bounty should be picked up by the LogFundAnswerBounty event.
139
+ // In version 2 this isn't fired on question create.
140
+ // We could handle this with a call but this would mean we'd need an archive node to index.
141
+ // Instead, make sure we do a call in the UI for the current bounty when using the v2 contract.
142
+ // This shouldn't matter much as neither v2 nor the bounty feature is used much.
143
+ question.bounty = new BigInt(0);
114
144
 
115
145
  question.save();
146
+
147
+ let ua = new UserAction(event.transaction.hash.toHex() + "-" + event.logIndex.toString());
148
+ ua.actionType = 'AskQuestion';
149
+ ua.user = event.params.user;
150
+ ua.question = contractQuestionId;
151
+ ua.createdBlock = event.block.number;
152
+ ua.createdTimestamp = event.block.timestamp;
153
+ ua.save();
154
+
116
155
  }
117
156
 
118
157
  export function handleNewAnswer(event: LogNewAnswer): void {
@@ -130,6 +169,7 @@ export function handleNewAnswer(event: LogNewAnswer): void {
130
169
  let responseId = contractQuestionId + '-' + event.params.bond.toHexString();
131
170
  let response = new Response(responseId);
132
171
  response.question = contractQuestionId;
172
+ response.createdBlock = event.block.number;
133
173
  if (isCommitment) {
134
174
  response.commitmentId = event.params.answer;
135
175
  response.isUnrevealed = true;
@@ -138,13 +178,19 @@ export function handleNewAnswer(event: LogNewAnswer): void {
138
178
  response.isUnrevealed = false;
139
179
  }
140
180
  response.bond = event.params.bond;
141
- response.answerer = event.params.user;
181
+ response.user = event.params.user;
142
182
  response.timestamp = event.params.ts;
143
183
  response.isCommitment = isCommitment;
184
+ response.historyHash = event.params.history_hash;
144
185
  response.save();
145
186
 
146
187
  if (!isCommitment) {
147
- saveAnswer(contractQuestionId, event.params.answer, event.params.bond, event.params.ts);
188
+ saveAnswer(contractQuestionId, event.params.answer, event.params.bond, event.params.ts, event.block.number);
189
+ if (event.params.bond > question.lastBond) {
190
+ question.currentAnswer = event.params.answer;
191
+ question.currentAnswerBond = event.params.bond;
192
+ question.currentAnswerTimestamp = event.params.ts;
193
+ }
148
194
  }
149
195
  // response.bondAggregate = response.bondAggregate.plus(bond);
150
196
 
@@ -156,11 +202,24 @@ export function handleNewAnswer(event: LogNewAnswer): void {
156
202
  question.answerFinalizedTimestamp = question.arbitrationOccurred ? ts : ts.plus(question.timeout);
157
203
  question.currentScheduledFinalizationTimestamp = question.arbitrationOccurred ? ts : ts.plus(question.timeout);
158
204
 
205
+ question.historyHash = event.params.history_hash;
159
206
  question.lastBond = event.params.bond;
160
207
  question.cumulativeBonds = question.cumulativeBonds.plus(event.params.bond);
161
208
 
209
+ question.updatedBlock = event.block.number;
210
+ question.updatedTimestamp = event.block.timestamp;
211
+
162
212
  question.save();
163
213
 
214
+ let ua = new UserAction(event.transaction.hash.toHex() + "-" + event.logIndex.toString());
215
+ ua.actionType = 'AnswerQuestion';
216
+ ua.user = event.params.user;
217
+ ua.question = contractQuestionId;
218
+ ua.response = responseId;
219
+ ua.createdBlock = event.block.number;
220
+ ua.createdTimestamp = event.block.timestamp;
221
+ ua.save();
222
+
164
223
  }
165
224
 
166
225
  export function handleAnswerReveal(event: LogAnswerReveal): void {
@@ -174,9 +233,34 @@ export function handleAnswerReveal(event: LogAnswerReveal): void {
174
233
  }
175
234
  response.answer = event.params.answer;
176
235
  response.isUnrevealed = false;
177
- // TODO: Handle question updates etc
236
+ response.revealedBlock = event.block.number;
178
237
  response.save()
179
238
 
239
+ let question = Question.load(contractQuestionId);
240
+ if (question == null) {
241
+ log.info('cannot find question {} to answer', [contractQuestionId]);
242
+ return;
243
+ }
244
+ saveAnswer(contractQuestionId, event.params.answer, event.params.bond, response.timestamp, event.block.number);
245
+
246
+ question.updatedBlock = event.block.number;
247
+ question.updatedTimestamp = event.block.timestamp;
248
+
249
+ // Update the question to the current answer, unless someone has posted a higher bond since you made the commitment
250
+ if (event.params.bond == question.lastBond) {
251
+ question.currentAnswer = event.params.answer;
252
+ }
253
+ question.save()
254
+
255
+ let ua = new UserAction(event.transaction.hash.toHex() + "-" + event.logIndex.toString());
256
+ ua.actionType = 'RevealAnswer';
257
+ ua.user = event.params.user;
258
+ ua.question = contractQuestionId;
259
+ ua.response = responseId;
260
+ ua.createdBlock = event.block.number;
261
+ ua.createdTimestamp = event.block.timestamp;
262
+ ua.save();
263
+
180
264
  //saveAnswer(question, questionId, event.params.answer, event.params.bond, event.params.ts);
181
265
 
182
266
  }
@@ -196,8 +280,18 @@ export function handleArbitrationRequest(event: LogNotifyOfArbitrationRequest):
196
280
 
197
281
  question.currentScheduledFinalizationTimestamp = BigInt.fromI32(I32.MAX_VALUE);
198
282
 
283
+ question.updatedBlock = event.block.number;
284
+ question.updatedTimestamp = event.block.timestamp;
199
285
  question.save();
200
286
 
287
+ let ua = new UserAction(event.transaction.hash.toHex() + "-" + event.logIndex.toString());
288
+ ua.actionType = 'RequestArbitration';
289
+ ua.user = event.params.user;
290
+ ua.question = contractQuestionId;
291
+ ua.createdBlock = event.block.number;
292
+ ua.createdTimestamp = event.block.timestamp;
293
+ ua.save();
294
+
201
295
  }
202
296
 
203
297
  export function handleFinalize(event: LogFinalize): void {
@@ -212,6 +306,8 @@ export function handleFinalize(event: LogFinalize): void {
212
306
  question.arbitrationOccurred = true;
213
307
  question.currentAnswer = event.params.answer;
214
308
 
309
+ question.updatedBlock = event.block.number;
310
+ question.updatedTimestamp = event.block.timestamp;
215
311
  question.save();
216
312
 
217
313
  }
@@ -224,11 +320,83 @@ export function handleFundAnswerBounty(event: LogFundAnswerBounty): void {
224
320
  return;
225
321
  }
226
322
  question.bounty = event.params.bounty;
323
+ question.updatedBlock = event.block.number;
324
+ question.updatedTimestamp = event.block.timestamp;
227
325
  question.save()
326
+
327
+ let fundId = event.transaction.hash.toHex() + "-" + event.logIndex.toString()
328
+ let fund = new Fund(fundId);
329
+ fund.question = contractQuestionId;
330
+ fund.user = event.params.user;
331
+ fund.amount = event.params.bounty_added;
332
+ fund.createdBlock = event.block.number;
333
+ fund.save()
334
+
335
+ let ua = new UserAction(event.transaction.hash.toHex() + "-" + event.logIndex.toString());
336
+ ua.actionType = 'FundAnswerBounty';
337
+ ua.user = event.params.user;
338
+ ua.createdBlock = event.block.number;
339
+ ua.createdTimestamp = event.block.timestamp;
340
+ ua.fund = fundId;
341
+ ua.question = contractQuestionId;
342
+ ua.save();
228
343
  }
229
344
 
230
- function saveAnswer(contractQuestionId: string, answer: Bytes, bond: BigInt, ts: BigInt): void {
345
+ export function handleLogClaim(event: LogClaim): void {
346
+ let claimId = event.transaction.hash.toHex() + "-" + event.logIndex.toString()
347
+ let claim = new Claim(claimId)
231
348
 
349
+ let contractQuestionId = event.address.toHexString() + '-' + event.params.question_id.toHexString();
350
+ claim.question = contractQuestionId;
351
+ claim.user = event.params.user;
352
+ claim.amount = event.params.amount;
353
+ claim.createdBlock = event.block.number;
354
+ claim.save();
355
+
356
+ let question = Question.load(contractQuestionId);
357
+ let contract = RealityETH.bind(event.address)
358
+ question.historyHash = contract.getHistoryHash(event.params.question_id);
359
+
360
+ question.updatedBlock = event.block.number;
361
+ question.updatedTimestamp = event.block.timestamp;
362
+ question.save();
363
+ }
364
+
365
+ export function handleLogWithdraw(event: LogWithdraw): void {
366
+ let withdrawalId = event.transaction.hash.toHex() + "-" + event.logIndex.toString();
367
+ let withdrawal = new Withdrawal(withdrawalId);
368
+ withdrawal.user = event.params.user;
369
+ withdrawal.amount = event.params.amount;
370
+ withdrawal.createdBlock = event.block.number;
371
+ withdrawal.save();
372
+ }
373
+
374
+ // This is done on question creation.
375
+ // To preserve the old event signatures it adds a new event
376
+ export function handleLogMinimumBond(event: LogMinimumBond): void {
377
+ let contractQuestionId = event.address.toHexString() + '-' + event.params.question_id.toHexString();
378
+ let question = Question.load(contractQuestionId);
379
+ question.minBond = event.params.min_bond;
380
+ question.save();
381
+ }
382
+
383
+ export function handleLogReopenQuestion(event: LogReopenQuestion): void {
384
+ // We'll save this in both directions for easy querying
385
+ let contractQuestionId = event.address.toHexString() + '-' + event.params.question_id.toHexString();
386
+ let reopenedContractQuestionId = event.address.toHexString() + '-' + event.params.reopened_question_id.toHexString();
387
+ let question = Question.load(contractQuestionId);
388
+ let reopenedQuestion = Question.load(reopenedContractQuestionId);
389
+ question.reopens = reopenedContractQuestionId;
390
+ question.updatedBlock = event.block.number;
391
+ question.updatedTimestamp = event.block.timestamp;
392
+ question.save();
393
+ reopenedQuestion.reopenedBy = contractQuestionId;
394
+ reopenedQuestion.updatedBlock = event.block.number;
395
+ reopenedQuestion.updatedTimestamp = event.block.timestamp;
396
+ reopenedQuestion.save();
397
+ }
398
+
399
+ function saveAnswer(contractQuestionId: string, answer: Bytes, bond: BigInt, ts: BigInt, createdBlock: BigInt): void {
232
400
  let question = Question.load(contractQuestionId);
233
401
 
234
402
  let answerId = contractQuestionId + '-' + answer.toHexString();
@@ -240,6 +408,7 @@ function saveAnswer(contractQuestionId: string, answer: Bytes, bond: BigInt, ts:
240
408
  answerEntity.bondAggregate = bond;
241
409
  answerEntity.lastBond = bond;
242
410
  answerEntity.timestamp = ts;
411
+ answerEntity.createdBlock = createdBlock;
243
412
  answerEntity.save();
244
413
  } else {
245
414
  answerEntity.bondAggregate = answerEntity.bondAggregate.plus(bond);
@@ -249,16 +418,5 @@ function saveAnswer(contractQuestionId: string, answer: Bytes, bond: BigInt, ts:
249
418
  }
250
419
  answerEntity.save();
251
420
  }
252
-
253
- let answerFinalizedTimestamp = question.arbitrationOccurred ? ts : ts.plus(question.timeout);
254
-
255
- if (bond > question.lastBond) {
256
- question.currentAnswer = answer;
257
- question.currentAnswerBond = bond;
258
- question.currentAnswerTimestamp = ts;
259
- question.answerFinalizedTimestamp = answerFinalizedTimestamp;
260
- }
261
-
262
- question.save();
263
421
  }
264
422
 
@@ -13,7 +13,7 @@
13
13
  - Question
14
14
  abis:
15
15
  - name: RealityETH
16
- file: ./node_modules/@reality.eth/contracts/abi/solc-0.4.25/RealityETH-all.abi.json
16
+ file: ./node_modules/@reality.eth/contracts/abi/solc-0.8.6/RealityETH-all.abi.json
17
17
  eventHandlers:
18
18
  - event: LogNewTemplate(indexed uint256,indexed address,string)
19
19
  handler: handleNewTemplate
@@ -29,4 +29,12 @@
29
29
  handler: handleFinalize
30
30
  - event: LogFundAnswerBounty(indexed bytes32,uint256,uint256,indexed address)
31
31
  handler: handleFundAnswerBounty
32
+ - event: LogClaim(indexed bytes32,indexed address,uint256)
33
+ handler: handleLogClaim
34
+ - event: LogWithdraw(indexed address,uint256)
35
+ handler: handleLogWithdraw
36
+ - event: LogMinimumBond(indexed bytes32,uint256)
37
+ handler: handleLogMinimumBond
38
+ - event: LogReopenQuestion(indexed bytes32,indexed bytes32)
39
+ handler: handleLogReopenQuestion
32
40
  file: ./src/mapping.ts