@ensdomains/ensjs 3.0.0-alpha.45 → 3.0.0-alpha.47
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/functions/deleteSubname.js +17 -7
- package/dist/cjs/functions/getNames.js +25 -13
- package/dist/cjs/functions/getSubnames.js +32 -8
- package/dist/cjs/functions/transferSubname.js +4 -9
- package/dist/cjs/index.js +1 -1
- package/dist/cjs/utils/consts.js +1 -1
- package/dist/cjs/utils/fuses.js +2 -0
- package/dist/cjs/utils/registry.js +32 -0
- package/dist/cjs/utils/wrapper.js +14 -9
- package/dist/esm/functions/deleteSubname.mjs +17 -7
- package/dist/esm/functions/getNames.mjs +26 -14
- package/dist/esm/functions/getSubnames.mjs +32 -8
- package/dist/esm/functions/transferSubname.mjs +5 -10
- package/dist/esm/index.mjs +1 -1
- package/dist/esm/utils/consts.mjs +1 -1
- package/dist/esm/utils/fuses.mjs +2 -0
- package/dist/esm/utils/registry.mjs +13 -0
- package/dist/esm/utils/wrapper.mjs +14 -9
- package/dist/types/functions/deleteSubname.d.ts +8 -2
- package/dist/types/functions/getSubnames.d.ts +16 -4
- package/dist/types/functions/transferSubname.d.ts +1 -1
- package/dist/types/index.d.ts +62 -4
- package/dist/types/utils/fuses.d.ts +1 -0
- package/dist/types/utils/registry.d.ts +2 -0
- package/dist/types/utils/wrapper.d.ts +1 -0
- package/package.json +1 -1
- package/src/functions/deleteSubname.test.ts +139 -6
- package/src/functions/deleteSubname.ts +28 -11
- package/src/functions/getNames.test.ts +15 -2
- package/src/functions/getNames.ts +46 -22
- package/src/functions/getSubnames.test.ts +1227 -322
- package/src/functions/getSubnames.ts +62 -13
- package/src/functions/getWrapperData.test.ts +0 -1
- package/src/functions/transferSubname.test.ts +120 -18
- package/src/functions/transferSubname.ts +5 -10
- package/src/index.ts +1 -1
- package/src/utils/consts.ts +1 -1
- package/src/utils/fuses.ts +3 -0
- package/src/utils/registry.ts +14 -0
- package/src/utils/wrapper.ts +12 -9
|
@@ -23,17 +23,17 @@ __export(deleteSubname_exports, {
|
|
|
23
23
|
module.exports = __toCommonJS(deleteSubname_exports);
|
|
24
24
|
var import_solidity = require("@ethersproject/solidity");
|
|
25
25
|
var import_normalise = require("../utils/normalise");
|
|
26
|
-
async function deleteSubname_default({ contracts, signer }, name, { contract }) {
|
|
26
|
+
async function deleteSubname_default({ contracts, signer }, name, { contract, ...args }) {
|
|
27
27
|
const labels = name.split(".");
|
|
28
28
|
if (labels.length < 3) {
|
|
29
29
|
throw new Error(`${name} is not a valid subname`);
|
|
30
30
|
}
|
|
31
|
-
const label = labels.shift();
|
|
32
|
-
const labelhash = (0, import_solidity.keccak256)(["string"], [label]);
|
|
33
|
-
const parentNodehash = (0, import_normalise.namehash)(labels.join("."));
|
|
34
31
|
switch (contract) {
|
|
35
32
|
case "registry": {
|
|
36
33
|
const registry = (await contracts.getRegistry()).connect(signer);
|
|
34
|
+
const label = labels.shift();
|
|
35
|
+
const labelhash = (0, import_solidity.keccak256)(["string"], [label]);
|
|
36
|
+
const parentNodehash = (0, import_normalise.namehash)(labels.join("."));
|
|
37
37
|
return registry.populateTransaction.setSubnodeRecord(
|
|
38
38
|
parentNodehash,
|
|
39
39
|
labelhash,
|
|
@@ -44,12 +44,22 @@ async function deleteSubname_default({ contracts, signer }, name, { contract })
|
|
|
44
44
|
}
|
|
45
45
|
case "nameWrapper": {
|
|
46
46
|
const nameWrapper = (await contracts.getNameWrapper()).connect(signer);
|
|
47
|
-
|
|
47
|
+
const { method } = args;
|
|
48
|
+
if (method === "setRecord") {
|
|
49
|
+
const node = (0, import_normalise.namehash)(name);
|
|
50
|
+
return nameWrapper.populateTransaction.setRecord(
|
|
51
|
+
node,
|
|
52
|
+
"0x0000000000000000000000000000000000000000",
|
|
53
|
+
"0x0000000000000000000000000000000000000000",
|
|
54
|
+
0
|
|
55
|
+
);
|
|
56
|
+
}
|
|
57
|
+
const label = labels.shift();
|
|
58
|
+
const parentNodehash = (0, import_normalise.namehash)(labels.join("."));
|
|
59
|
+
return nameWrapper.populateTransaction.setSubnodeOwner(
|
|
48
60
|
parentNodehash,
|
|
49
61
|
label,
|
|
50
62
|
"0x0000000000000000000000000000000000000000",
|
|
51
|
-
"0x0000000000000000000000000000000000000000",
|
|
52
|
-
0,
|
|
53
63
|
0,
|
|
54
64
|
0
|
|
55
65
|
);
|
|
@@ -28,6 +28,16 @@ const mapDomain = ({ name, ...domain }) => {
|
|
|
28
28
|
const decrypted = name ? (0, import_labels.decryptName)(name) : void 0;
|
|
29
29
|
return {
|
|
30
30
|
...domain,
|
|
31
|
+
...domain.registration ? {
|
|
32
|
+
registration: {
|
|
33
|
+
expiryDate: new Date(
|
|
34
|
+
parseInt(domain.registration.expiryDate) * 1e3
|
|
35
|
+
),
|
|
36
|
+
registrationDate: new Date(
|
|
37
|
+
parseInt(domain.registration.registrationDate) * 1e3
|
|
38
|
+
)
|
|
39
|
+
}
|
|
40
|
+
} : {},
|
|
31
41
|
name: decrypted,
|
|
32
42
|
truncatedName: decrypted ? (0, import_format.truncateFormat)(decrypted) : void 0,
|
|
33
43
|
createdAt: new Date(parseInt(domain.createdAt) * 1e3),
|
|
@@ -35,19 +45,13 @@ const mapDomain = ({ name, ...domain }) => {
|
|
|
35
45
|
};
|
|
36
46
|
};
|
|
37
47
|
const mapWrappedDomain = (wrappedDomain) => {
|
|
38
|
-
const
|
|
39
|
-
if (
|
|
40
|
-
|
|
41
|
-
expiryDate: new Date(
|
|
42
|
-
parseInt(domain.registration.expiryDate) * 1e3
|
|
43
|
-
),
|
|
44
|
-
registrationDate: new Date(
|
|
45
|
-
parseInt(domain.registration.registrationDate) * 1e3
|
|
46
|
-
)
|
|
47
|
-
};
|
|
48
|
+
const expiryDate = wrappedDomain.expiryDate && wrappedDomain.expiryDate !== "0" ? new Date(parseInt(wrappedDomain.expiryDate) * 1e3) : void 0;
|
|
49
|
+
if (expiryDate && expiryDate < new Date() && (0, import_fuses.checkPCCBurned)(wrappedDomain.fuses)) {
|
|
50
|
+
return null;
|
|
48
51
|
}
|
|
52
|
+
const domain = mapDomain(wrappedDomain.domain);
|
|
49
53
|
return {
|
|
50
|
-
expiryDate
|
|
54
|
+
expiryDate,
|
|
51
55
|
fuses: (0, import_fuses.decodeFuses)(wrappedDomain.fuses),
|
|
52
56
|
...domain,
|
|
53
57
|
type: "wrappedDomain"
|
|
@@ -106,6 +110,10 @@ const getNames = async ({ gqlInstance }, {
|
|
|
106
110
|
domains(first: 1000) {
|
|
107
111
|
${domainQueryData}
|
|
108
112
|
createdAt
|
|
113
|
+
registration {
|
|
114
|
+
registrationDate
|
|
115
|
+
expiryDate
|
|
116
|
+
}
|
|
109
117
|
}
|
|
110
118
|
wrappedDomains(first: 1000) {
|
|
111
119
|
expiryDate
|
|
@@ -137,6 +145,10 @@ const getNames = async ({ gqlInstance }, {
|
|
|
137
145
|
domains(orderBy: $orderBy, orderDirection: $orderDirection) {
|
|
138
146
|
${domainQueryData}
|
|
139
147
|
createdAt
|
|
148
|
+
registration {
|
|
149
|
+
registrationDate
|
|
150
|
+
expiryDate
|
|
151
|
+
}
|
|
140
152
|
}
|
|
141
153
|
}
|
|
142
154
|
}
|
|
@@ -310,7 +322,7 @@ const getNames = async ({ gqlInstance }, {
|
|
|
310
322
|
return [
|
|
311
323
|
...(account == null ? void 0 : account.domains.map(mapDomain)) || [],
|
|
312
324
|
...(account == null ? void 0 : account.registrations.map(mapRegistration)) || [],
|
|
313
|
-
...(account == null ? void 0 : account.wrappedDomains.map(mapWrappedDomain)) || []
|
|
325
|
+
...(account == null ? void 0 : account.wrappedDomains.map(mapWrappedDomain).filter((d) => d)) || []
|
|
314
326
|
].sort((a, b) => {
|
|
315
327
|
if (orderDirection === "desc") {
|
|
316
328
|
if (orderBy === "labelName") {
|
|
@@ -328,7 +340,7 @@ const getNames = async ({ gqlInstance }, {
|
|
|
328
340
|
return (account == null ? void 0 : account.domains.map(mapDomain)) || [];
|
|
329
341
|
}
|
|
330
342
|
if (type === "wrappedOwner") {
|
|
331
|
-
return (account == null ? void 0 : account.wrappedDomains.map(mapWrappedDomain)) || [];
|
|
343
|
+
return (account == null ? void 0 : account.wrappedDomains.map(mapWrappedDomain).filter((d) => d)) || [];
|
|
332
344
|
}
|
|
333
345
|
return (account == null ? void 0 : account.registrations.map(mapRegistration)) || [];
|
|
334
346
|
};
|
|
@@ -22,6 +22,7 @@ __export(getSubnames_exports, {
|
|
|
22
22
|
});
|
|
23
23
|
module.exports = __toCommonJS(getSubnames_exports);
|
|
24
24
|
var import_format = require("../utils/format");
|
|
25
|
+
var import_fuses = require("../utils/fuses");
|
|
25
26
|
var import_labels = require("../utils/labels");
|
|
26
27
|
var import_normalise = require("../utils/normalise");
|
|
27
28
|
const largeQuery = async ({ gqlInstance }, {
|
|
@@ -77,6 +78,13 @@ const largeQuery = async ({ gqlInstance }, {
|
|
|
77
78
|
owner {
|
|
78
79
|
id
|
|
79
80
|
}
|
|
81
|
+
wrappedDomain {
|
|
82
|
+
fuses
|
|
83
|
+
expiryDate
|
|
84
|
+
owner {
|
|
85
|
+
id
|
|
86
|
+
}
|
|
87
|
+
}
|
|
80
88
|
}
|
|
81
89
|
}
|
|
82
90
|
}
|
|
@@ -92,14 +100,30 @@ const largeQuery = async ({ gqlInstance }, {
|
|
|
92
100
|
};
|
|
93
101
|
const response = await client.request(finalQuery, queryVars);
|
|
94
102
|
const domain = response == null ? void 0 : response.domain;
|
|
95
|
-
const subdomains = domain.subdomains.map(
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
+
const subdomains = domain.subdomains.map(
|
|
104
|
+
({ wrappedDomain, ...subname }) => {
|
|
105
|
+
const decrypted = (0, import_labels.decryptName)(subname.name);
|
|
106
|
+
const obj = {
|
|
107
|
+
...subname,
|
|
108
|
+
labelName: subname.labelName || null,
|
|
109
|
+
labelhash: subname.labelhash || "",
|
|
110
|
+
name: decrypted,
|
|
111
|
+
truncatedName: (0, import_format.truncateFormat)(decrypted),
|
|
112
|
+
owner: subname.owner.id,
|
|
113
|
+
type: "domain"
|
|
114
|
+
};
|
|
115
|
+
if (wrappedDomain) {
|
|
116
|
+
obj.type = "wrappedDomain";
|
|
117
|
+
const expiryDateAsDate = wrappedDomain.expiryDate && wrappedDomain.expiryDate !== "0" ? new Date(parseInt(wrappedDomain.expiryDate) * 1e3) : void 0;
|
|
118
|
+
const hasExpired = expiryDateAsDate && expiryDateAsDate < new Date();
|
|
119
|
+
obj.expiryDate = expiryDateAsDate;
|
|
120
|
+
obj.fuses = (0, import_fuses.decodeFuses)(hasExpired ? 0 : wrappedDomain.fuses);
|
|
121
|
+
obj.pccExpired = hasExpired ? (0, import_fuses.checkPCCBurned)(wrappedDomain.fuses) : false;
|
|
122
|
+
obj.owner = obj.pccExpired ? void 0 : wrappedDomain.owner.id;
|
|
123
|
+
}
|
|
124
|
+
return obj;
|
|
125
|
+
}
|
|
126
|
+
);
|
|
103
127
|
return {
|
|
104
128
|
subnames: subdomains,
|
|
105
129
|
subnameCount: domain.subdomainCount
|
|
@@ -24,11 +24,7 @@ module.exports = __toCommonJS(transferSubname_exports);
|
|
|
24
24
|
var import_solidity = require("@ethersproject/solidity");
|
|
25
25
|
var import_normalise = require("../utils/normalise");
|
|
26
26
|
var import_wrapper = require("../utils/wrapper");
|
|
27
|
-
async function transferSubname_default({
|
|
28
|
-
contracts,
|
|
29
|
-
signer,
|
|
30
|
-
getExpiry
|
|
31
|
-
}, name, { contract, owner, resolverAddress, ...wrapperArgs }) {
|
|
27
|
+
async function transferSubname_default({ contracts, signer }, name, { contract, owner, resolverAddress, ...wrapperArgs }) {
|
|
32
28
|
const labels = name.split(".");
|
|
33
29
|
const label = labels.shift();
|
|
34
30
|
const labelhash = (0, import_solidity.keccak256)(["string"], [label]);
|
|
@@ -44,10 +40,9 @@ async function transferSubname_default({
|
|
|
44
40
|
}
|
|
45
41
|
case "nameWrapper": {
|
|
46
42
|
const nameWrapper = (await contracts.getNameWrapper()).connect(signer);
|
|
47
|
-
const expiry =
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
"expiry" in wrapperArgs ? wrapperArgs.expiry : void 0
|
|
43
|
+
const expiry = (0, import_wrapper.expiryToBigNumber)(
|
|
44
|
+
wrapperArgs.expiry,
|
|
45
|
+
0
|
|
51
46
|
);
|
|
52
47
|
return nameWrapper.populateTransaction.setSubnodeOwner(
|
|
53
48
|
parentNodehash,
|
package/dist/cjs/index.js
CHANGED
|
@@ -316,7 +316,7 @@ class ENS {
|
|
|
316
316
|
this.importDNSSECName = this.generateWriteFunction("importDNSSECName", ["contracts", "provider", "signer"]);
|
|
317
317
|
this.createSubname = this.generateWriteFunction("createSubname", ["contracts", "getExpiry"]);
|
|
318
318
|
this.deleteSubname = this.generateWriteFunction("deleteSubname", ["contracts"]);
|
|
319
|
-
this.transferSubname = this.generateWriteFunction("transferSubname", ["contracts"
|
|
319
|
+
this.transferSubname = this.generateWriteFunction("transferSubname", ["contracts"]);
|
|
320
320
|
this.commitName = this.generateWriteFunction(
|
|
321
321
|
"commitName",
|
|
322
322
|
["contracts"]
|
package/dist/cjs/utils/consts.js
CHANGED
package/dist/cjs/utils/fuses.js
CHANGED
|
@@ -21,6 +21,7 @@ __export(fuses_exports, {
|
|
|
21
21
|
CHILD_CONTROLLED_FUSES: () => CHILD_CONTROLLED_FUSES,
|
|
22
22
|
PARENT_CONTROLLED_FUSES: () => PARENT_CONTROLLED_FUSES,
|
|
23
23
|
USER_SETTABLE_FUSES: () => USER_SETTABLE_FUSES,
|
|
24
|
+
checkPCCBurned: () => checkPCCBurned,
|
|
24
25
|
childFuseEnum: () => childFuseEnum,
|
|
25
26
|
childFuseKeys: () => childFuseKeys,
|
|
26
27
|
decodeFuses: () => decodeFuses,
|
|
@@ -297,4 +298,5 @@ const decodeFuses = (fuses) => {
|
|
|
297
298
|
}
|
|
298
299
|
};
|
|
299
300
|
};
|
|
301
|
+
const checkPCCBurned = (fuses) => (fuses & PARENT_CANNOT_CONTROL) === PARENT_CANNOT_CONTROL;
|
|
300
302
|
var fuses_default = fullFuseEnum;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var registry_exports = {};
|
|
20
|
+
__export(registry_exports, {
|
|
21
|
+
makeResolver: () => makeResolver
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(registry_exports);
|
|
24
|
+
var import_normalise = require("./normalise");
|
|
25
|
+
const makeResolver = async ({ contracts }, name, resolver) => {
|
|
26
|
+
if (resolver)
|
|
27
|
+
return resolver;
|
|
28
|
+
const registry = await contracts.getRegistry();
|
|
29
|
+
const node = (0, import_normalise.namehash)(name);
|
|
30
|
+
const _resolver = await registry.resolver(node);
|
|
31
|
+
return _resolver;
|
|
32
|
+
};
|
|
@@ -19,6 +19,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
19
19
|
var wrapper_exports = {};
|
|
20
20
|
__export(wrapper_exports, {
|
|
21
21
|
MAX_EXPIRY: () => MAX_EXPIRY,
|
|
22
|
+
expiryToBigNumber: () => expiryToBigNumber,
|
|
22
23
|
makeExpiry: () => makeExpiry,
|
|
23
24
|
wrappedLabelLengthCheck: () => wrappedLabelLengthCheck
|
|
24
25
|
});
|
|
@@ -26,16 +27,20 @@ module.exports = __toCommonJS(wrapper_exports);
|
|
|
26
27
|
var import_bignumber = require("@ethersproject/bignumber");
|
|
27
28
|
var import_strings = require("@ethersproject/strings");
|
|
28
29
|
const MAX_EXPIRY = import_bignumber.BigNumber.from(2).pow(64).sub(1);
|
|
29
|
-
const
|
|
30
|
-
if (expiry)
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
return import_bignumber.BigNumber.from(expiry);
|
|
30
|
+
const expiryToBigNumber = (expiry, defaultValue = 0) => {
|
|
31
|
+
if (!expiry)
|
|
32
|
+
return import_bignumber.BigNumber.from(defaultValue);
|
|
33
|
+
if (expiry instanceof Date) {
|
|
34
|
+
return import_bignumber.BigNumber.from(expiry.getTime() / 1e3);
|
|
35
|
+
}
|
|
36
|
+
if (expiry instanceof import_bignumber.BigNumber) {
|
|
37
|
+
return expiry;
|
|
38
38
|
}
|
|
39
|
+
return import_bignumber.BigNumber.from(expiry);
|
|
40
|
+
};
|
|
41
|
+
const makeExpiry = async ({ getExpiry }, name, expiry) => {
|
|
42
|
+
if (expiry)
|
|
43
|
+
return expiryToBigNumber(expiry);
|
|
39
44
|
if (name.endsWith(".eth")) {
|
|
40
45
|
const expResponse = await getExpiry(name);
|
|
41
46
|
if (!(expResponse == null ? void 0 : expResponse.expiry))
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
// src/functions/deleteSubname.ts
|
|
2
2
|
import { keccak256 as solidityKeccak256 } from "@ethersproject/solidity";
|
|
3
3
|
import { namehash } from "../utils/normalise.mjs";
|
|
4
|
-
async function deleteSubname_default({ contracts, signer }, name, { contract }) {
|
|
4
|
+
async function deleteSubname_default({ contracts, signer }, name, { contract, ...args }) {
|
|
5
5
|
const labels = name.split(".");
|
|
6
6
|
if (labels.length < 3) {
|
|
7
7
|
throw new Error(`${name} is not a valid subname`);
|
|
8
8
|
}
|
|
9
|
-
const label = labels.shift();
|
|
10
|
-
const labelhash = solidityKeccak256(["string"], [label]);
|
|
11
|
-
const parentNodehash = namehash(labels.join("."));
|
|
12
9
|
switch (contract) {
|
|
13
10
|
case "registry": {
|
|
14
11
|
const registry = (await contracts.getRegistry()).connect(signer);
|
|
12
|
+
const label = labels.shift();
|
|
13
|
+
const labelhash = solidityKeccak256(["string"], [label]);
|
|
14
|
+
const parentNodehash = namehash(labels.join("."));
|
|
15
15
|
return registry.populateTransaction.setSubnodeRecord(
|
|
16
16
|
parentNodehash,
|
|
17
17
|
labelhash,
|
|
@@ -22,12 +22,22 @@ async function deleteSubname_default({ contracts, signer }, name, { contract })
|
|
|
22
22
|
}
|
|
23
23
|
case "nameWrapper": {
|
|
24
24
|
const nameWrapper = (await contracts.getNameWrapper()).connect(signer);
|
|
25
|
-
|
|
25
|
+
const { method } = args;
|
|
26
|
+
if (method === "setRecord") {
|
|
27
|
+
const node = namehash(name);
|
|
28
|
+
return nameWrapper.populateTransaction.setRecord(
|
|
29
|
+
node,
|
|
30
|
+
"0x0000000000000000000000000000000000000000",
|
|
31
|
+
"0x0000000000000000000000000000000000000000",
|
|
32
|
+
0
|
|
33
|
+
);
|
|
34
|
+
}
|
|
35
|
+
const label = labels.shift();
|
|
36
|
+
const parentNodehash = namehash(labels.join("."));
|
|
37
|
+
return nameWrapper.populateTransaction.setSubnodeOwner(
|
|
26
38
|
parentNodehash,
|
|
27
39
|
label,
|
|
28
40
|
"0x0000000000000000000000000000000000000000",
|
|
29
|
-
"0x0000000000000000000000000000000000000000",
|
|
30
|
-
0,
|
|
31
41
|
0,
|
|
32
42
|
0
|
|
33
43
|
);
|
|
@@ -1,11 +1,21 @@
|
|
|
1
1
|
// src/functions/getNames.ts
|
|
2
2
|
import { truncateFormat } from "../utils/format.mjs";
|
|
3
|
-
import { decodeFuses } from "../utils/fuses.mjs";
|
|
3
|
+
import { checkPCCBurned, decodeFuses } from "../utils/fuses.mjs";
|
|
4
4
|
import { decryptName } from "../utils/labels.mjs";
|
|
5
5
|
var mapDomain = ({ name, ...domain }) => {
|
|
6
6
|
const decrypted = name ? decryptName(name) : void 0;
|
|
7
7
|
return {
|
|
8
8
|
...domain,
|
|
9
|
+
...domain.registration ? {
|
|
10
|
+
registration: {
|
|
11
|
+
expiryDate: new Date(
|
|
12
|
+
parseInt(domain.registration.expiryDate) * 1e3
|
|
13
|
+
),
|
|
14
|
+
registrationDate: new Date(
|
|
15
|
+
parseInt(domain.registration.registrationDate) * 1e3
|
|
16
|
+
)
|
|
17
|
+
}
|
|
18
|
+
} : {},
|
|
9
19
|
name: decrypted,
|
|
10
20
|
truncatedName: decrypted ? truncateFormat(decrypted) : void 0,
|
|
11
21
|
createdAt: new Date(parseInt(domain.createdAt) * 1e3),
|
|
@@ -13,19 +23,13 @@ var mapDomain = ({ name, ...domain }) => {
|
|
|
13
23
|
};
|
|
14
24
|
};
|
|
15
25
|
var mapWrappedDomain = (wrappedDomain) => {
|
|
16
|
-
const
|
|
17
|
-
if (
|
|
18
|
-
|
|
19
|
-
expiryDate: new Date(
|
|
20
|
-
parseInt(domain.registration.expiryDate) * 1e3
|
|
21
|
-
),
|
|
22
|
-
registrationDate: new Date(
|
|
23
|
-
parseInt(domain.registration.registrationDate) * 1e3
|
|
24
|
-
)
|
|
25
|
-
};
|
|
26
|
+
const expiryDate = wrappedDomain.expiryDate && wrappedDomain.expiryDate !== "0" ? new Date(parseInt(wrappedDomain.expiryDate) * 1e3) : void 0;
|
|
27
|
+
if (expiryDate && expiryDate < new Date() && checkPCCBurned(wrappedDomain.fuses)) {
|
|
28
|
+
return null;
|
|
26
29
|
}
|
|
30
|
+
const domain = mapDomain(wrappedDomain.domain);
|
|
27
31
|
return {
|
|
28
|
-
expiryDate
|
|
32
|
+
expiryDate,
|
|
29
33
|
fuses: decodeFuses(wrappedDomain.fuses),
|
|
30
34
|
...domain,
|
|
31
35
|
type: "wrappedDomain"
|
|
@@ -84,6 +88,10 @@ var getNames = async ({ gqlInstance }, {
|
|
|
84
88
|
domains(first: 1000) {
|
|
85
89
|
${domainQueryData}
|
|
86
90
|
createdAt
|
|
91
|
+
registration {
|
|
92
|
+
registrationDate
|
|
93
|
+
expiryDate
|
|
94
|
+
}
|
|
87
95
|
}
|
|
88
96
|
wrappedDomains(first: 1000) {
|
|
89
97
|
expiryDate
|
|
@@ -115,6 +123,10 @@ var getNames = async ({ gqlInstance }, {
|
|
|
115
123
|
domains(orderBy: $orderBy, orderDirection: $orderDirection) {
|
|
116
124
|
${domainQueryData}
|
|
117
125
|
createdAt
|
|
126
|
+
registration {
|
|
127
|
+
registrationDate
|
|
128
|
+
expiryDate
|
|
129
|
+
}
|
|
118
130
|
}
|
|
119
131
|
}
|
|
120
132
|
}
|
|
@@ -288,7 +300,7 @@ var getNames = async ({ gqlInstance }, {
|
|
|
288
300
|
return [
|
|
289
301
|
...account?.domains.map(mapDomain) || [],
|
|
290
302
|
...account?.registrations.map(mapRegistration) || [],
|
|
291
|
-
...account?.wrappedDomains.map(mapWrappedDomain) || []
|
|
303
|
+
...account?.wrappedDomains.map(mapWrappedDomain).filter((d) => d) || []
|
|
292
304
|
].sort((a, b) => {
|
|
293
305
|
if (orderDirection === "desc") {
|
|
294
306
|
if (orderBy === "labelName") {
|
|
@@ -306,7 +318,7 @@ var getNames = async ({ gqlInstance }, {
|
|
|
306
318
|
return account?.domains.map(mapDomain) || [];
|
|
307
319
|
}
|
|
308
320
|
if (type === "wrappedOwner") {
|
|
309
|
-
return account?.wrappedDomains.map(mapWrappedDomain) || [];
|
|
321
|
+
return account?.wrappedDomains.map(mapWrappedDomain).filter((d) => d) || [];
|
|
310
322
|
}
|
|
311
323
|
return account?.registrations.map(mapRegistration) || [];
|
|
312
324
|
};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
// src/functions/getSubnames.ts
|
|
2
2
|
import { truncateFormat } from "../utils/format.mjs";
|
|
3
|
+
import { checkPCCBurned, decodeFuses } from "../utils/fuses.mjs";
|
|
3
4
|
import { decryptName } from "../utils/labels.mjs";
|
|
4
5
|
import { namehash } from "../utils/normalise.mjs";
|
|
5
6
|
var largeQuery = async ({ gqlInstance }, {
|
|
@@ -55,6 +56,13 @@ var largeQuery = async ({ gqlInstance }, {
|
|
|
55
56
|
owner {
|
|
56
57
|
id
|
|
57
58
|
}
|
|
59
|
+
wrappedDomain {
|
|
60
|
+
fuses
|
|
61
|
+
expiryDate
|
|
62
|
+
owner {
|
|
63
|
+
id
|
|
64
|
+
}
|
|
65
|
+
}
|
|
58
66
|
}
|
|
59
67
|
}
|
|
60
68
|
}
|
|
@@ -70,14 +78,30 @@ var largeQuery = async ({ gqlInstance }, {
|
|
|
70
78
|
};
|
|
71
79
|
const response = await client.request(finalQuery, queryVars);
|
|
72
80
|
const domain = response?.domain;
|
|
73
|
-
const subdomains = domain.subdomains.map(
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
+
const subdomains = domain.subdomains.map(
|
|
82
|
+
({ wrappedDomain, ...subname }) => {
|
|
83
|
+
const decrypted = decryptName(subname.name);
|
|
84
|
+
const obj = {
|
|
85
|
+
...subname,
|
|
86
|
+
labelName: subname.labelName || null,
|
|
87
|
+
labelhash: subname.labelhash || "",
|
|
88
|
+
name: decrypted,
|
|
89
|
+
truncatedName: truncateFormat(decrypted),
|
|
90
|
+
owner: subname.owner.id,
|
|
91
|
+
type: "domain"
|
|
92
|
+
};
|
|
93
|
+
if (wrappedDomain) {
|
|
94
|
+
obj.type = "wrappedDomain";
|
|
95
|
+
const expiryDateAsDate = wrappedDomain.expiryDate && wrappedDomain.expiryDate !== "0" ? new Date(parseInt(wrappedDomain.expiryDate) * 1e3) : void 0;
|
|
96
|
+
const hasExpired = expiryDateAsDate && expiryDateAsDate < new Date();
|
|
97
|
+
obj.expiryDate = expiryDateAsDate;
|
|
98
|
+
obj.fuses = decodeFuses(hasExpired ? 0 : wrappedDomain.fuses);
|
|
99
|
+
obj.pccExpired = hasExpired ? checkPCCBurned(wrappedDomain.fuses) : false;
|
|
100
|
+
obj.owner = obj.pccExpired ? void 0 : wrappedDomain.owner.id;
|
|
101
|
+
}
|
|
102
|
+
return obj;
|
|
103
|
+
}
|
|
104
|
+
);
|
|
81
105
|
return {
|
|
82
106
|
subnames: subdomains,
|
|
83
107
|
subnameCount: domain.subdomainCount
|
|
@@ -1,12 +1,8 @@
|
|
|
1
1
|
// src/functions/transferSubname.ts
|
|
2
2
|
import { keccak256 as solidityKeccak256 } from "@ethersproject/solidity";
|
|
3
3
|
import { namehash } from "../utils/normalise.mjs";
|
|
4
|
-
import {
|
|
5
|
-
async function transferSubname_default({
|
|
6
|
-
contracts,
|
|
7
|
-
signer,
|
|
8
|
-
getExpiry
|
|
9
|
-
}, name, { contract, owner, resolverAddress, ...wrapperArgs }) {
|
|
4
|
+
import { expiryToBigNumber } from "../utils/wrapper.mjs";
|
|
5
|
+
async function transferSubname_default({ contracts, signer }, name, { contract, owner, resolverAddress, ...wrapperArgs }) {
|
|
10
6
|
const labels = name.split(".");
|
|
11
7
|
const label = labels.shift();
|
|
12
8
|
const labelhash = solidityKeccak256(["string"], [label]);
|
|
@@ -22,10 +18,9 @@ async function transferSubname_default({
|
|
|
22
18
|
}
|
|
23
19
|
case "nameWrapper": {
|
|
24
20
|
const nameWrapper = (await contracts.getNameWrapper()).connect(signer);
|
|
25
|
-
const expiry =
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
"expiry" in wrapperArgs ? wrapperArgs.expiry : void 0
|
|
21
|
+
const expiry = expiryToBigNumber(
|
|
22
|
+
wrapperArgs.expiry,
|
|
23
|
+
0
|
|
29
24
|
);
|
|
30
25
|
return nameWrapper.populateTransaction.setSubnodeOwner(
|
|
31
26
|
parentNodehash,
|
package/dist/esm/index.mjs
CHANGED
|
@@ -293,7 +293,7 @@ var ENS = class {
|
|
|
293
293
|
importDNSSECName = this.generateWriteFunction("importDNSSECName", ["contracts", "provider", "signer"]);
|
|
294
294
|
createSubname = this.generateWriteFunction("createSubname", ["contracts", "getExpiry"]);
|
|
295
295
|
deleteSubname = this.generateWriteFunction("deleteSubname", ["contracts"]);
|
|
296
|
-
transferSubname = this.generateWriteFunction("transferSubname", ["contracts"
|
|
296
|
+
transferSubname = this.generateWriteFunction("transferSubname", ["contracts"]);
|
|
297
297
|
commitName = this.generateWriteFunction(
|
|
298
298
|
"commitName",
|
|
299
299
|
["contracts"]
|
package/dist/esm/utils/fuses.mjs
CHANGED
|
@@ -257,11 +257,13 @@ var decodeFuses = (fuses) => {
|
|
|
257
257
|
}
|
|
258
258
|
};
|
|
259
259
|
};
|
|
260
|
+
var checkPCCBurned = (fuses) => (fuses & PARENT_CANNOT_CONTROL) === PARENT_CANNOT_CONTROL;
|
|
260
261
|
var fuses_default = fullFuseEnum;
|
|
261
262
|
export {
|
|
262
263
|
CHILD_CONTROLLED_FUSES,
|
|
263
264
|
PARENT_CONTROLLED_FUSES,
|
|
264
265
|
USER_SETTABLE_FUSES,
|
|
266
|
+
checkPCCBurned,
|
|
265
267
|
childFuseEnum,
|
|
266
268
|
childFuseKeys,
|
|
267
269
|
decodeFuses,
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
// src/utils/registry.ts
|
|
2
|
+
import { namehash } from "./normalise.mjs";
|
|
3
|
+
var makeResolver = async ({ contracts }, name, resolver) => {
|
|
4
|
+
if (resolver)
|
|
5
|
+
return resolver;
|
|
6
|
+
const registry = await contracts.getRegistry();
|
|
7
|
+
const node = namehash(name);
|
|
8
|
+
const _resolver = await registry.resolver(node);
|
|
9
|
+
return _resolver;
|
|
10
|
+
};
|
|
11
|
+
export {
|
|
12
|
+
makeResolver
|
|
13
|
+
};
|
|
@@ -2,16 +2,20 @@
|
|
|
2
2
|
import { BigNumber } from "@ethersproject/bignumber";
|
|
3
3
|
import { toUtf8Bytes } from "@ethersproject/strings";
|
|
4
4
|
var MAX_EXPIRY = BigNumber.from(2).pow(64).sub(1);
|
|
5
|
-
var
|
|
6
|
-
if (expiry)
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
return BigNumber.from(expiry);
|
|
5
|
+
var expiryToBigNumber = (expiry, defaultValue = 0) => {
|
|
6
|
+
if (!expiry)
|
|
7
|
+
return BigNumber.from(defaultValue);
|
|
8
|
+
if (expiry instanceof Date) {
|
|
9
|
+
return BigNumber.from(expiry.getTime() / 1e3);
|
|
10
|
+
}
|
|
11
|
+
if (expiry instanceof BigNumber) {
|
|
12
|
+
return expiry;
|
|
14
13
|
}
|
|
14
|
+
return BigNumber.from(expiry);
|
|
15
|
+
};
|
|
16
|
+
var makeExpiry = async ({ getExpiry }, name, expiry) => {
|
|
17
|
+
if (expiry)
|
|
18
|
+
return expiryToBigNumber(expiry);
|
|
15
19
|
if (name.endsWith(".eth")) {
|
|
16
20
|
const expResponse = await getExpiry(name);
|
|
17
21
|
if (!expResponse?.expiry)
|
|
@@ -27,6 +31,7 @@ var wrappedLabelLengthCheck = (label) => {
|
|
|
27
31
|
};
|
|
28
32
|
export {
|
|
29
33
|
MAX_EXPIRY,
|
|
34
|
+
expiryToBigNumber,
|
|
30
35
|
makeExpiry,
|
|
31
36
|
wrappedLabelLengthCheck
|
|
32
37
|
};
|
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
import { ENSArgs } from '..';
|
|
2
|
-
declare type
|
|
2
|
+
declare type BaseArgs = {
|
|
3
3
|
contract: 'registry' | 'nameWrapper';
|
|
4
|
+
method?: 'setRecord' | 'setSubnodeOwner';
|
|
4
5
|
};
|
|
5
|
-
|
|
6
|
+
declare type NameWrapperArgs = {
|
|
7
|
+
contract: 'nameWrapper';
|
|
8
|
+
method: 'setRecord' | 'setSubnodeOwner';
|
|
9
|
+
};
|
|
10
|
+
declare type Args = BaseArgs | NameWrapperArgs;
|
|
11
|
+
export default function ({ contracts, signer }: ENSArgs<'contracts' | 'signer'>, name: string, { contract, ...args }: Args): Promise<import("ethers").PopulatedTransaction>;
|
|
6
12
|
export {};
|