@ensdomains/ensjs 3.0.0-alpha.1 → 3.0.0-alpha.10
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/README.md +2 -0
- package/dist/cjs/GqlManager.d.ts +3 -0
- package/dist/cjs/GqlManager.js +62 -2
- package/dist/cjs/functions/burnFuses.d.ts +3 -2
- package/dist/cjs/functions/burnFuses.js +4 -8
- package/dist/cjs/functions/createSubname.d.ts +1 -5
- package/dist/cjs/functions/createSubname.js +5 -8
- package/dist/cjs/functions/deleteSubname.d.ts +3 -3
- package/dist/cjs/functions/deleteSubname.js +5 -2
- package/dist/cjs/functions/getDNSOwner.d.ts +7 -0
- package/dist/cjs/functions/getDNSOwner.js +81 -0
- package/dist/cjs/functions/getFuses.js +3 -2
- package/dist/cjs/functions/getOwner.js +7 -6
- package/dist/cjs/functions/getProfile.d.ts +4 -1
- package/dist/cjs/functions/getProfile.js +102 -24
- package/dist/cjs/functions/getRecords.d.ts +1 -0
- package/dist/cjs/functions/getSpecificRecord.js +22 -5
- package/dist/cjs/functions/getSubnames.js +6 -6
- package/dist/cjs/functions/setName.d.ts +4 -3
- package/dist/cjs/functions/setName.js +5 -10
- package/dist/cjs/functions/setRecord.d.ts +18 -0
- package/dist/cjs/functions/setRecord.js +27 -0
- package/dist/cjs/functions/setRecords.d.ts +4 -2
- package/dist/cjs/functions/setRecords.js +14 -12
- package/dist/cjs/functions/setResolver.d.ts +4 -4
- package/dist/cjs/functions/setResolver.js +6 -12
- package/dist/cjs/functions/transferName.d.ts +4 -3
- package/dist/cjs/functions/transferName.js +9 -13
- package/dist/cjs/functions/transferSubname.d.ts +4 -3
- package/dist/cjs/functions/transferSubname.js +5 -8
- package/dist/cjs/functions/unwrapName.d.ts +4 -3
- package/dist/cjs/functions/unwrapName.js +5 -9
- package/dist/cjs/functions/wrapName.d.ts +5 -3
- package/dist/cjs/functions/wrapName.js +8 -12
- package/dist/cjs/index.d.ts +48 -46
- package/dist/cjs/index.js +43 -19
- package/dist/cjs/utils/labels.js +5 -4
- package/dist/cjs/utils/makeHashIndexes.js +2 -2
- package/dist/cjs/utils/normalise.d.ts +1 -0
- package/dist/cjs/utils/normalise.js +27 -1
- package/dist/cjs/utils/recordHelpers.d.ts +3 -0
- package/dist/cjs/utils/recordHelpers.js +42 -15
- package/dist/cjs/utils/registerHelpers.js +3 -4
- package/dist/cjs/utils/writeTx.d.ts +4 -0
- package/dist/cjs/utils/writeTx.js +3 -0
- package/dist/esm/GqlManager.d.ts +3 -0
- package/dist/esm/GqlManager.js +58 -2
- package/dist/esm/functions/burnFuses.d.ts +3 -2
- package/dist/esm/functions/burnFuses.js +4 -8
- package/dist/esm/functions/createSubname.d.ts +1 -5
- package/dist/esm/functions/createSubname.js +5 -8
- package/dist/esm/functions/deleteSubname.d.ts +3 -3
- package/dist/esm/functions/deleteSubname.js +5 -2
- package/dist/esm/functions/getDNSOwner.d.ts +7 -0
- package/dist/esm/functions/getDNSOwner.js +51 -0
- package/dist/esm/functions/getFuses.js +4 -3
- package/dist/esm/functions/getOwner.js +7 -6
- package/dist/esm/functions/getProfile.d.ts +4 -1
- package/dist/esm/functions/getProfile.js +102 -24
- package/dist/esm/functions/getRecords.d.ts +1 -0
- package/dist/esm/functions/getSpecificRecord.js +22 -5
- package/dist/esm/functions/getSubnames.js +3 -3
- package/dist/esm/functions/setName.d.ts +4 -3
- package/dist/esm/functions/setName.js +5 -10
- package/dist/esm/functions/setRecord.d.ts +18 -0
- package/dist/esm/functions/setRecord.js +24 -0
- package/dist/esm/functions/setRecords.d.ts +4 -2
- package/dist/esm/functions/setRecords.js +14 -12
- package/dist/esm/functions/setResolver.d.ts +4 -4
- package/dist/esm/functions/setResolver.js +6 -12
- package/dist/esm/functions/transferName.d.ts +4 -3
- package/dist/esm/functions/transferName.js +9 -13
- package/dist/esm/functions/transferSubname.d.ts +4 -3
- package/dist/esm/functions/transferSubname.js +5 -8
- package/dist/esm/functions/unwrapName.d.ts +4 -3
- package/dist/esm/functions/unwrapName.js +5 -9
- package/dist/esm/functions/wrapName.d.ts +5 -3
- package/dist/esm/functions/wrapName.js +8 -12
- package/dist/esm/index.d.ts +48 -46
- package/dist/esm/index.js +43 -19
- package/dist/esm/utils/labels.js +5 -4
- package/dist/esm/utils/makeHashIndexes.js +2 -2
- package/dist/esm/utils/normalise.d.ts +1 -0
- package/dist/esm/utils/normalise.js +25 -0
- package/dist/esm/utils/recordHelpers.d.ts +3 -0
- package/dist/esm/utils/recordHelpers.js +40 -14
- package/dist/esm/utils/registerHelpers.js +3 -4
- package/dist/esm/utils/writeTx.d.ts +4 -0
- package/dist/esm/utils/writeTx.js +1 -0
- package/package.json +15 -7
- package/src/@types/dns-packet/index.d.ts +114 -0
- package/src/GqlManager.test.ts +170 -0
- package/src/GqlManager.ts +67 -2
- package/src/{tests → functions}/batch.test.ts +1 -1
- package/src/{tests → functions}/batchWrappers.test.ts +1 -1
- package/src/{tests → functions}/burnFuses.test.ts +12 -10
- package/src/functions/burnFuses.ts +9 -11
- package/src/{tests → functions}/createSubname.test.ts +12 -16
- package/src/functions/createSubname.ts +7 -13
- package/src/{tests → functions}/deleteSubname.test.ts +32 -32
- package/src/functions/deleteSubname.ts +9 -12
- package/src/functions/getDNSOwner.test.ts +122 -0
- package/src/functions/getDNSOwner.ts +61 -0
- package/src/{tests → functions}/getExpiry.test.ts +1 -1
- package/src/{tests → functions}/getFuses.test.ts +12 -10
- package/src/functions/getFuses.ts +4 -3
- package/src/{tests → functions}/getHistory.test.ts +1 -1
- package/src/{tests → functions}/getName.test.ts +1 -1
- package/src/{tests → functions}/getNames.test.ts +1 -1
- package/src/{tests → functions}/getOwner.test.ts +14 -2
- package/src/functions/getOwner.ts +7 -7
- package/src/{tests → functions}/getProfile.test.ts +45 -12
- package/src/functions/getProfile.ts +151 -24
- package/src/functions/getRecords.ts +1 -0
- package/src/{tests → functions}/getResolver.test.ts +1 -1
- package/src/{tests → functions}/getSpecificRecord.test.ts +1 -1
- package/src/functions/getSpecificRecord.ts +28 -8
- package/src/{tests → functions}/getSubnames.test.ts +1 -1
- package/src/functions/getSubnames.ts +68 -66
- package/src/{tests → functions}/makeCommitment.test.ts +1 -1
- package/src/functions/normalise.test.ts +22 -0
- package/src/{tests → functions}/setName.test.ts +3 -2
- package/src/functions/setName.ts +15 -17
- package/src/functions/setRecord.test.ts +100 -0
- package/src/functions/setRecord.ts +63 -0
- package/src/{tests → functions}/setRecords.test.ts +12 -10
- package/src/functions/setRecords.ts +22 -16
- package/src/{tests → functions}/setResolver.test.ts +12 -15
- package/src/functions/setResolver.ts +15 -20
- package/src/{tests → functions}/transferName.test.ts +30 -31
- package/src/functions/transferName.ts +19 -22
- package/src/{tests → functions}/transferSubname.test.ts +34 -34
- package/src/functions/transferSubname.ts +21 -13
- package/src/{tests → functions}/unwrapName.test.ts +24 -23
- package/src/functions/unwrapName.ts +20 -15
- package/src/{tests → functions}/wrapName.test.ts +19 -19
- package/src/functions/wrapName.ts +20 -22
- package/src/index.ts +115 -26
- package/src/tests/populateTransaction.test.ts +40 -0
- package/src/tests/signerInjection.test.ts +46 -0
- package/src/tests/withProvider.test.ts +1 -1
- package/src/utils/labels.ts +6 -4
- package/src/utils/makeHashIndexes.ts +4 -4
- package/src/utils/normalise.ts +29 -0
- package/src/utils/recordHelpers.ts +52 -18
- package/src/utils/registerHelpers.ts +3 -4
- package/src/utils/writeTx.ts +6 -0
|
@@ -4,13 +4,14 @@ exports.getAddr = exports._getAddr = exports.getText = exports._getText = export
|
|
|
4
4
|
const address_encoder_1 = require("@ensdomains/address-encoder");
|
|
5
5
|
const ethers_1 = require("ethers");
|
|
6
6
|
const contentHash_1 = require("../utils/contentHash");
|
|
7
|
+
const normalise_1 = require("../utils/normalise");
|
|
7
8
|
exports._getContentHash = {
|
|
8
9
|
raw: async ({ contracts }, name) => {
|
|
9
10
|
const publicResolver = await contracts?.getPublicResolver();
|
|
10
11
|
return {
|
|
11
12
|
to: '0x0000000000000000000000000000000000000000',
|
|
12
13
|
data: publicResolver.interface.encodeFunctionData('contenthash', [
|
|
13
|
-
|
|
14
|
+
(0, normalise_1.namehash)(name),
|
|
14
15
|
]),
|
|
15
16
|
};
|
|
16
17
|
},
|
|
@@ -48,7 +49,7 @@ exports._getText = {
|
|
|
48
49
|
return {
|
|
49
50
|
to: '0x0000000000000000000000000000000000000000',
|
|
50
51
|
data: publicResolver.interface.encodeFunctionData('text', [
|
|
51
|
-
|
|
52
|
+
(0, normalise_1.namehash)(name),
|
|
52
53
|
key,
|
|
53
54
|
]),
|
|
54
55
|
};
|
|
@@ -80,10 +81,18 @@ exports._getAddr = {
|
|
|
80
81
|
coinType = 60;
|
|
81
82
|
}
|
|
82
83
|
const publicResolver = await contracts?.getPublicResolver();
|
|
84
|
+
if (coinType === 60 || coinType === '60') {
|
|
85
|
+
return {
|
|
86
|
+
to: '0x0000000000000000000000000000000000000000',
|
|
87
|
+
data: publicResolver.interface.encodeFunctionData('addr(bytes32)', [
|
|
88
|
+
(0, normalise_1.namehash)(name),
|
|
89
|
+
]),
|
|
90
|
+
};
|
|
91
|
+
}
|
|
83
92
|
if (bypassFormat) {
|
|
84
93
|
return {
|
|
85
94
|
to: '0x0000000000000000000000000000000000000000',
|
|
86
|
-
data: publicResolver.interface.encodeFunctionData('addr(bytes32,uint256)', [
|
|
95
|
+
data: publicResolver.interface.encodeFunctionData('addr(bytes32,uint256)', [(0, normalise_1.namehash)(name), coinType]),
|
|
87
96
|
};
|
|
88
97
|
}
|
|
89
98
|
const formatter = typeof coinType === 'string' && isNaN(parseInt(coinType))
|
|
@@ -94,7 +103,7 @@ exports._getAddr = {
|
|
|
94
103
|
}
|
|
95
104
|
return {
|
|
96
105
|
to: '0x0000000000000000000000000000000000000000',
|
|
97
|
-
data: publicResolver.interface.encodeFunctionData('addr(bytes32,uint256)', [
|
|
106
|
+
data: publicResolver.interface.encodeFunctionData('addr(bytes32,uint256)', [(0, normalise_1.namehash)(name), formatter.coinType]),
|
|
98
107
|
};
|
|
99
108
|
},
|
|
100
109
|
decode: async ({ contracts }, data, _name, coinType) => {
|
|
@@ -107,7 +116,15 @@ exports._getAddr = {
|
|
|
107
116
|
const formatter = typeof coinType === 'string' && isNaN(parseInt(coinType))
|
|
108
117
|
? address_encoder_1.formatsByName[coinType]
|
|
109
118
|
: address_encoder_1.formatsByCoinType[typeof coinType === 'number' ? coinType : parseInt(coinType)];
|
|
110
|
-
|
|
119
|
+
let response;
|
|
120
|
+
if (coinType === 60 || coinType === '60') {
|
|
121
|
+
;
|
|
122
|
+
[response] = publicResolver.interface.decodeFunctionResult('addr(bytes32)', data);
|
|
123
|
+
}
|
|
124
|
+
else {
|
|
125
|
+
;
|
|
126
|
+
[response] = publicResolver.interface.decodeFunctionResult('addr(bytes32,uint256)', data);
|
|
127
|
+
}
|
|
111
128
|
if (!response)
|
|
112
129
|
return;
|
|
113
130
|
if (ethers_1.ethers.utils.hexStripZeros(response) === '0x') {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const utils_1 = require("ethers/lib/utils");
|
|
4
3
|
const format_1 = require("../utils/format");
|
|
5
4
|
const labels_1 = require("../utils/labels");
|
|
5
|
+
const normalise_1 = require("../utils/normalise");
|
|
6
6
|
const largeQuery = async ({ gqlInstance }, { name, page, pageSize = 10, orderDirection, orderBy, lastSubnames }) => {
|
|
7
7
|
const client = gqlInstance.client;
|
|
8
8
|
let finalQuery = gqlInstance.gql `
|
|
@@ -38,7 +38,7 @@ const largeQuery = async ({ gqlInstance }, { name, page, pageSize = 10, orderDir
|
|
|
38
38
|
}
|
|
39
39
|
`;
|
|
40
40
|
let queryVars = {
|
|
41
|
-
id: (0,
|
|
41
|
+
id: (0, normalise_1.namehash)(name),
|
|
42
42
|
first: pageSize,
|
|
43
43
|
lastCreatedAt: lastSubnames[lastSubnames.length - 1]?.createdAt,
|
|
44
44
|
orderBy,
|
|
@@ -55,7 +55,7 @@ const largeQuery = async ({ gqlInstance }, { name, page, pageSize = 10, orderDir
|
|
|
55
55
|
});
|
|
56
56
|
return {
|
|
57
57
|
subnames: subdomains,
|
|
58
|
-
subnameCount: domain.subdomainCount
|
|
58
|
+
subnameCount: domain.subdomainCount,
|
|
59
59
|
};
|
|
60
60
|
};
|
|
61
61
|
const smallQuery = async ({ gqlInstance }, { name, page, pageSize = 10, orderDirection, orderBy }) => {
|
|
@@ -94,7 +94,7 @@ const smallQuery = async ({ gqlInstance }, { name, page, pageSize = 10, orderDir
|
|
|
94
94
|
}
|
|
95
95
|
`;
|
|
96
96
|
queryVars = {
|
|
97
|
-
id: (0,
|
|
97
|
+
id: (0, normalise_1.namehash)(name),
|
|
98
98
|
orderBy,
|
|
99
99
|
orderDirection,
|
|
100
100
|
};
|
|
@@ -124,7 +124,7 @@ const smallQuery = async ({ gqlInstance }, { name, page, pageSize = 10, orderDir
|
|
|
124
124
|
}
|
|
125
125
|
`;
|
|
126
126
|
queryVars = {
|
|
127
|
-
id: (0,
|
|
127
|
+
id: (0, normalise_1.namehash)(name),
|
|
128
128
|
first: pageSize,
|
|
129
129
|
skip: (page || 0) * pageSize,
|
|
130
130
|
orderBy,
|
|
@@ -142,7 +142,7 @@ const smallQuery = async ({ gqlInstance }, { name, page, pageSize = 10, orderDir
|
|
|
142
142
|
});
|
|
143
143
|
return {
|
|
144
144
|
subnames: subdomains,
|
|
145
|
-
subnameCount: domain.subdomainCount
|
|
145
|
+
subnameCount: domain.subdomainCount,
|
|
146
146
|
};
|
|
147
147
|
};
|
|
148
148
|
const getSubnames = (injected, functionArgs) => {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { ENSArgs } from '..';
|
|
2
|
-
export default function ({ contracts,
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
export default function ({ contracts, signer }: ENSArgs<'contracts' | 'signer'>, name: string, { address, resolver, }?: {
|
|
3
|
+
address?: string;
|
|
4
|
+
resolver?: string;
|
|
5
|
+
}): Promise<import("ethers").PopulatedTransaction>;
|
|
@@ -1,17 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
async function default_1({ contracts,
|
|
4
|
-
const signerAddress = await
|
|
5
|
-
|
|
6
|
-
.getAddress();
|
|
7
|
-
if (!signerAddress) {
|
|
8
|
-
throw new Error('No signer found');
|
|
9
|
-
}
|
|
10
|
-
const reverseRegistrar = (await contracts?.getReverseRegistrar())?.connect(provider?.getSigner());
|
|
3
|
+
async function default_1({ contracts, signer }, name, { address, resolver, } = {}) {
|
|
4
|
+
const signerAddress = await signer.getAddress();
|
|
5
|
+
const reverseRegistrar = (await contracts?.getReverseRegistrar())?.connect(signer);
|
|
11
6
|
if (address) {
|
|
12
7
|
const publicResolver = await contracts?.getPublicResolver();
|
|
13
|
-
return reverseRegistrar
|
|
8
|
+
return reverseRegistrar.populateTransaction.setNameForAddr(address, signerAddress, resolver || publicResolver.address, name);
|
|
14
9
|
}
|
|
15
|
-
return reverseRegistrar
|
|
10
|
+
return reverseRegistrar.populateTransaction.setName(name);
|
|
16
11
|
}
|
|
17
12
|
exports.default = default_1;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { ENSArgs } from '..';
|
|
2
|
+
import { RecordInput, RecordTypes } from '../utils/recordHelpers';
|
|
3
|
+
declare type BaseInput = {
|
|
4
|
+
resolverAddress?: string;
|
|
5
|
+
};
|
|
6
|
+
declare type ContentHashInput = {
|
|
7
|
+
record: RecordInput<'contentHash'>;
|
|
8
|
+
type: 'contentHash';
|
|
9
|
+
};
|
|
10
|
+
declare type AddrOrTextInput = {
|
|
11
|
+
record: RecordInput<'addr' | 'text'>;
|
|
12
|
+
type: 'addr' | 'text';
|
|
13
|
+
};
|
|
14
|
+
export default function <T extends RecordTypes>({ contracts, provider, getResolver, signer, }: ENSArgs<'contracts' | 'provider' | 'getResolver' | 'signer'>, name: string, { record, type, resolverAddress, }: BaseInput & (ContentHashInput | AddrOrTextInput)): Promise<{
|
|
15
|
+
to: string;
|
|
16
|
+
data: string;
|
|
17
|
+
}>;
|
|
18
|
+
export {};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const normalise_1 = require("../utils/normalise");
|
|
4
|
+
const recordHelpers_1 = require("../utils/recordHelpers");
|
|
5
|
+
async function default_1({ contracts, provider, getResolver, signer, }, name, { record, type, resolverAddress, }) {
|
|
6
|
+
if (!name.includes('.')) {
|
|
7
|
+
throw new Error('Input is not an ENS name');
|
|
8
|
+
}
|
|
9
|
+
let resolverToUse;
|
|
10
|
+
if (resolverAddress) {
|
|
11
|
+
resolverToUse = resolverAddress;
|
|
12
|
+
}
|
|
13
|
+
else {
|
|
14
|
+
resolverToUse = await getResolver(name);
|
|
15
|
+
}
|
|
16
|
+
if (!resolverToUse) {
|
|
17
|
+
throw new Error('No resolver found for input address');
|
|
18
|
+
}
|
|
19
|
+
const resolver = (await contracts?.getPublicResolver(provider, resolverToUse))?.connect(signer);
|
|
20
|
+
const hash = (0, normalise_1.namehash)(name);
|
|
21
|
+
const call = (0, recordHelpers_1.generateSingleRecordCall)(hash, resolver, type)(record);
|
|
22
|
+
return {
|
|
23
|
+
to: resolver.address,
|
|
24
|
+
data: call,
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
exports.default = default_1;
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import { ethers } from 'ethers';
|
|
2
1
|
import { ENSArgs } from '..';
|
|
3
2
|
import { RecordOptions } from '../utils/recordHelpers';
|
|
4
|
-
export default function ({ contracts, provider, getResolver, }: ENSArgs<'contracts' | 'provider' | 'getResolver'>, name: string, records
|
|
3
|
+
export default function ({ contracts, provider, getResolver, signer, }: ENSArgs<'contracts' | 'provider' | 'getResolver' | 'signer'>, name: string, { records, resolverAddress, }: {
|
|
4
|
+
records: RecordOptions;
|
|
5
|
+
resolverAddress?: string;
|
|
6
|
+
}): Promise<import("ethers").PopulatedTransaction>;
|
|
@@ -1,22 +1,24 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const
|
|
3
|
+
const normalise_1 = require("../utils/normalise");
|
|
4
4
|
const recordHelpers_1 = require("../utils/recordHelpers");
|
|
5
|
-
async function default_1({ contracts, provider, getResolver, }, name, records) {
|
|
5
|
+
async function default_1({ contracts, provider, getResolver, signer, }, name, { records, resolverAddress, }) {
|
|
6
6
|
if (!name.includes('.')) {
|
|
7
7
|
throw new Error('Input is not an ENS name');
|
|
8
8
|
}
|
|
9
|
-
|
|
10
|
-
if (
|
|
11
|
-
|
|
9
|
+
let resolverToUse;
|
|
10
|
+
if (resolverAddress) {
|
|
11
|
+
resolverToUse = resolverAddress;
|
|
12
|
+
}
|
|
13
|
+
else {
|
|
14
|
+
resolverToUse = await getResolver(name);
|
|
12
15
|
}
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
throw new Error('No signer found');
|
|
16
|
+
if (!resolverToUse) {
|
|
17
|
+
throw new Error('No resolver found for input address');
|
|
16
18
|
}
|
|
17
|
-
const resolver = (await contracts?.getPublicResolver(provider,
|
|
18
|
-
const
|
|
19
|
-
const calls = (0, recordHelpers_1.generateRecordCallArray)(
|
|
20
|
-
return resolver
|
|
19
|
+
const resolver = (await contracts?.getPublicResolver(provider, resolverToUse))?.connect(signer);
|
|
20
|
+
const hash = (0, normalise_1.namehash)(name);
|
|
21
|
+
const calls = (0, recordHelpers_1.generateRecordCallArray)(hash, records, resolver);
|
|
22
|
+
return resolver.populateTransaction.multicall(calls);
|
|
21
23
|
}
|
|
22
24
|
exports.default = default_1;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ethers } from 'ethers';
|
|
2
1
|
import { ENSArgs } from '..';
|
|
3
|
-
export default function ({ contracts,
|
|
4
|
-
|
|
5
|
-
|
|
2
|
+
export default function ({ contracts, signer }: ENSArgs<'contracts' | 'signer'>, name: string, { contract, resolver, }: {
|
|
3
|
+
contract: 'registry' | 'nameWrapper';
|
|
4
|
+
resolver?: string;
|
|
5
|
+
}): Promise<import("ethers").PopulatedTransaction>;
|
|
@@ -1,24 +1,18 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const
|
|
4
|
-
async function default_1({ contracts,
|
|
5
|
-
const address = await provider
|
|
6
|
-
?.getSigner(options?.addressOrIndex)
|
|
7
|
-
.getAddress();
|
|
8
|
-
if (!address) {
|
|
9
|
-
throw new Error('No signer found');
|
|
10
|
-
}
|
|
3
|
+
const normalise_1 = require("../utils/normalise");
|
|
4
|
+
async function default_1({ contracts, signer }, name, { contract, resolver, }) {
|
|
11
5
|
if (!resolver) {
|
|
12
6
|
resolver = (await contracts?.getPublicResolver()).address;
|
|
13
7
|
}
|
|
14
8
|
switch (contract) {
|
|
15
9
|
case 'registry': {
|
|
16
|
-
const registry = (await contracts?.getRegistry()).connect(
|
|
17
|
-
return registry.setResolver(
|
|
10
|
+
const registry = (await contracts?.getRegistry()).connect(signer);
|
|
11
|
+
return registry.populateTransaction.setResolver((0, normalise_1.namehash)(name), resolver);
|
|
18
12
|
}
|
|
19
13
|
case 'nameWrapper': {
|
|
20
|
-
const nameWrapper = (await contracts?.getNameWrapper()).connect(
|
|
21
|
-
return nameWrapper.setResolver(
|
|
14
|
+
const nameWrapper = (await contracts?.getNameWrapper()).connect(signer);
|
|
15
|
+
return nameWrapper.populateTransaction.setResolver((0, normalise_1.namehash)(name), resolver);
|
|
22
16
|
}
|
|
23
17
|
default: {
|
|
24
18
|
throw new Error(`Unknown contract: ${contract}`);
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { ethers } from 'ethers';
|
|
2
2
|
import { ENSArgs } from '..';
|
|
3
|
-
export default function ({ contracts,
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
export default function ({ contracts, signer }: ENSArgs<'contracts' | 'signer'>, name: string, { newOwner, contract, }: {
|
|
4
|
+
newOwner: string;
|
|
5
|
+
contract: 'registry' | 'nameWrapper' | 'baseRegistrar';
|
|
6
|
+
}): Promise<ethers.PopulatedTransaction>;
|
|
@@ -1,29 +1,25 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const ethers_1 = require("ethers");
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
.getAddress();
|
|
8
|
-
if (!address) {
|
|
9
|
-
throw new Error('No signer found');
|
|
10
|
-
}
|
|
4
|
+
const normalise_1 = require("../utils/normalise");
|
|
5
|
+
async function default_1({ contracts, signer }, name, { newOwner, contract, }) {
|
|
6
|
+
const address = await signer.getAddress();
|
|
11
7
|
switch (contract) {
|
|
12
8
|
case 'registry': {
|
|
13
|
-
const registry = (await contracts?.getRegistry()).connect(
|
|
14
|
-
return registry.setOwner(
|
|
9
|
+
const registry = (await contracts?.getRegistry()).connect(signer);
|
|
10
|
+
return registry.populateTransaction.setOwner((0, normalise_1.namehash)(name), newOwner);
|
|
15
11
|
}
|
|
16
12
|
case 'baseRegistrar': {
|
|
17
|
-
const baseRegistrar = (await contracts?.getBaseRegistrar()).connect(
|
|
13
|
+
const baseRegistrar = (await contracts?.getBaseRegistrar()).connect(signer);
|
|
18
14
|
const labels = name.split('.');
|
|
19
15
|
if (labels.length > 2 || labels[labels.length - 1] !== 'eth') {
|
|
20
16
|
throw new Error('Invalid name for baseRegistrar');
|
|
21
17
|
}
|
|
22
|
-
return baseRegistrar['safeTransferFrom(address,address,uint256)'](address, newOwner, ethers_1.ethers.utils.solidityKeccak256(['string'], [labels[0]]));
|
|
18
|
+
return baseRegistrar.populateTransaction['safeTransferFrom(address,address,uint256)'](address, newOwner, ethers_1.ethers.utils.solidityKeccak256(['string'], [labels[0]]));
|
|
23
19
|
}
|
|
24
20
|
case 'nameWrapper': {
|
|
25
|
-
const nameWrapper = (await contracts?.getNameWrapper()).connect(
|
|
26
|
-
return nameWrapper.safeTransferFrom(address, newOwner,
|
|
21
|
+
const nameWrapper = (await contracts?.getNameWrapper()).connect(signer);
|
|
22
|
+
return nameWrapper.populateTransaction.safeTransferFrom(address, newOwner, (0, normalise_1.namehash)(name), 1, '0x');
|
|
27
23
|
}
|
|
28
24
|
default: {
|
|
29
25
|
throw new Error(`Unknown contract: ${contract}`);
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { ethers } from 'ethers';
|
|
2
2
|
import { ENSArgs } from '..';
|
|
3
|
-
export default function ({ contracts,
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
export default function ({ contracts, signer }: ENSArgs<'contracts' | 'signer'>, name: string, { contract, address, }: {
|
|
4
|
+
contract: 'registry' | 'nameWrapper';
|
|
5
|
+
address: string;
|
|
6
|
+
}): Promise<ethers.PopulatedTransaction>;
|
|
@@ -1,23 +1,20 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const ethers_1 = require("ethers");
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
if (!signer) {
|
|
7
|
-
throw new Error('No signer found');
|
|
8
|
-
}
|
|
4
|
+
const normalise_1 = require("../utils/normalise");
|
|
5
|
+
async function default_1({ contracts, signer }, name, { contract, address, }) {
|
|
9
6
|
const labels = name.split('.');
|
|
10
7
|
const label = labels.shift();
|
|
11
8
|
const labelhash = ethers_1.ethers.utils.solidityKeccak256(['string'], [label]);
|
|
12
|
-
const parentNodehash =
|
|
9
|
+
const parentNodehash = (0, normalise_1.namehash)(labels.join('.'));
|
|
13
10
|
switch (contract) {
|
|
14
11
|
case 'registry': {
|
|
15
12
|
const registry = (await contracts?.getRegistry()).connect(signer);
|
|
16
|
-
return registry.setSubnodeOwner(parentNodehash, labelhash, address);
|
|
13
|
+
return registry.populateTransaction.setSubnodeOwner(parentNodehash, labelhash, address);
|
|
17
14
|
}
|
|
18
15
|
case 'nameWrapper': {
|
|
19
16
|
const nameWrapper = (await contracts?.getNameWrapper()).connect(signer);
|
|
20
|
-
return nameWrapper.setSubnodeOwner(parentNodehash, label, address, '0');
|
|
17
|
+
return nameWrapper.populateTransaction.setSubnodeOwner(parentNodehash, label, address, '0');
|
|
21
18
|
}
|
|
22
19
|
default: {
|
|
23
20
|
throw new Error(`Unknown contract: ${contract}`);
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { ENSArgs } from '..';
|
|
2
|
-
export default function ({ contracts,
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
export default function ({ contracts, signer }: ENSArgs<'contracts' | 'signer'>, name: string, { newController, newRegistrant, }: {
|
|
3
|
+
newController: string;
|
|
4
|
+
newRegistrant?: string;
|
|
5
|
+
}): Promise<import("ethers").PopulatedTransaction>;
|
|
@@ -1,27 +1,23 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const ethers_1 = require("ethers");
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
const address = await signer?.getAddress();
|
|
7
|
-
if (!signer || !address) {
|
|
8
|
-
throw new Error('No signer found');
|
|
9
|
-
}
|
|
4
|
+
const normalise_1 = require("../utils/normalise");
|
|
5
|
+
async function default_1({ contracts, signer }, name, { newController, newRegistrant, }) {
|
|
10
6
|
const labels = name.split('.');
|
|
11
7
|
const labelhash = ethers_1.utils.solidityKeccak256(['string'], [labels[0]]);
|
|
12
|
-
const parentNodehash =
|
|
8
|
+
const parentNodehash = (0, normalise_1.namehash)(labels.slice(1).join('.'));
|
|
13
9
|
const nameWrapper = (await contracts?.getNameWrapper()).connect(signer);
|
|
14
10
|
if (labels.length === 2 && labels[1] === 'eth') {
|
|
15
11
|
if (!newRegistrant) {
|
|
16
12
|
throw new Error('newRegistrant must be specified for .eth names');
|
|
17
13
|
}
|
|
18
|
-
return nameWrapper.unwrapETH2LD(labelhash, newRegistrant, newController);
|
|
14
|
+
return nameWrapper.populateTransaction.unwrapETH2LD(labelhash, newRegistrant, newController);
|
|
19
15
|
}
|
|
20
16
|
else {
|
|
21
17
|
if (newRegistrant) {
|
|
22
18
|
throw new Error('newRegistrant can only be specified for .eth names');
|
|
23
19
|
}
|
|
24
|
-
return nameWrapper.unwrap(parentNodehash, labelhash, newController);
|
|
20
|
+
return nameWrapper.populateTransaction.unwrap(parentNodehash, labelhash, newController);
|
|
25
21
|
}
|
|
26
22
|
}
|
|
27
23
|
exports.default = default_1;
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { ethers } from 'ethers';
|
|
2
2
|
import { ENSArgs } from '..';
|
|
3
3
|
import type { FuseOptions } from '../@types/FuseOptions';
|
|
4
|
-
export default function ({ contracts,
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
export default function ({ contracts, signer, populate }: ENSArgs<'contracts' | 'signer' | 'populate'>, name: string, { wrappedOwner, fuseOptions, resolverAddress, }: {
|
|
5
|
+
wrappedOwner: string;
|
|
6
|
+
fuseOptions?: FuseOptions | string | number;
|
|
7
|
+
resolverAddress?: string;
|
|
8
|
+
}): Promise<ethers.PopulatedTransaction>;
|
|
@@ -10,24 +10,20 @@ async function wrapETH({ contracts }, labels, wrappedOwner, decodedFuses, resolv
|
|
|
10
10
|
const nameWrapper = await contracts?.getNameWrapper();
|
|
11
11
|
const baseRegistrar = (await contracts?.getBaseRegistrar()).connect(signer);
|
|
12
12
|
const labelhash = ethers_1.ethers.utils.solidityKeccak256(['string'], [labels[0]]);
|
|
13
|
-
const data = ethers_1.ethers.utils.defaultAbiCoder.encode(['string', 'address', '
|
|
14
|
-
return baseRegistrar['safeTransferFrom(address,address,uint256,bytes)'](address, nameWrapper.address, labelhash, data);
|
|
13
|
+
const data = ethers_1.ethers.utils.defaultAbiCoder.encode(['string', 'address', 'uint32', 'uint64', 'address'], [labels[0], wrappedOwner, '0x0', decodedFuses, resolverAddress]);
|
|
14
|
+
return baseRegistrar.populateTransaction['safeTransferFrom(address,address,uint256,bytes)'](address, nameWrapper.address, labelhash, data);
|
|
15
15
|
}
|
|
16
|
-
async function wrapOther({ contracts }, name, wrappedOwner, decodedFuses, resolverAddress, address) {
|
|
17
|
-
const nameWrapper = await contracts?.getNameWrapper();
|
|
16
|
+
async function wrapOther({ contracts }, name, wrappedOwner, decodedFuses, resolverAddress, address, signer) {
|
|
17
|
+
const nameWrapper = (await contracts?.getNameWrapper()).connect(signer);
|
|
18
18
|
const registry = await contracts?.getRegistry();
|
|
19
19
|
const hasApproval = await registry.isApprovedForAll(address, nameWrapper.address);
|
|
20
20
|
if (!hasApproval) {
|
|
21
21
|
throw new Error('NameWrapper must have approval to wrap a name from this address.');
|
|
22
22
|
}
|
|
23
|
-
return nameWrapper.wrap((0, hexEncodedName_1.hexEncodeName)(name), wrappedOwner, decodedFuses, resolverAddress);
|
|
23
|
+
return nameWrapper.populateTransaction.wrap((0, hexEncodedName_1.hexEncodeName)(name), wrappedOwner, decodedFuses, resolverAddress);
|
|
24
24
|
}
|
|
25
|
-
async function default_1({ contracts,
|
|
26
|
-
const
|
|
27
|
-
const address = await signer?.getAddress();
|
|
28
|
-
if (!signer || !address) {
|
|
29
|
-
throw new Error('No signer found');
|
|
30
|
-
}
|
|
25
|
+
async function default_1({ contracts, signer, populate }, name, { wrappedOwner, fuseOptions, resolverAddress, }) {
|
|
26
|
+
const address = await signer.getAddress();
|
|
31
27
|
let decodedFuses;
|
|
32
28
|
switch (typeof fuseOptions) {
|
|
33
29
|
case 'object': {
|
|
@@ -58,7 +54,7 @@ async function default_1({ contracts, provider }, name, wrappedOwner, fuseOption
|
|
|
58
54
|
return wrapETH({ contracts }, labels, wrappedOwner, decodedFuses, resolverAddress, signer, address);
|
|
59
55
|
}
|
|
60
56
|
else {
|
|
61
|
-
return wrapOther({ contracts }, name, wrappedOwner, decodedFuses, resolverAddress, address);
|
|
57
|
+
return wrapOther({ contracts }, name, wrappedOwner, decodedFuses, resolverAddress, address, signer);
|
|
62
58
|
}
|
|
63
59
|
}
|
|
64
60
|
exports.default = default_1;
|
package/dist/cjs/index.d.ts
CHANGED
|
@@ -1,7 +1,19 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { JsonRpcSigner } from '@ethersproject/providers';
|
|
2
|
+
import { ContractTransaction, ethers, PopulatedTransaction } from 'ethers';
|
|
2
3
|
import ContractManager from './contracts';
|
|
3
4
|
import { getContractAddress as _getContractAddress } from './contracts/getContractAddress';
|
|
4
5
|
import { SupportedNetworkId } from './contracts/types';
|
|
6
|
+
import type burnFuses from './functions/burnFuses';
|
|
7
|
+
import type createSubname from './functions/createSubname';
|
|
8
|
+
import type deleteSubname from './functions/deleteSubname';
|
|
9
|
+
import type setName from './functions/setName';
|
|
10
|
+
import type setRecord from './functions/setRecord';
|
|
11
|
+
import type setRecords from './functions/setRecords';
|
|
12
|
+
import type setResolver from './functions/setResolver';
|
|
13
|
+
import type transferName from './functions/transferName';
|
|
14
|
+
import type transferSubname from './functions/transferSubname';
|
|
15
|
+
import type unwrapName from './functions/unwrapName';
|
|
16
|
+
import type wrapName from './functions/wrapName';
|
|
5
17
|
import GqlManager from './GqlManager';
|
|
6
18
|
declare type ENSOptions = {
|
|
7
19
|
graphURI?: string | null;
|
|
@@ -10,6 +22,7 @@ declare type ENSOptions = {
|
|
|
10
22
|
export declare type InternalENS = {
|
|
11
23
|
options?: ENSOptions;
|
|
12
24
|
provider?: ethers.providers.Provider;
|
|
25
|
+
signer: JsonRpcSigner;
|
|
13
26
|
graphURI?: string | null;
|
|
14
27
|
} & ENS;
|
|
15
28
|
export declare type ENSArgs<K extends keyof InternalENS> = {
|
|
@@ -17,6 +30,15 @@ export declare type ENSArgs<K extends keyof InternalENS> = {
|
|
|
17
30
|
};
|
|
18
31
|
declare type OmitFirstArg<F> = F extends (x: any, ...args: infer P) => infer R ? (...args: P) => R : never;
|
|
19
32
|
declare type OmitFirstTwoArgs<F> = F extends (x: any, y: any, ...args: infer P) => infer R ? (...args: P) => R : never;
|
|
33
|
+
declare type WriteOptions = {
|
|
34
|
+
addressOrIndex?: string | number;
|
|
35
|
+
signer?: JsonRpcSigner;
|
|
36
|
+
};
|
|
37
|
+
declare type OptionalWriteOptions<F> = F extends (x: any, arg_0: infer Z, options?: infer P) => infer R ? (name: Z, options?: P & WriteOptions) => R : F extends (x: any, arg_0: infer Z, options: infer P) => infer R ? (name: Z, options: P & WriteOptions) => R : never;
|
|
38
|
+
interface WriteFunction<F extends (...args: any) => any> extends Function {
|
|
39
|
+
(...args: Parameters<OptionalWriteOptions<F>>): Promise<ContractTransaction>;
|
|
40
|
+
populateTransaction: (...args: Parameters<OptionalWriteOptions<F>>) => Promise<PopulatedTransaction>;
|
|
41
|
+
}
|
|
20
42
|
export declare type RawFunction = {
|
|
21
43
|
raw: (...args: any[]) => Promise<{
|
|
22
44
|
to: string;
|
|
@@ -77,6 +99,14 @@ export declare class ENS {
|
|
|
77
99
|
* @returns {OmitFirstArg} - The generated wrapped function
|
|
78
100
|
*/
|
|
79
101
|
private generateFunction;
|
|
102
|
+
/**
|
|
103
|
+
* Generates a write wrapped function
|
|
104
|
+
* @param {string} path - The path of the exported function
|
|
105
|
+
* @param {FunctionDeps} dependencies - An array of ENS properties
|
|
106
|
+
* @param {string} exportName - The export name of the target function
|
|
107
|
+
* @returns {OmitFirstArg} - The generated wrapped function
|
|
108
|
+
*/
|
|
109
|
+
private generateWriteFunction;
|
|
80
110
|
/**
|
|
81
111
|
* Generates a wrapped function from raw and decode exports
|
|
82
112
|
* @param {string} path - The path of the exported function
|
|
@@ -104,11 +134,13 @@ export declare class ENS {
|
|
|
104
134
|
}>;
|
|
105
135
|
decode: ({ multicallWrapper }: ENSArgs<"multicallWrapper">, data: string, ...items: BatchFunctionResult<RawFunction>[]) => Promise<any[] | undefined>;
|
|
106
136
|
}>;
|
|
107
|
-
getProfile: (nameOrAddress: string, options?: {
|
|
137
|
+
getProfile: (nameOrAddress: string, options?: ({
|
|
108
138
|
contentHash?: boolean | undefined;
|
|
109
139
|
texts?: boolean | string[] | undefined;
|
|
110
140
|
coinTypes?: boolean | string[] | undefined;
|
|
111
|
-
}
|
|
141
|
+
} & {
|
|
142
|
+
resolverAddress?: string | undefined;
|
|
143
|
+
}) | undefined) => Promise<{
|
|
112
144
|
isMigrated: boolean | null;
|
|
113
145
|
createdAt: string | null;
|
|
114
146
|
address?: string | undefined;
|
|
@@ -137,6 +169,7 @@ export declare class ENS {
|
|
|
137
169
|
contentHash?: boolean | undefined;
|
|
138
170
|
texts?: boolean | string[] | undefined;
|
|
139
171
|
coinTypes?: boolean | string[] | undefined;
|
|
172
|
+
resolverAddress?: string | undefined;
|
|
140
173
|
} | undefined) => Promise<{
|
|
141
174
|
isMigrated: boolean | null;
|
|
142
175
|
createdAt: string | null;
|
|
@@ -423,48 +456,17 @@ export declare class ENS {
|
|
|
423
456
|
}>;
|
|
424
457
|
decode: ({ contracts }: ENSArgs<"contracts">, data: string) => Promise<any>;
|
|
425
458
|
}>;
|
|
426
|
-
setName:
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
} | undefined) => Promise<ethers.ContractTransaction>;
|
|
439
|
-
unwrapName: (name: string, newController: string, newRegistrant?: string | undefined, options?: {
|
|
440
|
-
addressOrIndex?: string | number | undefined;
|
|
441
|
-
} | undefined) => Promise<ethers.ContractTransaction>;
|
|
442
|
-
burnFuses: (name: string, fusesToBurn: import("./@types/FuseOptions").FuseOptions) => Promise<ethers.ContractTransaction>;
|
|
443
|
-
createSubname: (args_0: {
|
|
444
|
-
name: string;
|
|
445
|
-
owner: string;
|
|
446
|
-
resolverAddress?: string | undefined;
|
|
447
|
-
contract: "nameWrapper" | "registry";
|
|
448
|
-
options?: {
|
|
449
|
-
addressOrIndex?: string | number | undefined;
|
|
450
|
-
} | undefined;
|
|
451
|
-
} | ({
|
|
452
|
-
contract: "nameWrapper";
|
|
453
|
-
fuses?: import("./@types/FuseOptions").FuseOptions | undefined;
|
|
454
|
-
} & {
|
|
455
|
-
name: string;
|
|
456
|
-
owner: string;
|
|
457
|
-
resolverAddress?: string | undefined;
|
|
458
|
-
contract: "nameWrapper" | "registry";
|
|
459
|
-
options?: {
|
|
460
|
-
addressOrIndex?: string | number | undefined;
|
|
461
|
-
} | undefined;
|
|
462
|
-
})) => Promise<ethers.ContractTransaction>;
|
|
463
|
-
deleteSubname: (name: string, contract: "nameWrapper" | "registry", options?: {
|
|
464
|
-
addressOrIndex?: string | number | undefined;
|
|
465
|
-
} | undefined) => Promise<ethers.ContractTransaction>;
|
|
466
|
-
transferSubname: (name: string, contract: "nameWrapper" | "registry", address: string, options?: {
|
|
467
|
-
addressOrIndex?: string | number | undefined;
|
|
468
|
-
} | undefined) => Promise<ethers.ContractTransaction>;
|
|
459
|
+
setName: WriteFunction<typeof setName>;
|
|
460
|
+
setRecords: WriteFunction<typeof setRecords>;
|
|
461
|
+
setRecord: WriteFunction<typeof setRecord>;
|
|
462
|
+
setResolver: WriteFunction<typeof setResolver>;
|
|
463
|
+
transferName: WriteFunction<typeof transferName>;
|
|
464
|
+
wrapName: WriteFunction<typeof wrapName>;
|
|
465
|
+
unwrapName: WriteFunction<typeof unwrapName>;
|
|
466
|
+
burnFuses: WriteFunction<typeof burnFuses>;
|
|
467
|
+
createSubname: WriteFunction<typeof createSubname>;
|
|
468
|
+
deleteSubname: WriteFunction<typeof deleteSubname>;
|
|
469
|
+
transferSubname: WriteFunction<typeof transferSubname>;
|
|
470
|
+
getDNSOwner: (dnsName: string) => Promise<any>;
|
|
469
471
|
}
|
|
470
472
|
export {};
|