@ensnode/ensnode-sdk 1.6.0 → 1.8.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.cjs +65 -39
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +169 -224
- package/dist/index.d.ts +169 -224
- package/dist/index.js +65 -39
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/index.cjs
CHANGED
|
@@ -56,7 +56,6 @@ __export(index_exports, {
|
|
|
56
56
|
EnsApiIndexingStatusResponseCodes: () => EnsApiIndexingStatusResponseCodes,
|
|
57
57
|
EnsIndexerClient: () => EnsIndexerClient,
|
|
58
58
|
EnsIndexerIndexingStatusResponseCodes: () => EnsIndexerIndexingStatusResponseCodes,
|
|
59
|
-
EnsNodeMetadataKeys: () => EnsNodeMetadataKeys,
|
|
60
59
|
ForwardResolutionProtocolStep: () => ForwardResolutionProtocolStep,
|
|
61
60
|
IndexingStatusResponseCodes: () => IndexingStatusResponseCodes,
|
|
62
61
|
LINEANAMES_NODE: () => LINEANAMES_NODE,
|
|
@@ -170,6 +169,7 @@ __export(index_exports, {
|
|
|
170
169
|
getENSv2RootRegistryId: () => getENSv2RootRegistryId,
|
|
171
170
|
getEthnamesSubregistryId: () => getEthnamesSubregistryId,
|
|
172
171
|
getEthnamesSubregistryManagedName: () => getEthnamesSubregistryManagedName,
|
|
172
|
+
getHighestKnownBlockTimestamp: () => getHighestKnownBlockTimestamp,
|
|
173
173
|
getLatestIndexedBlockRef: () => getLatestIndexedBlockRef,
|
|
174
174
|
getLineanamesSubregistryId: () => getLineanamesSubregistryId,
|
|
175
175
|
getLineanamesSubregistryManagedName: () => getLineanamesSubregistryManagedName,
|
|
@@ -241,6 +241,8 @@ __export(index_exports, {
|
|
|
241
241
|
makeSerializedEnsApiPublicConfigSchema: () => makeSerializedEnsApiPublicConfigSchema,
|
|
242
242
|
makeSubdomainNode: () => makeSubdomainNode,
|
|
243
243
|
maybeGetDatasourceContract: () => maybeGetDatasourceContract,
|
|
244
|
+
maybeGetENSv2RootRegistry: () => maybeGetENSv2RootRegistry,
|
|
245
|
+
maybeGetENSv2RootRegistryId: () => maybeGetENSv2RootRegistryId,
|
|
244
246
|
mergeBlockNumberRanges: () => mergeBlockNumberRanges,
|
|
245
247
|
nameTokensPrerequisites: () => nameTokensPrerequisites,
|
|
246
248
|
parseAccountId: () => parseAccountId,
|
|
@@ -1159,7 +1161,7 @@ var import_v412 = require("zod/v4");
|
|
|
1159
1161
|
|
|
1160
1162
|
// src/shared/block-ref.ts
|
|
1161
1163
|
function isBefore(blockA, blockB) {
|
|
1162
|
-
return blockA.number < blockB.number
|
|
1164
|
+
return blockA.number < blockB.number;
|
|
1163
1165
|
}
|
|
1164
1166
|
function isEqualTo(blockA, blockB) {
|
|
1165
1167
|
return blockA.number === blockB.number && blockA.timestamp === blockB.timestamp;
|
|
@@ -1213,18 +1215,29 @@ function mergeBlockNumberRanges(...ranges) {
|
|
|
1213
1215
|
}
|
|
1214
1216
|
let minStartBlock;
|
|
1215
1217
|
let maxEndBlock;
|
|
1218
|
+
let hasUnboundedStart = false;
|
|
1219
|
+
let hasUnboundedEnd = false;
|
|
1216
1220
|
for (const range of ranges) {
|
|
1217
|
-
if (range.startBlock
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
+
if (range.startBlock === void 0) {
|
|
1222
|
+
hasUnboundedStart = true;
|
|
1223
|
+
} else if (minStartBlock === void 0 || range.startBlock < minStartBlock) {
|
|
1224
|
+
minStartBlock = range.startBlock;
|
|
1221
1225
|
}
|
|
1222
|
-
if (range.endBlock
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
+
if (range.endBlock === void 0) {
|
|
1227
|
+
hasUnboundedEnd = true;
|
|
1228
|
+
} else if (maxEndBlock === void 0 || range.endBlock > maxEndBlock) {
|
|
1229
|
+
maxEndBlock = range.endBlock;
|
|
1230
|
+
}
|
|
1231
|
+
if (hasUnboundedStart && hasUnboundedEnd) {
|
|
1232
|
+
return buildBlockNumberRange(void 0, void 0);
|
|
1226
1233
|
}
|
|
1227
1234
|
}
|
|
1235
|
+
if (hasUnboundedStart) {
|
|
1236
|
+
minStartBlock = void 0;
|
|
1237
|
+
}
|
|
1238
|
+
if (hasUnboundedEnd) {
|
|
1239
|
+
maxEndBlock = void 0;
|
|
1240
|
+
}
|
|
1228
1241
|
return buildBlockNumberRange(minStartBlock, maxEndBlock);
|
|
1229
1242
|
}
|
|
1230
1243
|
function buildBlockRefRange(startBlock, endBlock) {
|
|
@@ -1375,12 +1388,31 @@ function getLatestIndexedBlockRef(indexingStatus, chainId) {
|
|
|
1375
1388
|
}
|
|
1376
1389
|
return chainIndexingStatus.latestIndexedBlock;
|
|
1377
1390
|
}
|
|
1391
|
+
function getHighestKnownBlockTimestamp(chains) {
|
|
1392
|
+
if (chains.length === 0) {
|
|
1393
|
+
throw new Error(
|
|
1394
|
+
"Invariant violation: at least one chain is required to determine the highest known block timestamp"
|
|
1395
|
+
);
|
|
1396
|
+
}
|
|
1397
|
+
const startBlockTimestamps = chains.map((chain) => chain.config.startBlock.timestamp);
|
|
1398
|
+
const endBlockTimestamps = chains.map((chain) => chain.config).filter((chainConfig) => chainConfig.rangeType === RangeTypeIds.Bounded).map((chainConfig) => chainConfig.endBlock.timestamp);
|
|
1399
|
+
const backfillEndBlockTimestamps = chains.filter((chain) => chain.chainStatus === ChainIndexingStatusIds.Backfill).map((chain) => chain.backfillEndBlock.timestamp);
|
|
1400
|
+
const latestKnownBlockTimestamps = chains.filter((chain) => chain.chainStatus === ChainIndexingStatusIds.Following).map((chain) => chain.latestKnownBlock.timestamp);
|
|
1401
|
+
return Math.max(
|
|
1402
|
+
...startBlockTimestamps,
|
|
1403
|
+
...endBlockTimestamps,
|
|
1404
|
+
...backfillEndBlockTimestamps,
|
|
1405
|
+
...latestKnownBlockTimestamps
|
|
1406
|
+
);
|
|
1407
|
+
}
|
|
1378
1408
|
function buildCrossChainIndexingStatusSnapshotOmnichain(omnichainSnapshot, snapshotTime) {
|
|
1409
|
+
const chains = Array.from(omnichainSnapshot.chains.values());
|
|
1410
|
+
const adjustedSnapshotTime = Math.max(snapshotTime, getHighestKnownBlockTimestamp(chains));
|
|
1379
1411
|
return validateCrossChainIndexingStatusSnapshot({
|
|
1380
1412
|
strategy: CrossChainIndexingStrategyIds.Omnichain,
|
|
1381
1413
|
slowestChainIndexingCursor: omnichainSnapshot.omnichainIndexingCursor,
|
|
1382
1414
|
omnichainSnapshot,
|
|
1383
|
-
snapshotTime
|
|
1415
|
+
snapshotTime: adjustedSnapshotTime
|
|
1384
1416
|
});
|
|
1385
1417
|
}
|
|
1386
1418
|
|
|
@@ -1908,16 +1940,7 @@ function invariant_slowestChainEqualsToOmnichainSnapshotTime(ctx) {
|
|
|
1908
1940
|
function invariant_snapshotTimeIsTheHighestKnownBlockTimestamp(ctx) {
|
|
1909
1941
|
const { snapshotTime, omnichainSnapshot } = ctx.value;
|
|
1910
1942
|
const chains = Array.from(omnichainSnapshot.chains.values());
|
|
1911
|
-
const
|
|
1912
|
-
const endBlockTimestamps = chains.map((chain) => chain.config).filter((chainConfig) => chainConfig.rangeType === RangeTypeIds.Bounded).map((chainConfig) => chainConfig.endBlock.timestamp);
|
|
1913
|
-
const backfillEndBlockTimestamps = chains.filter((chain) => chain.chainStatus === ChainIndexingStatusIds.Backfill).map((chain) => chain.backfillEndBlock.timestamp);
|
|
1914
|
-
const latestKnownBlockTimestamps = chains.filter((chain) => chain.chainStatus === ChainIndexingStatusIds.Following).map((chain) => chain.latestKnownBlock.timestamp);
|
|
1915
|
-
const highestKnownBlockTimestamp = Math.max(
|
|
1916
|
-
...startBlockTimestamps,
|
|
1917
|
-
...endBlockTimestamps,
|
|
1918
|
-
...backfillEndBlockTimestamps,
|
|
1919
|
-
...latestKnownBlockTimestamps
|
|
1920
|
-
);
|
|
1943
|
+
const highestKnownBlockTimestamp = getHighestKnownBlockTimestamp(chains);
|
|
1921
1944
|
if (snapshotTime < highestKnownBlockTimestamp) {
|
|
1922
1945
|
ctx.issues.push({
|
|
1923
1946
|
code: "custom",
|
|
@@ -3223,6 +3246,14 @@ var RegistrarActionsFilterTypes = {
|
|
|
3223
3246
|
EndTimestamp: "endTimestamp"
|
|
3224
3247
|
};
|
|
3225
3248
|
var RegistrarActionsOrders = {
|
|
3249
|
+
/**
|
|
3250
|
+
* Returns registrar actions newest-first.
|
|
3251
|
+
*
|
|
3252
|
+
* Sorts by block timestamp descending. Because each action's identifier encodes
|
|
3253
|
+
* all ordering-relevant onchain properties, this also correctly orders actions
|
|
3254
|
+
* that share the same block timestamp by the chronological order in which they
|
|
3255
|
+
* were executed within the block.
|
|
3256
|
+
*/
|
|
3226
3257
|
LatestRegistrarActions: "orderBy[timestamp]=desc"
|
|
3227
3258
|
};
|
|
3228
3259
|
|
|
@@ -3883,13 +3914,6 @@ var EnsApiClient = class _EnsApiClient {
|
|
|
3883
3914
|
var ENSNodeClient = class extends EnsApiClient {
|
|
3884
3915
|
};
|
|
3885
3916
|
|
|
3886
|
-
// src/ensdb/ensnode-metadata.ts
|
|
3887
|
-
var EnsNodeMetadataKeys = {
|
|
3888
|
-
EnsDbVersion: "ensdb_version",
|
|
3889
|
-
EnsIndexerPublicConfig: "ensindexer_public_config",
|
|
3890
|
-
EnsIndexerIndexingStatus: "ensindexer_indexing_status"
|
|
3891
|
-
};
|
|
3892
|
-
|
|
3893
3917
|
// src/ensindexer/api/config/deserialize.ts
|
|
3894
3918
|
function deserializeEnsIndexerConfigResponse(maybeResponse) {
|
|
3895
3919
|
return deserializeEnsIndexerPublicConfig(maybeResponse, "EnsIndexerConfigResponse");
|
|
@@ -4750,18 +4774,14 @@ var TtlCache = class {
|
|
|
4750
4774
|
|
|
4751
4775
|
// src/shared/config/indexed-blockranges.ts
|
|
4752
4776
|
var import_datasources12 = require("@ensnode/datasources");
|
|
4753
|
-
function buildIndexedBlockranges(namespace,
|
|
4777
|
+
function buildIndexedBlockranges(namespace, pluginsDatasourceNames) {
|
|
4754
4778
|
const indexedBlockranges = /* @__PURE__ */ new Map();
|
|
4755
|
-
for (const [
|
|
4756
|
-
for (const
|
|
4757
|
-
const
|
|
4758
|
-
if (!
|
|
4759
|
-
|
|
4760
|
-
|
|
4761
|
-
);
|
|
4762
|
-
}
|
|
4763
|
-
const datasourceChainId = requiredDatasource.chain.id;
|
|
4764
|
-
const datasourceContracts = Object.values(requiredDatasource.contracts);
|
|
4779
|
+
for (const [, datasourceNames] of pluginsDatasourceNames) {
|
|
4780
|
+
for (const datasourceName of datasourceNames) {
|
|
4781
|
+
const datasource = (0, import_datasources12.maybeGetDatasource)(namespace, datasourceName);
|
|
4782
|
+
if (!datasource) continue;
|
|
4783
|
+
const datasourceChainId = datasource.chain.id;
|
|
4784
|
+
const datasourceContracts = Object.values(datasource.contracts);
|
|
4765
4785
|
for (const datasourceContract of datasourceContracts) {
|
|
4766
4786
|
const currentChainIndexedBlockrange = indexedBlockranges.get(datasourceChainId);
|
|
4767
4787
|
const contractIndexedBlockrange = buildBlockNumberRange(
|
|
@@ -4908,6 +4928,12 @@ var isENSv1Registry = (namespace, contract) => accountIdEqual(getENSv1Registry(n
|
|
|
4908
4928
|
var getENSv2RootRegistry = (namespace) => getDatasourceContract(namespace, import_datasources13.DatasourceNames.ENSv2Root, "RootRegistry");
|
|
4909
4929
|
var getENSv2RootRegistryId = (namespace) => makeRegistryId(getENSv2RootRegistry(namespace));
|
|
4910
4930
|
var isENSv2RootRegistry = (namespace, contract) => accountIdEqual(getENSv2RootRegistry(namespace), contract);
|
|
4931
|
+
var maybeGetENSv2RootRegistry = (namespace) => maybeGetDatasourceContract(namespace, import_datasources13.DatasourceNames.ENSv2Root, "RootRegistry");
|
|
4932
|
+
var maybeGetENSv2RootRegistryId = (namespace) => {
|
|
4933
|
+
const root = maybeGetENSv2RootRegistry(namespace);
|
|
4934
|
+
if (!root) return void 0;
|
|
4935
|
+
return makeRegistryId(root);
|
|
4936
|
+
};
|
|
4911
4937
|
|
|
4912
4938
|
// src/shared/url.ts
|
|
4913
4939
|
function isHttpProtocol(url) {
|