@ensnode/ensnode-sdk 1.15.2 → 1.17.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 +19 -6
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +8 -3
- package/dist/index.d.ts +8 -3
- package/dist/index.js +19 -6
- package/dist/index.js.map +1 -1
- package/dist/internal.cjs +1223 -63
- package/dist/internal.cjs.map +1 -1
- package/dist/internal.d.cts +4 -4
- package/dist/internal.d.ts +4 -4
- package/dist/internal.js +1223 -63
- package/dist/internal.js.map +1 -1
- package/dist/{namespace-specific-value-BBZET9O0.d.cts → namespace-specific-value-C9XIUp1F.d.cts} +15 -2
- package/dist/{namespace-specific-value-BBZET9O0.d.ts → namespace-specific-value-C9XIUp1F.d.ts} +15 -2
- package/package.json +5 -5
package/dist/internal.cjs
CHANGED
|
@@ -61,6 +61,7 @@ __export(internal_exports, {
|
|
|
61
61
|
interpretAddressRecordValue: () => interpretAddressRecordValue,
|
|
62
62
|
interpretContenthashValue: () => interpretContenthashValue,
|
|
63
63
|
interpretDnszonehashValue: () => interpretDnszonehashValue,
|
|
64
|
+
interpretMetadataKey: () => interpretMetadataKey,
|
|
64
65
|
interpretNameRecordValue: () => interpretNameRecordValue,
|
|
65
66
|
interpretPubkeyValue: () => interpretPubkeyValue,
|
|
66
67
|
interpretTextRecordKey: () => interpretTextRecordKey,
|
|
@@ -699,10 +700,10 @@ function getHighestKnownBlockTimestamp(chains) {
|
|
|
699
700
|
"Invariant violation: at least one chain is required to determine the highest known block timestamp"
|
|
700
701
|
);
|
|
701
702
|
}
|
|
702
|
-
const startBlockTimestamps = chains.map((
|
|
703
|
-
const endBlockTimestamps = chains.map((
|
|
704
|
-
const backfillEndBlockTimestamps = chains.filter((
|
|
705
|
-
const latestKnownBlockTimestamps = chains.filter((
|
|
703
|
+
const startBlockTimestamps = chains.map((chain2) => chain2.config.startBlock.timestamp);
|
|
704
|
+
const endBlockTimestamps = chains.map((chain2) => chain2.config).filter((chainConfig) => chainConfig.rangeType === RangeTypeIds.Bounded).map((chainConfig) => chainConfig.endBlock.timestamp);
|
|
705
|
+
const backfillEndBlockTimestamps = chains.filter((chain2) => chain2.chainStatus === ChainIndexingStatusIds.Backfill).map((chain2) => chain2.backfillEndBlock.timestamp);
|
|
706
|
+
const latestKnownBlockTimestamps = chains.filter((chain2) => chain2.chainStatus === ChainIndexingStatusIds.Following).map((chain2) => chain2.latestKnownBlock.timestamp);
|
|
706
707
|
return Math.max(
|
|
707
708
|
...startBlockTimestamps,
|
|
708
709
|
...endBlockTimestamps,
|
|
@@ -742,26 +743,26 @@ var OmnichainIndexingStatusIds = {
|
|
|
742
743
|
Completed: "omnichain-completed"
|
|
743
744
|
};
|
|
744
745
|
function checkChainIndexingStatusSnapshotsForOmnichainStatusSnapshotUnstarted(chains) {
|
|
745
|
-
return chains.every((
|
|
746
|
+
return chains.every((chain2) => chain2.chainStatus === ChainIndexingStatusIds.Queued);
|
|
746
747
|
}
|
|
747
748
|
function checkChainIndexingStatusSnapshotsForOmnichainStatusSnapshotBackfill(chains) {
|
|
748
749
|
const atLeastOneChainInTargetStatus = chains.some(
|
|
749
|
-
(
|
|
750
|
+
(chain2) => chain2.chainStatus === ChainIndexingStatusIds.Backfill
|
|
750
751
|
);
|
|
751
752
|
const otherChainsHaveValidStatuses = chains.every(
|
|
752
|
-
(
|
|
753
|
+
(chain2) => chain2.chainStatus === ChainIndexingStatusIds.Queued || chain2.chainStatus === ChainIndexingStatusIds.Backfill || chain2.chainStatus === ChainIndexingStatusIds.Completed
|
|
753
754
|
);
|
|
754
755
|
return atLeastOneChainInTargetStatus && otherChainsHaveValidStatuses;
|
|
755
756
|
}
|
|
756
757
|
function checkChainIndexingStatusSnapshotsForOmnichainStatusSnapshotCompleted(chains) {
|
|
757
758
|
const allChainsHaveValidStatuses = chains.every(
|
|
758
|
-
(
|
|
759
|
+
(chain2) => chain2.chainStatus === ChainIndexingStatusIds.Completed
|
|
759
760
|
);
|
|
760
761
|
return allChainsHaveValidStatuses;
|
|
761
762
|
}
|
|
762
763
|
function checkChainIndexingStatusSnapshotsForOmnichainStatusSnapshotFollowing(chains) {
|
|
763
764
|
const allChainsHaveValidStatuses = chains.some(
|
|
764
|
-
(
|
|
765
|
+
(chain2) => chain2.chainStatus === ChainIndexingStatusIds.Following
|
|
765
766
|
);
|
|
766
767
|
return allChainsHaveValidStatuses;
|
|
767
768
|
}
|
|
@@ -923,12 +924,12 @@ function invariant_omnichainSnapshotStatusIsConsistentWithChainSnapshot(ctx) {
|
|
|
923
924
|
function invariant_omnichainIndexingCursorLowerThanEarliestStartBlockAcrossQueuedChains(ctx) {
|
|
924
925
|
const snapshot = ctx.value;
|
|
925
926
|
const queuedChains = Array.from(snapshot.chains.values()).filter(
|
|
926
|
-
(
|
|
927
|
+
(chain2) => chain2.chainStatus === ChainIndexingStatusIds.Queued
|
|
927
928
|
);
|
|
928
929
|
if (queuedChains.length === 0) {
|
|
929
930
|
return;
|
|
930
931
|
}
|
|
931
|
-
const queuedChainStartBlocks = queuedChains.map((
|
|
932
|
+
const queuedChainStartBlocks = queuedChains.map((chain2) => chain2.config.startBlock.timestamp);
|
|
932
933
|
const queuedChainEarliestStartBlock = Math.min(...queuedChainStartBlocks);
|
|
933
934
|
if (snapshot.omnichainIndexingCursor >= queuedChainEarliestStartBlock) {
|
|
934
935
|
ctx.issues.push({
|
|
@@ -941,12 +942,12 @@ function invariant_omnichainIndexingCursorLowerThanEarliestStartBlockAcrossQueue
|
|
|
941
942
|
function invariant_omnichainIndexingCursorLowerThanOrEqualToLatestBackfillEndBlockAcrossBackfillChains(ctx) {
|
|
942
943
|
const snapshot = ctx.value;
|
|
943
944
|
const backfillChains = Array.from(snapshot.chains.values()).filter(
|
|
944
|
-
(
|
|
945
|
+
(chain2) => chain2.chainStatus === ChainIndexingStatusIds.Backfill
|
|
945
946
|
);
|
|
946
947
|
if (backfillChains.length === 0) {
|
|
947
948
|
return;
|
|
948
949
|
}
|
|
949
|
-
const backfillEndBlocks = backfillChains.map((
|
|
950
|
+
const backfillEndBlocks = backfillChains.map((chain2) => chain2.backfillEndBlock.timestamp);
|
|
950
951
|
const highestBackfillEndBlock = Math.max(...backfillEndBlocks);
|
|
951
952
|
if (snapshot.omnichainIndexingCursor > highestBackfillEndBlock) {
|
|
952
953
|
ctx.issues.push({
|
|
@@ -959,13 +960,13 @@ function invariant_omnichainIndexingCursorLowerThanOrEqualToLatestBackfillEndBlo
|
|
|
959
960
|
function invariant_omnichainIndexingCursorIsEqualToHighestLatestIndexedBlockAcrossIndexedChain(ctx) {
|
|
960
961
|
const snapshot = ctx.value;
|
|
961
962
|
const indexedChains = Array.from(snapshot.chains.values()).filter(
|
|
962
|
-
(
|
|
963
|
+
(chain2) => chain2.chainStatus === ChainIndexingStatusIds.Backfill || chain2.chainStatus === ChainIndexingStatusIds.Completed || chain2.chainStatus === ChainIndexingStatusIds.Following
|
|
963
964
|
);
|
|
964
965
|
if (indexedChains.length === 0) {
|
|
965
966
|
return;
|
|
966
967
|
}
|
|
967
968
|
const indexedChainLatestIndexedBlocks = indexedChains.map(
|
|
968
|
-
(
|
|
969
|
+
(chain2) => chain2.latestIndexedBlock.timestamp
|
|
969
970
|
);
|
|
970
971
|
const indexedChainHighestLatestIndexedBlock = Math.max(...indexedChainLatestIndexedBlocks);
|
|
971
972
|
if (snapshot.omnichainIndexingCursor !== indexedChainHighestLatestIndexedBlock) {
|
|
@@ -1789,8 +1790,8 @@ function decodeEncodedReferrer(encodedReferrer) {
|
|
|
1789
1790
|
`Encoded referrer value must be represented by ${ENCODED_REFERRER_BYTE_LENGTH} bytes.`
|
|
1790
1791
|
);
|
|
1791
1792
|
}
|
|
1792
|
-
const
|
|
1793
|
-
if (
|
|
1793
|
+
const padding2 = (0, import_viem7.slice)(encodedReferrer, 0, ENCODED_REFERRER_BYTE_OFFSET);
|
|
1794
|
+
if (padding2 !== EXPECTED_ENCODED_REFERRER_PADDING) return import_viem7.zeroAddress;
|
|
1794
1795
|
const decodedReferrer = (0, import_viem7.slice)(encodedReferrer, ENCODED_REFERRER_BYTE_OFFSET);
|
|
1795
1796
|
try {
|
|
1796
1797
|
return (0, import_enssdk6.toNormalizedAddress)(decodedReferrer);
|
|
@@ -2156,7 +2157,1000 @@ var import_datasources5 = require("@ensnode/datasources");
|
|
|
2156
2157
|
|
|
2157
2158
|
// ../integration-test-env/src/devnet/fixtures.ts
|
|
2158
2159
|
var import_address_encoder = require("@ensdomains/address-encoder");
|
|
2159
|
-
var
|
|
2160
|
+
var import_utils2 = require("@ensdomains/address-encoder/utils");
|
|
2161
|
+
|
|
2162
|
+
// ../../node_modules/.pnpm/@ensdomains+content-hash@3.1.0-rc.1/node_modules/@ensdomains/content-hash/dist/esm/utils/coders.js
|
|
2163
|
+
var import_coders = require("@ensdomains/address-encoder/coders");
|
|
2164
|
+
|
|
2165
|
+
// ../../node_modules/.pnpm/@scure+base@1.2.6/node_modules/@scure/base/lib/esm/index.js
|
|
2166
|
+
function isBytes(a) {
|
|
2167
|
+
return a instanceof Uint8Array || ArrayBuffer.isView(a) && a.constructor.name === "Uint8Array";
|
|
2168
|
+
}
|
|
2169
|
+
function isArrayOf(isString, arr) {
|
|
2170
|
+
if (!Array.isArray(arr))
|
|
2171
|
+
return false;
|
|
2172
|
+
if (arr.length === 0)
|
|
2173
|
+
return true;
|
|
2174
|
+
if (isString) {
|
|
2175
|
+
return arr.every((item) => typeof item === "string");
|
|
2176
|
+
} else {
|
|
2177
|
+
return arr.every((item) => Number.isSafeInteger(item));
|
|
2178
|
+
}
|
|
2179
|
+
}
|
|
2180
|
+
function afn(input) {
|
|
2181
|
+
if (typeof input !== "function")
|
|
2182
|
+
throw new Error("function expected");
|
|
2183
|
+
return true;
|
|
2184
|
+
}
|
|
2185
|
+
function astr(label, input) {
|
|
2186
|
+
if (typeof input !== "string")
|
|
2187
|
+
throw new Error(`${label}: string expected`);
|
|
2188
|
+
return true;
|
|
2189
|
+
}
|
|
2190
|
+
function anumber(n) {
|
|
2191
|
+
if (!Number.isSafeInteger(n))
|
|
2192
|
+
throw new Error(`invalid integer: ${n}`);
|
|
2193
|
+
}
|
|
2194
|
+
function aArr(input) {
|
|
2195
|
+
if (!Array.isArray(input))
|
|
2196
|
+
throw new Error("array expected");
|
|
2197
|
+
}
|
|
2198
|
+
function astrArr(label, input) {
|
|
2199
|
+
if (!isArrayOf(true, input))
|
|
2200
|
+
throw new Error(`${label}: array of strings expected`);
|
|
2201
|
+
}
|
|
2202
|
+
function anumArr(label, input) {
|
|
2203
|
+
if (!isArrayOf(false, input))
|
|
2204
|
+
throw new Error(`${label}: array of numbers expected`);
|
|
2205
|
+
}
|
|
2206
|
+
// @__NO_SIDE_EFFECTS__
|
|
2207
|
+
function chain(...args) {
|
|
2208
|
+
const id = (a) => a;
|
|
2209
|
+
const wrap = (a, b) => (c) => a(b(c));
|
|
2210
|
+
const encode2 = args.map((x) => x.encode).reduceRight(wrap, id);
|
|
2211
|
+
const decode2 = args.map((x) => x.decode).reduce(wrap, id);
|
|
2212
|
+
return { encode: encode2, decode: decode2 };
|
|
2213
|
+
}
|
|
2214
|
+
// @__NO_SIDE_EFFECTS__
|
|
2215
|
+
function alphabet(letters) {
|
|
2216
|
+
const lettersA = typeof letters === "string" ? letters.split("") : letters;
|
|
2217
|
+
const len = lettersA.length;
|
|
2218
|
+
astrArr("alphabet", lettersA);
|
|
2219
|
+
const indexes = new Map(lettersA.map((l, i) => [l, i]));
|
|
2220
|
+
return {
|
|
2221
|
+
encode: (digits) => {
|
|
2222
|
+
aArr(digits);
|
|
2223
|
+
return digits.map((i) => {
|
|
2224
|
+
if (!Number.isSafeInteger(i) || i < 0 || i >= len)
|
|
2225
|
+
throw new Error(`alphabet.encode: digit index outside alphabet "${i}". Allowed: ${letters}`);
|
|
2226
|
+
return lettersA[i];
|
|
2227
|
+
});
|
|
2228
|
+
},
|
|
2229
|
+
decode: (input) => {
|
|
2230
|
+
aArr(input);
|
|
2231
|
+
return input.map((letter) => {
|
|
2232
|
+
astr("alphabet.decode", letter);
|
|
2233
|
+
const i = indexes.get(letter);
|
|
2234
|
+
if (i === void 0)
|
|
2235
|
+
throw new Error(`Unknown letter: "${letter}". Allowed: ${letters}`);
|
|
2236
|
+
return i;
|
|
2237
|
+
});
|
|
2238
|
+
}
|
|
2239
|
+
};
|
|
2240
|
+
}
|
|
2241
|
+
// @__NO_SIDE_EFFECTS__
|
|
2242
|
+
function join(separator = "") {
|
|
2243
|
+
astr("join", separator);
|
|
2244
|
+
return {
|
|
2245
|
+
encode: (from) => {
|
|
2246
|
+
astrArr("join.decode", from);
|
|
2247
|
+
return from.join(separator);
|
|
2248
|
+
},
|
|
2249
|
+
decode: (to) => {
|
|
2250
|
+
astr("join.decode", to);
|
|
2251
|
+
return to.split(separator);
|
|
2252
|
+
}
|
|
2253
|
+
};
|
|
2254
|
+
}
|
|
2255
|
+
// @__NO_SIDE_EFFECTS__
|
|
2256
|
+
function padding(bits, chr = "=") {
|
|
2257
|
+
anumber(bits);
|
|
2258
|
+
astr("padding", chr);
|
|
2259
|
+
return {
|
|
2260
|
+
encode(data) {
|
|
2261
|
+
astrArr("padding.encode", data);
|
|
2262
|
+
while (data.length * bits % 8)
|
|
2263
|
+
data.push(chr);
|
|
2264
|
+
return data;
|
|
2265
|
+
},
|
|
2266
|
+
decode(input) {
|
|
2267
|
+
astrArr("padding.decode", input);
|
|
2268
|
+
let end = input.length;
|
|
2269
|
+
if (end * bits % 8)
|
|
2270
|
+
throw new Error("padding: invalid, string should have whole number of bytes");
|
|
2271
|
+
for (; end > 0 && input[end - 1] === chr; end--) {
|
|
2272
|
+
const last = end - 1;
|
|
2273
|
+
const byte = last * bits;
|
|
2274
|
+
if (byte % 8 === 0)
|
|
2275
|
+
throw new Error("padding: invalid, string has too much padding");
|
|
2276
|
+
}
|
|
2277
|
+
return input.slice(0, end);
|
|
2278
|
+
}
|
|
2279
|
+
};
|
|
2280
|
+
}
|
|
2281
|
+
function convertRadix(data, from, to) {
|
|
2282
|
+
if (from < 2)
|
|
2283
|
+
throw new Error(`convertRadix: invalid from=${from}, base cannot be less than 2`);
|
|
2284
|
+
if (to < 2)
|
|
2285
|
+
throw new Error(`convertRadix: invalid to=${to}, base cannot be less than 2`);
|
|
2286
|
+
aArr(data);
|
|
2287
|
+
if (!data.length)
|
|
2288
|
+
return [];
|
|
2289
|
+
let pos = 0;
|
|
2290
|
+
const res = [];
|
|
2291
|
+
const digits = Array.from(data, (d) => {
|
|
2292
|
+
anumber(d);
|
|
2293
|
+
if (d < 0 || d >= from)
|
|
2294
|
+
throw new Error(`invalid integer: ${d}`);
|
|
2295
|
+
return d;
|
|
2296
|
+
});
|
|
2297
|
+
const dlen = digits.length;
|
|
2298
|
+
while (true) {
|
|
2299
|
+
let carry = 0;
|
|
2300
|
+
let done = true;
|
|
2301
|
+
for (let i = pos; i < dlen; i++) {
|
|
2302
|
+
const digit = digits[i];
|
|
2303
|
+
const fromCarry = from * carry;
|
|
2304
|
+
const digitBase = fromCarry + digit;
|
|
2305
|
+
if (!Number.isSafeInteger(digitBase) || fromCarry / from !== carry || digitBase - digit !== fromCarry) {
|
|
2306
|
+
throw new Error("convertRadix: carry overflow");
|
|
2307
|
+
}
|
|
2308
|
+
const div = digitBase / to;
|
|
2309
|
+
carry = digitBase % to;
|
|
2310
|
+
const rounded = Math.floor(div);
|
|
2311
|
+
digits[i] = rounded;
|
|
2312
|
+
if (!Number.isSafeInteger(rounded) || rounded * to + carry !== digitBase)
|
|
2313
|
+
throw new Error("convertRadix: carry overflow");
|
|
2314
|
+
if (!done)
|
|
2315
|
+
continue;
|
|
2316
|
+
else if (!rounded)
|
|
2317
|
+
pos = i;
|
|
2318
|
+
else
|
|
2319
|
+
done = false;
|
|
2320
|
+
}
|
|
2321
|
+
res.push(carry);
|
|
2322
|
+
if (done)
|
|
2323
|
+
break;
|
|
2324
|
+
}
|
|
2325
|
+
for (let i = 0; i < data.length - 1 && data[i] === 0; i++)
|
|
2326
|
+
res.push(0);
|
|
2327
|
+
return res.reverse();
|
|
2328
|
+
}
|
|
2329
|
+
var gcd = (a, b) => b === 0 ? a : gcd(b, a % b);
|
|
2330
|
+
var radix2carry = /* @__NO_SIDE_EFFECTS__ */ (from, to) => from + (to - gcd(from, to));
|
|
2331
|
+
var powers = /* @__PURE__ */ (() => {
|
|
2332
|
+
let res = [];
|
|
2333
|
+
for (let i = 0; i < 40; i++)
|
|
2334
|
+
res.push(2 ** i);
|
|
2335
|
+
return res;
|
|
2336
|
+
})();
|
|
2337
|
+
function convertRadix2(data, from, to, padding2) {
|
|
2338
|
+
aArr(data);
|
|
2339
|
+
if (from <= 0 || from > 32)
|
|
2340
|
+
throw new Error(`convertRadix2: wrong from=${from}`);
|
|
2341
|
+
if (to <= 0 || to > 32)
|
|
2342
|
+
throw new Error(`convertRadix2: wrong to=${to}`);
|
|
2343
|
+
if (/* @__PURE__ */ radix2carry(from, to) > 32) {
|
|
2344
|
+
throw new Error(`convertRadix2: carry overflow from=${from} to=${to} carryBits=${/* @__PURE__ */ radix2carry(from, to)}`);
|
|
2345
|
+
}
|
|
2346
|
+
let carry = 0;
|
|
2347
|
+
let pos = 0;
|
|
2348
|
+
const max = powers[from];
|
|
2349
|
+
const mask = powers[to] - 1;
|
|
2350
|
+
const res = [];
|
|
2351
|
+
for (const n of data) {
|
|
2352
|
+
anumber(n);
|
|
2353
|
+
if (n >= max)
|
|
2354
|
+
throw new Error(`convertRadix2: invalid data word=${n} from=${from}`);
|
|
2355
|
+
carry = carry << from | n;
|
|
2356
|
+
if (pos + from > 32)
|
|
2357
|
+
throw new Error(`convertRadix2: carry overflow pos=${pos} from=${from}`);
|
|
2358
|
+
pos += from;
|
|
2359
|
+
for (; pos >= to; pos -= to)
|
|
2360
|
+
res.push((carry >> pos - to & mask) >>> 0);
|
|
2361
|
+
const pow = powers[pos];
|
|
2362
|
+
if (pow === void 0)
|
|
2363
|
+
throw new Error("invalid carry");
|
|
2364
|
+
carry &= pow - 1;
|
|
2365
|
+
}
|
|
2366
|
+
carry = carry << to - pos & mask;
|
|
2367
|
+
if (!padding2 && pos >= from)
|
|
2368
|
+
throw new Error("Excess padding");
|
|
2369
|
+
if (!padding2 && carry > 0)
|
|
2370
|
+
throw new Error(`Non-zero padding: ${carry}`);
|
|
2371
|
+
if (padding2 && pos > 0)
|
|
2372
|
+
res.push(carry >>> 0);
|
|
2373
|
+
return res;
|
|
2374
|
+
}
|
|
2375
|
+
// @__NO_SIDE_EFFECTS__
|
|
2376
|
+
function radix(num) {
|
|
2377
|
+
anumber(num);
|
|
2378
|
+
const _256 = 2 ** 8;
|
|
2379
|
+
return {
|
|
2380
|
+
encode: (bytes) => {
|
|
2381
|
+
if (!isBytes(bytes))
|
|
2382
|
+
throw new Error("radix.encode input should be Uint8Array");
|
|
2383
|
+
return convertRadix(Array.from(bytes), _256, num);
|
|
2384
|
+
},
|
|
2385
|
+
decode: (digits) => {
|
|
2386
|
+
anumArr("radix.decode", digits);
|
|
2387
|
+
return Uint8Array.from(convertRadix(digits, num, _256));
|
|
2388
|
+
}
|
|
2389
|
+
};
|
|
2390
|
+
}
|
|
2391
|
+
// @__NO_SIDE_EFFECTS__
|
|
2392
|
+
function radix2(bits, revPadding = false) {
|
|
2393
|
+
anumber(bits);
|
|
2394
|
+
if (bits <= 0 || bits > 32)
|
|
2395
|
+
throw new Error("radix2: bits should be in (0..32]");
|
|
2396
|
+
if (/* @__PURE__ */ radix2carry(8, bits) > 32 || /* @__PURE__ */ radix2carry(bits, 8) > 32)
|
|
2397
|
+
throw new Error("radix2: carry overflow");
|
|
2398
|
+
return {
|
|
2399
|
+
encode: (bytes) => {
|
|
2400
|
+
if (!isBytes(bytes))
|
|
2401
|
+
throw new Error("radix2.encode input should be Uint8Array");
|
|
2402
|
+
return convertRadix2(Array.from(bytes), 8, bits, !revPadding);
|
|
2403
|
+
},
|
|
2404
|
+
decode: (digits) => {
|
|
2405
|
+
anumArr("radix2.decode", digits);
|
|
2406
|
+
return Uint8Array.from(convertRadix2(digits, bits, 8, revPadding));
|
|
2407
|
+
}
|
|
2408
|
+
};
|
|
2409
|
+
}
|
|
2410
|
+
function checksum(len, fn) {
|
|
2411
|
+
anumber(len);
|
|
2412
|
+
afn(fn);
|
|
2413
|
+
return {
|
|
2414
|
+
encode(data) {
|
|
2415
|
+
if (!isBytes(data))
|
|
2416
|
+
throw new Error("checksum.encode: input should be Uint8Array");
|
|
2417
|
+
const sum = fn(data).slice(0, len);
|
|
2418
|
+
const res = new Uint8Array(data.length + len);
|
|
2419
|
+
res.set(data);
|
|
2420
|
+
res.set(sum, data.length);
|
|
2421
|
+
return res;
|
|
2422
|
+
},
|
|
2423
|
+
decode(data) {
|
|
2424
|
+
if (!isBytes(data))
|
|
2425
|
+
throw new Error("checksum.decode: input should be Uint8Array");
|
|
2426
|
+
const payload = data.slice(0, -len);
|
|
2427
|
+
const oldChecksum = data.slice(-len);
|
|
2428
|
+
const newChecksum = fn(payload).slice(0, len);
|
|
2429
|
+
for (let i = 0; i < len; i++)
|
|
2430
|
+
if (newChecksum[i] !== oldChecksum[i])
|
|
2431
|
+
throw new Error("Invalid checksum");
|
|
2432
|
+
return payload;
|
|
2433
|
+
}
|
|
2434
|
+
};
|
|
2435
|
+
}
|
|
2436
|
+
var utils = {
|
|
2437
|
+
alphabet,
|
|
2438
|
+
chain,
|
|
2439
|
+
checksum,
|
|
2440
|
+
convertRadix,
|
|
2441
|
+
convertRadix2,
|
|
2442
|
+
radix,
|
|
2443
|
+
radix2,
|
|
2444
|
+
join,
|
|
2445
|
+
padding
|
|
2446
|
+
};
|
|
2447
|
+
var genBase58 = /* @__NO_SIDE_EFFECTS__ */ (abc) => /* @__PURE__ */ chain(/* @__PURE__ */ radix(58), /* @__PURE__ */ alphabet(abc), /* @__PURE__ */ join(""));
|
|
2448
|
+
var base58 = /* @__PURE__ */ genBase58("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz");
|
|
2449
|
+
|
|
2450
|
+
// ../../node_modules/.pnpm/@ensdomains+content-hash@3.1.0-rc.1/node_modules/@ensdomains/content-hash/dist/esm/utils/coders.js
|
|
2451
|
+
var createMultibaseCoder = ({ name, prefix, encode: encodeWithoutPrefix, decode: decodeWithoutPrefix }) => {
|
|
2452
|
+
const encode2 = (bytes) => `${prefix}${encodeWithoutPrefix(bytes)}`;
|
|
2453
|
+
const decode2 = (multibase) => {
|
|
2454
|
+
if (!multibase.startsWith(prefix)) {
|
|
2455
|
+
throw new Error(`Multibase ${name} must start with ${prefix}`);
|
|
2456
|
+
}
|
|
2457
|
+
return decodeWithoutPrefix(multibase.slice(prefix.length));
|
|
2458
|
+
};
|
|
2459
|
+
return {
|
|
2460
|
+
name,
|
|
2461
|
+
prefix,
|
|
2462
|
+
encode: encode2,
|
|
2463
|
+
decode: decode2
|
|
2464
|
+
};
|
|
2465
|
+
};
|
|
2466
|
+
var base58btc = createMultibaseCoder({
|
|
2467
|
+
name: "base58btc",
|
|
2468
|
+
prefix: "z",
|
|
2469
|
+
encode: base58.encode,
|
|
2470
|
+
decode: base58.decode
|
|
2471
|
+
});
|
|
2472
|
+
var customBase32 = utils.chain(utils.radix2(5), utils.alphabet("abcdefghijklmnopqrstuvwxyz234567"), utils.join(""));
|
|
2473
|
+
var base32 = createMultibaseCoder({
|
|
2474
|
+
name: "base32",
|
|
2475
|
+
prefix: "b",
|
|
2476
|
+
encode: (bytes) => customBase32.encode(bytes),
|
|
2477
|
+
decode: (multibase) => customBase32.decode(multibase)
|
|
2478
|
+
});
|
|
2479
|
+
var base36Chain = utils.chain(utils.radix(36), utils.alphabet("0123456789abcdefghijklmnopqrstuvwxyz"), utils.join(""));
|
|
2480
|
+
var base36 = createMultibaseCoder({
|
|
2481
|
+
name: "base36",
|
|
2482
|
+
prefix: "k",
|
|
2483
|
+
encode: base36Chain.encode,
|
|
2484
|
+
decode: base36Chain.decode
|
|
2485
|
+
});
|
|
2486
|
+
var base64url = createMultibaseCoder({
|
|
2487
|
+
name: "base64url",
|
|
2488
|
+
prefix: "u",
|
|
2489
|
+
encode: import_coders.encodeArAddress,
|
|
2490
|
+
decode: import_coders.decodeArAddress
|
|
2491
|
+
});
|
|
2492
|
+
|
|
2493
|
+
// ../../node_modules/.pnpm/@ensdomains+content-hash@3.1.0-rc.1/node_modules/@ensdomains/content-hash/dist/esm/utils/coerce.js
|
|
2494
|
+
var coerce = (o) => {
|
|
2495
|
+
if (o instanceof Uint8Array && o.constructor.name === "Uint8Array")
|
|
2496
|
+
return o;
|
|
2497
|
+
if (o instanceof ArrayBuffer)
|
|
2498
|
+
return new Uint8Array(o);
|
|
2499
|
+
if (ArrayBuffer.isView(o)) {
|
|
2500
|
+
return new Uint8Array(o.buffer, o.byteOffset, o.byteLength);
|
|
2501
|
+
}
|
|
2502
|
+
throw new Error("Unknown type, must be binary type");
|
|
2503
|
+
};
|
|
2504
|
+
|
|
2505
|
+
// ../../node_modules/.pnpm/@noble+curves@1.9.7/node_modules/@noble/curves/esm/utils.js
|
|
2506
|
+
function equalBytes(a, b) {
|
|
2507
|
+
if (a.length !== b.length)
|
|
2508
|
+
return false;
|
|
2509
|
+
let diff = 0;
|
|
2510
|
+
for (let i = 0; i < a.length; i++)
|
|
2511
|
+
diff |= a[i] ^ b[i];
|
|
2512
|
+
return diff === 0;
|
|
2513
|
+
}
|
|
2514
|
+
|
|
2515
|
+
// ../../node_modules/.pnpm/@noble+curves@1.9.7/node_modules/@noble/curves/esm/abstract/utils.js
|
|
2516
|
+
var equalBytes2 = equalBytes;
|
|
2517
|
+
|
|
2518
|
+
// ../../node_modules/.pnpm/@ensdomains+content-hash@3.1.0-rc.1/node_modules/@ensdomains/content-hash/dist/esm/utils/varint.js
|
|
2519
|
+
var MSB = 128;
|
|
2520
|
+
var REST = 127;
|
|
2521
|
+
var MSBALL = ~REST;
|
|
2522
|
+
var INT = Math.pow(2, 31);
|
|
2523
|
+
var encodeVarint = (num, out, offset = 0) => {
|
|
2524
|
+
out = out || [];
|
|
2525
|
+
offset = offset || 0;
|
|
2526
|
+
while (num >= INT) {
|
|
2527
|
+
out[offset++] = num & 255 | MSB;
|
|
2528
|
+
num /= 128;
|
|
2529
|
+
}
|
|
2530
|
+
while (num & MSBALL) {
|
|
2531
|
+
out[offset++] = num & 255 | MSB;
|
|
2532
|
+
num >>>= 7;
|
|
2533
|
+
}
|
|
2534
|
+
out[offset] = num | 0;
|
|
2535
|
+
return out;
|
|
2536
|
+
};
|
|
2537
|
+
var MSB$1 = 128;
|
|
2538
|
+
var REST$1 = 127;
|
|
2539
|
+
var decodeVarint = (buf, offset = 0) => {
|
|
2540
|
+
var res = 0, offset = offset || 0, shift = 0, counter = offset, b, l = buf.length;
|
|
2541
|
+
do {
|
|
2542
|
+
if (counter >= l) {
|
|
2543
|
+
read.bytes = 0;
|
|
2544
|
+
throw new RangeError("Could not decode varint");
|
|
2545
|
+
}
|
|
2546
|
+
b = buf[counter++];
|
|
2547
|
+
res += shift < 28 ? (b & REST$1) << shift : (b & REST$1) * Math.pow(2, shift);
|
|
2548
|
+
shift += 7;
|
|
2549
|
+
} while (b >= MSB$1);
|
|
2550
|
+
return [res, counter - offset];
|
|
2551
|
+
};
|
|
2552
|
+
var N1 = Math.pow(2, 7);
|
|
2553
|
+
var N2 = Math.pow(2, 14);
|
|
2554
|
+
var N3 = Math.pow(2, 21);
|
|
2555
|
+
var N4 = Math.pow(2, 28);
|
|
2556
|
+
var N5 = Math.pow(2, 35);
|
|
2557
|
+
var N6 = Math.pow(2, 42);
|
|
2558
|
+
var N7 = Math.pow(2, 49);
|
|
2559
|
+
var N8 = Math.pow(2, 56);
|
|
2560
|
+
var N9 = Math.pow(2, 63);
|
|
2561
|
+
var varintEncodingLength = (value) => {
|
|
2562
|
+
return value < N1 ? 1 : value < N2 ? 2 : value < N3 ? 3 : value < N4 ? 4 : value < N5 ? 5 : value < N6 ? 6 : value < N7 ? 7 : value < N8 ? 8 : value < N9 ? 9 : 10;
|
|
2563
|
+
};
|
|
2564
|
+
|
|
2565
|
+
// ../../node_modules/.pnpm/@ensdomains+content-hash@3.1.0-rc.1/node_modules/@ensdomains/content-hash/dist/esm/utils/digest.js
|
|
2566
|
+
var Digest = class {
|
|
2567
|
+
/**
|
|
2568
|
+
* Creates a multihash digest.
|
|
2569
|
+
*/
|
|
2570
|
+
constructor(code, size4, digest, bytes) {
|
|
2571
|
+
Object.defineProperty(this, "code", {
|
|
2572
|
+
enumerable: true,
|
|
2573
|
+
configurable: true,
|
|
2574
|
+
writable: true,
|
|
2575
|
+
value: void 0
|
|
2576
|
+
});
|
|
2577
|
+
Object.defineProperty(this, "size", {
|
|
2578
|
+
enumerable: true,
|
|
2579
|
+
configurable: true,
|
|
2580
|
+
writable: true,
|
|
2581
|
+
value: void 0
|
|
2582
|
+
});
|
|
2583
|
+
Object.defineProperty(this, "digest", {
|
|
2584
|
+
enumerable: true,
|
|
2585
|
+
configurable: true,
|
|
2586
|
+
writable: true,
|
|
2587
|
+
value: void 0
|
|
2588
|
+
});
|
|
2589
|
+
Object.defineProperty(this, "bytes", {
|
|
2590
|
+
enumerable: true,
|
|
2591
|
+
configurable: true,
|
|
2592
|
+
writable: true,
|
|
2593
|
+
value: void 0
|
|
2594
|
+
});
|
|
2595
|
+
this.code = code;
|
|
2596
|
+
this.size = size4;
|
|
2597
|
+
this.digest = digest;
|
|
2598
|
+
this.bytes = bytes;
|
|
2599
|
+
}
|
|
2600
|
+
};
|
|
2601
|
+
var createDigest = (code, digest) => {
|
|
2602
|
+
const size4 = digest.byteLength;
|
|
2603
|
+
const sizeOffset = varintEncodingLength(code);
|
|
2604
|
+
const digestOffset = sizeOffset + varintEncodingLength(size4);
|
|
2605
|
+
const bytes = new Uint8Array(digestOffset + size4);
|
|
2606
|
+
encodeVarint(code, bytes, 0);
|
|
2607
|
+
encodeVarint(size4, bytes, sizeOffset);
|
|
2608
|
+
bytes.set(digest, digestOffset);
|
|
2609
|
+
return new Digest(code, size4, digest, bytes);
|
|
2610
|
+
};
|
|
2611
|
+
var decodeDigest = (multihash) => {
|
|
2612
|
+
const bytes = coerce(multihash);
|
|
2613
|
+
const [code, sizeOffset] = decodeVarint(bytes);
|
|
2614
|
+
const [size4, digestOffset] = decodeVarint(bytes.subarray(sizeOffset));
|
|
2615
|
+
const digest = bytes.subarray(sizeOffset + digestOffset);
|
|
2616
|
+
if (digest.byteLength !== size4) {
|
|
2617
|
+
throw new Error("Incorrect length");
|
|
2618
|
+
}
|
|
2619
|
+
return new Digest(code, size4, digest, bytes);
|
|
2620
|
+
};
|
|
2621
|
+
var digestEquals = (a, b) => {
|
|
2622
|
+
if (a === b) {
|
|
2623
|
+
return true;
|
|
2624
|
+
} else {
|
|
2625
|
+
const data = b;
|
|
2626
|
+
return a.code === data.code && a.size === data.size && data.bytes instanceof Uint8Array && equalBytes2(a.bytes, data.bytes);
|
|
2627
|
+
}
|
|
2628
|
+
};
|
|
2629
|
+
|
|
2630
|
+
// ../../node_modules/.pnpm/@ensdomains+content-hash@3.1.0-rc.1/node_modules/@ensdomains/content-hash/dist/esm/utils/cid.js
|
|
2631
|
+
function format(link, base2) {
|
|
2632
|
+
const { bytes, version } = link;
|
|
2633
|
+
switch (version) {
|
|
2634
|
+
case 0:
|
|
2635
|
+
return toStringV0(bytes, baseCache(link), base2 ?? base58btc.encode);
|
|
2636
|
+
default:
|
|
2637
|
+
return toStringV1(bytes, baseCache(link), base2 ?? base32.encode);
|
|
2638
|
+
}
|
|
2639
|
+
}
|
|
2640
|
+
var cache = /* @__PURE__ */ new WeakMap();
|
|
2641
|
+
function baseCache(cid) {
|
|
2642
|
+
const baseCache2 = cache.get(cid);
|
|
2643
|
+
if (baseCache2 == null) {
|
|
2644
|
+
const baseCache3 = /* @__PURE__ */ new Map();
|
|
2645
|
+
cache.set(cid, baseCache3);
|
|
2646
|
+
return baseCache3;
|
|
2647
|
+
}
|
|
2648
|
+
return baseCache2;
|
|
2649
|
+
}
|
|
2650
|
+
var CID = class _CID {
|
|
2651
|
+
/**
|
|
2652
|
+
* @param version - Version of the CID
|
|
2653
|
+
* @param code - Code of the codec content is encoded in, see https://github.com/multiformats/multicodec/blob/master/table.csv
|
|
2654
|
+
* @param multihash - (Multi)hash of the of the content.
|
|
2655
|
+
*/
|
|
2656
|
+
constructor(version, code, multihash, bytes) {
|
|
2657
|
+
Object.defineProperty(this, "code", {
|
|
2658
|
+
enumerable: true,
|
|
2659
|
+
configurable: true,
|
|
2660
|
+
writable: true,
|
|
2661
|
+
value: void 0
|
|
2662
|
+
});
|
|
2663
|
+
Object.defineProperty(this, "version", {
|
|
2664
|
+
enumerable: true,
|
|
2665
|
+
configurable: true,
|
|
2666
|
+
writable: true,
|
|
2667
|
+
value: void 0
|
|
2668
|
+
});
|
|
2669
|
+
Object.defineProperty(this, "multihash", {
|
|
2670
|
+
enumerable: true,
|
|
2671
|
+
configurable: true,
|
|
2672
|
+
writable: true,
|
|
2673
|
+
value: void 0
|
|
2674
|
+
});
|
|
2675
|
+
Object.defineProperty(this, "bytes", {
|
|
2676
|
+
enumerable: true,
|
|
2677
|
+
configurable: true,
|
|
2678
|
+
writable: true,
|
|
2679
|
+
value: void 0
|
|
2680
|
+
});
|
|
2681
|
+
Object.defineProperty(this, "/", {
|
|
2682
|
+
enumerable: true,
|
|
2683
|
+
configurable: true,
|
|
2684
|
+
writable: true,
|
|
2685
|
+
value: void 0
|
|
2686
|
+
});
|
|
2687
|
+
this.code = code;
|
|
2688
|
+
this.version = version;
|
|
2689
|
+
this.multihash = multihash;
|
|
2690
|
+
this.bytes = bytes;
|
|
2691
|
+
this["/"] = bytes;
|
|
2692
|
+
}
|
|
2693
|
+
/**
|
|
2694
|
+
* Signalling `cid.asCID === cid` has been replaced with `cid['/'] === cid.bytes`
|
|
2695
|
+
* please either use `CID.asCID(cid)` or switch to new signalling mechanism
|
|
2696
|
+
*
|
|
2697
|
+
* @deprecated
|
|
2698
|
+
*/
|
|
2699
|
+
get asCID() {
|
|
2700
|
+
return this;
|
|
2701
|
+
}
|
|
2702
|
+
// ArrayBufferView
|
|
2703
|
+
get byteOffset() {
|
|
2704
|
+
return this.bytes.byteOffset;
|
|
2705
|
+
}
|
|
2706
|
+
// ArrayBufferView
|
|
2707
|
+
get byteLength() {
|
|
2708
|
+
return this.bytes.byteLength;
|
|
2709
|
+
}
|
|
2710
|
+
toV0() {
|
|
2711
|
+
switch (this.version) {
|
|
2712
|
+
case 0: {
|
|
2713
|
+
return this;
|
|
2714
|
+
}
|
|
2715
|
+
case 1: {
|
|
2716
|
+
const { code, multihash } = this;
|
|
2717
|
+
if (code !== DAG_PB_CODE) {
|
|
2718
|
+
throw new Error("Cannot convert a non dag-pb CID to CIDv0");
|
|
2719
|
+
}
|
|
2720
|
+
if (multihash.code !== SHA_256_CODE) {
|
|
2721
|
+
throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");
|
|
2722
|
+
}
|
|
2723
|
+
return _CID.createV0(multihash);
|
|
2724
|
+
}
|
|
2725
|
+
default: {
|
|
2726
|
+
throw Error(`Can not convert CID version ${this.version} to version 0. This is a bug please report`);
|
|
2727
|
+
}
|
|
2728
|
+
}
|
|
2729
|
+
}
|
|
2730
|
+
toV1() {
|
|
2731
|
+
switch (this.version) {
|
|
2732
|
+
case 0: {
|
|
2733
|
+
const { code, digest } = this.multihash;
|
|
2734
|
+
const multihash = createDigest(code, digest);
|
|
2735
|
+
return _CID.createV1(this.code, multihash);
|
|
2736
|
+
}
|
|
2737
|
+
case 1: {
|
|
2738
|
+
return this;
|
|
2739
|
+
}
|
|
2740
|
+
default: {
|
|
2741
|
+
throw Error(`Can not convert CID version ${this.version} to version 1. This is a bug please report`);
|
|
2742
|
+
}
|
|
2743
|
+
}
|
|
2744
|
+
}
|
|
2745
|
+
equals(other) {
|
|
2746
|
+
return _CID.equals(this, other);
|
|
2747
|
+
}
|
|
2748
|
+
static equals(self, other) {
|
|
2749
|
+
const unknown = other;
|
|
2750
|
+
return unknown != null && self.code === unknown.code && self.version === unknown.version && digestEquals(self.multihash, unknown.multihash);
|
|
2751
|
+
}
|
|
2752
|
+
toString(base2) {
|
|
2753
|
+
return format(this, base2);
|
|
2754
|
+
}
|
|
2755
|
+
toJSON() {
|
|
2756
|
+
return { "/": format(this) };
|
|
2757
|
+
}
|
|
2758
|
+
link() {
|
|
2759
|
+
return this;
|
|
2760
|
+
}
|
|
2761
|
+
get [Symbol.toStringTag]() {
|
|
2762
|
+
return "CID";
|
|
2763
|
+
}
|
|
2764
|
+
// Legacy
|
|
2765
|
+
[/* @__PURE__ */ Symbol.for("nodejs.util.inspect.custom")]() {
|
|
2766
|
+
return `CID(${this.toString()})`;
|
|
2767
|
+
}
|
|
2768
|
+
/**
|
|
2769
|
+
* Takes any input `value` and returns a `CID` instance if it was
|
|
2770
|
+
* a `CID` otherwise returns `null`. If `value` is instanceof `CID`
|
|
2771
|
+
* it will return value back. If `value` is not instance of this CID
|
|
2772
|
+
* class, but is compatible CID it will return new instance of this
|
|
2773
|
+
* `CID` class. Otherwise returns null.
|
|
2774
|
+
*
|
|
2775
|
+
* This allows two different incompatible versions of CID library to
|
|
2776
|
+
* co-exist and interop as long as binary interface is compatible.
|
|
2777
|
+
*/
|
|
2778
|
+
static asCID(input) {
|
|
2779
|
+
if (input == null) {
|
|
2780
|
+
return null;
|
|
2781
|
+
}
|
|
2782
|
+
const value = input;
|
|
2783
|
+
if (value instanceof _CID) {
|
|
2784
|
+
return value;
|
|
2785
|
+
} else if (value["/"] != null && value["/"] === value.bytes || value.asCID === value) {
|
|
2786
|
+
const { version, code, multihash, bytes } = value;
|
|
2787
|
+
return new _CID(version, code, multihash, bytes ?? encodeCID(version, code, multihash.bytes));
|
|
2788
|
+
} else if (value[cidSymbol] === true) {
|
|
2789
|
+
const { version, multihash, code } = value;
|
|
2790
|
+
const digest = decodeDigest(multihash);
|
|
2791
|
+
return _CID.create(version, code, digest);
|
|
2792
|
+
} else {
|
|
2793
|
+
return null;
|
|
2794
|
+
}
|
|
2795
|
+
}
|
|
2796
|
+
/**
|
|
2797
|
+
* @param version - Version of the CID
|
|
2798
|
+
* @param code - Code of the codec content is encoded in, see https://github.com/multiformats/multicodec/blob/master/table.csv
|
|
2799
|
+
* @param digest - (Multi)hash of the of the content.
|
|
2800
|
+
*/
|
|
2801
|
+
static create(version, code, digest) {
|
|
2802
|
+
if (typeof code !== "number") {
|
|
2803
|
+
throw new Error("String codecs are no longer supported");
|
|
2804
|
+
}
|
|
2805
|
+
if (!(digest.bytes instanceof Uint8Array)) {
|
|
2806
|
+
throw new Error("Invalid digest");
|
|
2807
|
+
}
|
|
2808
|
+
switch (version) {
|
|
2809
|
+
case 0: {
|
|
2810
|
+
if (code !== DAG_PB_CODE) {
|
|
2811
|
+
throw new Error(`Version 0 CID must use dag-pb (code: ${DAG_PB_CODE}) block encoding`);
|
|
2812
|
+
} else {
|
|
2813
|
+
return new _CID(version, code, digest, digest.bytes);
|
|
2814
|
+
}
|
|
2815
|
+
}
|
|
2816
|
+
case 1: {
|
|
2817
|
+
const bytes = encodeCID(version, code, digest.bytes);
|
|
2818
|
+
return new _CID(version, code, digest, bytes);
|
|
2819
|
+
}
|
|
2820
|
+
default: {
|
|
2821
|
+
throw new Error("Invalid version");
|
|
2822
|
+
}
|
|
2823
|
+
}
|
|
2824
|
+
}
|
|
2825
|
+
/**
|
|
2826
|
+
* Simplified version of `create` for CIDv0.
|
|
2827
|
+
*/
|
|
2828
|
+
static createV0(digest) {
|
|
2829
|
+
return _CID.create(0, DAG_PB_CODE, digest);
|
|
2830
|
+
}
|
|
2831
|
+
/**
|
|
2832
|
+
* Simplified version of `create` for CIDv1.
|
|
2833
|
+
*
|
|
2834
|
+
* @param code - Content encoding format code.
|
|
2835
|
+
* @param digest - Multihash of the content.
|
|
2836
|
+
*/
|
|
2837
|
+
static createV1(code, digest) {
|
|
2838
|
+
return _CID.create(1, code, digest);
|
|
2839
|
+
}
|
|
2840
|
+
/**
|
|
2841
|
+
* Decoded a CID from its binary representation. The byte array must contain
|
|
2842
|
+
* only the CID with no additional bytes.
|
|
2843
|
+
*
|
|
2844
|
+
* An error will be thrown if the bytes provided do not contain a valid
|
|
2845
|
+
* binary representation of a CID.
|
|
2846
|
+
*/
|
|
2847
|
+
static decode(bytes) {
|
|
2848
|
+
let [cid, remainder] = _CID.decodeFirst(bytes);
|
|
2849
|
+
if (remainder.length !== 0) {
|
|
2850
|
+
[cid, remainder] = _CID.decodeFirst(Uint8Array.from([0, DAG_PB_CODE, ...bytes]));
|
|
2851
|
+
if (remainder.length !== 0)
|
|
2852
|
+
throw new Error("Incorrect length");
|
|
2853
|
+
}
|
|
2854
|
+
return cid;
|
|
2855
|
+
}
|
|
2856
|
+
/**
|
|
2857
|
+
* Decoded a CID from its binary representation at the beginning of a byte
|
|
2858
|
+
* array.
|
|
2859
|
+
*
|
|
2860
|
+
* Returns an array with the first element containing the CID and the second
|
|
2861
|
+
* element containing the remainder of the original byte array. The remainder
|
|
2862
|
+
* will be a zero-length byte array if the provided bytes only contained a
|
|
2863
|
+
* binary CID representation.
|
|
2864
|
+
*/
|
|
2865
|
+
static decodeFirst(bytes) {
|
|
2866
|
+
const specs = _CID.inspectBytes(bytes);
|
|
2867
|
+
const prefixSize = specs.size - specs.multihashSize;
|
|
2868
|
+
const multihashBytes = coerce(bytes.subarray(prefixSize, prefixSize + specs.multihashSize));
|
|
2869
|
+
if (multihashBytes.byteLength !== specs.multihashSize) {
|
|
2870
|
+
throw new Error("Incorrect length");
|
|
2871
|
+
}
|
|
2872
|
+
const digestBytes = multihashBytes.subarray(specs.multihashSize - specs.digestSize);
|
|
2873
|
+
const digest = new Digest(specs.multihashCode, specs.digestSize, digestBytes, multihashBytes);
|
|
2874
|
+
const cid = specs.version === 0 ? _CID.createV0(digest) : _CID.createV1(specs.codec, digest);
|
|
2875
|
+
return [cid, bytes.subarray(specs.size)];
|
|
2876
|
+
}
|
|
2877
|
+
/**
|
|
2878
|
+
* Inspect the initial bytes of a CID to determine its properties.
|
|
2879
|
+
*
|
|
2880
|
+
* Involves decoding up to 4 varints. Typically this will require only 4 to 6
|
|
2881
|
+
* bytes but for larger multicodec code values and larger multihash digest
|
|
2882
|
+
* lengths these varints can be quite large. It is recommended that at least
|
|
2883
|
+
* 10 bytes be made available in the `initialBytes` argument for a complete
|
|
2884
|
+
* inspection.
|
|
2885
|
+
*/
|
|
2886
|
+
static inspectBytes(initialBytes) {
|
|
2887
|
+
let offset = 0;
|
|
2888
|
+
const next = () => {
|
|
2889
|
+
const [i, length] = decodeVarint(initialBytes.subarray(offset));
|
|
2890
|
+
offset += length;
|
|
2891
|
+
return i;
|
|
2892
|
+
};
|
|
2893
|
+
let version = next();
|
|
2894
|
+
let codec = DAG_PB_CODE;
|
|
2895
|
+
if (version === 18) {
|
|
2896
|
+
version = 0;
|
|
2897
|
+
offset = 0;
|
|
2898
|
+
} else {
|
|
2899
|
+
codec = next();
|
|
2900
|
+
}
|
|
2901
|
+
if (version !== 0 && version !== 1) {
|
|
2902
|
+
throw new RangeError(`Invalid CID version ${version}`);
|
|
2903
|
+
}
|
|
2904
|
+
const prefixSize = offset;
|
|
2905
|
+
const multihashCode = next();
|
|
2906
|
+
const digestSize = next();
|
|
2907
|
+
const size4 = offset + digestSize;
|
|
2908
|
+
const multihashSize = size4 - prefixSize;
|
|
2909
|
+
return { version, codec, multihashCode, digestSize, multihashSize, size: size4 };
|
|
2910
|
+
}
|
|
2911
|
+
/**
|
|
2912
|
+
* Takes cid in a string representation and creates an instance. If `base`
|
|
2913
|
+
* decoder is not provided will use a default from the configuration. It will
|
|
2914
|
+
* throw an error if encoding of the CID is not compatible with supplied (or
|
|
2915
|
+
* a default decoder).
|
|
2916
|
+
*/
|
|
2917
|
+
static parse(source, base2) {
|
|
2918
|
+
const [prefix, bytes] = parseCIDtoBytes(source, base2);
|
|
2919
|
+
const cid = _CID.decode(bytes);
|
|
2920
|
+
baseCache(cid).set(prefix, source);
|
|
2921
|
+
return cid;
|
|
2922
|
+
}
|
|
2923
|
+
};
|
|
2924
|
+
function parseCIDtoBytes(source, base2) {
|
|
2925
|
+
switch (source[0]) {
|
|
2926
|
+
// CIDv0 is parsed differently
|
|
2927
|
+
case "Q": {
|
|
2928
|
+
const decoder = base2 ?? base58btc;
|
|
2929
|
+
return [
|
|
2930
|
+
base58btc.prefix,
|
|
2931
|
+
decoder.decode(`${base58btc.prefix}${source}`)
|
|
2932
|
+
];
|
|
2933
|
+
}
|
|
2934
|
+
case base58btc.prefix: {
|
|
2935
|
+
const decoder = base2 ?? base58btc;
|
|
2936
|
+
return [base58btc.prefix, decoder.decode(source)];
|
|
2937
|
+
}
|
|
2938
|
+
case base32.prefix: {
|
|
2939
|
+
const decoder = base2 ?? base32;
|
|
2940
|
+
return [base32.prefix, decoder.decode(source)];
|
|
2941
|
+
}
|
|
2942
|
+
case base36.prefix: {
|
|
2943
|
+
const decoder = base2 ?? base36;
|
|
2944
|
+
return [base36.prefix, decoder.decode(source)];
|
|
2945
|
+
}
|
|
2946
|
+
default: {
|
|
2947
|
+
source = `z${source}`;
|
|
2948
|
+
return [source[0], base58btc.decode(source)];
|
|
2949
|
+
}
|
|
2950
|
+
}
|
|
2951
|
+
}
|
|
2952
|
+
function toStringV0(bytes, cache4, base2) {
|
|
2953
|
+
const { prefix } = base2;
|
|
2954
|
+
if (prefix !== base58btc.prefix) {
|
|
2955
|
+
throw Error(`Cannot string encode V0 in ${base2.name} encoding`);
|
|
2956
|
+
}
|
|
2957
|
+
const cid = cache4.get(prefix);
|
|
2958
|
+
if (cid == null) {
|
|
2959
|
+
const cid2 = base2.encode(bytes).slice(1);
|
|
2960
|
+
cache4.set(prefix, cid2);
|
|
2961
|
+
return cid2;
|
|
2962
|
+
} else {
|
|
2963
|
+
return cid;
|
|
2964
|
+
}
|
|
2965
|
+
}
|
|
2966
|
+
function toStringV1(bytes, cache4, base2) {
|
|
2967
|
+
const { prefix } = base2;
|
|
2968
|
+
const cid = cache4.get(prefix);
|
|
2969
|
+
if (cid == null) {
|
|
2970
|
+
const cid2 = base2.encode(bytes);
|
|
2971
|
+
cache4.set(prefix, cid2);
|
|
2972
|
+
return cid2;
|
|
2973
|
+
} else {
|
|
2974
|
+
return cid;
|
|
2975
|
+
}
|
|
2976
|
+
}
|
|
2977
|
+
var DAG_PB_CODE = 112;
|
|
2978
|
+
var SHA_256_CODE = 18;
|
|
2979
|
+
function encodeCID(version, code, multihash) {
|
|
2980
|
+
const codeOffset = varintEncodingLength(version);
|
|
2981
|
+
const hashOffset = codeOffset + varintEncodingLength(code);
|
|
2982
|
+
const bytes = new Uint8Array(hashOffset + multihash.byteLength);
|
|
2983
|
+
encodeVarint(version, bytes, 0);
|
|
2984
|
+
encodeVarint(code, bytes, codeOffset);
|
|
2985
|
+
bytes.set(multihash, hashOffset);
|
|
2986
|
+
return bytes;
|
|
2987
|
+
}
|
|
2988
|
+
var cidSymbol = /* @__PURE__ */ Symbol.for("@ipld/js-cid/CID");
|
|
2989
|
+
|
|
2990
|
+
// ../../node_modules/.pnpm/@ensdomains+content-hash@3.1.0-rc.1/node_modules/@ensdomains/content-hash/dist/esm/helpers.js
|
|
2991
|
+
var concatUint8Arrays = (array1, array2) => {
|
|
2992
|
+
let result = new Uint8Array(array1.length + array2.length);
|
|
2993
|
+
result.set(array1, 0);
|
|
2994
|
+
result.set(array2, array1.length);
|
|
2995
|
+
return result;
|
|
2996
|
+
};
|
|
2997
|
+
|
|
2998
|
+
// ../../node_modules/.pnpm/@ensdomains+content-hash@3.1.0-rc.1/node_modules/@ensdomains/content-hash/dist/esm/map.js
|
|
2999
|
+
var codeToName = {
|
|
3000
|
+
227: "ipfs",
|
|
3001
|
+
229: "ipns",
|
|
3002
|
+
228: "swarm",
|
|
3003
|
+
444: "onion",
|
|
3004
|
+
445: "onion3",
|
|
3005
|
+
11639056: "skynet",
|
|
3006
|
+
11704592: "arweave"
|
|
3007
|
+
};
|
|
3008
|
+
var nameToCode = {
|
|
3009
|
+
ipfs: 227,
|
|
3010
|
+
ipns: 229,
|
|
3011
|
+
swarm: 228,
|
|
3012
|
+
onion: 444,
|
|
3013
|
+
onion3: 445,
|
|
3014
|
+
skynet: 11639056,
|
|
3015
|
+
arweave: 11704592
|
|
3016
|
+
};
|
|
3017
|
+
|
|
3018
|
+
// ../../node_modules/.pnpm/@ensdomains+content-hash@3.1.0-rc.1/node_modules/@ensdomains/content-hash/dist/esm/profiles.js
|
|
3019
|
+
var import_coders3 = require("@ensdomains/address-encoder/coders");
|
|
3020
|
+
var hexStringToBytes = (hex) => {
|
|
3021
|
+
let value = hex;
|
|
3022
|
+
if (value.startsWith("0x")) {
|
|
3023
|
+
value = value.slice(2);
|
|
3024
|
+
}
|
|
3025
|
+
if (value.length % 2 !== 0) {
|
|
3026
|
+
throw new Error("Invalid hex string");
|
|
3027
|
+
}
|
|
3028
|
+
const bytes = new Uint8Array(value.length / 2);
|
|
3029
|
+
for (let i = 0; i < value.length; i += 2) {
|
|
3030
|
+
bytes[i / 2] = parseInt(value.slice(i, i + 2), 16);
|
|
3031
|
+
}
|
|
3032
|
+
return bytes;
|
|
3033
|
+
};
|
|
3034
|
+
var bytesToHexString = (bytes) => {
|
|
3035
|
+
let hex = "";
|
|
3036
|
+
for (let i = 0; i < bytes.length; i++) {
|
|
3037
|
+
hex += bytes[i].toString(16).padStart(2, "0");
|
|
3038
|
+
}
|
|
3039
|
+
return hex;
|
|
3040
|
+
};
|
|
3041
|
+
var isCryptographicIPNS = (cid) => {
|
|
3042
|
+
try {
|
|
3043
|
+
const { multihash } = cid;
|
|
3044
|
+
if (multihash.size < 38) {
|
|
3045
|
+
const mh = decodeDigest(multihash.bytes);
|
|
3046
|
+
if (mh.code === 0 && mh.size < 36) {
|
|
3047
|
+
return false;
|
|
3048
|
+
}
|
|
3049
|
+
}
|
|
3050
|
+
return true;
|
|
3051
|
+
} catch (_) {
|
|
3052
|
+
return false;
|
|
3053
|
+
}
|
|
3054
|
+
};
|
|
3055
|
+
var base64Decode = (value) => (0, import_coders3.decodeArAddress)(value);
|
|
3056
|
+
var encodes = {
|
|
3057
|
+
skynet: (value) => {
|
|
3058
|
+
return base64Decode(value);
|
|
3059
|
+
},
|
|
3060
|
+
swarm: (value) => {
|
|
3061
|
+
const bytes = hexStringToBytes(value);
|
|
3062
|
+
const multihash = createDigest(27, bytes);
|
|
3063
|
+
return CID.create(1, 250, multihash).bytes;
|
|
3064
|
+
},
|
|
3065
|
+
ipfs: (value) => {
|
|
3066
|
+
return CID.parse(value).toV1().bytes;
|
|
3067
|
+
},
|
|
3068
|
+
ipns: (value) => {
|
|
3069
|
+
const cid = CID.parse(value);
|
|
3070
|
+
return CID.create(1, 114, cid.multihash).bytes;
|
|
3071
|
+
},
|
|
3072
|
+
utf8: (value) => {
|
|
3073
|
+
const encoder = new TextEncoder();
|
|
3074
|
+
return encoder.encode(value);
|
|
3075
|
+
},
|
|
3076
|
+
arweave: (value) => {
|
|
3077
|
+
return base64Decode(value);
|
|
3078
|
+
}
|
|
3079
|
+
};
|
|
3080
|
+
var decodes = {
|
|
3081
|
+
hexMultiHash: (value) => {
|
|
3082
|
+
const cid = CID.decode(value);
|
|
3083
|
+
return bytesToHexString(decodeDigest(cid.multihash.bytes).digest);
|
|
3084
|
+
},
|
|
3085
|
+
ipfs: (value) => {
|
|
3086
|
+
const cid = CID.decode(value).toV1();
|
|
3087
|
+
return cid.toString(cid.code === 114 ? base36 : base32);
|
|
3088
|
+
},
|
|
3089
|
+
ipns: (value) => {
|
|
3090
|
+
const cid = CID.decode(value).toV1();
|
|
3091
|
+
if (!isCryptographicIPNS(cid)) {
|
|
3092
|
+
console.warn("[ensdomains/content-hash] use of non-cryptographic identifiers in ipns-ns is deprecated and will be removed, migrate to ED25519 libp2p-key");
|
|
3093
|
+
return String.fromCodePoint(...CID.decode(value).multihash.digest);
|
|
3094
|
+
}
|
|
3095
|
+
return cid.toString(base36);
|
|
3096
|
+
},
|
|
3097
|
+
utf8: (value) => {
|
|
3098
|
+
const decoder = new TextDecoder();
|
|
3099
|
+
return decoder.decode(value);
|
|
3100
|
+
},
|
|
3101
|
+
base64: (value) => {
|
|
3102
|
+
return (0, import_coders3.encodeArAddress)(value);
|
|
3103
|
+
}
|
|
3104
|
+
};
|
|
3105
|
+
var profiles = {
|
|
3106
|
+
skynet: {
|
|
3107
|
+
encode: encodes.skynet,
|
|
3108
|
+
decode: decodes.base64
|
|
3109
|
+
},
|
|
3110
|
+
swarm: {
|
|
3111
|
+
encode: encodes.swarm,
|
|
3112
|
+
decode: decodes.hexMultiHash
|
|
3113
|
+
},
|
|
3114
|
+
ipfs: {
|
|
3115
|
+
encode: encodes.ipfs,
|
|
3116
|
+
decode: decodes.ipfs
|
|
3117
|
+
},
|
|
3118
|
+
ipns: {
|
|
3119
|
+
encode: encodes.ipns,
|
|
3120
|
+
decode: decodes.ipns
|
|
3121
|
+
},
|
|
3122
|
+
arweave: {
|
|
3123
|
+
encode: encodes.arweave,
|
|
3124
|
+
decode: decodes.base64
|
|
3125
|
+
},
|
|
3126
|
+
default: {
|
|
3127
|
+
encode: encodes.utf8,
|
|
3128
|
+
decode: decodes.utf8
|
|
3129
|
+
}
|
|
3130
|
+
};
|
|
3131
|
+
|
|
3132
|
+
// ../../node_modules/.pnpm/@ensdomains+content-hash@3.1.0-rc.1/node_modules/@ensdomains/content-hash/dist/esm/index.js
|
|
3133
|
+
var decode = (contentHash) => {
|
|
3134
|
+
const bytes = hexStringToBytes(contentHash);
|
|
3135
|
+
const [code, offset] = decodeVarint(bytes);
|
|
3136
|
+
const value = bytes.slice(offset);
|
|
3137
|
+
const name = codeToName[code];
|
|
3138
|
+
let profile = profiles[name];
|
|
3139
|
+
if (!profile)
|
|
3140
|
+
profile = profiles["default"];
|
|
3141
|
+
return profile.decode(value);
|
|
3142
|
+
};
|
|
3143
|
+
var encode = (name, value) => {
|
|
3144
|
+
let profile = profiles[name];
|
|
3145
|
+
if (!profile)
|
|
3146
|
+
profile = profiles["default"];
|
|
3147
|
+
const bytes = profile.encode(value);
|
|
3148
|
+
const code = nameToCode[name];
|
|
3149
|
+
const codeBytes = encodeVarint(code, new Uint8Array(varintEncodingLength(code)));
|
|
3150
|
+
return bytesToHexString(concatUint8Arrays(codeBytes, bytes));
|
|
3151
|
+
};
|
|
3152
|
+
|
|
3153
|
+
// ../integration-test-env/src/devnet/fixtures.ts
|
|
2160
3154
|
var import_enssdk8 = require("enssdk");
|
|
2161
3155
|
var import_accounts = require("viem/accounts");
|
|
2162
3156
|
var mnemonic = "test test test test test test test test test test test junk";
|
|
@@ -2181,10 +3175,18 @@ var getRawAddress = (coinName, address) => {
|
|
|
2181
3175
|
const coder = (0, import_address_encoder.getCoderByCoinName)(coinName);
|
|
2182
3176
|
return {
|
|
2183
3177
|
coinType: coder.coinType,
|
|
2184
|
-
raw: (0,
|
|
3178
|
+
raw: (0, import_utils2.bytesToHex)(coder.decode(address)),
|
|
2185
3179
|
address
|
|
2186
3180
|
};
|
|
2187
3181
|
};
|
|
3182
|
+
var getRawContenthash = (codec, input) => {
|
|
3183
|
+
const encoded = encode(codec, input);
|
|
3184
|
+
return {
|
|
3185
|
+
raw: `0x${encoded}`,
|
|
3186
|
+
// decode normalizes values (e.g. IPFS CIDv0 input → CIDv1 decoded, IPNS peer id → base36 CID)
|
|
3187
|
+
decoded: decode(encoded)
|
|
3188
|
+
};
|
|
3189
|
+
};
|
|
2188
3190
|
var testEthTextRecords = {
|
|
2189
3191
|
avatar: { key: "avatar", value: "https://example.com/avatar.png" },
|
|
2190
3192
|
twitter: { key: "com.twitter", value: "ensdomains" },
|
|
@@ -2210,10 +3212,54 @@ var fixtures = {
|
|
|
2210
3212
|
fourBytesInterface: "0x11100111",
|
|
2211
3213
|
publicKeyX: `0x${"02".repeat(32)}`,
|
|
2212
3214
|
publicKeyY: `0x${"03".repeat(32)}`,
|
|
2213
|
-
contenthash: `0x${"04".repeat(32)}`,
|
|
2214
3215
|
rawAddresses,
|
|
2215
3216
|
textRecords: testEthTextRecords
|
|
2216
3217
|
};
|
|
3218
|
+
var efpSeedTargets = {
|
|
3219
|
+
/** ADD + ADD_TAG("block") + ADD_TAG("block") -> tags === ["block"] (dedup). */
|
|
3220
|
+
dedup: (0, import_enssdk8.asNormalizedAddress)(`0x${"d1".repeat(20)}`),
|
|
3221
|
+
/** ADD + ADD_TAG("vip") + REMOVE + ADD -> record present, tags === [] (embed cascade + fresh). */
|
|
3222
|
+
cascade: (0, import_enssdk8.asNormalizedAddress)(`0x${"ca".repeat(20)}`),
|
|
3223
|
+
/** ADD + REMOVE(target + junk) -> record gone (canonical 22-byte keying). */
|
|
3224
|
+
junk: (0, import_enssdk8.asNormalizedAddress)(`0x${"1c".repeat(20)}`),
|
|
3225
|
+
/** Anchors a list whose `user` role must survive a storage-location re-point away and back. */
|
|
3226
|
+
durable: (0, import_enssdk8.asNormalizedAddress)(`0x${"d0".repeat(20)}`),
|
|
3227
|
+
/** Followed plainly by the validated {@link efpFollowActorAddress} list — a real follow. */
|
|
3228
|
+
followPlain: (0, import_enssdk8.asNormalizedAddress)(`0x${"f0".repeat(20)}`),
|
|
3229
|
+
/** Followed but `block`-tagged by that list — excluded from `following` / `followers`. */
|
|
3230
|
+
followBlocked: (0, import_enssdk8.asNormalizedAddress)(`0x${"fb".repeat(20)}`)
|
|
3231
|
+
};
|
|
3232
|
+
var efpSeedRoleUser = (0, import_enssdk8.asNormalizedAddress)(`0x${"ab".repeat(20)}`);
|
|
3233
|
+
var efpSeedActorAddress = (0, import_enssdk8.asNormalizedAddress)(
|
|
3234
|
+
"0x976ea74026e726554db657fa54763abd0c3a0aa9"
|
|
3235
|
+
);
|
|
3236
|
+
var efpFollowActorAddress = (0, import_enssdk8.asNormalizedAddress)(
|
|
3237
|
+
"0x14dc79964da2c08b23698b3d3cc7ca32193d9955"
|
|
3238
|
+
);
|
|
3239
|
+
var contenthashFixtures = {
|
|
3240
|
+
// CIDv0 input — decodes back to CIDv1
|
|
3241
|
+
ipfs: getRawContenthash("ipfs", "QmRAQB6YaCyidP37UdDnjFY5vQuiBrcqdyoW1CuDgwxkD4"),
|
|
3242
|
+
swarm: getRawContenthash(
|
|
3243
|
+
"swarm",
|
|
3244
|
+
"d1de9994b4d039f6548d191eb26786769f580809256b4685ef316805265ea162"
|
|
3245
|
+
),
|
|
3246
|
+
ipns: getRawContenthash("ipns", "12D3KooWG4NvqQVczTrWY1H2tvsJmbQf5bbA3xGYXC4FM3wWCfE4"),
|
|
3247
|
+
onion: getRawContenthash("onion", "zqktlwi4fecvo6ri"),
|
|
3248
|
+
onion3: getRawContenthash("onion3", "p53lf57qovyuvwsc6xnrppyply3vtqm7l6pcobkmyqsiofyeznfu5uqd"),
|
|
3249
|
+
skynet: getRawContenthash("skynet", "CABAB_1Dt0FJsxqsu_J4TodNCbCGvtFf1Uys_3EgzOlTcg"),
|
|
3250
|
+
arweave: getRawContenthash("arweave", "ys32Pt8uC7TrVxHdOLByOspfPEq2LO63wREHQIM9SJQ"),
|
|
3251
|
+
empty: { raw: "0x", decoded: null },
|
|
3252
|
+
invalid: { raw: "0xdeadbeef", decoded: null },
|
|
3253
|
+
zero: {
|
|
3254
|
+
raw: "0x0000000000000000000000000000000000000000000000000000000000000000",
|
|
3255
|
+
decoded: null
|
|
3256
|
+
}
|
|
3257
|
+
};
|
|
3258
|
+
var contenthashSubnames = Object.entries(contenthashFixtures).map(([label, fixture]) => ({
|
|
3259
|
+
label,
|
|
3260
|
+
name: `${label}.contenthash.eth`,
|
|
3261
|
+
records: { contenthash: fixture.raw }
|
|
3262
|
+
}));
|
|
2217
3263
|
|
|
2218
3264
|
// src/omnigraph-api/example-queries.ts
|
|
2219
3265
|
var SEPOLIA_V2_V2_ETH_REGISTRY = getDatasourceContract(
|
|
@@ -2239,7 +3285,10 @@ var SEPOLIA_V2_ACCOUNT_WITH_V1_AND_V2 = (0, import_enssdk9.toNormalizedAddress)(
|
|
|
2239
3285
|
var DEVNET_NAME_WITH_OWNED_RESOLVER = (0, import_enssdk9.asInterpretedName)("example.eth");
|
|
2240
3286
|
var SEPOLIA_V2_NAME = (0, import_enssdk9.asInterpretedName)("roppp.eth");
|
|
2241
3287
|
var VITALIK_NAME = (0, import_enssdk9.asInterpretedName)("vitalik.eth");
|
|
3288
|
+
var DPERRI_DNS_NAME = (0, import_enssdk9.asInterpretedName)("dperri.com");
|
|
2242
3289
|
var GREG_NAME = (0, import_enssdk9.asInterpretedName)("gregskril.eth");
|
|
3290
|
+
var GREG_ADDRESS = (0, import_enssdk9.toNormalizedAddress)("0x179a862703a4adfb29896552df9e307980d19285");
|
|
3291
|
+
var OFFCHAIN_NAME = (0, import_enssdk9.asInterpretedName)("patricio.onpoap.eth");
|
|
2243
3292
|
var MAINNET_PUBLIC_RESOLVER = getDatasourceContract(
|
|
2244
3293
|
import_datasources5.ENSNamespaceIds.Mainnet,
|
|
2245
3294
|
import_datasources5.DatasourceNames.ReverseResolverRoot,
|
|
@@ -2269,13 +3318,13 @@ var GRAPHQL_API_EXAMPLE_QUERIES = [
|
|
|
2269
3318
|
# Reverse resolve the ENS primary name of the account
|
|
2270
3319
|
# using a convenient ETHEREUM alias for mainnet.
|
|
2271
3320
|
primaryName(by: { chainName: ETHEREUM }) {
|
|
2272
|
-
# Get the regular interpreted variant of the primary name
|
|
2273
|
-
# and also the special beautified variant that optimizes names
|
|
3321
|
+
# Get the regular interpreted variant of the primary name
|
|
3322
|
+
# and also the special beautified variant that optimizes names
|
|
2274
3323
|
# containing special characters such as emojis for proper display in interfaces.
|
|
2275
3324
|
name { interpreted beautified }
|
|
2276
3325
|
resolve {
|
|
2277
3326
|
# If the account has a primary name on Ethereum (mainnet),
|
|
2278
|
-
# forward resolve the interpreted ENS profile of that name in the same query
|
|
3327
|
+
# forward resolve the interpreted ENS profile of that name in the same query!
|
|
2279
3328
|
profile {
|
|
2280
3329
|
description
|
|
2281
3330
|
avatar { httpUrl }
|
|
@@ -2290,7 +3339,9 @@ var GRAPHQL_API_EXAMPLE_QUERIES = [
|
|
|
2290
3339
|
}
|
|
2291
3340
|
|
|
2292
3341
|
# Also load the count of ENSv1 and ENSv2 domains owned by the account
|
|
2293
|
-
# to see if they have domains they should upgrade to ENSv2
|
|
3342
|
+
# to see if they have domains they should upgrade to ENSv2.
|
|
3343
|
+
# For simplicity this example query doesn't include additional logic
|
|
3344
|
+
# to filter out domains that have expired.
|
|
2294
3345
|
v1DomainsCount: domains(where: { version: ENSv1 }) { totalCount }
|
|
2295
3346
|
v2DomainsCount: domains(where: { version: ENSv2 }) { totalCount }
|
|
2296
3347
|
}
|
|
@@ -2511,6 +3562,78 @@ query DomainProfile($name: InterpretedName!) {
|
|
|
2511
3562
|
}`,
|
|
2512
3563
|
variables: { default: { name: GREG_NAME } }
|
|
2513
3564
|
},
|
|
3565
|
+
{
|
|
3566
|
+
id: "domain-profile-and-records",
|
|
3567
|
+
query: `
|
|
3568
|
+
query DomainProfileAndRecords($name: InterpretedName!) {
|
|
3569
|
+
domain(by: { name: $name }) {
|
|
3570
|
+
resolve {
|
|
3571
|
+
profile {
|
|
3572
|
+
avatar {
|
|
3573
|
+
httpUrl
|
|
3574
|
+
}
|
|
3575
|
+
addresses {
|
|
3576
|
+
ethereum
|
|
3577
|
+
solana
|
|
3578
|
+
}
|
|
3579
|
+
socials {
|
|
3580
|
+
github {
|
|
3581
|
+
handle
|
|
3582
|
+
httpUrl
|
|
3583
|
+
}
|
|
3584
|
+
twitter {
|
|
3585
|
+
handle
|
|
3586
|
+
httpUrl
|
|
3587
|
+
}
|
|
3588
|
+
}
|
|
3589
|
+
website {
|
|
3590
|
+
httpUrl
|
|
3591
|
+
}
|
|
3592
|
+
}
|
|
3593
|
+
records {
|
|
3594
|
+
addresses(coinTypes: [60, 501]) {
|
|
3595
|
+
coinType
|
|
3596
|
+
address
|
|
3597
|
+
}
|
|
3598
|
+
texts(keys: ["avatar", "com.twitter", "com.github", "url"]) {
|
|
3599
|
+
key
|
|
3600
|
+
value
|
|
3601
|
+
}
|
|
3602
|
+
}
|
|
3603
|
+
}
|
|
3604
|
+
}
|
|
3605
|
+
}`,
|
|
3606
|
+
variables: { default: { name: GREG_NAME } }
|
|
3607
|
+
},
|
|
3608
|
+
////////////////////////////////////
|
|
3609
|
+
// Offchain Name (UnindexedDomain)
|
|
3610
|
+
////////////////////////////////////
|
|
3611
|
+
{
|
|
3612
|
+
id: "offchain-name",
|
|
3613
|
+
query: `
|
|
3614
|
+
query OffchainName($name: InterpretedName!) {
|
|
3615
|
+
domain(by: { name: $name }) {
|
|
3616
|
+
# Resolvable-but-unindexed names (offchain / CCIP-Read) surface as UnindexedDomain
|
|
3617
|
+
__typename
|
|
3618
|
+
id
|
|
3619
|
+
canonical { name { interpreted } }
|
|
3620
|
+
resolver {
|
|
3621
|
+
# the wildcard Resolver that ENS Forward Resolution (ENSIP-10) lands on
|
|
3622
|
+
effective {
|
|
3623
|
+
extended
|
|
3624
|
+
contract { chainId address }
|
|
3625
|
+
}
|
|
3626
|
+
}
|
|
3627
|
+
resolve {
|
|
3628
|
+
records {
|
|
3629
|
+
addresses(coinTypes: [60]) { coinType address }
|
|
3630
|
+
texts(keys: ["avatar", "com.twitter", "description"]) { key value }
|
|
3631
|
+
}
|
|
3632
|
+
}
|
|
3633
|
+
}
|
|
3634
|
+
}`,
|
|
3635
|
+
variables: { default: { name: OFFCHAIN_NAME } }
|
|
3636
|
+
},
|
|
2514
3637
|
//////////////////////
|
|
2515
3638
|
// Domain Subdomains
|
|
2516
3639
|
//////////////////////
|
|
@@ -2641,9 +3764,39 @@ query AccountDomains(
|
|
|
2641
3764
|
// Account Primary Names
|
|
2642
3765
|
/////////////////////////
|
|
2643
3766
|
{
|
|
2644
|
-
id: "account-primary-
|
|
3767
|
+
id: "account-primary-names",
|
|
2645
3768
|
query: `
|
|
2646
|
-
query
|
|
3769
|
+
query AccountPrimaryNames($address: Address!) {
|
|
3770
|
+
account(by: { address: $address }) {
|
|
3771
|
+
address
|
|
3772
|
+
resolve {
|
|
3773
|
+
# Reverse resolution: given this address + a chain, get the primary
|
|
3774
|
+
# name the address has set for that chain.
|
|
3775
|
+
# primaryName returns the result for a single chain (here, Optimism).
|
|
3776
|
+
# (onePrimaryName / twoPrimaryNames are just GraphQL aliases.)
|
|
3777
|
+
onePrimaryName: primaryName(by: { chainName: OPTIMISM }) {
|
|
3778
|
+
chainName
|
|
3779
|
+
name { interpreted beautified }
|
|
3780
|
+
}
|
|
3781
|
+
|
|
3782
|
+
# primaryNames returns one result per requested chain, in a single call.
|
|
3783
|
+
twoPrimaryNames: primaryNames(where: { chainNames: [ETHEREUM, BASE] }) {
|
|
3784
|
+
chainName
|
|
3785
|
+
name { interpreted beautified }
|
|
3786
|
+
}
|
|
3787
|
+
}
|
|
3788
|
+
}
|
|
3789
|
+
}`,
|
|
3790
|
+
variables: {
|
|
3791
|
+
default: { address: GREG_ADDRESS },
|
|
3792
|
+
[import_datasources5.ENSNamespaceIds.EnsTestEnv]: { address: accounts.owner.address },
|
|
3793
|
+
[import_datasources5.ENSNamespaceIds.SepoliaV2]: { address: SEPOLIA_V2_ACCOUNT }
|
|
3794
|
+
}
|
|
3795
|
+
},
|
|
3796
|
+
{
|
|
3797
|
+
id: "account-primary-name-records",
|
|
3798
|
+
query: `
|
|
3799
|
+
query AccountPrimaryNameRecords($address: Address!) {
|
|
2647
3800
|
account(by: { address: $address }) {
|
|
2648
3801
|
address
|
|
2649
3802
|
resolve {
|
|
@@ -2808,19 +3961,20 @@ query AccountResolverPermissions($address: Address!) {
|
|
|
2808
3961
|
query DomainResolver($name: InterpretedName!) {
|
|
2809
3962
|
domain(by: { name: $name }) {
|
|
2810
3963
|
resolver {
|
|
3964
|
+
# the Resolver explicitly assigned to this Domain
|
|
2811
3965
|
assigned {
|
|
2812
|
-
contract {
|
|
2813
|
-
|
|
2814
|
-
|
|
2815
|
-
|
|
2816
|
-
|
|
2817
|
-
}
|
|
3966
|
+
contract { address }
|
|
3967
|
+
}
|
|
3968
|
+
# the Resolver that ENS Forward Resolution (ENSIP-10) actually lands
|
|
3969
|
+
# on for this Domain \u2014 i.e. its effective Resolver
|
|
3970
|
+
effective {
|
|
3971
|
+
contract { address }
|
|
2818
3972
|
}
|
|
2819
3973
|
}
|
|
2820
3974
|
}
|
|
2821
3975
|
}`,
|
|
2822
3976
|
variables: {
|
|
2823
|
-
default: { name:
|
|
3977
|
+
default: { name: DPERRI_DNS_NAME },
|
|
2824
3978
|
[import_datasources5.ENSNamespaceIds.EnsTestEnv]: { name: DEVNET_NAME_WITH_OWNED_RESOLVER },
|
|
2825
3979
|
[import_datasources5.ENSNamespaceIds.SepoliaV2]: { name: SEPOLIA_V2_NAME }
|
|
2826
3980
|
}
|
|
@@ -2889,6 +4043,9 @@ query Namegraph {
|
|
|
2889
4043
|
query: `
|
|
2890
4044
|
query AccountMigratedNames($address: Address!) {
|
|
2891
4045
|
account(by: { address: $address }) {
|
|
4046
|
+
# Count the ENSv1 and ENSv2 domains owned by the account.
|
|
4047
|
+
# For simplicity this example query doesn't include additional logic
|
|
4048
|
+
# to filter out domains that have expired.
|
|
2892
4049
|
v1DomainsCount: domains(where: { version: ENSv1 }) { totalCount }
|
|
2893
4050
|
v2DomainsCount: domains(where: { version: ENSv2 }) { totalCount }
|
|
2894
4051
|
}
|
|
@@ -2919,23 +4076,14 @@ query GetEthDomains {
|
|
|
2919
4076
|
query AccelerateResolve($address: Address!) {
|
|
2920
4077
|
account(by: { address: $address }) {
|
|
2921
4078
|
address
|
|
2922
|
-
resolve(accelerate:
|
|
2923
|
-
|
|
2924
|
-
acceleration {
|
|
2925
|
-
requested
|
|
2926
|
-
attempted
|
|
2927
|
-
}
|
|
4079
|
+
# resolve is automatically accelerated. To disable, resolve(accelerate: false)
|
|
4080
|
+
resolve {
|
|
4081
|
+
acceleration { requested attempted }
|
|
2928
4082
|
primaryName(by: { chainName: ETHEREUM }) {
|
|
2929
4083
|
name { interpreted beautified }
|
|
2930
4084
|
resolve {
|
|
2931
|
-
|
|
2932
|
-
|
|
2933
|
-
requested
|
|
2934
|
-
attempted
|
|
2935
|
-
}
|
|
2936
|
-
profile {
|
|
2937
|
-
description
|
|
2938
|
-
}
|
|
4085
|
+
acceleration { requested attempted }
|
|
4086
|
+
profile { description }
|
|
2939
4087
|
}
|
|
2940
4088
|
}
|
|
2941
4089
|
}
|
|
@@ -3178,29 +4326,29 @@ function buildRpcConfigsFromEnv(env, namespace) {
|
|
|
3178
4326
|
);
|
|
3179
4327
|
const rpcAutoGenMode = buildRpcAutoGenMode(env);
|
|
3180
4328
|
const rpcConfigs = {};
|
|
3181
|
-
for (const
|
|
3182
|
-
const specificValue = env[`RPC_URL_${
|
|
4329
|
+
for (const chain2 of chainsInNamespace) {
|
|
4330
|
+
const specificValue = env[`RPC_URL_${chain2.id}`];
|
|
3183
4331
|
if (specificValue) {
|
|
3184
|
-
rpcConfigs[serializeChainId(
|
|
4332
|
+
rpcConfigs[serializeChainId(chain2.id)] = specificValue;
|
|
3185
4333
|
continue;
|
|
3186
4334
|
}
|
|
3187
|
-
if (
|
|
4335
|
+
if (chain2.id === import_datasources6.ensTestEnvChain.id) {
|
|
3188
4336
|
rpcConfigs[serializeChainId(import_datasources6.ensTestEnvChain.id)] = import_datasources6.ensTestEnvChain.rpcUrls.default.http[0];
|
|
3189
4337
|
continue;
|
|
3190
4338
|
}
|
|
3191
4339
|
const httpUrls = [
|
|
3192
4340
|
// alchemy, if specified and available
|
|
3193
|
-
alchemyApiKey && alchemySupportsChain(
|
|
4341
|
+
alchemyApiKey && alchemySupportsChain(chain2.id) && `https://${buildAlchemyBaseUrl(chain2.id, alchemyApiKey)}`,
|
|
3194
4342
|
// QuickNode, if specified and available
|
|
3195
|
-
quickNodeApiKey && quickNodeEndpointName && quickNodeSupportsChain(
|
|
4343
|
+
quickNodeApiKey && quickNodeEndpointName && quickNodeSupportsChain(chain2.id) && `https://${buildQuickNodeURL(chain2.id, quickNodeApiKey, quickNodeEndpointName)}`,
|
|
3196
4344
|
// dRPC, if specified and available
|
|
3197
|
-
dRPCKey && dRPCSupportsChain(
|
|
4345
|
+
dRPCKey && dRPCSupportsChain(chain2.id) && buildDRPCUrl(chain2.id, dRPCKey)
|
|
3198
4346
|
];
|
|
3199
|
-
const wsUrl = rpcAutoGenMode === RpcAutoGenModes.HttpAndWs && alchemyApiKey && alchemySupportsChain(
|
|
3200
|
-
`wss://${buildAlchemyBaseUrl(
|
|
4347
|
+
const wsUrl = rpcAutoGenMode === RpcAutoGenModes.HttpAndWs && alchemyApiKey && alchemySupportsChain(chain2.id) && //
|
|
4348
|
+
`wss://${buildAlchemyBaseUrl(chain2.id, alchemyApiKey)}`;
|
|
3201
4349
|
const urls = [...httpUrls, wsUrl].filter(Boolean);
|
|
3202
4350
|
if (urls.length > 0) {
|
|
3203
|
-
rpcConfigs[serializeChainId(
|
|
4351
|
+
rpcConfigs[serializeChainId(chain2.id)] = urls.join(
|
|
3204
4352
|
","
|
|
3205
4353
|
);
|
|
3206
4354
|
}
|
|
@@ -3396,6 +4544,10 @@ function interpretTextRecordKey(key) {
|
|
|
3396
4544
|
if (key === "") return null;
|
|
3397
4545
|
return key;
|
|
3398
4546
|
}
|
|
4547
|
+
function interpretMetadataKey(key) {
|
|
4548
|
+
if (hasNullByte(key)) return null;
|
|
4549
|
+
return key;
|
|
4550
|
+
}
|
|
3399
4551
|
function interpretTextRecordValue(value) {
|
|
3400
4552
|
if (hasNullByte(value)) return null;
|
|
3401
4553
|
if (value === "") return null;
|
|
@@ -3549,10 +4701,10 @@ var getContractsByManagedName = (namespace) => {
|
|
|
3549
4701
|
}
|
|
3550
4702
|
};
|
|
3551
4703
|
};
|
|
3552
|
-
var
|
|
4704
|
+
var cache2 = /* @__PURE__ */ new Map();
|
|
3553
4705
|
var getManagedName = (namespace, contract) => {
|
|
3554
4706
|
const cacheKey = `${namespace}:${(0, import_enssdk11.stringifyAccountId)(contract)}`;
|
|
3555
|
-
const cached =
|
|
4707
|
+
const cached = cache2.get(cacheKey);
|
|
3556
4708
|
if (cached !== void 0) return cached;
|
|
3557
4709
|
for (const [managedName, group] of Object.entries(getContractsByManagedName(namespace))) {
|
|
3558
4710
|
const isAnyOfTheContracts = group.contracts.some(
|
|
@@ -3563,7 +4715,7 @@ var getManagedName = (namespace, contract) => {
|
|
|
3563
4715
|
const name = (0, import_enssdk11.asInterpretedName)(namespaceSpecific ?? managedName);
|
|
3564
4716
|
const node = (0, import_enssdk11.namehashInterpretedName)(name);
|
|
3565
4717
|
const result = { name, node, registry: group.registry };
|
|
3566
|
-
|
|
4718
|
+
cache2.set(cacheKey, result);
|
|
3567
4719
|
return result;
|
|
3568
4720
|
}
|
|
3569
4721
|
}
|
|
@@ -3578,9 +4730,9 @@ var import_datasources13 = require("@ensnode/datasources");
|
|
|
3578
4730
|
var getENSv1RootRegistry = (namespace) => getDatasourceContract(namespace, import_datasources13.DatasourceNames.ENSRoot, "ENSv1Registry");
|
|
3579
4731
|
|
|
3580
4732
|
// src/shared/protocol-acceleration/is-bridged-resolver.ts
|
|
3581
|
-
var
|
|
4733
|
+
var cache3 = /* @__PURE__ */ new Map();
|
|
3582
4734
|
var getBridgedResolverConfigs = (namespace) => {
|
|
3583
|
-
const cached =
|
|
4735
|
+
const cached = cache3.get(namespace);
|
|
3584
4736
|
if (cached) return cached;
|
|
3585
4737
|
const configs = [];
|
|
3586
4738
|
const basenames = (0, import_datasources14.maybeGetDatasource)(namespace, import_datasources14.DatasourceNames.Basenames);
|
|
@@ -3615,7 +4767,7 @@ var getBridgedResolverConfigs = (namespace) => {
|
|
|
3615
4767
|
targetRegistryId: (0, import_enssdk13.makeENSv1VirtualRegistryId)(registry, node)
|
|
3616
4768
|
});
|
|
3617
4769
|
}
|
|
3618
|
-
|
|
4770
|
+
cache3.set(namespace, configs);
|
|
3619
4771
|
return configs;
|
|
3620
4772
|
};
|
|
3621
4773
|
function isBridgedResolver(namespace, resolver) {
|
|
@@ -3707,4 +4859,12 @@ var makeTheGraphSubgraphUrl = (namespace, apiKey) => {
|
|
|
3707
4859
|
throw new Error("never");
|
|
3708
4860
|
}
|
|
3709
4861
|
};
|
|
4862
|
+
/*! Bundled license information:
|
|
4863
|
+
|
|
4864
|
+
@scure/base/lib/esm/index.js:
|
|
4865
|
+
(*! scure-base - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
|
|
4866
|
+
|
|
4867
|
+
@noble/curves/esm/utils.js:
|
|
4868
|
+
(*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
|
|
4869
|
+
*/
|
|
3710
4870
|
//# sourceMappingURL=internal.cjs.map
|