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