envio 2.30.2 → 2.31.0-alpha.1

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/src/Batch.res.js CHANGED
@@ -1,16 +1,18 @@
1
1
  // Generated by ReScript, PLEASE EDIT WITH CARE
2
2
  'use strict';
3
3
 
4
+ var Utils = require("./Utils.res.js");
4
5
  var ChainMap = require("./ChainMap.res.js");
5
- var Caml_array = require("rescript/lib/js/caml_array.js");
6
+ var Belt_Array = require("rescript/lib/js/belt_Array.js");
6
7
  var FetchState = require("./FetchState.res.js");
8
+ var ReorgDetection = require("./ReorgDetection.res.js");
7
9
 
8
10
  function getOrderedNextChain(fetchStates, batchSizePerChain) {
9
11
  var earliestChain;
10
12
  var earliestChainTimestamp = 0;
11
13
  var chainKeys = ChainMap.keys(fetchStates);
12
- for(var idx = 0 ,idx_finish = chainKeys.length; idx < idx_finish; ++idx){
13
- var chain = Caml_array.get(chainKeys, idx);
14
+ for(var idx = 0 ,idx_finish = chainKeys.length - 1; idx <= idx_finish; ++idx){
15
+ var chain = chainKeys[idx];
14
16
  var fetchState = ChainMap.get(fetchStates, chain);
15
17
  if (FetchState.isActivelyIndexing(fetchState)) {
16
18
  var batchSize = batchSizePerChain[chain];
@@ -56,51 +58,307 @@ function hasMultichainReadyItem(fetchStates, multichain) {
56
58
  }
57
59
  }
58
60
 
59
- function prepareOrderedBatch(batchSizeTarget, fetchStates, mutBatchSizePerChain) {
60
- var batchSize = 0;
61
+ function getChainAfterBatchIfProgressed(chainBeforeBatch, progressBlockNumberAfterBatch, fetchStateAfterBatch, batchSize) {
62
+ if (chainBeforeBatch.progressBlockNumber < progressBlockNumberAfterBatch) {
63
+ return {
64
+ batchSize: batchSize,
65
+ progressBlockNumber: progressBlockNumberAfterBatch,
66
+ totalEventsProcessed: chainBeforeBatch.totalEventsProcessed + batchSize,
67
+ fetchState: fetchStateAfterBatch,
68
+ isProgressAtHeadWhenBatchCreated: progressBlockNumberAfterBatch >= chainBeforeBatch.sourceBlockNumber
69
+ };
70
+ }
71
+
72
+ }
73
+
74
+ function getProgressedChainsById(chainsBeforeBatch, batchSizePerChain, progressBlockNumberPerChain) {
75
+ var progressedChainsById = {};
76
+ Belt_Array.forEachU(ChainMap.values(chainsBeforeBatch), (function (chainBeforeBatch) {
77
+ var fetchState = chainBeforeBatch.fetchState;
78
+ var progressBlockNumber = progressBlockNumberPerChain[String(fetchState.chainId)];
79
+ var progressBlockNumberAfterBatch = progressBlockNumber !== undefined ? progressBlockNumber : chainBeforeBatch.progressBlockNumber;
80
+ var batchSize = batchSizePerChain[String(fetchState.chainId)];
81
+ var progressedChain;
82
+ if (batchSize !== undefined) {
83
+ var leftItems = fetchState.buffer.slice(batchSize);
84
+ progressedChain = getChainAfterBatchIfProgressed(chainBeforeBatch, progressBlockNumberAfterBatch, FetchState.updateInternal(fetchState, undefined, undefined, undefined, leftItems, undefined), batchSize);
85
+ } else {
86
+ progressedChain = getChainAfterBatchIfProgressed(chainBeforeBatch, progressBlockNumberAfterBatch, chainBeforeBatch.fetchState, 0);
87
+ }
88
+ if (progressedChain !== undefined) {
89
+ progressedChainsById[chainBeforeBatch.fetchState.chainId] = progressedChain;
90
+ return ;
91
+ }
92
+
93
+ }));
94
+ return progressedChainsById;
95
+ }
96
+
97
+ function addReorgCheckpoints(prevCheckpointId, reorgDetection, fromBlockExclusive, toBlockExclusive, chainId, mutCheckpointIds, mutCheckpointChainIds, mutCheckpointBlockNumbers, mutCheckpointBlockHashes, mutCheckpointEventsProcessed) {
98
+ if (!(reorgDetection.shouldRollbackOnReorg && !Utils.Dict.isEmpty(reorgDetection.dataByBlockNumber))) {
99
+ return prevCheckpointId;
100
+ }
101
+ var prevCheckpointId$1 = prevCheckpointId;
102
+ for(var blockNumber = fromBlockExclusive + 1 ,blockNumber_finish = toBlockExclusive - 1; blockNumber <= blockNumber_finish; ++blockNumber){
103
+ var hash = ReorgDetection.getHashByBlockNumber(reorgDetection, blockNumber);
104
+ if (hash !== null) {
105
+ var checkpointId = prevCheckpointId$1 + 1;
106
+ prevCheckpointId$1 = checkpointId;
107
+ mutCheckpointIds.push(checkpointId);
108
+ mutCheckpointChainIds.push(chainId);
109
+ mutCheckpointBlockNumbers.push(blockNumber);
110
+ mutCheckpointBlockHashes.push(hash);
111
+ mutCheckpointEventsProcessed.push(0);
112
+ }
113
+
114
+ }
115
+ return prevCheckpointId$1;
116
+ }
117
+
118
+ function prepareOrderedBatch(checkpointIdBeforeBatch, chainsBeforeBatch, batchSizeTarget) {
119
+ var totalBatchSize = 0;
61
120
  var isFinished = false;
121
+ var prevCheckpointId = checkpointIdBeforeBatch;
122
+ var mutBatchSizePerChain = {};
123
+ var mutProgressBlockNumberPerChain = {};
124
+ var fetchStates = ChainMap.map(chainsBeforeBatch, (function (chainBeforeBatch) {
125
+ return chainBeforeBatch.fetchState;
126
+ }));
62
127
  var items = [];
63
- while(batchSize < batchSizeTarget && !isFinished) {
128
+ var checkpointIds = [];
129
+ var checkpointChainIds = [];
130
+ var checkpointBlockNumbers = [];
131
+ var checkpointBlockHashes = [];
132
+ var checkpointEventsProcessed = [];
133
+ while(totalBatchSize < batchSizeTarget && !isFinished) {
64
134
  var fetchState = getOrderedNextChain(fetchStates, mutBatchSizePerChain);
65
135
  if (fetchState !== undefined) {
66
- var batchSize$1 = mutBatchSizePerChain[fetchState.chainId];
67
- var itemsCountBefore = batchSize$1 !== undefined ? batchSize$1 : 0;
136
+ var chainBeforeBatch = ChainMap.get(chainsBeforeBatch, ChainMap.Chain.makeUnsafe(fetchState.chainId));
137
+ var batchSize = mutBatchSizePerChain[fetchState.chainId];
138
+ var itemsCountBefore = batchSize !== undefined ? batchSize : 0;
139
+ var progressBlockNumber = mutProgressBlockNumberPerChain[fetchState.chainId];
140
+ var prevBlockNumber = progressBlockNumber !== undefined ? progressBlockNumber : chainBeforeBatch.progressBlockNumber;
68
141
  var newItemsCount = FetchState.getReadyItemsCount(fetchState, 1, itemsCountBefore);
69
142
  if (newItemsCount > 0) {
70
- for(var idx = itemsCountBefore ,idx_finish = itemsCountBefore + newItemsCount | 0; idx < idx_finish; ++idx){
71
- items.push(fetchState.buffer[idx]);
143
+ var item0 = fetchState.buffer[itemsCountBefore];
144
+ var blockNumber = item0.blockNumber;
145
+ var chainId = fetchState.chainId;
146
+ var reorgDetection = chainBeforeBatch.reorgDetection;
147
+ var prevCheckpointId$1 = prevCheckpointId;
148
+ var tmp;
149
+ if (reorgDetection.shouldRollbackOnReorg && !Utils.Dict.isEmpty(reorgDetection.dataByBlockNumber)) {
150
+ var prevCheckpointId$2 = prevCheckpointId$1;
151
+ for(var blockNumber$1 = prevBlockNumber + 1 ,blockNumber_finish = blockNumber - 1; blockNumber$1 <= blockNumber_finish; ++blockNumber$1){
152
+ var hash = ReorgDetection.getHashByBlockNumber(reorgDetection, blockNumber$1);
153
+ if (hash !== null) {
154
+ var checkpointId = prevCheckpointId$2 + 1;
155
+ prevCheckpointId$2 = checkpointId;
156
+ checkpointIds.push(checkpointId);
157
+ checkpointChainIds.push(chainId);
158
+ checkpointBlockNumbers.push(blockNumber$1);
159
+ checkpointBlockHashes.push(hash);
160
+ checkpointEventsProcessed.push(0);
161
+ }
162
+
163
+ }
164
+ tmp = prevCheckpointId$2;
165
+ } else {
166
+ tmp = prevCheckpointId$1;
72
167
  }
73
- batchSize = batchSize + newItemsCount | 0;
74
- mutBatchSizePerChain[fetchState.chainId] = itemsCountBefore + newItemsCount | 0;
168
+ prevCheckpointId = tmp;
169
+ var checkpointId$1 = prevCheckpointId + 1;
170
+ items.push(item0);
171
+ for(var idx = 1 ,idx_finish = newItemsCount - 1; idx <= idx_finish; ++idx){
172
+ items.push(fetchState.buffer[itemsCountBefore + idx]);
173
+ }
174
+ checkpointIds.push(checkpointId$1);
175
+ checkpointChainIds.push(fetchState.chainId);
176
+ checkpointBlockNumbers.push(blockNumber);
177
+ checkpointBlockHashes.push(ReorgDetection.getHashByBlockNumber(chainBeforeBatch.reorgDetection, blockNumber));
178
+ checkpointEventsProcessed.push(newItemsCount);
179
+ prevCheckpointId = checkpointId$1;
180
+ totalBatchSize = totalBatchSize + newItemsCount;
181
+ mutBatchSizePerChain[fetchState.chainId] = itemsCountBefore + newItemsCount;
182
+ mutProgressBlockNumberPerChain[fetchState.chainId] = blockNumber;
75
183
  } else {
184
+ var blockNumberAfterBatch = FetchState.bufferBlockNumber(fetchState);
185
+ var chainId$1 = fetchState.chainId;
186
+ var toBlockExclusive = blockNumberAfterBatch + 1;
187
+ var reorgDetection$1 = chainBeforeBatch.reorgDetection;
188
+ var prevCheckpointId$3 = prevCheckpointId;
189
+ var tmp$1;
190
+ if (reorgDetection$1.shouldRollbackOnReorg && !Utils.Dict.isEmpty(reorgDetection$1.dataByBlockNumber)) {
191
+ var prevCheckpointId$4 = prevCheckpointId$3;
192
+ for(var blockNumber$2 = prevBlockNumber + 1 ,blockNumber_finish$1 = toBlockExclusive - 1; blockNumber$2 <= blockNumber_finish$1; ++blockNumber$2){
193
+ var hash$1 = ReorgDetection.getHashByBlockNumber(reorgDetection$1, blockNumber$2);
194
+ if (hash$1 !== null) {
195
+ var checkpointId$2 = prevCheckpointId$4 + 1;
196
+ prevCheckpointId$4 = checkpointId$2;
197
+ checkpointIds.push(checkpointId$2);
198
+ checkpointChainIds.push(chainId$1);
199
+ checkpointBlockNumbers.push(blockNumber$2);
200
+ checkpointBlockHashes.push(hash$1);
201
+ checkpointEventsProcessed.push(0);
202
+ }
203
+
204
+ }
205
+ tmp$1 = prevCheckpointId$4;
206
+ } else {
207
+ tmp$1 = prevCheckpointId$3;
208
+ }
209
+ prevCheckpointId = tmp$1;
210
+ mutProgressBlockNumberPerChain[fetchState.chainId] = blockNumberAfterBatch;
76
211
  isFinished = true;
77
212
  }
78
213
  } else {
79
214
  isFinished = true;
80
215
  }
81
216
  };
82
- return items;
217
+ return {
218
+ totalBatchSize: totalBatchSize,
219
+ items: items,
220
+ progressedChainsById: getProgressedChainsById(chainsBeforeBatch, mutBatchSizePerChain, mutProgressBlockNumberPerChain),
221
+ checkpointIds: checkpointIds,
222
+ checkpointChainIds: checkpointChainIds,
223
+ checkpointBlockNumbers: checkpointBlockNumbers,
224
+ checkpointBlockHashes: checkpointBlockHashes,
225
+ checkpointEventsProcessed: checkpointEventsProcessed
226
+ };
83
227
  }
84
228
 
85
- function prepareUnorderedBatch(batchSizeTarget, fetchStates, mutBatchSizePerChain) {
86
- var preparedFetchStates = FetchState.filterAndSortForUnorderedBatch(ChainMap.values(fetchStates), batchSizeTarget);
229
+ function prepareUnorderedBatch(checkpointIdBeforeBatch, chainsBeforeBatch, batchSizeTarget) {
230
+ var preparedFetchStates = FetchState.sortForUnorderedBatch(ChainMap.values(chainsBeforeBatch).map(function (chainBeforeBatch) {
231
+ return chainBeforeBatch.fetchState;
232
+ }), batchSizeTarget);
87
233
  var chainIdx = 0;
88
234
  var preparedNumber = preparedFetchStates.length;
89
- var batchSize = 0;
235
+ var totalBatchSize = 0;
236
+ var prevCheckpointId = checkpointIdBeforeBatch;
237
+ var mutBatchSizePerChain = {};
238
+ var mutProgressBlockNumberPerChain = {};
90
239
  var items = [];
91
- while(batchSize < batchSizeTarget && chainIdx < preparedNumber) {
240
+ var checkpointIds = [];
241
+ var checkpointChainIds = [];
242
+ var checkpointBlockNumbers = [];
243
+ var checkpointBlockHashes = [];
244
+ var checkpointEventsProcessed = [];
245
+ while(totalBatchSize < batchSizeTarget && chainIdx < preparedNumber) {
92
246
  var fetchState = preparedFetchStates[chainIdx];
93
- var chainBatchSize = FetchState.getReadyItemsCount(fetchState, batchSizeTarget - batchSize | 0, 0);
247
+ var chainBatchSize = FetchState.getReadyItemsCount(fetchState, batchSizeTarget - totalBatchSize, 0);
248
+ var chainBeforeBatch = ChainMap.get(chainsBeforeBatch, ChainMap.Chain.makeUnsafe(fetchState.chainId));
249
+ var prevBlockNumber = chainBeforeBatch.progressBlockNumber;
94
250
  if (chainBatchSize > 0) {
95
- for(var idx = 0; idx < chainBatchSize; ++idx){
96
- items.push(fetchState.buffer[idx]);
251
+ for(var idx = 0 ,idx_finish = chainBatchSize - 1; idx <= idx_finish; ++idx){
252
+ var item = fetchState.buffer[idx];
253
+ var blockNumber = item.blockNumber;
254
+ if (blockNumber !== prevBlockNumber) {
255
+ var chainId = fetchState.chainId;
256
+ var fromBlockExclusive = prevBlockNumber;
257
+ var reorgDetection = chainBeforeBatch.reorgDetection;
258
+ var prevCheckpointId$1 = prevCheckpointId;
259
+ var tmp;
260
+ if (reorgDetection.shouldRollbackOnReorg && !Utils.Dict.isEmpty(reorgDetection.dataByBlockNumber)) {
261
+ var prevCheckpointId$2 = prevCheckpointId$1;
262
+ for(var blockNumber$1 = fromBlockExclusive + 1 ,blockNumber_finish = blockNumber - 1; blockNumber$1 <= blockNumber_finish; ++blockNumber$1){
263
+ var hash = ReorgDetection.getHashByBlockNumber(reorgDetection, blockNumber$1);
264
+ if (hash !== null) {
265
+ var checkpointId = prevCheckpointId$2 + 1;
266
+ prevCheckpointId$2 = checkpointId;
267
+ checkpointIds.push(checkpointId);
268
+ checkpointChainIds.push(chainId);
269
+ checkpointBlockNumbers.push(blockNumber$1);
270
+ checkpointBlockHashes.push(hash);
271
+ checkpointEventsProcessed.push(0);
272
+ }
273
+
274
+ }
275
+ tmp = prevCheckpointId$2;
276
+ } else {
277
+ tmp = prevCheckpointId$1;
278
+ }
279
+ prevCheckpointId = tmp;
280
+ var checkpointId$1 = prevCheckpointId + 1;
281
+ checkpointIds.push(checkpointId$1);
282
+ checkpointChainIds.push(fetchState.chainId);
283
+ checkpointBlockNumbers.push(blockNumber);
284
+ checkpointBlockHashes.push(ReorgDetection.getHashByBlockNumber(chainBeforeBatch.reorgDetection, blockNumber));
285
+ checkpointEventsProcessed.push(1);
286
+ prevBlockNumber = blockNumber;
287
+ prevCheckpointId = checkpointId$1;
288
+ } else {
289
+ var lastIndex = checkpointEventsProcessed.length - 1;
290
+ checkpointEventsProcessed[lastIndex] = checkpointEventsProcessed[lastIndex] + 1;
291
+ }
292
+ items.push(item);
97
293
  }
98
- batchSize = batchSize + chainBatchSize | 0;
294
+ totalBatchSize = totalBatchSize + chainBatchSize;
99
295
  mutBatchSizePerChain[fetchState.chainId] = chainBatchSize;
100
296
  }
101
- chainIdx = chainIdx + 1 | 0;
297
+ var progressBlockNumberAfterBatch = FetchState.getUnorderedMultichainProgressBlockNumberAt(fetchState, chainBatchSize);
298
+ var chainId$1 = fetchState.chainId;
299
+ var toBlockExclusive = progressBlockNumberAfterBatch + 1;
300
+ var fromBlockExclusive$1 = prevBlockNumber;
301
+ var reorgDetection$1 = chainBeforeBatch.reorgDetection;
302
+ var prevCheckpointId$3 = prevCheckpointId;
303
+ var tmp$1;
304
+ if (reorgDetection$1.shouldRollbackOnReorg && !Utils.Dict.isEmpty(reorgDetection$1.dataByBlockNumber)) {
305
+ var prevCheckpointId$4 = prevCheckpointId$3;
306
+ for(var blockNumber$2 = fromBlockExclusive$1 + 1 ,blockNumber_finish$1 = toBlockExclusive - 1; blockNumber$2 <= blockNumber_finish$1; ++blockNumber$2){
307
+ var hash$1 = ReorgDetection.getHashByBlockNumber(reorgDetection$1, blockNumber$2);
308
+ if (hash$1 !== null) {
309
+ var checkpointId$2 = prevCheckpointId$4 + 1;
310
+ prevCheckpointId$4 = checkpointId$2;
311
+ checkpointIds.push(checkpointId$2);
312
+ checkpointChainIds.push(chainId$1);
313
+ checkpointBlockNumbers.push(blockNumber$2);
314
+ checkpointBlockHashes.push(hash$1);
315
+ checkpointEventsProcessed.push(0);
316
+ }
317
+
318
+ }
319
+ tmp$1 = prevCheckpointId$4;
320
+ } else {
321
+ tmp$1 = prevCheckpointId$3;
322
+ }
323
+ prevCheckpointId = tmp$1;
324
+ mutProgressBlockNumberPerChain[fetchState.chainId] = progressBlockNumberAfterBatch;
325
+ chainIdx = chainIdx + 1;
326
+ };
327
+ return {
328
+ totalBatchSize: totalBatchSize,
329
+ items: items,
330
+ progressedChainsById: getProgressedChainsById(chainsBeforeBatch, mutBatchSizePerChain, mutProgressBlockNumberPerChain),
331
+ checkpointIds: checkpointIds,
332
+ checkpointChainIds: checkpointChainIds,
333
+ checkpointBlockNumbers: checkpointBlockNumbers,
334
+ checkpointBlockHashes: checkpointBlockHashes,
335
+ checkpointEventsProcessed: checkpointEventsProcessed
336
+ };
337
+ }
338
+
339
+ function make(checkpointIdBeforeBatch, chainsBeforeBatch, multichain, batchSizeTarget) {
340
+ var tmp;
341
+ tmp = multichain === "ordered" ? ChainMap.size(chainsBeforeBatch) === 1 : true;
342
+ if (tmp) {
343
+ return prepareUnorderedBatch(checkpointIdBeforeBatch, chainsBeforeBatch, batchSizeTarget);
344
+ } else {
345
+ return prepareOrderedBatch(checkpointIdBeforeBatch, chainsBeforeBatch, batchSizeTarget);
346
+ }
347
+ }
348
+
349
+ function findFirstEventBlockNumber(batch, chainId) {
350
+ var idx = 0;
351
+ var result;
352
+ var checkpointsLength = batch.checkpointIds.length;
353
+ while(idx < checkpointsLength && result === undefined) {
354
+ var checkpointChainId = batch.checkpointChainIds[idx];
355
+ if (checkpointChainId === chainId && batch.checkpointEventsProcessed[idx] > 0) {
356
+ result = batch.checkpointBlockNumbers[idx];
357
+ } else {
358
+ idx = idx + 1;
359
+ }
102
360
  };
103
- return items;
361
+ return result;
104
362
  }
105
363
 
106
364
  exports.getOrderedNextChain = getOrderedNextChain;
@@ -108,6 +366,10 @@ exports.immutableEmptyBatchSizePerChain = immutableEmptyBatchSizePerChain;
108
366
  exports.hasOrderedReadyItem = hasOrderedReadyItem;
109
367
  exports.hasUnorderedReadyItem = hasUnorderedReadyItem;
110
368
  exports.hasMultichainReadyItem = hasMultichainReadyItem;
369
+ exports.getProgressedChainsById = getProgressedChainsById;
370
+ exports.addReorgCheckpoints = addReorgCheckpoints;
111
371
  exports.prepareOrderedBatch = prepareOrderedBatch;
112
372
  exports.prepareUnorderedBatch = prepareUnorderedBatch;
113
- /* ChainMap Not a pure module */
373
+ exports.make = make;
374
+ exports.findFirstEventBlockNumber = findFirstEventBlockNumber;
375
+ /* Utils Not a pure module */
@@ -1,4 +1,7 @@
1
- type registrations = {onBlockByChainId: dict<array<Internal.onBlockConfig>>}
1
+ type registrations = {
2
+ onBlockByChainId: dict<array<Internal.onBlockConfig>>,
3
+ mutable hasEvents: bool,
4
+ }
2
5
 
3
6
  type activeRegistration = {
4
7
  ecosystem: InternalConfig.ecosystem,
@@ -40,6 +43,7 @@ let startRegistration = (~ecosystem, ~multichain, ~preloadHandlers) => {
40
43
  preloadHandlers,
41
44
  registrations: {
42
45
  onBlockByChainId: Js.Dict.empty(),
46
+ hasEvents: false,
43
47
  },
44
48
  finished: false,
45
49
  }
@@ -205,7 +209,8 @@ let setEventOptions = (t: t, ~eventOptions, ~logger=Logging.getLogger()) => {
205
209
  }
206
210
 
207
211
  let setHandler = (t: t, handler, ~eventOptions, ~logger=Logging.getLogger()) => {
208
- withRegistration(_ => {
212
+ withRegistration(registration => {
213
+ registration.registrations.hasEvents = true
209
214
  switch t.handler {
210
215
  | None =>
211
216
  t.handler =
@@ -225,7 +230,8 @@ let setHandler = (t: t, handler, ~eventOptions, ~logger=Logging.getLogger()) =>
225
230
  }
226
231
 
227
232
  let setContractRegister = (t: t, contractRegister, ~eventOptions, ~logger=Logging.getLogger()) => {
228
- withRegistration(_ => {
233
+ withRegistration(registration => {
234
+ registration.registrations.hasEvents = true
229
235
  switch t.contractRegister {
230
236
  | None =>
231
237
  t.contractRegister = Some(
@@ -34,7 +34,8 @@ function startRegistration(ecosystem, multichain, preloadHandlers) {
34
34
  multichain: multichain,
35
35
  preloadHandlers: preloadHandlers,
36
36
  registrations: {
37
- onBlockByChainId: {}
37
+ onBlockByChainId: {},
38
+ hasEvents: false
38
39
  },
39
40
  finished: false
40
41
  };
@@ -180,7 +181,8 @@ function setEventOptions(t, eventOptions, loggerOpt) {
180
181
 
181
182
  function setHandler(t, handler, eventOptions, loggerOpt) {
182
183
  var logger = loggerOpt !== undefined ? loggerOpt : Logging.getLogger();
183
- withRegistration(function (param) {
184
+ withRegistration(function (registration) {
185
+ registration.registrations.hasEvents = true;
184
186
  var match = t.handler;
185
187
  if (match !== undefined) {
186
188
  var eventNamespace_contractName = t.contractName;
@@ -202,7 +204,8 @@ function setHandler(t, handler, eventOptions, loggerOpt) {
202
204
 
203
205
  function setContractRegister(t, contractRegister, eventOptions, loggerOpt) {
204
206
  var logger = loggerOpt !== undefined ? loggerOpt : Logging.getLogger();
205
- withRegistration(function (param) {
207
+ withRegistration(function (registration) {
208
+ registration.registrations.hasEvents = true;
206
209
  var match = t.contractRegister;
207
210
  if (match !== undefined) {
208
211
  var eventNamespace_contractName = t.contractName;
@@ -1,4 +1,7 @@
1
- type registrations = {onBlockByChainId: dict<array<Internal.onBlockConfig>>}
1
+ type registrations = {
2
+ onBlockByChainId: dict<array<Internal.onBlockConfig>>,
3
+ mutable hasEvents: bool,
4
+ }
2
5
 
3
6
  let startRegistration: (
4
7
  ~ecosystem: InternalConfig.ecosystem,