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,196 +0,0 @@
1
- // Generated by ReScript, PLEASE EDIT WITH CARE
2
-
3
- import * as Utils from "../Utils.res.mjs";
4
- import * as Source from "./Source.res.mjs";
5
- import * as Internal from "../Internal.res.mjs";
6
- import * as BlockStore from "./BlockStore.res.mjs";
7
- import * as Performance from "../bindings/Performance.res.mjs";
8
- import * as Stdlib_Array from "@rescript/runtime/lib/es6/Stdlib_Array.js";
9
- import * as Stdlib_Option from "@rescript/runtime/lib/es6/Stdlib_Option.js";
10
- import * as Stdlib_Nullable from "@rescript/runtime/lib/es6/Stdlib_Nullable.js";
11
- import * as Primitive_exceptions from "@rescript/runtime/lib/es6/Primitive_exceptions.js";
12
-
13
- let installed = {
14
- contents: undefined
15
- };
16
-
17
- function install(fetchCalls, rpcUrls) {
18
- installed.contents = {
19
- fetchCalls: fetchCalls,
20
- rpcUrls: rpcUrls
21
- };
22
- }
23
-
24
- function callRankOf(registration) {
25
- return Internal.callRankOfEventName(registration.eventConfig.name);
26
- }
27
-
28
- function selectorOf(registration) {
29
- let match = Internal.callRankOfEventName(registration.eventConfig.name);
30
- if (match === 1) {
31
- return "0x" + registration.eventConfig.name.slice(13, 21).toLowerCase();
32
- } else {
33
- return null;
34
- }
35
- }
36
-
37
- function wrap(source, addressStore, ecosystem, installed) {
38
- let newrecord = {...source};
39
- newrecord.getItemsOrThrow = async (fromBlock, toBlock, addressSet, reorgableFrom, knownHeight, partitionId, selection, itemsTarget, retry, logger) => {
40
- let callRegistrations = selection.onEventRegistrations.filter(registration => Stdlib_Option.isSome(Internal.callRankOfEventName(registration.eventConfig.name)));
41
- if (Utils.$$Array.isEmpty(callRegistrations)) {
42
- return await source.getItemsOrThrow(fromBlock, toBlock, addressSet, reorgableFrom, knownHeight, partitionId, selection, itemsTarget, retry, logger);
43
- }
44
- let logRegistrations = selection.onEventRegistrations.filter(registration => Stdlib_Option.isNone(Internal.callRankOfEventName(registration.eventConfig.name)));
45
- let logs;
46
- if (Utils.$$Array.isEmpty(logRegistrations) && Utils.$$Array.isEmpty(selection.onBlockRegistrations)) {
47
- logs = undefined;
48
- } else {
49
- let newrecord = {...selection};
50
- logs = await source.getItemsOrThrow(fromBlock, toBlock, addressSet, reorgableFrom, knownHeight, partitionId, (newrecord.onEventRegistrations = logRegistrations, newrecord), itemsTarget, retry, logger);
51
- }
52
- let rangeEnd = logs !== undefined ? logs.latestFetchedBlockNumber : (
53
- toBlock !== undefined ? toBlock : Math.min(knownHeight, fromBlock + 1000000 | 0)
54
- );
55
- let clientFiltered = contractName => {
56
- let contractNames = selection.clientFilteredContracts;
57
- if (contractNames !== undefined) {
58
- return contractNames.includes(contractName);
59
- } else {
60
- return false;
61
- }
62
- };
63
- let addresses = {};
64
- callRegistrations.forEach(registration => {
65
- let contractName = registration.eventConfig.contractName;
66
- if (!registration.isWildcard && Stdlib_Option.isNone(addresses[contractName])) {
67
- addresses[contractName] = clientFiltered(contractName) ? addressStore.contractAddresses(contractName, false) : addressSet.addressesOf(contractName);
68
- return;
69
- }
70
- });
71
- let startedAt = Performance.now();
72
- let response;
73
- try {
74
- response = await installed.fetchCalls({
75
- chainId: source.chainId,
76
- fromBlock: fromBlock,
77
- toBlock: rangeEnd,
78
- registrations: callRegistrations.map(registration => ({
79
- index: registration.index,
80
- contractName: registration.eventConfig.contractName,
81
- eventName: registration.eventConfig.name,
82
- selector: selectorOf(registration),
83
- rank: Stdlib_Option.getOr(Internal.callRankOfEventName(registration.eventConfig.name), 1),
84
- isWildcard: registration.isWildcard,
85
- startBlock: Stdlib_Nullable.fromOption(registration.startBlock)
86
- })),
87
- addresses: addresses,
88
- rpcUrls: installed.rpcUrls
89
- });
90
- } catch (raw_exn) {
91
- let exn = Primitive_exceptions.internalToException(raw_exn);
92
- throw {
93
- RE_EXN_ID: Source.GetItemsError,
94
- _1: {
95
- TAG: "FailedGettingItems",
96
- exn: exn,
97
- attemptedToBlock: rangeEnd,
98
- retry: {
99
- TAG: "WithBackoff",
100
- message: `Failed reading the calls of blocks ` + fromBlock.toString() + ` to ` + rangeEnd.toString() + `. Attempt a retry.`,
101
- backoffMillis: retry !== 0 ? 1000 * retry | 0 : 500
102
- },
103
- requestStats: []
104
- },
105
- Error: new Error()
106
- };
107
- }
108
- let callSeconds = Performance.secondsSince(startedAt);
109
- let registrationByIndex = {};
110
- callRegistrations.forEach(registration => {
111
- registrationByIndex[registration.index.toString()] = registration;
112
- });
113
- let latest = response.latestFetchedBlockNumber;
114
- let callItems = Stdlib_Array.filterMap(response.items, callItem => {
115
- let registration = registrationByIndex[callItem.registrationIndex.toString()];
116
- let contractName = registration.eventConfig.contractName;
117
- let ownsCall = true;
118
- if (!registration.isWildcard) {
119
- let address = callItem.payload.srcAddress;
120
- ownsCall = clientFiltered(contractName) ? addressStore.isIndexedAt(address, contractName, callItem.blockNumber) : addressSet.containsAt(address, contractName, callItem.blockNumber);
121
- }
122
- if (!(callItem.blockNumber <= latest && ownsCall)) {
123
- return;
124
- }
125
- let item_1 = source.chainId;
126
- let item_2 = callItem.blockNumber;
127
- let item_4 = callItem.traceAddress;
128
- let item_5 = callItem.transactionIndex;
129
- let item_6 = callItem.payload;
130
- let item = {
131
- kind: 0,
132
- onEventRegistration: registration,
133
- chainId: item_1,
134
- blockNumber: item_2,
135
- logIndex: 0,
136
- orderPath: item_4,
137
- transactionIndex: item_5,
138
- payload: item_6
139
- };
140
- Internal.markItemCall(item, Stdlib_Option.getOr(Internal.callRankOfEventName(registration.eventConfig.name), 1));
141
- return item;
142
- });
143
- let callBlocks = BlockStore.fromJs(response.blocks, ecosystem);
144
- let callRequestStat = {
145
- method: "getCalls",
146
- seconds: callSeconds
147
- };
148
- if (logs !== undefined) {
149
- logs.blockStore.appendPage(callBlocks);
150
- return {
151
- knownHeight: logs.knownHeight,
152
- parsedQueueItems: logs.parsedQueueItems.filter(item => item.blockNumber <= latest).concat(callItems),
153
- transactionStore: logs.transactionStore,
154
- blockStore: logs.blockStore,
155
- latestFetchedBlockNumber: Math.min(logs.latestFetchedBlockNumber, latest),
156
- stats: logs.stats,
157
- requestStats: logs.requestStats.concat([callRequestStat])
158
- };
159
- } else {
160
- return {
161
- knownHeight: Stdlib_Nullable.getOr(response.knownHeight, knownHeight),
162
- parsedQueueItems: callItems,
163
- transactionStore: undefined,
164
- blockStore: callBlocks,
165
- latestFetchedBlockNumber: latest,
166
- stats: {
167
- "total time elapsed (s)": callSeconds
168
- },
169
- requestStats: [callRequestStat]
170
- };
171
- }
172
- };
173
- return newrecord;
174
- }
175
-
176
- function wrapSources(sources, onEventRegistrations, addressStore, ecosystem) {
177
- let installed$1 = installed.contents;
178
- if (installed$1 !== undefined && onEventRegistrations.some(registration => Stdlib_Option.isSome(Internal.callRankOfEventName(registration.eventConfig.name)))) {
179
- return sources.map(source => wrap(source, addressStore, ecosystem, installed$1));
180
- } else {
181
- return sources;
182
- }
183
- }
184
-
185
- let openEndedSpan = 1000000;
186
-
187
- export {
188
- installed,
189
- install,
190
- openEndedSpan,
191
- callRankOf,
192
- selectorOf,
193
- wrap,
194
- wrapSources,
195
- }
196
- /* Utils Not a pure module */
@@ -1,84 +0,0 @@
1
- /**
2
- * Contract-call signatures and ABI type lists as graph codegen writes them.
3
- * Free of envio imports: the graph-ts shim reads them too.
4
- */
5
-
6
- export type ParsedSignature = {
7
- name: string;
8
- inputs: string;
9
- outputs: string;
10
- };
11
-
12
- /**
13
- * graph codegen emits `"balanceOf(address):(uint256)"`. Types only, no names —
14
- * which is all the ABI codec needs.
15
- */
16
- export function parseSignature(signature: string): ParsedSignature {
17
- const open = signature.indexOf("(");
18
- if (open === -1) {
19
- throw new Error(`Unreadable contract call signature "${signature}"`);
20
- }
21
- const name = signature.slice(0, open);
22
-
23
- let depth = 0;
24
- let close = -1;
25
- for (let index = open; index < signature.length; index++) {
26
- const char = signature[index];
27
- if (char === "(") depth++;
28
- if (char === ")") {
29
- depth--;
30
- if (depth === 0) {
31
- close = index;
32
- break;
33
- }
34
- }
35
- }
36
- if (close === -1) {
37
- throw new Error(`Unreadable contract call signature "${signature}"`);
38
- }
39
-
40
- const inputs = signature.slice(open + 1, close);
41
- const rest = signature.slice(close + 1).replace(/^:/, "");
42
- const outputs = rest.startsWith("(") ? rest.slice(1, -1) : rest;
43
-
44
- return { name, inputs, outputs };
45
- }
46
-
47
- /** `address,(uint256,bytes)` → `["address", "(uint256,bytes)"]`. */
48
- export function splitTypes(list: string): string[] {
49
- const types: string[] = [];
50
- let depth = 0;
51
- let start = 0;
52
- for (let index = 0; index < list.length; index++) {
53
- const char = list[index];
54
- if (char === "(") depth++;
55
- else if (char === ")") depth--;
56
- else if (char === "," && depth === 0) {
57
- types.push(list.slice(start, index));
58
- start = index + 1;
59
- }
60
- }
61
- if (list.length > 0) types.push(list.slice(start));
62
- return types;
63
- }
64
-
65
- type AbiParam = { type: string; components?: AbiParam[] };
66
-
67
- /** An ABI parameter's type as graph codegen spells it: a tuple as `(…)`, keeping its array suffix. */
68
- function abiTypeString(param: AbiParam): string {
69
- if (!param.type.startsWith("tuple")) return param.type;
70
- return `(${(param.components ?? []).map(abiTypeString).join(",")})${param.type.slice("tuple".length)}`;
71
- }
72
-
73
- /** The first function named `name` in an ABI, as graph codegen's call signature: `name(inputs):(outputs)`. */
74
- export function functionSignature(abi: unknown, name: string): string | null {
75
- const record = abi as { abi?: unknown; compilerOutput?: { abi?: unknown } } | null;
76
- const entries = Array.isArray(abi) ? abi : (record?.abi ?? record?.compilerOutput?.abi);
77
- if (!Array.isArray(entries)) return null;
78
- const found = entries.find(
79
- (entry) => (entry?.type ?? "function") === "function" && entry?.name === name,
80
- ) as { inputs?: AbiParam[]; outputs?: AbiParam[] } | undefined;
81
- if (!found) return null;
82
- const list = (params: AbiParam[] | undefined) => (params ?? []).map(abiTypeString).join(",");
83
- return `${name}(${list(found.inputs)}):(${list(found.outputs)})`;
84
- }