@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
|
@@ -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,14 +1,44 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const
|
|
3
|
+
const fuses_1 = require("../utils/fuses");
|
|
7
4
|
const normalise_1 = require("../utils/normalise");
|
|
8
|
-
async function default_1({ contracts, signer }, name,
|
|
5
|
+
async function default_1({ contracts, signer }, name, props) {
|
|
6
|
+
const isNumber = 'fuseNumberToBurn' in props;
|
|
7
|
+
const hasNamedArray = 'namedFusesToBurn' in props;
|
|
8
|
+
const hasUnnamedArray = 'unnamedFusesToBurn' in props;
|
|
9
|
+
let encodedFuses = 0;
|
|
10
|
+
if (isNumber) {
|
|
11
|
+
if (props.fuseNumberToBurn > 2 ** 32 || props.fuseNumberToBurn < 1) {
|
|
12
|
+
throw new Error(`Fuse number must be limited to uint32, ${props.fuseNumberToBurn} was too ${props.fuseNumberToBurn < 1 ? 'low' : 'high'}.`);
|
|
13
|
+
}
|
|
14
|
+
else if (props.fuseNumberToBurn % 1 !== 0) {
|
|
15
|
+
throw new Error(`Fuse number must be an integer, ${props.fuseNumberToBurn} was not.`);
|
|
16
|
+
}
|
|
17
|
+
encodedFuses = props.fuseNumberToBurn;
|
|
18
|
+
}
|
|
19
|
+
else {
|
|
20
|
+
if (!hasNamedArray && !hasUnnamedArray) {
|
|
21
|
+
throw new Error('Please provide fuses to burn');
|
|
22
|
+
}
|
|
23
|
+
if (hasNamedArray) {
|
|
24
|
+
for (const fuse of props.namedFusesToBurn) {
|
|
25
|
+
if (!(fuse in fuses_1.fuseEnum)) {
|
|
26
|
+
throw new Error(`${fuse} is not a valid named fuse.`);
|
|
27
|
+
}
|
|
28
|
+
encodedFuses |= fuses_1.fuseEnum[fuse];
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
if (hasUnnamedArray) {
|
|
32
|
+
for (const fuse of props.unnamedFusesToBurn) {
|
|
33
|
+
if (!fuses_1.unnamedFuses.includes(fuse)) {
|
|
34
|
+
throw new Error(`${fuse} is not a valid unnamed fuse. If you are trying to burn a named fuse, use the namedFusesToBurn property.`);
|
|
35
|
+
}
|
|
36
|
+
encodedFuses |= fuse;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
9
40
|
const nameWrapper = (await contracts?.getNameWrapper()).connect(signer);
|
|
10
41
|
const hash = (0, normalise_1.namehash)(name);
|
|
11
|
-
const encodedFuses = (0, generateFuseInput_1.default)(fusesToBurn);
|
|
12
42
|
return nameWrapper.populateTransaction.setFuses(hash, encodedFuses);
|
|
13
43
|
}
|
|
14
44
|
exports.default = default_1;
|
|
@@ -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;
|
|
@@ -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;
|
|
@@ -3,32 +3,21 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
const ethers_1 = require("ethers");
|
|
4
4
|
const fuses_1 = require("../utils/fuses");
|
|
5
5
|
const normalise_1 = require("../utils/normalise");
|
|
6
|
-
const NameSafety = [
|
|
7
|
-
'Safe',
|
|
8
|
-
'RegistrantNotWrapped',
|
|
9
|
-
'ControllerNotWrapped',
|
|
10
|
-
'SubdomainReplacementAllowed',
|
|
11
|
-
'Expired',
|
|
12
|
-
];
|
|
13
6
|
const raw = async ({ contracts }, name) => {
|
|
14
7
|
const nameWrapper = await contracts?.getNameWrapper();
|
|
15
8
|
return {
|
|
16
9
|
to: nameWrapper.address,
|
|
17
|
-
data: nameWrapper.interface.encodeFunctionData('
|
|
18
|
-
(0, normalise_1.namehash)(name),
|
|
19
|
-
]),
|
|
10
|
+
data: nameWrapper.interface.encodeFunctionData('getData', [(0, normalise_1.namehash)(name)]),
|
|
20
11
|
};
|
|
21
12
|
};
|
|
22
|
-
const decode = async ({ contracts }, data
|
|
13
|
+
const decode = async ({ contracts }, data) => {
|
|
23
14
|
const nameWrapper = await contracts?.getNameWrapper();
|
|
24
15
|
try {
|
|
25
|
-
const
|
|
16
|
+
const { owner, fuses: _fuses, expiry, } = nameWrapper.interface.decodeFunctionResult('getData', data);
|
|
26
17
|
const fuses = ethers_1.BigNumber.from(_fuses);
|
|
27
|
-
const fuseObj = Object.fromEntries(Object.keys(fuses_1.
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
.replace(/([-_][a-z])/g, (group) => group.toUpperCase().replace('-', '').replace('_', '')),
|
|
31
|
-
fuses.and(fuses_1.testable[fuseEnum]).gt(0),
|
|
18
|
+
const fuseObj = Object.fromEntries(Object.keys(fuses_1.fuseEnum).map((fuse) => [
|
|
19
|
+
fuse,
|
|
20
|
+
fuses.and(fuses_1.fuseEnum[fuse]).gt(0),
|
|
32
21
|
]));
|
|
33
22
|
if (fuses.eq(0)) {
|
|
34
23
|
fuseObj.canDoEverything = true;
|
|
@@ -41,9 +30,11 @@ const decode = async ({ contracts }, data, name) => {
|
|
|
41
30
|
fuseObj,
|
|
42
31
|
expiryDate,
|
|
43
32
|
rawFuses: fuses,
|
|
33
|
+
owner,
|
|
44
34
|
};
|
|
45
35
|
}
|
|
46
|
-
catch {
|
|
36
|
+
catch (e) {
|
|
37
|
+
console.error('Error decoding fuses data: ', e);
|
|
47
38
|
return;
|
|
48
39
|
}
|
|
49
40
|
};
|
|
@@ -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)
|
|
@@ -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,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 = {
|
|
@@ -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/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;
|
|
@@ -216,6 +218,7 @@ class ENS {
|
|
|
216
218
|
getSubnames = this.generateFunction('initialGetters', ['gqlInstance'], 'getSubnames');
|
|
217
219
|
getNames = this.generateFunction('initialGetters', ['gqlInstance'], 'getNames');
|
|
218
220
|
getPrice = this.generateRawFunction('initialGetters', ['contracts', 'multicallWrapper'], 'getPrice');
|
|
221
|
+
getDNSOwner = this.generateFunction('getDNSOwner', []);
|
|
219
222
|
universalWrapper = this.generateRawFunction('initialGetters', ['contracts'], 'universalWrapper');
|
|
220
223
|
resolverMulticallWrapper = this.generateRawFunction('initialGetters', ['contracts'], 'resolverMulticallWrapper');
|
|
221
224
|
multicallWrapper = this.generateRawFunction('initialGetters', ['contracts'], 'multicallWrapper');
|
|
@@ -241,6 +244,10 @@ class ENS {
|
|
|
241
244
|
createSubname = this.generateWriteFunction('createSubname', ['contracts', 'getExpiry']);
|
|
242
245
|
deleteSubname = this.generateWriteFunction('deleteSubname', ['transferSubname']);
|
|
243
246
|
transferSubname = this.generateWriteFunction('transferSubname', ['contracts', 'getExpiry']);
|
|
244
|
-
|
|
247
|
+
commitName = this.generateWriteFunction('commitName', ['contracts']);
|
|
248
|
+
registerName = this.generateWriteFunction('registerName', ['contracts']);
|
|
249
|
+
renewName = this.generateWriteFunction('renewName', [
|
|
250
|
+
'contracts',
|
|
251
|
+
]);
|
|
245
252
|
}
|
|
246
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;
|