@ensdomains/ensjs 3.0.0-alpha.11 → 3.0.0-alpha.14
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/contracts/index.d.ts +8 -8
- package/dist/cjs/functions/burnFuses.d.ts +31 -4
- package/dist/cjs/functions/burnFuses.js +36 -6
- package/dist/cjs/functions/commitName.d.ts +26 -0
- package/dist/cjs/functions/commitName.js +24 -0
- package/dist/cjs/functions/getFuses.d.ts +2 -1
- package/dist/cjs/functions/getFuses.js +9 -18
- package/dist/cjs/functions/getHistory.d.ts +0 -30
- package/dist/cjs/functions/getHistory.js +3 -99
- package/dist/cjs/functions/getName.d.ts +2 -2
- package/dist/cjs/functions/getName.js +1 -1
- package/dist/cjs/functions/getProfile.js +1 -1
- package/dist/cjs/functions/getSpecificRecord.d.ts +4 -4
- 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 +24 -35
- package/dist/cjs/index.js +8 -3
- package/dist/cjs/utils/fuses.d.ts +18 -17
- package/dist/cjs/utils/fuses.js +10 -4
- package/dist/cjs/utils/registerHelpers.d.ts +44 -16
- package/dist/cjs/utils/registerHelpers.js +43 -15
- package/dist/cjs/utils/wrapperExpiry.d.ts +1 -1
- package/dist/cjs/utils/writeTx.d.ts +18 -1
- package/dist/cjs/utils/writeTx.js +4 -1
- package/dist/esm/contracts/index.d.ts +8 -8
- package/dist/esm/functions/burnFuses.d.ts +31 -4
- package/dist/esm/functions/burnFuses.js +36 -3
- package/dist/esm/functions/commitName.d.ts +26 -0
- package/dist/esm/functions/commitName.js +21 -0
- package/dist/esm/functions/getFuses.d.ts +2 -1
- package/dist/esm/functions/getFuses.js +10 -19
- package/dist/esm/functions/getHistory.d.ts +0 -30
- package/dist/esm/functions/getHistory.js +2 -96
- package/dist/esm/functions/getName.d.ts +2 -2
- package/dist/esm/functions/getName.js +1 -1
- package/dist/esm/functions/getProfile.js +1 -1
- package/dist/esm/functions/getSpecificRecord.d.ts +4 -4
- 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 +24 -35
- package/dist/esm/index.js +8 -3
- package/dist/esm/utils/fuses.d.ts +18 -17
- package/dist/esm/utils/fuses.js +9 -3
- package/dist/esm/utils/registerHelpers.d.ts +44 -16
- package/dist/esm/utils/registerHelpers.js +40 -14
- package/dist/esm/utils/wrapperExpiry.d.ts +1 -1
- 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/burnFuses.test.ts +123 -15
- package/src/functions/burnFuses.ts +101 -10
- package/src/functions/commitName.test.ts +61 -0
- package/src/functions/commitName.ts +36 -0
- package/src/functions/getFuses.test.ts +33 -15
- package/src/functions/getFuses.ts +13 -25
- package/src/functions/getHistory.test.ts +0 -84
- package/src/functions/getHistory.ts +2 -127
- package/src/functions/getName.test.ts +1 -1
- package/src/functions/getName.ts +1 -1
- 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 +28 -25
- package/src/utils/fuses.ts +12 -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 -58
- package/src/tests/signerInjection.test.ts +0 -46
- package/src/tests/withProvider.test.ts +0 -28
package/dist/cjs/index.js
CHANGED
|
@@ -32,6 +32,7 @@ const getContractAddress_1 = require("./contracts/getContractAddress");
|
|
|
32
32
|
const GqlManager_1 = __importDefault(require("./GqlManager"));
|
|
33
33
|
const singleCall_1 = __importDefault(require("./utils/singleCall"));
|
|
34
34
|
const writeTx_1 = __importDefault(require("./utils/writeTx"));
|
|
35
|
+
const fuses_1 = __importDefault(require("./utils/fuses"));
|
|
35
36
|
const graphURIEndpoints = {
|
|
36
37
|
1: 'https://api.thegraph.com/subgraphs/name/ensdomains/ens',
|
|
37
38
|
3: 'https://api.thegraph.com/subgraphs/name/ensdomains/ensropsten',
|
|
@@ -46,6 +47,7 @@ class ENS {
|
|
|
46
47
|
contracts;
|
|
47
48
|
getContractAddress = getContractAddress_1.getContractAddress;
|
|
48
49
|
gqlInstance = new GqlManager_1.default();
|
|
50
|
+
fuses = fuses_1.default;
|
|
49
51
|
constructor(options) {
|
|
50
52
|
this.options = options;
|
|
51
53
|
this.getContractAddress = options?.getContractAddress || getContractAddress_1.getContractAddress;
|
|
@@ -205,8 +207,6 @@ class ENS {
|
|
|
205
207
|
'contracts',
|
|
206
208
|
]);
|
|
207
209
|
getHistory = this.generateFunction('getHistory', ['gqlInstance'], 'getHistory');
|
|
208
|
-
getHistoryWithDetail = this.generateFunction('getHistory', ['contracts', 'gqlInstance', 'provider'], 'getHistoryWithDetail');
|
|
209
|
-
getHistoryDetailForTransactionHash = this.generateFunction('getHistory', ['contracts', 'provider'], 'getHistoryDetailForTransactionHash');
|
|
210
210
|
getContentHash = this.generateRawFunction('initialGetters', ['contracts', 'universalWrapper'], 'getContentHash');
|
|
211
211
|
_getContentHash = this.generateRawFunction('initialGetters', ['contracts'], '_getContentHash');
|
|
212
212
|
getAddr = this.generateRawFunction('initialGetters', ['contracts', 'universalWrapper'], 'getAddr');
|
|
@@ -218,6 +218,7 @@ class ENS {
|
|
|
218
218
|
getSubnames = this.generateFunction('initialGetters', ['gqlInstance'], 'getSubnames');
|
|
219
219
|
getNames = this.generateFunction('initialGetters', ['gqlInstance'], 'getNames');
|
|
220
220
|
getPrice = this.generateRawFunction('initialGetters', ['contracts', 'multicallWrapper'], 'getPrice');
|
|
221
|
+
getDNSOwner = this.generateFunction('getDNSOwner', []);
|
|
221
222
|
universalWrapper = this.generateRawFunction('initialGetters', ['contracts'], 'universalWrapper');
|
|
222
223
|
resolverMulticallWrapper = this.generateRawFunction('initialGetters', ['contracts'], 'resolverMulticallWrapper');
|
|
223
224
|
multicallWrapper = this.generateRawFunction('initialGetters', ['contracts'], 'multicallWrapper');
|
|
@@ -243,6 +244,10 @@ class ENS {
|
|
|
243
244
|
createSubname = this.generateWriteFunction('createSubname', ['contracts', 'getExpiry']);
|
|
244
245
|
deleteSubname = this.generateWriteFunction('deleteSubname', ['transferSubname']);
|
|
245
246
|
transferSubname = this.generateWriteFunction('transferSubname', ['contracts', 'getExpiry']);
|
|
246
|
-
|
|
247
|
+
commitName = this.generateWriteFunction('commitName', ['contracts']);
|
|
248
|
+
registerName = this.generateWriteFunction('registerName', ['contracts']);
|
|
249
|
+
renewName = this.generateWriteFunction('renewName', [
|
|
250
|
+
'contracts',
|
|
251
|
+
]);
|
|
247
252
|
}
|
|
248
253
|
exports.ENS = ENS;
|
|
@@ -1,20 +1,21 @@
|
|
|
1
|
-
export declare const
|
|
2
|
-
CANNOT_UNWRAP:
|
|
3
|
-
CANNOT_BURN_FUSES:
|
|
4
|
-
CANNOT_TRANSFER:
|
|
5
|
-
CANNOT_SET_RESOLVER:
|
|
6
|
-
CANNOT_SET_TTL:
|
|
7
|
-
CANNOT_CREATE_SUBDOMAIN:
|
|
8
|
-
PARENT_CANNOT_CONTROL:
|
|
1
|
+
export declare const fuseEnum: {
|
|
2
|
+
readonly CANNOT_UNWRAP: 1;
|
|
3
|
+
readonly CANNOT_BURN_FUSES: 2;
|
|
4
|
+
readonly CANNOT_TRANSFER: 4;
|
|
5
|
+
readonly CANNOT_SET_RESOLVER: 8;
|
|
6
|
+
readonly CANNOT_SET_TTL: 16;
|
|
7
|
+
readonly CANNOT_CREATE_SUBDOMAIN: 32;
|
|
8
|
+
readonly PARENT_CANNOT_CONTROL: 64;
|
|
9
9
|
};
|
|
10
|
-
declare const
|
|
10
|
+
export declare const unnamedFuses: readonly [128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144, 524288, 1048576, 2097152, 4194304, 8388608, 16777216, 33554432, 67108864, 134217728, 268435456, 536870912, 1073741824, 2147483648, 4294967296];
|
|
11
|
+
declare const fullFuseEnum: {
|
|
11
12
|
CAN_DO_EVERYTHING: number;
|
|
12
|
-
CANNOT_UNWRAP:
|
|
13
|
-
CANNOT_BURN_FUSES:
|
|
14
|
-
CANNOT_TRANSFER:
|
|
15
|
-
CANNOT_SET_RESOLVER:
|
|
16
|
-
CANNOT_SET_TTL:
|
|
17
|
-
CANNOT_CREATE_SUBDOMAIN:
|
|
18
|
-
PARENT_CANNOT_CONTROL:
|
|
13
|
+
CANNOT_UNWRAP: 1;
|
|
14
|
+
CANNOT_BURN_FUSES: 2;
|
|
15
|
+
CANNOT_TRANSFER: 4;
|
|
16
|
+
CANNOT_SET_RESOLVER: 8;
|
|
17
|
+
CANNOT_SET_TTL: 16;
|
|
18
|
+
CANNOT_CREATE_SUBDOMAIN: 32;
|
|
19
|
+
PARENT_CANNOT_CONTROL: 64;
|
|
19
20
|
};
|
|
20
|
-
export default
|
|
21
|
+
export default fullFuseEnum;
|
package/dist/cjs/utils/fuses.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.unnamedFuses = exports.fuseEnum = void 0;
|
|
4
4
|
const CANNOT_UNWRAP = 1;
|
|
5
5
|
const CANNOT_BURN_FUSES = 2;
|
|
6
6
|
const CANNOT_TRANSFER = 4;
|
|
@@ -9,7 +9,7 @@ const CANNOT_SET_TTL = 16;
|
|
|
9
9
|
const CANNOT_CREATE_SUBDOMAIN = 32;
|
|
10
10
|
const PARENT_CANNOT_CONTROL = 64;
|
|
11
11
|
const CAN_DO_EVERYTHING = 0;
|
|
12
|
-
exports.
|
|
12
|
+
exports.fuseEnum = {
|
|
13
13
|
CANNOT_UNWRAP,
|
|
14
14
|
CANNOT_BURN_FUSES,
|
|
15
15
|
CANNOT_TRANSFER,
|
|
@@ -18,7 +18,13 @@ exports.testable = {
|
|
|
18
18
|
CANNOT_CREATE_SUBDOMAIN,
|
|
19
19
|
PARENT_CANNOT_CONTROL,
|
|
20
20
|
};
|
|
21
|
-
exports.
|
|
22
|
-
|
|
21
|
+
exports.unnamedFuses = [
|
|
22
|
+
128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144,
|
|
23
|
+
524288, 1048576, 2097152, 4194304, 8388608, 16777216, 33554432, 67108864,
|
|
24
|
+
134217728, 268435456, 536870912, 1073741824, 2147483648, 4294967296,
|
|
25
|
+
];
|
|
26
|
+
const fullFuseEnum = {
|
|
27
|
+
...exports.fuseEnum,
|
|
23
28
|
CAN_DO_EVERYTHING,
|
|
24
29
|
};
|
|
30
|
+
exports.default = fullFuseEnum;
|
|
@@ -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;
|
|
@@ -2,4 +2,4 @@ import { BigNumber } from 'ethers';
|
|
|
2
2
|
import { ENSArgs } from '..';
|
|
3
3
|
export declare type Expiry = string | number | Date | BigNumber;
|
|
4
4
|
export declare const MAX_EXPIRY: BigNumber;
|
|
5
|
-
export declare const makeExpiry: ({ getExpiry }: ENSArgs<'getExpiry'>, name: string, expiry?: Expiry
|
|
5
|
+
export declare const makeExpiry: ({ getExpiry }: ENSArgs<'getExpiry'>, name: string, expiry?: Expiry) => Promise<BigNumber>;
|
|
@@ -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));
|
|
@@ -5,12 +5,12 @@ export default class ContractManager {
|
|
|
5
5
|
private fetchAddress;
|
|
6
6
|
constructor(provider: ethers.providers.Provider, fetchAddress: ContractAddressFetch);
|
|
7
7
|
private generateContractGetter;
|
|
8
|
-
getPublicResolver: (passedProvider?: any, address?: string
|
|
9
|
-
getUniversalResolver: (passedProvider?: any, address?: string
|
|
10
|
-
getRegistry: (passedProvider?: any, address?: string
|
|
11
|
-
getReverseRegistrar: (passedProvider?: any, address?: string
|
|
12
|
-
getNameWrapper: (passedProvider?: any, address?: string
|
|
13
|
-
getBaseRegistrar: (passedProvider?: any, address?: string
|
|
14
|
-
getEthRegistrarController: (passedProvider?: any, address?: string
|
|
15
|
-
getMulticall: (passedProvider?: any, address?: string
|
|
8
|
+
getPublicResolver: (passedProvider?: any, address?: string) => Promise<import("../generated").PublicResolver>;
|
|
9
|
+
getUniversalResolver: (passedProvider?: any, address?: string) => Promise<import("../generated").UniversalResolver>;
|
|
10
|
+
getRegistry: (passedProvider?: any, address?: string) => Promise<import("../generated").ENSRegistry>;
|
|
11
|
+
getReverseRegistrar: (passedProvider?: any, address?: string) => Promise<import("../generated").ReverseRegistrar>;
|
|
12
|
+
getNameWrapper: (passedProvider?: any, address?: string) => Promise<import("../generated").NameWrapper>;
|
|
13
|
+
getBaseRegistrar: (passedProvider?: any, address?: string) => Promise<import("../generated").BaseRegistrarImplementation>;
|
|
14
|
+
getEthRegistrarController: (passedProvider?: any, address?: string) => Promise<import("../generated").ETHRegistrarController>;
|
|
15
|
+
getMulticall: (passedProvider?: any, address?: string) => Promise<import("../generated").Multicall>;
|
|
16
16
|
}
|
|
@@ -1,5 +1,32 @@
|
|
|
1
1
|
import { ENSArgs } from '..';
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
2
|
+
import { fuseEnum, unnamedFuses } from '../utils/fuses';
|
|
3
|
+
declare type FuseObj = typeof fuseEnum;
|
|
4
|
+
declare type UnnamedFuseType = typeof unnamedFuses;
|
|
5
|
+
declare type Fuse = keyof FuseObj;
|
|
6
|
+
declare type UnnamedFuseValues = UnnamedFuseType[number];
|
|
7
|
+
declare type FuseArrayPossibilities = [Fuse] | [Fuse, Fuse] | [Fuse, Fuse, Fuse] | [Fuse, Fuse, Fuse, Fuse] | [Fuse, Fuse, Fuse, Fuse, Fuse] | [Fuse, Fuse, Fuse, Fuse, Fuse, Fuse] | [Fuse, Fuse, Fuse, Fuse, Fuse, Fuse, Fuse];
|
|
8
|
+
/**
|
|
9
|
+
* This type creates a type error if there are any duplicate fuses.
|
|
10
|
+
* It effectively works like a reduce function, starting with 0 included types, adding a type each time, and then checking for duplicates.
|
|
11
|
+
*
|
|
12
|
+
* @template A The array to check for duplicates.
|
|
13
|
+
* @template B The union of all checked existing types.
|
|
14
|
+
*/
|
|
15
|
+
declare type FusesWithoutDuplicates<A, B = never> = A extends FuseArrayPossibilities ? A extends [infer Head, ...infer Tail] ? Head extends B ? [
|
|
16
|
+
] : [
|
|
17
|
+
Head,
|
|
18
|
+
...FusesWithoutDuplicates<Tail, Head | B>
|
|
19
|
+
] : A : [
|
|
20
|
+
];
|
|
21
|
+
declare type FusePropsNamedArray<A extends FuseArrayPossibilities> = {
|
|
22
|
+
namedFusesToBurn: FusesWithoutDuplicates<A>;
|
|
23
|
+
};
|
|
24
|
+
declare type FusePropsUnnamedArray = {
|
|
25
|
+
unnamedFusesToBurn: UnnamedFuseValues[];
|
|
26
|
+
};
|
|
27
|
+
declare type FusePropsNumber = {
|
|
28
|
+
fuseNumberToBurn: number;
|
|
29
|
+
};
|
|
30
|
+
declare type FuseProps<A extends FuseArrayPossibilities> = (Partial<FusePropsNamedArray<A>> & FusePropsUnnamedArray) | (FusePropsNamedArray<A> & Partial<FusePropsUnnamedArray>) | FusePropsNumber;
|
|
31
|
+
export default function <A extends FuseArrayPossibilities>({ contracts, signer }: ENSArgs<'contracts' | 'signer'>, name: string, props: FuseProps<A>): Promise<import("ethers").PopulatedTransaction>;
|
|
32
|
+
export {};
|
|
@@ -1,8 +1,41 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { fuseEnum, unnamedFuses } from '../utils/fuses';
|
|
2
2
|
import { namehash } from '../utils/normalise';
|
|
3
|
-
export default async function ({ contracts, signer }, name,
|
|
3
|
+
export default async function ({ contracts, signer }, name, props) {
|
|
4
|
+
const isNumber = 'fuseNumberToBurn' in props;
|
|
5
|
+
const hasNamedArray = 'namedFusesToBurn' in props;
|
|
6
|
+
const hasUnnamedArray = 'unnamedFusesToBurn' in props;
|
|
7
|
+
let encodedFuses = 0;
|
|
8
|
+
if (isNumber) {
|
|
9
|
+
if (props.fuseNumberToBurn > 2 ** 32 || props.fuseNumberToBurn < 1) {
|
|
10
|
+
throw new Error(`Fuse number must be limited to uint32, ${props.fuseNumberToBurn} was too ${props.fuseNumberToBurn < 1 ? 'low' : 'high'}.`);
|
|
11
|
+
}
|
|
12
|
+
else if (props.fuseNumberToBurn % 1 !== 0) {
|
|
13
|
+
throw new Error(`Fuse number must be an integer, ${props.fuseNumberToBurn} was not.`);
|
|
14
|
+
}
|
|
15
|
+
encodedFuses = props.fuseNumberToBurn;
|
|
16
|
+
}
|
|
17
|
+
else {
|
|
18
|
+
if (!hasNamedArray && !hasUnnamedArray) {
|
|
19
|
+
throw new Error('Please provide fuses to burn');
|
|
20
|
+
}
|
|
21
|
+
if (hasNamedArray) {
|
|
22
|
+
for (const fuse of props.namedFusesToBurn) {
|
|
23
|
+
if (!(fuse in fuseEnum)) {
|
|
24
|
+
throw new Error(`${fuse} is not a valid named fuse.`);
|
|
25
|
+
}
|
|
26
|
+
encodedFuses |= fuseEnum[fuse];
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
if (hasUnnamedArray) {
|
|
30
|
+
for (const fuse of props.unnamedFusesToBurn) {
|
|
31
|
+
if (!unnamedFuses.includes(fuse)) {
|
|
32
|
+
throw new Error(`${fuse} is not a valid unnamed fuse. If you are trying to burn a named fuse, use the namedFusesToBurn property.`);
|
|
33
|
+
}
|
|
34
|
+
encodedFuses |= fuse;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
4
38
|
const nameWrapper = (await contracts?.getNameWrapper()).connect(signer);
|
|
5
39
|
const hash = namehash(name);
|
|
6
|
-
const encodedFuses = generateFuseInput(fusesToBurn);
|
|
7
40
|
return nameWrapper.populateTransaction.setFuses(hash, encodedFuses);
|
|
8
41
|
}
|
|
@@ -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
|
+
}
|
|
@@ -5,12 +5,13 @@ declare const _default: {
|
|
|
5
5
|
to: string;
|
|
6
6
|
data: string;
|
|
7
7
|
}>;
|
|
8
|
-
decode: ({ contracts }: ENSArgs<"contracts">, data: string
|
|
8
|
+
decode: ({ contracts }: ENSArgs<"contracts">, data: string) => Promise<{
|
|
9
9
|
fuseObj: {
|
|
10
10
|
[k: string]: boolean;
|
|
11
11
|
};
|
|
12
12
|
expiryDate: Date;
|
|
13
13
|
rawFuses: BigNumber;
|
|
14
|
+
owner: any;
|
|
14
15
|
} | undefined>;
|
|
15
16
|
};
|
|
16
17
|
export default _default;
|
|
@@ -1,32 +1,21 @@
|
|
|
1
1
|
import { BigNumber } from 'ethers';
|
|
2
|
-
import {
|
|
2
|
+
import { fuseEnum } from '../utils/fuses';
|
|
3
3
|
import { namehash } from '../utils/normalise';
|
|
4
|
-
const NameSafety = [
|
|
5
|
-
'Safe',
|
|
6
|
-
'RegistrantNotWrapped',
|
|
7
|
-
'ControllerNotWrapped',
|
|
8
|
-
'SubdomainReplacementAllowed',
|
|
9
|
-
'Expired',
|
|
10
|
-
];
|
|
11
4
|
const raw = async ({ contracts }, name) => {
|
|
12
5
|
const nameWrapper = await contracts?.getNameWrapper();
|
|
13
6
|
return {
|
|
14
7
|
to: nameWrapper.address,
|
|
15
|
-
data: nameWrapper.interface.encodeFunctionData('
|
|
16
|
-
namehash(name),
|
|
17
|
-
]),
|
|
8
|
+
data: nameWrapper.interface.encodeFunctionData('getData', [namehash(name)]),
|
|
18
9
|
};
|
|
19
10
|
};
|
|
20
|
-
const decode = async ({ contracts }, data
|
|
11
|
+
const decode = async ({ contracts }, data) => {
|
|
21
12
|
const nameWrapper = await contracts?.getNameWrapper();
|
|
22
13
|
try {
|
|
23
|
-
const
|
|
14
|
+
const { owner, fuses: _fuses, expiry, } = nameWrapper.interface.decodeFunctionResult('getData', data);
|
|
24
15
|
const fuses = BigNumber.from(_fuses);
|
|
25
|
-
const fuseObj = Object.fromEntries(Object.keys(
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
.replace(/([-_][a-z])/g, (group) => group.toUpperCase().replace('-', '').replace('_', '')),
|
|
29
|
-
fuses.and(fuseEnums[fuseEnum]).gt(0),
|
|
16
|
+
const fuseObj = Object.fromEntries(Object.keys(fuseEnum).map((fuse) => [
|
|
17
|
+
fuse,
|
|
18
|
+
fuses.and(fuseEnum[fuse]).gt(0),
|
|
30
19
|
]));
|
|
31
20
|
if (fuses.eq(0)) {
|
|
32
21
|
fuseObj.canDoEverything = true;
|
|
@@ -39,9 +28,11 @@ const decode = async ({ contracts }, data, name) => {
|
|
|
39
28
|
fuseObj,
|
|
40
29
|
expiryDate,
|
|
41
30
|
rawFuses: fuses,
|
|
31
|
+
owner,
|
|
42
32
|
};
|
|
43
33
|
}
|
|
44
|
-
catch {
|
|
34
|
+
catch (e) {
|
|
35
|
+
console.error('Error decoding fuses data: ', e);
|
|
45
36
|
return;
|
|
46
37
|
}
|
|
47
38
|
};
|
|
@@ -22,33 +22,3 @@ export declare function getHistory({ gqlInstance }: ENSArgs<'gqlInstance'>, name
|
|
|
22
22
|
data: Record<string, any>;
|
|
23
23
|
}[];
|
|
24
24
|
} | undefined>;
|
|
25
|
-
export declare function getHistoryWithDetail({ contracts, gqlInstance, provider, }: ENSArgs<'contracts' | 'gqlInstance' | 'provider'>, name: string): Promise<{
|
|
26
|
-
domain: {
|
|
27
|
-
type: any;
|
|
28
|
-
blockNumber: any;
|
|
29
|
-
transactionHash: any;
|
|
30
|
-
id: any;
|
|
31
|
-
data: Record<string, any>;
|
|
32
|
-
}[];
|
|
33
|
-
registration: {
|
|
34
|
-
type: any;
|
|
35
|
-
blockNumber: any;
|
|
36
|
-
transactionHash: any;
|
|
37
|
-
id: any;
|
|
38
|
-
data: Record<string, any>;
|
|
39
|
-
}[];
|
|
40
|
-
resolver: {
|
|
41
|
-
type: any;
|
|
42
|
-
blockNumber: any;
|
|
43
|
-
transactionHash: any;
|
|
44
|
-
id: any;
|
|
45
|
-
data: Record<string, any>;
|
|
46
|
-
}[];
|
|
47
|
-
} | undefined>;
|
|
48
|
-
export declare function getHistoryDetailForTransactionHash({ contracts, provider }: ENSArgs<'contracts' | 'provider'>, hash: string, indexInTransaction?: number): Promise<({
|
|
49
|
-
key: any;
|
|
50
|
-
value: any;
|
|
51
|
-
} | undefined)[] | {
|
|
52
|
-
key: any;
|
|
53
|
-
value: any;
|
|
54
|
-
} | undefined>;
|