@ensdomains/ensjs 3.0.0-alpha.12 → 3.0.0-alpha.13
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/commitName.d.ts +26 -0
- package/dist/cjs/functions/commitName.js +24 -0
- package/dist/cjs/functions/getProfile.js +1 -1
- package/dist/cjs/functions/registerName.d.ts +11 -0
- package/dist/cjs/functions/registerName.js +19 -0
- package/dist/cjs/functions/renewName.d.ts +6 -0
- package/dist/cjs/functions/renewName.js +10 -0
- package/dist/cjs/index.d.ts +10 -2
- package/dist/cjs/index.js +6 -1
- package/dist/cjs/utils/registerHelpers.d.ts +44 -16
- package/dist/cjs/utils/registerHelpers.js +43 -15
- package/dist/cjs/utils/writeTx.d.ts +18 -1
- package/dist/cjs/utils/writeTx.js +4 -1
- package/dist/esm/functions/commitName.d.ts +26 -0
- package/dist/esm/functions/commitName.js +21 -0
- package/dist/esm/functions/getProfile.js +1 -1
- package/dist/esm/functions/registerName.d.ts +11 -0
- package/dist/esm/functions/registerName.js +16 -0
- package/dist/esm/functions/renewName.d.ts +6 -0
- package/dist/esm/functions/renewName.js +7 -0
- package/dist/esm/index.d.ts +10 -2
- package/dist/esm/index.js +6 -1
- package/dist/esm/utils/registerHelpers.d.ts +44 -16
- package/dist/esm/utils/registerHelpers.js +40 -14
- package/dist/esm/utils/writeTx.d.ts +18 -1
- package/dist/esm/utils/writeTx.js +4 -1
- package/package.json +19 -22
- package/src/functions/commitName.test.ts +61 -0
- package/src/functions/commitName.ts +36 -0
- package/src/functions/getProfile.ts +1 -1
- package/src/functions/registerName.test.ts +59 -0
- package/src/functions/registerName.ts +38 -0
- package/src/functions/renewName.test.ts +44 -0
- package/src/functions/renewName.ts +22 -0
- package/src/index.ts +25 -4
- package/src/utils/registerHelpers.ts +107 -49
- package/src/utils/writeTx.ts +12 -2
- package/src/tests/populateTransaction.test.ts +0 -40
- package/src/tests/setup.ts +0 -57
- package/src/tests/signerInjection.test.ts +0 -46
- package/src/tests/withProvider.test.ts +0 -28
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { ENSArgs } from '..';
|
|
2
|
+
import { CommitmentParams } from '../utils/registerHelpers';
|
|
3
|
+
declare type Params = Omit<CommitmentParams, 'resolver' | 'name'> & {
|
|
4
|
+
resolverAddress?: string;
|
|
5
|
+
};
|
|
6
|
+
export default function ({ contracts }: ENSArgs<'contracts'>, name: string, { resolverAddress, ...params }: Params): Promise<{
|
|
7
|
+
customData: {
|
|
8
|
+
secret: string;
|
|
9
|
+
commitment: string;
|
|
10
|
+
wrapperExpiry: number;
|
|
11
|
+
};
|
|
12
|
+
to?: string | undefined;
|
|
13
|
+
from?: string | undefined;
|
|
14
|
+
nonce?: number | undefined;
|
|
15
|
+
gasLimit?: import("ethers").BigNumber | undefined;
|
|
16
|
+
gasPrice?: import("ethers").BigNumber | undefined;
|
|
17
|
+
data?: string | undefined;
|
|
18
|
+
value?: import("ethers").BigNumber | undefined;
|
|
19
|
+
chainId?: number | undefined;
|
|
20
|
+
type?: number | undefined;
|
|
21
|
+
accessList?: import("ethers/lib/utils").AccessList | undefined;
|
|
22
|
+
maxFeePerGas?: import("ethers").BigNumber | undefined;
|
|
23
|
+
maxPriorityFeePerGas?: import("ethers").BigNumber | undefined;
|
|
24
|
+
ccipReadEnabled?: boolean | undefined;
|
|
25
|
+
}>;
|
|
26
|
+
export {};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const registerHelpers_1 = require("../utils/registerHelpers");
|
|
4
|
+
async function default_1({ contracts }, name, { resolverAddress, ...params }) {
|
|
5
|
+
const labels = name.split('.');
|
|
6
|
+
if (labels.length !== 2 || labels[1] !== 'eth')
|
|
7
|
+
throw new Error('Currently only .eth TLD registrations are supported');
|
|
8
|
+
const controller = await contracts.getEthRegistrarController();
|
|
9
|
+
const resolver = await contracts.getPublicResolver(undefined, resolverAddress);
|
|
10
|
+
const { secret, commitment, wrapperExpiry } = (0, registerHelpers_1.makeCommitment)({
|
|
11
|
+
name,
|
|
12
|
+
resolver,
|
|
13
|
+
...params,
|
|
14
|
+
});
|
|
15
|
+
return {
|
|
16
|
+
...(await controller.populateTransaction.commit(commitment)),
|
|
17
|
+
customData: {
|
|
18
|
+
secret,
|
|
19
|
+
commitment,
|
|
20
|
+
wrapperExpiry,
|
|
21
|
+
},
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
exports.default = default_1;
|
|
@@ -217,7 +217,7 @@ const graphFetch = async ({ gqlInstance }, name, wantedRecords, resolverAddress)
|
|
|
217
217
|
resolverResponse = domain?.resolver;
|
|
218
218
|
}
|
|
219
219
|
else {
|
|
220
|
-
const resolverId = `${resolverAddress}-${id}`;
|
|
220
|
+
const resolverId = `${resolverAddress.toLowerCase()}-${id}`;
|
|
221
221
|
({ resolver: resolverResponse, domain } = await client.request(customResolverQuery, { id, resolverId }));
|
|
222
222
|
}
|
|
223
223
|
if (!domain)
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { BigNumber } from 'ethers';
|
|
2
|
+
import { ENSArgs } from '..';
|
|
3
|
+
import { CommitmentParams } from '../utils/registerHelpers';
|
|
4
|
+
declare type Params = Omit<CommitmentParams, 'name' | 'resolver'> & {
|
|
5
|
+
resolverAddress?: string;
|
|
6
|
+
secret: string;
|
|
7
|
+
wrapperExpiry: number;
|
|
8
|
+
value: BigNumber;
|
|
9
|
+
};
|
|
10
|
+
export default function ({ contracts }: ENSArgs<'contracts'>, name: string, { resolverAddress, value, ...params }: Params): Promise<import("ethers").PopulatedTransaction>;
|
|
11
|
+
export {};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const registerHelpers_1 = require("../utils/registerHelpers");
|
|
4
|
+
async function default_1({ contracts }, name, { resolverAddress, value, ...params }) {
|
|
5
|
+
const labels = name.split('.');
|
|
6
|
+
if (labels.length !== 2 || labels[1] !== 'eth')
|
|
7
|
+
throw new Error('Currently only .eth TLD registrations are supported');
|
|
8
|
+
const controller = await contracts.getEthRegistrarController();
|
|
9
|
+
const _resolver = await contracts.getPublicResolver(undefined, resolverAddress);
|
|
10
|
+
const generatedParams = (0, registerHelpers_1.makeRegistrationData)({
|
|
11
|
+
name,
|
|
12
|
+
resolver: _resolver,
|
|
13
|
+
...params,
|
|
14
|
+
});
|
|
15
|
+
return controller.populateTransaction.register(...generatedParams, {
|
|
16
|
+
value,
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
exports.default = default_1;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
async function default_1({ contracts }, name, { duration, value, }) {
|
|
4
|
+
const labels = name.split('.');
|
|
5
|
+
if (labels.length !== 2 || labels[1] !== 'eth')
|
|
6
|
+
throw new Error('Currently only .eth TLD renewals are supported');
|
|
7
|
+
const controller = await contracts.getEthRegistrarController();
|
|
8
|
+
return controller.populateTransaction.renew(labels[0], duration, { value });
|
|
9
|
+
}
|
|
10
|
+
exports.default = default_1;
|
package/dist/cjs/index.d.ts
CHANGED
|
@@ -4,8 +4,11 @@ import ContractManager from './contracts';
|
|
|
4
4
|
import { getContractAddress as _getContractAddress } from './contracts/getContractAddress';
|
|
5
5
|
import { SupportedNetworkId } from './contracts/types';
|
|
6
6
|
import type burnFuses from './functions/burnFuses';
|
|
7
|
+
import type commitName from './functions/commitName';
|
|
7
8
|
import type createSubname from './functions/createSubname';
|
|
8
9
|
import type deleteSubname from './functions/deleteSubname';
|
|
10
|
+
import registerName from './functions/registerName';
|
|
11
|
+
import renewName from './functions/renewName';
|
|
9
12
|
import type setName from './functions/setName';
|
|
10
13
|
import type setRecord from './functions/setRecord';
|
|
11
14
|
import type setRecords from './functions/setRecords';
|
|
@@ -36,7 +39,9 @@ declare type WriteOptions = {
|
|
|
36
39
|
};
|
|
37
40
|
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
41
|
interface WriteFunction<F extends (...args: any) => any> extends Function {
|
|
39
|
-
(...args: Parameters<OptionalWriteOptions<F>>): Promise<ContractTransaction
|
|
42
|
+
(...args: Parameters<OptionalWriteOptions<F>>): Promise<ContractTransaction & {
|
|
43
|
+
customData?: Record<string, any>;
|
|
44
|
+
}>;
|
|
40
45
|
populateTransaction: (...args: Parameters<OptionalWriteOptions<F>>) => Promise<PopulatedTransaction>;
|
|
41
46
|
}
|
|
42
47
|
export declare type RawFunction = {
|
|
@@ -405,6 +410,7 @@ export declare class ENS {
|
|
|
405
410
|
premium: ethers.BigNumber;
|
|
406
411
|
} | undefined>;
|
|
407
412
|
}>;
|
|
413
|
+
getDNSOwner: (dnsName: string) => Promise<any>;
|
|
408
414
|
universalWrapper: GeneratedRawFunction<{
|
|
409
415
|
raw: ({ contracts }: ENSArgs<"contracts">, name: string, data: string) => Promise<{
|
|
410
416
|
to: string;
|
|
@@ -443,6 +449,8 @@ export declare class ENS {
|
|
|
443
449
|
createSubname: WriteFunction<typeof createSubname>;
|
|
444
450
|
deleteSubname: WriteFunction<typeof deleteSubname>;
|
|
445
451
|
transferSubname: WriteFunction<typeof transferSubname>;
|
|
446
|
-
|
|
452
|
+
commitName: WriteFunction<typeof commitName>;
|
|
453
|
+
registerName: WriteFunction<typeof registerName>;
|
|
454
|
+
renewName: WriteFunction<typeof renewName>;
|
|
447
455
|
}
|
|
448
456
|
export {};
|
package/dist/cjs/index.js
CHANGED
|
@@ -216,6 +216,7 @@ class ENS {
|
|
|
216
216
|
getSubnames = this.generateFunction('initialGetters', ['gqlInstance'], 'getSubnames');
|
|
217
217
|
getNames = this.generateFunction('initialGetters', ['gqlInstance'], 'getNames');
|
|
218
218
|
getPrice = this.generateRawFunction('initialGetters', ['contracts', 'multicallWrapper'], 'getPrice');
|
|
219
|
+
getDNSOwner = this.generateFunction('getDNSOwner', []);
|
|
219
220
|
universalWrapper = this.generateRawFunction('initialGetters', ['contracts'], 'universalWrapper');
|
|
220
221
|
resolverMulticallWrapper = this.generateRawFunction('initialGetters', ['contracts'], 'resolverMulticallWrapper');
|
|
221
222
|
multicallWrapper = this.generateRawFunction('initialGetters', ['contracts'], 'multicallWrapper');
|
|
@@ -241,6 +242,10 @@ class ENS {
|
|
|
241
242
|
createSubname = this.generateWriteFunction('createSubname', ['contracts', 'getExpiry']);
|
|
242
243
|
deleteSubname = this.generateWriteFunction('deleteSubname', ['transferSubname']);
|
|
243
244
|
transferSubname = this.generateWriteFunction('transferSubname', ['contracts', 'getExpiry']);
|
|
244
|
-
|
|
245
|
+
commitName = this.generateWriteFunction('commitName', ['contracts']);
|
|
246
|
+
registerName = this.generateWriteFunction('registerName', ['contracts']);
|
|
247
|
+
renewName = this.generateWriteFunction('renewName', [
|
|
248
|
+
'contracts',
|
|
249
|
+
]);
|
|
245
250
|
}
|
|
246
251
|
exports.ENS = ENS;
|
|
@@ -1,26 +1,54 @@
|
|
|
1
1
|
import type { FuseOptions } from '../@types/FuseOptions';
|
|
2
2
|
import type { PublicResolver } from '../generated';
|
|
3
3
|
import { RecordOptions } from './recordHelpers';
|
|
4
|
-
export declare
|
|
5
|
-
export declare const makeCommitment: ({ name, owner, duration, resolver, records, reverseRecord, fuses, }: {
|
|
4
|
+
export declare type RegistrationParams = {
|
|
6
5
|
name: string;
|
|
7
6
|
owner: string;
|
|
8
7
|
duration: number;
|
|
8
|
+
secret: string;
|
|
9
9
|
resolver: PublicResolver;
|
|
10
|
-
records?: RecordOptions
|
|
11
|
-
reverseRecord?: boolean
|
|
12
|
-
fuses?: FuseOptions
|
|
13
|
-
|
|
10
|
+
records?: RecordOptions;
|
|
11
|
+
reverseRecord?: boolean;
|
|
12
|
+
fuses?: FuseOptions;
|
|
13
|
+
wrapperExpiry: number;
|
|
14
|
+
};
|
|
15
|
+
export declare type CommitmentParams = Omit<RegistrationParams, 'secret' | 'wrapperExpiry'> & {
|
|
16
|
+
secret?: string;
|
|
17
|
+
wrapperExpiry?: number;
|
|
18
|
+
};
|
|
19
|
+
export declare type RegistrationTuple = [
|
|
20
|
+
name: string,
|
|
21
|
+
owner: string,
|
|
22
|
+
duration: number,
|
|
23
|
+
secret: string,
|
|
24
|
+
resolver: string,
|
|
25
|
+
data: string[],
|
|
26
|
+
reverseRecord: boolean,
|
|
27
|
+
fuses: string,
|
|
28
|
+
wrapperExpiry: number
|
|
29
|
+
];
|
|
30
|
+
export declare type CommitmentTuple = [
|
|
31
|
+
labelhash: string,
|
|
32
|
+
owner: string,
|
|
33
|
+
duration: number,
|
|
34
|
+
resolver: string,
|
|
35
|
+
data: string[],
|
|
36
|
+
secret: string,
|
|
37
|
+
reverseRecord: boolean,
|
|
38
|
+
fuses: string,
|
|
39
|
+
wrapperExpiry: number
|
|
40
|
+
];
|
|
41
|
+
export declare const randomSecret: () => string;
|
|
42
|
+
export declare const makeCommitmentData: ({ name, owner, duration, resolver, records, reverseRecord, fuses, wrapperExpiry, secret, }: Omit<RegistrationParams, "secret" | "wrapperExpiry"> & {
|
|
43
|
+
secret?: string | undefined;
|
|
44
|
+
wrapperExpiry?: number | undefined;
|
|
45
|
+
} & {
|
|
46
|
+
secret: string;
|
|
47
|
+
}) => CommitmentTuple;
|
|
48
|
+
export declare const makeRegistrationData: (params: RegistrationParams) => RegistrationTuple;
|
|
49
|
+
export declare const makeCommitment: ({ secret, ...inputParams }: CommitmentParams) => {
|
|
14
50
|
secret: string;
|
|
15
51
|
commitment: string;
|
|
52
|
+
wrapperExpiry: number;
|
|
16
53
|
};
|
|
17
|
-
export declare const _makeCommitment: (
|
|
18
|
-
labelhash: string;
|
|
19
|
-
owner: string;
|
|
20
|
-
duration: number;
|
|
21
|
-
secret: string;
|
|
22
|
-
resolver: string;
|
|
23
|
-
data: string[];
|
|
24
|
-
reverseRecord: boolean;
|
|
25
|
-
fuses: string;
|
|
26
|
-
}) => string;
|
|
54
|
+
export declare const _makeCommitment: (params: CommitmentTuple) => string;
|
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports._makeCommitment = exports.makeCommitment = exports.randomSecret = void 0;
|
|
6
|
+
exports._makeCommitment = exports.makeCommitment = exports.makeRegistrationData = exports.makeCommitmentData = exports.randomSecret = void 0;
|
|
7
7
|
const ethers_1 = require("ethers");
|
|
8
8
|
const generateFuseInput_1 = __importDefault(require("./generateFuseInput"));
|
|
9
9
|
const labels_1 = require("./labels");
|
|
@@ -14,39 +14,67 @@ const randomSecret = () => {
|
|
|
14
14
|
return '0x' + crypto.getRandomValues(bytes).toString('hex');
|
|
15
15
|
};
|
|
16
16
|
exports.randomSecret = randomSecret;
|
|
17
|
-
const
|
|
17
|
+
const makeCommitmentData = ({ name, owner, duration, resolver, records, reverseRecord, fuses, wrapperExpiry, secret, }) => {
|
|
18
18
|
const label = (0, labels_1.labelhash)(name.split('.')[0]);
|
|
19
19
|
const hash = (0, normalise_1.namehash)(name);
|
|
20
20
|
const resolverAddress = resolver.address;
|
|
21
|
-
const data = records ? (0, recordHelpers_1.generateRecordCallArray)(hash, records, resolver) : [];
|
|
22
|
-
const secret = (0, exports.randomSecret)();
|
|
23
21
|
const fuseData = fuses ? (0, generateFuseInput_1.default)(fuses) : '0';
|
|
24
|
-
|
|
25
|
-
|
|
22
|
+
if (reverseRecord) {
|
|
23
|
+
if (!records) {
|
|
24
|
+
records = { coinTypes: [{ key: 'ETH', value: owner }] };
|
|
25
|
+
}
|
|
26
|
+
else if (!records.coinTypes?.find((c) => c.key === 'ETH')) {
|
|
27
|
+
if (!records.coinTypes)
|
|
28
|
+
records.coinTypes = [];
|
|
29
|
+
records.coinTypes.push({ key: 'ETH', value: owner });
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
const data = records ? (0, recordHelpers_1.generateRecordCallArray)(hash, records, resolver) : [];
|
|
33
|
+
return [
|
|
34
|
+
label,
|
|
26
35
|
owner,
|
|
27
36
|
duration,
|
|
28
|
-
|
|
29
|
-
resolver: resolverAddress,
|
|
37
|
+
resolverAddress,
|
|
30
38
|
data,
|
|
31
|
-
|
|
32
|
-
|
|
39
|
+
secret,
|
|
40
|
+
!!reverseRecord,
|
|
41
|
+
fuseData,
|
|
42
|
+
wrapperExpiry || Math.floor(Date.now() / 1000) + duration,
|
|
43
|
+
];
|
|
44
|
+
};
|
|
45
|
+
exports.makeCommitmentData = makeCommitmentData;
|
|
46
|
+
const makeRegistrationData = (params) => {
|
|
47
|
+
const commitmentData = (0, exports.makeCommitmentData)(params);
|
|
48
|
+
commitmentData[0] = params.name.split('.')[0];
|
|
49
|
+
const secret = commitmentData.splice(5, 1)[0];
|
|
50
|
+
commitmentData.splice(3, 0, secret);
|
|
51
|
+
return commitmentData;
|
|
52
|
+
};
|
|
53
|
+
exports.makeRegistrationData = makeRegistrationData;
|
|
54
|
+
const makeCommitment = ({ secret = (0, exports.randomSecret)(), ...inputParams }) => {
|
|
55
|
+
const generatedParams = (0, exports.makeCommitmentData)({
|
|
56
|
+
...inputParams,
|
|
57
|
+
secret,
|
|
33
58
|
});
|
|
59
|
+
const commitment = (0, exports._makeCommitment)(generatedParams);
|
|
34
60
|
return {
|
|
35
61
|
secret,
|
|
36
62
|
commitment,
|
|
63
|
+
wrapperExpiry: generatedParams[8],
|
|
37
64
|
};
|
|
38
65
|
};
|
|
39
66
|
exports.makeCommitment = makeCommitment;
|
|
40
|
-
const _makeCommitment = (
|
|
41
|
-
return ethers_1.utils.
|
|
67
|
+
const _makeCommitment = (params) => {
|
|
68
|
+
return ethers_1.utils.keccak256(ethers_1.utils.defaultAbiCoder.encode([
|
|
42
69
|
'bytes32',
|
|
43
70
|
'address',
|
|
44
71
|
'uint256',
|
|
45
|
-
'bytes32',
|
|
46
72
|
'address',
|
|
47
73
|
'bytes[]',
|
|
74
|
+
'bytes32',
|
|
48
75
|
'bool',
|
|
49
|
-
'
|
|
50
|
-
|
|
76
|
+
'uint32',
|
|
77
|
+
'uint64',
|
|
78
|
+
], params));
|
|
51
79
|
};
|
|
52
80
|
exports._makeCommitment = _makeCommitment;
|
|
@@ -1,4 +1,21 @@
|
|
|
1
1
|
import { JsonRpcSigner } from '@ethersproject/providers';
|
|
2
2
|
import type { PopulatedTransaction } from 'ethers';
|
|
3
|
-
declare
|
|
3
|
+
declare type CustomData = Record<string, any>;
|
|
4
|
+
declare const _default: (signer: JsonRpcSigner, populate: boolean) => ({ customData, ...tx }: PopulatedTransaction) => {
|
|
5
|
+
to?: string | undefined;
|
|
6
|
+
from?: string | undefined;
|
|
7
|
+
nonce?: number | undefined;
|
|
8
|
+
gasLimit?: import("ethers").BigNumber | undefined;
|
|
9
|
+
gasPrice?: import("ethers").BigNumber | undefined;
|
|
10
|
+
data?: string | undefined;
|
|
11
|
+
value?: import("ethers").BigNumber | undefined;
|
|
12
|
+
chainId?: number | undefined;
|
|
13
|
+
type?: number | undefined;
|
|
14
|
+
accessList?: import("ethers/lib/utils").AccessList | undefined;
|
|
15
|
+
maxFeePerGas?: import("ethers").BigNumber | undefined;
|
|
16
|
+
maxPriorityFeePerGas?: import("ethers").BigNumber | undefined;
|
|
17
|
+
ccipReadEnabled?: boolean | undefined;
|
|
18
|
+
} | Promise<import("@ethersproject/providers").TransactionResponse | (import("@ethersproject/providers").TransactionResponse & {
|
|
19
|
+
customData: CustomData;
|
|
20
|
+
})>;
|
|
4
21
|
export default _default;
|
|
@@ -1,3 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
|
|
3
|
+
const withCustomData = (tx, customData) => customData ? { ...tx, customData } : tx;
|
|
4
|
+
exports.default = (signer, populate) => ({ customData, ...tx }) => populate
|
|
5
|
+
? withCustomData(tx, customData)
|
|
6
|
+
: signer.sendTransaction(tx).then((r) => withCustomData(r, customData));
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { ENSArgs } from '..';
|
|
2
|
+
import { CommitmentParams } from '../utils/registerHelpers';
|
|
3
|
+
declare type Params = Omit<CommitmentParams, 'resolver' | 'name'> & {
|
|
4
|
+
resolverAddress?: string;
|
|
5
|
+
};
|
|
6
|
+
export default function ({ contracts }: ENSArgs<'contracts'>, name: string, { resolverAddress, ...params }: Params): Promise<{
|
|
7
|
+
customData: {
|
|
8
|
+
secret: string;
|
|
9
|
+
commitment: string;
|
|
10
|
+
wrapperExpiry: number;
|
|
11
|
+
};
|
|
12
|
+
to?: string | undefined;
|
|
13
|
+
from?: string | undefined;
|
|
14
|
+
nonce?: number | undefined;
|
|
15
|
+
gasLimit?: import("ethers").BigNumber | undefined;
|
|
16
|
+
gasPrice?: import("ethers").BigNumber | undefined;
|
|
17
|
+
data?: string | undefined;
|
|
18
|
+
value?: import("ethers").BigNumber | undefined;
|
|
19
|
+
chainId?: number | undefined;
|
|
20
|
+
type?: number | undefined;
|
|
21
|
+
accessList?: import("ethers/lib/utils").AccessList | undefined;
|
|
22
|
+
maxFeePerGas?: import("ethers").BigNumber | undefined;
|
|
23
|
+
maxPriorityFeePerGas?: import("ethers").BigNumber | undefined;
|
|
24
|
+
ccipReadEnabled?: boolean | undefined;
|
|
25
|
+
}>;
|
|
26
|
+
export {};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { makeCommitment } from '../utils/registerHelpers';
|
|
2
|
+
export default async function ({ contracts }, name, { resolverAddress, ...params }) {
|
|
3
|
+
const labels = name.split('.');
|
|
4
|
+
if (labels.length !== 2 || labels[1] !== 'eth')
|
|
5
|
+
throw new Error('Currently only .eth TLD registrations are supported');
|
|
6
|
+
const controller = await contracts.getEthRegistrarController();
|
|
7
|
+
const resolver = await contracts.getPublicResolver(undefined, resolverAddress);
|
|
8
|
+
const { secret, commitment, wrapperExpiry } = makeCommitment({
|
|
9
|
+
name,
|
|
10
|
+
resolver,
|
|
11
|
+
...params,
|
|
12
|
+
});
|
|
13
|
+
return {
|
|
14
|
+
...(await controller.populateTransaction.commit(commitment)),
|
|
15
|
+
customData: {
|
|
16
|
+
secret,
|
|
17
|
+
commitment,
|
|
18
|
+
wrapperExpiry,
|
|
19
|
+
},
|
|
20
|
+
};
|
|
21
|
+
}
|
|
@@ -215,7 +215,7 @@ const graphFetch = async ({ gqlInstance }, name, wantedRecords, resolverAddress)
|
|
|
215
215
|
resolverResponse = domain?.resolver;
|
|
216
216
|
}
|
|
217
217
|
else {
|
|
218
|
-
const resolverId = `${resolverAddress}-${id}`;
|
|
218
|
+
const resolverId = `${resolverAddress.toLowerCase()}-${id}`;
|
|
219
219
|
({ resolver: resolverResponse, domain } = await client.request(customResolverQuery, { id, resolverId }));
|
|
220
220
|
}
|
|
221
221
|
if (!domain)
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { BigNumber } from 'ethers';
|
|
2
|
+
import { ENSArgs } from '..';
|
|
3
|
+
import { CommitmentParams } from '../utils/registerHelpers';
|
|
4
|
+
declare type Params = Omit<CommitmentParams, 'name' | 'resolver'> & {
|
|
5
|
+
resolverAddress?: string;
|
|
6
|
+
secret: string;
|
|
7
|
+
wrapperExpiry: number;
|
|
8
|
+
value: BigNumber;
|
|
9
|
+
};
|
|
10
|
+
export default function ({ contracts }: ENSArgs<'contracts'>, name: string, { resolverAddress, value, ...params }: Params): Promise<import("ethers").PopulatedTransaction>;
|
|
11
|
+
export {};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { makeRegistrationData, } from '../utils/registerHelpers';
|
|
2
|
+
export default async function ({ contracts }, name, { resolverAddress, value, ...params }) {
|
|
3
|
+
const labels = name.split('.');
|
|
4
|
+
if (labels.length !== 2 || labels[1] !== 'eth')
|
|
5
|
+
throw new Error('Currently only .eth TLD registrations are supported');
|
|
6
|
+
const controller = await contracts.getEthRegistrarController();
|
|
7
|
+
const _resolver = await contracts.getPublicResolver(undefined, resolverAddress);
|
|
8
|
+
const generatedParams = makeRegistrationData({
|
|
9
|
+
name,
|
|
10
|
+
resolver: _resolver,
|
|
11
|
+
...params,
|
|
12
|
+
});
|
|
13
|
+
return controller.populateTransaction.register(...generatedParams, {
|
|
14
|
+
value,
|
|
15
|
+
});
|
|
16
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export default async function ({ contracts }, name, { duration, value, }) {
|
|
2
|
+
const labels = name.split('.');
|
|
3
|
+
if (labels.length !== 2 || labels[1] !== 'eth')
|
|
4
|
+
throw new Error('Currently only .eth TLD renewals are supported');
|
|
5
|
+
const controller = await contracts.getEthRegistrarController();
|
|
6
|
+
return controller.populateTransaction.renew(labels[0], duration, { value });
|
|
7
|
+
}
|
package/dist/esm/index.d.ts
CHANGED
|
@@ -4,8 +4,11 @@ import ContractManager from './contracts';
|
|
|
4
4
|
import { getContractAddress as _getContractAddress } from './contracts/getContractAddress';
|
|
5
5
|
import { SupportedNetworkId } from './contracts/types';
|
|
6
6
|
import type burnFuses from './functions/burnFuses';
|
|
7
|
+
import type commitName from './functions/commitName';
|
|
7
8
|
import type createSubname from './functions/createSubname';
|
|
8
9
|
import type deleteSubname from './functions/deleteSubname';
|
|
10
|
+
import registerName from './functions/registerName';
|
|
11
|
+
import renewName from './functions/renewName';
|
|
9
12
|
import type setName from './functions/setName';
|
|
10
13
|
import type setRecord from './functions/setRecord';
|
|
11
14
|
import type setRecords from './functions/setRecords';
|
|
@@ -36,7 +39,9 @@ declare type WriteOptions = {
|
|
|
36
39
|
};
|
|
37
40
|
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
41
|
interface WriteFunction<F extends (...args: any) => any> extends Function {
|
|
39
|
-
(...args: Parameters<OptionalWriteOptions<F>>): Promise<ContractTransaction
|
|
42
|
+
(...args: Parameters<OptionalWriteOptions<F>>): Promise<ContractTransaction & {
|
|
43
|
+
customData?: Record<string, any>;
|
|
44
|
+
}>;
|
|
40
45
|
populateTransaction: (...args: Parameters<OptionalWriteOptions<F>>) => Promise<PopulatedTransaction>;
|
|
41
46
|
}
|
|
42
47
|
export declare type RawFunction = {
|
|
@@ -405,6 +410,7 @@ export declare class ENS {
|
|
|
405
410
|
premium: ethers.BigNumber;
|
|
406
411
|
} | undefined>;
|
|
407
412
|
}>;
|
|
413
|
+
getDNSOwner: (dnsName: string) => Promise<any>;
|
|
408
414
|
universalWrapper: GeneratedRawFunction<{
|
|
409
415
|
raw: ({ contracts }: ENSArgs<"contracts">, name: string, data: string) => Promise<{
|
|
410
416
|
to: string;
|
|
@@ -443,6 +449,8 @@ export declare class ENS {
|
|
|
443
449
|
createSubname: WriteFunction<typeof createSubname>;
|
|
444
450
|
deleteSubname: WriteFunction<typeof deleteSubname>;
|
|
445
451
|
transferSubname: WriteFunction<typeof transferSubname>;
|
|
446
|
-
|
|
452
|
+
commitName: WriteFunction<typeof commitName>;
|
|
453
|
+
registerName: WriteFunction<typeof registerName>;
|
|
454
|
+
renewName: WriteFunction<typeof renewName>;
|
|
447
455
|
}
|
|
448
456
|
export {};
|
package/dist/esm/index.js
CHANGED
|
@@ -179,6 +179,7 @@ export class ENS {
|
|
|
179
179
|
this.getSubnames = this.generateFunction('initialGetters', ['gqlInstance'], 'getSubnames');
|
|
180
180
|
this.getNames = this.generateFunction('initialGetters', ['gqlInstance'], 'getNames');
|
|
181
181
|
this.getPrice = this.generateRawFunction('initialGetters', ['contracts', 'multicallWrapper'], 'getPrice');
|
|
182
|
+
this.getDNSOwner = this.generateFunction('getDNSOwner', []);
|
|
182
183
|
this.universalWrapper = this.generateRawFunction('initialGetters', ['contracts'], 'universalWrapper');
|
|
183
184
|
this.resolverMulticallWrapper = this.generateRawFunction('initialGetters', ['contracts'], 'resolverMulticallWrapper');
|
|
184
185
|
this.multicallWrapper = this.generateRawFunction('initialGetters', ['contracts'], 'multicallWrapper');
|
|
@@ -204,7 +205,11 @@ export class ENS {
|
|
|
204
205
|
this.createSubname = this.generateWriteFunction('createSubname', ['contracts', 'getExpiry']);
|
|
205
206
|
this.deleteSubname = this.generateWriteFunction('deleteSubname', ['transferSubname']);
|
|
206
207
|
this.transferSubname = this.generateWriteFunction('transferSubname', ['contracts', 'getExpiry']);
|
|
207
|
-
this.
|
|
208
|
+
this.commitName = this.generateWriteFunction('commitName', ['contracts']);
|
|
209
|
+
this.registerName = this.generateWriteFunction('registerName', ['contracts']);
|
|
210
|
+
this.renewName = this.generateWriteFunction('renewName', [
|
|
211
|
+
'contracts',
|
|
212
|
+
]);
|
|
208
213
|
this.options = options;
|
|
209
214
|
this.getContractAddress = options?.getContractAddress || _getContractAddress;
|
|
210
215
|
}
|
|
@@ -1,26 +1,54 @@
|
|
|
1
1
|
import type { FuseOptions } from '../@types/FuseOptions';
|
|
2
2
|
import type { PublicResolver } from '../generated';
|
|
3
3
|
import { RecordOptions } from './recordHelpers';
|
|
4
|
-
export declare
|
|
5
|
-
export declare const makeCommitment: ({ name, owner, duration, resolver, records, reverseRecord, fuses, }: {
|
|
4
|
+
export declare type RegistrationParams = {
|
|
6
5
|
name: string;
|
|
7
6
|
owner: string;
|
|
8
7
|
duration: number;
|
|
8
|
+
secret: string;
|
|
9
9
|
resolver: PublicResolver;
|
|
10
|
-
records?: RecordOptions
|
|
11
|
-
reverseRecord?: boolean
|
|
12
|
-
fuses?: FuseOptions
|
|
13
|
-
|
|
10
|
+
records?: RecordOptions;
|
|
11
|
+
reverseRecord?: boolean;
|
|
12
|
+
fuses?: FuseOptions;
|
|
13
|
+
wrapperExpiry: number;
|
|
14
|
+
};
|
|
15
|
+
export declare type CommitmentParams = Omit<RegistrationParams, 'secret' | 'wrapperExpiry'> & {
|
|
16
|
+
secret?: string;
|
|
17
|
+
wrapperExpiry?: number;
|
|
18
|
+
};
|
|
19
|
+
export declare type RegistrationTuple = [
|
|
20
|
+
name: string,
|
|
21
|
+
owner: string,
|
|
22
|
+
duration: number,
|
|
23
|
+
secret: string,
|
|
24
|
+
resolver: string,
|
|
25
|
+
data: string[],
|
|
26
|
+
reverseRecord: boolean,
|
|
27
|
+
fuses: string,
|
|
28
|
+
wrapperExpiry: number
|
|
29
|
+
];
|
|
30
|
+
export declare type CommitmentTuple = [
|
|
31
|
+
labelhash: string,
|
|
32
|
+
owner: string,
|
|
33
|
+
duration: number,
|
|
34
|
+
resolver: string,
|
|
35
|
+
data: string[],
|
|
36
|
+
secret: string,
|
|
37
|
+
reverseRecord: boolean,
|
|
38
|
+
fuses: string,
|
|
39
|
+
wrapperExpiry: number
|
|
40
|
+
];
|
|
41
|
+
export declare const randomSecret: () => string;
|
|
42
|
+
export declare const makeCommitmentData: ({ name, owner, duration, resolver, records, reverseRecord, fuses, wrapperExpiry, secret, }: Omit<RegistrationParams, "secret" | "wrapperExpiry"> & {
|
|
43
|
+
secret?: string | undefined;
|
|
44
|
+
wrapperExpiry?: number | undefined;
|
|
45
|
+
} & {
|
|
46
|
+
secret: string;
|
|
47
|
+
}) => CommitmentTuple;
|
|
48
|
+
export declare const makeRegistrationData: (params: RegistrationParams) => RegistrationTuple;
|
|
49
|
+
export declare const makeCommitment: ({ secret, ...inputParams }: CommitmentParams) => {
|
|
14
50
|
secret: string;
|
|
15
51
|
commitment: string;
|
|
52
|
+
wrapperExpiry: number;
|
|
16
53
|
};
|
|
17
|
-
export declare const _makeCommitment: (
|
|
18
|
-
labelhash: string;
|
|
19
|
-
owner: string;
|
|
20
|
-
duration: number;
|
|
21
|
-
secret: string;
|
|
22
|
-
resolver: string;
|
|
23
|
-
data: string[];
|
|
24
|
-
reverseRecord: boolean;
|
|
25
|
-
fuses: string;
|
|
26
|
-
}) => string;
|
|
54
|
+
export declare const _makeCommitment: (params: CommitmentTuple) => string;
|