envio 3.0.1 → 3.0.2-svm-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.
Files changed (43) hide show
  1. package/evm.schema.json +8 -8
  2. package/fuel.schema.json +12 -12
  3. package/index.d.ts +167 -1
  4. package/package.json +6 -7
  5. package/src/ChainFetcher.res +25 -1
  6. package/src/ChainFetcher.res.mjs +19 -1
  7. package/src/Config.res +158 -94
  8. package/src/Config.res.mjs +60 -97
  9. package/src/Core.res +32 -0
  10. package/src/Env.res.mjs +1 -2
  11. package/src/Envio.res +103 -0
  12. package/src/EventConfigBuilder.res +52 -0
  13. package/src/EventConfigBuilder.res.mjs +32 -0
  14. package/src/HandlerLoader.res +12 -1
  15. package/src/HandlerLoader.res.mjs +6 -1
  16. package/src/Hasura.res +43 -0
  17. package/src/Hasura.res.mjs +38 -0
  18. package/src/Internal.res +39 -0
  19. package/src/Main.res +53 -3
  20. package/src/Main.res.mjs +34 -2
  21. package/src/Persistence.res +2 -17
  22. package/src/Persistence.res.mjs +2 -14
  23. package/src/SimulateItems.res +23 -10
  24. package/src/SimulateItems.res.mjs +21 -6
  25. package/src/SvmTypes.res +9 -0
  26. package/src/SvmTypes.res.mjs +14 -0
  27. package/src/sources/EventRouter.res +65 -0
  28. package/src/sources/EventRouter.res.mjs +43 -0
  29. package/src/sources/HyperSyncClient.res +30 -157
  30. package/src/sources/HyperSyncClient.res.mjs +20 -6
  31. package/src/sources/HyperSyncSolanaClient.res +249 -0
  32. package/src/sources/HyperSyncSolanaClient.res.mjs +25 -0
  33. package/src/sources/HyperSyncSolanaSource.res +566 -0
  34. package/src/sources/HyperSyncSolanaSource.res.mjs +488 -0
  35. package/src/sources/HyperSyncSource.res +5 -8
  36. package/src/sources/HyperSyncSource.res.mjs +1 -8
  37. package/src/sources/RpcSource.res.mjs +1 -1
  38. package/src/sources/Svm.res +2 -2
  39. package/src/sources/Svm.res.mjs +3 -2
  40. package/src/tui/Tui.res +9 -2
  41. package/src/tui/Tui.res.mjs +19 -4
  42. package/src/tui/components/TuiData.res +3 -0
  43. package/svm.schema.json +352 -4
@@ -27,7 +27,7 @@ function make(userEntities, allEnums, storage) {
27
27
  };
28
28
  }
29
29
 
30
- async function init(persistence, chainConfigs, envioInfo, resetCommand, runCommand, resetOpt) {
30
+ async function init(persistence, chainConfigs, envioInfo, resetCommand, resetOpt) {
31
31
  let reset = resetOpt !== undefined ? resetOpt : false;
32
32
  try {
33
33
  let promise = persistence.storageStatus;
@@ -70,19 +70,7 @@ async function init(persistence, chainConfigs, envioInfo, resetCommand, runComma
70
70
  let initialState$1 = await persistence.storage.resumeInitialState();
71
71
  let stored = initialState$1.envioInfo;
72
72
  let changedPaths = stored !== undefined ? Config.diffPaths(stored, envioInfo) : ["envio info is missing — storage initialized by an older envio"];
73
- let hasClickhouse;
74
- if (typeof envioInfo === "object" && envioInfo !== null && !Array.isArray(envioInfo)) {
75
- let match$1 = envioInfo["storage"];
76
- if (typeof match$1 === "object" && match$1 !== null && !Array.isArray(match$1)) {
77
- let match$2 = match$1["clickhouse"];
78
- hasClickhouse = match$2 === true;
79
- } else {
80
- hasClickhouse = false;
81
- }
82
- } else {
83
- hasClickhouse = false;
84
- }
85
- Config.throwIfIncompatible(changedPaths, resetCommand, runCommand, hasClickhouse);
73
+ Config.throwIfIncompatible(changedPaths, resetCommand);
86
74
  persistence.storageStatus = {
87
75
  TAG: "Ready",
88
76
  _0: initialState$1
@@ -320,21 +320,34 @@ let patchConfig = (~config: Config.t, ~processConfig: JSON.t): Config.t => {
320
320
  let chainIdStr = chain->ChainMap.Chain.toChainId->Int.toString
321
321
  switch chainsDict->Dict.get(chainIdStr) {
322
322
  | Some(processChainJson) =>
323
- let simulateRaw: option<array<JSON.t>> =
324
- (processChainJson->(Utils.magic: JSON.t => {..}))["simulate"]->Nullable.toOption
323
+ let raw = processChainJson->(Utils.magic: JSON.t => {..})
324
+ let simulateRaw: option<array<JSON.t>> = raw["simulate"]->Nullable.toOption
325
325
  switch simulateRaw {
326
326
  | Some(simulateItems) =>
327
327
  let items = parse(~simulateItems, ~config, ~chainConfig)
328
- // Use endBlock from processConfig (the user-specified range)
329
- let startBlock: int =
330
- (processChainJson->(Utils.magic: JSON.t => {..}))["startBlock"]->(
331
- Utils.magic: 'a => int
332
- )
333
- let endBlock: int =
334
- (processChainJson->(Utils.magic: JSON.t => {..}))["endBlock"]->(Utils.magic: 'a => int)
328
+ let startBlock: int = raw["startBlock"]->(Utils.magic: 'a => int)
329
+ let endBlock: int = raw["endBlock"]->(Utils.magic: 'a => int)
335
330
  let source = SimulateSource.make(~items, ~endBlock, ~chain)
336
331
  {...chainConfig, startBlock, endBlock, sourceConfig: Config.CustomSources([source])}
337
- | None => chainConfig
332
+ | None =>
333
+ // No simulate items: still honor `startBlock` / `endBlock` overrides
334
+ // so non-EVM/Fuel ecosystems (notably SVM `indexer.onInstruction`,
335
+ // which doesn't support simulate items) can bound the run window
336
+ // via `testIndexer.process({chains: { id: {startBlock, endBlock} }})`.
337
+ let startBlockOpt: option<int> =
338
+ raw["startBlock"]
339
+ ->(Utils.magic: 'a => Nullable.t<int>)
340
+ ->Nullable.toOption
341
+ let endBlockOpt: option<int> =
342
+ raw["endBlock"]->(Utils.magic: 'a => Nullable.t<int>)->Nullable.toOption
343
+ let withStart = switch startBlockOpt {
344
+ | Some(sb) => {...chainConfig, startBlock: sb}
345
+ | None => chainConfig
346
+ }
347
+ switch endBlockOpt {
348
+ | Some(eb) => {...withStart, endBlock: eb}
349
+ | None => withStart
350
+ }
338
351
  }
339
352
  | None => chainConfig
340
353
  }
@@ -266,20 +266,35 @@ function patchConfig(config, processConfig) {
266
266
  }
267
267
  let simulateRaw = processChainJson.simulate;
268
268
  if (simulateRaw == null) {
269
- return chainConfig;
269
+ let startBlockOpt = processChainJson.startBlock;
270
+ let endBlockOpt = processChainJson.endBlock;
271
+ let withStart;
272
+ if (startBlockOpt == null) {
273
+ withStart = chainConfig;
274
+ } else {
275
+ let newrecord = {...chainConfig};
276
+ newrecord.startBlock = startBlockOpt;
277
+ withStart = newrecord;
278
+ }
279
+ if (endBlockOpt == null) {
280
+ return withStart;
281
+ }
282
+ let newrecord$1 = {...withStart};
283
+ newrecord$1.endBlock = endBlockOpt;
284
+ return newrecord$1;
270
285
  }
271
286
  let items = parse(simulateRaw, config, chainConfig);
272
287
  let startBlock = processChainJson.startBlock;
273
288
  let endBlock = processChainJson.endBlock;
274
289
  let source = SimulateSource.make(items, endBlock, chain);
275
- let newrecord = {...chainConfig};
276
- newrecord.sourceConfig = {
290
+ let newrecord$2 = {...chainConfig};
291
+ newrecord$2.sourceConfig = {
277
292
  TAG: "CustomSources",
278
293
  _0: [source]
279
294
  };
280
- newrecord.endBlock = endBlock;
281
- newrecord.startBlock = startBlock;
282
- return newrecord;
295
+ newrecord$2.endBlock = endBlock;
296
+ newrecord$2.startBlock = startBlock;
297
+ return newrecord$2;
283
298
  });
284
299
  let newrecord = {...config};
285
300
  newrecord.chainMap = newChainMap;
@@ -0,0 +1,9 @@
1
+ module Pubkey = {
2
+ type t
3
+ let schema =
4
+ S.string->S.setName("SVM.Pubkey")->(Utils.magic: S.t<string> => S.t<t>)
5
+ external fromStringUnsafe: string => t = "%identity"
6
+ external fromStringsUnsafe: array<string> => array<t> = "%identity"
7
+ external toString: t => string = "%identity"
8
+ external toStrings: array<t> => array<string> = "%identity"
9
+ }
@@ -0,0 +1,14 @@
1
+ // Generated by ReScript, PLEASE EDIT WITH CARE
2
+
3
+ import * as S$RescriptSchema from "rescript-schema/src/S.res.mjs";
4
+
5
+ let schema = S$RescriptSchema.setName(S$RescriptSchema.string, "SVM.Pubkey");
6
+
7
+ let Pubkey = {
8
+ schema: schema
9
+ };
10
+
11
+ export {
12
+ Pubkey,
13
+ }
14
+ /* schema Not a pure module */
@@ -116,3 +116,68 @@ let fromEvmEventModsOrThrow = (events: array<Internal.evmEventConfig>, ~chain):
116
116
  })
117
117
  router
118
118
  }
119
+
120
+ /** Dispatch key for SVM instructions. `None` matches any instruction in the
121
+ program (lowest priority). */
122
+ let getSvmEventId = (~programId: SvmTypes.Pubkey.t, ~discriminator: option<string>) =>
123
+ switch discriminator {
124
+ | None => (programId->SvmTypes.Pubkey.toString) ++ "_none"
125
+ | Some(d) => (programId->SvmTypes.Pubkey.toString) ++ "_" ++ d
126
+ }
127
+
128
+ /** Discriminator byte-lengths declared by a program, sorted descending. The
129
+ source uses this to probe `(programId, dN)` keys longest-first when routing
130
+ a returned instruction to a handler — matching the locked Q1 answer. */
131
+ type svmProgramOrdering = {
132
+ programId: SvmTypes.Pubkey.t,
133
+ /** Byte lengths in descending order, deduplicated. Includes `0` only when
134
+ a handler is registered with no discriminator (program-wide match). */
135
+ byteLengthsDesc: array<int>,
136
+ }
137
+
138
+ let fromSvmEventConfigsOrThrow = (
139
+ events: array<Internal.svmInstructionEventConfig>,
140
+ ~chain,
141
+ ): (t<Internal.svmInstructionEventConfig>, array<svmProgramOrdering>) => {
142
+ let router = empty()
143
+ events->Belt.Array.forEach(config => {
144
+ // The router tag must include the programId so two programs declaring the
145
+ // same discriminator coexist. The source-side lookup uses the same shape
146
+ // via `getSvmEventId(~programId, ~discriminator)`.
147
+ let routerTag = getSvmEventId(~programId=config.programId, ~discriminator=config.discriminator)
148
+ router->addOrThrow(
149
+ routerTag,
150
+ config,
151
+ ~contractName=config.contractName,
152
+ ~eventName=config.name,
153
+ ~chain,
154
+ ~isWildcard=config.isWildcard,
155
+ )
156
+ })
157
+
158
+ // Per-program list of declared discriminator byte lengths, sorted desc.
159
+ let byProgram: dict<Utils.Set.t<int>> = Dict.make()
160
+ events->Belt.Array.forEach(config => {
161
+ let key = config.programId->SvmTypes.Pubkey.toString
162
+ let set = switch byProgram->Utils.Dict.dangerouslyGetNonOption(key) {
163
+ | Some(s) => s
164
+ | None =>
165
+ let s = Utils.Set.make()
166
+ byProgram->Dict.set(key, s)
167
+ s
168
+ }
169
+ let _ = set->Utils.Set.add(config.discriminatorByteLen)
170
+ })
171
+ let ordering =
172
+ byProgram
173
+ ->Dict.toArray
174
+ ->Array.map(((programIdString, lens)) => {
175
+ let sorted = lens->Utils.Set.toArray->Array.toSorted((a, b) => (b - a)->Int.toFloat)
176
+ {
177
+ programId: programIdString->SvmTypes.Pubkey.fromStringUnsafe,
178
+ byteLengthsDesc: sorted,
179
+ }
180
+ })
181
+
182
+ (router, ordering)
183
+ }
@@ -111,6 +111,47 @@ function fromEvmEventModsOrThrow(events, chain) {
111
111
  return router;
112
112
  }
113
113
 
114
+ function getSvmEventId(programId, discriminator) {
115
+ if (discriminator !== undefined) {
116
+ return programId + "_" + discriminator;
117
+ } else {
118
+ return programId + "_none";
119
+ }
120
+ }
121
+
122
+ function fromSvmEventConfigsOrThrow(events, chain) {
123
+ let router = {};
124
+ Belt_Array.forEach(events, config => {
125
+ let routerTag = getSvmEventId(config.programId, config.discriminator);
126
+ addOrThrow$1(router, routerTag, config, config.contractName, config.isWildcard, config.name, chain);
127
+ });
128
+ let byProgram = {};
129
+ Belt_Array.forEach(events, config => {
130
+ let key = config.programId;
131
+ let s = byProgram[key];
132
+ let set;
133
+ if (s !== undefined) {
134
+ set = Primitive_option.valFromOption(s);
135
+ } else {
136
+ let s$1 = new Set();
137
+ byProgram[key] = s$1;
138
+ set = s$1;
139
+ }
140
+ set.add(config.discriminatorByteLen);
141
+ });
142
+ let ordering = Object.entries(byProgram).map(param => {
143
+ let sorted = Array.from(param[1]).toSorted((a, b) => b - a | 0);
144
+ return {
145
+ programId: param[0],
146
+ byteLengthsDesc: sorted
147
+ };
148
+ });
149
+ return [
150
+ router,
151
+ ordering
152
+ ];
153
+ }
154
+
114
155
  export {
115
156
  EventDuplicate,
116
157
  WildcardCollision,
@@ -120,5 +161,7 @@ export {
120
161
  get$1 as get,
121
162
  getEvmEventId,
122
163
  fromEvmEventModsOrThrow,
164
+ getSvmEventId,
165
+ fromSvmEventConfigsOrThrow,
123
166
  }
124
167
  /* ChainMap Not a pure module */
@@ -155,41 +155,18 @@ module QueryTypes = {
155
155
  )
156
156
 
157
157
  type logFilter = {
158
- /**
159
- * Address of the contract, any logs that has any of these addresses will be returned.
160
- * Empty means match all.
161
- */
162
158
  address?: array<Address.t>,
163
- /**
164
- * Topics to match, each member of the top level array is another array, if the nth topic matches any
165
- * topic specified in topics[n] the log will be returned. Empty means match all.
166
- */
167
159
  topics: topicSelection,
168
160
  }
169
161
 
170
162
  let makeLogSelection = (~address, ~topics) => {address, topics}
171
163
 
172
164
  type transactionFilter = {
173
- /**
174
- * Address the transaction should originate from. If transaction.from matches any of these, the transaction
175
- * will be returned. Keep in mind that this has an and relationship with to filter, so each transaction should
176
- * match both of them. Empty means match all.
177
- */
178
165
  from?: array<Address.t>,
179
- /**
180
- * Address the transaction should go to. If transaction.to matches any of these, the transaction will
181
- * be returned. Keep in mind that this has an and relationship with from filter, so each transaction should
182
- * match both of them. Empty means match all.
183
- */
184
- @as("to")
185
- to_?: array<Address.t>,
186
- /** If first 4 bytes of transaction input matches any of these, transaction will be returned. Empty means match all. */
166
+ @as("to") to_?: array<Address.t>,
187
167
  sighash?: array<string>,
188
- /** If tx.status matches this it will be returned. */
189
168
  status?: int,
190
- /** If transaction.type matches any of these values, the transaction will be returned */
191
- @as("type")
192
- type_?: array<int>,
169
+ @as("type") type_?: array<int>,
193
170
  contractAddress?: array<Address.t>,
194
171
  }
195
172
 
@@ -199,94 +176,30 @@ module QueryTypes = {
199
176
  address?: array<Address.t>,
200
177
  callType?: array<string>,
201
178
  rewardType?: array<string>,
202
- @as("type")
203
- type_?: array<string>,
179
+ @as("type") type_?: array<string>,
204
180
  sighash?: array<string>,
205
181
  }
206
182
 
207
183
  type blockSelection = {
208
- /**
209
- * Hash of a block, any blocks that have one of these hashes will be returned.
210
- * Empty means match all.
211
- */
212
184
  hash?: array<string>,
213
- /**
214
- * Miner address of a block, any blocks that have one of these miners will be returned.
215
- * Empty means match all.
216
- */
217
185
  miner?: array<Address.t>,
218
186
  }
219
187
 
220
188
  type joinMode = | @as(0) Default | @as(1) JoinAll | @as(2) JoinNothing
221
189
 
222
190
  type query = {
223
- /** The block to start the query from */
224
191
  fromBlock: int,
225
- /**
226
- * The block to end the query at. If not specified, the query will go until the
227
- * end of data. Exclusive, the returned range will be [from_block..to_block).
228
- *
229
- * The query will return before it reaches this target block if it hits the time limit
230
- * configured on the server. The user should continue their query by putting the
231
- * next_block field in the response into from_block field of their next query. This implements
232
- * pagination.
233
- */
234
- @as("toBlock")
235
- toBlockExclusive?: int,
236
- /**
237
- * List of log selections, these have an or relationship between them, so the query will return logs
238
- * that match any of these selections.
239
- */
192
+ @as("toBlock") toBlockExclusive?: int,
240
193
  logs?: array<logFilter>,
241
- /**
242
- * List of transaction selections, the query will return transactions that match any of these selections and
243
- * it will return transactions that are related to the returned logs.
244
- */
245
194
  transactions?: array<transactionFilter>,
246
- /**
247
- * List of trace selections, the query will return traces that match any of these selections and
248
- * it will re turn traces that are related to the returned logs.
249
- */
250
195
  traces?: array<traceSelection>,
251
- /** List of block selections, the query will return blocks that match any of these selections */
252
196
  blocks?: array<blockSelection>,
253
- /**
254
- * Field selection. The user can select which fields they are interested in, requesting less fields will improve
255
- * query execution time and reduce the payload size so the user should always use a minimal number of fields.
256
- */
257
197
  fieldSelection: fieldSelection,
258
- /**
259
- * Maximum number of blocks that should be returned, the server might return more blocks than this number but
260
- * it won't overshoot by too much.
261
- */
262
198
  maxNumBlocks?: int,
263
- /**
264
- * Maximum number of transactions that should be returned, the server might return more transactions than this number but
265
- * it won't overshoot by too much.
266
- */
267
199
  maxNumTransactions?: int,
268
- /**
269
- * Maximum number of logs that should be returned, the server might return more logs than this number but
270
- * it won't overshoot by too much.
271
- */
272
200
  maxNumLogs?: int,
273
- /**
274
- * Maximum number of traces that should be returned, the server might return more traces than this number but
275
- * it won't overshoot by too much.
276
- */
277
201
  maxNumTraces?: int,
278
- /**
279
- * Selects join mode for the query,
280
- * Default: join in this order logs -> transactions -> traces -> blocks
281
- * JoinAll: join everything to everything. For example if logSelection matches log0, we get the
282
- * associated transaction of log0 and then we get associated logs of that transaction as well. Applites similarly
283
- * to blocks, traces.
284
- * JoinNothing: join nothing.
285
- */
286
202
  joinMode?: joinMode,
287
- /**
288
- * If set to true, the server will return data for all blocks in the requested range [from_block, to_block).
289
- */
290
203
  includeAllBlocks?: bool,
291
204
  }
292
205
  }
@@ -385,8 +298,7 @@ module ResponseTypes = {
385
298
  gasUsed?: bigint,
386
299
  contractAddress?: string,
387
300
  logsBloom?: string,
388
- @as("type")
389
- type_?: int,
301
+ @as("type") type_?: int,
390
302
  root?: string,
391
303
  status?: int,
392
304
  l1Fee?: bigint,
@@ -416,40 +328,18 @@ module ResponseTypes = {
416
328
  }
417
329
 
418
330
  type rollbackGuard = {
419
- /** Block number of the last scanned block */
420
331
  blockNumber: int,
421
- /** Block timestamp of the last scanned block */
422
332
  timestamp: int,
423
- /** Block hash of the last scanned block */
424
333
  hash: string,
425
- /**
426
- * Block number of the first scanned block in memory.
427
- *
428
- * This might not be the first scanned block. It only includes blocks that are in memory (possible to be rolled back).
429
- */
430
334
  firstBlockNumber: int,
431
- /**
432
- * Parent hash of the first scanned block in memory.
433
- *
434
- * This might not be the first scanned block. It only includes blocks that are in memory (possible to be rolled back).
435
- */
436
335
  firstParentHash: string,
437
336
  }
438
337
 
439
338
  type eventResponse = {
440
- /** Current height of the source hypersync instance */
441
339
  archiveHeight: option<int>,
442
- /**
443
- * Next block to query for, the responses are paginated so,
444
- * the caller should continue the query from this block if they
445
- * didn't get responses up to the to_block they specified in the Query.
446
- */
447
340
  nextBlock: int,
448
- /** Total time it took the hypersync instance to execute the query. */
449
341
  totalExecutionTime: int,
450
- /** Response data */
451
342
  data: array<event>,
452
- /** Rollback guard, supposed to be used to detect rollbacks */
453
343
  rollbackGuard: option<rollbackGuard>,
454
344
  }
455
345
  }
@@ -471,40 +361,16 @@ type queryResponse = {
471
361
  rollbackGuard: option<ResponseTypes.rollbackGuard>,
472
362
  }
473
363
 
474
- //Todo, add bindings for these types
475
- type streamConfig
476
- type queryResponseStream
477
- type eventStream
478
-
479
- @tag("type")
480
- type heightStreamEvent =
481
- | Height({height: int})
482
- | Connected
483
- | Reconnecting({delayMillis: int, errorMsg: string})
484
-
485
- module HeightStream = {
486
- type t = {
487
- /** Close the height stream */
488
- close: unit => promise<unit>,
489
- /** Receive the next height stream event from the stream */
490
- recv: unit => promise<heightStreamEvent>,
491
- }
492
- }
493
-
494
364
  type t = {
495
- getHeight: unit => promise<int>,
496
- collect: (~query: query, ~config: streamConfig) => promise<queryResponse>,
497
- collectEvents: (~query: query, ~config: streamConfig) => promise<eventResponse>,
498
- collectParquet: (~path: string, ~query: query, ~config: streamConfig) => promise<unit>,
499
365
  get: (~query: query) => promise<queryResponse>,
500
366
  getEvents: (~query: query) => promise<eventResponse>,
501
- stream: (~query: query, ~config: streamConfig) => promise<queryResponseStream>,
502
- streamEvents: (~query: query, ~config: streamConfig) => promise<eventStream>,
503
- streamHeight: unit => promise<HeightStream.t>,
504
367
  }
505
368
 
506
- @module("@envio-dev/hypersync-client") @scope("HypersyncClient")
507
- external makeWithAgent: (cfg, ~userAgent: string) => t = "newWithAgent"
369
+ @send
370
+ external classNewWithAgent: (Core.hypersyncClientCtor, cfg, string) => t = "newWithAgent"
371
+
372
+ let makeWithAgent = (cfg, ~userAgent) =>
373
+ Core.getAddon().hypersyncClient->classNewWithAgent(cfg, userAgent)
508
374
 
509
375
  let make = (
510
376
  ~url,
@@ -540,11 +406,19 @@ type logLevel = [#trace | #debug | #info | #warn | #error]
540
406
  let logLevelSchema: S.t<logLevel> = S.enum([#trace, #debug, #info, #warn, #error])
541
407
 
542
408
  /**
543
- * Set the log level for the underlying Rust logger in hypersync-client.
409
+ * Set the log level for the underlying Rust logger.
544
410
  * Must be called before creating any HypersyncClient.
545
411
  */
546
- @module("@envio-dev/hypersync-client")
547
- external setLogLevel: logLevel => unit = "setLogLevel"
412
+ let setLogLevel = (level: logLevel) => {
413
+ let s = switch level {
414
+ | #trace => "trace"
415
+ | #debug => "debug"
416
+ | #info => "info"
417
+ | #warn => "warn"
418
+ | #error => "error"
419
+ }
420
+ Core.getAddon().setLogLevel(s)
421
+ }
548
422
 
549
423
  module Decoder = {
550
424
  type rec decodedSolType<'a> = {val: 'a}
@@ -579,18 +453,17 @@ module Decoder = {
579
453
  body: array<decodedRaw>,
580
454
  }
581
455
 
582
- type log
583
456
  type t = {
584
- enableChecksummedAddresses: unit => unit,
585
- disableChecksummedAddresses: unit => unit,
586
- decodeLogs: array<log> => promise<array<Nullable.t<decodedEvent>>>,
587
- decodeLogsSync: array<log> => array<Nullable.t<decodedEvent>>,
588
457
  decodeEvents: array<ResponseTypes.event> => promise<array<Nullable.t<decodedEvent>>>,
589
- decodeEventsSync: array<ResponseTypes.event> => array<Nullable.t<decodedEvent>>,
590
458
  }
591
459
 
592
- @module("@envio-dev/hypersync-client") @scope("Decoder")
593
- external fromSignatures: array<string> => t = "fromSignatures"
594
- // Keep the @envio-dev/hypersync-client import inside of the package
595
- let fromSignatures = fromSignatures
460
+ @send
461
+ external classFromSignatures: (
462
+ Core.decoderCtor,
463
+ array<string>,
464
+ ~checksumAddresses: bool=?,
465
+ ) => t = "fromSignatures"
466
+
467
+ let fromSignatures = (signatures, ~checksumAddresses=?) =>
468
+ Core.getAddon().decoder->classFromSignatures(signatures, ~checksumAddresses?)
596
469
  }
@@ -1,10 +1,11 @@
1
1
  // Generated by ReScript, PLEASE EDIT WITH CARE
2
2
 
3
+ import * as Core from "../Core.res.mjs";
3
4
  import * as Utils from "../Utils.res.mjs";
4
5
  import * as Address from "../Address.res.mjs";
5
6
  import * as Belt_Array from "@rescript/runtime/lib/es6/Belt_Array.js";
7
+ import * as Primitive_option from "@rescript/runtime/lib/es6/Primitive_option.js";
6
8
  import * as S$RescriptSchema from "rescript-schema/src/S.res.mjs";
7
- import * as HypersyncClient from "@envio-dev/hypersync-client";
8
9
 
9
10
  let serializationFormatSchema = S$RescriptSchema.$$enum([
10
11
  "Json",
@@ -58,12 +59,14 @@ let ResponseTypes = {
58
59
  authorizationListSchema: authorizationListSchema
59
60
  };
60
61
 
61
- let HeightStream = {};
62
+ function makeWithAgent(cfg, userAgent) {
63
+ return Core.getAddon().HypersyncClient.newWithAgent(cfg, userAgent);
64
+ }
62
65
 
63
66
  function make(url, apiToken, httpReqTimeoutMillis, maxNumRetries, enableChecksumAddressesOpt, serializationFormat, enableQueryCaching, retryBaseMs, retryBackoffMs, retryCeilingMs) {
64
67
  let enableChecksumAddresses = enableChecksumAddressesOpt !== undefined ? enableChecksumAddressesOpt : true;
65
68
  let envioVersion = Utils.EnvioPackage.value.version;
66
- return HypersyncClient.HypersyncClient.newWithAgent({
69
+ return makeWithAgent({
67
70
  url: url,
68
71
  apiToken: apiToken,
69
72
  httpReqTimeoutMillis: httpReqTimeoutMillis,
@@ -85,6 +88,16 @@ let logLevelSchema = S$RescriptSchema.$$enum([
85
88
  "error"
86
89
  ]);
87
90
 
91
+ function setLogLevel(level) {
92
+ Core.getAddon().setLogLevel(level === "warn" ? "warn" : (
93
+ level === "debug" ? "debug" : (
94
+ level === "error" ? "error" : (
95
+ level === "trace" ? "trace" : "info"
96
+ )
97
+ )
98
+ ));
99
+ }
100
+
88
101
  function toUnderlying(_d) {
89
102
  while (true) {
90
103
  let d = _d;
@@ -105,8 +118,8 @@ function toUnderlying(_d) {
105
118
  };
106
119
  }
107
120
 
108
- function fromSignatures(prim) {
109
- return HypersyncClient.Decoder.fromSignatures(prim);
121
+ function fromSignatures(signatures, checksumAddresses) {
122
+ return Core.getAddon().Decoder.fromSignatures(signatures, checksumAddresses !== undefined ? Primitive_option.valFromOption(checksumAddresses) : undefined);
110
123
  }
111
124
 
112
125
  let Decoder = {
@@ -118,9 +131,10 @@ export {
118
131
  serializationFormatSchema,
119
132
  QueryTypes,
120
133
  ResponseTypes,
121
- HeightStream,
134
+ makeWithAgent,
122
135
  make,
123
136
  logLevelSchema,
137
+ setLogLevel,
124
138
  Decoder,
125
139
  }
126
140
  /* serializationFormatSchema Not a pure module */