@ensnode/ensnode-sdk 0.0.0-next-20260227190633 → 0.0.0-next-20260228175526
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 +112 -85
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +130 -79
- package/dist/index.d.ts +130 -79
- package/dist/index.js +112 -85
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/index.cjs
CHANGED
|
@@ -36,7 +36,6 @@ __export(index_exports, {
|
|
|
36
36
|
ATTR_PROTOCOL_STEP_RESULT: () => ATTR_PROTOCOL_STEP_RESULT,
|
|
37
37
|
AssetNamespaces: () => AssetNamespaces,
|
|
38
38
|
BASENAMES_NODE: () => BASENAMES_NODE,
|
|
39
|
-
BlockRefRangeTypeIds: () => BlockRefRangeTypeIds,
|
|
40
39
|
ChainIndexingStatusIds: () => ChainIndexingStatusIds,
|
|
41
40
|
ClientError: () => ClientError,
|
|
42
41
|
CrossChainIndexingStrategyIds: () => CrossChainIndexingStrategyIds,
|
|
@@ -75,6 +74,7 @@ __export(index_exports, {
|
|
|
75
74
|
RECORDS_PER_PAGE_MAX: () => RECORDS_PER_PAGE_MAX,
|
|
76
75
|
ROOT_NODE: () => ROOT_NODE,
|
|
77
76
|
ROOT_RESOURCE: () => ROOT_RESOURCE,
|
|
77
|
+
RangeTypeIds: () => RangeTypeIds,
|
|
78
78
|
RegistrarActionTypes: () => RegistrarActionTypes,
|
|
79
79
|
RegistrarActionsFilterTypes: () => RegistrarActionsFilterTypes,
|
|
80
80
|
RegistrarActionsOrders: () => RegistrarActionsOrders,
|
|
@@ -96,6 +96,8 @@ __export(index_exports, {
|
|
|
96
96
|
bigIntToNumber: () => bigIntToNumber,
|
|
97
97
|
bigintToCoinType: () => bigintToCoinType,
|
|
98
98
|
buildAssetId: () => buildAssetId,
|
|
99
|
+
buildBlockNumberRange: () => buildBlockNumberRange,
|
|
100
|
+
buildBlockRefRange: () => buildBlockRefRange,
|
|
99
101
|
buildEncodedReferrer: () => buildEncodedReferrer,
|
|
100
102
|
buildEnsRainbowClientLabelSet: () => buildEnsRainbowClientLabelSet,
|
|
101
103
|
buildLabelSetId: () => buildLabelSetId,
|
|
@@ -113,7 +115,6 @@ __export(index_exports, {
|
|
|
113
115
|
coinTypeReverseLabel: () => coinTypeReverseLabel,
|
|
114
116
|
coinTypeToEvmChainId: () => coinTypeToEvmChainId,
|
|
115
117
|
constructSubInterpretedName: () => constructSubInterpretedName,
|
|
116
|
-
createIndexingConfig: () => createIndexingConfig,
|
|
117
118
|
createRealtimeIndexingStatusProjection: () => createRealtimeIndexingStatusProjection,
|
|
118
119
|
decodeDNSEncodedLiteralName: () => decodeDNSEncodedLiteralName,
|
|
119
120
|
decodeDNSEncodedName: () => decodeDNSEncodedName,
|
|
@@ -121,7 +122,6 @@ __export(index_exports, {
|
|
|
121
122
|
deserializeAssetId: () => deserializeAssetId,
|
|
122
123
|
deserializeBlockNumber: () => deserializeBlockNumber,
|
|
123
124
|
deserializeBlockRef: () => deserializeBlockRef,
|
|
124
|
-
deserializeBlockrange: () => deserializeBlockrange,
|
|
125
125
|
deserializeChainId: () => deserializeChainId,
|
|
126
126
|
deserializeChainIndexingStatusSnapshot: () => deserializeChainIndexingStatusSnapshot,
|
|
127
127
|
deserializeConfigResponse: () => deserializeConfigResponse,
|
|
@@ -742,23 +742,6 @@ var makeUrlSchema = (valueLabel = "Value") => import_v4.z.url({
|
|
|
742
742
|
abort: true
|
|
743
743
|
}).transform((v) => new URL(v));
|
|
744
744
|
var makeBlockNumberSchema = (valueLabel = "Block number") => makeNonNegativeIntegerSchema(valueLabel);
|
|
745
|
-
var makeBlockrangeSchema = (valueLabel = "Value") => import_v4.z.strictObject(
|
|
746
|
-
{
|
|
747
|
-
startBlock: makeBlockNumberSchema(`${valueLabel}.startBlock`).optional(),
|
|
748
|
-
endBlock: makeBlockNumberSchema(`${valueLabel}.endBlock`).optional()
|
|
749
|
-
},
|
|
750
|
-
{
|
|
751
|
-
error: `${valueLabel} must be a valid Blockrange object.`
|
|
752
|
-
}
|
|
753
|
-
).refine(
|
|
754
|
-
(v) => {
|
|
755
|
-
if (v.startBlock && v.endBlock) {
|
|
756
|
-
return v.startBlock <= v.endBlock;
|
|
757
|
-
}
|
|
758
|
-
return true;
|
|
759
|
-
},
|
|
760
|
-
{ error: `${valueLabel}: startBlock must be before or equal to endBlock` }
|
|
761
|
-
);
|
|
762
745
|
var makeBlockRefSchema = (valueLabel = "Value") => import_v4.z.strictObject(
|
|
763
746
|
{
|
|
764
747
|
timestamp: makeUnixTimestampSchema(`${valueLabel}.timestamp`),
|
|
@@ -1100,17 +1083,88 @@ var import_v410 = require("zod/v4");
|
|
|
1100
1083
|
// src/indexing-status/zod-schema/cross-chain-indexing-status-snapshot.ts
|
|
1101
1084
|
var import_v49 = require("zod/v4");
|
|
1102
1085
|
|
|
1103
|
-
// src/
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1086
|
+
// src/shared/block-ref.ts
|
|
1087
|
+
function isBefore(blockA, blockB) {
|
|
1088
|
+
return blockA.number < blockB.number && blockA.timestamp < blockB.timestamp;
|
|
1089
|
+
}
|
|
1090
|
+
function isEqualTo(blockA, blockB) {
|
|
1091
|
+
return blockA.number === blockB.number && blockA.timestamp === blockB.timestamp;
|
|
1092
|
+
}
|
|
1093
|
+
function isBeforeOrEqualTo(blockA, blockB) {
|
|
1094
|
+
return isBefore(blockA, blockB) || isEqualTo(blockA, blockB);
|
|
1095
|
+
}
|
|
1096
|
+
|
|
1097
|
+
// src/shared/blockrange.ts
|
|
1098
|
+
var RangeTypeIds = {
|
|
1099
|
+
Unbounded: "unbounded",
|
|
1100
|
+
LeftBounded: "left-bounded",
|
|
1101
|
+
RightBounded: "right-bounded",
|
|
1102
|
+
Bounded: "bounded"
|
|
1113
1103
|
};
|
|
1104
|
+
function buildBlockNumberRange(startBlock, endBlock) {
|
|
1105
|
+
if (startBlock === void 0 && endBlock === void 0) {
|
|
1106
|
+
return {
|
|
1107
|
+
rangeType: RangeTypeIds.Unbounded
|
|
1108
|
+
};
|
|
1109
|
+
}
|
|
1110
|
+
if (startBlock !== void 0 && endBlock === void 0) {
|
|
1111
|
+
return {
|
|
1112
|
+
rangeType: RangeTypeIds.LeftBounded,
|
|
1113
|
+
startBlock
|
|
1114
|
+
};
|
|
1115
|
+
}
|
|
1116
|
+
if (startBlock === void 0 && endBlock !== void 0) {
|
|
1117
|
+
return {
|
|
1118
|
+
rangeType: RangeTypeIds.RightBounded,
|
|
1119
|
+
endBlock
|
|
1120
|
+
};
|
|
1121
|
+
}
|
|
1122
|
+
if (startBlock !== void 0 && endBlock !== void 0) {
|
|
1123
|
+
if (startBlock > endBlock) {
|
|
1124
|
+
throw new Error(
|
|
1125
|
+
`For a block number range startBlock must be lower than or equal to endBlock.`
|
|
1126
|
+
);
|
|
1127
|
+
}
|
|
1128
|
+
return {
|
|
1129
|
+
rangeType: RangeTypeIds.Bounded,
|
|
1130
|
+
startBlock,
|
|
1131
|
+
endBlock
|
|
1132
|
+
};
|
|
1133
|
+
}
|
|
1134
|
+
throw new Error("Invalid block number range. This should be unreachable.");
|
|
1135
|
+
}
|
|
1136
|
+
function buildBlockRefRange(startBlock, endBlock) {
|
|
1137
|
+
if (startBlock === void 0 && endBlock === void 0) {
|
|
1138
|
+
return {
|
|
1139
|
+
rangeType: RangeTypeIds.Unbounded
|
|
1140
|
+
};
|
|
1141
|
+
}
|
|
1142
|
+
if (startBlock !== void 0 && endBlock === void 0) {
|
|
1143
|
+
return {
|
|
1144
|
+
rangeType: RangeTypeIds.LeftBounded,
|
|
1145
|
+
startBlock
|
|
1146
|
+
};
|
|
1147
|
+
}
|
|
1148
|
+
if (startBlock === void 0 && endBlock !== void 0) {
|
|
1149
|
+
return {
|
|
1150
|
+
rangeType: RangeTypeIds.RightBounded,
|
|
1151
|
+
endBlock
|
|
1152
|
+
};
|
|
1153
|
+
}
|
|
1154
|
+
if (startBlock !== void 0 && endBlock !== void 0) {
|
|
1155
|
+
if (isBeforeOrEqualTo(startBlock, endBlock) === false) {
|
|
1156
|
+
throw new Error(`For a block ref range startBlock must be before or equal to endBlock.`);
|
|
1157
|
+
}
|
|
1158
|
+
return {
|
|
1159
|
+
rangeType: RangeTypeIds.Bounded,
|
|
1160
|
+
startBlock,
|
|
1161
|
+
endBlock
|
|
1162
|
+
};
|
|
1163
|
+
}
|
|
1164
|
+
throw new Error("Invalid block ref range. This should be unreachable.");
|
|
1165
|
+
}
|
|
1166
|
+
|
|
1167
|
+
// src/indexing-status/chain-indexing-status-snapshot.ts
|
|
1114
1168
|
var ChainIndexingStatusIds = {
|
|
1115
1169
|
/**
|
|
1116
1170
|
* Represents that indexing of the chain is not ready to begin yet because:
|
|
@@ -1142,19 +1196,6 @@ var ChainIndexingStatusIds = {
|
|
|
1142
1196
|
*/
|
|
1143
1197
|
Completed: "chain-completed"
|
|
1144
1198
|
};
|
|
1145
|
-
function createIndexingConfig(startBlock, endBlock) {
|
|
1146
|
-
if (endBlock) {
|
|
1147
|
-
return {
|
|
1148
|
-
blockRangeType: BlockRefRangeTypeIds.Definite,
|
|
1149
|
-
startBlock,
|
|
1150
|
-
endBlock
|
|
1151
|
-
};
|
|
1152
|
-
}
|
|
1153
|
-
return {
|
|
1154
|
-
blockRangeType: BlockRefRangeTypeIds.Indefinite,
|
|
1155
|
-
startBlock
|
|
1156
|
-
};
|
|
1157
|
-
}
|
|
1158
1199
|
function getTimestampForLowestOmnichainStartBlock(chains) {
|
|
1159
1200
|
const earliestKnownBlockTimestamps = chains.map(
|
|
1160
1201
|
(chain) => chain.config.startBlock.timestamp
|
|
@@ -1171,7 +1212,7 @@ function getTimestampForHighestOmnichainKnownBlock(chains) {
|
|
|
1171
1212
|
for (const chain of chains) {
|
|
1172
1213
|
switch (chain.chainStatus) {
|
|
1173
1214
|
case ChainIndexingStatusIds.Queued:
|
|
1174
|
-
if (chain.config.
|
|
1215
|
+
if (chain.config.rangeType === RangeTypeIds.Bounded) {
|
|
1175
1216
|
latestKnownBlockTimestamps.push(chain.config.endBlock.timestamp);
|
|
1176
1217
|
}
|
|
1177
1218
|
break;
|
|
@@ -1314,22 +1355,9 @@ function getOmnichainIndexingCursor(chains) {
|
|
|
1314
1355
|
|
|
1315
1356
|
// src/indexing-status/zod-schema/chain-indexing-status-snapshot.ts
|
|
1316
1357
|
var import_v47 = require("zod/v4");
|
|
1317
|
-
|
|
1318
|
-
// src/shared/block-ref.ts
|
|
1319
|
-
function isBefore(blockA, blockB) {
|
|
1320
|
-
return blockA.number < blockB.number && blockA.timestamp < blockB.timestamp;
|
|
1321
|
-
}
|
|
1322
|
-
function isEqualTo(blockA, blockB) {
|
|
1323
|
-
return blockA.number === blockB.number && blockA.timestamp === blockB.timestamp;
|
|
1324
|
-
}
|
|
1325
|
-
function isBeforeOrEqualTo(blockA, blockB) {
|
|
1326
|
-
return isBefore(blockA, blockB) || isEqualTo(blockA, blockB);
|
|
1327
|
-
}
|
|
1328
|
-
|
|
1329
|
-
// src/indexing-status/zod-schema/chain-indexing-status-snapshot.ts
|
|
1330
1358
|
function invariant_chainSnapshotQueuedBlocks(ctx) {
|
|
1331
1359
|
const { config } = ctx.value;
|
|
1332
|
-
if (config.
|
|
1360
|
+
if (config.rangeType === RangeTypeIds.LeftBounded) {
|
|
1333
1361
|
return;
|
|
1334
1362
|
}
|
|
1335
1363
|
if (isBeforeOrEqualTo(config.startBlock, config.endBlock) === false) {
|
|
@@ -1356,7 +1384,7 @@ function invariant_chainSnapshotBackfillBlocks(ctx) {
|
|
|
1356
1384
|
message: "`latestIndexedBlock` must be before or same as `backfillEndBlock`."
|
|
1357
1385
|
});
|
|
1358
1386
|
}
|
|
1359
|
-
if (config.
|
|
1387
|
+
if (config.rangeType === RangeTypeIds.LeftBounded) {
|
|
1360
1388
|
return;
|
|
1361
1389
|
}
|
|
1362
1390
|
if (isEqualTo(backfillEndBlock, config.endBlock) === false) {
|
|
@@ -1401,31 +1429,40 @@ function invariant_chainSnapshotFollowingBlocks(ctx) {
|
|
|
1401
1429
|
});
|
|
1402
1430
|
}
|
|
1403
1431
|
}
|
|
1404
|
-
var makeBlockRefRangeSchema = (valueLabel = "Value") => import_v47.z.discriminatedUnion("blockRangeType", [
|
|
1405
|
-
import_v47.z.object({
|
|
1406
|
-
blockRangeType: import_v47.z.literal(BlockRefRangeTypeIds.Indefinite),
|
|
1407
|
-
startBlock: makeBlockRefSchema(valueLabel)
|
|
1408
|
-
}),
|
|
1409
|
-
import_v47.z.object({
|
|
1410
|
-
blockRangeType: import_v47.z.literal(BlockRefRangeTypeIds.Definite),
|
|
1411
|
-
startBlock: makeBlockRefSchema(valueLabel),
|
|
1412
|
-
endBlock: makeBlockRefSchema(valueLabel)
|
|
1413
|
-
})
|
|
1414
|
-
]);
|
|
1415
1432
|
var makeChainIndexingStatusSnapshotQueuedSchema = (valueLabel = "Value") => import_v47.z.object({
|
|
1416
1433
|
chainStatus: import_v47.z.literal(ChainIndexingStatusIds.Queued),
|
|
1417
|
-
config:
|
|
1434
|
+
config: import_v47.z.discriminatedUnion("rangeType", [
|
|
1435
|
+
import_v47.z.object({
|
|
1436
|
+
rangeType: import_v47.z.literal(RangeTypeIds.LeftBounded),
|
|
1437
|
+
startBlock: makeBlockRefSchema(valueLabel)
|
|
1438
|
+
}),
|
|
1439
|
+
import_v47.z.object({
|
|
1440
|
+
rangeType: import_v47.z.literal(RangeTypeIds.Bounded),
|
|
1441
|
+
startBlock: makeBlockRefSchema(valueLabel),
|
|
1442
|
+
endBlock: makeBlockRefSchema(valueLabel)
|
|
1443
|
+
})
|
|
1444
|
+
])
|
|
1418
1445
|
}).check(invariant_chainSnapshotQueuedBlocks);
|
|
1419
1446
|
var makeChainIndexingStatusSnapshotBackfillSchema = (valueLabel = "Value") => import_v47.z.object({
|
|
1420
1447
|
chainStatus: import_v47.z.literal(ChainIndexingStatusIds.Backfill),
|
|
1421
|
-
config:
|
|
1448
|
+
config: import_v47.z.discriminatedUnion("rangeType", [
|
|
1449
|
+
import_v47.z.object({
|
|
1450
|
+
rangeType: import_v47.z.literal(RangeTypeIds.LeftBounded),
|
|
1451
|
+
startBlock: makeBlockRefSchema(valueLabel)
|
|
1452
|
+
}),
|
|
1453
|
+
import_v47.z.object({
|
|
1454
|
+
rangeType: import_v47.z.literal(RangeTypeIds.Bounded),
|
|
1455
|
+
startBlock: makeBlockRefSchema(valueLabel),
|
|
1456
|
+
endBlock: makeBlockRefSchema(valueLabel)
|
|
1457
|
+
})
|
|
1458
|
+
]),
|
|
1422
1459
|
latestIndexedBlock: makeBlockRefSchema(valueLabel),
|
|
1423
1460
|
backfillEndBlock: makeBlockRefSchema(valueLabel)
|
|
1424
1461
|
}).check(invariant_chainSnapshotBackfillBlocks);
|
|
1425
1462
|
var makeChainIndexingStatusSnapshotCompletedSchema = (valueLabel = "Value") => import_v47.z.object({
|
|
1426
1463
|
chainStatus: import_v47.z.literal(ChainIndexingStatusIds.Completed),
|
|
1427
1464
|
config: import_v47.z.object({
|
|
1428
|
-
|
|
1465
|
+
rangeType: import_v47.z.literal(RangeTypeIds.Bounded),
|
|
1429
1466
|
startBlock: makeBlockRefSchema(valueLabel),
|
|
1430
1467
|
endBlock: makeBlockRefSchema(valueLabel)
|
|
1431
1468
|
}),
|
|
@@ -1434,7 +1471,7 @@ var makeChainIndexingStatusSnapshotCompletedSchema = (valueLabel = "Value") => i
|
|
|
1434
1471
|
var makeChainIndexingStatusSnapshotFollowingSchema = (valueLabel = "Value") => import_v47.z.object({
|
|
1435
1472
|
chainStatus: import_v47.z.literal(ChainIndexingStatusIds.Following),
|
|
1436
1473
|
config: import_v47.z.object({
|
|
1437
|
-
|
|
1474
|
+
rangeType: import_v47.z.literal(RangeTypeIds.LeftBounded),
|
|
1438
1475
|
startBlock: makeBlockRefSchema(valueLabel)
|
|
1439
1476
|
}),
|
|
1440
1477
|
latestIndexedBlock: makeBlockRefSchema(valueLabel),
|
|
@@ -1702,7 +1739,7 @@ function invariant_snapshotTimeIsTheHighestKnownBlockTimestamp(ctx) {
|
|
|
1702
1739
|
const { snapshotTime, omnichainSnapshot } = ctx.value;
|
|
1703
1740
|
const chains = Array.from(omnichainSnapshot.chains.values());
|
|
1704
1741
|
const startBlockTimestamps = chains.map((chain) => chain.config.startBlock.timestamp);
|
|
1705
|
-
const endBlockTimestamps = chains.map((chain) => chain.config).filter((chainConfig) => chainConfig.
|
|
1742
|
+
const endBlockTimestamps = chains.map((chain) => chain.config).filter((chainConfig) => chainConfig.rangeType === RangeTypeIds.Bounded).map((chainConfig) => chainConfig.endBlock.timestamp);
|
|
1706
1743
|
const backfillEndBlockTimestamps = chains.filter((chain) => chain.chainStatus === ChainIndexingStatusIds.Backfill).map((chain) => chain.backfillEndBlock.timestamp);
|
|
1707
1744
|
const latestKnownBlockTimestamps = chains.filter((chain) => chain.chainStatus === ChainIndexingStatusIds.Following).map((chain) => chain.latestKnownBlock.timestamp);
|
|
1708
1745
|
const highestKnownBlockTimestamp = Math.max(
|
|
@@ -4376,16 +4413,6 @@ ${(0, import_v435.prettifyError)(parsed.error)}
|
|
|
4376
4413
|
}
|
|
4377
4414
|
return parsed.data;
|
|
4378
4415
|
}
|
|
4379
|
-
function deserializeBlockrange(maybeBlockrange, valueLabel) {
|
|
4380
|
-
const schema = makeBlockrangeSchema(valueLabel);
|
|
4381
|
-
const parsed = schema.safeParse(maybeBlockrange);
|
|
4382
|
-
if (parsed.error) {
|
|
4383
|
-
throw new Error(`Cannot deserialize Blockrange:
|
|
4384
|
-
${(0, import_v435.prettifyError)(parsed.error)}
|
|
4385
|
-
`);
|
|
4386
|
-
}
|
|
4387
|
-
return parsed.data;
|
|
4388
|
-
}
|
|
4389
4416
|
function deserializeBlockRef(maybeBlockRef, valueLabel) {
|
|
4390
4417
|
const schema = makeBlockRefSchema(valueLabel);
|
|
4391
4418
|
const parsed = schema.safeParse(maybeBlockRef);
|