envio 3.0.2-svm-alpha.0 → 3.0.2

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 +1 -155
  4. package/package.json +7 -6
  5. package/src/ChainFetcher.res +1 -25
  6. package/src/ChainFetcher.res.mjs +1 -19
  7. package/src/Config.res +94 -156
  8. package/src/Config.res.mjs +97 -60
  9. package/src/Core.res +0 -32
  10. package/src/Env.res.mjs +2 -1
  11. package/src/Envio.res +0 -94
  12. package/src/EventConfigBuilder.res +25 -63
  13. package/src/EventConfigBuilder.res.mjs +8 -37
  14. package/src/HandlerLoader.res +1 -12
  15. package/src/HandlerLoader.res.mjs +1 -6
  16. package/src/Internal.res +0 -38
  17. package/src/Main.res +3 -53
  18. package/src/Main.res.mjs +2 -34
  19. package/src/Persistence.res +17 -2
  20. package/src/Persistence.res.mjs +14 -2
  21. package/src/SimulateItems.res +10 -23
  22. package/src/SimulateItems.res.mjs +6 -21
  23. package/src/bindings/ClickHouse.res +6 -2
  24. package/src/bindings/ClickHouse.res.mjs +3 -2
  25. package/src/sources/EventRouter.res +0 -65
  26. package/src/sources/EventRouter.res.mjs +0 -43
  27. package/src/sources/HyperSyncClient.res +157 -30
  28. package/src/sources/HyperSyncClient.res.mjs +6 -20
  29. package/src/sources/HyperSyncSource.res +8 -5
  30. package/src/sources/HyperSyncSource.res.mjs +8 -1
  31. package/src/sources/RpcSource.res.mjs +1 -1
  32. package/src/sources/Svm.res +2 -2
  33. package/src/sources/Svm.res.mjs +2 -3
  34. package/src/tui/Tui.res +2 -9
  35. package/src/tui/Tui.res.mjs +4 -19
  36. package/src/tui/components/TuiData.res +0 -3
  37. package/svm.schema.json +4 -345
  38. package/src/SvmTypes.res +0 -9
  39. package/src/SvmTypes.res.mjs +0 -14
  40. package/src/sources/HyperSyncSolanaClient.res +0 -227
  41. package/src/sources/HyperSyncSolanaClient.res.mjs +0 -25
  42. package/src/sources/HyperSyncSolanaSource.res +0 -515
  43. package/src/sources/HyperSyncSolanaSource.res.mjs +0 -441
@@ -135,12 +135,19 @@ Learn more or get a free API token at: https://envio.dev/app/api-tokens`);
135
135
  if (decoder !== undefined) {
136
136
  return decoder;
137
137
  }
138
+ let decoder$1;
138
139
  try {
139
- return HyperSyncClient.Decoder.fromSignatures(allEventSignatures, !lowercaseAddresses);
140
+ decoder$1 = HyperSyncClient.Decoder.fromSignatures(allEventSignatures);
140
141
  } catch (raw_exn) {
141
142
  let exn = Primitive_exceptions.internalToException(raw_exn);
142
143
  return ErrorHandling.mkLogAndRaise(undefined, "Failed to instantiate a decoder from hypersync client, please double check your ABI", exn);
143
144
  }
145
+ if (lowercaseAddresses) {
146
+ decoder$1.disableChecksummedAddresses();
147
+ } else {
148
+ decoder$1.enableChecksummedAddresses();
149
+ }
150
+ return decoder$1;
144
151
  };
145
152
  let UndefinedValue = /* @__PURE__ */Primitive_exceptions.create("UndefinedValue");
146
153
  let makeEventBatchQueueItem = (item, params, eventConfig) => {
@@ -1022,7 +1022,7 @@ function make(param) {
1022
1022
  if (decoder !== undefined) {
1023
1023
  return decoder;
1024
1024
  } else {
1025
- return HyperSyncClient.Decoder.fromSignatures(allEventSignatures, undefined);
1025
+ return HyperSyncClient.Decoder.fromSignatures(allEventSignatures);
1026
1026
  }
1027
1027
  };
1028
1028
  let getItemsOrThrow = async (fromBlock, toBlock, addressesByContractName, indexingAddresses, knownHeight, partitionId, selection, param, param$1) => {
@@ -39,7 +39,7 @@ module GetFinalizedSlot = {
39
39
  )
40
40
  }
41
41
 
42
- let makeRPCSource = (~chain, ~rpc: string, ~sourceFor: Source.sourceFor=Sync): Source.t => {
42
+ let makeRPCSource = (~chain, ~rpc: string): Source.t => {
43
43
  let client = Rest.client(rpc)
44
44
  let chainId = chain->ChainMap.Chain.toChainId
45
45
 
@@ -54,7 +54,7 @@ let makeRPCSource = (~chain, ~rpc: string, ~sourceFor: Source.sourceFor=Sync): S
54
54
 
55
55
  {
56
56
  name,
57
- sourceFor,
57
+ sourceFor: Sync,
58
58
  chain,
59
59
  poweredByHyperSync: false,
60
60
  pollingInterval: 10_000,
@@ -60,15 +60,14 @@ let GetFinalizedSlot = {
60
60
  route: route
61
61
  };
62
62
 
63
- function makeRPCSource(chain, rpc, sourceForOpt) {
64
- let sourceFor = sourceForOpt !== undefined ? sourceForOpt : "Sync";
63
+ function makeRPCSource(chain, rpc) {
65
64
  let client = Rest.client(rpc, undefined);
66
65
  let host = Utils.Url.getHostFromUrl(rpc);
67
66
  let urlHost = host !== undefined ? host : Stdlib_JsError.throwWithMessage(`The RPC url for chain ` + String(chain) + ` is in incorrect format. The RPC url needs to start with either http:// or https://`);
68
67
  let name = `RPC (` + urlHost + `)`;
69
68
  return {
70
69
  name: name,
71
- sourceFor: sourceFor,
70
+ sourceFor: "Sync",
72
71
  chain: chain,
73
72
  poweredByHyperSync: false,
74
73
  pollingInterval: 10000,
package/src/tui/Tui.res CHANGED
@@ -13,7 +13,6 @@ module ChainLine = {
13
13
  ~endBlock,
14
14
  ~poweredByHyperSync,
15
15
  ~eventsProcessed,
16
- ~blockUnit: string,
17
16
  ) => {
18
17
  let chainsWidth = Pervasives.min(stdoutColumns - 2, 60)
19
18
  let headerWidth = maxChainIdLength + 10 // 10 for additional text
@@ -28,10 +27,9 @@ module ChainLine = {
28
27
  let toBlockStr = toBlock->TuiData.formatLocaleString
29
28
  let eventsStr = eventsProcessed->TuiData.formatFloatLocaleString
30
29
 
31
- let endLabel = blockUnit === "Slots" ? " (End Slot)" : " (End Block)"
32
30
  let blocksText =
33
- `${blockUnit}: ${progressBlockStr} / ${toBlockStr}` ++
34
- (endBlock->Option.isSome ? endLabel : "") ++ ` `
31
+ `Blocks: ${progressBlockStr} / ${toBlockStr}` ++
32
+ (endBlock->Option.isSome ? " (End Block)" : "") ++ ` `
35
33
  let eventsText = `Events: ${eventsStr}`
36
34
 
37
35
  let fitsSameLine = blocksText->String.length + eventsText->String.length <= chainsWidth
@@ -212,10 +210,6 @@ module App = {
212
210
  poweredByHyperSync: (
213
211
  cf.sourceManager->SourceManager.getActiveSource
214
212
  ).poweredByHyperSync,
215
- blockUnit: switch state.ctx.config.ecosystem.name {
216
- | Svm => "Slots"
217
- | Evm | Fuel => "Blocks"
218
- },
219
213
  }: TuiData.chain
220
214
  )
221
215
  })
@@ -255,7 +249,6 @@ module App = {
255
249
  stdoutColumns={stdoutColumns}
256
250
  poweredByHyperSync={chainData.poweredByHyperSync}
257
251
  eventsProcessed={chainData.eventsProcessed}
258
- blockUnit={chainData.blockUnit}
259
252
  />
260
253
  })
261
254
  ->React.array}
@@ -19,7 +19,6 @@ import * as JsxRuntime from "react/jsx-runtime";
19
19
  import * as BufferedProgressBar from "./components/BufferedProgressBar.res.mjs";
20
20
 
21
21
  function Tui$ChainLine(props) {
22
- let blockUnit = props.blockUnit;
23
22
  let poweredByHyperSync = props.poweredByHyperSync;
24
23
  let endBlock = props.endBlock;
25
24
  let startBlock = props.startBlock;
@@ -34,9 +33,8 @@ function Tui$ChainLine(props) {
34
33
  let progressBlockStr = TuiData.formatLocaleString(progressBlock);
35
34
  let toBlockStr = TuiData.formatLocaleString(toBlock);
36
35
  let eventsStr = TuiData.formatFloatLocaleString(props.eventsProcessed);
37
- let endLabel = blockUnit === "Slots" ? " (End Slot)" : " (End Block)";
38
- let blocksText = blockUnit + `: ` + progressBlockStr + ` / ` + toBlockStr + (
39
- Stdlib_Option.isSome(endBlock) ? endLabel : ""
36
+ let blocksText = `Blocks: ` + progressBlockStr + ` / ` + toBlockStr + (
37
+ Stdlib_Option.isSome(endBlock) ? " (End Block)" : ""
40
38
  ) + ` `;
41
39
  let eventsText = `Events: ` + eventsStr;
42
40
  let fitsSameLine = (blocksText.length + eventsText.length | 0) <= chainsWidth;
@@ -244,17 +242,6 @@ function Tui$App(props) {
244
242
  })
245
243
  ) : "SearchingForEvents";
246
244
  }
247
- let match$1 = state.ctx.config.ecosystem.name;
248
- let tmp;
249
- switch (match$1) {
250
- case "evm" :
251
- case "fuel" :
252
- tmp = "Blocks";
253
- break;
254
- case "svm" :
255
- tmp = "Slots";
256
- break;
257
- }
258
245
  return {
259
246
  chainId: cf.chainConfig.id.toString(),
260
247
  eventsProcessed: numEventsProcessed,
@@ -267,8 +254,7 @@ function Tui$App(props) {
267
254
  poweredByHyperSync: SourceManager.getActiveSource(cf.sourceManager).poweredByHyperSync,
268
255
  progress: progress,
269
256
  latestFetchedBlockNumber: latestFetchedBlockNumber,
270
- knownHeight: knownHeight,
271
- blockUnit: tmp
257
+ knownHeight: knownHeight
272
258
  };
273
259
  });
274
260
  let totalEventsProcessed = Stdlib_Array.reduce(chains, 0, (acc, chain) => acc + chain.eventsProcessed);
@@ -306,8 +292,7 @@ function Tui$App(props) {
306
292
  startBlock: chainData.startBlock,
307
293
  endBlock: chainData.endBlock,
308
294
  poweredByHyperSync: chainData.poweredByHyperSync,
309
- eventsProcessed: chainData.eventsProcessed,
310
- blockUnit: chainData.blockUnit
295
+ eventsProcessed: chainData.eventsProcessed
311
296
  }, i.toString())),
312
297
  JsxRuntime.jsx(Tui$TotalEventsProcessed, {
313
298
  totalEventsProcessed: totalEventsProcessed,
@@ -30,9 +30,6 @@ type chain = {
30
30
  progress: progress,
31
31
  latestFetchedBlockNumber: int,
32
32
  knownHeight: int,
33
- /** Localized unit noun for this chain's progress. `"Slots"` on SVM,
34
- `"Blocks"` everywhere else. Drives the per-chain progress label. */
35
- blockUnit: string,
36
33
  }
37
34
 
38
35
  let minOfOption: (int, option<int>) => int = (a: int, b: option<int>) => {
package/svm.schema.json CHANGED
@@ -4,10 +4,6 @@
4
4
  "description": "Schema for a YAML config for an envio Svm indexer",
5
5
  "type": "object",
6
6
  "properties": {
7
- "name": {
8
- "description": "Name of the project",
9
- "type": "string"
10
- },
11
7
  "description": {
12
8
  "description": "Description of the project",
13
9
  "type": [
@@ -15,6 +11,10 @@
15
11
  "null"
16
12
  ]
17
13
  },
14
+ "name": {
15
+ "description": "Name of the project",
16
+ "type": "string"
17
+ },
18
18
  "schema": {
19
19
  "description": "Custom path to schema.graphql file",
20
20
  "type": [
@@ -137,17 +137,6 @@
137
137
  "description": "RPC endpoint URL for connecting to the Svm cluster to fetch blockchain data.",
138
138
  "type": "string"
139
139
  },
140
- "hypersync_config": {
141
- "description": "Optional HyperSync Config for fetching historical instructions.",
142
- "anyOf": [
143
- {
144
- "$ref": "#/$defs/HypersyncConfig"
145
- },
146
- {
147
- "type": "null"
148
- }
149
- ]
150
- },
151
140
  "start_block": {
152
141
  "description": "The slot number at which the indexer should start ingesting data",
153
142
  "type": "integer",
@@ -171,16 +160,6 @@
171
160
  ],
172
161
  "format": "uint32",
173
162
  "minimum": 0
174
- },
175
- "programs": {
176
- "description": "Solana programs to index on this chain.",
177
- "type": [
178
- "array",
179
- "null"
180
- ],
181
- "items": {
182
- "$ref": "#/$defs/Program"
183
- }
184
163
  }
185
164
  },
186
165
  "additionalProperties": false,
@@ -188,326 +167,6 @@
188
167
  "rpc",
189
168
  "start_block"
190
169
  ]
191
- },
192
- "HypersyncConfig": {
193
- "type": "object",
194
- "properties": {
195
- "url": {
196
- "description": "URL of the HyperSync endpoint (default: the public Solana HyperSync endpoint at https://solana.hypersync.xyz)",
197
- "type": "string"
198
- }
199
- },
200
- "additionalProperties": false,
201
- "required": [
202
- "url"
203
- ]
204
- },
205
- "Program": {
206
- "type": "object",
207
- "properties": {
208
- "name": {
209
- "description": "A unique project-wide name for this program (used in generated code).",
210
- "type": "string"
211
- },
212
- "program_id": {
213
- "description": "Base58-encoded program id (32 bytes).",
214
- "type": "string"
215
- },
216
- "handler": {
217
- "description": "Optional relative path to a file where handlers are registered for the given program. If not provided, handlers can be auto-loaded from the src directory.",
218
- "type": [
219
- "string",
220
- "null"
221
- ]
222
- },
223
- "idl": {
224
- "description": "Optional path (relative to config.yaml) to an Anchor IDL JSON file. When present, codegen parses the IDL and derives `accounts`/`args` for every named instruction. Mutually exclusive with per-instruction `accounts`/`args` overrides.",
225
- "type": [
226
- "string",
227
- "null"
228
- ]
229
- },
230
- "instructions": {
231
- "description": "A list of instructions that should be indexed on this program.",
232
- "type": "array",
233
- "items": {
234
- "$ref": "#/$defs/Instruction"
235
- }
236
- }
237
- },
238
- "additionalProperties": false,
239
- "required": [
240
- "name",
241
- "program_id",
242
- "instructions"
243
- ]
244
- },
245
- "Instruction": {
246
- "type": "object",
247
- "properties": {
248
- "name": {
249
- "description": "Name of the instruction in the HyperIndex generated code. Should be unique per program.",
250
- "type": "string"
251
- },
252
- "discriminator": {
253
- "description": "Hex-encoded instruction-data prefix used as the discriminator (\"0x\" optional). Must be 1, 2, 4, or 8 bytes after decoding. An 8-byte value matches the standard Anchor discriminator.",
254
- "type": [
255
- "string",
256
- "null"
257
- ]
258
- },
259
- "is_inner": {
260
- "description": "Filter on inner-vs-outer instructions. None / absent matches both.",
261
- "type": [
262
- "boolean",
263
- "null"
264
- ]
265
- },
266
- "account_filters": {
267
- "description": "Optional positional account filters. Each entry pins a particular account position (0..=9) to one of a set of base58 pubkeys.",
268
- "type": [
269
- "array",
270
- "null"
271
- ],
272
- "items": {
273
- "$ref": "#/$defs/AccountFilter"
274
- }
275
- },
276
- "include_transaction": {
277
- "description": "When true, also fetch the parent transaction for each matched instruction. Defaults to true so handlers can read tx signatures.",
278
- "type": [
279
- "boolean",
280
- "null"
281
- ]
282
- },
283
- "include_logs": {
284
- "description": "When true, also fetch program logs for each matched instruction.",
285
- "type": [
286
- "boolean",
287
- "null"
288
- ]
289
- },
290
- "accounts": {
291
- "description": "Optional positional account names. The Nth entry names account slot N on the dispatched instruction; surfaces as `event.instruction.decoded.accounts.<name>`. Accounts beyond the named list become `extra_accounts`.",
292
- "type": [
293
- "array",
294
- "null"
295
- ],
296
- "items": {
297
- "type": "string"
298
- }
299
- },
300
- "args": {
301
- "description": "Optional Borsh argument schema. Each entry names one arg and gives its type; the decoder walks the instruction data after the discriminator in declared order. Mutually exclusive with the program-level `idl` field.",
302
- "type": [
303
- "array",
304
- "null"
305
- ],
306
- "items": {
307
- "$ref": "#/$defs/ArgDef"
308
- }
309
- }
310
- },
311
- "additionalProperties": false,
312
- "required": [
313
- "name"
314
- ]
315
- },
316
- "AccountFilter": {
317
- "type": "object",
318
- "properties": {
319
- "position": {
320
- "description": "Account position within the instruction (0..=9).",
321
- "type": "integer",
322
- "format": "uint8",
323
- "minimum": 0,
324
- "maximum": 255
325
- },
326
- "values": {
327
- "description": "Allowed base58 pubkeys for this account position.",
328
- "type": "array",
329
- "items": {
330
- "type": "string"
331
- }
332
- }
333
- },
334
- "additionalProperties": false,
335
- "required": [
336
- "position",
337
- "values"
338
- ]
339
- },
340
- "ArgDef": {
341
- "description": "One named argument of an instruction. Mirrors\n`hypersync_client_solana::decode::NamedField`.",
342
- "type": "object",
343
- "properties": {
344
- "name": {
345
- "description": "Field name as it appears on the decoded args object.",
346
- "type": "string"
347
- },
348
- "type": {
349
- "description": "Borsh type of this field.",
350
- "$ref": "#/$defs/ArgType"
351
- }
352
- },
353
- "additionalProperties": false,
354
- "required": [
355
- "name",
356
- "type"
357
- ]
358
- },
359
- "ArgType": {
360
- "description": "User-facing Borsh type grammar. Mirrors\n`hypersync_client_solana::decode::FieldType`. The YAML accepts either:\n- A bare string for primitives (`\"u64\"`, `\"pubkey\"`, `\"bool\"`, ...).\n- A tagged object for composites (`{ vec: u8 }`, `{ option: pubkey }`,\n `{ array: [u8, 32] }`, `{ defined: \"DataV2\" }`).\n- An object with `kind: struct` or `kind: enum` for nominal types\n declared inline on this field. Most users will use `defined` and\n declare the nominal types under the program's `types:` block (Anchor\n IDL shape) once that lands; for now inline `struct` / `enum` is the\n only way to express nominal shapes ad-hoc.",
361
- "anyOf": [
362
- {
363
- "$ref": "#/$defs/ArgPrimitive"
364
- },
365
- {
366
- "$ref": "#/$defs/ArgComposite"
367
- }
368
- ]
369
- },
370
- "ArgPrimitive": {
371
- "type": "string",
372
- "enum": [
373
- "bool",
374
- "u8",
375
- "u16",
376
- "u32",
377
- "u64",
378
- "u128",
379
- "i8",
380
- "i16",
381
- "i32",
382
- "i64",
383
- "i128",
384
- "f32",
385
- "f64",
386
- "string",
387
- "bytes",
388
- "pubkey",
389
- "publicKey"
390
- ]
391
- },
392
- "ArgComposite": {
393
- "oneOf": [
394
- {
395
- "type": "object",
396
- "properties": {
397
- "option": {
398
- "$ref": "#/$defs/ArgType"
399
- }
400
- },
401
- "required": [
402
- "option"
403
- ],
404
- "additionalProperties": false
405
- },
406
- {
407
- "type": "object",
408
- "properties": {
409
- "vec": {
410
- "$ref": "#/$defs/ArgType"
411
- }
412
- },
413
- "required": [
414
- "vec"
415
- ],
416
- "additionalProperties": false
417
- },
418
- {
419
- "description": "`[ <element type>, <length> ]` — same shape Anchor IDLs use.",
420
- "type": "object",
421
- "properties": {
422
- "array": {
423
- "type": "array",
424
- "prefixItems": [
425
- {
426
- "$ref": "#/$defs/ArgType"
427
- },
428
- {
429
- "type": "integer",
430
- "format": "uint",
431
- "minimum": 0
432
- }
433
- ],
434
- "minItems": 2,
435
- "maxItems": 2
436
- }
437
- },
438
- "required": [
439
- "array"
440
- ],
441
- "additionalProperties": false
442
- },
443
- {
444
- "description": "Reference to a nominal type defined in the program-level\n`defined_types` registry (populated from an Anchor IDL `types:`\nblock or the bundled-Metaplex registry).",
445
- "type": "object",
446
- "properties": {
447
- "defined": {
448
- "type": "string"
449
- }
450
- },
451
- "required": [
452
- "defined"
453
- ],
454
- "additionalProperties": false
455
- },
456
- {
457
- "description": "Inline-or-registry struct. Used as a nominal type definition in\nthe `defined_types` registry; rarely seen at the field level.",
458
- "type": "object",
459
- "properties": {
460
- "struct": {
461
- "type": "array",
462
- "items": {
463
- "$ref": "#/$defs/ArgDef"
464
- }
465
- }
466
- },
467
- "required": [
468
- "struct"
469
- ],
470
- "additionalProperties": false
471
- },
472
- {
473
- "description": "Inline-or-registry enum. Same role as `Struct`: a nominal type\ndefinition in the `defined_types` registry.",
474
- "type": "object",
475
- "properties": {
476
- "enum": {
477
- "type": "array",
478
- "items": {
479
- "$ref": "#/$defs/ArgEnumVariant"
480
- }
481
- }
482
- },
483
- "required": [
484
- "enum"
485
- ],
486
- "additionalProperties": false
487
- }
488
- ]
489
- },
490
- "ArgEnumVariant": {
491
- "type": "object",
492
- "properties": {
493
- "name": {
494
- "type": "string"
495
- },
496
- "fields": {
497
- "description": "`None` for unit variants; `Some([])` for struct variants with no\nfields. The Borsh wire format is identical in both cases (the\n1-byte tag), but the distinction is preserved for round-tripping.",
498
- "type": [
499
- "array",
500
- "null"
501
- ],
502
- "items": {
503
- "$ref": "#/$defs/ArgDef"
504
- }
505
- }
506
- },
507
- "additionalProperties": false,
508
- "required": [
509
- "name"
510
- ]
511
170
  }
512
171
  }
513
172
  }
package/src/SvmTypes.res DELETED
@@ -1,9 +0,0 @@
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
- }
@@ -1,14 +0,0 @@
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 */