@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
|
@@ -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
|
};
|
|
@@ -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>;
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.getHistory = void 0;
|
|
4
4
|
const address_encoder_1 = require("@ensdomains/address-encoder");
|
|
5
5
|
const ethers_1 = require("ethers");
|
|
6
6
|
const contentHash_1 = require("../utils/contentHash");
|
|
7
|
-
const makeHashIndexes_1 = require("../utils/makeHashIndexes");
|
|
8
7
|
const eventFormat = {
|
|
9
8
|
Domain: {
|
|
10
9
|
NewOwner: (args) => ({ owner: args.owner.id }),
|
|
@@ -46,7 +45,7 @@ const eventFormat = {
|
|
|
46
45
|
NameChanged: (args) => ({ name: args.name }),
|
|
47
46
|
AbiChanged: (args) => ({ contentType: args.contentType }),
|
|
48
47
|
PubkeyChanged: (args) => ({ x: args.x, y: args.y }),
|
|
49
|
-
TextChanged: (args) => ({ key: args.key }),
|
|
48
|
+
TextChanged: (args) => ({ key: args.key, value: args.value }),
|
|
50
49
|
ContenthashChanged: (args) => ({ hash: (0, contentHash_1.decodeContenthash)(args.hash) }),
|
|
51
50
|
InterfaceChanged: (args) => ({
|
|
52
51
|
interfaceId: args.interfaceId,
|
|
@@ -66,31 +65,6 @@ const mapEvents = (eventArray, type) => eventArray.map((event) => ({
|
|
|
66
65
|
id: event.id,
|
|
67
66
|
data: eventFormat[type][event.__typename](event),
|
|
68
67
|
}));
|
|
69
|
-
const mapResultDetailDecode = (publicResolver) => (result) => {
|
|
70
|
-
const hashIndexes = (0, makeHashIndexes_1.makeOtherIndexes)(result.input, '10f13a8c');
|
|
71
|
-
const abiLengths = hashIndexes.map((x) => ({
|
|
72
|
-
index: x,
|
|
73
|
-
length: x === 0
|
|
74
|
-
? ethers_1.ethers.utils.hexDataLength(result.input)
|
|
75
|
-
: parseInt(ethers_1.ethers.utils.hexDataSlice(result.input, x - 32, x), 16),
|
|
76
|
-
}));
|
|
77
|
-
const ABIs = abiLengths.map(({ index, length }) => ethers_1.ethers.utils.hexDataSlice(result.input, index, index + length));
|
|
78
|
-
return ABIs.map((abi) => {
|
|
79
|
-
try {
|
|
80
|
-
return publicResolver.interface.decodeFunctionData('setText(bytes32,string,string)', abi);
|
|
81
|
-
}
|
|
82
|
-
catch {
|
|
83
|
-
return;
|
|
84
|
-
}
|
|
85
|
-
});
|
|
86
|
-
};
|
|
87
|
-
const expandDecode = (prev, curr) => {
|
|
88
|
-
if (!curr)
|
|
89
|
-
return [...prev, { value: null }];
|
|
90
|
-
if (!curr.length)
|
|
91
|
-
return [...prev, curr];
|
|
92
|
-
return [...prev, ...curr];
|
|
93
|
-
};
|
|
94
68
|
async function getHistory({ gqlInstance }, name) {
|
|
95
69
|
const client = gqlInstance.client;
|
|
96
70
|
const query = gqlInstance.gql `
|
|
@@ -171,6 +145,7 @@ async function getHistory({ gqlInstance }, name) {
|
|
|
171
145
|
}
|
|
172
146
|
...on TextChanged {
|
|
173
147
|
key
|
|
148
|
+
value
|
|
174
149
|
}
|
|
175
150
|
...on ContenthashChanged {
|
|
176
151
|
hash
|
|
@@ -206,74 +181,3 @@ async function getHistory({ gqlInstance }, name) {
|
|
|
206
181
|
};
|
|
207
182
|
}
|
|
208
183
|
exports.getHistory = getHistory;
|
|
209
|
-
async function getHistoryWithDetail({ contracts, gqlInstance, provider, }, name) {
|
|
210
|
-
const historyRes = await getHistory({ gqlInstance }, name);
|
|
211
|
-
if (!historyRes)
|
|
212
|
-
return;
|
|
213
|
-
const { domain, registration, resolver: resolverHistory } = historyRes;
|
|
214
|
-
const textEvents = resolverHistory.filter((event) => event.type === 'TextChanged');
|
|
215
|
-
const transactions = textEvents.reduce((prev, curr) => {
|
|
216
|
-
if (prev.includes(curr.transactionHash)) {
|
|
217
|
-
return prev;
|
|
218
|
-
}
|
|
219
|
-
return [...prev, curr.transactionHash];
|
|
220
|
-
}, []);
|
|
221
|
-
const publicResolver = await contracts?.getPublicResolver();
|
|
222
|
-
const fetchResult = (await ethers_1.ethers.utils.fetchJson(provider.connection, JSON.stringify(transactions.map((tx, i) => ({
|
|
223
|
-
jsonrpc: '2.0',
|
|
224
|
-
id: i,
|
|
225
|
-
method: 'eth_getTransactionByHash',
|
|
226
|
-
params: [tx],
|
|
227
|
-
})))))
|
|
228
|
-
.map((result) => result.result)
|
|
229
|
-
.map(mapResultDetailDecode(publicResolver))
|
|
230
|
-
.reduce(expandDecode, []);
|
|
231
|
-
const detailedResolverHistory = resolverHistory.map((event) => {
|
|
232
|
-
if (event.type !== 'TextChanged')
|
|
233
|
-
return event;
|
|
234
|
-
const { id } = event;
|
|
235
|
-
const matchedTextInx = textEvents.findIndex((x) => x.id === id);
|
|
236
|
-
return {
|
|
237
|
-
...event,
|
|
238
|
-
data: {
|
|
239
|
-
...event.data,
|
|
240
|
-
value: fetchResult[matchedTextInx] && fetchResult[matchedTextInx].value,
|
|
241
|
-
},
|
|
242
|
-
};
|
|
243
|
-
});
|
|
244
|
-
return {
|
|
245
|
-
domain,
|
|
246
|
-
registration,
|
|
247
|
-
resolver: detailedResolverHistory,
|
|
248
|
-
};
|
|
249
|
-
}
|
|
250
|
-
exports.getHistoryWithDetail = getHistoryWithDetail;
|
|
251
|
-
async function getHistoryDetailForTransactionHash({ contracts, provider }, hash, indexInTransaction) {
|
|
252
|
-
const publicResolver = await contracts?.getPublicResolver();
|
|
253
|
-
const transaction = await provider.getTransaction(hash);
|
|
254
|
-
if (!transaction)
|
|
255
|
-
return;
|
|
256
|
-
const result = mapResultDetailDecode(publicResolver)({
|
|
257
|
-
input: transaction.data,
|
|
258
|
-
});
|
|
259
|
-
if (!result || !result.length)
|
|
260
|
-
return;
|
|
261
|
-
if (typeof indexInTransaction === 'number') {
|
|
262
|
-
if (indexInTransaction + 1 > result.length)
|
|
263
|
-
return;
|
|
264
|
-
const resultItem = result[indexInTransaction];
|
|
265
|
-
if (!resultItem ||
|
|
266
|
-
!resultItem.key ||
|
|
267
|
-
(!resultItem.value && resultItem.value !== ''))
|
|
268
|
-
return;
|
|
269
|
-
return { key: resultItem.key, value: resultItem.value };
|
|
270
|
-
}
|
|
271
|
-
return result.map((item) => {
|
|
272
|
-
if (!item.key)
|
|
273
|
-
return;
|
|
274
|
-
if (!item.value && item.value !== '')
|
|
275
|
-
return { key: item.key, value: null };
|
|
276
|
-
return { key: item.key, value: item.value };
|
|
277
|
-
});
|
|
278
|
-
}
|
|
279
|
-
exports.getHistoryDetailForTransactionHash = getHistoryDetailForTransactionHash;
|
|
@@ -10,8 +10,8 @@ declare const _default: {
|
|
|
10
10
|
reverseResolverAddress: any;
|
|
11
11
|
resolverAddress: any;
|
|
12
12
|
} | {
|
|
13
|
-
name:
|
|
14
|
-
match
|
|
13
|
+
name: undefined;
|
|
14
|
+
match?: undefined;
|
|
15
15
|
reverseResolverAddress?: undefined;
|
|
16
16
|
resolverAddress?: undefined;
|
|
17
17
|
} | undefined>;
|
|
@@ -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
|
|
@@ -206,8 +221,8 @@ export declare class ENS {
|
|
|
206
221
|
reverseResolverAddress: any;
|
|
207
222
|
resolverAddress: any;
|
|
208
223
|
} | {
|
|
209
|
-
name:
|
|
210
|
-
match
|
|
224
|
+
name: undefined;
|
|
225
|
+
match?: undefined;
|
|
211
226
|
reverseResolverAddress?: undefined;
|
|
212
227
|
resolverAddress?: undefined;
|
|
213
228
|
} | undefined>;
|
|
@@ -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<{
|
|
@@ -255,36 +271,6 @@ export declare class ENS {
|
|
|
255
271
|
data: Record<string, any>;
|
|
256
272
|
}[];
|
|
257
273
|
} | undefined>;
|
|
258
|
-
getHistoryWithDetail: (name: string) => Promise<{
|
|
259
|
-
domain: {
|
|
260
|
-
type: any;
|
|
261
|
-
blockNumber: any;
|
|
262
|
-
transactionHash: any;
|
|
263
|
-
id: any;
|
|
264
|
-
data: Record<string, any>;
|
|
265
|
-
}[];
|
|
266
|
-
registration: {
|
|
267
|
-
type: any;
|
|
268
|
-
blockNumber: any;
|
|
269
|
-
transactionHash: any;
|
|
270
|
-
id: any;
|
|
271
|
-
data: Record<string, any>;
|
|
272
|
-
}[];
|
|
273
|
-
resolver: {
|
|
274
|
-
type: any;
|
|
275
|
-
blockNumber: any;
|
|
276
|
-
transactionHash: any;
|
|
277
|
-
id: any;
|
|
278
|
-
data: Record<string, any>;
|
|
279
|
-
}[];
|
|
280
|
-
} | undefined>;
|
|
281
|
-
getHistoryDetailForTransactionHash: (hash: string, indexInTransaction?: number | undefined) => Promise<({
|
|
282
|
-
key: any;
|
|
283
|
-
value: any;
|
|
284
|
-
} | undefined)[] | {
|
|
285
|
-
key: any;
|
|
286
|
-
value: any;
|
|
287
|
-
} | undefined>;
|
|
288
274
|
getContentHash: GeneratedRawFunction<{
|
|
289
275
|
raw: ({ contracts, universalWrapper }: ENSArgs<"contracts" | "universalWrapper">, name: string) => Promise<{
|
|
290
276
|
to: string;
|
|
@@ -435,6 +421,7 @@ export declare class ENS {
|
|
|
435
421
|
premium: ethers.BigNumber;
|
|
436
422
|
} | undefined>;
|
|
437
423
|
}>;
|
|
424
|
+
getDNSOwner: (dnsName: string) => Promise<any>;
|
|
438
425
|
universalWrapper: GeneratedRawFunction<{
|
|
439
426
|
raw: ({ contracts }: ENSArgs<"contracts">, name: string, data: string) => Promise<{
|
|
440
427
|
to: string;
|
|
@@ -473,6 +460,8 @@ export declare class ENS {
|
|
|
473
460
|
createSubname: WriteFunction<typeof createSubname>;
|
|
474
461
|
deleteSubname: WriteFunction<typeof deleteSubname>;
|
|
475
462
|
transferSubname: WriteFunction<typeof transferSubname>;
|
|
476
|
-
|
|
463
|
+
commitName: WriteFunction<typeof commitName>;
|
|
464
|
+
registerName: WriteFunction<typeof registerName>;
|
|
465
|
+
renewName: WriteFunction<typeof renewName>;
|
|
477
466
|
}
|
|
478
467
|
export {};
|