@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.js
CHANGED
|
@@ -102,6 +102,7 @@ var makeDefaultableChainIdSchema = (valueLabel = "Defaultable Chain ID") => make
|
|
|
102
102
|
var makeDefaultableChainIdStringSchema = (valueLabel = "Defaultable Chain ID String") => z.string({ error: `${valueLabel} must be a string representing a chain ID.` }).pipe(z.coerce.number({ error: `${valueLabel} must represent a non-negative integer (>=0).` })).pipe(makeDefaultableChainIdSchema(`The numeric value represented by ${valueLabel}`));
|
|
103
103
|
var makeCoinTypeSchema = (valueLabel = "Coin Type") => 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);
|
|
104
104
|
var makeCoinTypeStringSchema = (valueLabel = "Coin Type String") => z.string({ error: `${valueLabel} must be a string representing a coin type.` }).pipe(z.coerce.number({ error: `${valueLabel} must represent a non-negative integer (>=0).` })).pipe(makeCoinTypeSchema(`The numeric value represented by ${valueLabel}`));
|
|
105
|
+
var makeEmailSchema = (valueLabel = "Email") => z.string({ error: `${valueLabel} must be a string.` }).trim().pipe(z.email({ error: `${valueLabel} must be a valid email address.` })).transform((value) => value);
|
|
105
106
|
var makeNormalizedAddressSchema = (valueLabel = "EVM address") => z.string().check((ctx) => {
|
|
106
107
|
if (!isAddress(ctx.value, { strict: false })) {
|
|
107
108
|
ctx.issues.push({
|
|
@@ -508,10 +509,10 @@ function getHighestKnownBlockTimestamp(chains) {
|
|
|
508
509
|
"Invariant violation: at least one chain is required to determine the highest known block timestamp"
|
|
509
510
|
);
|
|
510
511
|
}
|
|
511
|
-
const startBlockTimestamps = chains.map((
|
|
512
|
-
const endBlockTimestamps = chains.map((
|
|
513
|
-
const backfillEndBlockTimestamps = chains.filter((
|
|
514
|
-
const latestKnownBlockTimestamps = chains.filter((
|
|
512
|
+
const startBlockTimestamps = chains.map((chain2) => chain2.config.startBlock.timestamp);
|
|
513
|
+
const endBlockTimestamps = chains.map((chain2) => chain2.config).filter((chainConfig) => chainConfig.rangeType === RangeTypeIds.Bounded).map((chainConfig) => chainConfig.endBlock.timestamp);
|
|
514
|
+
const backfillEndBlockTimestamps = chains.filter((chain2) => chain2.chainStatus === ChainIndexingStatusIds.Backfill).map((chain2) => chain2.backfillEndBlock.timestamp);
|
|
515
|
+
const latestKnownBlockTimestamps = chains.filter((chain2) => chain2.chainStatus === ChainIndexingStatusIds.Following).map((chain2) => chain2.latestKnownBlock.timestamp);
|
|
515
516
|
return Math.max(
|
|
516
517
|
...startBlockTimestamps,
|
|
517
518
|
...endBlockTimestamps,
|
|
@@ -551,26 +552,26 @@ var OmnichainIndexingStatusIds = {
|
|
|
551
552
|
Completed: "omnichain-completed"
|
|
552
553
|
};
|
|
553
554
|
function checkChainIndexingStatusSnapshotsForOmnichainStatusSnapshotUnstarted(chains) {
|
|
554
|
-
return chains.every((
|
|
555
|
+
return chains.every((chain2) => chain2.chainStatus === ChainIndexingStatusIds.Queued);
|
|
555
556
|
}
|
|
556
557
|
function checkChainIndexingStatusSnapshotsForOmnichainStatusSnapshotBackfill(chains) {
|
|
557
558
|
const atLeastOneChainInTargetStatus = chains.some(
|
|
558
|
-
(
|
|
559
|
+
(chain2) => chain2.chainStatus === ChainIndexingStatusIds.Backfill
|
|
559
560
|
);
|
|
560
561
|
const otherChainsHaveValidStatuses = chains.every(
|
|
561
|
-
(
|
|
562
|
+
(chain2) => chain2.chainStatus === ChainIndexingStatusIds.Queued || chain2.chainStatus === ChainIndexingStatusIds.Backfill || chain2.chainStatus === ChainIndexingStatusIds.Completed
|
|
562
563
|
);
|
|
563
564
|
return atLeastOneChainInTargetStatus && otherChainsHaveValidStatuses;
|
|
564
565
|
}
|
|
565
566
|
function checkChainIndexingStatusSnapshotsForOmnichainStatusSnapshotCompleted(chains) {
|
|
566
567
|
const allChainsHaveValidStatuses = chains.every(
|
|
567
|
-
(
|
|
568
|
+
(chain2) => chain2.chainStatus === ChainIndexingStatusIds.Completed
|
|
568
569
|
);
|
|
569
570
|
return allChainsHaveValidStatuses;
|
|
570
571
|
}
|
|
571
572
|
function checkChainIndexingStatusSnapshotsForOmnichainStatusSnapshotFollowing(chains) {
|
|
572
573
|
const allChainsHaveValidStatuses = chains.some(
|
|
573
|
-
(
|
|
574
|
+
(chain2) => chain2.chainStatus === ChainIndexingStatusIds.Following
|
|
574
575
|
);
|
|
575
576
|
return allChainsHaveValidStatuses;
|
|
576
577
|
}
|
|
@@ -732,12 +733,12 @@ function invariant_omnichainSnapshotStatusIsConsistentWithChainSnapshot(ctx) {
|
|
|
732
733
|
function invariant_omnichainIndexingCursorLowerThanEarliestStartBlockAcrossQueuedChains(ctx) {
|
|
733
734
|
const snapshot = ctx.value;
|
|
734
735
|
const queuedChains = Array.from(snapshot.chains.values()).filter(
|
|
735
|
-
(
|
|
736
|
+
(chain2) => chain2.chainStatus === ChainIndexingStatusIds.Queued
|
|
736
737
|
);
|
|
737
738
|
if (queuedChains.length === 0) {
|
|
738
739
|
return;
|
|
739
740
|
}
|
|
740
|
-
const queuedChainStartBlocks = queuedChains.map((
|
|
741
|
+
const queuedChainStartBlocks = queuedChains.map((chain2) => chain2.config.startBlock.timestamp);
|
|
741
742
|
const queuedChainEarliestStartBlock = Math.min(...queuedChainStartBlocks);
|
|
742
743
|
if (snapshot.omnichainIndexingCursor >= queuedChainEarliestStartBlock) {
|
|
743
744
|
ctx.issues.push({
|
|
@@ -750,12 +751,12 @@ function invariant_omnichainIndexingCursorLowerThanEarliestStartBlockAcrossQueue
|
|
|
750
751
|
function invariant_omnichainIndexingCursorLowerThanOrEqualToLatestBackfillEndBlockAcrossBackfillChains(ctx) {
|
|
751
752
|
const snapshot = ctx.value;
|
|
752
753
|
const backfillChains = Array.from(snapshot.chains.values()).filter(
|
|
753
|
-
(
|
|
754
|
+
(chain2) => chain2.chainStatus === ChainIndexingStatusIds.Backfill
|
|
754
755
|
);
|
|
755
756
|
if (backfillChains.length === 0) {
|
|
756
757
|
return;
|
|
757
758
|
}
|
|
758
|
-
const backfillEndBlocks = backfillChains.map((
|
|
759
|
+
const backfillEndBlocks = backfillChains.map((chain2) => chain2.backfillEndBlock.timestamp);
|
|
759
760
|
const highestBackfillEndBlock = Math.max(...backfillEndBlocks);
|
|
760
761
|
if (snapshot.omnichainIndexingCursor > highestBackfillEndBlock) {
|
|
761
762
|
ctx.issues.push({
|
|
@@ -768,13 +769,13 @@ function invariant_omnichainIndexingCursorLowerThanOrEqualToLatestBackfillEndBlo
|
|
|
768
769
|
function invariant_omnichainIndexingCursorIsEqualToHighestLatestIndexedBlockAcrossIndexedChain(ctx) {
|
|
769
770
|
const snapshot = ctx.value;
|
|
770
771
|
const indexedChains = Array.from(snapshot.chains.values()).filter(
|
|
771
|
-
(
|
|
772
|
+
(chain2) => chain2.chainStatus === ChainIndexingStatusIds.Backfill || chain2.chainStatus === ChainIndexingStatusIds.Completed || chain2.chainStatus === ChainIndexingStatusIds.Following
|
|
772
773
|
);
|
|
773
774
|
if (indexedChains.length === 0) {
|
|
774
775
|
return;
|
|
775
776
|
}
|
|
776
777
|
const indexedChainLatestIndexedBlocks = indexedChains.map(
|
|
777
|
-
(
|
|
778
|
+
(chain2) => chain2.latestIndexedBlock.timestamp
|
|
778
779
|
);
|
|
779
780
|
const indexedChainHighestLatestIndexedBlock = Math.max(...indexedChainLatestIndexedBlocks);
|
|
780
781
|
if (snapshot.omnichainIndexingCursor !== indexedChainHighestLatestIndexedBlock) {
|
|
@@ -1602,8 +1603,8 @@ function decodeEncodedReferrer(encodedReferrer) {
|
|
|
1602
1603
|
`Encoded referrer value must be represented by ${ENCODED_REFERRER_BYTE_LENGTH} bytes.`
|
|
1603
1604
|
);
|
|
1604
1605
|
}
|
|
1605
|
-
const
|
|
1606
|
-
if (
|
|
1606
|
+
const padding2 = slice(encodedReferrer, 0, ENCODED_REFERRER_BYTE_OFFSET);
|
|
1607
|
+
if (padding2 !== EXPECTED_ENCODED_REFERRER_PADDING) return zeroAddress4;
|
|
1607
1608
|
const decodedReferrer = slice(encodedReferrer, ENCODED_REFERRER_BYTE_OFFSET);
|
|
1608
1609
|
try {
|
|
1609
1610
|
return toNormalizedAddress2(decodedReferrer);
|
|
@@ -1964,9 +1965,1095 @@ var errorResponseInternalServerErrorExample = {
|
|
|
1964
1965
|
};
|
|
1965
1966
|
|
|
1966
1967
|
// src/omnigraph-api/example-queries.ts
|
|
1967
|
-
import { asInterpretedName, toNormalizedAddress as
|
|
1968
|
+
import { asInterpretedName, toNormalizedAddress as toNormalizedAddress4 } from "enssdk";
|
|
1968
1969
|
import { DatasourceNames as DatasourceNames2, ENSNamespaceIds as ENSNamespaceIds3 } from "@ensnode/datasources";
|
|
1969
|
-
|
|
1970
|
+
|
|
1971
|
+
// ../integration-test-env/src/devnet/fixtures.ts
|
|
1972
|
+
import { getCoderByCoinName } from "@ensdomains/address-encoder";
|
|
1973
|
+
import { bytesToHex as bytesToHex2 } from "@ensdomains/address-encoder/utils";
|
|
1974
|
+
|
|
1975
|
+
// ../../node_modules/.pnpm/@ensdomains+content-hash@3.1.0-rc.1/node_modules/@ensdomains/content-hash/dist/esm/utils/coders.js
|
|
1976
|
+
import { decodeArAddress, encodeArAddress } from "@ensdomains/address-encoder/coders";
|
|
1977
|
+
|
|
1978
|
+
// ../../node_modules/.pnpm/@scure+base@1.2.6/node_modules/@scure/base/lib/esm/index.js
|
|
1979
|
+
function isBytes(a) {
|
|
1980
|
+
return a instanceof Uint8Array || ArrayBuffer.isView(a) && a.constructor.name === "Uint8Array";
|
|
1981
|
+
}
|
|
1982
|
+
function isArrayOf(isString, arr) {
|
|
1983
|
+
if (!Array.isArray(arr))
|
|
1984
|
+
return false;
|
|
1985
|
+
if (arr.length === 0)
|
|
1986
|
+
return true;
|
|
1987
|
+
if (isString) {
|
|
1988
|
+
return arr.every((item) => typeof item === "string");
|
|
1989
|
+
} else {
|
|
1990
|
+
return arr.every((item) => Number.isSafeInteger(item));
|
|
1991
|
+
}
|
|
1992
|
+
}
|
|
1993
|
+
function afn(input) {
|
|
1994
|
+
if (typeof input !== "function")
|
|
1995
|
+
throw new Error("function expected");
|
|
1996
|
+
return true;
|
|
1997
|
+
}
|
|
1998
|
+
function astr(label, input) {
|
|
1999
|
+
if (typeof input !== "string")
|
|
2000
|
+
throw new Error(`${label}: string expected`);
|
|
2001
|
+
return true;
|
|
2002
|
+
}
|
|
2003
|
+
function anumber(n) {
|
|
2004
|
+
if (!Number.isSafeInteger(n))
|
|
2005
|
+
throw new Error(`invalid integer: ${n}`);
|
|
2006
|
+
}
|
|
2007
|
+
function aArr(input) {
|
|
2008
|
+
if (!Array.isArray(input))
|
|
2009
|
+
throw new Error("array expected");
|
|
2010
|
+
}
|
|
2011
|
+
function astrArr(label, input) {
|
|
2012
|
+
if (!isArrayOf(true, input))
|
|
2013
|
+
throw new Error(`${label}: array of strings expected`);
|
|
2014
|
+
}
|
|
2015
|
+
function anumArr(label, input) {
|
|
2016
|
+
if (!isArrayOf(false, input))
|
|
2017
|
+
throw new Error(`${label}: array of numbers expected`);
|
|
2018
|
+
}
|
|
2019
|
+
// @__NO_SIDE_EFFECTS__
|
|
2020
|
+
function chain(...args) {
|
|
2021
|
+
const id = (a) => a;
|
|
2022
|
+
const wrap = (a, b) => (c) => a(b(c));
|
|
2023
|
+
const encode2 = args.map((x) => x.encode).reduceRight(wrap, id);
|
|
2024
|
+
const decode2 = args.map((x) => x.decode).reduce(wrap, id);
|
|
2025
|
+
return { encode: encode2, decode: decode2 };
|
|
2026
|
+
}
|
|
2027
|
+
// @__NO_SIDE_EFFECTS__
|
|
2028
|
+
function alphabet(letters) {
|
|
2029
|
+
const lettersA = typeof letters === "string" ? letters.split("") : letters;
|
|
2030
|
+
const len = lettersA.length;
|
|
2031
|
+
astrArr("alphabet", lettersA);
|
|
2032
|
+
const indexes = new Map(lettersA.map((l, i) => [l, i]));
|
|
2033
|
+
return {
|
|
2034
|
+
encode: (digits) => {
|
|
2035
|
+
aArr(digits);
|
|
2036
|
+
return digits.map((i) => {
|
|
2037
|
+
if (!Number.isSafeInteger(i) || i < 0 || i >= len)
|
|
2038
|
+
throw new Error(`alphabet.encode: digit index outside alphabet "${i}". Allowed: ${letters}`);
|
|
2039
|
+
return lettersA[i];
|
|
2040
|
+
});
|
|
2041
|
+
},
|
|
2042
|
+
decode: (input) => {
|
|
2043
|
+
aArr(input);
|
|
2044
|
+
return input.map((letter) => {
|
|
2045
|
+
astr("alphabet.decode", letter);
|
|
2046
|
+
const i = indexes.get(letter);
|
|
2047
|
+
if (i === void 0)
|
|
2048
|
+
throw new Error(`Unknown letter: "${letter}". Allowed: ${letters}`);
|
|
2049
|
+
return i;
|
|
2050
|
+
});
|
|
2051
|
+
}
|
|
2052
|
+
};
|
|
2053
|
+
}
|
|
2054
|
+
// @__NO_SIDE_EFFECTS__
|
|
2055
|
+
function join(separator = "") {
|
|
2056
|
+
astr("join", separator);
|
|
2057
|
+
return {
|
|
2058
|
+
encode: (from) => {
|
|
2059
|
+
astrArr("join.decode", from);
|
|
2060
|
+
return from.join(separator);
|
|
2061
|
+
},
|
|
2062
|
+
decode: (to) => {
|
|
2063
|
+
astr("join.decode", to);
|
|
2064
|
+
return to.split(separator);
|
|
2065
|
+
}
|
|
2066
|
+
};
|
|
2067
|
+
}
|
|
2068
|
+
// @__NO_SIDE_EFFECTS__
|
|
2069
|
+
function padding(bits, chr = "=") {
|
|
2070
|
+
anumber(bits);
|
|
2071
|
+
astr("padding", chr);
|
|
2072
|
+
return {
|
|
2073
|
+
encode(data) {
|
|
2074
|
+
astrArr("padding.encode", data);
|
|
2075
|
+
while (data.length * bits % 8)
|
|
2076
|
+
data.push(chr);
|
|
2077
|
+
return data;
|
|
2078
|
+
},
|
|
2079
|
+
decode(input) {
|
|
2080
|
+
astrArr("padding.decode", input);
|
|
2081
|
+
let end = input.length;
|
|
2082
|
+
if (end * bits % 8)
|
|
2083
|
+
throw new Error("padding: invalid, string should have whole number of bytes");
|
|
2084
|
+
for (; end > 0 && input[end - 1] === chr; end--) {
|
|
2085
|
+
const last = end - 1;
|
|
2086
|
+
const byte = last * bits;
|
|
2087
|
+
if (byte % 8 === 0)
|
|
2088
|
+
throw new Error("padding: invalid, string has too much padding");
|
|
2089
|
+
}
|
|
2090
|
+
return input.slice(0, end);
|
|
2091
|
+
}
|
|
2092
|
+
};
|
|
2093
|
+
}
|
|
2094
|
+
function convertRadix(data, from, to) {
|
|
2095
|
+
if (from < 2)
|
|
2096
|
+
throw new Error(`convertRadix: invalid from=${from}, base cannot be less than 2`);
|
|
2097
|
+
if (to < 2)
|
|
2098
|
+
throw new Error(`convertRadix: invalid to=${to}, base cannot be less than 2`);
|
|
2099
|
+
aArr(data);
|
|
2100
|
+
if (!data.length)
|
|
2101
|
+
return [];
|
|
2102
|
+
let pos = 0;
|
|
2103
|
+
const res = [];
|
|
2104
|
+
const digits = Array.from(data, (d) => {
|
|
2105
|
+
anumber(d);
|
|
2106
|
+
if (d < 0 || d >= from)
|
|
2107
|
+
throw new Error(`invalid integer: ${d}`);
|
|
2108
|
+
return d;
|
|
2109
|
+
});
|
|
2110
|
+
const dlen = digits.length;
|
|
2111
|
+
while (true) {
|
|
2112
|
+
let carry = 0;
|
|
2113
|
+
let done = true;
|
|
2114
|
+
for (let i = pos; i < dlen; i++) {
|
|
2115
|
+
const digit = digits[i];
|
|
2116
|
+
const fromCarry = from * carry;
|
|
2117
|
+
const digitBase = fromCarry + digit;
|
|
2118
|
+
if (!Number.isSafeInteger(digitBase) || fromCarry / from !== carry || digitBase - digit !== fromCarry) {
|
|
2119
|
+
throw new Error("convertRadix: carry overflow");
|
|
2120
|
+
}
|
|
2121
|
+
const div = digitBase / to;
|
|
2122
|
+
carry = digitBase % to;
|
|
2123
|
+
const rounded = Math.floor(div);
|
|
2124
|
+
digits[i] = rounded;
|
|
2125
|
+
if (!Number.isSafeInteger(rounded) || rounded * to + carry !== digitBase)
|
|
2126
|
+
throw new Error("convertRadix: carry overflow");
|
|
2127
|
+
if (!done)
|
|
2128
|
+
continue;
|
|
2129
|
+
else if (!rounded)
|
|
2130
|
+
pos = i;
|
|
2131
|
+
else
|
|
2132
|
+
done = false;
|
|
2133
|
+
}
|
|
2134
|
+
res.push(carry);
|
|
2135
|
+
if (done)
|
|
2136
|
+
break;
|
|
2137
|
+
}
|
|
2138
|
+
for (let i = 0; i < data.length - 1 && data[i] === 0; i++)
|
|
2139
|
+
res.push(0);
|
|
2140
|
+
return res.reverse();
|
|
2141
|
+
}
|
|
2142
|
+
var gcd = (a, b) => b === 0 ? a : gcd(b, a % b);
|
|
2143
|
+
var radix2carry = /* @__NO_SIDE_EFFECTS__ */ (from, to) => from + (to - gcd(from, to));
|
|
2144
|
+
var powers = /* @__PURE__ */ (() => {
|
|
2145
|
+
let res = [];
|
|
2146
|
+
for (let i = 0; i < 40; i++)
|
|
2147
|
+
res.push(2 ** i);
|
|
2148
|
+
return res;
|
|
2149
|
+
})();
|
|
2150
|
+
function convertRadix2(data, from, to, padding2) {
|
|
2151
|
+
aArr(data);
|
|
2152
|
+
if (from <= 0 || from > 32)
|
|
2153
|
+
throw new Error(`convertRadix2: wrong from=${from}`);
|
|
2154
|
+
if (to <= 0 || to > 32)
|
|
2155
|
+
throw new Error(`convertRadix2: wrong to=${to}`);
|
|
2156
|
+
if (/* @__PURE__ */ radix2carry(from, to) > 32) {
|
|
2157
|
+
throw new Error(`convertRadix2: carry overflow from=${from} to=${to} carryBits=${/* @__PURE__ */ radix2carry(from, to)}`);
|
|
2158
|
+
}
|
|
2159
|
+
let carry = 0;
|
|
2160
|
+
let pos = 0;
|
|
2161
|
+
const max = powers[from];
|
|
2162
|
+
const mask = powers[to] - 1;
|
|
2163
|
+
const res = [];
|
|
2164
|
+
for (const n of data) {
|
|
2165
|
+
anumber(n);
|
|
2166
|
+
if (n >= max)
|
|
2167
|
+
throw new Error(`convertRadix2: invalid data word=${n} from=${from}`);
|
|
2168
|
+
carry = carry << from | n;
|
|
2169
|
+
if (pos + from > 32)
|
|
2170
|
+
throw new Error(`convertRadix2: carry overflow pos=${pos} from=${from}`);
|
|
2171
|
+
pos += from;
|
|
2172
|
+
for (; pos >= to; pos -= to)
|
|
2173
|
+
res.push((carry >> pos - to & mask) >>> 0);
|
|
2174
|
+
const pow = powers[pos];
|
|
2175
|
+
if (pow === void 0)
|
|
2176
|
+
throw new Error("invalid carry");
|
|
2177
|
+
carry &= pow - 1;
|
|
2178
|
+
}
|
|
2179
|
+
carry = carry << to - pos & mask;
|
|
2180
|
+
if (!padding2 && pos >= from)
|
|
2181
|
+
throw new Error("Excess padding");
|
|
2182
|
+
if (!padding2 && carry > 0)
|
|
2183
|
+
throw new Error(`Non-zero padding: ${carry}`);
|
|
2184
|
+
if (padding2 && pos > 0)
|
|
2185
|
+
res.push(carry >>> 0);
|
|
2186
|
+
return res;
|
|
2187
|
+
}
|
|
2188
|
+
// @__NO_SIDE_EFFECTS__
|
|
2189
|
+
function radix(num) {
|
|
2190
|
+
anumber(num);
|
|
2191
|
+
const _256 = 2 ** 8;
|
|
2192
|
+
return {
|
|
2193
|
+
encode: (bytes) => {
|
|
2194
|
+
if (!isBytes(bytes))
|
|
2195
|
+
throw new Error("radix.encode input should be Uint8Array");
|
|
2196
|
+
return convertRadix(Array.from(bytes), _256, num);
|
|
2197
|
+
},
|
|
2198
|
+
decode: (digits) => {
|
|
2199
|
+
anumArr("radix.decode", digits);
|
|
2200
|
+
return Uint8Array.from(convertRadix(digits, num, _256));
|
|
2201
|
+
}
|
|
2202
|
+
};
|
|
2203
|
+
}
|
|
2204
|
+
// @__NO_SIDE_EFFECTS__
|
|
2205
|
+
function radix2(bits, revPadding = false) {
|
|
2206
|
+
anumber(bits);
|
|
2207
|
+
if (bits <= 0 || bits > 32)
|
|
2208
|
+
throw new Error("radix2: bits should be in (0..32]");
|
|
2209
|
+
if (/* @__PURE__ */ radix2carry(8, bits) > 32 || /* @__PURE__ */ radix2carry(bits, 8) > 32)
|
|
2210
|
+
throw new Error("radix2: carry overflow");
|
|
2211
|
+
return {
|
|
2212
|
+
encode: (bytes) => {
|
|
2213
|
+
if (!isBytes(bytes))
|
|
2214
|
+
throw new Error("radix2.encode input should be Uint8Array");
|
|
2215
|
+
return convertRadix2(Array.from(bytes), 8, bits, !revPadding);
|
|
2216
|
+
},
|
|
2217
|
+
decode: (digits) => {
|
|
2218
|
+
anumArr("radix2.decode", digits);
|
|
2219
|
+
return Uint8Array.from(convertRadix2(digits, bits, 8, revPadding));
|
|
2220
|
+
}
|
|
2221
|
+
};
|
|
2222
|
+
}
|
|
2223
|
+
function checksum(len, fn) {
|
|
2224
|
+
anumber(len);
|
|
2225
|
+
afn(fn);
|
|
2226
|
+
return {
|
|
2227
|
+
encode(data) {
|
|
2228
|
+
if (!isBytes(data))
|
|
2229
|
+
throw new Error("checksum.encode: input should be Uint8Array");
|
|
2230
|
+
const sum = fn(data).slice(0, len);
|
|
2231
|
+
const res = new Uint8Array(data.length + len);
|
|
2232
|
+
res.set(data);
|
|
2233
|
+
res.set(sum, data.length);
|
|
2234
|
+
return res;
|
|
2235
|
+
},
|
|
2236
|
+
decode(data) {
|
|
2237
|
+
if (!isBytes(data))
|
|
2238
|
+
throw new Error("checksum.decode: input should be Uint8Array");
|
|
2239
|
+
const payload = data.slice(0, -len);
|
|
2240
|
+
const oldChecksum = data.slice(-len);
|
|
2241
|
+
const newChecksum = fn(payload).slice(0, len);
|
|
2242
|
+
for (let i = 0; i < len; i++)
|
|
2243
|
+
if (newChecksum[i] !== oldChecksum[i])
|
|
2244
|
+
throw new Error("Invalid checksum");
|
|
2245
|
+
return payload;
|
|
2246
|
+
}
|
|
2247
|
+
};
|
|
2248
|
+
}
|
|
2249
|
+
var utils = {
|
|
2250
|
+
alphabet,
|
|
2251
|
+
chain,
|
|
2252
|
+
checksum,
|
|
2253
|
+
convertRadix,
|
|
2254
|
+
convertRadix2,
|
|
2255
|
+
radix,
|
|
2256
|
+
radix2,
|
|
2257
|
+
join,
|
|
2258
|
+
padding
|
|
2259
|
+
};
|
|
2260
|
+
var genBase58 = /* @__NO_SIDE_EFFECTS__ */ (abc) => /* @__PURE__ */ chain(/* @__PURE__ */ radix(58), /* @__PURE__ */ alphabet(abc), /* @__PURE__ */ join(""));
|
|
2261
|
+
var base58 = /* @__PURE__ */ genBase58("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz");
|
|
2262
|
+
|
|
2263
|
+
// ../../node_modules/.pnpm/@ensdomains+content-hash@3.1.0-rc.1/node_modules/@ensdomains/content-hash/dist/esm/utils/coders.js
|
|
2264
|
+
var createMultibaseCoder = ({ name, prefix, encode: encodeWithoutPrefix, decode: decodeWithoutPrefix }) => {
|
|
2265
|
+
const encode2 = (bytes) => `${prefix}${encodeWithoutPrefix(bytes)}`;
|
|
2266
|
+
const decode2 = (multibase) => {
|
|
2267
|
+
if (!multibase.startsWith(prefix)) {
|
|
2268
|
+
throw new Error(`Multibase ${name} must start with ${prefix}`);
|
|
2269
|
+
}
|
|
2270
|
+
return decodeWithoutPrefix(multibase.slice(prefix.length));
|
|
2271
|
+
};
|
|
2272
|
+
return {
|
|
2273
|
+
name,
|
|
2274
|
+
prefix,
|
|
2275
|
+
encode: encode2,
|
|
2276
|
+
decode: decode2
|
|
2277
|
+
};
|
|
2278
|
+
};
|
|
2279
|
+
var base58btc = createMultibaseCoder({
|
|
2280
|
+
name: "base58btc",
|
|
2281
|
+
prefix: "z",
|
|
2282
|
+
encode: base58.encode,
|
|
2283
|
+
decode: base58.decode
|
|
2284
|
+
});
|
|
2285
|
+
var customBase32 = utils.chain(utils.radix2(5), utils.alphabet("abcdefghijklmnopqrstuvwxyz234567"), utils.join(""));
|
|
2286
|
+
var base32 = createMultibaseCoder({
|
|
2287
|
+
name: "base32",
|
|
2288
|
+
prefix: "b",
|
|
2289
|
+
encode: (bytes) => customBase32.encode(bytes),
|
|
2290
|
+
decode: (multibase) => customBase32.decode(multibase)
|
|
2291
|
+
});
|
|
2292
|
+
var base36Chain = utils.chain(utils.radix(36), utils.alphabet("0123456789abcdefghijklmnopqrstuvwxyz"), utils.join(""));
|
|
2293
|
+
var base36 = createMultibaseCoder({
|
|
2294
|
+
name: "base36",
|
|
2295
|
+
prefix: "k",
|
|
2296
|
+
encode: base36Chain.encode,
|
|
2297
|
+
decode: base36Chain.decode
|
|
2298
|
+
});
|
|
2299
|
+
var base64url = createMultibaseCoder({
|
|
2300
|
+
name: "base64url",
|
|
2301
|
+
prefix: "u",
|
|
2302
|
+
encode: encodeArAddress,
|
|
2303
|
+
decode: decodeArAddress
|
|
2304
|
+
});
|
|
2305
|
+
|
|
2306
|
+
// ../../node_modules/.pnpm/@ensdomains+content-hash@3.1.0-rc.1/node_modules/@ensdomains/content-hash/dist/esm/utils/coerce.js
|
|
2307
|
+
var coerce = (o) => {
|
|
2308
|
+
if (o instanceof Uint8Array && o.constructor.name === "Uint8Array")
|
|
2309
|
+
return o;
|
|
2310
|
+
if (o instanceof ArrayBuffer)
|
|
2311
|
+
return new Uint8Array(o);
|
|
2312
|
+
if (ArrayBuffer.isView(o)) {
|
|
2313
|
+
return new Uint8Array(o.buffer, o.byteOffset, o.byteLength);
|
|
2314
|
+
}
|
|
2315
|
+
throw new Error("Unknown type, must be binary type");
|
|
2316
|
+
};
|
|
2317
|
+
|
|
2318
|
+
// ../../node_modules/.pnpm/@noble+curves@1.9.7/node_modules/@noble/curves/esm/utils.js
|
|
2319
|
+
function equalBytes(a, b) {
|
|
2320
|
+
if (a.length !== b.length)
|
|
2321
|
+
return false;
|
|
2322
|
+
let diff = 0;
|
|
2323
|
+
for (let i = 0; i < a.length; i++)
|
|
2324
|
+
diff |= a[i] ^ b[i];
|
|
2325
|
+
return diff === 0;
|
|
2326
|
+
}
|
|
2327
|
+
|
|
2328
|
+
// ../../node_modules/.pnpm/@noble+curves@1.9.7/node_modules/@noble/curves/esm/abstract/utils.js
|
|
2329
|
+
var equalBytes2 = equalBytes;
|
|
2330
|
+
|
|
2331
|
+
// ../../node_modules/.pnpm/@ensdomains+content-hash@3.1.0-rc.1/node_modules/@ensdomains/content-hash/dist/esm/utils/varint.js
|
|
2332
|
+
var MSB = 128;
|
|
2333
|
+
var REST = 127;
|
|
2334
|
+
var MSBALL = ~REST;
|
|
2335
|
+
var INT = Math.pow(2, 31);
|
|
2336
|
+
var encodeVarint = (num, out, offset = 0) => {
|
|
2337
|
+
out = out || [];
|
|
2338
|
+
offset = offset || 0;
|
|
2339
|
+
while (num >= INT) {
|
|
2340
|
+
out[offset++] = num & 255 | MSB;
|
|
2341
|
+
num /= 128;
|
|
2342
|
+
}
|
|
2343
|
+
while (num & MSBALL) {
|
|
2344
|
+
out[offset++] = num & 255 | MSB;
|
|
2345
|
+
num >>>= 7;
|
|
2346
|
+
}
|
|
2347
|
+
out[offset] = num | 0;
|
|
2348
|
+
return out;
|
|
2349
|
+
};
|
|
2350
|
+
var MSB$1 = 128;
|
|
2351
|
+
var REST$1 = 127;
|
|
2352
|
+
var decodeVarint = (buf, offset = 0) => {
|
|
2353
|
+
var res = 0, offset = offset || 0, shift = 0, counter = offset, b, l = buf.length;
|
|
2354
|
+
do {
|
|
2355
|
+
if (counter >= l) {
|
|
2356
|
+
read.bytes = 0;
|
|
2357
|
+
throw new RangeError("Could not decode varint");
|
|
2358
|
+
}
|
|
2359
|
+
b = buf[counter++];
|
|
2360
|
+
res += shift < 28 ? (b & REST$1) << shift : (b & REST$1) * Math.pow(2, shift);
|
|
2361
|
+
shift += 7;
|
|
2362
|
+
} while (b >= MSB$1);
|
|
2363
|
+
return [res, counter - offset];
|
|
2364
|
+
};
|
|
2365
|
+
var N1 = Math.pow(2, 7);
|
|
2366
|
+
var N2 = Math.pow(2, 14);
|
|
2367
|
+
var N3 = Math.pow(2, 21);
|
|
2368
|
+
var N4 = Math.pow(2, 28);
|
|
2369
|
+
var N5 = Math.pow(2, 35);
|
|
2370
|
+
var N6 = Math.pow(2, 42);
|
|
2371
|
+
var N7 = Math.pow(2, 49);
|
|
2372
|
+
var N8 = Math.pow(2, 56);
|
|
2373
|
+
var N9 = Math.pow(2, 63);
|
|
2374
|
+
var varintEncodingLength = (value) => {
|
|
2375
|
+
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;
|
|
2376
|
+
};
|
|
2377
|
+
|
|
2378
|
+
// ../../node_modules/.pnpm/@ensdomains+content-hash@3.1.0-rc.1/node_modules/@ensdomains/content-hash/dist/esm/utils/digest.js
|
|
2379
|
+
var Digest = class {
|
|
2380
|
+
/**
|
|
2381
|
+
* Creates a multihash digest.
|
|
2382
|
+
*/
|
|
2383
|
+
constructor(code, size4, digest, bytes) {
|
|
2384
|
+
Object.defineProperty(this, "code", {
|
|
2385
|
+
enumerable: true,
|
|
2386
|
+
configurable: true,
|
|
2387
|
+
writable: true,
|
|
2388
|
+
value: void 0
|
|
2389
|
+
});
|
|
2390
|
+
Object.defineProperty(this, "size", {
|
|
2391
|
+
enumerable: true,
|
|
2392
|
+
configurable: true,
|
|
2393
|
+
writable: true,
|
|
2394
|
+
value: void 0
|
|
2395
|
+
});
|
|
2396
|
+
Object.defineProperty(this, "digest", {
|
|
2397
|
+
enumerable: true,
|
|
2398
|
+
configurable: true,
|
|
2399
|
+
writable: true,
|
|
2400
|
+
value: void 0
|
|
2401
|
+
});
|
|
2402
|
+
Object.defineProperty(this, "bytes", {
|
|
2403
|
+
enumerable: true,
|
|
2404
|
+
configurable: true,
|
|
2405
|
+
writable: true,
|
|
2406
|
+
value: void 0
|
|
2407
|
+
});
|
|
2408
|
+
this.code = code;
|
|
2409
|
+
this.size = size4;
|
|
2410
|
+
this.digest = digest;
|
|
2411
|
+
this.bytes = bytes;
|
|
2412
|
+
}
|
|
2413
|
+
};
|
|
2414
|
+
var createDigest = (code, digest) => {
|
|
2415
|
+
const size4 = digest.byteLength;
|
|
2416
|
+
const sizeOffset = varintEncodingLength(code);
|
|
2417
|
+
const digestOffset = sizeOffset + varintEncodingLength(size4);
|
|
2418
|
+
const bytes = new Uint8Array(digestOffset + size4);
|
|
2419
|
+
encodeVarint(code, bytes, 0);
|
|
2420
|
+
encodeVarint(size4, bytes, sizeOffset);
|
|
2421
|
+
bytes.set(digest, digestOffset);
|
|
2422
|
+
return new Digest(code, size4, digest, bytes);
|
|
2423
|
+
};
|
|
2424
|
+
var decodeDigest = (multihash) => {
|
|
2425
|
+
const bytes = coerce(multihash);
|
|
2426
|
+
const [code, sizeOffset] = decodeVarint(bytes);
|
|
2427
|
+
const [size4, digestOffset] = decodeVarint(bytes.subarray(sizeOffset));
|
|
2428
|
+
const digest = bytes.subarray(sizeOffset + digestOffset);
|
|
2429
|
+
if (digest.byteLength !== size4) {
|
|
2430
|
+
throw new Error("Incorrect length");
|
|
2431
|
+
}
|
|
2432
|
+
return new Digest(code, size4, digest, bytes);
|
|
2433
|
+
};
|
|
2434
|
+
var digestEquals = (a, b) => {
|
|
2435
|
+
if (a === b) {
|
|
2436
|
+
return true;
|
|
2437
|
+
} else {
|
|
2438
|
+
const data = b;
|
|
2439
|
+
return a.code === data.code && a.size === data.size && data.bytes instanceof Uint8Array && equalBytes2(a.bytes, data.bytes);
|
|
2440
|
+
}
|
|
2441
|
+
};
|
|
2442
|
+
|
|
2443
|
+
// ../../node_modules/.pnpm/@ensdomains+content-hash@3.1.0-rc.1/node_modules/@ensdomains/content-hash/dist/esm/utils/cid.js
|
|
2444
|
+
function format(link, base2) {
|
|
2445
|
+
const { bytes, version } = link;
|
|
2446
|
+
switch (version) {
|
|
2447
|
+
case 0:
|
|
2448
|
+
return toStringV0(bytes, baseCache(link), base2 ?? base58btc.encode);
|
|
2449
|
+
default:
|
|
2450
|
+
return toStringV1(bytes, baseCache(link), base2 ?? base32.encode);
|
|
2451
|
+
}
|
|
2452
|
+
}
|
|
2453
|
+
var cache = /* @__PURE__ */ new WeakMap();
|
|
2454
|
+
function baseCache(cid) {
|
|
2455
|
+
const baseCache2 = cache.get(cid);
|
|
2456
|
+
if (baseCache2 == null) {
|
|
2457
|
+
const baseCache3 = /* @__PURE__ */ new Map();
|
|
2458
|
+
cache.set(cid, baseCache3);
|
|
2459
|
+
return baseCache3;
|
|
2460
|
+
}
|
|
2461
|
+
return baseCache2;
|
|
2462
|
+
}
|
|
2463
|
+
var CID = class _CID {
|
|
2464
|
+
/**
|
|
2465
|
+
* @param version - Version of the CID
|
|
2466
|
+
* @param code - Code of the codec content is encoded in, see https://github.com/multiformats/multicodec/blob/master/table.csv
|
|
2467
|
+
* @param multihash - (Multi)hash of the of the content.
|
|
2468
|
+
*/
|
|
2469
|
+
constructor(version, code, multihash, bytes) {
|
|
2470
|
+
Object.defineProperty(this, "code", {
|
|
2471
|
+
enumerable: true,
|
|
2472
|
+
configurable: true,
|
|
2473
|
+
writable: true,
|
|
2474
|
+
value: void 0
|
|
2475
|
+
});
|
|
2476
|
+
Object.defineProperty(this, "version", {
|
|
2477
|
+
enumerable: true,
|
|
2478
|
+
configurable: true,
|
|
2479
|
+
writable: true,
|
|
2480
|
+
value: void 0
|
|
2481
|
+
});
|
|
2482
|
+
Object.defineProperty(this, "multihash", {
|
|
2483
|
+
enumerable: true,
|
|
2484
|
+
configurable: true,
|
|
2485
|
+
writable: true,
|
|
2486
|
+
value: void 0
|
|
2487
|
+
});
|
|
2488
|
+
Object.defineProperty(this, "bytes", {
|
|
2489
|
+
enumerable: true,
|
|
2490
|
+
configurable: true,
|
|
2491
|
+
writable: true,
|
|
2492
|
+
value: void 0
|
|
2493
|
+
});
|
|
2494
|
+
Object.defineProperty(this, "/", {
|
|
2495
|
+
enumerable: true,
|
|
2496
|
+
configurable: true,
|
|
2497
|
+
writable: true,
|
|
2498
|
+
value: void 0
|
|
2499
|
+
});
|
|
2500
|
+
this.code = code;
|
|
2501
|
+
this.version = version;
|
|
2502
|
+
this.multihash = multihash;
|
|
2503
|
+
this.bytes = bytes;
|
|
2504
|
+
this["/"] = bytes;
|
|
2505
|
+
}
|
|
2506
|
+
/**
|
|
2507
|
+
* Signalling `cid.asCID === cid` has been replaced with `cid['/'] === cid.bytes`
|
|
2508
|
+
* please either use `CID.asCID(cid)` or switch to new signalling mechanism
|
|
2509
|
+
*
|
|
2510
|
+
* @deprecated
|
|
2511
|
+
*/
|
|
2512
|
+
get asCID() {
|
|
2513
|
+
return this;
|
|
2514
|
+
}
|
|
2515
|
+
// ArrayBufferView
|
|
2516
|
+
get byteOffset() {
|
|
2517
|
+
return this.bytes.byteOffset;
|
|
2518
|
+
}
|
|
2519
|
+
// ArrayBufferView
|
|
2520
|
+
get byteLength() {
|
|
2521
|
+
return this.bytes.byteLength;
|
|
2522
|
+
}
|
|
2523
|
+
toV0() {
|
|
2524
|
+
switch (this.version) {
|
|
2525
|
+
case 0: {
|
|
2526
|
+
return this;
|
|
2527
|
+
}
|
|
2528
|
+
case 1: {
|
|
2529
|
+
const { code, multihash } = this;
|
|
2530
|
+
if (code !== DAG_PB_CODE) {
|
|
2531
|
+
throw new Error("Cannot convert a non dag-pb CID to CIDv0");
|
|
2532
|
+
}
|
|
2533
|
+
if (multihash.code !== SHA_256_CODE) {
|
|
2534
|
+
throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");
|
|
2535
|
+
}
|
|
2536
|
+
return _CID.createV0(multihash);
|
|
2537
|
+
}
|
|
2538
|
+
default: {
|
|
2539
|
+
throw Error(`Can not convert CID version ${this.version} to version 0. This is a bug please report`);
|
|
2540
|
+
}
|
|
2541
|
+
}
|
|
2542
|
+
}
|
|
2543
|
+
toV1() {
|
|
2544
|
+
switch (this.version) {
|
|
2545
|
+
case 0: {
|
|
2546
|
+
const { code, digest } = this.multihash;
|
|
2547
|
+
const multihash = createDigest(code, digest);
|
|
2548
|
+
return _CID.createV1(this.code, multihash);
|
|
2549
|
+
}
|
|
2550
|
+
case 1: {
|
|
2551
|
+
return this;
|
|
2552
|
+
}
|
|
2553
|
+
default: {
|
|
2554
|
+
throw Error(`Can not convert CID version ${this.version} to version 1. This is a bug please report`);
|
|
2555
|
+
}
|
|
2556
|
+
}
|
|
2557
|
+
}
|
|
2558
|
+
equals(other) {
|
|
2559
|
+
return _CID.equals(this, other);
|
|
2560
|
+
}
|
|
2561
|
+
static equals(self, other) {
|
|
2562
|
+
const unknown = other;
|
|
2563
|
+
return unknown != null && self.code === unknown.code && self.version === unknown.version && digestEquals(self.multihash, unknown.multihash);
|
|
2564
|
+
}
|
|
2565
|
+
toString(base2) {
|
|
2566
|
+
return format(this, base2);
|
|
2567
|
+
}
|
|
2568
|
+
toJSON() {
|
|
2569
|
+
return { "/": format(this) };
|
|
2570
|
+
}
|
|
2571
|
+
link() {
|
|
2572
|
+
return this;
|
|
2573
|
+
}
|
|
2574
|
+
get [Symbol.toStringTag]() {
|
|
2575
|
+
return "CID";
|
|
2576
|
+
}
|
|
2577
|
+
// Legacy
|
|
2578
|
+
[/* @__PURE__ */ Symbol.for("nodejs.util.inspect.custom")]() {
|
|
2579
|
+
return `CID(${this.toString()})`;
|
|
2580
|
+
}
|
|
2581
|
+
/**
|
|
2582
|
+
* Takes any input `value` and returns a `CID` instance if it was
|
|
2583
|
+
* a `CID` otherwise returns `null`. If `value` is instanceof `CID`
|
|
2584
|
+
* it will return value back. If `value` is not instance of this CID
|
|
2585
|
+
* class, but is compatible CID it will return new instance of this
|
|
2586
|
+
* `CID` class. Otherwise returns null.
|
|
2587
|
+
*
|
|
2588
|
+
* This allows two different incompatible versions of CID library to
|
|
2589
|
+
* co-exist and interop as long as binary interface is compatible.
|
|
2590
|
+
*/
|
|
2591
|
+
static asCID(input) {
|
|
2592
|
+
if (input == null) {
|
|
2593
|
+
return null;
|
|
2594
|
+
}
|
|
2595
|
+
const value = input;
|
|
2596
|
+
if (value instanceof _CID) {
|
|
2597
|
+
return value;
|
|
2598
|
+
} else if (value["/"] != null && value["/"] === value.bytes || value.asCID === value) {
|
|
2599
|
+
const { version, code, multihash, bytes } = value;
|
|
2600
|
+
return new _CID(version, code, multihash, bytes ?? encodeCID(version, code, multihash.bytes));
|
|
2601
|
+
} else if (value[cidSymbol] === true) {
|
|
2602
|
+
const { version, multihash, code } = value;
|
|
2603
|
+
const digest = decodeDigest(multihash);
|
|
2604
|
+
return _CID.create(version, code, digest);
|
|
2605
|
+
} else {
|
|
2606
|
+
return null;
|
|
2607
|
+
}
|
|
2608
|
+
}
|
|
2609
|
+
/**
|
|
2610
|
+
* @param version - Version of the CID
|
|
2611
|
+
* @param code - Code of the codec content is encoded in, see https://github.com/multiformats/multicodec/blob/master/table.csv
|
|
2612
|
+
* @param digest - (Multi)hash of the of the content.
|
|
2613
|
+
*/
|
|
2614
|
+
static create(version, code, digest) {
|
|
2615
|
+
if (typeof code !== "number") {
|
|
2616
|
+
throw new Error("String codecs are no longer supported");
|
|
2617
|
+
}
|
|
2618
|
+
if (!(digest.bytes instanceof Uint8Array)) {
|
|
2619
|
+
throw new Error("Invalid digest");
|
|
2620
|
+
}
|
|
2621
|
+
switch (version) {
|
|
2622
|
+
case 0: {
|
|
2623
|
+
if (code !== DAG_PB_CODE) {
|
|
2624
|
+
throw new Error(`Version 0 CID must use dag-pb (code: ${DAG_PB_CODE}) block encoding`);
|
|
2625
|
+
} else {
|
|
2626
|
+
return new _CID(version, code, digest, digest.bytes);
|
|
2627
|
+
}
|
|
2628
|
+
}
|
|
2629
|
+
case 1: {
|
|
2630
|
+
const bytes = encodeCID(version, code, digest.bytes);
|
|
2631
|
+
return new _CID(version, code, digest, bytes);
|
|
2632
|
+
}
|
|
2633
|
+
default: {
|
|
2634
|
+
throw new Error("Invalid version");
|
|
2635
|
+
}
|
|
2636
|
+
}
|
|
2637
|
+
}
|
|
2638
|
+
/**
|
|
2639
|
+
* Simplified version of `create` for CIDv0.
|
|
2640
|
+
*/
|
|
2641
|
+
static createV0(digest) {
|
|
2642
|
+
return _CID.create(0, DAG_PB_CODE, digest);
|
|
2643
|
+
}
|
|
2644
|
+
/**
|
|
2645
|
+
* Simplified version of `create` for CIDv1.
|
|
2646
|
+
*
|
|
2647
|
+
* @param code - Content encoding format code.
|
|
2648
|
+
* @param digest - Multihash of the content.
|
|
2649
|
+
*/
|
|
2650
|
+
static createV1(code, digest) {
|
|
2651
|
+
return _CID.create(1, code, digest);
|
|
2652
|
+
}
|
|
2653
|
+
/**
|
|
2654
|
+
* Decoded a CID from its binary representation. The byte array must contain
|
|
2655
|
+
* only the CID with no additional bytes.
|
|
2656
|
+
*
|
|
2657
|
+
* An error will be thrown if the bytes provided do not contain a valid
|
|
2658
|
+
* binary representation of a CID.
|
|
2659
|
+
*/
|
|
2660
|
+
static decode(bytes) {
|
|
2661
|
+
let [cid, remainder] = _CID.decodeFirst(bytes);
|
|
2662
|
+
if (remainder.length !== 0) {
|
|
2663
|
+
[cid, remainder] = _CID.decodeFirst(Uint8Array.from([0, DAG_PB_CODE, ...bytes]));
|
|
2664
|
+
if (remainder.length !== 0)
|
|
2665
|
+
throw new Error("Incorrect length");
|
|
2666
|
+
}
|
|
2667
|
+
return cid;
|
|
2668
|
+
}
|
|
2669
|
+
/**
|
|
2670
|
+
* Decoded a CID from its binary representation at the beginning of a byte
|
|
2671
|
+
* array.
|
|
2672
|
+
*
|
|
2673
|
+
* Returns an array with the first element containing the CID and the second
|
|
2674
|
+
* element containing the remainder of the original byte array. The remainder
|
|
2675
|
+
* will be a zero-length byte array if the provided bytes only contained a
|
|
2676
|
+
* binary CID representation.
|
|
2677
|
+
*/
|
|
2678
|
+
static decodeFirst(bytes) {
|
|
2679
|
+
const specs = _CID.inspectBytes(bytes);
|
|
2680
|
+
const prefixSize = specs.size - specs.multihashSize;
|
|
2681
|
+
const multihashBytes = coerce(bytes.subarray(prefixSize, prefixSize + specs.multihashSize));
|
|
2682
|
+
if (multihashBytes.byteLength !== specs.multihashSize) {
|
|
2683
|
+
throw new Error("Incorrect length");
|
|
2684
|
+
}
|
|
2685
|
+
const digestBytes = multihashBytes.subarray(specs.multihashSize - specs.digestSize);
|
|
2686
|
+
const digest = new Digest(specs.multihashCode, specs.digestSize, digestBytes, multihashBytes);
|
|
2687
|
+
const cid = specs.version === 0 ? _CID.createV0(digest) : _CID.createV1(specs.codec, digest);
|
|
2688
|
+
return [cid, bytes.subarray(specs.size)];
|
|
2689
|
+
}
|
|
2690
|
+
/**
|
|
2691
|
+
* Inspect the initial bytes of a CID to determine its properties.
|
|
2692
|
+
*
|
|
2693
|
+
* Involves decoding up to 4 varints. Typically this will require only 4 to 6
|
|
2694
|
+
* bytes but for larger multicodec code values and larger multihash digest
|
|
2695
|
+
* lengths these varints can be quite large. It is recommended that at least
|
|
2696
|
+
* 10 bytes be made available in the `initialBytes` argument for a complete
|
|
2697
|
+
* inspection.
|
|
2698
|
+
*/
|
|
2699
|
+
static inspectBytes(initialBytes) {
|
|
2700
|
+
let offset = 0;
|
|
2701
|
+
const next = () => {
|
|
2702
|
+
const [i, length] = decodeVarint(initialBytes.subarray(offset));
|
|
2703
|
+
offset += length;
|
|
2704
|
+
return i;
|
|
2705
|
+
};
|
|
2706
|
+
let version = next();
|
|
2707
|
+
let codec = DAG_PB_CODE;
|
|
2708
|
+
if (version === 18) {
|
|
2709
|
+
version = 0;
|
|
2710
|
+
offset = 0;
|
|
2711
|
+
} else {
|
|
2712
|
+
codec = next();
|
|
2713
|
+
}
|
|
2714
|
+
if (version !== 0 && version !== 1) {
|
|
2715
|
+
throw new RangeError(`Invalid CID version ${version}`);
|
|
2716
|
+
}
|
|
2717
|
+
const prefixSize = offset;
|
|
2718
|
+
const multihashCode = next();
|
|
2719
|
+
const digestSize = next();
|
|
2720
|
+
const size4 = offset + digestSize;
|
|
2721
|
+
const multihashSize = size4 - prefixSize;
|
|
2722
|
+
return { version, codec, multihashCode, digestSize, multihashSize, size: size4 };
|
|
2723
|
+
}
|
|
2724
|
+
/**
|
|
2725
|
+
* Takes cid in a string representation and creates an instance. If `base`
|
|
2726
|
+
* decoder is not provided will use a default from the configuration. It will
|
|
2727
|
+
* throw an error if encoding of the CID is not compatible with supplied (or
|
|
2728
|
+
* a default decoder).
|
|
2729
|
+
*/
|
|
2730
|
+
static parse(source, base2) {
|
|
2731
|
+
const [prefix, bytes] = parseCIDtoBytes(source, base2);
|
|
2732
|
+
const cid = _CID.decode(bytes);
|
|
2733
|
+
baseCache(cid).set(prefix, source);
|
|
2734
|
+
return cid;
|
|
2735
|
+
}
|
|
2736
|
+
};
|
|
2737
|
+
function parseCIDtoBytes(source, base2) {
|
|
2738
|
+
switch (source[0]) {
|
|
2739
|
+
// CIDv0 is parsed differently
|
|
2740
|
+
case "Q": {
|
|
2741
|
+
const decoder = base2 ?? base58btc;
|
|
2742
|
+
return [
|
|
2743
|
+
base58btc.prefix,
|
|
2744
|
+
decoder.decode(`${base58btc.prefix}${source}`)
|
|
2745
|
+
];
|
|
2746
|
+
}
|
|
2747
|
+
case base58btc.prefix: {
|
|
2748
|
+
const decoder = base2 ?? base58btc;
|
|
2749
|
+
return [base58btc.prefix, decoder.decode(source)];
|
|
2750
|
+
}
|
|
2751
|
+
case base32.prefix: {
|
|
2752
|
+
const decoder = base2 ?? base32;
|
|
2753
|
+
return [base32.prefix, decoder.decode(source)];
|
|
2754
|
+
}
|
|
2755
|
+
case base36.prefix: {
|
|
2756
|
+
const decoder = base2 ?? base36;
|
|
2757
|
+
return [base36.prefix, decoder.decode(source)];
|
|
2758
|
+
}
|
|
2759
|
+
default: {
|
|
2760
|
+
source = `z${source}`;
|
|
2761
|
+
return [source[0], base58btc.decode(source)];
|
|
2762
|
+
}
|
|
2763
|
+
}
|
|
2764
|
+
}
|
|
2765
|
+
function toStringV0(bytes, cache4, base2) {
|
|
2766
|
+
const { prefix } = base2;
|
|
2767
|
+
if (prefix !== base58btc.prefix) {
|
|
2768
|
+
throw Error(`Cannot string encode V0 in ${base2.name} encoding`);
|
|
2769
|
+
}
|
|
2770
|
+
const cid = cache4.get(prefix);
|
|
2771
|
+
if (cid == null) {
|
|
2772
|
+
const cid2 = base2.encode(bytes).slice(1);
|
|
2773
|
+
cache4.set(prefix, cid2);
|
|
2774
|
+
return cid2;
|
|
2775
|
+
} else {
|
|
2776
|
+
return cid;
|
|
2777
|
+
}
|
|
2778
|
+
}
|
|
2779
|
+
function toStringV1(bytes, cache4, base2) {
|
|
2780
|
+
const { prefix } = base2;
|
|
2781
|
+
const cid = cache4.get(prefix);
|
|
2782
|
+
if (cid == null) {
|
|
2783
|
+
const cid2 = base2.encode(bytes);
|
|
2784
|
+
cache4.set(prefix, cid2);
|
|
2785
|
+
return cid2;
|
|
2786
|
+
} else {
|
|
2787
|
+
return cid;
|
|
2788
|
+
}
|
|
2789
|
+
}
|
|
2790
|
+
var DAG_PB_CODE = 112;
|
|
2791
|
+
var SHA_256_CODE = 18;
|
|
2792
|
+
function encodeCID(version, code, multihash) {
|
|
2793
|
+
const codeOffset = varintEncodingLength(version);
|
|
2794
|
+
const hashOffset = codeOffset + varintEncodingLength(code);
|
|
2795
|
+
const bytes = new Uint8Array(hashOffset + multihash.byteLength);
|
|
2796
|
+
encodeVarint(version, bytes, 0);
|
|
2797
|
+
encodeVarint(code, bytes, codeOffset);
|
|
2798
|
+
bytes.set(multihash, hashOffset);
|
|
2799
|
+
return bytes;
|
|
2800
|
+
}
|
|
2801
|
+
var cidSymbol = /* @__PURE__ */ Symbol.for("@ipld/js-cid/CID");
|
|
2802
|
+
|
|
2803
|
+
// ../../node_modules/.pnpm/@ensdomains+content-hash@3.1.0-rc.1/node_modules/@ensdomains/content-hash/dist/esm/helpers.js
|
|
2804
|
+
var concatUint8Arrays = (array1, array2) => {
|
|
2805
|
+
let result = new Uint8Array(array1.length + array2.length);
|
|
2806
|
+
result.set(array1, 0);
|
|
2807
|
+
result.set(array2, array1.length);
|
|
2808
|
+
return result;
|
|
2809
|
+
};
|
|
2810
|
+
|
|
2811
|
+
// ../../node_modules/.pnpm/@ensdomains+content-hash@3.1.0-rc.1/node_modules/@ensdomains/content-hash/dist/esm/map.js
|
|
2812
|
+
var codeToName = {
|
|
2813
|
+
227: "ipfs",
|
|
2814
|
+
229: "ipns",
|
|
2815
|
+
228: "swarm",
|
|
2816
|
+
444: "onion",
|
|
2817
|
+
445: "onion3",
|
|
2818
|
+
11639056: "skynet",
|
|
2819
|
+
11704592: "arweave"
|
|
2820
|
+
};
|
|
2821
|
+
var nameToCode = {
|
|
2822
|
+
ipfs: 227,
|
|
2823
|
+
ipns: 229,
|
|
2824
|
+
swarm: 228,
|
|
2825
|
+
onion: 444,
|
|
2826
|
+
onion3: 445,
|
|
2827
|
+
skynet: 11639056,
|
|
2828
|
+
arweave: 11704592
|
|
2829
|
+
};
|
|
2830
|
+
|
|
2831
|
+
// ../../node_modules/.pnpm/@ensdomains+content-hash@3.1.0-rc.1/node_modules/@ensdomains/content-hash/dist/esm/profiles.js
|
|
2832
|
+
import { decodeArAddress as decodeArAddress2, encodeArAddress as encodeArAddress2 } from "@ensdomains/address-encoder/coders";
|
|
2833
|
+
var hexStringToBytes = (hex) => {
|
|
2834
|
+
let value = hex;
|
|
2835
|
+
if (value.startsWith("0x")) {
|
|
2836
|
+
value = value.slice(2);
|
|
2837
|
+
}
|
|
2838
|
+
if (value.length % 2 !== 0) {
|
|
2839
|
+
throw new Error("Invalid hex string");
|
|
2840
|
+
}
|
|
2841
|
+
const bytes = new Uint8Array(value.length / 2);
|
|
2842
|
+
for (let i = 0; i < value.length; i += 2) {
|
|
2843
|
+
bytes[i / 2] = parseInt(value.slice(i, i + 2), 16);
|
|
2844
|
+
}
|
|
2845
|
+
return bytes;
|
|
2846
|
+
};
|
|
2847
|
+
var bytesToHexString = (bytes) => {
|
|
2848
|
+
let hex = "";
|
|
2849
|
+
for (let i = 0; i < bytes.length; i++) {
|
|
2850
|
+
hex += bytes[i].toString(16).padStart(2, "0");
|
|
2851
|
+
}
|
|
2852
|
+
return hex;
|
|
2853
|
+
};
|
|
2854
|
+
var isCryptographicIPNS = (cid) => {
|
|
2855
|
+
try {
|
|
2856
|
+
const { multihash } = cid;
|
|
2857
|
+
if (multihash.size < 38) {
|
|
2858
|
+
const mh = decodeDigest(multihash.bytes);
|
|
2859
|
+
if (mh.code === 0 && mh.size < 36) {
|
|
2860
|
+
return false;
|
|
2861
|
+
}
|
|
2862
|
+
}
|
|
2863
|
+
return true;
|
|
2864
|
+
} catch (_) {
|
|
2865
|
+
return false;
|
|
2866
|
+
}
|
|
2867
|
+
};
|
|
2868
|
+
var base64Decode = (value) => decodeArAddress2(value);
|
|
2869
|
+
var encodes = {
|
|
2870
|
+
skynet: (value) => {
|
|
2871
|
+
return base64Decode(value);
|
|
2872
|
+
},
|
|
2873
|
+
swarm: (value) => {
|
|
2874
|
+
const bytes = hexStringToBytes(value);
|
|
2875
|
+
const multihash = createDigest(27, bytes);
|
|
2876
|
+
return CID.create(1, 250, multihash).bytes;
|
|
2877
|
+
},
|
|
2878
|
+
ipfs: (value) => {
|
|
2879
|
+
return CID.parse(value).toV1().bytes;
|
|
2880
|
+
},
|
|
2881
|
+
ipns: (value) => {
|
|
2882
|
+
const cid = CID.parse(value);
|
|
2883
|
+
return CID.create(1, 114, cid.multihash).bytes;
|
|
2884
|
+
},
|
|
2885
|
+
utf8: (value) => {
|
|
2886
|
+
const encoder = new TextEncoder();
|
|
2887
|
+
return encoder.encode(value);
|
|
2888
|
+
},
|
|
2889
|
+
arweave: (value) => {
|
|
2890
|
+
return base64Decode(value);
|
|
2891
|
+
}
|
|
2892
|
+
};
|
|
2893
|
+
var decodes = {
|
|
2894
|
+
hexMultiHash: (value) => {
|
|
2895
|
+
const cid = CID.decode(value);
|
|
2896
|
+
return bytesToHexString(decodeDigest(cid.multihash.bytes).digest);
|
|
2897
|
+
},
|
|
2898
|
+
ipfs: (value) => {
|
|
2899
|
+
const cid = CID.decode(value).toV1();
|
|
2900
|
+
return cid.toString(cid.code === 114 ? base36 : base32);
|
|
2901
|
+
},
|
|
2902
|
+
ipns: (value) => {
|
|
2903
|
+
const cid = CID.decode(value).toV1();
|
|
2904
|
+
if (!isCryptographicIPNS(cid)) {
|
|
2905
|
+
console.warn("[ensdomains/content-hash] use of non-cryptographic identifiers in ipns-ns is deprecated and will be removed, migrate to ED25519 libp2p-key");
|
|
2906
|
+
return String.fromCodePoint(...CID.decode(value).multihash.digest);
|
|
2907
|
+
}
|
|
2908
|
+
return cid.toString(base36);
|
|
2909
|
+
},
|
|
2910
|
+
utf8: (value) => {
|
|
2911
|
+
const decoder = new TextDecoder();
|
|
2912
|
+
return decoder.decode(value);
|
|
2913
|
+
},
|
|
2914
|
+
base64: (value) => {
|
|
2915
|
+
return encodeArAddress2(value);
|
|
2916
|
+
}
|
|
2917
|
+
};
|
|
2918
|
+
var profiles = {
|
|
2919
|
+
skynet: {
|
|
2920
|
+
encode: encodes.skynet,
|
|
2921
|
+
decode: decodes.base64
|
|
2922
|
+
},
|
|
2923
|
+
swarm: {
|
|
2924
|
+
encode: encodes.swarm,
|
|
2925
|
+
decode: decodes.hexMultiHash
|
|
2926
|
+
},
|
|
2927
|
+
ipfs: {
|
|
2928
|
+
encode: encodes.ipfs,
|
|
2929
|
+
decode: decodes.ipfs
|
|
2930
|
+
},
|
|
2931
|
+
ipns: {
|
|
2932
|
+
encode: encodes.ipns,
|
|
2933
|
+
decode: decodes.ipns
|
|
2934
|
+
},
|
|
2935
|
+
arweave: {
|
|
2936
|
+
encode: encodes.arweave,
|
|
2937
|
+
decode: decodes.base64
|
|
2938
|
+
},
|
|
2939
|
+
default: {
|
|
2940
|
+
encode: encodes.utf8,
|
|
2941
|
+
decode: decodes.utf8
|
|
2942
|
+
}
|
|
2943
|
+
};
|
|
2944
|
+
|
|
2945
|
+
// ../../node_modules/.pnpm/@ensdomains+content-hash@3.1.0-rc.1/node_modules/@ensdomains/content-hash/dist/esm/index.js
|
|
2946
|
+
var decode = (contentHash) => {
|
|
2947
|
+
const bytes = hexStringToBytes(contentHash);
|
|
2948
|
+
const [code, offset] = decodeVarint(bytes);
|
|
2949
|
+
const value = bytes.slice(offset);
|
|
2950
|
+
const name = codeToName[code];
|
|
2951
|
+
let profile = profiles[name];
|
|
2952
|
+
if (!profile)
|
|
2953
|
+
profile = profiles["default"];
|
|
2954
|
+
return profile.decode(value);
|
|
2955
|
+
};
|
|
2956
|
+
var encode = (name, value) => {
|
|
2957
|
+
let profile = profiles[name];
|
|
2958
|
+
if (!profile)
|
|
2959
|
+
profile = profiles["default"];
|
|
2960
|
+
const bytes = profile.encode(value);
|
|
2961
|
+
const code = nameToCode[name];
|
|
2962
|
+
const codeBytes = encodeVarint(code, new Uint8Array(varintEncodingLength(code)));
|
|
2963
|
+
return bytesToHexString(concatUint8Arrays(codeBytes, bytes));
|
|
2964
|
+
};
|
|
2965
|
+
|
|
2966
|
+
// ../integration-test-env/src/devnet/fixtures.ts
|
|
2967
|
+
import { asNormalizedAddress, toNormalizedAddress as toNormalizedAddress3 } from "enssdk";
|
|
2968
|
+
import { mnemonicToAccount } from "viem/accounts";
|
|
2969
|
+
var mnemonic = "test test test test test test test test test test test junk";
|
|
2970
|
+
function createAccount(addressIndex, resolver) {
|
|
2971
|
+
const account = mnemonicToAccount(mnemonic, { addressIndex });
|
|
2972
|
+
return {
|
|
2973
|
+
...account,
|
|
2974
|
+
address: toNormalizedAddress3(account.address),
|
|
2975
|
+
resolver
|
|
2976
|
+
};
|
|
2977
|
+
}
|
|
2978
|
+
var accounts = {
|
|
2979
|
+
deployer: createAccount(0, asNormalizedAddress("0x9c97ec2d79944fa55aa2eb6385bc8711cacf18d2")),
|
|
2980
|
+
owner: createAccount(1, asNormalizedAddress("0x8550d35164e7f86bb6adf4cedb3f012913c9d563")),
|
|
2981
|
+
user: createAccount(2, asNormalizedAddress("0x98a84b915ffe27241033ac8f29c6b7849a0fb6e4")),
|
|
2982
|
+
user2: createAccount(3, asNormalizedAddress("0xd04f8f3726a417cfadeea604fc94cf66112b9af6"))
|
|
2983
|
+
};
|
|
2984
|
+
var addresses = {
|
|
2985
|
+
one: asNormalizedAddress(`0x${"1".repeat(40)}`)
|
|
2986
|
+
};
|
|
2987
|
+
var getRawAddress = (coinName, address) => {
|
|
2988
|
+
const coder = getCoderByCoinName(coinName);
|
|
2989
|
+
return {
|
|
2990
|
+
coinType: coder.coinType,
|
|
2991
|
+
raw: bytesToHex2(coder.decode(address)),
|
|
2992
|
+
address
|
|
2993
|
+
};
|
|
2994
|
+
};
|
|
2995
|
+
var getRawContenthash = (codec, input) => {
|
|
2996
|
+
const encoded = encode(codec, input);
|
|
2997
|
+
return {
|
|
2998
|
+
raw: `0x${encoded}`,
|
|
2999
|
+
// decode normalizes values (e.g. IPFS CIDv0 input → CIDv1 decoded, IPNS peer id → base36 CID)
|
|
3000
|
+
decoded: decode(encoded)
|
|
3001
|
+
};
|
|
3002
|
+
};
|
|
3003
|
+
var testEthTextRecords = {
|
|
3004
|
+
avatar: { key: "avatar", value: "https://example.com/avatar.png" },
|
|
3005
|
+
twitter: { key: "com.twitter", value: "ensdomains" },
|
|
3006
|
+
github: { key: "com.github", value: "@ensdomains" },
|
|
3007
|
+
x: { key: "com.x", value: "this_is_real_ensdomains_not_twitter_but_x_haha" },
|
|
3008
|
+
telegram: { key: "org.telegram", value: "t.me/ensdomains" },
|
|
3009
|
+
url: { key: "url", value: "https://ens.domains" },
|
|
3010
|
+
email: { key: "email", value: "test@ens.domains" },
|
|
3011
|
+
description: { key: "description", value: "test.eth" },
|
|
3012
|
+
header: { key: "header", value: "https://example.com/header.png" }
|
|
3013
|
+
};
|
|
3014
|
+
var rawAddresses = {
|
|
3015
|
+
bitcoin: getRawAddress("btc", "bc1qw508d6qejxtdg4y5r3zarvary0c5xw7kv8f3t4"),
|
|
3016
|
+
litecoin: getRawAddress("ltc", "LaMT348PWRnrqeeWArpwQPbuanpXDZGEUz"),
|
|
3017
|
+
dogecoin: getRawAddress("doge", "DBXu2kgc3xtvCUWFcxFE3r9hEYgmuaaCyD"),
|
|
3018
|
+
monacoin: getRawAddress("mona", "MHxgS2XMXjeJ4if2PRRbWYcdwZPWfdwaDT"),
|
|
3019
|
+
rootstock: getRawAddress("rbtc", "0x5aaEB6053f3e94c9b9a09f33669435E7ef1bEAeD"),
|
|
3020
|
+
binance: getRawAddress("bnb", "bnb1grpf0955h0ykzq3ar5nmum7y6gdfl6lxfn46h2"),
|
|
3021
|
+
solana: getRawAddress("sol", "FncazAs6omJJjtLVzquzT9KoyXn6tFixr9kGjr42ktLj")
|
|
3022
|
+
};
|
|
3023
|
+
var fixtures = {
|
|
3024
|
+
abiBytes: `0x${"01".repeat(32)}`,
|
|
3025
|
+
fourBytesInterface: "0x11100111",
|
|
3026
|
+
publicKeyX: `0x${"02".repeat(32)}`,
|
|
3027
|
+
publicKeyY: `0x${"03".repeat(32)}`,
|
|
3028
|
+
rawAddresses,
|
|
3029
|
+
textRecords: testEthTextRecords
|
|
3030
|
+
};
|
|
3031
|
+
var contenthashFixtures = {
|
|
3032
|
+
// CIDv0 input — decodes back to CIDv1
|
|
3033
|
+
ipfs: getRawContenthash("ipfs", "QmRAQB6YaCyidP37UdDnjFY5vQuiBrcqdyoW1CuDgwxkD4"),
|
|
3034
|
+
swarm: getRawContenthash(
|
|
3035
|
+
"swarm",
|
|
3036
|
+
"d1de9994b4d039f6548d191eb26786769f580809256b4685ef316805265ea162"
|
|
3037
|
+
),
|
|
3038
|
+
ipns: getRawContenthash("ipns", "12D3KooWG4NvqQVczTrWY1H2tvsJmbQf5bbA3xGYXC4FM3wWCfE4"),
|
|
3039
|
+
onion: getRawContenthash("onion", "zqktlwi4fecvo6ri"),
|
|
3040
|
+
onion3: getRawContenthash("onion3", "p53lf57qovyuvwsc6xnrppyply3vtqm7l6pcobkmyqsiofyeznfu5uqd"),
|
|
3041
|
+
skynet: getRawContenthash("skynet", "CABAB_1Dt0FJsxqsu_J4TodNCbCGvtFf1Uys_3EgzOlTcg"),
|
|
3042
|
+
arweave: getRawContenthash("arweave", "ys32Pt8uC7TrVxHdOLByOspfPEq2LO63wREHQIM9SJQ"),
|
|
3043
|
+
empty: { raw: "0x", decoded: null },
|
|
3044
|
+
invalid: { raw: "0xdeadbeef", decoded: null },
|
|
3045
|
+
zero: {
|
|
3046
|
+
raw: "0x0000000000000000000000000000000000000000000000000000000000000000",
|
|
3047
|
+
decoded: null
|
|
3048
|
+
}
|
|
3049
|
+
};
|
|
3050
|
+
var contenthashSubnames = Object.entries(contenthashFixtures).map(([label, fixture]) => ({
|
|
3051
|
+
label,
|
|
3052
|
+
name: `${label}.contenthash.eth`,
|
|
3053
|
+
records: { contenthash: fixture.raw }
|
|
3054
|
+
}));
|
|
3055
|
+
|
|
3056
|
+
// src/omnigraph-api/example-queries.ts
|
|
1970
3057
|
var SEPOLIA_V2_V2_ETH_REGISTRY = getDatasourceContract(
|
|
1971
3058
|
ENSNamespaceIds3.SepoliaV2,
|
|
1972
3059
|
DatasourceNames2.ENSv2Root,
|
|
@@ -1982,25 +3069,26 @@ var ENS_TEST_ENV_V2_ETH_REGISTRAR = getDatasourceContract(
|
|
|
1982
3069
|
DatasourceNames2.ENSv2Root,
|
|
1983
3070
|
"ETHRegistrar"
|
|
1984
3071
|
);
|
|
1985
|
-
var VITALIK_ADDRESS =
|
|
1986
|
-
var
|
|
1987
|
-
|
|
1988
|
-
|
|
1989
|
-
var SEPOLIA_V2_ADDRESS_WITH_PERMISSIONS = toNormalizedAddress3(
|
|
1990
|
-
"0x4c65a1c8d330ce1c3f60e00cd55709ba5fe2e090"
|
|
3072
|
+
var VITALIK_ADDRESS = toNormalizedAddress4("0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045");
|
|
3073
|
+
var SEPOLIA_V2_ACCOUNT = toNormalizedAddress4("0x801d2e48d378f161dba7ad7ad002ad557714c191");
|
|
3074
|
+
var SEPOLIA_V2_ACCOUNT_WITH_V1_AND_V2 = toNormalizedAddress4(
|
|
3075
|
+
"0xffffffffff52d316b7bd028358089bc8066b8f80"
|
|
1991
3076
|
);
|
|
1992
3077
|
var DEVNET_NAME_WITH_OWNED_RESOLVER = asInterpretedName("example.eth");
|
|
1993
|
-
var
|
|
3078
|
+
var SEPOLIA_V2_NAME = asInterpretedName("roppp.eth");
|
|
3079
|
+
var VITALIK_NAME = asInterpretedName("vitalik.eth");
|
|
3080
|
+
var GREG_NAME = asInterpretedName("gregskril.eth");
|
|
3081
|
+
var GREG_ADDRESS = toNormalizedAddress4("0x179a862703a4adfb29896552df9e307980d19285");
|
|
3082
|
+
var OFFCHAIN_NAME = asInterpretedName("patricio.onpoap.eth");
|
|
1994
3083
|
var MAINNET_PUBLIC_RESOLVER = getDatasourceContract(
|
|
1995
3084
|
ENSNamespaceIds3.Mainnet,
|
|
1996
3085
|
DatasourceNames2.ReverseResolverRoot,
|
|
1997
3086
|
"DefaultPublicResolver5"
|
|
1998
3087
|
);
|
|
1999
|
-
var
|
|
2000
|
-
|
|
2001
|
-
|
|
2002
|
-
|
|
2003
|
-
);
|
|
3088
|
+
var SEPOLIA_V2_RESOLVER_WITH_RECORDS = {
|
|
3089
|
+
chainId: 11155111,
|
|
3090
|
+
address: toNormalizedAddress4("0x8fade66b79cc9f707ab26799354482eb93a5b7dd")
|
|
3091
|
+
};
|
|
2004
3092
|
function getGraphqlApiExampleQueryById(id) {
|
|
2005
3093
|
const found = graphqlApiExampleQueryById.get(id);
|
|
2006
3094
|
if (!found) {
|
|
@@ -2014,18 +3102,44 @@ var GRAPHQL_API_EXAMPLE_QUERIES = [
|
|
|
2014
3102
|
////////////////
|
|
2015
3103
|
{
|
|
2016
3104
|
id: "hello-world",
|
|
2017
|
-
query:
|
|
2018
|
-
#
|
|
2019
|
-
|
|
2020
|
-
|
|
2021
|
-
#
|
|
2022
|
-
#
|
|
2023
|
-
|
|
2024
|
-
#
|
|
2025
|
-
|
|
2026
|
-
|
|
3105
|
+
query: `query HelloWorld($address: Address!) {
|
|
3106
|
+
# Lookup an Account by address.
|
|
3107
|
+
account(by: { address: $address }) {
|
|
3108
|
+
resolve {
|
|
3109
|
+
# Reverse resolve the ENS primary name of the account
|
|
3110
|
+
# using a convenient ETHEREUM alias for mainnet.
|
|
3111
|
+
primaryName(by: { chainName: ETHEREUM }) {
|
|
3112
|
+
# Get the regular interpreted variant of the primary name
|
|
3113
|
+
# and also the special beautified variant that optimizes names
|
|
3114
|
+
# containing special characters such as emojis for proper display in interfaces.
|
|
3115
|
+
name { interpreted beautified }
|
|
3116
|
+
resolve {
|
|
3117
|
+
# If the account has a primary name on Ethereum (mainnet),
|
|
3118
|
+
# forward resolve the interpreted ENS profile of that name in the same query!
|
|
3119
|
+
profile {
|
|
3120
|
+
description
|
|
3121
|
+
avatar { httpUrl }
|
|
3122
|
+
addresses { ethereum bitcoin }
|
|
3123
|
+
socials {
|
|
3124
|
+
twitter { handle httpUrl }
|
|
3125
|
+
github { handle httpUrl }
|
|
3126
|
+
}
|
|
3127
|
+
}
|
|
3128
|
+
}
|
|
3129
|
+
}
|
|
3130
|
+
}
|
|
3131
|
+
|
|
3132
|
+
# Also load the count of ENSv1 and ENSv2 domains owned by the account
|
|
3133
|
+
# to see if they have domains they should upgrade to ENSv2
|
|
3134
|
+
v1DomainsCount: domains(where: { version: ENSv1 }) { totalCount }
|
|
3135
|
+
v2DomainsCount: domains(where: { version: ENSv2 }) { totalCount }
|
|
3136
|
+
}
|
|
2027
3137
|
}`,
|
|
2028
|
-
variables: {
|
|
3138
|
+
variables: {
|
|
3139
|
+
default: { address: VITALIK_ADDRESS },
|
|
3140
|
+
[ENSNamespaceIds3.EnsTestEnv]: { address: accounts.owner.address },
|
|
3141
|
+
[ENSNamespaceIds3.SepoliaV2]: { address: SEPOLIA_V2_ACCOUNT_WITH_V1_AND_V2 }
|
|
3142
|
+
}
|
|
2029
3143
|
},
|
|
2030
3144
|
/////////////////
|
|
2031
3145
|
// Find Domains
|
|
@@ -2061,17 +3175,40 @@ query FindDomains(
|
|
|
2061
3175
|
order: { by: "NAME", dir: "DESC" }
|
|
2062
3176
|
},
|
|
2063
3177
|
[ENSNamespaceIds3.SepoliaV2]: {
|
|
2064
|
-
name: { starts_with: "
|
|
3178
|
+
name: { starts_with: "sf" },
|
|
2065
3179
|
order: { by: "NAME", dir: "DESC" }
|
|
2066
3180
|
}
|
|
2067
3181
|
}
|
|
2068
3182
|
},
|
|
2069
|
-
///////////////////
|
|
2070
|
-
// Domain By Name
|
|
2071
|
-
///////////////////
|
|
2072
3183
|
{
|
|
2073
3184
|
id: "domain-by-name",
|
|
2074
3185
|
query: `
|
|
3186
|
+
query DomainByName($name: InterpretedName!) {
|
|
3187
|
+
domain(by: { name: $name }) {
|
|
3188
|
+
canonical { name { beautified } }
|
|
3189
|
+
owner { address }
|
|
3190
|
+
resolve {
|
|
3191
|
+
profile {
|
|
3192
|
+
description
|
|
3193
|
+
addresses {
|
|
3194
|
+
ethereum
|
|
3195
|
+
}
|
|
3196
|
+
}
|
|
3197
|
+
}
|
|
3198
|
+
}
|
|
3199
|
+
}`,
|
|
3200
|
+
variables: {
|
|
3201
|
+
default: { name: "eth" },
|
|
3202
|
+
[ENSNamespaceIds3.SepoliaV2]: { name: SEPOLIA_V2_NAME },
|
|
3203
|
+
[ENSNamespaceIds3.Mainnet]: { name: VITALIK_NAME }
|
|
3204
|
+
}
|
|
3205
|
+
},
|
|
3206
|
+
////////////////////////////////
|
|
3207
|
+
// Domain By Name Type Condition
|
|
3208
|
+
////////////////////////////////
|
|
3209
|
+
{
|
|
3210
|
+
id: "domain-by-name-type-condition",
|
|
3211
|
+
query: `
|
|
2075
3212
|
query DomainByName($name: InterpretedName!) {
|
|
2076
3213
|
domain(by: {name: $name}) {
|
|
2077
3214
|
__typename
|
|
@@ -2088,7 +3225,7 @@ query DomainByName($name: InterpretedName!) {
|
|
|
2088
3225
|
}`,
|
|
2089
3226
|
variables: {
|
|
2090
3227
|
default: { name: "eth" },
|
|
2091
|
-
[ENSNamespaceIds3.SepoliaV2]: { name:
|
|
3228
|
+
[ENSNamespaceIds3.SepoliaV2]: { name: SEPOLIA_V2_NAME }
|
|
2092
3229
|
}
|
|
2093
3230
|
},
|
|
2094
3231
|
///////////////////////
|
|
@@ -2132,10 +3269,160 @@ query DomainRegistration($name: InterpretedName!) {
|
|
|
2132
3269
|
}
|
|
2133
3270
|
}`,
|
|
2134
3271
|
variables: {
|
|
2135
|
-
default: { name:
|
|
2136
|
-
[ENSNamespaceIds3.SepoliaV2]: { name:
|
|
3272
|
+
default: { name: VITALIK_NAME },
|
|
3273
|
+
[ENSNamespaceIds3.SepoliaV2]: { name: SEPOLIA_V2_NAME }
|
|
2137
3274
|
}
|
|
2138
3275
|
},
|
|
3276
|
+
////////////////////
|
|
3277
|
+
// Domain Records
|
|
3278
|
+
////////////////////
|
|
3279
|
+
{
|
|
3280
|
+
id: "domain-records",
|
|
3281
|
+
query: `
|
|
3282
|
+
query DomainRecords($name: InterpretedName!) {
|
|
3283
|
+
domain(by: {name: $name}) {
|
|
3284
|
+
canonical {
|
|
3285
|
+
name {
|
|
3286
|
+
interpreted
|
|
3287
|
+
}
|
|
3288
|
+
}
|
|
3289
|
+
resolve {
|
|
3290
|
+
records {
|
|
3291
|
+
addresses(coinTypes: [60, 2147483658, 501]) {
|
|
3292
|
+
coinType
|
|
3293
|
+
address
|
|
3294
|
+
}
|
|
3295
|
+
texts(keys: ["description", "avatar", "url", "com.github", "com.twitter"]) {
|
|
3296
|
+
key
|
|
3297
|
+
value
|
|
3298
|
+
}
|
|
3299
|
+
contenthash
|
|
3300
|
+
}
|
|
3301
|
+
}
|
|
3302
|
+
}
|
|
3303
|
+
}`,
|
|
3304
|
+
variables: {
|
|
3305
|
+
default: { name: GREG_NAME },
|
|
3306
|
+
[ENSNamespaceIds3.EnsTestEnv]: {
|
|
3307
|
+
name: DEVNET_NAME_WITH_OWNED_RESOLVER
|
|
3308
|
+
},
|
|
3309
|
+
[ENSNamespaceIds3.SepoliaV2]: {
|
|
3310
|
+
name: SEPOLIA_V2_NAME
|
|
3311
|
+
}
|
|
3312
|
+
}
|
|
3313
|
+
},
|
|
3314
|
+
{
|
|
3315
|
+
id: "domain-profile",
|
|
3316
|
+
query: `
|
|
3317
|
+
query DomainProfile($name: InterpretedName!) {
|
|
3318
|
+
domain(by: {name: $name}) {
|
|
3319
|
+
resolve {
|
|
3320
|
+
profile {
|
|
3321
|
+
description
|
|
3322
|
+
avatar {
|
|
3323
|
+
httpUrl
|
|
3324
|
+
}
|
|
3325
|
+
addresses {
|
|
3326
|
+
ethereum
|
|
3327
|
+
base
|
|
3328
|
+
solana
|
|
3329
|
+
bitcoin
|
|
3330
|
+
rootstock
|
|
3331
|
+
}
|
|
3332
|
+
socials {
|
|
3333
|
+
github {
|
|
3334
|
+
handle
|
|
3335
|
+
httpUrl
|
|
3336
|
+
}
|
|
3337
|
+
twitter {
|
|
3338
|
+
handle
|
|
3339
|
+
httpUrl
|
|
3340
|
+
}
|
|
3341
|
+
}
|
|
3342
|
+
website {
|
|
3343
|
+
httpUrl
|
|
3344
|
+
}
|
|
3345
|
+
header {
|
|
3346
|
+
httpUrl
|
|
3347
|
+
}
|
|
3348
|
+
}
|
|
3349
|
+
}
|
|
3350
|
+
}
|
|
3351
|
+
}`,
|
|
3352
|
+
variables: { default: { name: GREG_NAME } }
|
|
3353
|
+
},
|
|
3354
|
+
{
|
|
3355
|
+
id: "domain-profile-and-records",
|
|
3356
|
+
query: `
|
|
3357
|
+
query DomainProfileAndRecords($name: InterpretedName!) {
|
|
3358
|
+
domain(by: { name: $name }) {
|
|
3359
|
+
resolve {
|
|
3360
|
+
profile {
|
|
3361
|
+
avatar {
|
|
3362
|
+
httpUrl
|
|
3363
|
+
}
|
|
3364
|
+
addresses {
|
|
3365
|
+
ethereum
|
|
3366
|
+
solana
|
|
3367
|
+
}
|
|
3368
|
+
socials {
|
|
3369
|
+
github {
|
|
3370
|
+
handle
|
|
3371
|
+
httpUrl
|
|
3372
|
+
}
|
|
3373
|
+
twitter {
|
|
3374
|
+
handle
|
|
3375
|
+
httpUrl
|
|
3376
|
+
}
|
|
3377
|
+
}
|
|
3378
|
+
website {
|
|
3379
|
+
httpUrl
|
|
3380
|
+
}
|
|
3381
|
+
}
|
|
3382
|
+
records {
|
|
3383
|
+
addresses(coinTypes: [60, 501]) {
|
|
3384
|
+
coinType
|
|
3385
|
+
address
|
|
3386
|
+
}
|
|
3387
|
+
texts(keys: ["avatar", "com.twitter", "com.github", "url"]) {
|
|
3388
|
+
key
|
|
3389
|
+
value
|
|
3390
|
+
}
|
|
3391
|
+
}
|
|
3392
|
+
}
|
|
3393
|
+
}
|
|
3394
|
+
}`,
|
|
3395
|
+
variables: { default: { name: GREG_NAME } }
|
|
3396
|
+
},
|
|
3397
|
+
////////////////////////////////////
|
|
3398
|
+
// Offchain Name (UnindexedDomain)
|
|
3399
|
+
////////////////////////////////////
|
|
3400
|
+
{
|
|
3401
|
+
id: "offchain-name",
|
|
3402
|
+
query: `
|
|
3403
|
+
query OffchainName($name: InterpretedName!) {
|
|
3404
|
+
domain(by: { name: $name }) {
|
|
3405
|
+
# Resolvable-but-unindexed names (offchain / CCIP-Read) surface as UnindexedDomain
|
|
3406
|
+
__typename
|
|
3407
|
+
id
|
|
3408
|
+
canonical { name { interpreted } }
|
|
3409
|
+
resolver {
|
|
3410
|
+
# the wildcard Resolver that ENS Forward Resolution (ENSIP-10) lands on
|
|
3411
|
+
effective {
|
|
3412
|
+
extended
|
|
3413
|
+
contract { chainId address }
|
|
3414
|
+
}
|
|
3415
|
+
}
|
|
3416
|
+
resolve {
|
|
3417
|
+
records {
|
|
3418
|
+
addresses(coinTypes: [60]) { coinType address }
|
|
3419
|
+
texts(keys: ["avatar", "com.twitter", "description"]) { key value }
|
|
3420
|
+
}
|
|
3421
|
+
}
|
|
3422
|
+
}
|
|
3423
|
+
}`,
|
|
3424
|
+
variables: { default: { name: OFFCHAIN_NAME } }
|
|
3425
|
+
},
|
|
2139
3426
|
//////////////////////
|
|
2140
3427
|
// Domain Subdomains
|
|
2141
3428
|
//////////////////////
|
|
@@ -2145,7 +3432,34 @@ query DomainRegistration($name: InterpretedName!) {
|
|
|
2145
3432
|
query DomainSubdomains($name: InterpretedName!) {
|
|
2146
3433
|
domain(by: {name: $name}) {
|
|
2147
3434
|
canonical { name { interpreted beautified } }
|
|
2148
|
-
subdomains(first: 10
|
|
3435
|
+
subdomains(first: 10, order: {
|
|
3436
|
+
by: NAME,
|
|
3437
|
+
dir: ASC
|
|
3438
|
+
}) {
|
|
3439
|
+
edges {
|
|
3440
|
+
node {
|
|
3441
|
+
canonical { name { interpreted beautified } }
|
|
3442
|
+
}
|
|
3443
|
+
}
|
|
3444
|
+
}
|
|
3445
|
+
}
|
|
3446
|
+
}`,
|
|
3447
|
+
variables: {
|
|
3448
|
+
default: { name: "eth" },
|
|
3449
|
+
// in mainnet there is too many subdomains of eth
|
|
3450
|
+
[ENSNamespaceIds3.Mainnet]: { name: "base.eth" }
|
|
3451
|
+
}
|
|
3452
|
+
},
|
|
3453
|
+
////////////////////////////////////
|
|
3454
|
+
// Most Recently Registered Subdomains
|
|
3455
|
+
////////////////////////////////////
|
|
3456
|
+
{
|
|
3457
|
+
id: "domain-subdomains-recently-registered",
|
|
3458
|
+
query: `
|
|
3459
|
+
query RecentlyRegisteredSubdomains($name: InterpretedName!) {
|
|
3460
|
+
domain(by: {name: $name}) {
|
|
3461
|
+
canonical { name { interpreted beautified } }
|
|
3462
|
+
subdomains(first: 10, order: {by: REGISTRATION_TIMESTAMP, dir: DESC}) {
|
|
2149
3463
|
edges {
|
|
2150
3464
|
node {
|
|
2151
3465
|
canonical { name { interpreted beautified } }
|
|
@@ -2206,7 +3520,7 @@ query DomainEvents($name: InterpretedName!) {
|
|
|
2206
3520
|
}`,
|
|
2207
3521
|
variables: {
|
|
2208
3522
|
default: { name: "newowner.eth" },
|
|
2209
|
-
[ENSNamespaceIds3.SepoliaV2]: { name:
|
|
3523
|
+
[ENSNamespaceIds3.SepoliaV2]: { name: SEPOLIA_V2_NAME }
|
|
2210
3524
|
}
|
|
2211
3525
|
},
|
|
2212
3526
|
////////////////////
|
|
@@ -2232,7 +3546,64 @@ query AccountDomains(
|
|
|
2232
3546
|
variables: {
|
|
2233
3547
|
default: { address: VITALIK_ADDRESS },
|
|
2234
3548
|
[ENSNamespaceIds3.EnsTestEnv]: { address: accounts.owner.address },
|
|
2235
|
-
[ENSNamespaceIds3.SepoliaV2]: { address:
|
|
3549
|
+
[ENSNamespaceIds3.SepoliaV2]: { address: SEPOLIA_V2_ACCOUNT }
|
|
3550
|
+
}
|
|
3551
|
+
},
|
|
3552
|
+
/////////////////////////
|
|
3553
|
+
// Account Primary Names
|
|
3554
|
+
/////////////////////////
|
|
3555
|
+
{
|
|
3556
|
+
id: "account-primary-names",
|
|
3557
|
+
query: `
|
|
3558
|
+
query AccountPrimaryNames($address: Address!) {
|
|
3559
|
+
account(by: { address: $address }) {
|
|
3560
|
+
address
|
|
3561
|
+
resolve {
|
|
3562
|
+
onePrimaryName: primaryName(by: { chainName: OPTIMISM }) {
|
|
3563
|
+
chainName
|
|
3564
|
+
name { interpreted beautified }
|
|
3565
|
+
}
|
|
3566
|
+
|
|
3567
|
+
twoPrimaryNames: primaryNames(where: { chainNames: [ETHEREUM, BASE] }) {
|
|
3568
|
+
chainName
|
|
3569
|
+
name { interpreted beautified }
|
|
3570
|
+
}
|
|
3571
|
+
}
|
|
3572
|
+
}
|
|
3573
|
+
}`,
|
|
3574
|
+
variables: {
|
|
3575
|
+
default: { address: GREG_ADDRESS },
|
|
3576
|
+
[ENSNamespaceIds3.EnsTestEnv]: { address: accounts.owner.address },
|
|
3577
|
+
[ENSNamespaceIds3.SepoliaV2]: { address: SEPOLIA_V2_ACCOUNT }
|
|
3578
|
+
}
|
|
3579
|
+
},
|
|
3580
|
+
{
|
|
3581
|
+
id: "account-primary-name-records",
|
|
3582
|
+
query: `
|
|
3583
|
+
query AccountPrimaryNameRecords($address: Address!) {
|
|
3584
|
+
account(by: { address: $address }) {
|
|
3585
|
+
address
|
|
3586
|
+
resolve {
|
|
3587
|
+
primaryName(by: { chainName: ETHEREUM }) {
|
|
3588
|
+
name { interpreted beautified }
|
|
3589
|
+
resolve {
|
|
3590
|
+
profile {
|
|
3591
|
+
description
|
|
3592
|
+
socials {
|
|
3593
|
+
twitter {
|
|
3594
|
+
httpUrl
|
|
3595
|
+
}
|
|
3596
|
+
}
|
|
3597
|
+
}
|
|
3598
|
+
}
|
|
3599
|
+
}
|
|
3600
|
+
}
|
|
3601
|
+
}
|
|
3602
|
+
}`,
|
|
3603
|
+
variables: {
|
|
3604
|
+
default: { address: VITALIK_ADDRESS },
|
|
3605
|
+
[ENSNamespaceIds3.EnsTestEnv]: { address: accounts.owner.address },
|
|
3606
|
+
[ENSNamespaceIds3.SepoliaV2]: { address: SEPOLIA_V2_ACCOUNT }
|
|
2236
3607
|
}
|
|
2237
3608
|
},
|
|
2238
3609
|
////////////////////
|
|
@@ -2251,7 +3622,7 @@ query AccountEvents(
|
|
|
2251
3622
|
variables: {
|
|
2252
3623
|
default: { address: VITALIK_ADDRESS },
|
|
2253
3624
|
[ENSNamespaceIds3.EnsTestEnv]: { address: accounts.deployer.address },
|
|
2254
|
-
[ENSNamespaceIds3.SepoliaV2]: { address:
|
|
3625
|
+
[ENSNamespaceIds3.SepoliaV2]: { address: SEPOLIA_V2_ACCOUNT }
|
|
2255
3626
|
}
|
|
2256
3627
|
},
|
|
2257
3628
|
/////////////////////
|
|
@@ -2336,7 +3707,7 @@ query PermissionsByUser($address: Address!) {
|
|
|
2336
3707
|
}`,
|
|
2337
3708
|
variables: {
|
|
2338
3709
|
default: { address: accounts.deployer.address },
|
|
2339
|
-
[ENSNamespaceIds3.SepoliaV2]: { address:
|
|
3710
|
+
[ENSNamespaceIds3.SepoliaV2]: { address: SEPOLIA_V2_ACCOUNT }
|
|
2340
3711
|
}
|
|
2341
3712
|
},
|
|
2342
3713
|
//////////////////////////////////
|
|
@@ -2362,7 +3733,7 @@ query AccountResolverPermissions($address: Address!) {
|
|
|
2362
3733
|
}`,
|
|
2363
3734
|
variables: {
|
|
2364
3735
|
default: { address: accounts.deployer.address },
|
|
2365
|
-
[ENSNamespaceIds3.SepoliaV2]: { address:
|
|
3736
|
+
[ENSNamespaceIds3.SepoliaV2]: { address: SEPOLIA_V2_ACCOUNT }
|
|
2366
3737
|
}
|
|
2367
3738
|
},
|
|
2368
3739
|
//////////////////////////////
|
|
@@ -2375,17 +3746,20 @@ query DomainResolver($name: InterpretedName!) {
|
|
|
2375
3746
|
domain(by: { name: $name }) {
|
|
2376
3747
|
resolver {
|
|
2377
3748
|
assigned {
|
|
2378
|
-
|
|
2379
|
-
|
|
2380
|
-
|
|
3749
|
+
contract {
|
|
3750
|
+
address
|
|
3751
|
+
}
|
|
3752
|
+
events(first: 5) {
|
|
3753
|
+
edges { node { topics data timestamp } }
|
|
3754
|
+
}
|
|
2381
3755
|
}
|
|
2382
3756
|
}
|
|
2383
3757
|
}
|
|
2384
3758
|
}`,
|
|
2385
3759
|
variables: {
|
|
2386
|
-
default: { name:
|
|
3760
|
+
default: { name: VITALIK_NAME },
|
|
2387
3761
|
[ENSNamespaceIds3.EnsTestEnv]: { name: DEVNET_NAME_WITH_OWNED_RESOLVER },
|
|
2388
|
-
[ENSNamespaceIds3.SepoliaV2]: { name:
|
|
3762
|
+
[ENSNamespaceIds3.SepoliaV2]: { name: SEPOLIA_V2_NAME }
|
|
2389
3763
|
}
|
|
2390
3764
|
},
|
|
2391
3765
|
////////////////////////
|
|
@@ -2417,7 +3791,7 @@ query ResolverByAddress($contract: AccountIdInput!) {
|
|
|
2417
3791
|
}`,
|
|
2418
3792
|
variables: {
|
|
2419
3793
|
default: { contract: MAINNET_PUBLIC_RESOLVER },
|
|
2420
|
-
[ENSNamespaceIds3.SepoliaV2]: { contract:
|
|
3794
|
+
[ENSNamespaceIds3.SepoliaV2]: { contract: SEPOLIA_V2_RESOLVER_WITH_RECORDS }
|
|
2421
3795
|
}
|
|
2422
3796
|
},
|
|
2423
3797
|
//////////////
|
|
@@ -2427,31 +3801,19 @@ query ResolverByAddress($contract: AccountIdInput!) {
|
|
|
2427
3801
|
id: "namegraph",
|
|
2428
3802
|
query: `
|
|
2429
3803
|
query Namegraph {
|
|
2430
|
-
|
|
2431
|
-
id
|
|
2432
|
-
|
|
2433
|
-
|
|
2434
|
-
|
|
2435
|
-
|
|
2436
|
-
|
|
2437
|
-
|
|
2438
|
-
edges {
|
|
2439
|
-
node {
|
|
2440
|
-
canonical { name { interpreted beautified } }
|
|
2441
|
-
|
|
2442
|
-
subdomains {
|
|
2443
|
-
edges {
|
|
2444
|
-
node {
|
|
2445
|
-
canonical { name { interpreted beautified } }
|
|
2446
|
-
}
|
|
2447
|
-
}
|
|
2448
|
-
}
|
|
2449
|
-
}
|
|
2450
|
-
}
|
|
3804
|
+
domain(by: { name: "eth" }) {
|
|
3805
|
+
registry { id contract { chainId address } }
|
|
3806
|
+
parent { id }
|
|
3807
|
+
subregistry {
|
|
3808
|
+
domains {
|
|
3809
|
+
edges {
|
|
3810
|
+
node {
|
|
3811
|
+
canonical { name { beautified } }
|
|
2451
3812
|
}
|
|
2452
3813
|
}
|
|
2453
3814
|
}
|
|
2454
3815
|
}
|
|
3816
|
+
subdomains { edges { node { canonical { name { beautified } } } } }
|
|
2455
3817
|
}
|
|
2456
3818
|
}`,
|
|
2457
3819
|
variables: { default: {} }
|
|
@@ -2470,7 +3832,7 @@ query AccountMigratedNames($address: Address!) {
|
|
|
2470
3832
|
}`,
|
|
2471
3833
|
variables: {
|
|
2472
3834
|
default: { address: VITALIK_ADDRESS },
|
|
2473
|
-
[ENSNamespaceIds3.SepoliaV2]: { address:
|
|
3835
|
+
[ENSNamespaceIds3.SepoliaV2]: { address: SEPOLIA_V2_ACCOUNT_WITH_V1_AND_V2 }
|
|
2474
3836
|
}
|
|
2475
3837
|
},
|
|
2476
3838
|
{
|
|
@@ -2487,6 +3849,31 @@ query GetEthDomains {
|
|
|
2487
3849
|
}
|
|
2488
3850
|
}`,
|
|
2489
3851
|
variables: { default: {} }
|
|
3852
|
+
},
|
|
3853
|
+
{
|
|
3854
|
+
id: "accelerate-resolve",
|
|
3855
|
+
query: `
|
|
3856
|
+
query AccelerateResolve($address: Address!) {
|
|
3857
|
+
account(by: { address: $address }) {
|
|
3858
|
+
address
|
|
3859
|
+
# resolve is automatically accelerated. To disable, resolve(accelerate: false)
|
|
3860
|
+
resolve {
|
|
3861
|
+
acceleration { requested attempted }
|
|
3862
|
+
primaryName(by: { chainName: ETHEREUM }) {
|
|
3863
|
+
name { interpreted beautified }
|
|
3864
|
+
resolve {
|
|
3865
|
+
acceleration { requested attempted }
|
|
3866
|
+
profile { description }
|
|
3867
|
+
}
|
|
3868
|
+
}
|
|
3869
|
+
}
|
|
3870
|
+
}
|
|
3871
|
+
}`,
|
|
3872
|
+
variables: {
|
|
3873
|
+
default: { address: VITALIK_ADDRESS },
|
|
3874
|
+
[ENSNamespaceIds3.EnsTestEnv]: { address: accounts.owner.address },
|
|
3875
|
+
[ENSNamespaceIds3.SepoliaV2]: { address: SEPOLIA_V2_ACCOUNT_WITH_V1_AND_V2 }
|
|
3876
|
+
}
|
|
2490
3877
|
}
|
|
2491
3878
|
];
|
|
2492
3879
|
var graphqlApiExampleQueryById = new Map(
|
|
@@ -2525,7 +3912,8 @@ async function supportsInterface({
|
|
|
2525
3912
|
abi: EIP_165_ABI,
|
|
2526
3913
|
functionName: "supportsInterface",
|
|
2527
3914
|
address,
|
|
2528
|
-
args: [selector]
|
|
3915
|
+
args: [selector],
|
|
3916
|
+
retryEmptyResponse: false
|
|
2529
3917
|
});
|
|
2530
3918
|
} catch {
|
|
2531
3919
|
return false;
|
|
@@ -2734,29 +4122,29 @@ function buildRpcConfigsFromEnv(env, namespace) {
|
|
|
2734
4122
|
);
|
|
2735
4123
|
const rpcAutoGenMode = buildRpcAutoGenMode(env);
|
|
2736
4124
|
const rpcConfigs = {};
|
|
2737
|
-
for (const
|
|
2738
|
-
const specificValue = env[`RPC_URL_${
|
|
4125
|
+
for (const chain2 of chainsInNamespace) {
|
|
4126
|
+
const specificValue = env[`RPC_URL_${chain2.id}`];
|
|
2739
4127
|
if (specificValue) {
|
|
2740
|
-
rpcConfigs[serializeChainId(
|
|
4128
|
+
rpcConfigs[serializeChainId(chain2.id)] = specificValue;
|
|
2741
4129
|
continue;
|
|
2742
4130
|
}
|
|
2743
|
-
if (
|
|
4131
|
+
if (chain2.id === ensTestEnvChain.id) {
|
|
2744
4132
|
rpcConfigs[serializeChainId(ensTestEnvChain.id)] = ensTestEnvChain.rpcUrls.default.http[0];
|
|
2745
4133
|
continue;
|
|
2746
4134
|
}
|
|
2747
4135
|
const httpUrls = [
|
|
2748
4136
|
// alchemy, if specified and available
|
|
2749
|
-
alchemyApiKey && alchemySupportsChain(
|
|
4137
|
+
alchemyApiKey && alchemySupportsChain(chain2.id) && `https://${buildAlchemyBaseUrl(chain2.id, alchemyApiKey)}`,
|
|
2750
4138
|
// QuickNode, if specified and available
|
|
2751
|
-
quickNodeApiKey && quickNodeEndpointName && quickNodeSupportsChain(
|
|
4139
|
+
quickNodeApiKey && quickNodeEndpointName && quickNodeSupportsChain(chain2.id) && `https://${buildQuickNodeURL(chain2.id, quickNodeApiKey, quickNodeEndpointName)}`,
|
|
2752
4140
|
// dRPC, if specified and available
|
|
2753
|
-
dRPCKey && dRPCSupportsChain(
|
|
4141
|
+
dRPCKey && dRPCSupportsChain(chain2.id) && buildDRPCUrl(chain2.id, dRPCKey)
|
|
2754
4142
|
];
|
|
2755
|
-
const wsUrl = rpcAutoGenMode === RpcAutoGenModes.HttpAndWs && alchemyApiKey && alchemySupportsChain(
|
|
2756
|
-
`wss://${buildAlchemyBaseUrl(
|
|
4143
|
+
const wsUrl = rpcAutoGenMode === RpcAutoGenModes.HttpAndWs && alchemyApiKey && alchemySupportsChain(chain2.id) && //
|
|
4144
|
+
`wss://${buildAlchemyBaseUrl(chain2.id, alchemyApiKey)}`;
|
|
2757
4145
|
const urls = [...httpUrls, wsUrl].filter(Boolean);
|
|
2758
4146
|
if (urls.length > 0) {
|
|
2759
|
-
rpcConfigs[serializeChainId(
|
|
4147
|
+
rpcConfigs[serializeChainId(chain2.id)] = urls.join(
|
|
2760
4148
|
","
|
|
2761
4149
|
);
|
|
2762
4150
|
}
|
|
@@ -2934,8 +4322,8 @@ import { isAddressEqual as isAddressEqual4, zeroAddress as zeroAddress5 } from "
|
|
|
2934
4322
|
var interpretAddress = (owner) => isAddressEqual4(zeroAddress5, owner) ? null : owner;
|
|
2935
4323
|
|
|
2936
4324
|
// src/shared/interpretation/interpret-record-values.ts
|
|
2937
|
-
import { isInterpretedName
|
|
2938
|
-
import {
|
|
4325
|
+
import { isInterpretedName } from "enssdk";
|
|
4326
|
+
import { isHex as isHex2, zeroAddress as zeroAddress6 } from "viem";
|
|
2939
4327
|
|
|
2940
4328
|
// src/shared/null-bytes.ts
|
|
2941
4329
|
var hasNullByte = (value) => value.indexOf("\0") !== -1;
|
|
@@ -2947,12 +4335,11 @@ function interpretNameRecordValue(value) {
|
|
|
2947
4335
|
return value;
|
|
2948
4336
|
}
|
|
2949
4337
|
function interpretAddressRecordValue(value) {
|
|
2950
|
-
if (hasNullByte(value)) return null;
|
|
2951
|
-
if (value === "") return null;
|
|
2952
4338
|
if (value === "0x") return null;
|
|
2953
|
-
if (!
|
|
2954
|
-
|
|
2955
|
-
|
|
4339
|
+
if (!isHex2(value, { strict: true })) return null;
|
|
4340
|
+
const normalized = value.toLowerCase();
|
|
4341
|
+
if (normalized === zeroAddress6) return null;
|
|
4342
|
+
return normalized;
|
|
2956
4343
|
}
|
|
2957
4344
|
function interpretTextRecordKey(key) {
|
|
2958
4345
|
if (hasNullByte(key)) return null;
|
|
@@ -3120,10 +4507,10 @@ var getContractsByManagedName = (namespace) => {
|
|
|
3120
4507
|
}
|
|
3121
4508
|
};
|
|
3122
4509
|
};
|
|
3123
|
-
var
|
|
4510
|
+
var cache2 = /* @__PURE__ */ new Map();
|
|
3124
4511
|
var getManagedName = (namespace, contract) => {
|
|
3125
4512
|
const cacheKey = `${namespace}:${stringifyAccountId(contract)}`;
|
|
3126
|
-
const cached =
|
|
4513
|
+
const cached = cache2.get(cacheKey);
|
|
3127
4514
|
if (cached !== void 0) return cached;
|
|
3128
4515
|
for (const [managedName, group] of Object.entries(getContractsByManagedName(namespace))) {
|
|
3129
4516
|
const isAnyOfTheContracts = group.contracts.some(
|
|
@@ -3134,7 +4521,7 @@ var getManagedName = (namespace, contract) => {
|
|
|
3134
4521
|
const name = asInterpretedName2(namespaceSpecific ?? managedName);
|
|
3135
4522
|
const node = namehashInterpretedName3(name);
|
|
3136
4523
|
const result = { name, node, registry: group.registry };
|
|
3137
|
-
|
|
4524
|
+
cache2.set(cacheKey, result);
|
|
3138
4525
|
return result;
|
|
3139
4526
|
}
|
|
3140
4527
|
}
|
|
@@ -3144,14 +4531,18 @@ var getManagedName = (namespace, contract) => {
|
|
|
3144
4531
|
};
|
|
3145
4532
|
|
|
3146
4533
|
// src/shared/root-registry.ts
|
|
3147
|
-
import {
|
|
4534
|
+
import {
|
|
4535
|
+
makeConcreteRegistryId,
|
|
4536
|
+
makeENSv1RegistryId,
|
|
4537
|
+
makeENSv2RegistryId
|
|
4538
|
+
} from "enssdk";
|
|
3148
4539
|
import { DatasourceNames as DatasourceNames6 } from "@ensnode/datasources";
|
|
3149
4540
|
var getENSv1RootRegistry = (namespace) => getDatasourceContract(namespace, DatasourceNames6.ENSRoot, "ENSv1Registry");
|
|
3150
4541
|
|
|
3151
4542
|
// src/shared/protocol-acceleration/is-bridged-resolver.ts
|
|
3152
|
-
var
|
|
4543
|
+
var cache3 = /* @__PURE__ */ new Map();
|
|
3153
4544
|
var getBridgedResolverConfigs = (namespace) => {
|
|
3154
|
-
const cached =
|
|
4545
|
+
const cached = cache3.get(namespace);
|
|
3155
4546
|
if (cached) return cached;
|
|
3156
4547
|
const configs = [];
|
|
3157
4548
|
const basenames = maybeGetDatasource4(namespace, DatasourceNames7.Basenames);
|
|
@@ -3186,7 +4577,7 @@ var getBridgedResolverConfigs = (namespace) => {
|
|
|
3186
4577
|
targetRegistryId: makeENSv1VirtualRegistryId(registry, node)
|
|
3187
4578
|
});
|
|
3188
4579
|
}
|
|
3189
|
-
|
|
4580
|
+
cache3.set(namespace, configs);
|
|
3190
4581
|
return configs;
|
|
3191
4582
|
};
|
|
3192
4583
|
function isBridgedResolver(namespace, resolver) {
|
|
@@ -3348,6 +4739,7 @@ export {
|
|
|
3348
4739
|
makeENSIndexerPublicConfigSchema,
|
|
3349
4740
|
makeENSIndexerVersionInfoSchema,
|
|
3350
4741
|
makeENSNamespaceIdSchema,
|
|
4742
|
+
makeEmailSchema,
|
|
3351
4743
|
makeEnsApiIndexingStatusResponseErrorSchema,
|
|
3352
4744
|
makeEnsApiIndexingStatusResponseOkSchema,
|
|
3353
4745
|
makeEnsApiIndexingStatusResponseSchema,
|
|
@@ -3434,4 +4826,12 @@ export {
|
|
|
3434
4826
|
staticResolverImplementsAddressRecordDefaulting,
|
|
3435
4827
|
stringifyConfig
|
|
3436
4828
|
};
|
|
4829
|
+
/*! Bundled license information:
|
|
4830
|
+
|
|
4831
|
+
@scure/base/lib/esm/index.js:
|
|
4832
|
+
(*! scure-base - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
|
|
4833
|
+
|
|
4834
|
+
@noble/curves/esm/utils.js:
|
|
4835
|
+
(*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
|
|
4836
|
+
*/
|
|
3437
4837
|
//# sourceMappingURL=internal.js.map
|