envio 3.15.0-subgraph → 3.16.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 (186) hide show
  1. package/README.md +40 -34
  2. package/evm.schema.json +3 -3
  3. package/fuel.schema.json +2 -2
  4. package/index.d.ts +3 -3
  5. package/licenses/README.md +1 -1
  6. package/package.json +9 -10
  7. package/src/Batch.res.mjs +5 -5
  8. package/src/BatchProcessing.res +1 -0
  9. package/src/BatchProcessing.res.mjs +1 -0
  10. package/src/Bin.res +0 -7
  11. package/src/Bin.res.mjs +0 -8
  12. package/src/ChainFetching.res +17 -456
  13. package/src/ChainFetching.res.mjs +33 -404
  14. package/src/ChainState.res +48 -83
  15. package/src/ChainState.res.mjs +83 -115
  16. package/src/ChainState.resi +0 -26
  17. package/src/Clock.res +57 -0
  18. package/src/Clock.res.mjs +72 -0
  19. package/src/Config.res +7 -16
  20. package/src/Config.res.mjs +4 -11
  21. package/src/ContractRegisterContext.res +6 -3
  22. package/src/ContractRegisterContext.res.mjs +2 -4
  23. package/src/Core.res +5 -136
  24. package/src/Core.res.mjs +1 -90
  25. package/src/CrossChainState.res +2 -8
  26. package/src/CrossChainState.res.mjs +3 -3
  27. package/src/Ecosystem.res +4 -7
  28. package/src/Ecosystem.res.mjs +8 -8
  29. package/src/EffectState.res +10 -2
  30. package/src/EffectState.res.mjs +8 -4
  31. package/src/EffectState.resi +3 -1
  32. package/src/EntityId.res +2 -7
  33. package/src/EntityId.res.mjs +1 -8
  34. package/src/EntityTables.res +4 -1
  35. package/src/EntityTables.res.mjs +1 -1
  36. package/src/Env.res +0 -16
  37. package/src/Env.res.mjs +0 -11
  38. package/src/EventProcessing.res +1 -38
  39. package/src/EventProcessing.res.mjs +1 -28
  40. package/src/FetchState.res +160 -319
  41. package/src/FetchState.res.mjs +182 -292
  42. package/src/FinalizeBackfill.res +2 -4
  43. package/src/FinalizeBackfill.res.mjs +3 -4
  44. package/src/HandlerLoader.res +15 -39
  45. package/src/HandlerLoader.res.mjs +8 -27
  46. package/src/HandlerRegister.res +0 -4
  47. package/src/HandlerRegister.res.mjs +2 -5
  48. package/src/HandlerRegister.resi +0 -2
  49. package/src/InMemoryTable.res +17 -16
  50. package/src/InMemoryTable.res.mjs +14 -15
  51. package/src/IndexerState.res +28 -4
  52. package/src/IndexerState.res.mjs +19 -6
  53. package/src/IndexerState.resi +4 -0
  54. package/src/Internal.res +0 -110
  55. package/src/Internal.res.mjs +1 -115
  56. package/src/LoadLayer.res +21 -47
  57. package/src/LoadLayer.res.mjs +47 -72
  58. package/src/LoadLayer.resi +0 -26
  59. package/src/Main.res +1 -14
  60. package/src/Main.res.mjs +3 -4
  61. package/src/Persistence.res +3 -23
  62. package/src/Persistence.res.mjs +3 -3
  63. package/src/Rollback.res +0 -1
  64. package/src/Rollback.res.mjs +1 -1
  65. package/src/RunScope.res +0 -3
  66. package/src/SafeCheckpointTracking.res +4 -4
  67. package/src/SafeCheckpointTracking.res.mjs +1 -1
  68. package/src/SimulateItems.res +26 -42
  69. package/src/SimulateItems.res.mjs +16 -40
  70. package/src/StagedRows.res +106 -0
  71. package/src/StagedRows.res.mjs +102 -0
  72. package/src/Staging.res +32 -14
  73. package/src/Staging.res.mjs +17 -20
  74. package/src/Storage.res +277 -998
  75. package/src/Storage.res.mjs +216 -731
  76. package/src/Supervisor.res +75 -56
  77. package/src/Supervisor.res.mjs +55 -26
  78. package/src/TestIndexer.res +22 -27
  79. package/src/TestIndexer.res.mjs +20 -17
  80. package/src/Throttler.res +15 -8
  81. package/src/Throttler.res.mjs +9 -6
  82. package/src/Throttler.resi +1 -1
  83. package/src/UserContext.res +46 -410
  84. package/src/UserContext.res.mjs +30 -318
  85. package/src/Utils.res +0 -23
  86. package/src/Utils.res.mjs +1 -17
  87. package/src/Writing.res +0 -1
  88. package/src/Writing.res.mjs +1 -1
  89. package/src/bindings/ClickHouse.res +0 -322
  90. package/src/bindings/ClickHouse.res.mjs +0 -338
  91. package/src/bindings/StorageClient.res +107 -175
  92. package/src/bindings/StorageClient.res.mjs +19 -8
  93. package/src/bindings/Vitest.res +0 -26
  94. package/src/bindings/Vitest.res.mjs +0 -3
  95. package/src/db/Table.res +24 -150
  96. package/src/db/Table.res.mjs +38 -272
  97. package/src/sources/AddressSet.res +0 -2
  98. package/src/sources/AddressStore.res +0 -3
  99. package/src/sources/ChainSources.res +2 -0
  100. package/src/sources/ChainSources.res.mjs +2 -2
  101. package/src/sources/EvmChain.res +4 -7
  102. package/src/sources/EvmChain.res.mjs +5 -4
  103. package/src/sources/EvmHyperSyncSource.res +2 -2
  104. package/src/sources/EvmHyperSyncSource.res.mjs +1 -1
  105. package/src/sources/EvmRpcClient.res +13 -3
  106. package/src/sources/EvmRpcClient.res.mjs +4 -3
  107. package/src/sources/EvmRpcWs.res +4 -3
  108. package/src/sources/EvmRpcWs.res.mjs +2 -2
  109. package/src/sources/HeightFeed.res +31 -10
  110. package/src/sources/HeightFeed.res.mjs +10 -6
  111. package/src/sources/HeightStream.res +32 -17
  112. package/src/sources/HeightStream.res.mjs +10 -10
  113. package/src/sources/HyperSync.res +1 -2
  114. package/src/sources/HyperSync.res.mjs +1 -2
  115. package/src/sources/HyperSyncSSE.res +4 -6
  116. package/src/sources/HyperSyncSSE.res.mjs +2 -2
  117. package/src/sources/RpcSource.res +10 -1
  118. package/src/sources/RpcSource.res.mjs +4 -3
  119. package/src/sources/Source.res +3 -0
  120. package/src/sources/SourceManager.res +85 -104
  121. package/src/sources/SourceManager.res.mjs +18 -37
  122. package/src/sources/SourceManager.resi +3 -5
  123. package/src/sources/StartBlockResolver.res +1 -0
  124. package/src/sources/StartBlockResolver.res.mjs +4 -3
  125. package/src/sources/SvmHyperSyncSource.res +2 -2
  126. package/src/sources/SvmHyperSyncSource.res.mjs +1 -1
  127. package/svm.schema.json +3 -3
  128. package/src/EffectCacheLookup.res +0 -98
  129. package/src/EffectCacheLookup.res.mjs +0 -116
  130. package/src/PgWriting.res +0 -36
  131. package/src/PgWriting.res.mjs +0 -34
  132. package/src/PreloadLookahead.res +0 -184
  133. package/src/PreloadLookahead.res.mjs +0 -197
  134. package/src/SubgraphLog.res +0 -19
  135. package/src/SubgraphLog.res.mjs +0 -26
  136. package/src/SyncWrites.res +0 -101
  137. package/src/SyncWrites.res.mjs +0 -98
  138. package/src/db/IndexDefinition.res +0 -47
  139. package/src/db/IndexDefinition.res.mjs +0 -60
  140. package/src/sources/CallSource.res +0 -274
  141. package/src/sources/CallSource.res.mjs +0 -196
  142. package/src/subgraph/abi-types.ts +0 -84
  143. package/src/subgraph/aggregations.ts +0 -745
  144. package/src/subgraph/as-package.ts +0 -143
  145. package/src/subgraph/assemblyscript-regex.ts +0 -67
  146. package/src/subgraph/assemblyscript.ts +0 -731
  147. package/src/subgraph/blocks.ts +0 -398
  148. package/src/subgraph/calls-source.ts +0 -702
  149. package/src/subgraph/calls.ts +0 -258
  150. package/src/subgraph/conformance.ts +0 -106
  151. package/src/subgraph/errors.ts +0 -85
  152. package/src/subgraph/graft.ts +0 -73
  153. package/src/subgraph/graph-cli-worker.mjs +0 -35
  154. package/src/subgraph/graph-cli.ts +0 -900
  155. package/src/subgraph/graph-node-decimal.ts +0 -199
  156. package/src/subgraph/graph-ts-enums.ts +0 -28
  157. package/src/subgraph/graph-ts-types/VERSION +0 -2
  158. package/src/subgraph/graph-ts-types/chain/arweave.d.ts +0 -70
  159. package/src/subgraph/graph-ts-types/chain/cosmos.d.ts +0 -327
  160. package/src/subgraph/graph-ts-types/chain/ethereum.d.ts +0 -233
  161. package/src/subgraph/graph-ts-types/chain/near.d.ts +0 -253
  162. package/src/subgraph/graph-ts-types/chain/starknet.d.ts +0 -32
  163. package/src/subgraph/graph-ts-types/common/collections.d.ts +0 -136
  164. package/src/subgraph/graph-ts-types/common/conversion.d.ts +0 -11
  165. package/src/subgraph/graph-ts-types/common/datasource.d.ts +0 -30
  166. package/src/subgraph/graph-ts-types/common/eager-offset.d.ts +0 -0
  167. package/src/subgraph/graph-ts-types/common/json.d.ts +0 -17
  168. package/src/subgraph/graph-ts-types/common/numbers.d.ts +0 -120
  169. package/src/subgraph/graph-ts-types/common/value.d.ts +0 -120
  170. package/src/subgraph/graph-ts-types/common/yaml.d.ts +0 -90
  171. package/src/subgraph/graph-ts-types/global/global.d.ts +0 -194
  172. package/src/subgraph/graph-ts-types/helper-functions.d.ts +0 -22
  173. package/src/subgraph/graph-ts-types/index.d.ts +0 -102
  174. package/src/subgraph/graph-ts.ts +0 -4280
  175. package/src/subgraph/hosts.ts +0 -554
  176. package/src/subgraph/log.ts +0 -28
  177. package/src/subgraph/receipts.ts +0 -184
  178. package/src/subgraph/register-slots.ts +0 -93
  179. package/src/subgraph/rollup.ts +0 -109
  180. package/src/subgraph/rpc.ts +0 -337
  181. package/src/subgraph/runtime.ts +0 -2060
  182. package/src/subgraph/scope.ts +0 -177
  183. package/src/subgraph/stats.ts +0 -42
  184. package/src/subgraph/template-instances.ts +0 -66
  185. package/src/subgraph/toolchain.ts +0 -327
  186. package/src/subgraph/transient.ts +0 -176
@@ -1,143 +0,0 @@
1
- /**
2
- * Where AssemblyScript finds a library that has no JavaScript entry.
3
- *
4
- * `asc` resolves `import { decode } from "as-base64"` to the package's
5
- * `assembly/index.ts` (or the file its package.json names as `ascMain`), and a
6
- * subpath such as `as-bignum/assembly/integer/u128` to the TypeScript file of
7
- * that name. Node only knows `main`/`exports`, so `as-base64` — whose
8
- * package.json names neither — is "Cannot find package .../index.js". This is
9
- * the AssemblyScript half of resolution, run only after Node has failed.
10
- */
11
-
12
- import { existsSync, readFileSync, statSync } from "node:fs";
13
- import { fileURLToPath, pathToFileURL } from "node:url";
14
- import path from "node:path";
15
-
16
- function isFile(file: string): boolean {
17
- try {
18
- return statSync(file).isFile();
19
- } catch {
20
- return false;
21
- }
22
- }
23
-
24
- /** The package name and the path inside it: `@scope/pkg/sub/file` → [`@scope/pkg`, `sub/file`]. */
25
- function splitSpecifier(specifier: string): [string, string] | null {
26
- const parts = specifier.split("/");
27
- const nameLength = specifier.startsWith("@") ? 2 : 1;
28
- if (parts.length < nameLength || parts.slice(0, nameLength).some((part) => part === "")) return null;
29
- return [parts.slice(0, nameLength).join("/"), parts.slice(nameLength).join("/")];
30
- }
31
-
32
- /** The `.ts` file AssemblyScript would load for `specifier` imported from `parentUrl`, as a URL. */
33
- export function resolveAssemblyScriptPackage(specifier: string, parentUrl: string | undefined): string | null {
34
- if (!parentUrl?.startsWith("file:")) return null;
35
- if (specifier.startsWith(".") || specifier.startsWith("/") || specifier.startsWith("node:")) return null;
36
- const split = splitSpecifier(specifier);
37
- if (!split) return null;
38
- const [name, inner] = split;
39
-
40
- let dir = path.dirname(fileURLToPath(parentUrl));
41
- for (;;) {
42
- const packageDir = path.join(dir, "node_modules", name);
43
- if (existsSync(packageDir)) {
44
- const found = resolveInPackage(packageDir, inner);
45
- if (found) return pathToFileURL(found).href;
46
- }
47
- const up = path.dirname(dir);
48
- if (up === dir) return null;
49
- dir = up;
50
- }
51
- }
52
-
53
- function resolveInPackage(packageDir: string, inner: string): string | null {
54
- const candidates: string[] = [];
55
- if (inner === "") {
56
- let manifest: { ascMain?: unknown; types?: unknown } = {};
57
- try {
58
- manifest = JSON.parse(readFileSync(path.join(packageDir, "package.json"), "utf8"));
59
- } catch {
60
- // A package without a readable manifest still has its assembly/ directory.
61
- }
62
- if (typeof manifest.ascMain === "string") candidates.push(manifest.ascMain);
63
- candidates.push("assembly/index.ts");
64
- if (typeof manifest.types === "string" && manifest.types.endsWith(".ts") && !manifest.types.endsWith(".d.ts")) {
65
- candidates.push(manifest.types);
66
- }
67
- candidates.push("index.ts");
68
- } else {
69
- candidates.push(inner, `${inner}.ts`, path.join(inner, "index.ts"), path.join("assembly", inner, "index.ts"));
70
- }
71
- for (const candidate of candidates) {
72
- const file = path.join(packageDir, candidate);
73
- if (candidate.endsWith(".ts") && !candidate.endsWith(".d.ts") && isFile(file)) return file;
74
- }
75
- return null;
76
- }
77
-
78
- /**
79
- * A bare import of a package the workspace declares (`workspaces`, or
80
- * pnpm-workspace.yaml), resolved in that package as an install would link it:
81
- * enzyme's mappings import `@enzymefinance/subgraph-utils`, its
82
- * `packages/utils`, whose `main` is `index.ts`. `workspace` maps package names
83
- * to their directories.
84
- */
85
- export function resolveWorkspacePackage(specifier: string, workspace: Map<string, string>): string | null {
86
- const split = splitSpecifier(specifier);
87
- if (!split) return null;
88
- const [name, inner] = split;
89
- const packageDir = workspace.get(name);
90
- if (!packageDir) return null;
91
- if (inner === "") {
92
- const { main } = readManifest(packageDir);
93
- if (typeof main === "string") {
94
- const base = path.join(packageDir, main);
95
- const file = [base, `${base}.ts`, `${base}.js`, path.join(base, "index.ts"), path.join(base, "index.js")].find(
96
- isFile,
97
- );
98
- if (file) return pathToFileURL(file).href;
99
- }
100
- }
101
- const found = resolveInPackage(packageDir, inner);
102
- return found ? pathToFileURL(found).href : null;
103
- }
104
-
105
- function readManifest(packageDir: string): { main?: unknown; scripts?: Record<string, unknown> } {
106
- try {
107
- return JSON.parse(readFileSync(path.join(packageDir, "package.json"), "utf8")) ?? {};
108
- } catch {
109
- return {};
110
- }
111
- }
112
-
113
- /**
114
- * Why a workspace package that `resolveWorkspacePackage` found no entry for
115
- * can't load: the `main` its package.json names isn't written yet. sushiswap's
116
- * `const` renders its own index.ts per network (`"prepare:mainnet": "mustache
117
- * ../../config/mainnet.json index.template.ts > index.ts"`), which the root runs
118
- * through `yarn workspaces run prepare:mainnet`.
119
- */
120
- export function unwrittenWorkspaceEntry(
121
- specifier: string,
122
- workspace: Map<string, string>,
123
- workspaceRoot: string | null,
124
- ): Error | null {
125
- const split = splitSpecifier(specifier);
126
- if (!split || split[1] !== "") return null;
127
- const [name] = split;
128
- const packageDir = workspace.get(name);
129
- if (!packageDir) return null;
130
- const { main, scripts } = readManifest(packageDir);
131
- if (typeof main !== "string") return null;
132
- const writers = Object.entries(scripts ?? {})
133
- .filter(([, script]) => typeof script === "string" && script.includes(path.basename(main)))
134
- .map(([script]) => script);
135
- const where = path.relative(workspaceRoot ?? packageDir, packageDir);
136
- return new Error(
137
- `${name} is a package of the project's workspace (${where}), and the ${main} its package.json names ` +
138
- "doesn't exist: " +
139
- (writers.length > 0
140
- ? `its scripts ${writers.join(", ")} write it. Run the one for your network, then start envio again.`
141
- : "a build step of that package writes it. Run it, then start envio again."),
142
- );
143
- }
@@ -1,67 +0,0 @@
1
- /**
2
- * `assemblyscript-regex`, the regular-expression library AssemblyScript
3
- * mappings import (Polymarket's resolution subgraph tests an update string with
4
- * it). The package is AssemblyScript through and through — `unchecked`, `<i32>`
5
- * casts, memory-level matching — so mappings get this JavaScript-backed class
6
- * with the same surface instead: a pattern, a `test`, an `exec` that answers a
7
- * match with its `index`, `input` and `matches` (the whole match, then each
8
- * group, an unmatched group as an empty string), and `replace`.
9
- */
10
-
11
- const JsRegExp = globalThis.RegExp;
12
-
13
- export class RegExpMatch {
14
- constructor(
15
- public index: number,
16
- public input: string,
17
- public matches: string[],
18
- ) {}
19
- }
20
-
21
- export class RegExp {
22
- lastIndex = 0;
23
- readonly source: string;
24
- readonly flags: string;
25
- private readonly re: globalThis.RegExp;
26
-
27
- constructor(pattern: string, flags = "") {
28
- this.source = pattern;
29
- this.flags = flags;
30
- this.re = new JsRegExp(pattern, flags);
31
- }
32
-
33
- get global(): boolean {
34
- return this.re.global;
35
- }
36
- get ignoreCase(): boolean {
37
- return this.re.ignoreCase;
38
- }
39
- get multiline(): boolean {
40
- return this.re.multiline;
41
- }
42
-
43
- test(text: string): boolean {
44
- return this.exec(text) !== null;
45
- }
46
-
47
- exec(text: string): RegExpMatch | null {
48
- const sticky = this.re.global || this.re.sticky;
49
- if (sticky) this.re.lastIndex = this.lastIndex;
50
- const match = this.re.exec(text);
51
- if (sticky) this.lastIndex = match ? this.re.lastIndex : 0;
52
- if (!match) return null;
53
- return new RegExpMatch(
54
- match.index,
55
- text,
56
- Array.from(match, (group) => group ?? ""),
57
- );
58
- }
59
-
60
- replace(text: string, replacement: string): string {
61
- return text.replace(this.re, replacement);
62
- }
63
-
64
- toString(): string {
65
- return `/${this.source}/${this.flags}`;
66
- }
67
- }