@ensdomains/ensjs 3.0.0-alpha.12 → 3.0.0-alpha.15
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/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 +22 -3
- package/dist/cjs/index.js +8 -1
- 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/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 +22 -3
- package/dist/esm/index.js +8 -1
- 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/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 +27 -4
- 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 -57
- package/src/tests/signerInjection.test.ts +0 -46
- package/src/tests/withProvider.test.ts +0 -28
|
@@ -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
|
};
|
|
@@ -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)
|
|
@@ -52,21 +52,21 @@ export declare const getText: {
|
|
|
52
52
|
decode: ({ contracts, universalWrapper }: ENSArgs<'contracts' | 'universalWrapper'>, data: string) => Promise<any>;
|
|
53
53
|
};
|
|
54
54
|
export declare const _getAddr: {
|
|
55
|
-
raw: ({ contracts }: ENSArgs<'contracts'>, name: string, coinType?: string | number
|
|
55
|
+
raw: ({ contracts }: ENSArgs<'contracts'>, name: string, coinType?: string | number, bypassFormat?: boolean) => Promise<{
|
|
56
56
|
to: string;
|
|
57
57
|
data: string;
|
|
58
58
|
}>;
|
|
59
|
-
decode: ({ contracts }: ENSArgs<'contracts'>, data: string, _name: string, coinType?: string | number
|
|
59
|
+
decode: ({ contracts }: ENSArgs<'contracts'>, data: string, _name: string, coinType?: string | number) => Promise<string | {
|
|
60
60
|
coin: string;
|
|
61
61
|
addr: string;
|
|
62
62
|
} | undefined>;
|
|
63
63
|
};
|
|
64
64
|
export declare const getAddr: {
|
|
65
|
-
raw: ({ contracts, universalWrapper }: ENSArgs<'contracts' | 'universalWrapper'>, name: string, coinType?: string | number
|
|
65
|
+
raw: ({ contracts, universalWrapper }: ENSArgs<'contracts' | 'universalWrapper'>, name: string, coinType?: string | number) => Promise<{
|
|
66
66
|
to: string;
|
|
67
67
|
data: string;
|
|
68
68
|
}>;
|
|
69
|
-
decode: ({ contracts, universalWrapper }: ENSArgs<'contracts' | 'universalWrapper'>, data: string, _name: string, coinType?: string | number
|
|
69
|
+
decode: ({ contracts, universalWrapper }: ENSArgs<'contracts' | 'universalWrapper'>, data: string, _name: string, coinType?: string | number) => Promise<string | {
|
|
70
70
|
coin: string;
|
|
71
71
|
addr: string;
|
|
72
72
|
} | undefined>;
|
|
@@ -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 = {
|
|
@@ -70,6 +75,16 @@ export declare class ENS {
|
|
|
70
75
|
contracts?: ContractManager;
|
|
71
76
|
getContractAddress: (networkId: SupportedNetworkId) => import("./contracts/getContractAddress").ContractAddressFetch;
|
|
72
77
|
gqlInstance: GqlManager;
|
|
78
|
+
fuses: {
|
|
79
|
+
CAN_DO_EVERYTHING: number;
|
|
80
|
+
CANNOT_UNWRAP: 1;
|
|
81
|
+
CANNOT_BURN_FUSES: 2;
|
|
82
|
+
CANNOT_TRANSFER: 4;
|
|
83
|
+
CANNOT_SET_RESOLVER: 8;
|
|
84
|
+
CANNOT_SET_TTL: 16;
|
|
85
|
+
CANNOT_CREATE_SUBDOMAIN: 32;
|
|
86
|
+
PARENT_CANNOT_CONTROL: 64;
|
|
87
|
+
};
|
|
73
88
|
constructor(options?: ENSOptions);
|
|
74
89
|
/**
|
|
75
90
|
* Checks for an initial provider and if it exists, sets it as the provider
|
|
@@ -224,12 +239,13 @@ export declare class ENS {
|
|
|
224
239
|
to: string;
|
|
225
240
|
data: string;
|
|
226
241
|
}>;
|
|
227
|
-
decode: ({ contracts }: ENSArgs<"contracts">, data: string
|
|
242
|
+
decode: ({ contracts }: ENSArgs<"contracts">, data: string) => Promise<{
|
|
228
243
|
fuseObj: {
|
|
229
244
|
[k: string]: boolean;
|
|
230
245
|
};
|
|
231
246
|
expiryDate: Date;
|
|
232
247
|
rawFuses: ethers.BigNumber;
|
|
248
|
+
owner: any;
|
|
233
249
|
} | undefined>;
|
|
234
250
|
}>;
|
|
235
251
|
getHistory: (name: string) => Promise<{
|
|
@@ -405,6 +421,7 @@ export declare class ENS {
|
|
|
405
421
|
premium: ethers.BigNumber;
|
|
406
422
|
} | undefined>;
|
|
407
423
|
}>;
|
|
424
|
+
getDNSOwner: (dnsName: string) => Promise<any>;
|
|
408
425
|
universalWrapper: GeneratedRawFunction<{
|
|
409
426
|
raw: ({ contracts }: ENSArgs<"contracts">, name: string, data: string) => Promise<{
|
|
410
427
|
to: string;
|
|
@@ -443,6 +460,8 @@ export declare class ENS {
|
|
|
443
460
|
createSubname: WriteFunction<typeof createSubname>;
|
|
444
461
|
deleteSubname: WriteFunction<typeof deleteSubname>;
|
|
445
462
|
transferSubname: WriteFunction<typeof transferSubname>;
|
|
446
|
-
|
|
463
|
+
commitName: WriteFunction<typeof commitName>;
|
|
464
|
+
registerName: WriteFunction<typeof registerName>;
|
|
465
|
+
renewName: WriteFunction<typeof renewName>;
|
|
447
466
|
}
|
|
448
467
|
export {};
|
package/dist/esm/index.js
CHANGED
|
@@ -3,6 +3,7 @@ import { getContractAddress as _getContractAddress } from './contracts/getContra
|
|
|
3
3
|
import GqlManager from './GqlManager';
|
|
4
4
|
import singleCall from './utils/singleCall';
|
|
5
5
|
import writeTx from './utils/writeTx';
|
|
6
|
+
import fuseEnum from './utils/fuses';
|
|
6
7
|
const graphURIEndpoints = {
|
|
7
8
|
1: 'https://api.thegraph.com/subgraphs/name/ensdomains/ens',
|
|
8
9
|
3: 'https://api.thegraph.com/subgraphs/name/ensdomains/ensropsten',
|
|
@@ -13,6 +14,7 @@ export class ENS {
|
|
|
13
14
|
constructor(options) {
|
|
14
15
|
this.getContractAddress = _getContractAddress;
|
|
15
16
|
this.gqlInstance = new GqlManager();
|
|
17
|
+
this.fuses = fuseEnum;
|
|
16
18
|
/**
|
|
17
19
|
* Checks for an initial provider and if it exists, sets it as the provider
|
|
18
20
|
* @returns {Promise<void>} - A promise that resolves when the provider is checked, and set if needed
|
|
@@ -179,6 +181,7 @@ export class ENS {
|
|
|
179
181
|
this.getSubnames = this.generateFunction('initialGetters', ['gqlInstance'], 'getSubnames');
|
|
180
182
|
this.getNames = this.generateFunction('initialGetters', ['gqlInstance'], 'getNames');
|
|
181
183
|
this.getPrice = this.generateRawFunction('initialGetters', ['contracts', 'multicallWrapper'], 'getPrice');
|
|
184
|
+
this.getDNSOwner = this.generateFunction('getDNSOwner', []);
|
|
182
185
|
this.universalWrapper = this.generateRawFunction('initialGetters', ['contracts'], 'universalWrapper');
|
|
183
186
|
this.resolverMulticallWrapper = this.generateRawFunction('initialGetters', ['contracts'], 'resolverMulticallWrapper');
|
|
184
187
|
this.multicallWrapper = this.generateRawFunction('initialGetters', ['contracts'], 'multicallWrapper');
|
|
@@ -204,7 +207,11 @@ export class ENS {
|
|
|
204
207
|
this.createSubname = this.generateWriteFunction('createSubname', ['contracts', 'getExpiry']);
|
|
205
208
|
this.deleteSubname = this.generateWriteFunction('deleteSubname', ['transferSubname']);
|
|
206
209
|
this.transferSubname = this.generateWriteFunction('transferSubname', ['contracts', 'getExpiry']);
|
|
207
|
-
this.
|
|
210
|
+
this.commitName = this.generateWriteFunction('commitName', ['contracts']);
|
|
211
|
+
this.registerName = this.generateWriteFunction('registerName', ['contracts']);
|
|
212
|
+
this.renewName = this.generateWriteFunction('renewName', [
|
|
213
|
+
'contracts',
|
|
214
|
+
]);
|
|
208
215
|
this.options = options;
|
|
209
216
|
this.getContractAddress = options?.getContractAddress || _getContractAddress;
|
|
210
217
|
}
|
|
@@ -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/esm/utils/fuses.js
CHANGED
|
@@ -6,7 +6,7 @@ const CANNOT_SET_TTL = 16;
|
|
|
6
6
|
const CANNOT_CREATE_SUBDOMAIN = 32;
|
|
7
7
|
const PARENT_CANNOT_CONTROL = 64;
|
|
8
8
|
const CAN_DO_EVERYTHING = 0;
|
|
9
|
-
export const
|
|
9
|
+
export const fuseEnum = {
|
|
10
10
|
CANNOT_UNWRAP,
|
|
11
11
|
CANNOT_BURN_FUSES,
|
|
12
12
|
CANNOT_TRANSFER,
|
|
@@ -15,7 +15,13 @@ export const testable = {
|
|
|
15
15
|
CANNOT_CREATE_SUBDOMAIN,
|
|
16
16
|
PARENT_CANNOT_CONTROL,
|
|
17
17
|
};
|
|
18
|
-
export
|
|
19
|
-
|
|
18
|
+
export const unnamedFuses = [
|
|
19
|
+
128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144,
|
|
20
|
+
524288, 1048576, 2097152, 4194304, 8388608, 16777216, 33554432, 67108864,
|
|
21
|
+
134217728, 268435456, 536870912, 1073741824, 2147483648, 4294967296,
|
|
22
|
+
];
|
|
23
|
+
const fullFuseEnum = {
|
|
24
|
+
...fuseEnum,
|
|
20
25
|
CAN_DO_EVERYTHING,
|
|
21
26
|
};
|
|
27
|
+
export default fullFuseEnum;
|