@reality.eth/graph 0.4.2 → 0.4.3

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.2",
3
+ "version": "0.4.3",
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.2",
43
+ "@reality.eth/contracts": "^3.0.3",
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": "48b58e830b19c65a8695da37861d6d49f0f7ec26"
49
+ "gitHead": "b9fcb24ff3274a58c4f98c0c97b58c4d5c5b0fcd"
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,23 @@ 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
138
  // TODO: This may theoretically be wrong if the arbitrator snaffled part of the transaction value
113
139
  question.bounty = event.transaction.value;
114
140
 
115
141
  question.save();
142
+
143
+ let ua = new UserAction(event.transaction.hash.toHex() + "-" + event.logIndex.toString());
144
+ ua.actionType = 'AskQuestion';
145
+ ua.user = event.params.user;
146
+ ua.question = contractQuestionId;
147
+ ua.createdBlock = event.block.number;
148
+ ua.createdTimestamp = event.block.timestamp;
149
+ ua.save();
150
+
116
151
  }
117
152
 
118
153
  export function handleNewAnswer(event: LogNewAnswer): void {
@@ -130,6 +165,7 @@ export function handleNewAnswer(event: LogNewAnswer): void {
130
165
  let responseId = contractQuestionId + '-' + event.params.bond.toHexString();
131
166
  let response = new Response(responseId);
132
167
  response.question = contractQuestionId;
168
+ response.createdBlock = event.block.number;
133
169
  if (isCommitment) {
134
170
  response.commitmentId = event.params.answer;
135
171
  response.isUnrevealed = true;
@@ -138,13 +174,19 @@ export function handleNewAnswer(event: LogNewAnswer): void {
138
174
  response.isUnrevealed = false;
139
175
  }
140
176
  response.bond = event.params.bond;
141
- response.answerer = event.params.user;
177
+ response.user = event.params.user;
142
178
  response.timestamp = event.params.ts;
143
179
  response.isCommitment = isCommitment;
180
+ response.historyHash = event.params.history_hash;
144
181
  response.save();
145
182
 
146
183
  if (!isCommitment) {
147
- saveAnswer(contractQuestionId, event.params.answer, event.params.bond, event.params.ts);
184
+ saveAnswer(contractQuestionId, event.params.answer, event.params.bond, event.params.ts, event.block.number);
185
+ if (event.params.bond > question.lastBond) {
186
+ question.currentAnswer = event.params.answer;
187
+ question.currentAnswerBond = event.params.bond;
188
+ question.currentAnswerTimestamp = event.params.ts;
189
+ }
148
190
  }
149
191
  // response.bondAggregate = response.bondAggregate.plus(bond);
150
192
 
@@ -156,11 +198,24 @@ export function handleNewAnswer(event: LogNewAnswer): void {
156
198
  question.answerFinalizedTimestamp = question.arbitrationOccurred ? ts : ts.plus(question.timeout);
157
199
  question.currentScheduledFinalizationTimestamp = question.arbitrationOccurred ? ts : ts.plus(question.timeout);
158
200
 
201
+ question.historyHash = event.params.history_hash;
159
202
  question.lastBond = event.params.bond;
160
203
  question.cumulativeBonds = question.cumulativeBonds.plus(event.params.bond);
161
204
 
205
+ question.updatedBlock = event.block.number;
206
+ question.updatedTimestamp = event.block.timestamp;
207
+
162
208
  question.save();
163
209
 
210
+ let ua = new UserAction(event.transaction.hash.toHex() + "-" + event.logIndex.toString());
211
+ ua.actionType = 'AnswerQuestion';
212
+ ua.user = event.params.user;
213
+ ua.question = contractQuestionId;
214
+ ua.response = responseId;
215
+ ua.createdBlock = event.block.number;
216
+ ua.createdTimestamp = event.block.timestamp;
217
+ ua.save();
218
+
164
219
  }
165
220
 
166
221
  export function handleAnswerReveal(event: LogAnswerReveal): void {
@@ -174,9 +229,34 @@ export function handleAnswerReveal(event: LogAnswerReveal): void {
174
229
  }
175
230
  response.answer = event.params.answer;
176
231
  response.isUnrevealed = false;
177
- // TODO: Handle question updates etc
232
+ response.revealedBlock = event.block.number;
178
233
  response.save()
179
234
 
235
+ let question = Question.load(contractQuestionId);
236
+ if (question == null) {
237
+ log.info('cannot find question {} to answer', [contractQuestionId]);
238
+ return;
239
+ }
240
+ saveAnswer(contractQuestionId, event.params.answer, event.params.bond, response.timestamp, event.block.number);
241
+
242
+ question.updatedBlock = event.block.number;
243
+ question.updatedTimestamp = event.block.timestamp;
244
+
245
+ // Update the question to the current answer, unless someone has posted a higher bond since you made the commitment
246
+ if (event.params.bond == question.lastBond) {
247
+ question.currentAnswer = event.params.answer;
248
+ }
249
+ question.save()
250
+
251
+ let ua = new UserAction(event.transaction.hash.toHex() + "-" + event.logIndex.toString());
252
+ ua.actionType = 'RevealAnswer';
253
+ ua.user = event.params.user;
254
+ ua.question = contractQuestionId;
255
+ ua.response = responseId;
256
+ ua.createdBlock = event.block.number;
257
+ ua.createdTimestamp = event.block.timestamp;
258
+ ua.save();
259
+
180
260
  //saveAnswer(question, questionId, event.params.answer, event.params.bond, event.params.ts);
181
261
 
182
262
  }
@@ -196,8 +276,18 @@ export function handleArbitrationRequest(event: LogNotifyOfArbitrationRequest):
196
276
 
197
277
  question.currentScheduledFinalizationTimestamp = BigInt.fromI32(I32.MAX_VALUE);
198
278
 
279
+ question.updatedBlock = event.block.number;
280
+ question.updatedTimestamp = event.block.timestamp;
199
281
  question.save();
200
282
 
283
+ let ua = new UserAction(event.transaction.hash.toHex() + "-" + event.logIndex.toString());
284
+ ua.actionType = 'RequestArbitration';
285
+ ua.user = event.params.user;
286
+ ua.question = contractQuestionId;
287
+ ua.createdBlock = event.block.number;
288
+ ua.createdTimestamp = event.block.timestamp;
289
+ ua.save();
290
+
201
291
  }
202
292
 
203
293
  export function handleFinalize(event: LogFinalize): void {
@@ -212,6 +302,8 @@ export function handleFinalize(event: LogFinalize): void {
212
302
  question.arbitrationOccurred = true;
213
303
  question.currentAnswer = event.params.answer;
214
304
 
305
+ question.updatedBlock = event.block.number;
306
+ question.updatedTimestamp = event.block.timestamp;
215
307
  question.save();
216
308
 
217
309
  }
@@ -224,11 +316,83 @@ export function handleFundAnswerBounty(event: LogFundAnswerBounty): void {
224
316
  return;
225
317
  }
226
318
  question.bounty = event.params.bounty;
319
+ question.updatedBlock = event.block.number;
320
+ question.updatedTimestamp = event.block.timestamp;
227
321
  question.save()
322
+
323
+ let fundId = event.transaction.hash.toHex() + "-" + event.logIndex.toString()
324
+ let fund = new Fund(fundId);
325
+ fund.question = contractQuestionId;
326
+ fund.user = event.params.user;
327
+ fund.amount = event.params.bounty_added;
328
+ fund.createdBlock = event.block.number;
329
+ fund.save()
330
+
331
+ let ua = new UserAction(event.transaction.hash.toHex() + "-" + event.logIndex.toString());
332
+ ua.actionType = 'FundAnswerBounty';
333
+ ua.user = event.params.user;
334
+ ua.createdBlock = event.block.number;
335
+ ua.createdTimestamp = event.block.timestamp;
336
+ ua.fund = fundId;
337
+ ua.question = contractQuestionId;
338
+ ua.save();
228
339
  }
229
340
 
230
- function saveAnswer(contractQuestionId: string, answer: Bytes, bond: BigInt, ts: BigInt): void {
341
+ export function handleLogClaim(event: LogClaim): void {
342
+ let claimId = event.transaction.hash.toHex() + "-" + event.logIndex.toString()
343
+ let claim = new Claim(claimId)
231
344
 
345
+ let contractQuestionId = event.address.toHexString() + '-' + event.params.question_id.toHexString();
346
+ claim.question = contractQuestionId;
347
+ claim.user = event.params.user;
348
+ claim.amount = event.params.amount;
349
+ claim.createdBlock = event.block.number;
350
+ claim.save();
351
+
352
+ let question = Question.load(contractQuestionId);
353
+ let contract = RealityETH.bind(event.address)
354
+ question.historyHash = contract.getHistoryHash(event.params.question_id);
355
+
356
+ question.updatedBlock = event.block.number;
357
+ question.updatedTimestamp = event.block.timestamp;
358
+ question.save();
359
+ }
360
+
361
+ export function handleLogWithdraw(event: LogWithdraw): void {
362
+ let withdrawalId = event.transaction.hash.toHex() + "-" + event.logIndex.toString();
363
+ let withdrawal = new Withdrawal(withdrawalId);
364
+ withdrawal.user = event.params.user;
365
+ withdrawal.amount = event.params.amount;
366
+ withdrawal.createdBlock = event.block.number;
367
+ withdrawal.save();
368
+ }
369
+
370
+ // This is done on question creation.
371
+ // To preserve the old event signatures it adds a new event
372
+ export function handleLogMinimumBond(event: LogMinimumBond): void {
373
+ let contractQuestionId = event.address.toHexString() + '-' + event.params.question_id.toHexString();
374
+ let question = Question.load(contractQuestionId);
375
+ question.minBond = event.params.min_bond;
376
+ question.save();
377
+ }
378
+
379
+ export function handleLogReopenQuestion(event: LogReopenQuestion): void {
380
+ // We'll save this in both directions for easy querying
381
+ let contractQuestionId = event.address.toHexString() + '-' + event.params.question_id.toHexString();
382
+ let reopenedContractQuestionId = event.address.toHexString() + '-' + event.params.reopened_question_id.toHexString();
383
+ let question = Question.load(contractQuestionId);
384
+ let reopenedQuestion = Question.load(reopenedContractQuestionId);
385
+ question.reopens = reopenedContractQuestionId;
386
+ question.updatedBlock = event.block.number;
387
+ question.updatedTimestamp = event.block.timestamp;
388
+ question.save();
389
+ reopenedQuestion.reopenedBy = contractQuestionId;
390
+ reopenedQuestion.updatedBlock = event.block.number;
391
+ reopenedQuestion.updatedTimestamp = event.block.timestamp;
392
+ reopenedQuestion.save();
393
+ }
394
+
395
+ function saveAnswer(contractQuestionId: string, answer: Bytes, bond: BigInt, ts: BigInt, createdBlock: BigInt): void {
232
396
  let question = Question.load(contractQuestionId);
233
397
 
234
398
  let answerId = contractQuestionId + '-' + answer.toHexString();
@@ -240,6 +404,7 @@ function saveAnswer(contractQuestionId: string, answer: Bytes, bond: BigInt, ts:
240
404
  answerEntity.bondAggregate = bond;
241
405
  answerEntity.lastBond = bond;
242
406
  answerEntity.timestamp = ts;
407
+ answerEntity.createdBlock = createdBlock;
243
408
  answerEntity.save();
244
409
  } else {
245
410
  answerEntity.bondAggregate = answerEntity.bondAggregate.plus(bond);
@@ -249,16 +414,5 @@ function saveAnswer(contractQuestionId: string, answer: Bytes, bond: BigInt, ts:
249
414
  }
250
415
  answerEntity.save();
251
416
  }
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
417
  }
264
418
 
@@ -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