envio 3.0.2 → 3.1.0-rc.0

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.
Files changed (91) hide show
  1. package/README.md +0 -1
  2. package/evm.schema.json +15 -8
  3. package/fuel.schema.json +19 -12
  4. package/index.d.ts +0 -2
  5. package/package.json +6 -7
  6. package/rescript.json +1 -1
  7. package/src/Batch.res +4 -214
  8. package/src/Batch.res.mjs +6 -165
  9. package/src/ChainFetcher.res +4 -5
  10. package/src/ChainFetcher.res.mjs +6 -7
  11. package/src/ChainManager.res +10 -9
  12. package/src/ChainManager.res.mjs +6 -10
  13. package/src/Config.res +9 -25
  14. package/src/Config.res.mjs +17 -27
  15. package/src/Core.res +7 -0
  16. package/src/Ctx.res +1 -0
  17. package/src/Env.res +0 -1
  18. package/src/Env.res.mjs +0 -3
  19. package/src/EventConfigBuilder.res +13 -123
  20. package/src/EventConfigBuilder.res.mjs +6 -73
  21. package/src/EventProcessing.res +5 -29
  22. package/src/EventProcessing.res.mjs +11 -20
  23. package/src/EventUtils.res +0 -27
  24. package/src/EventUtils.res.mjs +0 -24
  25. package/src/FetchState.res +1 -11
  26. package/src/FetchState.res.mjs +2 -16
  27. package/src/GlobalState.res +23 -37
  28. package/src/GlobalState.res.mjs +10 -38
  29. package/src/HandlerLoader.res +6 -5
  30. package/src/HandlerLoader.res.mjs +27 -9
  31. package/src/HandlerRegister.res +1 -12
  32. package/src/HandlerRegister.res.mjs +1 -6
  33. package/src/HandlerRegister.resi +1 -1
  34. package/src/Hasura.res +96 -32
  35. package/src/Hasura.res.mjs +93 -38
  36. package/src/InMemoryStore.res +181 -45
  37. package/src/InMemoryStore.res.mjs +143 -40
  38. package/src/InMemoryTable.res +147 -247
  39. package/src/InMemoryTable.res.mjs +131 -230
  40. package/src/Internal.res +10 -34
  41. package/src/Internal.res.mjs +9 -3
  42. package/src/LoadLayer.res +5 -5
  43. package/src/LoadLayer.res.mjs +5 -5
  44. package/src/Main.res +4 -6
  45. package/src/Main.res.mjs +26 -15
  46. package/src/Persistence.res +7 -132
  47. package/src/Persistence.res.mjs +1 -102
  48. package/src/PgStorage.res +57 -40
  49. package/src/PgStorage.res.mjs +60 -34
  50. package/src/ReorgDetection.res +35 -58
  51. package/src/ReorgDetection.res.mjs +21 -29
  52. package/src/SimulateItems.res.mjs +21 -3
  53. package/src/Sink.res +2 -2
  54. package/src/Sink.res.mjs +1 -1
  55. package/src/TableIndices.res +9 -2
  56. package/src/TableIndices.res.mjs +7 -1
  57. package/src/TestIndexer.res +53 -60
  58. package/src/TestIndexer.res.mjs +77 -63
  59. package/src/TestIndexerProxyStorage.res +4 -14
  60. package/src/TestIndexerProxyStorage.res.mjs +1 -5
  61. package/src/UserContext.res +2 -4
  62. package/src/UserContext.res.mjs +4 -5
  63. package/src/Utils.res +0 -2
  64. package/src/Utils.res.mjs +0 -3
  65. package/src/bindings/ClickHouse.res +45 -38
  66. package/src/bindings/ClickHouse.res.mjs +16 -17
  67. package/src/bindings/Vitest.res +3 -0
  68. package/src/db/InternalTable.res +59 -18
  69. package/src/db/InternalTable.res.mjs +82 -51
  70. package/src/db/Table.res +9 -2
  71. package/src/db/Table.res.mjs +10 -7
  72. package/src/sources/EvmChain.res +32 -9
  73. package/src/sources/EvmChain.res.mjs +31 -4
  74. package/src/sources/HyperFuelSource.res +14 -57
  75. package/src/sources/HyperFuelSource.res.mjs +18 -38
  76. package/src/sources/HyperSync.res +36 -101
  77. package/src/sources/HyperSync.res.mjs +42 -96
  78. package/src/sources/HyperSync.resi +4 -22
  79. package/src/sources/HyperSyncClient.res +67 -245
  80. package/src/sources/HyperSyncClient.res.mjs +47 -46
  81. package/src/sources/HyperSyncSource.res +76 -147
  82. package/src/sources/HyperSyncSource.res.mjs +61 -114
  83. package/src/sources/RpcSource.res +43 -22
  84. package/src/sources/RpcSource.res.mjs +50 -35
  85. package/src/sources/SimulateSource.res +1 -7
  86. package/src/sources/SimulateSource.res.mjs +1 -7
  87. package/src/sources/Source.res +8 -1
  88. package/src/sources/SourceManager.res +9 -0
  89. package/src/sources/SourceManager.res.mjs +10 -0
  90. package/src/sources/SourceManager.resi +2 -0
  91. package/svm.schema.json +11 -4
@@ -51,6 +51,7 @@ let make = (
51
51
  ~reorgCheckpoints: array<Internal.reorgCheckpoint>,
52
52
  ~maxReorgDepth,
53
53
  ~knownHeight=0,
54
+ ~reducedPollingInterval=?,
54
55
  ): t => {
55
56
  // We don't need the router itself, but only validation logic,
56
57
  // since now event router is created for selection of events
@@ -210,10 +211,6 @@ let make = (
210
211
  Utils.magic: array<Internal.eventConfig> => array<Internal.evmEventConfig>
211
212
  ),
212
213
  })
213
- // Collect all event signatures from contracts
214
- let allEventSignatures =
215
- chainConfig.contracts->Array.flatMap(contract => contract.eventSignatures)
216
- // Convert rpcs to EvmChain.rpc format
217
214
  let evmRpcs: array<EvmChain.rpc> = rpcs->Array.map((rpc): EvmChain.rpc => {
218
215
  let syncConfig = rpc.syncConfig
219
216
  let ws = rpc.ws
@@ -228,7 +225,6 @@ let make = (
228
225
  ~chain,
229
226
  ~contracts=evmContracts,
230
227
  ~hyperSync=hypersync,
231
- ~allEventSignatures,
232
228
  ~rpcs=evmRpcs,
233
229
  ~lowercaseAddresses,
234
230
  )
@@ -245,6 +241,7 @@ let make = (
245
241
  ~sources,
246
242
  ~maxPartitionConcurrency=Env.maxPartitionConcurrency,
247
243
  ~isRealtime,
244
+ ~reducedPollingInterval?,
248
245
  ),
249
246
  reorgDetection: ReorgDetection.make(
250
247
  ~chainReorgCheckpoints,
@@ -305,6 +302,7 @@ let makeFromDbState = (
305
302
  ~config,
306
303
  ~registrations,
307
304
  ~targetBufferSize,
305
+ ~reducedPollingInterval=?,
308
306
  ) => {
309
307
  let chainId = chainConfig.id
310
308
  let logger = Logging.createChild(~params={"chainId": chainId})
@@ -337,6 +335,7 @@ let makeFromDbState = (
337
335
  ~isInReorgThreshold,
338
336
  ~isRealtime,
339
337
  ~knownHeight=resumedChainState.sourceBlockNumber,
338
+ ~reducedPollingInterval?,
340
339
  )
341
340
  }
342
341
 
@@ -37,7 +37,7 @@ function configAddresses(chainConfig) {
37
37
  return addresses;
38
38
  }
39
39
 
40
- function make(chainConfig, indexingAddresses, startBlock, endBlock, firstEventBlockOpt, progressBlockNumber, config, registrations, targetBufferSize, logger, timestampCaughtUpToHeadOrEndblock, numEventsProcessed, isInReorgThreshold, isRealtime, reorgCheckpoints, maxReorgDepth, knownHeightOpt) {
40
+ function make(chainConfig, indexingAddresses, startBlock, endBlock, firstEventBlockOpt, progressBlockNumber, config, registrations, targetBufferSize, logger, timestampCaughtUpToHeadOrEndblock, numEventsProcessed, isInReorgThreshold, isRealtime, reorgCheckpoints, maxReorgDepth, knownHeightOpt, reducedPollingInterval) {
41
41
  let firstEventBlock = firstEventBlockOpt !== undefined ? Primitive_option.valFromOption(firstEventBlockOpt) : undefined;
42
42
  let knownHeight = knownHeightOpt !== undefined ? knownHeightOpt : 0;
43
43
  let eventRouter = EventRouter.empty();
@@ -113,7 +113,6 @@ function make(chainConfig, indexingAddresses, startBlock, endBlock, firstEventBl
113
113
  abi: contract.abi,
114
114
  events: contract.events
115
115
  }));
116
- let allEventSignatures = chainConfig.contracts.flatMap(contract => contract.eventSignatures);
117
116
  let evmRpcs = sources.rpcs.map(rpc => {
118
117
  let syncConfig = rpc.syncConfig;
119
118
  let ws = rpc.ws;
@@ -124,7 +123,7 @@ function make(chainConfig, indexingAddresses, startBlock, endBlock, firstEventBl
124
123
  ws: ws
125
124
  };
126
125
  });
127
- sources$1 = EvmChain.makeSources(chain, evmContracts, sources.hypersync, allEventSignatures, evmRpcs, lowercaseAddresses);
126
+ sources$1 = EvmChain.makeSources(chain, evmContracts, sources.hypersync, evmRpcs, lowercaseAddresses);
128
127
  break;
129
128
  case "FuelSourceConfig" :
130
129
  sources$1 = [HyperFuelSource.make({
@@ -142,7 +141,7 @@ function make(chainConfig, indexingAddresses, startBlock, endBlock, firstEventBl
142
141
  return {
143
142
  logger: logger,
144
143
  fetchState: fetchState,
145
- sourceManager: SourceManager.make(sources$1, Env.maxPartitionConcurrency, isRealtime, undefined, undefined, undefined, undefined, undefined, undefined),
144
+ sourceManager: SourceManager.make(sources$1, Env.maxPartitionConcurrency, isRealtime, undefined, undefined, undefined, reducedPollingInterval, undefined, undefined),
146
145
  chainConfig: chainConfig,
147
146
  isProgressAtHead: false,
148
147
  timestampCaughtUpToHeadOrEndblock: timestampCaughtUpToHeadOrEndblock,
@@ -157,17 +156,17 @@ function makeFromConfig(chainConfig, config, registrations, targetBufferSize, kn
157
156
  let logger = Logging.createChild({
158
157
  chainId: chainConfig.id
159
158
  });
160
- return make(chainConfig, configAddresses(chainConfig), chainConfig.startBlock, chainConfig.endBlock, undefined, -1, config, registrations, targetBufferSize, logger, undefined, 0, false, false, [], chainConfig.maxReorgDepth, knownHeight);
159
+ return make(chainConfig, configAddresses(chainConfig), chainConfig.startBlock, chainConfig.endBlock, undefined, -1, config, registrations, targetBufferSize, logger, undefined, 0, false, false, [], chainConfig.maxReorgDepth, knownHeight, undefined);
161
160
  }
162
161
 
163
- function makeFromDbState(chainConfig, resumedChainState, reorgCheckpoints, isInReorgThreshold, isRealtime, config, registrations, targetBufferSize) {
162
+ function makeFromDbState(chainConfig, resumedChainState, reorgCheckpoints, isInReorgThreshold, isRealtime, config, registrations, targetBufferSize, reducedPollingInterval) {
164
163
  let chainId = chainConfig.id;
165
164
  let logger = Logging.createChild({
166
165
  chainId: chainId
167
166
  });
168
167
  Prometheus.ProgressEventsCount.set(resumedChainState.numEventsProcessed, chainId);
169
168
  let progressBlockNumber = resumedChainState.progressBlockNumber >= 0 ? resumedChainState.progressBlockNumber : resumedChainState.startBlock - 1 | 0;
170
- return make(chainConfig, resumedChainState.indexingAddresses, resumedChainState.startBlock, resumedChainState.endBlock, Primitive_option.some(resumedChainState.firstEventBlockNumber), progressBlockNumber, config, registrations, targetBufferSize, logger, Env.updateSyncTimeOnRestart ? undefined : resumedChainState.timestampCaughtUpToHeadOrEndblock, resumedChainState.numEventsProcessed, isInReorgThreshold, isRealtime, reorgCheckpoints, resumedChainState.maxReorgDepth, resumedChainState.sourceBlockNumber);
169
+ return make(chainConfig, resumedChainState.indexingAddresses, resumedChainState.startBlock, resumedChainState.endBlock, Primitive_option.some(resumedChainState.firstEventBlockNumber), progressBlockNumber, config, registrations, targetBufferSize, logger, Env.updateSyncTimeOnRestart ? undefined : resumedChainState.timestampCaughtUpToHeadOrEndblock, resumedChainState.numEventsProcessed, isInReorgThreshold, isRealtime, reorgCheckpoints, resumedChainState.maxReorgDepth, resumedChainState.sourceBlockNumber, reducedPollingInterval);
171
170
  }
172
171
 
173
172
  async function runContractRegistersOrThrow(itemsWithContractRegister, config) {
@@ -1,7 +1,5 @@
1
1
  type t = {
2
- committedCheckpointId: bigint,
3
2
  chainFetchers: ChainMap.t<ChainFetcher.t>,
4
- multichain: Config.multichain,
5
3
  isInReorgThreshold: bool,
6
4
  // True once every chain has caught up to head/endBlock. Monotonic during a run.
7
5
  isRealtime: bool,
@@ -35,6 +33,7 @@ let makeFromDbState = (
35
33
  ~initialState: Persistence.initialState,
36
34
  ~config: Config.t,
37
35
  ~registrations,
36
+ ~reducedPollingInterval=?,
38
37
  ): t => {
39
38
  let isInReorgThreshold = if initialState.cleanRun {
40
39
  false
@@ -81,6 +80,7 @@ let makeFromDbState = (
81
80
  ~targetBufferSize,
82
81
  ~config,
83
82
  ~registrations,
83
+ ~reducedPollingInterval?,
84
84
  ),
85
85
  )
86
86
  })
@@ -105,8 +105,6 @@ let makeFromDbState = (
105
105
  }
106
106
 
107
107
  {
108
- committedCheckpointId: initialState.checkpointId,
109
- multichain: config.multichain,
110
108
  chainFetchers,
111
109
  isInReorgThreshold,
112
110
  isRealtime,
@@ -128,17 +126,21 @@ let setChainFetcher = (chainManager: t, chainFetcher: ChainFetcher.t) => {
128
126
  }
129
127
 
130
128
  let nextItemIsNone = (chainManager: t): bool => {
131
- !Batch.hasMultichainReadyItem(
129
+ !Batch.hasReadyItem(
132
130
  chainManager.chainFetchers->ChainMap.map(cf => {
133
131
  cf.fetchState
134
132
  }),
135
- ~multichain=chainManager.multichain,
136
133
  )
137
134
  }
138
135
 
139
- let createBatch = (chainManager: t, ~batchSizeTarget: int, ~isRollback: bool): Batch.t => {
136
+ let createBatch = (
137
+ chainManager: t,
138
+ ~committedCheckpointId,
139
+ ~batchSizeTarget: int,
140
+ ~isRollback: bool,
141
+ ): Batch.t => {
140
142
  Batch.make(
141
- ~checkpointIdBeforeBatch=chainManager.committedCheckpointId->BigInt.add(
143
+ ~checkpointIdBeforeBatch=committedCheckpointId->BigInt.add(
142
144
  // Since for rollback we have a diff checkpoint id.
143
145
  // This is needed to currectly overwrite old state
144
146
  // in an append-only ClickHouse insert.
@@ -152,7 +154,6 @@ let createBatch = (chainManager: t, ~batchSizeTarget: int, ~isRollback: bool): B
152
154
  reorgDetection: cf.reorgDetection,
153
155
  chainConfig: cf.chainConfig,
154
156
  }),
155
- ~multichain=chainManager.multichain,
156
157
  ~batchSizeTarget,
157
158
  )
158
159
  }
@@ -38,7 +38,7 @@ function calculateTargetBufferSize(activeChainsCount) {
38
38
  }
39
39
  }
40
40
 
41
- function makeFromDbState(initialState, config, registrations) {
41
+ function makeFromDbState(initialState, config, registrations, reducedPollingInterval) {
42
42
  let isInReorgThreshold = initialState.cleanRun ? false : initialState.chains.some(chain => isProgressInReorgThreshold(chain.progressBlockNumber, chain.sourceBlockNumber, chain.maxReorgDepth));
43
43
  let targetBufferSize = calculateTargetBufferSize(initialState.chains.length);
44
44
  Prometheus.ProcessingMaxBatchSize.set(config.batchSize);
@@ -54,7 +54,7 @@ function makeFromDbState(initialState, config, registrations) {
54
54
  let chainConfig = ChainMap.get(config.chainMap, chain);
55
55
  return [
56
56
  chain,
57
- ChainFetcher.makeFromDbState(chainConfig, resumedChainState, initialState.reorgCheckpoints, isInReorgThreshold, isRealtime, config, registrations, targetBufferSize)
57
+ ChainFetcher.makeFromDbState(chainConfig, resumedChainState, initialState.reorgCheckpoints, isInReorgThreshold, isRealtime, config, registrations, targetBufferSize, reducedPollingInterval)
58
58
  ];
59
59
  });
60
60
  let chainFetchers = ChainMap.fromArrayUnsafe(chainFetchersArr);
@@ -77,9 +77,7 @@ function makeFromDbState(initialState, config, registrations) {
77
77
  Prometheus.ProgressReady.setAllReady();
78
78
  }
79
79
  return {
80
- committedCheckpointId: initialState.checkpointId,
81
80
  chainFetchers: chainFetchers,
82
- multichain: config.multichain,
83
81
  isInReorgThreshold: isInReorgThreshold,
84
82
  isRealtime: isRealtime
85
83
  };
@@ -91,20 +89,18 @@ function getChainFetcher(chainManager, chain) {
91
89
 
92
90
  function setChainFetcher(chainManager, chainFetcher) {
93
91
  return {
94
- committedCheckpointId: chainManager.committedCheckpointId,
95
92
  chainFetchers: ChainMap.set(chainManager.chainFetchers, ChainMap.Chain.makeUnsafe(chainFetcher.chainConfig.id), chainFetcher),
96
- multichain: chainManager.multichain,
97
93
  isInReorgThreshold: chainManager.isInReorgThreshold,
98
94
  isRealtime: chainManager.isRealtime
99
95
  };
100
96
  }
101
97
 
102
98
  function nextItemIsNone(chainManager) {
103
- return !Batch.hasMultichainReadyItem(ChainMap.map(chainManager.chainFetchers, cf => cf.fetchState), chainManager.multichain);
99
+ return !Batch.hasReadyItem(ChainMap.map(chainManager.chainFetchers, cf => cf.fetchState));
104
100
  }
105
101
 
106
- function createBatch(chainManager, batchSizeTarget, isRollback) {
107
- return Batch.make(chainManager.committedCheckpointId + (
102
+ function createBatch(chainManager, committedCheckpointId, batchSizeTarget, isRollback) {
103
+ return Batch.make(committedCheckpointId + (
108
104
  isRollback ? 1n : 0n
109
105
  ), ChainMap.map(chainManager.chainFetchers, cf => ({
110
106
  fetchState: cf.fetchState,
@@ -113,7 +109,7 @@ function createBatch(chainManager, batchSizeTarget, isRollback) {
113
109
  sourceBlockNumber: cf.fetchState.knownHeight,
114
110
  totalEventsProcessed: cf.numEventsProcessed,
115
111
  chainConfig: cf.chainConfig
116
- })), chainManager.multichain, batchSizeTarget);
112
+ })), batchSizeTarget);
117
113
  }
118
114
 
119
115
  function isProgressAtHead(chainManager) {
package/src/Config.res CHANGED
@@ -15,8 +15,6 @@ type contract = {
15
15
  addresses: array<Address.t>,
16
16
  events: array<Internal.eventConfig>,
17
17
  startBlock: option<int>,
18
- // EVM-specific: event sighashes for HyperSync queries
19
- eventSignatures: array<string>,
20
18
  }
21
19
 
22
20
  // Sources are instantiated lazily in ChainFetcher from this config.
@@ -56,10 +54,6 @@ type sourceSync = {
56
54
  pollingInterval: int,
57
55
  }
58
56
 
59
- type multichain = Internal.multichain =
60
- | @as("ordered") Ordered
61
- | @as("unordered") Unordered
62
-
63
57
  type storage = {
64
58
  postgres: bool,
65
59
  clickhouse: bool,
@@ -78,7 +72,6 @@ type t = {
78
72
  shouldRollbackOnReorg: bool,
79
73
  shouldSaveFullHistory: bool,
80
74
  storage: storage,
81
- multichain: multichain,
82
75
  chainMap: ChainMap.t<chain>,
83
76
  defaultChain: option<chain>,
84
77
  ecosystem: Ecosystem.t,
@@ -203,10 +196,9 @@ let publicConfigChainSchema = S.schema(s =>
203
196
 
204
197
  let contractEventItemSchema = S.schema(s =>
205
198
  {
206
- "event": s.matches(S.string),
207
199
  "name": s.matches(S.string),
208
200
  "sighash": s.matches(S.string),
209
- "params": s.matches(S.option(S.array(EventConfigBuilder.eventParamSchema))),
201
+ "params": s.matches(S.option(S.array(EventConfigBuilder.paramMetaSchema))),
210
202
  "kind": s.matches(S.option(S.string)),
211
203
  "blockFields": s.matches(S.option(S.array(Internal.evmBlockFieldSchema))),
212
204
  "transactionFields": s.matches(S.option(S.array(Internal.evmTransactionFieldSchema))),
@@ -241,8 +233,6 @@ let publicConfigEvmSchema = S.schema(s =>
241
233
  }
242
234
  )
243
235
 
244
- let multichainSchema = S.enum([Ordered, Unordered])
245
-
246
236
  let compositeIndexFieldSchema = S.schema(s =>
247
237
  {
248
238
  "fieldName": s.matches(S.string),
@@ -255,6 +245,7 @@ let derivedFieldSchema = S.schema(s =>
255
245
  "fieldName": s.matches(S.string),
256
246
  "derivedFromEntity": s.matches(S.string),
257
247
  "derivedFromField": s.matches(S.string),
248
+ "description": s.matches(S.option(S.string)),
258
249
  }
259
250
  )
260
251
 
@@ -270,6 +261,7 @@ let propertySchema = S.schema(s =>
270
261
  "entity": s.matches(S.option(S.string)),
271
262
  "precision": s.matches(S.option(S.int)),
272
263
  "scale": s.matches(S.option(S.int)),
264
+ "description": s.matches(S.option(S.string)),
273
265
  }
274
266
  )
275
267
 
@@ -287,6 +279,7 @@ let entityJsonSchema = S.schema(s =>
287
279
  "properties": s.matches(S.array(propertySchema)),
288
280
  "derivedFields": s.matches(S.option(S.array(derivedFieldSchema))),
289
281
  "compositeIndices": s.matches(S.option(S.array(S.array(compositeIndexFieldSchema)))),
282
+ "description": s.matches(S.option(S.string)),
290
283
  }
291
284
  )
292
285
 
@@ -379,6 +372,7 @@ let parseEntitiesFromJson = (
379
372
  ~isArray,
380
373
  ~isIndex,
381
374
  ~linkedEntity=?prop["linkedEntity"],
375
+ ~description=?prop["description"],
382
376
  )
383
377
  })
384
378
 
@@ -390,6 +384,7 @@ let parseEntitiesFromJson = (
390
384
  df["fieldName"],
391
385
  ~derivedFromEntity=df["derivedFromEntity"],
392
386
  ~derivedFromField=df["derivedFromField"],
387
+ ~description=?df["description"],
393
388
  )
394
389
  )
395
390
 
@@ -409,6 +404,7 @@ let parseEntitiesFromJson = (
409
404
  entityName,
410
405
  ~fields=Array.concat(fields, derivedFields),
411
406
  ~compositeIndices,
407
+ ~description=?entityJson["description"],
412
408
  )
413
409
 
414
410
  // Build schema dynamically from properties
@@ -470,7 +466,6 @@ let publicConfigSchema = S.schema(s =>
470
466
  "description": s.matches(S.option(S.string)),
471
467
  "handlers": s.matches(S.option(S.string)),
472
468
  "isDev": s.matches(S.option(S.bool)),
473
- "multichain": s.matches(S.option(multichainSchema)),
474
469
  "fullBatchSize": s.matches(S.option(S.int)),
475
470
  "rollbackOnReorg": s.matches(S.option(S.bool)),
476
471
  "saveFullHistory": s.matches(S.option(S.bool)),
@@ -544,12 +539,7 @@ let fromPublic = (publicConfigJson: JSON.t) => {
544
539
  | None => (Utils.Set.fromArray(EventConfigBuilder.alwaysIncludedBlockFields), Utils.Set.make())
545
540
  }
546
541
 
547
- // Build contract data lookup: ABI, event signatures, event configs (keyed by capitalized name)
548
- let contractDataByName: dict<{
549
- "abi": EvmTypes.Abi.t,
550
- "eventSignatures": array<string>,
551
- "events": option<array<_>>,
552
- }> = Dict.make()
542
+ let contractDataByName: dict<{"abi": EvmTypes.Abi.t, "events": option<array<_>>}> = Dict.make()
553
543
  switch publicContractsConfig {
554
544
  | Some(contractsDict) =>
555
545
  contractsDict
@@ -557,13 +547,9 @@ let fromPublic = (publicConfigJson: JSON.t) => {
557
547
  ->Array.forEach(((contractName, contractConfig)) => {
558
548
  let capitalizedName = contractName->Utils.String.capitalize
559
549
  let abi = contractConfig["abi"]->(Utils.magic: JSON.t => EvmTypes.Abi.t)
560
- let eventSignatures = switch contractConfig["events"] {
561
- | Some(events) => events->Array.map(eventItem => eventItem["event"])
562
- | None => []
563
- }
564
550
  contractDataByName->Dict.set(
565
551
  capitalizedName,
566
- {"abi": abi, "eventSignatures": eventSignatures, "events": contractConfig["events"]},
552
+ {"abi": abi, "events": contractConfig["events"]},
567
553
  )
568
554
  })
569
555
  | None => ()
@@ -691,7 +677,6 @@ let fromPublic = (publicConfigJson: JSON.t) => {
691
677
  addresses,
692
678
  events,
693
679
  startBlock,
694
- eventSignatures: contractData["eventSignatures"],
695
680
  }
696
681
  })
697
682
 
@@ -826,7 +811,6 @@ let fromPublic = (publicConfigJson: JSON.t) => {
826
811
  shouldRollbackOnReorg: publicConfig["rollbackOnReorg"]->Option.getOr(true),
827
812
  shouldSaveFullHistory: publicConfig["saveFullHistory"]->Option.getOr(false),
828
813
  storage: globalStorage,
829
- multichain: publicConfig["multichain"]->Option.getOr(Unordered),
830
814
  chainMap,
831
815
  defaultChain: chains->Array.get(0),
832
816
  enableRawEvents: publicConfig["rawEvents"]->Option.getOr(false),
@@ -44,12 +44,12 @@ let schema = S$RescriptSchema.schema(s => ({
44
44
  let rowsSchema = S$RescriptSchema.array(schema);
45
45
 
46
46
  let table = Table.mkTable(name, undefined, [
47
- Table.mkField("id", "String", S$RescriptSchema.string, undefined, undefined, undefined, true, undefined, undefined),
48
- Table.mkField("chain_id", "Int32", S$RescriptSchema.int, undefined, undefined, undefined, undefined, undefined, undefined),
49
- Table.mkField("registration_block", "Int32", S$RescriptSchema.int, undefined, undefined, undefined, undefined, undefined, undefined),
50
- Table.mkField("registration_log_index", "Int32", S$RescriptSchema.int, undefined, undefined, undefined, undefined, undefined, undefined),
51
- Table.mkField("contract_name", "String", S$RescriptSchema.string, undefined, undefined, undefined, undefined, undefined, undefined)
52
- ]);
47
+ Table.mkField("id", "String", S$RescriptSchema.string, undefined, undefined, undefined, true, undefined, undefined, undefined),
48
+ Table.mkField("chain_id", "Int32", S$RescriptSchema.int, undefined, undefined, undefined, undefined, undefined, undefined, undefined),
49
+ Table.mkField("registration_block", "Int32", S$RescriptSchema.int, undefined, undefined, undefined, undefined, undefined, undefined, undefined),
50
+ Table.mkField("registration_log_index", "Int32", S$RescriptSchema.int, undefined, undefined, undefined, undefined, undefined, undefined, undefined),
51
+ Table.mkField("contract_name", "String", S$RescriptSchema.string, undefined, undefined, undefined, undefined, undefined, undefined, undefined)
52
+ ], undefined);
53
53
 
54
54
  let entityConfig_storage = {
55
55
  postgres: true,
@@ -114,10 +114,9 @@ let publicConfigChainSchema = S$RescriptSchema.schema(s => ({
114
114
  }));
115
115
 
116
116
  let contractEventItemSchema = S$RescriptSchema.schema(s => ({
117
- event: s.m(S$RescriptSchema.string),
118
117
  name: s.m(S$RescriptSchema.string),
119
118
  sighash: s.m(S$RescriptSchema.string),
120
- params: s.m(S$RescriptSchema.option(S$RescriptSchema.array(EventConfigBuilder.eventParamSchema))),
119
+ params: s.m(S$RescriptSchema.option(S$RescriptSchema.array(EventConfigBuilder.paramMetaSchema))),
121
120
  kind: s.m(S$RescriptSchema.option(S$RescriptSchema.string)),
122
121
  blockFields: s.m(S$RescriptSchema.option(S$RescriptSchema.array(Internal.evmBlockFieldSchema))),
123
122
  transactionFields: s.m(S$RescriptSchema.option(S$RescriptSchema.array(Internal.evmTransactionFieldSchema)))
@@ -145,11 +144,6 @@ let publicConfigEvmSchema = S$RescriptSchema.schema(s => ({
145
144
  globalTransactionFields: s.m(S$RescriptSchema.option(S$RescriptSchema.array(Internal.evmTransactionFieldSchema)))
146
145
  }));
147
146
 
148
- let multichainSchema = S$RescriptSchema.$$enum([
149
- "ordered",
150
- "unordered"
151
- ]);
152
-
153
147
  let compositeIndexFieldSchema = S$RescriptSchema.schema(s => ({
154
148
  fieldName: s.m(S$RescriptSchema.string),
155
149
  direction: s.m(S$RescriptSchema.string)
@@ -158,7 +152,8 @@ let compositeIndexFieldSchema = S$RescriptSchema.schema(s => ({
158
152
  let derivedFieldSchema = S$RescriptSchema.schema(s => ({
159
153
  fieldName: s.m(S$RescriptSchema.string),
160
154
  derivedFromEntity: s.m(S$RescriptSchema.string),
161
- derivedFromField: s.m(S$RescriptSchema.string)
155
+ derivedFromField: s.m(S$RescriptSchema.string),
156
+ description: s.m(S$RescriptSchema.option(S$RescriptSchema.string))
162
157
  }));
163
158
 
164
159
  let propertySchema = S$RescriptSchema.schema(s => ({
@@ -171,7 +166,8 @@ let propertySchema = S$RescriptSchema.schema(s => ({
171
166
  enum: s.m(S$RescriptSchema.option(S$RescriptSchema.string)),
172
167
  entity: s.m(S$RescriptSchema.option(S$RescriptSchema.string)),
173
168
  precision: s.m(S$RescriptSchema.option(S$RescriptSchema.int)),
174
- scale: s.m(S$RescriptSchema.option(S$RescriptSchema.int))
169
+ scale: s.m(S$RescriptSchema.option(S$RescriptSchema.int)),
170
+ description: s.m(S$RescriptSchema.option(S$RescriptSchema.string))
175
171
  }));
176
172
 
177
173
  let entityStorageSchema = S$RescriptSchema.schema(s => ({
@@ -184,7 +180,8 @@ let entityJsonSchema = S$RescriptSchema.schema(s => ({
184
180
  storage: s.m(S$RescriptSchema.option(entityStorageSchema)),
185
181
  properties: s.m(S$RescriptSchema.array(propertySchema)),
186
182
  derivedFields: s.m(S$RescriptSchema.option(S$RescriptSchema.array(derivedFieldSchema))),
187
- compositeIndices: s.m(S$RescriptSchema.option(S$RescriptSchema.array(S$RescriptSchema.array(compositeIndexFieldSchema))))
183
+ compositeIndices: s.m(S$RescriptSchema.option(S$RescriptSchema.array(S$RescriptSchema.array(compositeIndexFieldSchema)))),
184
+ description: s.m(S$RescriptSchema.option(S$RescriptSchema.string))
188
185
  }));
189
186
 
190
187
  function getFieldTypeAndSchema(prop, enumConfigsByName) {
@@ -302,14 +299,14 @@ function parseEntitiesFromJson(entitiesJson, enumConfigsByName, globalStorage) {
302
299
  let entityName = entityJson.name;
303
300
  let fields = entityJson.properties.map(prop => {
304
301
  let match = getFieldTypeAndSchema(prop, enumConfigsByName);
305
- return Table.mkField(prop.name, match[0], match[1], undefined, match[3], match[2], prop.name === "id", match[4], prop.linkedEntity);
302
+ return Table.mkField(prop.name, match[0], match[1], undefined, match[3], match[2], prop.name === "id", match[4], prop.linkedEntity, prop.description);
306
303
  });
307
- let derivedFields = Stdlib_Option.getOr(entityJson.derivedFields, []).map(df => Table.mkDerivedFromField(df.fieldName, df.derivedFromEntity, df.derivedFromField));
304
+ let derivedFields = Stdlib_Option.getOr(entityJson.derivedFields, []).map(df => Table.mkDerivedFromField(df.fieldName, df.derivedFromEntity, df.derivedFromField, df.description));
308
305
  let compositeIndices = Stdlib_Option.getOr(entityJson.compositeIndices, []).map(ci => ci.map(f => ({
309
306
  fieldName: f.fieldName,
310
307
  direction: f.direction === "Asc" ? "Asc" : "Desc"
311
308
  })));
312
- let table = Table.mkTable(entityName, compositeIndices, fields.concat(derivedFields));
309
+ let table = Table.mkTable(entityName, compositeIndices, fields.concat(derivedFields), entityJson.description);
313
310
  let schema = S$RescriptSchema.schema(s => {
314
311
  let dict = {};
315
312
  entityJson.properties.forEach(prop => {
@@ -355,7 +352,6 @@ let publicConfigSchema = S$RescriptSchema.schema(s => ({
355
352
  description: s.m(S$RescriptSchema.option(S$RescriptSchema.string)),
356
353
  handlers: s.m(S$RescriptSchema.option(S$RescriptSchema.string)),
357
354
  isDev: s.m(S$RescriptSchema.option(S$RescriptSchema.bool)),
358
- multichain: s.m(S$RescriptSchema.option(multichainSchema)),
359
355
  fullBatchSize: s.m(S$RescriptSchema.option(S$RescriptSchema.int)),
360
356
  rollbackOnReorg: s.m(S$RescriptSchema.option(S$RescriptSchema.bool)),
361
357
  saveFullHistory: s.m(S$RescriptSchema.option(S$RescriptSchema.bool)),
@@ -453,11 +449,8 @@ function fromPublic(publicConfigJson) {
453
449
  let contractConfig = param[1];
454
450
  let capitalizedName = Utils.$$String.capitalize(param[0]);
455
451
  let abi = contractConfig.abi;
456
- let events = contractConfig.events;
457
- let eventSignatures = events !== undefined ? events.map(eventItem => eventItem.event) : [];
458
452
  contractDataByName[capitalizedName] = {
459
453
  abi: abi,
460
- eventSignatures: eventSignatures,
461
454
  events: contractConfig.events
462
455
  };
463
456
  });
@@ -525,8 +518,7 @@ function fromPublic(publicConfigJson) {
525
518
  abi: contractData.abi,
526
519
  addresses: addresses,
527
520
  events: events,
528
- startBlock: startBlock,
529
- eventSignatures: contractData.eventSignatures
521
+ startBlock: startBlock
530
522
  };
531
523
  });
532
524
  let sourceConfig;
@@ -634,7 +626,6 @@ function fromPublic(publicConfigJson) {
634
626
  shouldRollbackOnReorg: Stdlib_Option.getOr(publicConfig.rollbackOnReorg, true),
635
627
  shouldSaveFullHistory: Stdlib_Option.getOr(publicConfig.saveFullHistory, false),
636
628
  storage: globalStorage,
637
- multichain: Stdlib_Option.getOr(publicConfig.multichain, "unordered"),
638
629
  chainMap: chainMap,
639
630
  defaultChain: chains[0],
640
631
  ecosystem: ecosystem,
@@ -943,7 +934,6 @@ export {
943
934
  contractConfigSchema,
944
935
  publicConfigEcosystemSchema,
945
936
  publicConfigEvmSchema,
946
- multichainSchema,
947
937
  compositeIndexFieldSchema,
948
938
  derivedFieldSchema,
949
939
  propertySchema,
package/src/Core.res CHANGED
@@ -4,9 +4,16 @@
4
4
 
5
5
  // NAPI encodes Rust `Option<T>` as `null | T` (never `undefined`), so the
6
6
  // tighter `Null.t` captures the exact boundary shape.
7
+ type hypersyncClientCtor
8
+ type decoderCtor
9
+
7
10
  type addon = {
8
11
  getConfigJson: (~configPath: Null.t<string>, ~directory: Null.t<string>) => string,
9
12
  runCli: (~args: array<string>, ~envioPackageDir: Null.t<string>) => promise<Null.t<string>>,
13
+ @as("HypersyncClient")
14
+ hypersyncClient: hypersyncClientCtor,
15
+ @as("Decoder")
16
+ decoder: decoderCtor,
10
17
  }
11
18
 
12
19
  @module("node:module") external createRequire: string => {..} = "createRequire"
package/src/Ctx.res CHANGED
@@ -2,4 +2,5 @@ type t = {
2
2
  registrations: HandlerRegister.registrations,
3
3
  config: Config.t,
4
4
  persistence: Persistence.t,
5
+ inMemoryStore: InMemoryStore.t,
5
6
  }
package/src/Env.res CHANGED
@@ -66,7 +66,6 @@ let hypersyncClientEnableQueryCaching =
66
66
 
67
67
  let hypersyncLogLevel =
68
68
  envSafe->EnvSafe.get("ENVIO_HYPERSYNC_LOG_LEVEL", HyperSyncClient.logLevelSchema, ~fallback=#info)
69
- HyperSyncClient.setLogLevel(hypersyncLogLevel)
70
69
 
71
70
  let logStrategy =
72
71
  envSafe->EnvSafe.get(
package/src/Env.res.mjs CHANGED
@@ -7,7 +7,6 @@ import * as Belt_Option from "@rescript/runtime/lib/es6/Belt_Option.js";
7
7
  import * as Stdlib_JsError from "@rescript/runtime/lib/es6/Stdlib_JsError.js";
8
8
  import * as HyperSyncClient from "./sources/HyperSyncClient.res.mjs";
9
9
  import * as S$RescriptSchema from "rescript-schema/src/S.res.mjs";
10
- import * as HypersyncClient from "@envio-dev/hypersync-client";
11
10
 
12
11
  import 'dotenv/config'
13
12
  ;
@@ -62,8 +61,6 @@ let hypersyncClientEnableQueryCaching = EnvSafe.get(envSafe, "ENVIO_HYPERSYNC_CL
62
61
 
63
62
  let hypersyncLogLevel = EnvSafe.get(envSafe, "ENVIO_HYPERSYNC_LOG_LEVEL", HyperSyncClient.logLevelSchema, undefined, "info", undefined, undefined);
64
63
 
65
- HypersyncClient.setLogLevel(hypersyncLogLevel);
66
-
67
64
  let logStrategy = EnvSafe.get(envSafe, "LOG_STRATEGY", S$RescriptSchema.$$enum([
68
65
  "ecs-file",
69
66
  "ecs-console",