envio 3.14.0-subgraph → 3.14.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 (63) hide show
  1. package/evm.schema.json +1 -1
  2. package/package.json +6 -6
  3. package/src/Config.res +0 -9
  4. package/src/Config.res.mjs +2 -6
  5. package/src/Core.res +0 -21
  6. package/src/Core.res.mjs +0 -17
  7. package/src/EventProcessing.res +6 -6
  8. package/src/EventProcessing.res.mjs +6 -8
  9. package/src/HandlerLoader.res +22 -48
  10. package/src/HandlerLoader.res.mjs +15 -41
  11. package/src/HandlerTypeCheck.res +207 -0
  12. package/src/HandlerTypeCheck.res.mjs +262 -0
  13. package/src/LoadLayer.res +7 -39
  14. package/src/LoadLayer.res.mjs +38 -65
  15. package/src/LoadLayer.resi +0 -28
  16. package/src/PgStorage.res +5 -24
  17. package/src/PgStorage.res.mjs +1 -18
  18. package/src/UserContext.res +62 -377
  19. package/src/UserContext.res.mjs +39 -297
  20. package/src/bindings/NodeJs.res +31 -0
  21. package/src/bindings/NodeJs.res.mjs +3 -0
  22. package/src/db/Table.res +0 -10
  23. package/src/db/Table.res.mjs +11 -22
  24. package/src/sources/EvmRpcClient.res +2 -0
  25. package/src/sources/RpcSource.res +17 -4
  26. package/src/sources/RpcSource.res.mjs +23 -5
  27. package/src/sources/SourceManager.res +63 -40
  28. package/src/sources/SourceManager.res.mjs +32 -20
  29. package/src/HandlerTypeCheck.mjs +0 -14
  30. package/src/HandlerTypeCheckWorker.mjs +0 -68
  31. package/src/SyncWrites.res +0 -86
  32. package/src/SyncWrites.res.mjs +0 -85
  33. package/src/subgraph/abi-types.ts +0 -63
  34. package/src/subgraph/assemblyscript.ts +0 -85
  35. package/src/subgraph/blocks.ts +0 -183
  36. package/src/subgraph/calls.ts +0 -149
  37. package/src/subgraph/conformance.ts +0 -83
  38. package/src/subgraph/errors.ts +0 -96
  39. package/src/subgraph/graph-cli-worker.mjs +0 -26
  40. package/src/subgraph/graph-cli.ts +0 -190
  41. package/src/subgraph/graph-ts-enums.ts +0 -28
  42. package/src/subgraph/graph-ts-types/VERSION +0 -2
  43. package/src/subgraph/graph-ts-types/chain/arweave.d.ts +0 -70
  44. package/src/subgraph/graph-ts-types/chain/cosmos.d.ts +0 -327
  45. package/src/subgraph/graph-ts-types/chain/ethereum.d.ts +0 -233
  46. package/src/subgraph/graph-ts-types/chain/near.d.ts +0 -253
  47. package/src/subgraph/graph-ts-types/chain/starknet.d.ts +0 -32
  48. package/src/subgraph/graph-ts-types/common/collections.d.ts +0 -136
  49. package/src/subgraph/graph-ts-types/common/conversion.d.ts +0 -11
  50. package/src/subgraph/graph-ts-types/common/datasource.d.ts +0 -30
  51. package/src/subgraph/graph-ts-types/common/eager-offset.d.ts +0 -0
  52. package/src/subgraph/graph-ts-types/common/json.d.ts +0 -17
  53. package/src/subgraph/graph-ts-types/common/numbers.d.ts +0 -120
  54. package/src/subgraph/graph-ts-types/common/value.d.ts +0 -120
  55. package/src/subgraph/graph-ts-types/common/yaml.d.ts +0 -90
  56. package/src/subgraph/graph-ts-types/global/global.d.ts +0 -194
  57. package/src/subgraph/graph-ts-types/helper-functions.d.ts +0 -22
  58. package/src/subgraph/graph-ts-types/index.d.ts +0 -102
  59. package/src/subgraph/graph-ts.ts +0 -2285
  60. package/src/subgraph/hosts.ts +0 -158
  61. package/src/subgraph/rpc.ts +0 -65
  62. package/src/subgraph/runtime.ts +0 -595
  63. package/src/subgraph/scope.ts +0 -68
package/evm.schema.json CHANGED
@@ -543,7 +543,7 @@
543
543
  "type": "object",
544
544
  "properties": {
545
545
  "url": {
546
- "description": "The RPC endpoint URL.",
546
+ "description": "The RPC endpoint URL. An entry whose url is empty, for example `${RPC_URL:-}` with the variable unset, is ignored.",
547
547
  "type": "string"
548
548
  },
549
549
  "for": {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "envio",
3
- "version": "3.14.0-subgraph",
3
+ "version": "3.14.1",
4
4
  "type": "module",
5
5
  "description": "A latency and sync speed optimized, developer friendly blockchain data indexer.",
6
6
  "bin": "./bin.mjs",
@@ -54,10 +54,10 @@
54
54
  "postgres": "3.4.8"
55
55
  },
56
56
  "optionalDependencies": {
57
- "envio-linux-x64": "3.14.0-subgraph",
58
- "envio-linux-x64-musl": "3.14.0-subgraph",
59
- "envio-linux-arm64": "3.14.0-subgraph",
60
- "envio-darwin-x64": "3.14.0-subgraph",
61
- "envio-darwin-arm64": "3.14.0-subgraph"
57
+ "envio-linux-x64": "3.14.1",
58
+ "envio-linux-x64-musl": "3.14.1",
59
+ "envio-linux-arm64": "3.14.1",
60
+ "envio-darwin-x64": "3.14.1",
61
+ "envio-darwin-arm64": "3.14.1"
62
62
  }
63
63
  }
package/src/Config.res CHANGED
@@ -151,9 +151,6 @@ type t = {
151
151
  // reach, so its checkpoints have to be comparable across chains.
152
152
  checkpointSequence: CheckpointSequence.t,
153
153
  envioInfo: JSON.t,
154
- // Set only in subgraph mode: the translated manifest, which is what makes
155
- // the subgraph runtime take over handler registration.
156
- subgraph: option<JSON.t>,
157
154
  }
158
155
 
159
156
  type rpcSourceFor = | @as("sync") Sync | @as("fallback") Fallback | @as("realtime") Realtime
@@ -615,7 +612,6 @@ let publicConfigSchema = S.schema(s =>
615
612
  "svm": s.matches(S.option(publicConfigEcosystemSchema)),
616
613
  "enums": s.matches(S.option(S.dict(S.array(S.string)))),
617
614
  "entities": s.matches(S.option(S.array(entityJsonSchema))),
618
- "subgraph": s.matches(S.option(S.json(~validate=false))),
619
615
  }
620
616
  )
621
617
 
@@ -698,10 +694,6 @@ let toEnvioInfo = (publicConfigJson: JSON.t): JSON.t => {
698
694
  switch envioInfo {
699
695
  | Object(obj) => {
700
696
  commandFields->Array.forEach(field => obj->Utils.Dict.deleteInPlace(field))
701
- // The subgraph blob is how the runtime finds mappings. None of it
702
- // describes stored data — that's already in `evm` / `entities` — so a
703
- // specVersion bump or a mapping-path edit must not force a reset.
704
- obj->Utils.Dict.deleteInPlace("subgraph")
705
697
  ecosystemFields->Array.forEach(ecosystem =>
706
698
  switch obj->Dict.get(ecosystem) {
707
699
  | Some(Object(ecosystemDict)) => ecosystemDict->Utils.Dict.deleteInPlace("chains")
@@ -1191,7 +1183,6 @@ let fromPublic = (publicConfigJson: JSON.t) => {
1191
1183
  allEnums,
1192
1184
  checkpointSequence: CheckpointSequence.fromEntities(userEntities),
1193
1185
  envioInfo: publicConfigJson->toEnvioInfo,
1194
- subgraph: publicConfig["subgraph"],
1195
1186
  }
1196
1187
 
1197
1188
  switch publicConfig["isolatedChains"] {
@@ -450,8 +450,7 @@ let publicConfigSchema = S$RescriptSchema.schema(s => ({
450
450
  fuel: s.m(S$RescriptSchema.option(publicConfigEcosystemSchema)),
451
451
  svm: s.m(S$RescriptSchema.option(publicConfigEcosystemSchema)),
452
452
  enums: s.m(S$RescriptSchema.option(S$RescriptSchema.dict(S$RescriptSchema.array(S$RescriptSchema.string)))),
453
- entities: s.m(S$RescriptSchema.option(S$RescriptSchema.array(entityJsonSchema))),
454
- subgraph: s.m(S$RescriptSchema.option(S$RescriptSchema.json(false)))
453
+ entities: s.m(S$RescriptSchema.option(S$RescriptSchema.array(entityJsonSchema)))
455
454
  }));
456
455
 
457
456
  function contractMappingOf(chainConfigs) {
@@ -521,7 +520,6 @@ function toEnvioInfo(publicConfigJson) {
521
520
  let envioInfo = JSON.parse(JSON.stringify(publicConfigJson));
522
521
  if (typeof envioInfo === "object" && envioInfo !== null && !Array.isArray(envioInfo)) {
523
522
  commandFields.forEach(field => Utils.Dict.deleteInPlace(envioInfo, field));
524
- Utils.Dict.deleteInPlace(envioInfo, "subgraph");
525
523
  ecosystemFields.forEach(ecosystem => {
526
524
  let match = envioInfo[ecosystem];
527
525
  if (typeof match === "object" && match !== null && !Array.isArray(match)) {
@@ -841,7 +839,6 @@ function fromPublic(publicConfigJson) {
841
839
  let config_projectFlags = Stdlib_Option.getOr(publicConfig.projectFlags, "");
842
840
  let config_checkpointSequence = CheckpointSequence.fromEntities(userEntities);
843
841
  let config_envioInfo = toEnvioInfo(publicConfigJson);
844
- let config_subgraph = publicConfig.subgraph;
845
842
  let config = {
846
843
  name: config_name,
847
844
  description: config_description,
@@ -869,8 +866,7 @@ function fromPublic(publicConfigJson) {
869
866
  userEntities: userEntities,
870
867
  allEnums: allEnums,
871
868
  checkpointSequence: config_checkpointSequence,
872
- envioInfo: config_envioInfo,
873
- subgraph: config_subgraph
869
+ envioInfo: config_envioInfo
874
870
  };
875
871
  let chainIds = publicConfig.isolatedChains;
876
872
  if (chainIds !== undefined) {
package/src/Core.res CHANGED
@@ -28,17 +28,8 @@ type fromUserApiResult = {
28
28
  indexerCode: Null.t<string>,
29
29
  }
30
30
 
31
- type fromSubgraphOptions = {
32
- name?: string,
33
- env?: dict<string>,
34
- files?: dict<string>,
35
- root?: string,
36
- }
37
-
38
31
  type addon = {
39
32
  getConfigJson: (~configPath: Null.t<string>, ~directory: Null.t<string>) => string,
40
- fromSubgraph: (string, string, fromSubgraphOptions) => fromUserApiResult,
41
- subgraphFileToJavascript: (string, string) => string,
42
33
  encodeIndexedTopic: (~abiType: string, ~value: unknown) => EvmTypes.Hex.t,
43
34
  isSvmPubkey: (~value: string) => bool,
44
35
  fromUserApi: (string, fromUserApiOptions) => fromUserApiResult,
@@ -314,18 +305,6 @@ let fromUserApi = (~schema=?, ~env=?, ~files=?, ~withIndexerTypes=false, yaml) =
314
305
  )
315
306
  }
316
307
 
317
- /// Parses a subgraph project without touching the filesystem: subgraph.yaml and
318
- /// its schema inline, ABI bodies through `files`.
319
- let fromSubgraph = (~name=?, ~env=?, ~files=?, ~root=?, ~manifest, ~schema) => {
320
- let addon = getAddon()
321
- addon.fromSubgraph(manifest, schema, {?name, ?env, ?files, ?root})
322
- }
323
-
324
- let subgraphFileToJavascript = (~source, ~path) => {
325
- let addon = getAddon()
326
- addon.subgraphFileToJavascript(source, path)
327
- }
328
-
329
308
  let runCli = args => {
330
309
  let addon = getAddon()
331
310
  addon.runCli(~args, ~envioPackageDir=Null.make(envioPackageDir))
package/src/Core.res.mjs CHANGED
@@ -232,21 +232,6 @@ function fromUserApi(schema, env, files, withIndexerTypesOpt, yaml) {
232
232
  });
233
233
  }
234
234
 
235
- function fromSubgraph(name, env, files, root, manifest, schema) {
236
- let addon = getAddon();
237
- return addon.fromSubgraph(manifest, schema, {
238
- name: name,
239
- env: env,
240
- files: files,
241
- root: root
242
- });
243
- }
244
-
245
- function subgraphFileToJavascript(source, path) {
246
- let addon = getAddon();
247
- return addon.subgraphFileToJavascript(source, path);
248
- }
249
-
250
235
  function runCli(args) {
251
236
  let addon = getAddon();
252
237
  return addon.runCli(args, envioPackageDir);
@@ -268,8 +253,6 @@ export {
268
253
  getAddon,
269
254
  getConfigJson,
270
255
  fromUserApi,
271
- fromSubgraph,
272
- subgraphFileToJavascript,
273
256
  runCli,
274
257
  }
275
258
  /* envioPackageDir Not a pure module */
@@ -51,7 +51,7 @@ let runEventHandlerOrThrow = async (
51
51
  isPreload: false,
52
52
  chains,
53
53
  config,
54
- sync: UserContext.makeSyncState(),
54
+ isResolved: false,
55
55
  }
56
56
  await handler(
57
57
  (
@@ -61,7 +61,7 @@ let runEventHandlerOrThrow = async (
61
61
  }: Internal.handlerArgs
62
62
  ),
63
63
  )
64
- contextParams.sync.status = Resolved
64
+ contextParams.isResolved = true
65
65
  } catch {
66
66
  | exn =>
67
67
  throw(
@@ -102,7 +102,7 @@ let runHandlerOrThrow = async (
102
102
  isPreload: false,
103
103
  chains,
104
104
  config,
105
- sync: UserContext.makeSyncState(),
105
+ isResolved: false,
106
106
  }
107
107
  await handler(
108
108
  Ecosystem.makeOnBlockArgs(
@@ -111,7 +111,7 @@ let runHandlerOrThrow = async (
111
111
  ~context=UserContext.getHandlerContext(contextParams),
112
112
  ),
113
113
  )
114
- contextParams.sync.status = Resolved
114
+ contextParams.isResolved = true
115
115
  } catch {
116
116
  | exn =>
117
117
  throw(
@@ -186,7 +186,7 @@ let preloadBatchOrThrow = async (
186
186
  checkpointId,
187
187
  isPreload: true,
188
188
  chains,
189
- sync: UserContext.makeSyncState(),
189
+ isResolved: false,
190
190
  config,
191
191
  }),
192
192
  })
@@ -221,7 +221,7 @@ let preloadBatchOrThrow = async (
221
221
  checkpointId,
222
222
  isPreload: true,
223
223
  chains,
224
- sync: UserContext.makeSyncState(),
224
+ isResolved: false,
225
225
  config,
226
226
  }),
227
227
  )
@@ -38,7 +38,6 @@ let ProcessingError = /* @__PURE__ */Primitive_exceptions.create("EventProcessin
38
38
  async function runEventHandlerOrThrow(item, checkpointId, handler, indexerState, loadManager, persistence, chains, config) {
39
39
  let timeBeforeHandler = Performance.now();
40
40
  try {
41
- let contextParams_sync = UserContext.makeSyncState();
42
41
  let contextParams = {
43
42
  item: item,
44
43
  checkpointId: checkpointId,
@@ -48,13 +47,13 @@ async function runEventHandlerOrThrow(item, checkpointId, handler, indexerState,
48
47
  isPreload: false,
49
48
  chains: chains,
50
49
  config: config,
51
- sync: contextParams_sync
50
+ isResolved: false
52
51
  };
53
52
  await handler({
54
53
  event: Ecosystem.getItemEvent(item, config.ecosystem),
55
54
  context: UserContext.getHandlerContext(contextParams)
56
55
  });
57
- contextParams_sync.status = "Resolved";
56
+ contextParams.isResolved = true;
58
57
  } catch (raw_exn) {
59
58
  let exn = Primitive_exceptions.internalToException(raw_exn);
60
59
  throw {
@@ -80,7 +79,6 @@ async function runHandlerOrThrow(item, checkpointId, indexerState, loadManager,
80
79
  }
81
80
  }
82
81
  try {
83
- let contextParams_sync = UserContext.makeSyncState();
84
82
  let contextParams = {
85
83
  item: item,
86
84
  checkpointId: checkpointId,
@@ -90,10 +88,10 @@ async function runHandlerOrThrow(item, checkpointId, indexerState, loadManager,
90
88
  isPreload: false,
91
89
  chains: chains,
92
90
  config: config,
93
- sync: contextParams_sync
91
+ isResolved: false
94
92
  };
95
93
  await item.onBlockRegistration.handler(Ecosystem.makeOnBlockArgs(item.blockNumber, config.ecosystem, UserContext.getHandlerContext(contextParams)));
96
- contextParams_sync.status = "Resolved";
94
+ contextParams.isResolved = true;
97
95
  return;
98
96
  } catch (raw_exn) {
99
97
  let exn = Primitive_exceptions.internalToException(raw_exn);
@@ -135,7 +133,7 @@ async function preloadBatchOrThrow(batch, loadManager, persistence, config, inde
135
133
  isPreload: true,
136
134
  chains: chains,
137
135
  config: config,
138
- sync: UserContext.makeSyncState()
136
+ isResolved: false
139
137
  })
140
138
  }).then(() => IndexerState.endPreloadHandler(indexerState, timerRef, contractName, eventName))));
141
139
  } catch (exn) {
@@ -153,7 +151,7 @@ async function preloadBatchOrThrow(batch, loadManager, persistence, config, inde
153
151
  isPreload: true,
154
152
  chains: chains,
155
153
  config: config,
156
- sync: UserContext.makeSyncState()
154
+ isResolved: false
157
155
  })))));
158
156
  } catch (exn$1) {
159
157
 
@@ -54,8 +54,8 @@ let registerContractHandlers = async (~contractName, ~handler: option<string>) =
54
54
  }
55
55
  }
56
56
 
57
- let globAutoLoadFiles = async (~handlers) => {
58
- let srcPattern = `./${handlers}/**/*.{js,mjs,ts}`
57
+ let getAutoLoadFiles = async (~config: Config.t) => {
58
+ let srcPattern = `./${config.handlers}/**/*.{js,mjs,ts}`
59
59
  try {
60
60
  let iterator = globIterator(srcPattern)
61
61
  let files = await iterator->Utils.Array.fromAsyncIterator
@@ -77,23 +77,6 @@ let globAutoLoadFiles = async (~handlers) => {
77
77
  }
78
78
  }
79
79
 
80
- let getAutoLoadFiles = async (~config: Config.t) =>
81
- switch config.subgraph {
82
- // A subgraph project's `src/` holds AssemblyScript mappings, not envio
83
- // handlers: auto-loading or type-checking them as TypeScript would fail.
84
- | Some(_) => []
85
- | None => await globAutoLoadFiles(~handlers=config.handlers)
86
- }
87
-
88
- type typeCheckResult = {
89
- skipped?: string,
90
- errors?: string,
91
- }
92
-
93
- @module("./HandlerTypeCheck.mjs")
94
- external checkTypesInWorker: (~cwd: string, ~files: array<string>) => promise<typeCheckResult> =
95
- "check"
96
-
97
80
  let typeCheck = async (~config: Config.t, ~autoLoadFiles) => {
98
81
  // A contract's `handler:` may also be an auto-loaded file.
99
82
  let files =
@@ -104,10 +87,13 @@ let typeCheck = async (~config: Config.t, ~autoLoadFiles) => {
104
87
  ->Utils.Set.fromArray
105
88
  ->Utils.Set.toArray
106
89
  if files->Array.length > 0 {
107
- switch await checkTypesInWorker(~cwd=NodeJs.Process.cwd(), ~files) {
108
- | {errors} => JsError.throwWithMessage(`Handler files have type errors:\n\n${errors}`)
109
- | {skipped} => Logging.warn(skipped)
110
- | _ => ()
90
+ switch await HandlerTypeCheck.check(~cwd=NodeJs.Process.cwd(), ~files) {
91
+ | TypeErrors(errors) =>
92
+ JsError.throwWithMessage(
93
+ `The handler type check found errors. Fix them to start the indexer:\n\n${errors}`,
94
+ )
95
+ | Skipped(warning) => Logging.warn(warning)
96
+ | Passed => ()
111
97
  }
112
98
  }
113
99
  }
@@ -117,12 +103,6 @@ let typeCheck = async (~config: Config.t, ~autoLoadFiles) => {
117
103
  // `HandlerRegister.finishRegistration`. This loads the user handler files
118
104
  // (populating the global `HandlerRegister` registry as a side effect) and
119
105
  // returns the resulting per-chain registrations.
120
- // The subgraph runtime lives in this package but is never exported: it's
121
- // reached only from here, when the resolved config carries a translated
122
- // manifest.
123
- let registerSubgraph: (JSON.t, ~isDev: bool) => promise<unit> = %raw(`(subgraph, isDev) =>
124
- import("./subgraph/runtime.ts").then((m) => m.registerSubgraph({ ...subgraph, isDev }))`)
125
-
126
106
  let registerAllHandlers = async (
127
107
  ~config: Config.t,
128
108
  ~autoLoadFiles,
@@ -130,27 +110,21 @@ let registerAllHandlers = async (
130
110
  HandlerRegister.startRegistration(~config)
131
111
  registerTsHooks()
132
112
 
133
- switch config.subgraph {
134
- // Registered after the TypeScript hooks, so the subgraph runtime's own hooks
135
- // see a mapping first.
136
- | Some(subgraph) => await registerSubgraph(subgraph, ~isDev=config.isDev)
137
- | None =>
138
- let _ = await autoLoadFiles
139
- ->Array.map(file => {
140
- importHandler(file)->Promise.catch(exn => {
141
- let cause = exn->Utils.prettifyExn->Obj.magic
142
- Logging.errorWithExn(exn, `Failed to auto-load handler file: ${file}`)
143
- JsError.throwWithMessage(`Failed to auto-load handler file: ${file}. Cause: ${cause}`)
144
- })
113
+ let _ = await autoLoadFiles
114
+ ->Array.map(file => {
115
+ importHandler(file)->Promise.catch(exn => {
116
+ let cause = exn->Utils.prettifyExn->Obj.magic
117
+ Logging.errorWithExn(exn, `Failed to auto-load handler file: ${file}`)
118
+ JsError.throwWithMessage(`Failed to auto-load handler file: ${file}. Cause: ${cause}`)
145
119
  })
146
- ->Promise.all
120
+ })
121
+ ->Promise.all
147
122
 
148
- let _ = await config.contractHandlers
149
- ->Array.map(({name, handler}) => {
150
- registerContractHandlers(~contractName=name, ~handler)
151
- })
152
- ->Promise.all
153
- }
123
+ let _ = await config.contractHandlers
124
+ ->Array.map(({name, handler}) => {
125
+ registerContractHandlers(~contractName=name, ~handler)
126
+ })
127
+ ->Promise.all
154
128
 
155
129
  HandlerRegister.finishRegistration(~config)
156
130
  }
@@ -10,10 +10,10 @@ import * as Stdlib_Array from "@rescript/runtime/lib/es6/Stdlib_Array.js";
10
10
  import * as Stdlib_JsError from "@rescript/runtime/lib/es6/Stdlib_JsError.js";
11
11
  import * as Stdlib_Promise from "@rescript/runtime/lib/es6/Stdlib_Promise.js";
12
12
  import * as HandlerRegister from "./HandlerRegister.res.mjs";
13
+ import * as HandlerTypeCheck from "./HandlerTypeCheck.res.mjs";
13
14
  import * as Promises from "node:fs/promises";
14
15
  import * as TsModuleHooksMjs from "./TsModuleHooks.mjs";
15
16
  import * as Primitive_exceptions from "@rescript/runtime/lib/es6/Primitive_exceptions.js";
16
- import * as HandlerTypeCheckMjs from "./HandlerTypeCheck.mjs";
17
17
 
18
18
  function registerTsHooksWith(prim) {
19
19
  TsModuleHooksMjs.register(prim);
@@ -58,8 +58,8 @@ async function registerContractHandlers(contractName, handler) {
58
58
  }
59
59
  }
60
60
 
61
- async function globAutoLoadFiles(handlers) {
62
- let srcPattern = `./` + handlers + `/**/*.{js,mjs,ts}`;
61
+ async function getAutoLoadFiles(config) {
62
+ let srcPattern = `./` + config.handlers + `/**/*.{js,mjs,ts}`;
63
63
  try {
64
64
  let iterator = Promises.glob(srcPattern);
65
65
  let files = await Utils.$$Array.fromAsyncIterator(iterator);
@@ -70,53 +70,30 @@ async function globAutoLoadFiles(handlers) {
70
70
  }
71
71
  }
72
72
 
73
- async function getAutoLoadFiles(config) {
74
- let match = config.subgraph;
75
- if (match !== undefined) {
76
- return [];
77
- } else {
78
- return await globAutoLoadFiles(config.handlers);
79
- }
80
- }
81
-
82
- function checkTypesInWorker(prim0, prim1) {
83
- return HandlerTypeCheckMjs.check(prim0, prim1);
84
- }
85
-
86
73
  async function typeCheck(config, autoLoadFiles) {
87
74
  let files = Array.from(new Set(autoLoadFiles.concat(Stdlib_Array.filterMap(config.contractHandlers, param => param.handler)).filter(isTypeScript).map(toAbsolutePath)));
88
75
  if (files.length === 0) {
89
76
  return;
90
77
  }
91
- let match = await HandlerTypeCheckMjs.check(Process.cwd(), files);
92
- let skipped = match.skipped;
93
- let errors = match.errors;
94
- if (errors !== undefined) {
95
- return Stdlib_JsError.throwWithMessage(`Handler files have type errors:\n\n` + errors);
96
- } else if (skipped !== undefined) {
97
- return Logging.warn(skipped);
98
- } else {
78
+ let errors = await HandlerTypeCheck.check(Process.cwd(), files);
79
+ if (typeof errors !== "object") {
99
80
  return;
81
+ } else if (errors.TAG === "TypeErrors") {
82
+ return Stdlib_JsError.throwWithMessage(`The handler type check found errors. Fix them to start the indexer:\n\n` + errors._0);
83
+ } else {
84
+ return Logging.warn(errors._0);
100
85
  }
101
86
  }
102
87
 
103
- let registerSubgraph = ((subgraph, isDev) =>
104
- import("./subgraph/runtime.ts").then((m) => m.registerSubgraph({ ...subgraph, isDev })));
105
-
106
88
  async function registerAllHandlers(config, autoLoadFiles) {
107
89
  HandlerRegister.startRegistration(config);
108
90
  registerTsHooks();
109
- let subgraph = config.subgraph;
110
- if (subgraph !== undefined) {
111
- await registerSubgraph(subgraph, config.isDev);
112
- } else {
113
- await Promise.all(autoLoadFiles.map(file => Stdlib_Promise.$$catch(importHandler(file), exn => {
114
- let cause = Utils.prettifyExn(exn);
115
- Logging.errorWithExn(exn, `Failed to auto-load handler file: ` + file);
116
- return Stdlib_JsError.throwWithMessage(`Failed to auto-load handler file: ` + file + `. Cause: ` + cause);
117
- })));
118
- await Promise.all(config.contractHandlers.map(param => registerContractHandlers(param.name, param.handler)));
119
- }
91
+ await Promise.all(autoLoadFiles.map(file => Stdlib_Promise.$$catch(importHandler(file), exn => {
92
+ let cause = Utils.prettifyExn(exn);
93
+ Logging.errorWithExn(exn, `Failed to auto-load handler file: ` + file);
94
+ return Stdlib_JsError.throwWithMessage(`Failed to auto-load handler file: ` + file + `. Cause: ` + cause);
95
+ })));
96
+ await Promise.all(config.contractHandlers.map(param => registerContractHandlers(param.name, param.handler)));
120
97
  return HandlerRegister.finishRegistration(config);
121
98
  }
122
99
 
@@ -127,11 +104,8 @@ export {
127
104
  toAbsolutePath,
128
105
  importHandler,
129
106
  registerContractHandlers,
130
- globAutoLoadFiles,
131
107
  getAutoLoadFiles,
132
- checkTypesInWorker,
133
108
  typeCheck,
134
- registerSubgraph,
135
109
  registerAllHandlers,
136
110
  }
137
111
  /* url Not a pure module */