@ensnode/ensnode-sdk 1.15.1 → 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/LICENSE +1 -1
- package/README.md +21 -9
- package/dist/index.cjs +13 -6
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +18 -9
- package/dist/index.d.ts +18 -9
- package/dist/index.js +20 -9
- package/dist/index.js.map +1 -1
- package/dist/internal.cjs +1519 -123
- package/dist/internal.cjs.map +1 -1
- package/dist/internal.d.cts +11 -5
- package/dist/internal.d.ts +11 -5
- package/dist/internal.js +1508 -108
- package/dist/internal.js.map +1 -1
- package/dist/{namespace-specific-value-CPvcFpGI.d.cts → namespace-specific-value-BBZET9O0.d.cts} +7 -10
- package/dist/{namespace-specific-value-CPvcFpGI.d.ts → namespace-specific-value-BBZET9O0.d.ts} +7 -10
- package/package.json +6 -5
package/dist/internal.cjs
CHANGED
|
@@ -99,6 +99,7 @@ __export(internal_exports, {
|
|
|
99
99
|
makeENSIndexerPublicConfigSchema: () => makeENSIndexerPublicConfigSchema,
|
|
100
100
|
makeENSIndexerVersionInfoSchema: () => makeENSIndexerVersionInfoSchema,
|
|
101
101
|
makeENSNamespaceIdSchema: () => makeENSNamespaceIdSchema,
|
|
102
|
+
makeEmailSchema: () => makeEmailSchema,
|
|
102
103
|
makeEnsApiIndexingStatusResponseErrorSchema: () => makeEnsApiIndexingStatusResponseErrorSchema,
|
|
103
104
|
makeEnsApiIndexingStatusResponseOkSchema: () => makeEnsApiIndexingStatusResponseOkSchema,
|
|
104
105
|
makeEnsApiIndexingStatusResponseSchema: () => makeEnsApiIndexingStatusResponseSchema,
|
|
@@ -291,6 +292,7 @@ var makeDefaultableChainIdSchema = (valueLabel = "Defaultable Chain ID") => make
|
|
|
291
292
|
var makeDefaultableChainIdStringSchema = (valueLabel = "Defaultable Chain ID String") => import_v4.z.string({ error: `${valueLabel} must be a string representing a chain ID.` }).pipe(import_v4.z.coerce.number({ error: `${valueLabel} must represent a non-negative integer (>=0).` })).pipe(makeDefaultableChainIdSchema(`The numeric value represented by ${valueLabel}`));
|
|
292
293
|
var makeCoinTypeSchema = (valueLabel = "Coin Type") => import_v4.z.number({ error: `${valueLabel} must be a number.` }).int({ error: `${valueLabel} must be an integer.` }).nonnegative({ error: `${valueLabel} must be a non-negative integer (>=0).` }).transform((val) => val);
|
|
293
294
|
var makeCoinTypeStringSchema = (valueLabel = "Coin Type String") => import_v4.z.string({ error: `${valueLabel} must be a string representing a coin type.` }).pipe(import_v4.z.coerce.number({ error: `${valueLabel} must represent a non-negative integer (>=0).` })).pipe(makeCoinTypeSchema(`The numeric value represented by ${valueLabel}`));
|
|
295
|
+
var makeEmailSchema = (valueLabel = "Email") => import_v4.z.string({ error: `${valueLabel} must be a string.` }).trim().pipe(import_v4.z.email({ error: `${valueLabel} must be a valid email address.` })).transform((value) => value);
|
|
294
296
|
var makeNormalizedAddressSchema = (valueLabel = "EVM address") => import_v4.z.string().check((ctx) => {
|
|
295
297
|
if (!(0, import_viem2.isAddress)(ctx.value, { strict: false })) {
|
|
296
298
|
ctx.issues.push({
|
|
@@ -697,10 +699,10 @@ function getHighestKnownBlockTimestamp(chains) {
|
|
|
697
699
|
"Invariant violation: at least one chain is required to determine the highest known block timestamp"
|
|
698
700
|
);
|
|
699
701
|
}
|
|
700
|
-
const startBlockTimestamps = chains.map((
|
|
701
|
-
const endBlockTimestamps = chains.map((
|
|
702
|
-
const backfillEndBlockTimestamps = chains.filter((
|
|
703
|
-
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);
|
|
704
706
|
return Math.max(
|
|
705
707
|
...startBlockTimestamps,
|
|
706
708
|
...endBlockTimestamps,
|
|
@@ -740,26 +742,26 @@ var OmnichainIndexingStatusIds = {
|
|
|
740
742
|
Completed: "omnichain-completed"
|
|
741
743
|
};
|
|
742
744
|
function checkChainIndexingStatusSnapshotsForOmnichainStatusSnapshotUnstarted(chains) {
|
|
743
|
-
return chains.every((
|
|
745
|
+
return chains.every((chain2) => chain2.chainStatus === ChainIndexingStatusIds.Queued);
|
|
744
746
|
}
|
|
745
747
|
function checkChainIndexingStatusSnapshotsForOmnichainStatusSnapshotBackfill(chains) {
|
|
746
748
|
const atLeastOneChainInTargetStatus = chains.some(
|
|
747
|
-
(
|
|
749
|
+
(chain2) => chain2.chainStatus === ChainIndexingStatusIds.Backfill
|
|
748
750
|
);
|
|
749
751
|
const otherChainsHaveValidStatuses = chains.every(
|
|
750
|
-
(
|
|
752
|
+
(chain2) => chain2.chainStatus === ChainIndexingStatusIds.Queued || chain2.chainStatus === ChainIndexingStatusIds.Backfill || chain2.chainStatus === ChainIndexingStatusIds.Completed
|
|
751
753
|
);
|
|
752
754
|
return atLeastOneChainInTargetStatus && otherChainsHaveValidStatuses;
|
|
753
755
|
}
|
|
754
756
|
function checkChainIndexingStatusSnapshotsForOmnichainStatusSnapshotCompleted(chains) {
|
|
755
757
|
const allChainsHaveValidStatuses = chains.every(
|
|
756
|
-
(
|
|
758
|
+
(chain2) => chain2.chainStatus === ChainIndexingStatusIds.Completed
|
|
757
759
|
);
|
|
758
760
|
return allChainsHaveValidStatuses;
|
|
759
761
|
}
|
|
760
762
|
function checkChainIndexingStatusSnapshotsForOmnichainStatusSnapshotFollowing(chains) {
|
|
761
763
|
const allChainsHaveValidStatuses = chains.some(
|
|
762
|
-
(
|
|
764
|
+
(chain2) => chain2.chainStatus === ChainIndexingStatusIds.Following
|
|
763
765
|
);
|
|
764
766
|
return allChainsHaveValidStatuses;
|
|
765
767
|
}
|
|
@@ -921,12 +923,12 @@ function invariant_omnichainSnapshotStatusIsConsistentWithChainSnapshot(ctx) {
|
|
|
921
923
|
function invariant_omnichainIndexingCursorLowerThanEarliestStartBlockAcrossQueuedChains(ctx) {
|
|
922
924
|
const snapshot = ctx.value;
|
|
923
925
|
const queuedChains = Array.from(snapshot.chains.values()).filter(
|
|
924
|
-
(
|
|
926
|
+
(chain2) => chain2.chainStatus === ChainIndexingStatusIds.Queued
|
|
925
927
|
);
|
|
926
928
|
if (queuedChains.length === 0) {
|
|
927
929
|
return;
|
|
928
930
|
}
|
|
929
|
-
const queuedChainStartBlocks = queuedChains.map((
|
|
931
|
+
const queuedChainStartBlocks = queuedChains.map((chain2) => chain2.config.startBlock.timestamp);
|
|
930
932
|
const queuedChainEarliestStartBlock = Math.min(...queuedChainStartBlocks);
|
|
931
933
|
if (snapshot.omnichainIndexingCursor >= queuedChainEarliestStartBlock) {
|
|
932
934
|
ctx.issues.push({
|
|
@@ -939,12 +941,12 @@ function invariant_omnichainIndexingCursorLowerThanEarliestStartBlockAcrossQueue
|
|
|
939
941
|
function invariant_omnichainIndexingCursorLowerThanOrEqualToLatestBackfillEndBlockAcrossBackfillChains(ctx) {
|
|
940
942
|
const snapshot = ctx.value;
|
|
941
943
|
const backfillChains = Array.from(snapshot.chains.values()).filter(
|
|
942
|
-
(
|
|
944
|
+
(chain2) => chain2.chainStatus === ChainIndexingStatusIds.Backfill
|
|
943
945
|
);
|
|
944
946
|
if (backfillChains.length === 0) {
|
|
945
947
|
return;
|
|
946
948
|
}
|
|
947
|
-
const backfillEndBlocks = backfillChains.map((
|
|
949
|
+
const backfillEndBlocks = backfillChains.map((chain2) => chain2.backfillEndBlock.timestamp);
|
|
948
950
|
const highestBackfillEndBlock = Math.max(...backfillEndBlocks);
|
|
949
951
|
if (snapshot.omnichainIndexingCursor > highestBackfillEndBlock) {
|
|
950
952
|
ctx.issues.push({
|
|
@@ -957,13 +959,13 @@ function invariant_omnichainIndexingCursorLowerThanOrEqualToLatestBackfillEndBlo
|
|
|
957
959
|
function invariant_omnichainIndexingCursorIsEqualToHighestLatestIndexedBlockAcrossIndexedChain(ctx) {
|
|
958
960
|
const snapshot = ctx.value;
|
|
959
961
|
const indexedChains = Array.from(snapshot.chains.values()).filter(
|
|
960
|
-
(
|
|
962
|
+
(chain2) => chain2.chainStatus === ChainIndexingStatusIds.Backfill || chain2.chainStatus === ChainIndexingStatusIds.Completed || chain2.chainStatus === ChainIndexingStatusIds.Following
|
|
961
963
|
);
|
|
962
964
|
if (indexedChains.length === 0) {
|
|
963
965
|
return;
|
|
964
966
|
}
|
|
965
967
|
const indexedChainLatestIndexedBlocks = indexedChains.map(
|
|
966
|
-
(
|
|
968
|
+
(chain2) => chain2.latestIndexedBlock.timestamp
|
|
967
969
|
);
|
|
968
970
|
const indexedChainHighestLatestIndexedBlock = Math.max(...indexedChainLatestIndexedBlocks);
|
|
969
971
|
if (snapshot.omnichainIndexingCursor !== indexedChainHighestLatestIndexedBlock) {
|
|
@@ -1787,8 +1789,8 @@ function decodeEncodedReferrer(encodedReferrer) {
|
|
|
1787
1789
|
`Encoded referrer value must be represented by ${ENCODED_REFERRER_BYTE_LENGTH} bytes.`
|
|
1788
1790
|
);
|
|
1789
1791
|
}
|
|
1790
|
-
const
|
|
1791
|
-
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;
|
|
1792
1794
|
const decodedReferrer = (0, import_viem7.slice)(encodedReferrer, ENCODED_REFERRER_BYTE_OFFSET);
|
|
1793
1795
|
try {
|
|
1794
1796
|
return (0, import_enssdk6.toNormalizedAddress)(decodedReferrer);
|
|
@@ -2149,9 +2151,1095 @@ var errorResponseInternalServerErrorExample = {
|
|
|
2149
2151
|
};
|
|
2150
2152
|
|
|
2151
2153
|
// src/omnigraph-api/example-queries.ts
|
|
2152
|
-
var
|
|
2154
|
+
var import_enssdk9 = require("enssdk");
|
|
2153
2155
|
var import_datasources5 = require("@ensnode/datasources");
|
|
2154
|
-
|
|
2156
|
+
|
|
2157
|
+
// ../integration-test-env/src/devnet/fixtures.ts
|
|
2158
|
+
var import_address_encoder = require("@ensdomains/address-encoder");
|
|
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
|
|
3153
|
+
var import_enssdk8 = require("enssdk");
|
|
3154
|
+
var import_accounts = require("viem/accounts");
|
|
3155
|
+
var mnemonic = "test test test test test test test test test test test junk";
|
|
3156
|
+
function createAccount(addressIndex, resolver) {
|
|
3157
|
+
const account = (0, import_accounts.mnemonicToAccount)(mnemonic, { addressIndex });
|
|
3158
|
+
return {
|
|
3159
|
+
...account,
|
|
3160
|
+
address: (0, import_enssdk8.toNormalizedAddress)(account.address),
|
|
3161
|
+
resolver
|
|
3162
|
+
};
|
|
3163
|
+
}
|
|
3164
|
+
var accounts = {
|
|
3165
|
+
deployer: createAccount(0, (0, import_enssdk8.asNormalizedAddress)("0x9c97ec2d79944fa55aa2eb6385bc8711cacf18d2")),
|
|
3166
|
+
owner: createAccount(1, (0, import_enssdk8.asNormalizedAddress)("0x8550d35164e7f86bb6adf4cedb3f012913c9d563")),
|
|
3167
|
+
user: createAccount(2, (0, import_enssdk8.asNormalizedAddress)("0x98a84b915ffe27241033ac8f29c6b7849a0fb6e4")),
|
|
3168
|
+
user2: createAccount(3, (0, import_enssdk8.asNormalizedAddress)("0xd04f8f3726a417cfadeea604fc94cf66112b9af6"))
|
|
3169
|
+
};
|
|
3170
|
+
var addresses = {
|
|
3171
|
+
one: (0, import_enssdk8.asNormalizedAddress)(`0x${"1".repeat(40)}`)
|
|
3172
|
+
};
|
|
3173
|
+
var getRawAddress = (coinName, address) => {
|
|
3174
|
+
const coder = (0, import_address_encoder.getCoderByCoinName)(coinName);
|
|
3175
|
+
return {
|
|
3176
|
+
coinType: coder.coinType,
|
|
3177
|
+
raw: (0, import_utils2.bytesToHex)(coder.decode(address)),
|
|
3178
|
+
address
|
|
3179
|
+
};
|
|
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
|
+
};
|
|
3189
|
+
var testEthTextRecords = {
|
|
3190
|
+
avatar: { key: "avatar", value: "https://example.com/avatar.png" },
|
|
3191
|
+
twitter: { key: "com.twitter", value: "ensdomains" },
|
|
3192
|
+
github: { key: "com.github", value: "@ensdomains" },
|
|
3193
|
+
x: { key: "com.x", value: "this_is_real_ensdomains_not_twitter_but_x_haha" },
|
|
3194
|
+
telegram: { key: "org.telegram", value: "t.me/ensdomains" },
|
|
3195
|
+
url: { key: "url", value: "https://ens.domains" },
|
|
3196
|
+
email: { key: "email", value: "test@ens.domains" },
|
|
3197
|
+
description: { key: "description", value: "test.eth" },
|
|
3198
|
+
header: { key: "header", value: "https://example.com/header.png" }
|
|
3199
|
+
};
|
|
3200
|
+
var rawAddresses = {
|
|
3201
|
+
bitcoin: getRawAddress("btc", "bc1qw508d6qejxtdg4y5r3zarvary0c5xw7kv8f3t4"),
|
|
3202
|
+
litecoin: getRawAddress("ltc", "LaMT348PWRnrqeeWArpwQPbuanpXDZGEUz"),
|
|
3203
|
+
dogecoin: getRawAddress("doge", "DBXu2kgc3xtvCUWFcxFE3r9hEYgmuaaCyD"),
|
|
3204
|
+
monacoin: getRawAddress("mona", "MHxgS2XMXjeJ4if2PRRbWYcdwZPWfdwaDT"),
|
|
3205
|
+
rootstock: getRawAddress("rbtc", "0x5aaEB6053f3e94c9b9a09f33669435E7ef1bEAeD"),
|
|
3206
|
+
binance: getRawAddress("bnb", "bnb1grpf0955h0ykzq3ar5nmum7y6gdfl6lxfn46h2"),
|
|
3207
|
+
solana: getRawAddress("sol", "FncazAs6omJJjtLVzquzT9KoyXn6tFixr9kGjr42ktLj")
|
|
3208
|
+
};
|
|
3209
|
+
var fixtures = {
|
|
3210
|
+
abiBytes: `0x${"01".repeat(32)}`,
|
|
3211
|
+
fourBytesInterface: "0x11100111",
|
|
3212
|
+
publicKeyX: `0x${"02".repeat(32)}`,
|
|
3213
|
+
publicKeyY: `0x${"03".repeat(32)}`,
|
|
3214
|
+
rawAddresses,
|
|
3215
|
+
textRecords: testEthTextRecords
|
|
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
|
+
}));
|
|
3241
|
+
|
|
3242
|
+
// src/omnigraph-api/example-queries.ts
|
|
2155
3243
|
var SEPOLIA_V2_V2_ETH_REGISTRY = getDatasourceContract(
|
|
2156
3244
|
import_datasources5.ENSNamespaceIds.SepoliaV2,
|
|
2157
3245
|
import_datasources5.DatasourceNames.ENSv2Root,
|
|
@@ -2167,25 +3255,26 @@ var ENS_TEST_ENV_V2_ETH_REGISTRAR = getDatasourceContract(
|
|
|
2167
3255
|
import_datasources5.DatasourceNames.ENSv2Root,
|
|
2168
3256
|
"ETHRegistrar"
|
|
2169
3257
|
);
|
|
2170
|
-
var VITALIK_ADDRESS = (0,
|
|
2171
|
-
var
|
|
2172
|
-
|
|
3258
|
+
var VITALIK_ADDRESS = (0, import_enssdk9.toNormalizedAddress)("0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045");
|
|
3259
|
+
var SEPOLIA_V2_ACCOUNT = (0, import_enssdk9.toNormalizedAddress)("0x801d2e48d378f161dba7ad7ad002ad557714c191");
|
|
3260
|
+
var SEPOLIA_V2_ACCOUNT_WITH_V1_AND_V2 = (0, import_enssdk9.toNormalizedAddress)(
|
|
3261
|
+
"0xffffffffff52d316b7bd028358089bc8066b8f80"
|
|
2173
3262
|
);
|
|
2174
|
-
var
|
|
2175
|
-
|
|
2176
|
-
);
|
|
2177
|
-
var
|
|
2178
|
-
var
|
|
3263
|
+
var DEVNET_NAME_WITH_OWNED_RESOLVER = (0, import_enssdk9.asInterpretedName)("example.eth");
|
|
3264
|
+
var SEPOLIA_V2_NAME = (0, import_enssdk9.asInterpretedName)("roppp.eth");
|
|
3265
|
+
var VITALIK_NAME = (0, import_enssdk9.asInterpretedName)("vitalik.eth");
|
|
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");
|
|
2179
3269
|
var MAINNET_PUBLIC_RESOLVER = getDatasourceContract(
|
|
2180
3270
|
import_datasources5.ENSNamespaceIds.Mainnet,
|
|
2181
3271
|
import_datasources5.DatasourceNames.ReverseResolverRoot,
|
|
2182
3272
|
"DefaultPublicResolver5"
|
|
2183
3273
|
);
|
|
2184
|
-
var
|
|
2185
|
-
|
|
2186
|
-
|
|
2187
|
-
|
|
2188
|
-
);
|
|
3274
|
+
var SEPOLIA_V2_RESOLVER_WITH_RECORDS = {
|
|
3275
|
+
chainId: 11155111,
|
|
3276
|
+
address: (0, import_enssdk9.toNormalizedAddress)("0x8fade66b79cc9f707ab26799354482eb93a5b7dd")
|
|
3277
|
+
};
|
|
2189
3278
|
function getGraphqlApiExampleQueryById(id) {
|
|
2190
3279
|
const found = graphqlApiExampleQueryById.get(id);
|
|
2191
3280
|
if (!found) {
|
|
@@ -2199,18 +3288,44 @@ var GRAPHQL_API_EXAMPLE_QUERIES = [
|
|
|
2199
3288
|
////////////////
|
|
2200
3289
|
{
|
|
2201
3290
|
id: "hello-world",
|
|
2202
|
-
query:
|
|
2203
|
-
#
|
|
2204
|
-
|
|
2205
|
-
|
|
2206
|
-
#
|
|
2207
|
-
#
|
|
2208
|
-
|
|
2209
|
-
#
|
|
2210
|
-
|
|
2211
|
-
|
|
3291
|
+
query: `query HelloWorld($address: Address!) {
|
|
3292
|
+
# Lookup an Account by address.
|
|
3293
|
+
account(by: { address: $address }) {
|
|
3294
|
+
resolve {
|
|
3295
|
+
# Reverse resolve the ENS primary name of the account
|
|
3296
|
+
# using a convenient ETHEREUM alias for mainnet.
|
|
3297
|
+
primaryName(by: { chainName: ETHEREUM }) {
|
|
3298
|
+
# Get the regular interpreted variant of the primary name
|
|
3299
|
+
# and also the special beautified variant that optimizes names
|
|
3300
|
+
# containing special characters such as emojis for proper display in interfaces.
|
|
3301
|
+
name { interpreted beautified }
|
|
3302
|
+
resolve {
|
|
3303
|
+
# If the account has a primary name on Ethereum (mainnet),
|
|
3304
|
+
# forward resolve the interpreted ENS profile of that name in the same query!
|
|
3305
|
+
profile {
|
|
3306
|
+
description
|
|
3307
|
+
avatar { httpUrl }
|
|
3308
|
+
addresses { ethereum bitcoin }
|
|
3309
|
+
socials {
|
|
3310
|
+
twitter { handle httpUrl }
|
|
3311
|
+
github { handle httpUrl }
|
|
3312
|
+
}
|
|
3313
|
+
}
|
|
3314
|
+
}
|
|
3315
|
+
}
|
|
3316
|
+
}
|
|
3317
|
+
|
|
3318
|
+
# Also load the count of ENSv1 and ENSv2 domains owned by the account
|
|
3319
|
+
# to see if they have domains they should upgrade to ENSv2
|
|
3320
|
+
v1DomainsCount: domains(where: { version: ENSv1 }) { totalCount }
|
|
3321
|
+
v2DomainsCount: domains(where: { version: ENSv2 }) { totalCount }
|
|
3322
|
+
}
|
|
2212
3323
|
}`,
|
|
2213
|
-
variables: {
|
|
3324
|
+
variables: {
|
|
3325
|
+
default: { address: VITALIK_ADDRESS },
|
|
3326
|
+
[import_datasources5.ENSNamespaceIds.EnsTestEnv]: { address: accounts.owner.address },
|
|
3327
|
+
[import_datasources5.ENSNamespaceIds.SepoliaV2]: { address: SEPOLIA_V2_ACCOUNT_WITH_V1_AND_V2 }
|
|
3328
|
+
}
|
|
2214
3329
|
},
|
|
2215
3330
|
/////////////////
|
|
2216
3331
|
// Find Domains
|
|
@@ -2246,17 +3361,40 @@ query FindDomains(
|
|
|
2246
3361
|
order: { by: "NAME", dir: "DESC" }
|
|
2247
3362
|
},
|
|
2248
3363
|
[import_datasources5.ENSNamespaceIds.SepoliaV2]: {
|
|
2249
|
-
name: { starts_with: "
|
|
3364
|
+
name: { starts_with: "sf" },
|
|
2250
3365
|
order: { by: "NAME", dir: "DESC" }
|
|
2251
3366
|
}
|
|
2252
3367
|
}
|
|
2253
3368
|
},
|
|
2254
|
-
///////////////////
|
|
2255
|
-
// Domain By Name
|
|
2256
|
-
///////////////////
|
|
2257
3369
|
{
|
|
2258
3370
|
id: "domain-by-name",
|
|
2259
3371
|
query: `
|
|
3372
|
+
query DomainByName($name: InterpretedName!) {
|
|
3373
|
+
domain(by: { name: $name }) {
|
|
3374
|
+
canonical { name { beautified } }
|
|
3375
|
+
owner { address }
|
|
3376
|
+
resolve {
|
|
3377
|
+
profile {
|
|
3378
|
+
description
|
|
3379
|
+
addresses {
|
|
3380
|
+
ethereum
|
|
3381
|
+
}
|
|
3382
|
+
}
|
|
3383
|
+
}
|
|
3384
|
+
}
|
|
3385
|
+
}`,
|
|
3386
|
+
variables: {
|
|
3387
|
+
default: { name: "eth" },
|
|
3388
|
+
[import_datasources5.ENSNamespaceIds.SepoliaV2]: { name: SEPOLIA_V2_NAME },
|
|
3389
|
+
[import_datasources5.ENSNamespaceIds.Mainnet]: { name: VITALIK_NAME }
|
|
3390
|
+
}
|
|
3391
|
+
},
|
|
3392
|
+
////////////////////////////////
|
|
3393
|
+
// Domain By Name Type Condition
|
|
3394
|
+
////////////////////////////////
|
|
3395
|
+
{
|
|
3396
|
+
id: "domain-by-name-type-condition",
|
|
3397
|
+
query: `
|
|
2260
3398
|
query DomainByName($name: InterpretedName!) {
|
|
2261
3399
|
domain(by: {name: $name}) {
|
|
2262
3400
|
__typename
|
|
@@ -2273,7 +3411,7 @@ query DomainByName($name: InterpretedName!) {
|
|
|
2273
3411
|
}`,
|
|
2274
3412
|
variables: {
|
|
2275
3413
|
default: { name: "eth" },
|
|
2276
|
-
[import_datasources5.ENSNamespaceIds.SepoliaV2]: { name:
|
|
3414
|
+
[import_datasources5.ENSNamespaceIds.SepoliaV2]: { name: SEPOLIA_V2_NAME }
|
|
2277
3415
|
}
|
|
2278
3416
|
},
|
|
2279
3417
|
///////////////////////
|
|
@@ -2317,9 +3455,159 @@ query DomainRegistration($name: InterpretedName!) {
|
|
|
2317
3455
|
}
|
|
2318
3456
|
}`,
|
|
2319
3457
|
variables: {
|
|
2320
|
-
default: { name:
|
|
2321
|
-
[import_datasources5.ENSNamespaceIds.SepoliaV2]: { name:
|
|
3458
|
+
default: { name: VITALIK_NAME },
|
|
3459
|
+
[import_datasources5.ENSNamespaceIds.SepoliaV2]: { name: SEPOLIA_V2_NAME }
|
|
3460
|
+
}
|
|
3461
|
+
},
|
|
3462
|
+
////////////////////
|
|
3463
|
+
// Domain Records
|
|
3464
|
+
////////////////////
|
|
3465
|
+
{
|
|
3466
|
+
id: "domain-records",
|
|
3467
|
+
query: `
|
|
3468
|
+
query DomainRecords($name: InterpretedName!) {
|
|
3469
|
+
domain(by: {name: $name}) {
|
|
3470
|
+
canonical {
|
|
3471
|
+
name {
|
|
3472
|
+
interpreted
|
|
3473
|
+
}
|
|
3474
|
+
}
|
|
3475
|
+
resolve {
|
|
3476
|
+
records {
|
|
3477
|
+
addresses(coinTypes: [60, 2147483658, 501]) {
|
|
3478
|
+
coinType
|
|
3479
|
+
address
|
|
3480
|
+
}
|
|
3481
|
+
texts(keys: ["description", "avatar", "url", "com.github", "com.twitter"]) {
|
|
3482
|
+
key
|
|
3483
|
+
value
|
|
3484
|
+
}
|
|
3485
|
+
contenthash
|
|
3486
|
+
}
|
|
3487
|
+
}
|
|
3488
|
+
}
|
|
3489
|
+
}`,
|
|
3490
|
+
variables: {
|
|
3491
|
+
default: { name: GREG_NAME },
|
|
3492
|
+
[import_datasources5.ENSNamespaceIds.EnsTestEnv]: {
|
|
3493
|
+
name: DEVNET_NAME_WITH_OWNED_RESOLVER
|
|
3494
|
+
},
|
|
3495
|
+
[import_datasources5.ENSNamespaceIds.SepoliaV2]: {
|
|
3496
|
+
name: SEPOLIA_V2_NAME
|
|
3497
|
+
}
|
|
3498
|
+
}
|
|
3499
|
+
},
|
|
3500
|
+
{
|
|
3501
|
+
id: "domain-profile",
|
|
3502
|
+
query: `
|
|
3503
|
+
query DomainProfile($name: InterpretedName!) {
|
|
3504
|
+
domain(by: {name: $name}) {
|
|
3505
|
+
resolve {
|
|
3506
|
+
profile {
|
|
3507
|
+
description
|
|
3508
|
+
avatar {
|
|
3509
|
+
httpUrl
|
|
3510
|
+
}
|
|
3511
|
+
addresses {
|
|
3512
|
+
ethereum
|
|
3513
|
+
base
|
|
3514
|
+
solana
|
|
3515
|
+
bitcoin
|
|
3516
|
+
rootstock
|
|
3517
|
+
}
|
|
3518
|
+
socials {
|
|
3519
|
+
github {
|
|
3520
|
+
handle
|
|
3521
|
+
httpUrl
|
|
3522
|
+
}
|
|
3523
|
+
twitter {
|
|
3524
|
+
handle
|
|
3525
|
+
httpUrl
|
|
3526
|
+
}
|
|
3527
|
+
}
|
|
3528
|
+
website {
|
|
3529
|
+
httpUrl
|
|
3530
|
+
}
|
|
3531
|
+
header {
|
|
3532
|
+
httpUrl
|
|
3533
|
+
}
|
|
3534
|
+
}
|
|
2322
3535
|
}
|
|
3536
|
+
}
|
|
3537
|
+
}`,
|
|
3538
|
+
variables: { default: { name: GREG_NAME } }
|
|
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 } }
|
|
2323
3611
|
},
|
|
2324
3612
|
//////////////////////
|
|
2325
3613
|
// Domain Subdomains
|
|
@@ -2330,7 +3618,34 @@ query DomainRegistration($name: InterpretedName!) {
|
|
|
2330
3618
|
query DomainSubdomains($name: InterpretedName!) {
|
|
2331
3619
|
domain(by: {name: $name}) {
|
|
2332
3620
|
canonical { name { interpreted beautified } }
|
|
2333
|
-
subdomains(first: 10
|
|
3621
|
+
subdomains(first: 10, order: {
|
|
3622
|
+
by: NAME,
|
|
3623
|
+
dir: ASC
|
|
3624
|
+
}) {
|
|
3625
|
+
edges {
|
|
3626
|
+
node {
|
|
3627
|
+
canonical { name { interpreted beautified } }
|
|
3628
|
+
}
|
|
3629
|
+
}
|
|
3630
|
+
}
|
|
3631
|
+
}
|
|
3632
|
+
}`,
|
|
3633
|
+
variables: {
|
|
3634
|
+
default: { name: "eth" },
|
|
3635
|
+
// in mainnet there is too many subdomains of eth
|
|
3636
|
+
[import_datasources5.ENSNamespaceIds.Mainnet]: { name: "base.eth" }
|
|
3637
|
+
}
|
|
3638
|
+
},
|
|
3639
|
+
////////////////////////////////////
|
|
3640
|
+
// Most Recently Registered Subdomains
|
|
3641
|
+
////////////////////////////////////
|
|
3642
|
+
{
|
|
3643
|
+
id: "domain-subdomains-recently-registered",
|
|
3644
|
+
query: `
|
|
3645
|
+
query RecentlyRegisteredSubdomains($name: InterpretedName!) {
|
|
3646
|
+
domain(by: {name: $name}) {
|
|
3647
|
+
canonical { name { interpreted beautified } }
|
|
3648
|
+
subdomains(first: 10, order: {by: REGISTRATION_TIMESTAMP, dir: DESC}) {
|
|
2334
3649
|
edges {
|
|
2335
3650
|
node {
|
|
2336
3651
|
canonical { name { interpreted beautified } }
|
|
@@ -2391,7 +3706,7 @@ query DomainEvents($name: InterpretedName!) {
|
|
|
2391
3706
|
}`,
|
|
2392
3707
|
variables: {
|
|
2393
3708
|
default: { name: "newowner.eth" },
|
|
2394
|
-
[import_datasources5.ENSNamespaceIds.SepoliaV2]: { name:
|
|
3709
|
+
[import_datasources5.ENSNamespaceIds.SepoliaV2]: { name: SEPOLIA_V2_NAME }
|
|
2395
3710
|
}
|
|
2396
3711
|
},
|
|
2397
3712
|
////////////////////
|
|
@@ -2416,8 +3731,65 @@ query AccountDomains(
|
|
|
2416
3731
|
}`,
|
|
2417
3732
|
variables: {
|
|
2418
3733
|
default: { address: VITALIK_ADDRESS },
|
|
2419
|
-
[import_datasources5.ENSNamespaceIds.EnsTestEnv]: { address:
|
|
2420
|
-
[import_datasources5.ENSNamespaceIds.SepoliaV2]: { address:
|
|
3734
|
+
[import_datasources5.ENSNamespaceIds.EnsTestEnv]: { address: accounts.owner.address },
|
|
3735
|
+
[import_datasources5.ENSNamespaceIds.SepoliaV2]: { address: SEPOLIA_V2_ACCOUNT }
|
|
3736
|
+
}
|
|
3737
|
+
},
|
|
3738
|
+
/////////////////////////
|
|
3739
|
+
// Account Primary Names
|
|
3740
|
+
/////////////////////////
|
|
3741
|
+
{
|
|
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",
|
|
3768
|
+
query: `
|
|
3769
|
+
query AccountPrimaryNameRecords($address: Address!) {
|
|
3770
|
+
account(by: { address: $address }) {
|
|
3771
|
+
address
|
|
3772
|
+
resolve {
|
|
3773
|
+
primaryName(by: { chainName: ETHEREUM }) {
|
|
3774
|
+
name { interpreted beautified }
|
|
3775
|
+
resolve {
|
|
3776
|
+
profile {
|
|
3777
|
+
description
|
|
3778
|
+
socials {
|
|
3779
|
+
twitter {
|
|
3780
|
+
httpUrl
|
|
3781
|
+
}
|
|
3782
|
+
}
|
|
3783
|
+
}
|
|
3784
|
+
}
|
|
3785
|
+
}
|
|
3786
|
+
}
|
|
3787
|
+
}
|
|
3788
|
+
}`,
|
|
3789
|
+
variables: {
|
|
3790
|
+
default: { address: VITALIK_ADDRESS },
|
|
3791
|
+
[import_datasources5.ENSNamespaceIds.EnsTestEnv]: { address: accounts.owner.address },
|
|
3792
|
+
[import_datasources5.ENSNamespaceIds.SepoliaV2]: { address: SEPOLIA_V2_ACCOUNT }
|
|
2421
3793
|
}
|
|
2422
3794
|
},
|
|
2423
3795
|
////////////////////
|
|
@@ -2435,8 +3807,8 @@ query AccountEvents(
|
|
|
2435
3807
|
}`,
|
|
2436
3808
|
variables: {
|
|
2437
3809
|
default: { address: VITALIK_ADDRESS },
|
|
2438
|
-
[import_datasources5.ENSNamespaceIds.EnsTestEnv]: { address:
|
|
2439
|
-
[import_datasources5.ENSNamespaceIds.SepoliaV2]: { address:
|
|
3810
|
+
[import_datasources5.ENSNamespaceIds.EnsTestEnv]: { address: accounts.deployer.address },
|
|
3811
|
+
[import_datasources5.ENSNamespaceIds.SepoliaV2]: { address: SEPOLIA_V2_ACCOUNT }
|
|
2440
3812
|
}
|
|
2441
3813
|
},
|
|
2442
3814
|
/////////////////////
|
|
@@ -2520,8 +3892,8 @@ query PermissionsByUser($address: Address!) {
|
|
|
2520
3892
|
}
|
|
2521
3893
|
}`,
|
|
2522
3894
|
variables: {
|
|
2523
|
-
default: { address:
|
|
2524
|
-
[import_datasources5.ENSNamespaceIds.SepoliaV2]: { address:
|
|
3895
|
+
default: { address: accounts.deployer.address },
|
|
3896
|
+
[import_datasources5.ENSNamespaceIds.SepoliaV2]: { address: SEPOLIA_V2_ACCOUNT }
|
|
2525
3897
|
}
|
|
2526
3898
|
},
|
|
2527
3899
|
//////////////////////////////////
|
|
@@ -2546,8 +3918,8 @@ query AccountResolverPermissions($address: Address!) {
|
|
|
2546
3918
|
}
|
|
2547
3919
|
}`,
|
|
2548
3920
|
variables: {
|
|
2549
|
-
default: { address:
|
|
2550
|
-
[import_datasources5.ENSNamespaceIds.SepoliaV2]: { address:
|
|
3921
|
+
default: { address: accounts.deployer.address },
|
|
3922
|
+
[import_datasources5.ENSNamespaceIds.SepoliaV2]: { address: SEPOLIA_V2_ACCOUNT }
|
|
2551
3923
|
}
|
|
2552
3924
|
},
|
|
2553
3925
|
//////////////////////////////
|
|
@@ -2560,17 +3932,20 @@ query DomainResolver($name: InterpretedName!) {
|
|
|
2560
3932
|
domain(by: { name: $name }) {
|
|
2561
3933
|
resolver {
|
|
2562
3934
|
assigned {
|
|
2563
|
-
|
|
2564
|
-
|
|
2565
|
-
|
|
3935
|
+
contract {
|
|
3936
|
+
address
|
|
3937
|
+
}
|
|
3938
|
+
events(first: 5) {
|
|
3939
|
+
edges { node { topics data timestamp } }
|
|
3940
|
+
}
|
|
2566
3941
|
}
|
|
2567
3942
|
}
|
|
2568
3943
|
}
|
|
2569
3944
|
}`,
|
|
2570
3945
|
variables: {
|
|
2571
|
-
default: { name:
|
|
3946
|
+
default: { name: VITALIK_NAME },
|
|
2572
3947
|
[import_datasources5.ENSNamespaceIds.EnsTestEnv]: { name: DEVNET_NAME_WITH_OWNED_RESOLVER },
|
|
2573
|
-
[import_datasources5.ENSNamespaceIds.SepoliaV2]: { name:
|
|
3948
|
+
[import_datasources5.ENSNamespaceIds.SepoliaV2]: { name: SEPOLIA_V2_NAME }
|
|
2574
3949
|
}
|
|
2575
3950
|
},
|
|
2576
3951
|
////////////////////////
|
|
@@ -2602,7 +3977,7 @@ query ResolverByAddress($contract: AccountIdInput!) {
|
|
|
2602
3977
|
}`,
|
|
2603
3978
|
variables: {
|
|
2604
3979
|
default: { contract: MAINNET_PUBLIC_RESOLVER },
|
|
2605
|
-
[import_datasources5.ENSNamespaceIds.SepoliaV2]: { contract:
|
|
3980
|
+
[import_datasources5.ENSNamespaceIds.SepoliaV2]: { contract: SEPOLIA_V2_RESOLVER_WITH_RECORDS }
|
|
2606
3981
|
}
|
|
2607
3982
|
},
|
|
2608
3983
|
//////////////
|
|
@@ -2612,31 +3987,19 @@ query ResolverByAddress($contract: AccountIdInput!) {
|
|
|
2612
3987
|
id: "namegraph",
|
|
2613
3988
|
query: `
|
|
2614
3989
|
query Namegraph {
|
|
2615
|
-
|
|
2616
|
-
id
|
|
2617
|
-
|
|
2618
|
-
|
|
2619
|
-
|
|
2620
|
-
|
|
2621
|
-
|
|
2622
|
-
|
|
2623
|
-
edges {
|
|
2624
|
-
node {
|
|
2625
|
-
canonical { name { interpreted beautified } }
|
|
2626
|
-
|
|
2627
|
-
subdomains {
|
|
2628
|
-
edges {
|
|
2629
|
-
node {
|
|
2630
|
-
canonical { name { interpreted beautified } }
|
|
2631
|
-
}
|
|
2632
|
-
}
|
|
2633
|
-
}
|
|
2634
|
-
}
|
|
2635
|
-
}
|
|
3990
|
+
domain(by: { name: "eth" }) {
|
|
3991
|
+
registry { id contract { chainId address } }
|
|
3992
|
+
parent { id }
|
|
3993
|
+
subregistry {
|
|
3994
|
+
domains {
|
|
3995
|
+
edges {
|
|
3996
|
+
node {
|
|
3997
|
+
canonical { name { beautified } }
|
|
2636
3998
|
}
|
|
2637
3999
|
}
|
|
2638
4000
|
}
|
|
2639
4001
|
}
|
|
4002
|
+
subdomains { edges { node { canonical { name { beautified } } } } }
|
|
2640
4003
|
}
|
|
2641
4004
|
}`,
|
|
2642
4005
|
variables: { default: {} }
|
|
@@ -2655,7 +4018,7 @@ query AccountMigratedNames($address: Address!) {
|
|
|
2655
4018
|
}`,
|
|
2656
4019
|
variables: {
|
|
2657
4020
|
default: { address: VITALIK_ADDRESS },
|
|
2658
|
-
[import_datasources5.ENSNamespaceIds.SepoliaV2]: { address:
|
|
4021
|
+
[import_datasources5.ENSNamespaceIds.SepoliaV2]: { address: SEPOLIA_V2_ACCOUNT_WITH_V1_AND_V2 }
|
|
2659
4022
|
}
|
|
2660
4023
|
},
|
|
2661
4024
|
{
|
|
@@ -2672,6 +4035,31 @@ query GetEthDomains {
|
|
|
2672
4035
|
}
|
|
2673
4036
|
}`,
|
|
2674
4037
|
variables: { default: {} }
|
|
4038
|
+
},
|
|
4039
|
+
{
|
|
4040
|
+
id: "accelerate-resolve",
|
|
4041
|
+
query: `
|
|
4042
|
+
query AccelerateResolve($address: Address!) {
|
|
4043
|
+
account(by: { address: $address }) {
|
|
4044
|
+
address
|
|
4045
|
+
# resolve is automatically accelerated. To disable, resolve(accelerate: false)
|
|
4046
|
+
resolve {
|
|
4047
|
+
acceleration { requested attempted }
|
|
4048
|
+
primaryName(by: { chainName: ETHEREUM }) {
|
|
4049
|
+
name { interpreted beautified }
|
|
4050
|
+
resolve {
|
|
4051
|
+
acceleration { requested attempted }
|
|
4052
|
+
profile { description }
|
|
4053
|
+
}
|
|
4054
|
+
}
|
|
4055
|
+
}
|
|
4056
|
+
}
|
|
4057
|
+
}`,
|
|
4058
|
+
variables: {
|
|
4059
|
+
default: { address: VITALIK_ADDRESS },
|
|
4060
|
+
[import_datasources5.ENSNamespaceIds.EnsTestEnv]: { address: accounts.owner.address },
|
|
4061
|
+
[import_datasources5.ENSNamespaceIds.SepoliaV2]: { address: SEPOLIA_V2_ACCOUNT_WITH_V1_AND_V2 }
|
|
4062
|
+
}
|
|
2675
4063
|
}
|
|
2676
4064
|
];
|
|
2677
4065
|
var graphqlApiExampleQueryById = new Map(
|
|
@@ -2710,7 +4098,8 @@ async function supportsInterface({
|
|
|
2710
4098
|
abi: EIP_165_ABI,
|
|
2711
4099
|
functionName: "supportsInterface",
|
|
2712
4100
|
address,
|
|
2713
|
-
args: [selector]
|
|
4101
|
+
args: [selector],
|
|
4102
|
+
retryEmptyResponse: false
|
|
2714
4103
|
});
|
|
2715
4104
|
} catch {
|
|
2716
4105
|
return false;
|
|
@@ -2903,29 +4292,29 @@ function buildRpcConfigsFromEnv(env, namespace) {
|
|
|
2903
4292
|
);
|
|
2904
4293
|
const rpcAutoGenMode = buildRpcAutoGenMode(env);
|
|
2905
4294
|
const rpcConfigs = {};
|
|
2906
|
-
for (const
|
|
2907
|
-
const specificValue = env[`RPC_URL_${
|
|
4295
|
+
for (const chain2 of chainsInNamespace) {
|
|
4296
|
+
const specificValue = env[`RPC_URL_${chain2.id}`];
|
|
2908
4297
|
if (specificValue) {
|
|
2909
|
-
rpcConfigs[serializeChainId(
|
|
4298
|
+
rpcConfigs[serializeChainId(chain2.id)] = specificValue;
|
|
2910
4299
|
continue;
|
|
2911
4300
|
}
|
|
2912
|
-
if (
|
|
4301
|
+
if (chain2.id === import_datasources6.ensTestEnvChain.id) {
|
|
2913
4302
|
rpcConfigs[serializeChainId(import_datasources6.ensTestEnvChain.id)] = import_datasources6.ensTestEnvChain.rpcUrls.default.http[0];
|
|
2914
4303
|
continue;
|
|
2915
4304
|
}
|
|
2916
4305
|
const httpUrls = [
|
|
2917
4306
|
// alchemy, if specified and available
|
|
2918
|
-
alchemyApiKey && alchemySupportsChain(
|
|
4307
|
+
alchemyApiKey && alchemySupportsChain(chain2.id) && `https://${buildAlchemyBaseUrl(chain2.id, alchemyApiKey)}`,
|
|
2919
4308
|
// QuickNode, if specified and available
|
|
2920
|
-
quickNodeApiKey && quickNodeEndpointName && quickNodeSupportsChain(
|
|
4309
|
+
quickNodeApiKey && quickNodeEndpointName && quickNodeSupportsChain(chain2.id) && `https://${buildQuickNodeURL(chain2.id, quickNodeApiKey, quickNodeEndpointName)}`,
|
|
2921
4310
|
// dRPC, if specified and available
|
|
2922
|
-
dRPCKey && dRPCSupportsChain(
|
|
4311
|
+
dRPCKey && dRPCSupportsChain(chain2.id) && buildDRPCUrl(chain2.id, dRPCKey)
|
|
2923
4312
|
];
|
|
2924
|
-
const wsUrl = rpcAutoGenMode === RpcAutoGenModes.HttpAndWs && alchemyApiKey && alchemySupportsChain(
|
|
2925
|
-
`wss://${buildAlchemyBaseUrl(
|
|
4313
|
+
const wsUrl = rpcAutoGenMode === RpcAutoGenModes.HttpAndWs && alchemyApiKey && alchemySupportsChain(chain2.id) && //
|
|
4314
|
+
`wss://${buildAlchemyBaseUrl(chain2.id, alchemyApiKey)}`;
|
|
2926
4315
|
const urls = [...httpUrls, wsUrl].filter(Boolean);
|
|
2927
4316
|
if (urls.length > 0) {
|
|
2928
|
-
rpcConfigs[serializeChainId(
|
|
4317
|
+
rpcConfigs[serializeChainId(chain2.id)] = urls.join(
|
|
2929
4318
|
","
|
|
2930
4319
|
);
|
|
2931
4320
|
}
|
|
@@ -3097,7 +4486,7 @@ var import_viem8 = require("viem");
|
|
|
3097
4486
|
var interpretAddress = (owner) => (0, import_viem8.isAddressEqual)(import_viem8.zeroAddress, owner) ? null : owner;
|
|
3098
4487
|
|
|
3099
4488
|
// src/shared/interpretation/interpret-record-values.ts
|
|
3100
|
-
var
|
|
4489
|
+
var import_enssdk10 = require("enssdk");
|
|
3101
4490
|
var import_viem9 = require("viem");
|
|
3102
4491
|
|
|
3103
4492
|
// src/shared/null-bytes.ts
|
|
@@ -3106,16 +4495,15 @@ var hasNullByte = (value) => value.indexOf("\0") !== -1;
|
|
|
3106
4495
|
// src/shared/interpretation/interpret-record-values.ts
|
|
3107
4496
|
function interpretNameRecordValue(value) {
|
|
3108
4497
|
if (value === "") return null;
|
|
3109
|
-
if (!(0,
|
|
4498
|
+
if (!(0, import_enssdk10.isInterpretedName)(value)) return null;
|
|
3110
4499
|
return value;
|
|
3111
4500
|
}
|
|
3112
4501
|
function interpretAddressRecordValue(value) {
|
|
3113
|
-
if (hasNullByte(value)) return null;
|
|
3114
|
-
if (value === "") return null;
|
|
3115
4502
|
if (value === "0x") return null;
|
|
3116
|
-
if (!(0, import_viem9.
|
|
3117
|
-
|
|
3118
|
-
|
|
4503
|
+
if (!(0, import_viem9.isHex)(value, { strict: true })) return null;
|
|
4504
|
+
const normalized = value.toLowerCase();
|
|
4505
|
+
if (normalized === import_viem9.zeroAddress) return null;
|
|
4506
|
+
return normalized;
|
|
3119
4507
|
}
|
|
3120
4508
|
function interpretTextRecordKey(key) {
|
|
3121
4509
|
if (hasNullByte(key)) return null;
|
|
@@ -3158,11 +4546,11 @@ function getLogLevelFromEnv(env, defaultLogLevel) {
|
|
|
3158
4546
|
}
|
|
3159
4547
|
|
|
3160
4548
|
// src/shared/protocol-acceleration/is-bridged-resolver.ts
|
|
3161
|
-
var
|
|
4549
|
+
var import_enssdk13 = require("enssdk");
|
|
3162
4550
|
var import_datasources14 = require("@ensnode/datasources");
|
|
3163
4551
|
|
|
3164
4552
|
// src/shared/managed-names.ts
|
|
3165
|
-
var
|
|
4553
|
+
var import_enssdk11 = require("enssdk");
|
|
3166
4554
|
var import_datasources12 = require("@ensnode/datasources");
|
|
3167
4555
|
|
|
3168
4556
|
// src/shared/to-json.ts
|
|
@@ -3211,7 +4599,7 @@ var getContractsByManagedName = (namespace) => {
|
|
|
3211
4599
|
"NameWrapper"
|
|
3212
4600
|
);
|
|
3213
4601
|
return {
|
|
3214
|
-
[
|
|
4602
|
+
[import_enssdk11.ENS_ROOT_NAME]: {
|
|
3215
4603
|
registry: ensRootRegistry,
|
|
3216
4604
|
contracts: [ensRootRegistry, ensRootRegistryOld]
|
|
3217
4605
|
},
|
|
@@ -3275,10 +4663,10 @@ var getContractsByManagedName = (namespace) => {
|
|
|
3275
4663
|
}
|
|
3276
4664
|
};
|
|
3277
4665
|
};
|
|
3278
|
-
var
|
|
4666
|
+
var cache2 = /* @__PURE__ */ new Map();
|
|
3279
4667
|
var getManagedName = (namespace, contract) => {
|
|
3280
|
-
const cacheKey = `${namespace}:${(0,
|
|
3281
|
-
const cached =
|
|
4668
|
+
const cacheKey = `${namespace}:${(0, import_enssdk11.stringifyAccountId)(contract)}`;
|
|
4669
|
+
const cached = cache2.get(cacheKey);
|
|
3282
4670
|
if (cached !== void 0) return cached;
|
|
3283
4671
|
for (const [managedName, group] of Object.entries(getContractsByManagedName(namespace))) {
|
|
3284
4672
|
const isAnyOfTheContracts = group.contracts.some(
|
|
@@ -3286,10 +4674,10 @@ var getManagedName = (namespace, contract) => {
|
|
|
3286
4674
|
);
|
|
3287
4675
|
if (isAnyOfTheContracts) {
|
|
3288
4676
|
const namespaceSpecific = MANAGED_NAME_BY_NAMESPACE[namespace]?.[managedName];
|
|
3289
|
-
const name = (0,
|
|
3290
|
-
const node = (0,
|
|
4677
|
+
const name = (0, import_enssdk11.asInterpretedName)(namespaceSpecific ?? managedName);
|
|
4678
|
+
const node = (0, import_enssdk11.namehashInterpretedName)(name);
|
|
3291
4679
|
const result = { name, node, registry: group.registry };
|
|
3292
|
-
|
|
4680
|
+
cache2.set(cacheKey, result);
|
|
3293
4681
|
return result;
|
|
3294
4682
|
}
|
|
3295
4683
|
}
|
|
@@ -3299,14 +4687,14 @@ var getManagedName = (namespace, contract) => {
|
|
|
3299
4687
|
};
|
|
3300
4688
|
|
|
3301
4689
|
// src/shared/root-registry.ts
|
|
3302
|
-
var
|
|
4690
|
+
var import_enssdk12 = require("enssdk");
|
|
3303
4691
|
var import_datasources13 = require("@ensnode/datasources");
|
|
3304
4692
|
var getENSv1RootRegistry = (namespace) => getDatasourceContract(namespace, import_datasources13.DatasourceNames.ENSRoot, "ENSv1Registry");
|
|
3305
4693
|
|
|
3306
4694
|
// src/shared/protocol-acceleration/is-bridged-resolver.ts
|
|
3307
|
-
var
|
|
4695
|
+
var cache3 = /* @__PURE__ */ new Map();
|
|
3308
4696
|
var getBridgedResolverConfigs = (namespace) => {
|
|
3309
|
-
const cached =
|
|
4697
|
+
const cached = cache3.get(namespace);
|
|
3310
4698
|
if (cached) return cached;
|
|
3311
4699
|
const configs = [];
|
|
3312
4700
|
const basenames = (0, import_datasources14.maybeGetDatasource)(namespace, import_datasources14.DatasourceNames.Basenames);
|
|
@@ -3320,9 +4708,9 @@ var getBridgedResolverConfigs = (namespace) => {
|
|
|
3320
4708
|
const { node } = getManagedName(namespace, registry);
|
|
3321
4709
|
configs.push({
|
|
3322
4710
|
resolver,
|
|
3323
|
-
originDomainId: (0,
|
|
4711
|
+
originDomainId: (0, import_enssdk13.makeENSv1DomainId)(getENSv1RootRegistry(namespace), node),
|
|
3324
4712
|
targetRegistry: registry,
|
|
3325
|
-
targetRegistryId: (0,
|
|
4713
|
+
targetRegistryId: (0, import_enssdk13.makeENSv1VirtualRegistryId)(registry, node)
|
|
3326
4714
|
});
|
|
3327
4715
|
}
|
|
3328
4716
|
const lineanames = (0, import_datasources14.maybeGetDatasource)(namespace, import_datasources14.DatasourceNames.Lineanames);
|
|
@@ -3336,12 +4724,12 @@ var getBridgedResolverConfigs = (namespace) => {
|
|
|
3336
4724
|
const { node } = getManagedName(namespace, registry);
|
|
3337
4725
|
configs.push({
|
|
3338
4726
|
resolver,
|
|
3339
|
-
originDomainId: (0,
|
|
4727
|
+
originDomainId: (0, import_enssdk13.makeENSv1DomainId)(getENSv1RootRegistry(namespace), node),
|
|
3340
4728
|
targetRegistry: registry,
|
|
3341
|
-
targetRegistryId: (0,
|
|
4729
|
+
targetRegistryId: (0, import_enssdk13.makeENSv1VirtualRegistryId)(registry, node)
|
|
3342
4730
|
});
|
|
3343
4731
|
}
|
|
3344
|
-
|
|
4732
|
+
cache3.set(namespace, configs);
|
|
3345
4733
|
return configs;
|
|
3346
4734
|
};
|
|
3347
4735
|
function isBridgedResolver(namespace, resolver) {
|
|
@@ -3433,4 +4821,12 @@ var makeTheGraphSubgraphUrl = (namespace, apiKey) => {
|
|
|
3433
4821
|
throw new Error("never");
|
|
3434
4822
|
}
|
|
3435
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
|
+
*/
|
|
3436
4832
|
//# sourceMappingURL=internal.cjs.map
|