envio 3.6.1-subgraph → 3.7.0-subgraph

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 (87) hide show
  1. package/index.d.ts +197 -9
  2. package/package.json +6 -6
  3. package/src/Batch.res +64 -25
  4. package/src/Batch.res.mjs +69 -46
  5. package/src/ChainFetching.res +13 -17
  6. package/src/ChainFetching.res.mjs +9 -14
  7. package/src/ChainState.res +160 -119
  8. package/src/ChainState.res.mjs +75 -46
  9. package/src/ChainState.resi +15 -12
  10. package/src/Config.res +13 -9
  11. package/src/Config.res.mjs +5 -8
  12. package/src/Core.res +5 -0
  13. package/src/Ecosystem.res +0 -1
  14. package/src/Envio.res +16 -3
  15. package/src/EventConfigBuilder.res +155 -40
  16. package/src/EventConfigBuilder.res.mjs +76 -24
  17. package/src/EventProcessing.res +4 -8
  18. package/src/EventProcessing.res.mjs +4 -4
  19. package/src/EventUtils.res +3 -47
  20. package/src/FetchState.res +124 -104
  21. package/src/FetchState.res.mjs +116 -100
  22. package/src/HandlerRegister.res +108 -2
  23. package/src/HandlerRegister.res.mjs +59 -10
  24. package/src/HandlerRegister.resi +4 -0
  25. package/src/InMemoryStore.res +1 -6
  26. package/src/InMemoryStore.res.mjs +1 -3
  27. package/src/Internal.res +84 -24
  28. package/src/Internal.res.mjs +33 -2
  29. package/src/LazyLoader.res +12 -11
  30. package/src/LazyLoader.res.mjs +13 -7
  31. package/src/Main.res +22 -9
  32. package/src/Main.res.mjs +18 -5
  33. package/src/MemoryStorage.res +756 -0
  34. package/src/MemoryStorage.res.mjs +623 -0
  35. package/src/Persistence.res +4 -2
  36. package/src/PgStorage.res +24 -8
  37. package/src/PgStorage.res.mjs +15 -12
  38. package/src/ReorgDetection.res +0 -222
  39. package/src/ReorgDetection.res.mjs +0 -163
  40. package/src/Rollback.res +14 -15
  41. package/src/Rollback.res.mjs +4 -5
  42. package/src/SimulateItems.res +2 -2
  43. package/src/Utils.res +3 -0
  44. package/src/bindings/ClickHouse.res +16 -11
  45. package/src/bindings/ClickHouse.res.mjs +10 -10
  46. package/src/bindings/Vitest.res +1 -1
  47. package/src/sources/BlockStore.res +115 -5
  48. package/src/sources/BlockStore.res.mjs +25 -0
  49. package/src/sources/Evm.res +0 -1
  50. package/src/sources/Evm.res.mjs +0 -1
  51. package/src/sources/EvmHyperSyncSource.res +19 -84
  52. package/src/sources/EvmHyperSyncSource.res.mjs +24 -60
  53. package/src/sources/Fuel.res +24 -4
  54. package/src/sources/Fuel.res.mjs +23 -3
  55. package/src/sources/FuelHyperSync.res +8 -3
  56. package/src/sources/FuelHyperSync.res.mjs +5 -4
  57. package/src/sources/FuelHyperSync.resi +3 -1
  58. package/src/sources/FuelHyperSyncClient.res +7 -10
  59. package/src/sources/FuelHyperSyncSource.res +18 -45
  60. package/src/sources/FuelHyperSyncSource.res.mjs +18 -35
  61. package/src/sources/HyperSync.res +49 -229
  62. package/src/sources/HyperSync.res.mjs +74 -191
  63. package/src/sources/HyperSync.resi +11 -35
  64. package/src/sources/HyperSyncClient.res +9 -79
  65. package/src/sources/HyperSyncClient.res.mjs +2 -6
  66. package/src/sources/RequestStat.res +5 -0
  67. package/src/sources/RequestStat.res.mjs +2 -0
  68. package/src/sources/RpcSource.res +149 -43
  69. package/src/sources/RpcSource.res.mjs +104 -41
  70. package/src/sources/SimulateSource.res +8 -5
  71. package/src/sources/SimulateSource.res.mjs +6 -6
  72. package/src/sources/Source.res +89 -16
  73. package/src/sources/Source.res.mjs +50 -1
  74. package/src/sources/SourceManager.res +255 -50
  75. package/src/sources/SourceManager.res.mjs +149 -55
  76. package/src/sources/SourceManager.resi +2 -6
  77. package/src/sources/Svm.res +0 -7
  78. package/src/sources/Svm.res.mjs +0 -8
  79. package/src/sources/SvmHyperSyncClient.res +21 -16
  80. package/src/sources/SvmHyperSyncClient.res.mjs +3 -4
  81. package/src/sources/SvmHyperSyncSource.res +25 -117
  82. package/src/sources/SvmHyperSyncSource.res.mjs +8 -121
  83. package/src/subgraph/calls.ts +5 -1
  84. package/src/subgraph/division.ts +10 -0
  85. package/src/subgraph/graph-ts.ts +180 -4
  86. package/src/subgraph/runtime.ts +22 -4
  87. package/svm.schema.json +3 -2
@@ -27,6 +27,7 @@ import {
27
27
  BigInt as GraphBigInt,
28
28
  Bytes,
29
29
  changetype,
30
+ retagChangetype,
30
31
  installCallHook,
31
32
  installHosts,
32
33
  installRegisterHook,
@@ -36,7 +37,14 @@ import {
36
37
  valueToJs,
37
38
  } from "./graph-ts.ts";
38
39
  import { encodeArg, decodeArg, makeCallEffect, resetClients } from "./calls.ts";
39
- import { DIVIDE_HELPER, integerDivision, loadTypeScript, rewriteDivision } from "./division.ts";
40
+ import {
41
+ DIVIDE_HELPER,
42
+ RETAG_HELPER,
43
+ integerDivision,
44
+ loadTypeScript,
45
+ rewriteChangetype,
46
+ rewriteDivision,
47
+ } from "./division.ts";
40
48
  import { makeHostEffects } from "./hosts.ts";
41
49
  import { unsupported } from "./errors.ts";
42
50
 
@@ -118,7 +126,7 @@ function installResolveHook(root: string) {
118
126
  const source = loaded?.source;
119
127
  if (typeof source !== "string" && !(source instanceof Uint8Array)) return loaded;
120
128
  const text = typeof source === "string" ? source : Buffer.from(source).toString("utf8");
121
- return { ...loaded, source: rewriteDivision(text) };
129
+ return { ...loaded, source: rewriteChangetype(rewriteDivision(text)) };
122
130
  },
123
131
  });
124
132
 
@@ -126,6 +134,7 @@ function installResolveHook(root: string) {
126
134
  const globals = globalThis as any;
127
135
  globals.changetype ??= changetype;
128
136
  globals[DIVIDE_HELPER] ??= integerDivision;
137
+ globals[RETAG_HELPER] ??= retagChangetype;
129
138
  globals.assert ??= (value: unknown, message?: string) => {
130
139
  if (!value) throw new Error(message ?? "assertion failed");
131
140
  return value;
@@ -291,6 +300,15 @@ function shaped(fields: ShapeField[], raw: Record<string, unknown> | undefined)
291
300
  return out;
292
301
  }
293
302
 
303
+ /**
304
+ * envio capitalizes a contract name for the config it stores, so a data source
305
+ * whose manifest name starts lowercase — `crvUSD` — is `CrvUSD` by the time the
306
+ * runtime looks it up. Register under the name the config actually holds.
307
+ */
308
+ function contractName(name: string): string {
309
+ return name.charAt(0).toUpperCase() + name.slice(1);
310
+ }
311
+
294
312
  /**
295
313
  * The graph-ts `ethereum.Event` a mapping sees, built per event kind so the
296
314
  * refusals and conversions live on a prototype rather than being installed on
@@ -758,7 +776,7 @@ export async function registerSubgraph(config: SubgraphConfig): Promise<void> {
758
776
  });
759
777
 
760
778
  indexer.onEvent(
761
- { contract: source.name, event: handler.name },
779
+ { contract: contractName(source.name), event: handler.name },
762
780
  async ({ event, context }: any) => {
763
781
  const graphEvent = new SubgraphEvent(event);
764
782
  await (context as any).runSync(() =>
@@ -772,7 +790,7 @@ export async function registerSubgraph(config: SubgraphConfig): Promise<void> {
772
790
  // register mode, where writes and logs are no-ops and reads are null.
773
791
  if (templateNames.size > 0) {
774
792
  indexer.contractRegister(
775
- { contract: source.name, event: handler.name },
793
+ { contract: contractName(source.name), event: handler.name },
776
794
  async ({ event, context }: any) => {
777
795
  const graphEvent = new SubgraphEvent(event);
778
796
  await runRegisterRounds(makeScope(event, context, "register"), () => fn(graphEvent));
package/svm.schema.json CHANGED
@@ -511,7 +511,7 @@
511
511
  "type": "string",
512
512
  "enum": [
513
513
  "transactionIndex",
514
- "signatures",
514
+ "signature",
515
515
  "feePayer",
516
516
  "success",
517
517
  "err",
@@ -519,7 +519,8 @@
519
519
  "computeUnitsConsumed",
520
520
  "accountKeys",
521
521
  "recentBlockhash",
522
- "version"
522
+ "version",
523
+ "allSignatures"
523
524
  ]
524
525
  },
525
526
  "SvmBlockField": {