@ensnode/ensdb-sdk 1.10.1 → 1.11.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.
package/dist/index.js CHANGED
@@ -9,23 +9,29 @@ var ensindexer_abstract_exports = {};
9
9
  __export(ensindexer_abstract_exports, {
10
10
  account: () => account,
11
11
  account_relations: () => account_relations,
12
+ domain: () => domain,
12
13
  domainEvent: () => domainEvent,
13
14
  domainResolverRelation: () => domainResolverRelation,
14
15
  domainResolverRelation_relations: () => domainResolverRelation_relations,
16
+ domainType: () => domainType,
15
17
  event: () => event,
16
18
  internal_registrarActionMetadata: () => internal_registrarActionMetadata,
17
19
  internal_registrarActionMetadataType: () => internal_registrarActionMetadataType,
18
20
  label: () => label,
19
21
  label_relations: () => label_relations,
20
22
  latestRegistrationIndex: () => latestRegistrationIndex,
23
+ latestRegistrationIndex_relations: () => latestRegistrationIndex_relations,
21
24
  latestRenewalIndex: () => latestRenewalIndex,
22
- migratedNode: () => migratedNode,
25
+ latestRenewalIndex_relations: () => latestRenewalIndex_relations,
26
+ migratedNodeByNode: () => migratedNodeByNode,
27
+ migratedNodeByParent: () => migratedNodeByParent,
23
28
  nameSales: () => nameSales,
24
29
  nameTokens: () => nameTokens,
25
30
  permissions: () => permissions,
26
31
  permissionsEvent: () => permissionsEvent,
27
32
  permissionsResource: () => permissionsResource,
28
33
  permissionsUser: () => permissionsUser,
34
+ permissionsUserEvent: () => permissionsUserEvent,
29
35
  registrarActionRelations: () => registrarActionRelations,
30
36
  registrarActionType: () => registrarActionType,
31
37
  registrarActions: () => registrarActions,
@@ -36,12 +42,12 @@ __export(ensindexer_abstract_exports, {
36
42
  registration_relations: () => registration_relations,
37
43
  registry: () => registry,
38
44
  registryCanonicalDomain: () => registryCanonicalDomain,
45
+ registryType: () => registryType,
46
+ relations_domain: () => relations_domain,
39
47
  relations_permissions: () => relations_permissions,
40
48
  relations_permissionsResource: () => relations_permissionsResource,
41
49
  relations_permissionsUser: () => relations_permissionsUser,
42
50
  relations_registry: () => relations_registry,
43
- relations_v1Domain: () => relations_v1Domain,
44
- relations_v2Domain: () => relations_v2Domain,
45
51
  renewal: () => renewal,
46
52
  renewal_relations: () => renewal_relations,
47
53
  resolver: () => resolver,
@@ -109,9 +115,7 @@ __export(ensindexer_abstract_exports, {
109
115
  subgraph_wrappedTransfer: () => subgraph_wrappedTransfer,
110
116
  subgraph_wrappedTransferRelations: () => subgraph_wrappedTransferRelations,
111
117
  subregistries: () => subregistries,
112
- subregistryRelations: () => subregistryRelations,
113
- v1Domain: () => v1Domain,
114
- v2Domain: () => v2Domain
118
+ subregistryRelations: () => subregistryRelations
115
119
  });
116
120
 
117
121
  // src/ensindexer-abstract/ensv2.schema.ts
@@ -121,9 +125,11 @@ var event = onchainTable(
121
125
  (t) => ({
122
126
  // Ponder's event.id
123
127
  id: t.text().primaryKey(),
128
+ // The HCA account address if used, otherwise Transaction.from.
129
+ sender: t.hex().notNull().$type(),
124
130
  // Event Log Metadata
125
131
  // chain
126
- chainId: t.integer().notNull().$type(),
132
+ chainId: t.int8({ mode: "number" }).notNull().$type(),
127
133
  // block
128
134
  blockNumber: t.bigint().notNull().$type(),
129
135
  blockHash: t.hex().notNull().$type(),
@@ -131,6 +137,8 @@ var event = onchainTable(
131
137
  // transaction
132
138
  transactionHash: t.hex().notNull().$type(),
133
139
  transactionIndex: t.integer().notNull(),
140
+ // `tx.from` — never HCA-aware. Always the EOA/relayer that submitted the transaction.
141
+ // Use `event.sender` for the HCA-aware actor.
134
142
  from: t.hex().notNull().$type(),
135
143
  to: t.hex().$type(),
136
144
  // NOTE: a null `to` means this was a tx that deployed a contract
@@ -144,6 +152,7 @@ var event = onchainTable(
144
152
  (t) => ({
145
153
  bySelector: index().on(t.selector),
146
154
  byFrom: index().on(t.from),
155
+ bySender: index().on(t.sender),
147
156
  byTimestamp: index().on(t.timestamp)
148
157
  })
149
158
  );
@@ -171,130 +180,114 @@ var permissionsEvent = onchainTable(
171
180
  }),
172
181
  (t) => ({ pk: primaryKey({ columns: [t.permissionsId, t.eventId] }) })
173
182
  );
183
+ var permissionsUserEvent = onchainTable(
184
+ "permissions_user_events",
185
+ (t) => ({
186
+ permissionsUserId: t.text().notNull().$type(),
187
+ eventId: t.text().notNull()
188
+ }),
189
+ (t) => ({ pk: primaryKey({ columns: [t.permissionsUserId, t.eventId] }) })
190
+ );
174
191
  var account = onchainTable("accounts", (t) => ({
175
192
  id: t.hex().primaryKey().$type()
176
193
  }));
177
194
  var account_relations = relations(account, ({ many }) => ({
178
195
  registrations: many(registration, { relationName: "registrant" }),
179
- domains: many(v2Domain),
196
+ domains: many(domain),
180
197
  permissions: many(permissionsUser)
181
198
  }));
199
+ var registryType = onchainEnum("RegistryType", [
200
+ "ENSv1Registry",
201
+ "ENSv1VirtualRegistry",
202
+ "ENSv2Registry"
203
+ ]);
182
204
  var registry = onchainTable(
183
205
  "registries",
184
206
  (t) => ({
185
207
  // see RegistryId for guarantees
186
208
  id: t.text().primaryKey().$type(),
187
- chainId: t.integer().notNull().$type(),
188
- address: t.hex().notNull().$type()
209
+ // has a type
210
+ type: registryType().notNull(),
211
+ chainId: t.int8({ mode: "number" }).notNull().$type(),
212
+ address: t.hex().notNull().$type(),
213
+ // If this is an ENSv1VirtualRegistry, `node` is the namehash of the parent ENSv1 domain that
214
+ // owns it, otherwise null.
215
+ node: t.hex().$type()
189
216
  }),
190
217
  (t) => ({
191
- byId: uniqueIndex().on(t.chainId, t.address)
218
+ // NOTE: non-unique index because multiple rows can share (chainId, address) across virtual registries
219
+ byChainAddress: index().on(t.chainId, t.address)
192
220
  })
193
221
  );
194
222
  var relations_registry = relations(registry, ({ one, many }) => ({
195
- domain: one(v2Domain, {
196
- relationName: "subregistry",
197
- fields: [registry.id],
198
- references: [v2Domain.registryId]
199
- }),
200
- domains: many(v2Domain, { relationName: "registry" }),
223
+ // domains that declare this registry as their parent registry
224
+ domains: many(domain, { relationName: "registry" }),
225
+ // domains that declare this registry as their subregistry
226
+ domainsAsSubregistry: many(domain, { relationName: "subregistry" }),
201
227
  permissions: one(permissions, {
202
228
  relationName: "permissions",
203
229
  fields: [registry.chainId, registry.address],
204
230
  references: [permissions.chainId, permissions.address]
205
231
  })
206
232
  }));
207
- var v1Domain = onchainTable(
208
- "v1_domains",
209
- (t) => ({
210
- // keyed by node, see ENSv1DomainId for guarantees.
211
- id: t.text().primaryKey().$type(),
212
- // must have a parent v1Domain (note: root node does not exist in index)
213
- parentId: t.text().notNull().$type(),
214
- // may have an owner
215
- ownerId: t.hex().$type(),
216
- // represents a labelHash
217
- labelHash: t.hex().notNull().$type(),
218
- // may have a `rootRegistryOwner` (ENSv1Registry's owner()), zeroAddress interpreted as null
219
- rootRegistryOwnerId: t.hex().$type()
220
- // NOTE: Domain-Resolver Relations tracked via Protocol Acceleration plugin
221
- }),
222
- (t) => ({
223
- byParent: index().on(t.parentId),
224
- byOwner: index().on(t.ownerId),
225
- byLabelHash: index().on(t.labelHash)
226
- })
227
- );
228
- var relations_v1Domain = relations(v1Domain, ({ one, many }) => ({
229
- // v1Domain
230
- parent: one(v1Domain, {
231
- fields: [v1Domain.parentId],
232
- references: [v1Domain.id]
233
- }),
234
- children: many(v1Domain, { relationName: "parent" }),
235
- rootRegistryOwner: one(account, {
236
- relationName: "rootRegistryOwner",
237
- fields: [v1Domain.rootRegistryOwnerId],
238
- references: [account.id]
239
- }),
240
- // shared
241
- owner: one(account, {
242
- relationName: "owner",
243
- fields: [v1Domain.ownerId],
244
- references: [account.id]
245
- }),
246
- label: one(label, {
247
- relationName: "label",
248
- fields: [v1Domain.labelHash],
249
- references: [label.labelHash]
250
- }),
251
- registrations: many(registration)
252
- }));
253
- var v2Domain = onchainTable(
254
- "v2_domains",
233
+ var domainType = onchainEnum("DomainType", ["ENSv1Domain", "ENSv2Domain"]);
234
+ var domain = onchainTable(
235
+ "domains",
255
236
  (t) => ({
256
- // see ENSv2DomainId for guarantees
237
+ // see DomainId for guarantees (ENSv1DomainId: `${ENSv1RegistryId}/${node}`, ENSv2DomainId: CAIP-19)
257
238
  id: t.text().primaryKey().$type(),
258
- // has a tokenId
259
- tokenId: t.bigint().notNull(),
260
- // belongs to registry
239
+ // has a type
240
+ type: domainType().notNull(),
241
+ // belongs to a registry
261
242
  registryId: t.text().notNull().$type(),
262
- // may have one subregistry
243
+ // may have a subregistry
263
244
  subregistryId: t.text().$type(),
264
- // may have an owner
265
- ownerId: t.hex().$type(),
245
+ // If this is an ENSv2Domain, the TokenId within the ENSv2Registry, otherwise null.
246
+ tokenId: t.bigint().$type(),
247
+ // If this is an ENSv1Domain, The Domain's namehash, otherwise null.
248
+ node: t.hex().$type(),
266
249
  // represents a labelHash
267
- labelHash: t.hex().notNull().$type()
250
+ labelHash: t.hex().notNull().$type(),
251
+ // If this is an ENSv1Domain, this is the effective owner of the Domain.
252
+ // If this is an ENSv2Domain, this is the on-chain owner address (the HCA account address if used).
253
+ ownerId: t.hex().$type(),
254
+ // If this is an ENSv1Domain, may have a `rootRegistryOwner`, otherwise null.
255
+ rootRegistryOwnerId: t.hex().$type()
268
256
  // NOTE: Domain-Resolver Relations tracked via Protocol Acceleration plugin
257
+ // NOTE: parent is derived via registryCanonicalDomain, not stored on the domain row
269
258
  }),
270
259
  (t) => ({
260
+ byType: index().on(t.type),
271
261
  byRegistry: index().on(t.registryId),
272
262
  bySubregistry: index().on(t.subregistryId).where(sql`${t.subregistryId} IS NOT NULL`),
273
263
  byOwner: index().on(t.ownerId),
274
264
  byLabelHash: index().on(t.labelHash)
275
265
  })
276
266
  );
277
- var relations_v2Domain = relations(v2Domain, ({ one, many }) => ({
278
- // v2Domain
267
+ var relations_domain = relations(domain, ({ one, many }) => ({
279
268
  registry: one(registry, {
280
269
  relationName: "registry",
281
- fields: [v2Domain.registryId],
270
+ fields: [domain.registryId],
282
271
  references: [registry.id]
283
272
  }),
284
273
  subregistry: one(registry, {
285
274
  relationName: "subregistry",
286
- fields: [v2Domain.subregistryId],
275
+ fields: [domain.subregistryId],
287
276
  references: [registry.id]
288
277
  }),
289
- // shared
290
278
  owner: one(account, {
291
279
  relationName: "owner",
292
- fields: [v2Domain.ownerId],
280
+ fields: [domain.ownerId],
281
+ references: [account.id]
282
+ }),
283
+ rootRegistryOwner: one(account, {
284
+ relationName: "rootRegistryOwner",
285
+ fields: [domain.rootRegistryOwnerId],
293
286
  references: [account.id]
294
287
  }),
295
288
  label: one(label, {
296
289
  relationName: "label",
297
- fields: [v2Domain.labelHash],
290
+ fields: [domain.labelHash],
298
291
  references: [label.labelHash]
299
292
  }),
300
293
  registrations: many(registration)
@@ -323,11 +316,13 @@ var registration = onchainTable(
323
316
  // maybe have a grace period (BaseRegistrar)
324
317
  gracePeriod: t.bigint(),
325
318
  // registrar AccountId
326
- registrarChainId: t.integer().notNull().$type(),
319
+ registrarChainId: t.int8({ mode: "number" }).notNull().$type(),
327
320
  registrarAddress: t.hex().notNull().$type(),
328
- // may reference a registrant
321
+ // may reference a registrant. If this is an ENSv2 Registration, the protocol-emitted
322
+ // registrant address (the HCA account address if used).
329
323
  registrantId: t.hex().$type(),
330
- // may reference an unregistrant
324
+ // may reference an unregistrant. If this is an ENSv2 Registration, the protocol-emitted
325
+ // unregistrant address (the HCA account address if used).
331
326
  unregistrantId: t.hex().$type(),
332
327
  // may have referrer data
333
328
  referrer: t.hex().$type(),
@@ -347,19 +342,11 @@ var registration = onchainTable(
347
342
  byId: uniqueIndex().on(t.domainId, t.registrationIndex)
348
343
  })
349
344
  );
350
- var latestRegistrationIndex = onchainTable("latest_registration_indexes", (t) => ({
351
- domainId: t.text().primaryKey().$type(),
352
- registrationIndex: t.integer().notNull()
353
- }));
354
345
  var registration_relations = relations(registration, ({ one, many }) => ({
355
- // belongs to either v1Domain or v2Domain
356
- v1Domain: one(v1Domain, {
357
- fields: [registration.domainId],
358
- references: [v1Domain.id]
359
- }),
360
- v2Domain: one(v2Domain, {
346
+ // belongs to a domain
347
+ domain: one(domain, {
361
348
  fields: [registration.domainId],
362
- references: [v2Domain.id]
349
+ references: [domain.id]
363
350
  }),
364
351
  // has one registrant
365
352
  registrant: one(account, {
@@ -367,6 +354,10 @@ var registration_relations = relations(registration, ({ one, many }) => ({
367
354
  references: [account.id],
368
355
  relationName: "registrant"
369
356
  }),
357
+ // has a latest registration index
358
+ latestRegistrationIndex: one(latestRegistrationIndex),
359
+ // has a latest renewal index
360
+ latestRenewalIndex: one(latestRenewalIndex),
370
361
  // has one unregistrant
371
362
  unregistrant: one(account, {
372
363
  fields: [registration.unregistrantId],
@@ -381,6 +372,17 @@ var registration_relations = relations(registration, ({ one, many }) => ({
381
372
  references: [event.id]
382
373
  })
383
374
  }));
375
+ var latestRegistrationIndex = onchainTable("latest_registration_indexes", (t) => ({
376
+ domainId: t.text().primaryKey().$type(),
377
+ registrationIndex: t.integer().notNull()
378
+ }));
379
+ var latestRegistrationIndex_relations = relations(latestRegistrationIndex, ({ one }) => ({
380
+ // references domain
381
+ domain: one(domain, {
382
+ fields: [latestRegistrationIndex.domainId],
383
+ references: [domain.id]
384
+ })
385
+ }));
384
386
  var renewal = onchainTable(
385
387
  "renewals",
386
388
  (t) => ({
@@ -426,11 +428,18 @@ var latestRenewalIndex = onchainTable(
426
428
  }),
427
429
  (t) => ({ pk: primaryKey({ columns: [t.domainId, t.registrationIndex] }) })
428
430
  );
431
+ var latestRenewalIndex_relations = relations(latestRenewalIndex, ({ one }) => ({
432
+ // references domain
433
+ domain: one(domain, {
434
+ fields: [latestRenewalIndex.domainId],
435
+ references: [domain.id]
436
+ })
437
+ }));
429
438
  var permissions = onchainTable(
430
439
  "permissions",
431
440
  (t) => ({
432
441
  id: t.text().primaryKey().$type(),
433
- chainId: t.integer().notNull().$type(),
442
+ chainId: t.int8({ mode: "number" }).notNull().$type(),
434
443
  address: t.hex().notNull().$type()
435
444
  }),
436
445
  (t) => ({
@@ -445,7 +454,7 @@ var permissionsResource = onchainTable(
445
454
  "permissions_resources",
446
455
  (t) => ({
447
456
  id: t.text().primaryKey().$type(),
448
- chainId: t.integer().notNull().$type(),
457
+ chainId: t.int8({ mode: "number" }).notNull().$type(),
449
458
  address: t.hex().notNull().$type(),
450
459
  resource: t.bigint().notNull()
451
460
  }),
@@ -463,9 +472,10 @@ var permissionsUser = onchainTable(
463
472
  "permissions_users",
464
473
  (t) => ({
465
474
  id: t.text().primaryKey().$type(),
466
- chainId: t.integer().notNull().$type(),
475
+ chainId: t.int8({ mode: "number" }).notNull().$type(),
467
476
  address: t.hex().notNull().$type(),
468
477
  resource: t.bigint().notNull(),
478
+ // The user/grantee address this Permission is granted to (the HCA account address if used).
469
479
  user: t.hex().notNull().$type(),
470
480
  // has one roles bitmap
471
481
  roles: t.bigint().notNull()
@@ -503,16 +513,33 @@ var label = onchainTable(
503
513
  })
504
514
  );
505
515
  var label_relations = relations(label, ({ many }) => ({
506
- domains: many(v2Domain)
516
+ domains: many(domain)
507
517
  }));
508
518
  var registryCanonicalDomain = onchainTable("registry_canonical_domains", (t) => ({
509
519
  registryId: t.text().primaryKey().$type(),
510
520
  domainId: t.text().notNull().$type()
511
521
  }));
512
522
 
523
+ // src/ensindexer-abstract/migrated-nodes.schema.ts
524
+ import { onchainTable as onchainTable2, primaryKey as primaryKey2 } from "ponder";
525
+ var migratedNodeByParent = onchainTable2(
526
+ "migrated_nodes_by_parent",
527
+ (t) => ({
528
+ // keyed by (parentNode, labelHash)
529
+ parentNode: t.hex().notNull().$type(),
530
+ labelHash: t.hex().notNull().$type()
531
+ }),
532
+ (t) => ({
533
+ pk: primaryKey2({ columns: [t.parentNode, t.labelHash] })
534
+ })
535
+ );
536
+ var migratedNodeByNode = onchainTable2("migrated_nodes_by_node", (t) => ({
537
+ node: t.hex().primaryKey().$type()
538
+ }));
539
+
513
540
  // src/ensindexer-abstract/protocol-acceleration.schema.ts
514
- import { onchainTable as onchainTable2, primaryKey as primaryKey2, relations as relations2, uniqueIndex as uniqueIndex2 } from "ponder";
515
- var reverseNameRecord = onchainTable2(
541
+ import { onchainTable as onchainTable3, primaryKey as primaryKey3, relations as relations2, uniqueIndex as uniqueIndex2 } from "ponder";
542
+ var reverseNameRecord = onchainTable3(
516
543
  "reverse_name_records",
517
544
  (t) => ({
518
545
  // keyed by (address, coinType)
@@ -526,22 +553,22 @@ var reverseNameRecord = onchainTable2(
526
553
  value: t.text().notNull().$type()
527
554
  }),
528
555
  (t) => ({
529
- pk: primaryKey2({ columns: [t.address, t.coinType] })
556
+ pk: primaryKey3({ columns: [t.address, t.coinType] })
530
557
  })
531
558
  );
532
- var domainResolverRelation = onchainTable2(
559
+ var domainResolverRelation = onchainTable3(
533
560
  "domain_resolver_relations",
534
561
  (t) => ({
535
- // keyed by (chainId, registry, node)
536
- chainId: t.integer().notNull().$type(),
562
+ // keyed by (chainId, address, node)
563
+ chainId: t.int8({ mode: "number" }).notNull().$type(),
537
564
  // The Registry (ENSv1Registry or ENSv2Registry)'s AccountId.
538
565
  address: t.hex().notNull().$type(),
539
- domainId: t.hex().notNull().$type(),
566
+ domainId: t.text().notNull().$type(),
540
567
  // The Domain's assigned Resolver's address (NOTE: always scoped to chainId)
541
568
  resolver: t.hex().notNull().$type()
542
569
  }),
543
570
  (t) => ({
544
- pk: primaryKey2({ columns: [t.chainId, t.address, t.domainId] })
571
+ pk: primaryKey3({ columns: [t.chainId, t.address, t.domainId] })
545
572
  })
546
573
  );
547
574
  var domainResolverRelation_relations = relations2(domainResolverRelation, ({ one }) => ({
@@ -550,12 +577,12 @@ var domainResolverRelation_relations = relations2(domainResolverRelation, ({ one
550
577
  references: [resolver.chainId, resolver.address]
551
578
  })
552
579
  }));
553
- var resolver = onchainTable2(
580
+ var resolver = onchainTable3(
554
581
  "resolvers",
555
582
  (t) => ({
556
583
  // keyed by (chainId, address)
557
584
  id: t.text().primaryKey().$type(),
558
- chainId: t.integer().notNull().$type(),
585
+ chainId: t.int8({ mode: "number" }).notNull().$type(),
559
586
  address: t.hex().notNull().$type()
560
587
  }),
561
588
  (t) => ({
@@ -565,12 +592,12 @@ var resolver = onchainTable2(
565
592
  var resolver_relations = relations2(resolver, ({ many }) => ({
566
593
  records: many(resolverRecords)
567
594
  }));
568
- var resolverRecords = onchainTable2(
595
+ var resolverRecords = onchainTable3(
569
596
  "resolver_records",
570
597
  (t) => ({
571
598
  // keyed by (chainId, resolver, node)
572
599
  id: t.text().primaryKey().$type(),
573
- chainId: t.integer().notNull().$type(),
600
+ chainId: t.int8({ mode: "number" }).notNull().$type(),
574
601
  address: t.hex().notNull().$type(),
575
602
  node: t.hex().notNull().$type(),
576
603
  /**
@@ -616,11 +643,11 @@ var resolverRecords_relations = relations2(resolverRecords, ({ one, many }) => (
616
643
  // resolverRecord has many text records
617
644
  textRecords: many(resolverTextRecord)
618
645
  }));
619
- var resolverAddressRecord = onchainTable2(
646
+ var resolverAddressRecord = onchainTable3(
620
647
  "resolver_address_records",
621
648
  (t) => ({
622
649
  // keyed by ((chainId, resolver, node), coinType)
623
- chainId: t.integer().notNull().$type(),
650
+ chainId: t.int8({ mode: "number" }).notNull().$type(),
624
651
  address: t.hex().notNull().$type(),
625
652
  node: t.hex().notNull().$type(),
626
653
  // NOTE: all well-known CoinTypes fit into javascript number but NOT postgres .integer, must be
@@ -635,7 +662,7 @@ var resolverAddressRecord = onchainTable2(
635
662
  value: t.text().notNull()
636
663
  }),
637
664
  (t) => ({
638
- pk: primaryKey2({ columns: [t.chainId, t.address, t.node, t.coinType] })
665
+ pk: primaryKey3({ columns: [t.chainId, t.address, t.node, t.coinType] })
639
666
  })
640
667
  );
641
668
  var resolverAddressRecordRelations = relations2(resolverAddressRecord, ({ one }) => ({
@@ -649,11 +676,11 @@ var resolverAddressRecordRelations = relations2(resolverAddressRecord, ({ one })
649
676
  references: [resolverRecords.chainId, resolverRecords.address, resolverRecords.node]
650
677
  })
651
678
  }));
652
- var resolverTextRecord = onchainTable2(
679
+ var resolverTextRecord = onchainTable3(
653
680
  "resolver_text_records",
654
681
  (t) => ({
655
682
  // keyed by ((chainId, resolver, node), key)
656
- chainId: t.integer().notNull().$type(),
683
+ chainId: t.int8({ mode: "number" }).notNull().$type(),
657
684
  address: t.hex().notNull().$type(),
658
685
  node: t.hex().notNull().$type(),
659
686
  key: t.text().notNull(),
@@ -666,7 +693,7 @@ var resolverTextRecord = onchainTable2(
666
693
  value: t.text().notNull()
667
694
  }),
668
695
  (t) => ({
669
- pk: primaryKey2({ columns: [t.chainId, t.address, t.node, t.key] })
696
+ pk: primaryKey3({ columns: [t.chainId, t.address, t.node, t.key] })
670
697
  })
671
698
  );
672
699
  var resolverTextRecordRelations = relations2(resolverTextRecord, ({ one }) => ({
@@ -676,13 +703,10 @@ var resolverTextRecordRelations = relations2(resolverTextRecord, ({ one }) => ({
676
703
  references: [resolverRecords.chainId, resolverRecords.address, resolverRecords.node]
677
704
  })
678
705
  }));
679
- var migratedNode = onchainTable2("migrated_nodes", (t) => ({
680
- node: t.hex().primaryKey().$type()
681
- }));
682
706
 
683
707
  // src/ensindexer-abstract/registrars.schema.ts
684
- import { index as index2, onchainEnum as onchainEnum2, onchainTable as onchainTable3, relations as relations3, uniqueIndex as uniqueIndex3 } from "ponder";
685
- var subregistries = onchainTable3(
708
+ import { index as index2, onchainEnum as onchainEnum2, onchainTable as onchainTable4, relations as relations3, uniqueIndex as uniqueIndex3 } from "ponder";
709
+ var subregistries = onchainTable4(
686
710
  "subregistries",
687
711
  (t) => ({
688
712
  /**
@@ -712,7 +736,7 @@ var subregistries = onchainTable3(
712
736
  uniqueNode: uniqueIndex3().on(t.node)
713
737
  })
714
738
  );
715
- var registrationLifecycles = onchainTable3(
739
+ var registrationLifecycles = onchainTable4(
716
740
  "registration_lifecycles",
717
741
  (t) => ({
718
742
  /**
@@ -752,7 +776,7 @@ var registrarActionType = onchainEnum2("registrar_action_type", [
752
776
  "registration",
753
777
  "renewal"
754
778
  ]);
755
- var registrarActions = onchainTable3(
779
+ var registrarActions = onchainTable4(
756
780
  "registrar_actions",
757
781
  (t) => ({
758
782
  /**
@@ -1009,7 +1033,7 @@ var internal_registrarActionMetadataType = onchainEnum2(
1009
1033
  "_ensindexer_registrar_action_metadata_type",
1010
1034
  ["CURRENT_LOGICAL_REGISTRAR_ACTION"]
1011
1035
  );
1012
- var internal_registrarActionMetadata = onchainTable3(
1036
+ var internal_registrarActionMetadata = onchainTable4(
1013
1037
  "_ensindexer_registrar_action_metadata",
1014
1038
  (t) => ({
1015
1039
  /**
@@ -1058,7 +1082,7 @@ var registrarActionRelations = relations3(registrarActions, ({ one }) => ({
1058
1082
  }));
1059
1083
 
1060
1084
  // src/ensindexer-abstract/subgraph.schema.ts
1061
- import { index as index3, onchainTable as onchainTable4, relations as relations4, sql as sql2 } from "ponder";
1085
+ import { index as index3, onchainTable as onchainTable5, relations as relations4, sql as sql2 } from "ponder";
1062
1086
 
1063
1087
  // src/lib/collate.ts
1064
1088
  function monkeypatchCollate(col, collation) {
@@ -1069,7 +1093,7 @@ function monkeypatchCollate(col, collation) {
1069
1093
  }
1070
1094
 
1071
1095
  // src/ensindexer-abstract/subgraph.schema.ts
1072
- var subgraph_domain = onchainTable4(
1096
+ var subgraph_domain = onchainTable5(
1073
1097
  "subgraph_domains",
1074
1098
  (t) => ({
1075
1099
  // The namehash of the name
@@ -1199,7 +1223,7 @@ var subgraph_domainRelations = relations4(subgraph_domain, ({ one, many }) => ({
1199
1223
  fusesSets: many(subgraph_fusesSet),
1200
1224
  expiryExtendeds: many(subgraph_expiryExtended)
1201
1225
  }));
1202
- var subgraph_account = onchainTable4("subgraph_accounts", (t) => ({
1226
+ var subgraph_account = onchainTable5("subgraph_accounts", (t) => ({
1203
1227
  id: t.hex().primaryKey()
1204
1228
  }));
1205
1229
  var subgraph_accountRelations = relations4(subgraph_account, ({ many }) => ({
@@ -1207,7 +1231,7 @@ var subgraph_accountRelations = relations4(subgraph_account, ({ many }) => ({
1207
1231
  wrappedDomains: many(subgraph_wrappedDomain),
1208
1232
  registrations: many(subgraph_registration)
1209
1233
  }));
1210
- var subgraph_resolver = onchainTable4(
1234
+ var subgraph_resolver = onchainTable5(
1211
1235
  "subgraph_resolvers",
1212
1236
  (t) => ({
1213
1237
  // The unique identifier for this resolver, which is a concatenation of the domain namehash and the resolver address
@@ -1252,7 +1276,7 @@ var subgraph_resolverRelations = relations4(subgraph_resolver, ({ one, many }) =
1252
1276
  authorisationChangeds: many(subgraph_authorisationChanged),
1253
1277
  versionChangeds: many(subgraph_versionChanged)
1254
1278
  }));
1255
- var subgraph_registration = onchainTable4(
1279
+ var subgraph_registration = onchainTable5(
1256
1280
  "subgraph_registrations",
1257
1281
  (t) => ({
1258
1282
  // The unique identifier of the registration
@@ -1308,7 +1332,7 @@ var subgraph_registrationRelations = relations4(subgraph_registration, ({ one, m
1308
1332
  nameReneweds: many(subgraph_nameRenewed),
1309
1333
  nameTransferreds: many(subgraph_nameTransferred)
1310
1334
  }));
1311
- var subgraph_wrappedDomain = onchainTable4(
1335
+ var subgraph_wrappedDomain = onchainTable5(
1312
1336
  "subgraph_wrapped_domains",
1313
1337
  (t) => ({
1314
1338
  // The unique identifier for each instance of the WrappedDomain entity
@@ -1368,7 +1392,7 @@ var domainEventIndex = (t) => ({
1368
1392
  // sorting index
1369
1393
  idx_compound: index3().on(t.domainId, t.id)
1370
1394
  });
1371
- var subgraph_transfer = onchainTable4(
1395
+ var subgraph_transfer = onchainTable5(
1372
1396
  "subgraph_transfers",
1373
1397
  (t) => ({
1374
1398
  ...domainEvent2(t),
@@ -1376,7 +1400,7 @@ var subgraph_transfer = onchainTable4(
1376
1400
  }),
1377
1401
  domainEventIndex
1378
1402
  );
1379
- var subgraph_newOwner = onchainTable4(
1403
+ var subgraph_newOwner = onchainTable5(
1380
1404
  "subgraph_new_owners",
1381
1405
  (t) => ({
1382
1406
  ...domainEvent2(t),
@@ -1385,7 +1409,7 @@ var subgraph_newOwner = onchainTable4(
1385
1409
  }),
1386
1410
  domainEventIndex
1387
1411
  );
1388
- var subgraph_newResolver = onchainTable4(
1412
+ var subgraph_newResolver = onchainTable5(
1389
1413
  "subgraph_new_resolvers",
1390
1414
  (t) => ({
1391
1415
  ...domainEvent2(t),
@@ -1393,7 +1417,7 @@ var subgraph_newResolver = onchainTable4(
1393
1417
  }),
1394
1418
  domainEventIndex
1395
1419
  );
1396
- var subgraph_newTTL = onchainTable4(
1420
+ var subgraph_newTTL = onchainTable5(
1397
1421
  "subgraph_new_ttls",
1398
1422
  (t) => ({
1399
1423
  ...domainEvent2(t),
@@ -1401,7 +1425,7 @@ var subgraph_newTTL = onchainTable4(
1401
1425
  }),
1402
1426
  domainEventIndex
1403
1427
  );
1404
- var subgraph_wrappedTransfer = onchainTable4(
1428
+ var subgraph_wrappedTransfer = onchainTable5(
1405
1429
  "subgraph_wrapped_transfers",
1406
1430
  (t) => ({
1407
1431
  ...domainEvent2(t),
@@ -1409,7 +1433,7 @@ var subgraph_wrappedTransfer = onchainTable4(
1409
1433
  }),
1410
1434
  domainEventIndex
1411
1435
  );
1412
- var subgraph_nameWrapped = onchainTable4(
1436
+ var subgraph_nameWrapped = onchainTable5(
1413
1437
  "subgraph_name_wrapped",
1414
1438
  (t) => ({
1415
1439
  ...domainEvent2(t),
@@ -1420,7 +1444,7 @@ var subgraph_nameWrapped = onchainTable4(
1420
1444
  }),
1421
1445
  domainEventIndex
1422
1446
  );
1423
- var subgraph_nameUnwrapped = onchainTable4(
1447
+ var subgraph_nameUnwrapped = onchainTable5(
1424
1448
  "subgraph_name_unwrapped",
1425
1449
  (t) => ({
1426
1450
  ...domainEvent2(t),
@@ -1428,7 +1452,7 @@ var subgraph_nameUnwrapped = onchainTable4(
1428
1452
  }),
1429
1453
  domainEventIndex
1430
1454
  );
1431
- var subgraph_fusesSet = onchainTable4(
1455
+ var subgraph_fusesSet = onchainTable5(
1432
1456
  "subgraph_fuses_set",
1433
1457
  (t) => ({
1434
1458
  ...domainEvent2(t),
@@ -1436,7 +1460,7 @@ var subgraph_fusesSet = onchainTable4(
1436
1460
  }),
1437
1461
  domainEventIndex
1438
1462
  );
1439
- var subgraph_expiryExtended = onchainTable4(
1463
+ var subgraph_expiryExtended = onchainTable5(
1440
1464
  "subgraph_expiry_extended",
1441
1465
  (t) => ({
1442
1466
  ...domainEvent2(t),
@@ -1454,7 +1478,7 @@ var registrationEventIndex = (t) => ({
1454
1478
  // sorting index
1455
1479
  idx_compound: index3().on(t.registrationId, t.id)
1456
1480
  });
1457
- var subgraph_nameRegistered = onchainTable4(
1481
+ var subgraph_nameRegistered = onchainTable5(
1458
1482
  "subgraph_name_registered",
1459
1483
  (t) => ({
1460
1484
  ...registrationEvent(t),
@@ -1463,7 +1487,7 @@ var subgraph_nameRegistered = onchainTable4(
1463
1487
  }),
1464
1488
  registrationEventIndex
1465
1489
  );
1466
- var subgraph_nameRenewed = onchainTable4(
1490
+ var subgraph_nameRenewed = onchainTable5(
1467
1491
  "subgraph_name_renewed",
1468
1492
  (t) => ({
1469
1493
  ...registrationEvent(t),
@@ -1471,7 +1495,7 @@ var subgraph_nameRenewed = onchainTable4(
1471
1495
  }),
1472
1496
  registrationEventIndex
1473
1497
  );
1474
- var subgraph_nameTransferred = onchainTable4(
1498
+ var subgraph_nameTransferred = onchainTable5(
1475
1499
  "subgraph_name_transferred",
1476
1500
  (t) => ({
1477
1501
  ...registrationEvent(t),
@@ -1489,7 +1513,7 @@ var resolverEventIndex = (t) => ({
1489
1513
  // sorting index
1490
1514
  idx_compound: index3().on(t.resolverId, t.id)
1491
1515
  });
1492
- var subgraph_addrChanged = onchainTable4(
1516
+ var subgraph_addrChanged = onchainTable5(
1493
1517
  "subgraph_addr_changed",
1494
1518
  (t) => ({
1495
1519
  ...resolverEvent2(t),
@@ -1497,7 +1521,7 @@ var subgraph_addrChanged = onchainTable4(
1497
1521
  }),
1498
1522
  resolverEventIndex
1499
1523
  );
1500
- var subgraph_multicoinAddrChanged = onchainTable4(
1524
+ var subgraph_multicoinAddrChanged = onchainTable5(
1501
1525
  "subgraph_multicoin_addr_changed",
1502
1526
  (t) => ({
1503
1527
  ...resolverEvent2(t),
@@ -1506,7 +1530,7 @@ var subgraph_multicoinAddrChanged = onchainTable4(
1506
1530
  }),
1507
1531
  resolverEventIndex
1508
1532
  );
1509
- var subgraph_nameChanged = onchainTable4(
1533
+ var subgraph_nameChanged = onchainTable5(
1510
1534
  "subgraph_name_changed",
1511
1535
  (t) => ({
1512
1536
  ...resolverEvent2(t),
@@ -1514,7 +1538,7 @@ var subgraph_nameChanged = onchainTable4(
1514
1538
  }),
1515
1539
  resolverEventIndex
1516
1540
  );
1517
- var subgraph_abiChanged = onchainTable4(
1541
+ var subgraph_abiChanged = onchainTable5(
1518
1542
  "subgraph_abi_changed",
1519
1543
  (t) => ({
1520
1544
  ...resolverEvent2(t),
@@ -1522,7 +1546,7 @@ var subgraph_abiChanged = onchainTable4(
1522
1546
  }),
1523
1547
  resolverEventIndex
1524
1548
  );
1525
- var subgraph_pubkeyChanged = onchainTable4(
1549
+ var subgraph_pubkeyChanged = onchainTable5(
1526
1550
  "subgraph_pubkey_changed",
1527
1551
  (t) => ({
1528
1552
  ...resolverEvent2(t),
@@ -1531,7 +1555,7 @@ var subgraph_pubkeyChanged = onchainTable4(
1531
1555
  }),
1532
1556
  resolverEventIndex
1533
1557
  );
1534
- var subgraph_textChanged = onchainTable4(
1558
+ var subgraph_textChanged = onchainTable5(
1535
1559
  "subgraph_text_changed",
1536
1560
  (t) => ({
1537
1561
  ...resolverEvent2(t),
@@ -1540,7 +1564,7 @@ var subgraph_textChanged = onchainTable4(
1540
1564
  }),
1541
1565
  resolverEventIndex
1542
1566
  );
1543
- var subgraph_contenthashChanged = onchainTable4(
1567
+ var subgraph_contenthashChanged = onchainTable5(
1544
1568
  "subgraph_contenthash_changed",
1545
1569
  (t) => ({
1546
1570
  ...resolverEvent2(t),
@@ -1548,7 +1572,7 @@ var subgraph_contenthashChanged = onchainTable4(
1548
1572
  }),
1549
1573
  resolverEventIndex
1550
1574
  );
1551
- var subgraph_interfaceChanged = onchainTable4(
1575
+ var subgraph_interfaceChanged = onchainTable5(
1552
1576
  "subgraph_interface_changed",
1553
1577
  (t) => ({
1554
1578
  ...resolverEvent2(t),
@@ -1557,7 +1581,7 @@ var subgraph_interfaceChanged = onchainTable4(
1557
1581
  }),
1558
1582
  resolverEventIndex
1559
1583
  );
1560
- var subgraph_authorisationChanged = onchainTable4(
1584
+ var subgraph_authorisationChanged = onchainTable5(
1561
1585
  "subgraph_authorisation_changed",
1562
1586
  (t) => ({
1563
1587
  ...resolverEvent2(t),
@@ -1567,7 +1591,7 @@ var subgraph_authorisationChanged = onchainTable4(
1567
1591
  }),
1568
1592
  resolverEventIndex
1569
1593
  );
1570
- var subgraph_versionChanged = onchainTable4(
1594
+ var subgraph_versionChanged = onchainTable5(
1571
1595
  "subgraph_version_changed",
1572
1596
  (t) => ({
1573
1597
  ...resolverEvent2(t),
@@ -1761,8 +1785,8 @@ var subgraph_versionChangedRelations = relations4(subgraph_versionChanged, ({ on
1761
1785
  }));
1762
1786
 
1763
1787
  // src/ensindexer-abstract/tokenscope.schema.ts
1764
- import { index as index4, onchainTable as onchainTable5 } from "ponder";
1765
- var nameSales = onchainTable5(
1788
+ import { index as index4, onchainTable as onchainTable6 } from "ponder";
1789
+ var nameSales = onchainTable6(
1766
1790
  "name_sales",
1767
1791
  (t) => ({
1768
1792
  /**
@@ -1774,7 +1798,7 @@ var nameSales = onchainTable5(
1774
1798
  /**
1775
1799
  * The chain where the sale occurred.
1776
1800
  */
1777
- chainId: t.integer().notNull(),
1801
+ chainId: t.int8({ mode: "number" }).notNull(),
1778
1802
  /**
1779
1803
  * The block number on chainId where the sale occurred.
1780
1804
  */
@@ -1858,7 +1882,7 @@ var nameSales = onchainTable5(
1858
1882
  idx_timestamp: index4().on(t.timestamp)
1859
1883
  })
1860
1884
  );
1861
- var nameTokens = onchainTable5(
1885
+ var nameTokens = onchainTable6(
1862
1886
  "name_tokens",
1863
1887
  (t) => ({
1864
1888
  /**
@@ -1888,7 +1912,7 @@ var nameTokens = onchainTable5(
1888
1912
  /**
1889
1913
  * The chain that manages the token.
1890
1914
  */
1891
- chainId: t.integer().notNull(),
1915
+ chainId: t.int8({ mode: "number" }).notNull(),
1892
1916
  /**
1893
1917
  * The address of the contract on chainId that manages the token.
1894
1918
  */
@@ -1948,7 +1972,7 @@ var ensnode_exports = {};
1948
1972
  __export(ensnode_exports, {
1949
1973
  metadata: () => metadata
1950
1974
  });
1951
- import { pgSchema, primaryKey as primaryKey3 } from "drizzle-orm/pg-core";
1975
+ import { pgSchema, primaryKey as primaryKey4 } from "drizzle-orm/pg-core";
1952
1976
  var ENSNODE_SCHEMA_NAME = "ensnode";
1953
1977
  var ENSNODE_SCHEMA = pgSchema(ENSNODE_SCHEMA_NAME);
1954
1978
  var metadata = ENSNODE_SCHEMA.table(
@@ -1988,7 +2012,7 @@ var metadata = ENSNODE_SCHEMA.table(
1988
2012
  * Primary key constraint on 'ensIndexerSchemaName' and 'key' columns,
1989
2013
  * to ensure that there is only one record for each key per ENSIndexer instance.
1990
2014
  */
1991
- primaryKey3({
2015
+ primaryKey4({
1992
2016
  name: "metadata_pkey",
1993
2017
  columns: [table.ensIndexerSchemaName, table.key]
1994
2018
  })
@@ -2072,8 +2096,12 @@ var ENSDB_SCHEMA_CHECKSUM = getDrizzleSchemaChecksum({
2072
2096
  // src/client/ensdb-reader.ts
2073
2097
  import { and, eq } from "drizzle-orm/sql";
2074
2098
  import {
2075
- deserializeCrossChainIndexingStatusSnapshot,
2076
- deserializeEnsIndexerPublicConfig
2099
+ buildIndexingMetadataContextUninitialized,
2100
+ deserializeIndexingMetadataContext,
2101
+ IndexingMetadataContextStatusCodes
2102
+ } from "@ensnode/ensnode-sdk";
2103
+ import {
2104
+ IndexingMetadataContextStatusCodes as IndexingMetadataContextStatusCodes2
2077
2105
  } from "@ensnode/ensnode-sdk";
2078
2106
 
2079
2107
  // src/lib/parse-pg-version-info.ts
@@ -2094,9 +2122,7 @@ function parsePgVersionInfo(versionString) {
2094
2122
 
2095
2123
  // src/client/ensnode-metadata.ts
2096
2124
  var EnsNodeMetadataKeys = {
2097
- EnsDbVersion: "ensdb_version",
2098
- EnsIndexerPublicConfig: "ensindexer_public_config",
2099
- EnsIndexerIndexingStatus: "ensindexer_indexing_status"
2125
+ IndexingMetadataContext: "indexing_metadata_context"
2100
2126
  };
2101
2127
 
2102
2128
  // src/client/ensdb-reader.ts
@@ -2175,29 +2201,29 @@ var EnsDbReader = class {
2175
2201
  return this._ensNodeSchema;
2176
2202
  }
2177
2203
  /**
2178
- * Get ENSDb Version
2179
- *
2180
- * @returns the existing record, or `undefined`.
2204
+ * Check if the ENSDb instance is healthy by running a simple query
2205
+ * against it.
2181
2206
  */
2182
- async getEnsDbVersion() {
2183
- const record = await this.getEnsNodeMetadata({
2184
- key: EnsNodeMetadataKeys.EnsDbVersion
2185
- });
2186
- return record;
2207
+ async isHealthy() {
2208
+ try {
2209
+ await this.ensDb.execute("SELECT 1;");
2210
+ return true;
2211
+ } catch {
2212
+ return false;
2213
+ }
2187
2214
  }
2188
2215
  /**
2189
- * Get ENSIndexer Public Config
2190
- *
2191
- * @returns the existing record, or `undefined`.
2216
+ * Check if the ENSDb instance is ready by verifying that
2217
+ * the {@link IndexingMetadataContext} has been initialized for
2218
+ * the ENSIndexer Schema used by this ENSDbReader instance.
2192
2219
  */
2193
- async getEnsIndexerPublicConfig() {
2194
- const record = await this.getEnsNodeMetadata({
2195
- key: EnsNodeMetadataKeys.EnsIndexerPublicConfig
2196
- });
2197
- if (!record) {
2198
- return void 0;
2220
+ async isReady() {
2221
+ try {
2222
+ const indexingMetadataContext = await this.getIndexingMetadataContext();
2223
+ return indexingMetadataContext.statusCode === IndexingMetadataContextStatusCodes.Initialized;
2224
+ } catch {
2225
+ return false;
2199
2226
  }
2200
- return deserializeEnsIndexerPublicConfig(record);
2201
2227
  }
2202
2228
  /**
2203
2229
  * Build ENSDb Public Config
@@ -2209,20 +2235,18 @@ var EnsDbReader = class {
2209
2235
  };
2210
2236
  }
2211
2237
  /**
2212
- * Get Indexing Status Snapshot
2238
+ * Get Indexing Metadata Context
2213
2239
  *
2214
- * @returns the existing record, or `undefined`.
2240
+ * @returns the initialized record, or a default uninitialized one if no record exists in ENSDb.
2215
2241
  */
2216
- async getIndexingStatusSnapshot() {
2217
- const record = await this.getEnsNodeMetadata(
2218
- {
2219
- key: EnsNodeMetadataKeys.EnsIndexerIndexingStatus
2220
- }
2221
- );
2242
+ async getIndexingMetadataContext() {
2243
+ const record = await this.getEnsNodeMetadata({
2244
+ key: EnsNodeMetadataKeys.IndexingMetadataContext
2245
+ });
2222
2246
  if (!record) {
2223
- return void 0;
2247
+ return buildIndexingMetadataContextUninitialized();
2224
2248
  }
2225
- return deserializeCrossChainIndexingStatusSnapshot(record);
2249
+ return deserializeIndexingMetadataContext(record);
2226
2250
  }
2227
2251
  /**
2228
2252
  * Get ENSNode Metadata record
@@ -2279,56 +2303,59 @@ var EnsDbReader = class {
2279
2303
  };
2280
2304
 
2281
2305
  // src/client/ensdb-writer.ts
2306
+ import { sql as sql3 } from "drizzle-orm";
2282
2307
  import { migrate } from "drizzle-orm/node-postgres/migrator";
2283
2308
  import {
2284
- serializeCrossChainIndexingStatusSnapshot,
2285
- serializeEnsIndexerPublicConfig
2309
+ serializeIndexingMetadataContext
2286
2310
  } from "@ensnode/ensnode-sdk";
2287
- var EnsDbWriter = class extends EnsDbReader {
2311
+
2312
+ // src/lib/advisory-lock-id.ts
2313
+ import { createHash as createHash2 } from "crypto";
2314
+ function advisoryLockId(name) {
2315
+ const hash = createHash2("sha256").update(name).digest();
2316
+ return hash.readBigInt64BE(0);
2317
+ }
2318
+
2319
+ // src/client/ensdb-writer.ts
2320
+ var EnsDbWriter = class _EnsDbWriter extends EnsDbReader {
2321
+ /**
2322
+ * Stable arbitrary lock ID for ENSNode Schema migrations to
2323
+ * prevent concurrent migration execution across multiple ENSIndexer instances.
2324
+ */
2325
+ static MIGRATION_LOCK_ID = advisoryLockId(
2326
+ "ensnode-schema-migration-lock"
2327
+ );
2288
2328
  /**
2289
2329
  * Execute pending database migrations for ENSNode Schema in ENSDb.
2290
2330
  *
2331
+ * This function is:
2332
+ * - idempotent and can be safely executed multiple times,
2333
+ * - safe to execute concurrently across multiple ENSIndexer instances,
2334
+ * as it uses a stable arbitrary advisory lock to prevent concurrent
2335
+ * execution of migrations.
2336
+ *
2291
2337
  * @param migrationsDirPath - The file path to the directory containing
2292
2338
  * database migration files for ENSNode Schema.
2293
2339
  * @throws error when migration execution fails.
2294
2340
  */
2295
2341
  async migrateEnsNodeSchema(migrationsDirPath) {
2296
- return migrate(this.drizzleClient, {
2297
- migrationsFolder: migrationsDirPath,
2298
- migrationsSchema: "ensnode"
2299
- });
2300
- }
2301
- /**
2302
- * Upsert ENSDb Version
2303
- *
2304
- * @throws when upsert operation failed.
2305
- */
2306
- async upsertEnsDbVersion(ensDbVersion) {
2307
- await this.upsertEnsNodeMetadata({
2308
- key: EnsNodeMetadataKeys.EnsDbVersion,
2309
- value: ensDbVersion
2310
- });
2311
- }
2312
- /**
2313
- * Upsert ENSIndexer Public Config
2314
- *
2315
- * @throws when upsert operation failed.
2316
- */
2317
- async upsertEnsIndexerPublicConfig(ensIndexerPublicConfig) {
2318
- await this.upsertEnsNodeMetadata({
2319
- key: EnsNodeMetadataKeys.EnsIndexerPublicConfig,
2320
- value: serializeEnsIndexerPublicConfig(ensIndexerPublicConfig)
2342
+ await this.drizzleClient.transaction(async (tx) => {
2343
+ await tx.execute(sql3`SELECT pg_advisory_xact_lock(${_EnsDbWriter.MIGRATION_LOCK_ID})`);
2344
+ await migrate(tx, {
2345
+ migrationsFolder: migrationsDirPath,
2346
+ migrationsSchema: "ensnode"
2347
+ });
2321
2348
  });
2322
2349
  }
2323
2350
  /**
2324
- * Upsert Indexing Status Snapshot
2351
+ * Upsert Indexing Metadata Context Initialized
2325
2352
  *
2326
2353
  * @throws when upsert operation failed.
2327
2354
  */
2328
- async upsertIndexingStatusSnapshot(indexingStatus) {
2355
+ async upsertIndexingMetadataContext(indexingMetadataContext) {
2329
2356
  await this.upsertEnsNodeMetadata({
2330
- key: EnsNodeMetadataKeys.EnsIndexerIndexingStatus,
2331
- value: serializeCrossChainIndexingStatusSnapshot(indexingStatus)
2357
+ key: EnsNodeMetadataKeys.IndexingMetadataContext,
2358
+ value: serializeIndexingMetadataContext(indexingMetadataContext)
2332
2359
  });
2333
2360
  }
2334
2361
  /**
@@ -2396,6 +2423,7 @@ export {
2396
2423
  EnsDbReader,
2397
2424
  EnsDbWriter,
2398
2425
  EnsNodeMetadataKeys,
2426
+ IndexingMetadataContextStatusCodes2 as IndexingMetadataContextStatusCodes,
2399
2427
  validateEnsDbConfig
2400
2428
  };
2401
2429
  //# sourceMappingURL=index.js.map