@ensdomains/ensjs 3.0.0-alpha.4 → 3.0.0-alpha.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/functions/burnFuses.d.ts +3 -1
- package/dist/cjs/functions/burnFuses.js +1 -5
- package/dist/cjs/functions/createSubname.d.ts +1 -5
- package/dist/cjs/functions/createSubname.js +1 -5
- package/dist/cjs/functions/deleteSubname.d.ts +2 -2
- package/dist/cjs/functions/deleteSubname.js +5 -2
- package/dist/cjs/functions/setName.d.ts +3 -2
- package/dist/cjs/functions/setName.js +3 -8
- package/dist/cjs/functions/setRecords.d.ts +4 -1
- package/dist/cjs/functions/setRecords.js +10 -8
- package/dist/cjs/functions/setResolver.d.ts +3 -2
- package/dist/cjs/functions/setResolver.js +3 -9
- package/dist/cjs/functions/transferName.d.ts +3 -2
- package/dist/cjs/functions/transferName.js +5 -10
- package/dist/cjs/functions/transferSubname.d.ts +3 -2
- package/dist/cjs/functions/transferSubname.js +1 -5
- package/dist/cjs/functions/unwrapName.d.ts +3 -2
- package/dist/cjs/functions/unwrapName.js +1 -6
- package/dist/cjs/functions/wrapName.d.ts +4 -2
- package/dist/cjs/functions/wrapName.js +6 -10
- package/dist/cjs/index.d.ts +51 -34
- package/dist/cjs/index.js +35 -22
- package/dist/esm/functions/burnFuses.d.ts +3 -1
- package/dist/esm/functions/burnFuses.js +1 -5
- package/dist/esm/functions/createSubname.d.ts +1 -5
- package/dist/esm/functions/createSubname.js +1 -5
- package/dist/esm/functions/deleteSubname.d.ts +2 -2
- package/dist/esm/functions/deleteSubname.js +5 -2
- package/dist/esm/functions/setName.d.ts +3 -2
- package/dist/esm/functions/setName.js +3 -8
- package/dist/esm/functions/setRecords.d.ts +4 -1
- package/dist/esm/functions/setRecords.js +10 -8
- package/dist/esm/functions/setResolver.d.ts +3 -2
- package/dist/esm/functions/setResolver.js +3 -9
- package/dist/esm/functions/transferName.d.ts +3 -2
- package/dist/esm/functions/transferName.js +5 -10
- package/dist/esm/functions/transferSubname.d.ts +3 -2
- package/dist/esm/functions/transferSubname.js +1 -5
- package/dist/esm/functions/unwrapName.d.ts +3 -2
- package/dist/esm/functions/unwrapName.js +1 -6
- package/dist/esm/functions/wrapName.d.ts +4 -2
- package/dist/esm/functions/wrapName.js +6 -10
- package/dist/esm/index.d.ts +51 -34
- package/dist/esm/index.js +35 -22
- package/package.json +3 -3
- package/src/functions/burnFuses.test.ts +9 -8
- package/src/functions/burnFuses.ts +6 -8
- package/src/functions/createSubname.test.ts +8 -11
- package/src/functions/createSubname.ts +3 -10
- package/src/functions/deleteSubname.test.ts +28 -27
- package/src/functions/deleteSubname.ts +9 -12
- package/src/functions/getFuses.test.ts +11 -9
- package/src/functions/getOwner.test.ts +3 -1
- package/src/functions/setName.test.ts +3 -2
- package/src/functions/setName.ts +10 -12
- package/src/functions/setRecords.test.ts +7 -5
- package/src/functions/setRecords.ts +18 -12
- package/src/functions/setResolver.test.ts +12 -15
- package/src/functions/setResolver.ts +10 -18
- package/src/functions/transferName.test.ts +27 -29
- package/src/functions/transferName.ts +12 -18
- package/src/functions/transferSubname.test.ts +30 -29
- package/src/functions/transferSubname.ts +8 -10
- package/src/functions/unwrapName.test.ts +22 -22
- package/src/functions/unwrapName.ts +8 -12
- package/src/functions/wrapName.test.ts +15 -12
- package/src/functions/wrapName.ts +16 -15
- package/src/index.ts +80 -30
- package/src/tests/signerInjection.test.ts +42 -0
|
@@ -1,3 +1,5 @@
|
|
|
1
1
|
import { ENSArgs } from '..';
|
|
2
2
|
import { FuseOptions } from '../@types/FuseOptions';
|
|
3
|
-
export default function ({ contracts,
|
|
3
|
+
export default function ({ contracts, signer }: ENSArgs<'contracts' | 'signer'>, name: string, { fusesToBurn, }: {
|
|
4
|
+
fusesToBurn: FuseOptions;
|
|
5
|
+
}): Promise<import("ethers").ContractTransaction>;
|
|
@@ -5,11 +5,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
const generateFuseInput_1 = __importDefault(require("../utils/generateFuseInput"));
|
|
7
7
|
const normalise_1 = require("../utils/normalise");
|
|
8
|
-
async function default_1({ contracts,
|
|
9
|
-
const signer = provider?.getSigner();
|
|
10
|
-
if (!signer) {
|
|
11
|
-
throw new Error('No signer found');
|
|
12
|
-
}
|
|
8
|
+
async function default_1({ contracts, signer }, name, { fusesToBurn, }) {
|
|
13
9
|
const nameWrapper = (await contracts?.getNameWrapper()).connect(signer);
|
|
14
10
|
const hash = (0, normalise_1.namehash)(name);
|
|
15
11
|
const encodedFuses = (0, generateFuseInput_1.default)(fusesToBurn);
|
|
@@ -2,18 +2,14 @@ import { ethers } from 'ethers';
|
|
|
2
2
|
import { ENSArgs } from '..';
|
|
3
3
|
import { FuseOptions } from '../@types/FuseOptions';
|
|
4
4
|
declare type BaseArgs = {
|
|
5
|
-
name: string;
|
|
6
5
|
owner: string;
|
|
7
6
|
resolverAddress?: string;
|
|
8
7
|
contract: 'registry' | 'nameWrapper';
|
|
9
|
-
options?: {
|
|
10
|
-
addressOrIndex?: string | number;
|
|
11
|
-
};
|
|
12
8
|
};
|
|
13
9
|
declare type NameWrapperArgs = {
|
|
14
10
|
contract: 'nameWrapper';
|
|
15
11
|
fuses?: FuseOptions;
|
|
16
12
|
} & BaseArgs;
|
|
17
13
|
declare type Args = BaseArgs | NameWrapperArgs;
|
|
18
|
-
export default function ({ contracts,
|
|
14
|
+
export default function ({ contracts, signer }: ENSArgs<'contracts' | 'signer'>, name: string, { owner, resolverAddress, contract, ...wrapperArgs }: Args): Promise<ethers.ContractTransaction>;
|
|
19
15
|
export {};
|
|
@@ -6,11 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
const ethers_1 = require("ethers");
|
|
7
7
|
const generateFuseInput_1 = __importDefault(require("../utils/generateFuseInput"));
|
|
8
8
|
const normalise_1 = require("../utils/normalise");
|
|
9
|
-
async function default_1({ contracts,
|
|
10
|
-
const signer = provider?.getSigner(options?.addressOrIndex);
|
|
11
|
-
if (!signer) {
|
|
12
|
-
throw new Error('No signer found');
|
|
13
|
-
}
|
|
9
|
+
async function default_1({ contracts, signer }, name, { owner, resolverAddress, contract, ...wrapperArgs }) {
|
|
14
10
|
const labels = name.split('.');
|
|
15
11
|
if (labels.length === 1) {
|
|
16
12
|
throw new Error('Subnames in ENS.js can only be created for 2LDs, not TLDs');
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { ENSArgs } from '..';
|
|
2
|
-
export default function ({
|
|
3
|
-
|
|
2
|
+
export default function ({ transferSubname }: ENSArgs<'transferSubname'>, name: string, { contract, }: {
|
|
3
|
+
contract: 'registry' | 'nameWrapper';
|
|
4
4
|
}): Promise<import("ethers").ContractTransaction>;
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
async function default_1({
|
|
4
|
-
return transferSubname(name,
|
|
3
|
+
async function default_1({ transferSubname }, name, { contract, }) {
|
|
4
|
+
return transferSubname(name, {
|
|
5
|
+
contract,
|
|
6
|
+
address: '0x0000000000000000000000000000000000000000',
|
|
7
|
+
});
|
|
5
8
|
}
|
|
6
9
|
exports.default = default_1;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { ENSArgs } from '..';
|
|
2
|
-
export default function ({ contracts,
|
|
3
|
-
|
|
2
|
+
export default function ({ contracts, signer }: ENSArgs<'contracts' | 'signer'>, name: string, { address, resolver, }?: {
|
|
3
|
+
address?: string;
|
|
4
|
+
resolver?: string;
|
|
4
5
|
}): Promise<import("ethers").ContractTransaction | undefined>;
|
|
@@ -1,13 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
async function default_1({ contracts,
|
|
4
|
-
const signerAddress = await
|
|
5
|
-
|
|
6
|
-
.getAddress();
|
|
7
|
-
if (!signerAddress) {
|
|
8
|
-
throw new Error('No signer found');
|
|
9
|
-
}
|
|
10
|
-
const reverseRegistrar = (await contracts?.getReverseRegistrar())?.connect(provider?.getSigner());
|
|
3
|
+
async function default_1({ contracts, signer }, name, { address, resolver, } = {}) {
|
|
4
|
+
const signerAddress = await signer.getAddress();
|
|
5
|
+
const reverseRegistrar = (await contracts?.getReverseRegistrar())?.connect(signer);
|
|
11
6
|
if (address) {
|
|
12
7
|
const publicResolver = await contracts?.getPublicResolver();
|
|
13
8
|
return reverseRegistrar?.setNameForAddr(address, signerAddress, resolver || publicResolver.address, name);
|
|
@@ -1,3 +1,6 @@
|
|
|
1
1
|
import { ENSArgs } from '..';
|
|
2
2
|
import { RecordOptions } from '../utils/recordHelpers';
|
|
3
|
-
export default function ({ contracts, provider, getResolver, }: ENSArgs<'contracts' | 'provider' | 'getResolver'>, name: string, records
|
|
3
|
+
export default function ({ contracts, provider, getResolver, signer, }: ENSArgs<'contracts' | 'provider' | 'getResolver' | 'signer'>, name: string, { records, resolverAddress, }: {
|
|
4
|
+
records: RecordOptions;
|
|
5
|
+
resolverAddress?: string;
|
|
6
|
+
}): Promise<import("ethers").ContractTransaction | undefined>;
|
|
@@ -2,19 +2,21 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const normalise_1 = require("../utils/normalise");
|
|
4
4
|
const recordHelpers_1 = require("../utils/recordHelpers");
|
|
5
|
-
async function default_1({ contracts, provider, getResolver, }, name, records) {
|
|
5
|
+
async function default_1({ contracts, provider, getResolver, signer, }, name, { records, resolverAddress, }) {
|
|
6
6
|
if (!name.includes('.')) {
|
|
7
7
|
throw new Error('Input is not an ENS name');
|
|
8
8
|
}
|
|
9
|
-
|
|
10
|
-
if (
|
|
11
|
-
|
|
9
|
+
let resolverToUse;
|
|
10
|
+
if (resolverAddress) {
|
|
11
|
+
resolverToUse = resolverAddress;
|
|
12
|
+
}
|
|
13
|
+
else {
|
|
14
|
+
resolverToUse = await getResolver(name);
|
|
12
15
|
}
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
throw new Error('No signer found');
|
|
16
|
+
if (!resolverToUse) {
|
|
17
|
+
throw new Error('No resolver found for input address');
|
|
16
18
|
}
|
|
17
|
-
const resolver = (await contracts?.getPublicResolver(provider,
|
|
19
|
+
const resolver = (await contracts?.getPublicResolver(provider, resolverToUse))?.connect(signer);
|
|
18
20
|
const hash = (0, normalise_1.namehash)(name);
|
|
19
21
|
const calls = (0, recordHelpers_1.generateRecordCallArray)(hash, records, resolver);
|
|
20
22
|
return resolver?.multicall(calls);
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { ENSArgs } from '..';
|
|
2
|
-
export default function ({ contracts,
|
|
3
|
-
|
|
2
|
+
export default function ({ contracts, signer }: ENSArgs<'contracts' | 'signer'>, name: string, { contract, resolver, }: {
|
|
3
|
+
contract: 'registry' | 'nameWrapper';
|
|
4
|
+
resolver?: string;
|
|
4
5
|
}): Promise<import("ethers").ContractTransaction>;
|
|
@@ -1,23 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const normalise_1 = require("../utils/normalise");
|
|
4
|
-
async function default_1({ contracts,
|
|
5
|
-
const address = await provider
|
|
6
|
-
?.getSigner(options?.addressOrIndex)
|
|
7
|
-
.getAddress();
|
|
8
|
-
if (!address) {
|
|
9
|
-
throw new Error('No signer found');
|
|
10
|
-
}
|
|
4
|
+
async function default_1({ contracts, signer }, name, { contract, resolver, }) {
|
|
11
5
|
if (!resolver) {
|
|
12
6
|
resolver = (await contracts?.getPublicResolver()).address;
|
|
13
7
|
}
|
|
14
8
|
switch (contract) {
|
|
15
9
|
case 'registry': {
|
|
16
|
-
const registry = (await contracts?.getRegistry()).connect(
|
|
10
|
+
const registry = (await contracts?.getRegistry()).connect(signer);
|
|
17
11
|
return registry.setResolver((0, normalise_1.namehash)(name), resolver);
|
|
18
12
|
}
|
|
19
13
|
case 'nameWrapper': {
|
|
20
|
-
const nameWrapper = (await contracts?.getNameWrapper()).connect(
|
|
14
|
+
const nameWrapper = (await contracts?.getNameWrapper()).connect(signer);
|
|
21
15
|
return nameWrapper.setResolver((0, normalise_1.namehash)(name), resolver);
|
|
22
16
|
}
|
|
23
17
|
default: {
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { ethers } from 'ethers';
|
|
2
2
|
import { ENSArgs } from '..';
|
|
3
|
-
export default function ({ contracts,
|
|
4
|
-
|
|
3
|
+
export default function ({ contracts, signer }: ENSArgs<'contracts' | 'signer'>, name: string, { newOwner, contract, }: {
|
|
4
|
+
newOwner: string;
|
|
5
|
+
contract: 'registry' | 'nameWrapper' | 'baseRegistrar';
|
|
5
6
|
}): Promise<ethers.ContractTransaction>;
|
|
@@ -2,20 +2,15 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const ethers_1 = require("ethers");
|
|
4
4
|
const normalise_1 = require("../utils/normalise");
|
|
5
|
-
async function default_1({ contracts,
|
|
6
|
-
const address = await
|
|
7
|
-
?.getSigner(options?.addressOrIndex)
|
|
8
|
-
.getAddress();
|
|
9
|
-
if (!address) {
|
|
10
|
-
throw new Error('No signer found');
|
|
11
|
-
}
|
|
5
|
+
async function default_1({ contracts, signer }, name, { newOwner, contract, }) {
|
|
6
|
+
const address = await signer.getAddress();
|
|
12
7
|
switch (contract) {
|
|
13
8
|
case 'registry': {
|
|
14
|
-
const registry = (await contracts?.getRegistry()).connect(
|
|
9
|
+
const registry = (await contracts?.getRegistry()).connect(signer);
|
|
15
10
|
return registry.setOwner((0, normalise_1.namehash)(name), newOwner);
|
|
16
11
|
}
|
|
17
12
|
case 'baseRegistrar': {
|
|
18
|
-
const baseRegistrar = (await contracts?.getBaseRegistrar()).connect(
|
|
13
|
+
const baseRegistrar = (await contracts?.getBaseRegistrar()).connect(signer);
|
|
19
14
|
const labels = name.split('.');
|
|
20
15
|
if (labels.length > 2 || labels[labels.length - 1] !== 'eth') {
|
|
21
16
|
throw new Error('Invalid name for baseRegistrar');
|
|
@@ -23,7 +18,7 @@ async function default_1({ contracts, provider }, name, newOwner, contract, opti
|
|
|
23
18
|
return baseRegistrar['safeTransferFrom(address,address,uint256)'](address, newOwner, ethers_1.ethers.utils.solidityKeccak256(['string'], [labels[0]]));
|
|
24
19
|
}
|
|
25
20
|
case 'nameWrapper': {
|
|
26
|
-
const nameWrapper = (await contracts?.getNameWrapper()).connect(
|
|
21
|
+
const nameWrapper = (await contracts?.getNameWrapper()).connect(signer);
|
|
27
22
|
return nameWrapper.safeTransferFrom(address, newOwner, (0, normalise_1.namehash)(name), 1, '0x');
|
|
28
23
|
}
|
|
29
24
|
default: {
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { ethers } from 'ethers';
|
|
2
2
|
import { ENSArgs } from '..';
|
|
3
|
-
export default function ({ contracts,
|
|
4
|
-
|
|
3
|
+
export default function ({ contracts, signer }: ENSArgs<'contracts' | 'signer'>, name: string, { contract, address, }: {
|
|
4
|
+
contract: 'registry' | 'nameWrapper';
|
|
5
|
+
address: string;
|
|
5
6
|
}): Promise<ethers.ContractTransaction>;
|
|
@@ -2,11 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const ethers_1 = require("ethers");
|
|
4
4
|
const normalise_1 = require("../utils/normalise");
|
|
5
|
-
async function default_1({ contracts,
|
|
6
|
-
const signer = provider?.getSigner(options?.addressOrIndex);
|
|
7
|
-
if (!signer) {
|
|
8
|
-
throw new Error('No signer found');
|
|
9
|
-
}
|
|
5
|
+
async function default_1({ contracts, signer }, name, { contract, address, }) {
|
|
10
6
|
const labels = name.split('.');
|
|
11
7
|
const label = labels.shift();
|
|
12
8
|
const labelhash = ethers_1.ethers.utils.solidityKeccak256(['string'], [label]);
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { ENSArgs } from '..';
|
|
2
|
-
export default function ({ contracts,
|
|
3
|
-
|
|
2
|
+
export default function ({ contracts, signer }: ENSArgs<'contracts' | 'signer'>, name: string, { newController, newRegistrant, }: {
|
|
3
|
+
newController: string;
|
|
4
|
+
newRegistrant?: string;
|
|
4
5
|
}): Promise<import("ethers").ContractTransaction>;
|
|
@@ -2,12 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const ethers_1 = require("ethers");
|
|
4
4
|
const normalise_1 = require("../utils/normalise");
|
|
5
|
-
async function default_1({ contracts,
|
|
6
|
-
const signer = provider?.getSigner(options?.addressOrIndex);
|
|
7
|
-
const address = await signer?.getAddress();
|
|
8
|
-
if (!signer || !address) {
|
|
9
|
-
throw new Error('No signer found');
|
|
10
|
-
}
|
|
5
|
+
async function default_1({ contracts, signer }, name, { newController, newRegistrant, }) {
|
|
11
6
|
const labels = name.split('.');
|
|
12
7
|
const labelhash = ethers_1.utils.solidityKeccak256(['string'], [labels[0]]);
|
|
13
8
|
const parentNodehash = (0, normalise_1.namehash)(labels.slice(1).join('.'));
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { ethers } from 'ethers';
|
|
2
2
|
import { ENSArgs } from '..';
|
|
3
3
|
import type { FuseOptions } from '../@types/FuseOptions';
|
|
4
|
-
export default function ({ contracts,
|
|
5
|
-
|
|
4
|
+
export default function ({ contracts, signer }: ENSArgs<'contracts' | 'signer'>, name: string, { wrappedOwner, fuseOptions, resolverAddress, }: {
|
|
5
|
+
wrappedOwner: string;
|
|
6
|
+
fuseOptions?: FuseOptions | string | number;
|
|
7
|
+
resolverAddress?: string;
|
|
6
8
|
}): Promise<ethers.ContractTransaction>;
|
|
@@ -10,11 +10,11 @@ async function wrapETH({ contracts }, labels, wrappedOwner, decodedFuses, resolv
|
|
|
10
10
|
const nameWrapper = await contracts?.getNameWrapper();
|
|
11
11
|
const baseRegistrar = (await contracts?.getBaseRegistrar()).connect(signer);
|
|
12
12
|
const labelhash = ethers_1.ethers.utils.solidityKeccak256(['string'], [labels[0]]);
|
|
13
|
-
const data = ethers_1.ethers.utils.defaultAbiCoder.encode(['string', 'address', '
|
|
13
|
+
const data = ethers_1.ethers.utils.defaultAbiCoder.encode(['string', 'address', 'uint32', 'uint64', 'address'], [labels[0], wrappedOwner, '0x0', decodedFuses, resolverAddress]);
|
|
14
14
|
return baseRegistrar['safeTransferFrom(address,address,uint256,bytes)'](address, nameWrapper.address, labelhash, data);
|
|
15
15
|
}
|
|
16
|
-
async function wrapOther({ contracts }, name, wrappedOwner, decodedFuses, resolverAddress, address) {
|
|
17
|
-
const nameWrapper = await contracts?.getNameWrapper();
|
|
16
|
+
async function wrapOther({ contracts }, name, wrappedOwner, decodedFuses, resolverAddress, address, signer) {
|
|
17
|
+
const nameWrapper = (await contracts?.getNameWrapper()).connect(signer);
|
|
18
18
|
const registry = await contracts?.getRegistry();
|
|
19
19
|
const hasApproval = await registry.isApprovedForAll(address, nameWrapper.address);
|
|
20
20
|
if (!hasApproval) {
|
|
@@ -22,12 +22,8 @@ async function wrapOther({ contracts }, name, wrappedOwner, decodedFuses, resolv
|
|
|
22
22
|
}
|
|
23
23
|
return nameWrapper.wrap((0, hexEncodedName_1.hexEncodeName)(name), wrappedOwner, decodedFuses, resolverAddress);
|
|
24
24
|
}
|
|
25
|
-
async function default_1({ contracts,
|
|
26
|
-
const
|
|
27
|
-
const address = await signer?.getAddress();
|
|
28
|
-
if (!signer || !address) {
|
|
29
|
-
throw new Error('No signer found');
|
|
30
|
-
}
|
|
25
|
+
async function default_1({ contracts, signer }, name, { wrappedOwner, fuseOptions, resolverAddress, }) {
|
|
26
|
+
const address = await signer.getAddress();
|
|
31
27
|
let decodedFuses;
|
|
32
28
|
switch (typeof fuseOptions) {
|
|
33
29
|
case 'object': {
|
|
@@ -58,7 +54,7 @@ async function default_1({ contracts, provider }, name, wrappedOwner, fuseOption
|
|
|
58
54
|
return wrapETH({ contracts }, labels, wrappedOwner, decodedFuses, resolverAddress, signer, address);
|
|
59
55
|
}
|
|
60
56
|
else {
|
|
61
|
-
return wrapOther({ contracts }, name, wrappedOwner, decodedFuses, resolverAddress, address);
|
|
57
|
+
return wrapOther({ contracts }, name, wrappedOwner, decodedFuses, resolverAddress, address, signer);
|
|
62
58
|
}
|
|
63
59
|
}
|
|
64
60
|
exports.default = default_1;
|
package/dist/cjs/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ethers } from 'ethers';
|
|
1
|
+
import { ethers, Signer } from 'ethers';
|
|
2
2
|
import ContractManager from './contracts';
|
|
3
3
|
import { getContractAddress as _getContractAddress } from './contracts/getContractAddress';
|
|
4
4
|
import { SupportedNetworkId } from './contracts/types';
|
|
@@ -10,6 +10,7 @@ declare type ENSOptions = {
|
|
|
10
10
|
export declare type InternalENS = {
|
|
11
11
|
options?: ENSOptions;
|
|
12
12
|
provider?: ethers.providers.Provider;
|
|
13
|
+
signer: Signer;
|
|
13
14
|
graphURI?: string | null;
|
|
14
15
|
} & ENS;
|
|
15
16
|
export declare type ENSArgs<K extends keyof InternalENS> = {
|
|
@@ -17,6 +18,10 @@ export declare type ENSArgs<K extends keyof InternalENS> = {
|
|
|
17
18
|
};
|
|
18
19
|
declare type OmitFirstArg<F> = F extends (x: any, ...args: infer P) => infer R ? (...args: P) => R : never;
|
|
19
20
|
declare type OmitFirstTwoArgs<F> = F extends (x: any, y: any, ...args: infer P) => infer R ? (...args: P) => R : never;
|
|
21
|
+
declare type WriteOptions = {
|
|
22
|
+
addressOrIndex?: string | number;
|
|
23
|
+
signer?: Signer;
|
|
24
|
+
};
|
|
20
25
|
export declare type RawFunction = {
|
|
21
26
|
raw: (...args: any[]) => Promise<{
|
|
22
27
|
to: string;
|
|
@@ -77,6 +82,14 @@ export declare class ENS {
|
|
|
77
82
|
* @returns {OmitFirstArg} - The generated wrapped function
|
|
78
83
|
*/
|
|
79
84
|
private generateFunction;
|
|
85
|
+
/**
|
|
86
|
+
* Generates a write wrapped function
|
|
87
|
+
* @param {string} path - The path of the exported function
|
|
88
|
+
* @param {FunctionDeps} dependencies - An array of ENS properties
|
|
89
|
+
* @param {string} exportName - The export name of the target function
|
|
90
|
+
* @returns {OmitFirstArg} - The generated wrapped function
|
|
91
|
+
*/
|
|
92
|
+
private generateWriteFunction;
|
|
80
93
|
/**
|
|
81
94
|
* Generates a wrapped function from raw and decode exports
|
|
82
95
|
* @param {string} path - The path of the exported function
|
|
@@ -423,49 +436,53 @@ export declare class ENS {
|
|
|
423
436
|
}>;
|
|
424
437
|
decode: ({ contracts }: ENSArgs<"contracts">, data: string) => Promise<any>;
|
|
425
438
|
}>;
|
|
426
|
-
setName: (name: string,
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
}
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
439
|
+
setName: (name: string, options?: ({
|
|
440
|
+
address?: string | undefined;
|
|
441
|
+
resolver?: string | undefined;
|
|
442
|
+
} & WriteOptions) | undefined) => Promise<ethers.ContractTransaction | undefined>;
|
|
443
|
+
setRecords: (name: string, options: {
|
|
444
|
+
records: import("./utils/recordHelpers").RecordOptions;
|
|
445
|
+
resolverAddress?: string | undefined;
|
|
446
|
+
} & WriteOptions) => Promise<ethers.ContractTransaction | undefined>;
|
|
447
|
+
setResolver: (name: string, options: {
|
|
448
|
+
contract: "nameWrapper" | "registry";
|
|
449
|
+
resolver?: string | undefined;
|
|
450
|
+
} & WriteOptions) => Promise<ethers.ContractTransaction>;
|
|
451
|
+
transferName: (name: string, options: {
|
|
452
|
+
newOwner: string;
|
|
453
|
+
contract: "nameWrapper" | "registry" | "baseRegistrar";
|
|
454
|
+
} & WriteOptions) => Promise<ethers.ContractTransaction>;
|
|
455
|
+
wrapName: (name: string, options: {
|
|
456
|
+
wrappedOwner: string;
|
|
457
|
+
fuseOptions?: string | number | import("./@types/FuseOptions").FuseOptions | undefined;
|
|
458
|
+
resolverAddress?: string | undefined;
|
|
459
|
+
} & WriteOptions) => Promise<ethers.ContractTransaction>;
|
|
460
|
+
unwrapName: (name: string, options: {
|
|
461
|
+
newController: string;
|
|
462
|
+
newRegistrant?: string | undefined;
|
|
463
|
+
} & WriteOptions) => Promise<ethers.ContractTransaction>;
|
|
464
|
+
burnFuses: (name: string, options: {
|
|
465
|
+
fusesToBurn: import("./@types/FuseOptions").FuseOptions;
|
|
466
|
+
} & WriteOptions) => Promise<ethers.ContractTransaction>;
|
|
467
|
+
createSubname: (name: string, options: ({
|
|
445
468
|
owner: string;
|
|
446
469
|
resolverAddress?: string | undefined;
|
|
447
470
|
contract: "nameWrapper" | "registry";
|
|
448
|
-
options?: {
|
|
449
|
-
addressOrIndex?: string | number | undefined;
|
|
450
|
-
} | undefined;
|
|
451
471
|
} | ({
|
|
452
472
|
contract: "nameWrapper";
|
|
453
473
|
fuses?: import("./@types/FuseOptions").FuseOptions | undefined;
|
|
454
474
|
} & {
|
|
455
|
-
name: string;
|
|
456
475
|
owner: string;
|
|
457
476
|
resolverAddress?: string | undefined;
|
|
458
477
|
contract: "nameWrapper" | "registry";
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
})
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
addressOrIndex?: string | number | undefined;
|
|
468
|
-
} | undefined) => Promise<ethers.ContractTransaction>;
|
|
478
|
+
})) & WriteOptions) => Promise<ethers.ContractTransaction>;
|
|
479
|
+
deleteSubname: (name: string, options: {
|
|
480
|
+
contract: "nameWrapper" | "registry";
|
|
481
|
+
} & WriteOptions) => Promise<ethers.ContractTransaction>;
|
|
482
|
+
transferSubname: (name: string, options: {
|
|
483
|
+
contract: "nameWrapper" | "registry";
|
|
484
|
+
address: string;
|
|
485
|
+
} & WriteOptions) => Promise<ethers.ContractTransaction>;
|
|
469
486
|
getDNSOwner: (dnsName: string) => Promise<any>;
|
|
470
487
|
}
|
|
471
488
|
export {};
|
package/dist/cjs/index.js
CHANGED
|
@@ -95,9 +95,24 @@ class ENS {
|
|
|
95
95
|
// otherwise, create a function from the raw and decode functions
|
|
96
96
|
if (subFunc !== 'combine') {
|
|
97
97
|
// get the function to call
|
|
98
|
-
const func = subFunc
|
|
98
|
+
const func = subFunc && subFunc !== 'write'
|
|
99
|
+
? mod[exportName][subFunc]
|
|
100
|
+
: mod[exportName];
|
|
99
101
|
// get the dependencies to forward to the function as the first arg
|
|
100
|
-
|
|
102
|
+
let dependenciesToForward = thisRef.forwardDependenciesFromArray(dependencies);
|
|
103
|
+
// if func is write func, inject signer into dependencies
|
|
104
|
+
if (subFunc === 'write') {
|
|
105
|
+
const options = (args[1] || {});
|
|
106
|
+
const signer = options.signer ||
|
|
107
|
+
thisRef.provider?.getSigner(options.addressOrIndex);
|
|
108
|
+
if (!signer) {
|
|
109
|
+
throw new Error('No signer specified');
|
|
110
|
+
}
|
|
111
|
+
delete options.addressOrIndex;
|
|
112
|
+
delete options.signer;
|
|
113
|
+
dependenciesToForward = { ...dependenciesToForward, signer };
|
|
114
|
+
return func(dependenciesToForward, args[0], options);
|
|
115
|
+
}
|
|
101
116
|
// return the function with the dependencies forwarded
|
|
102
117
|
return func(dependenciesToForward, ...args);
|
|
103
118
|
}
|
|
@@ -124,6 +139,14 @@ class ENS {
|
|
|
124
139
|
* @returns {OmitFirstArg} - The generated wrapped function
|
|
125
140
|
*/
|
|
126
141
|
generateFunction = (path, dependencies, exportName = 'default') => this.importGenerator(path, dependencies, exportName);
|
|
142
|
+
/**
|
|
143
|
+
* Generates a write wrapped function
|
|
144
|
+
* @param {string} path - The path of the exported function
|
|
145
|
+
* @param {FunctionDeps} dependencies - An array of ENS properties
|
|
146
|
+
* @param {string} exportName - The export name of the target function
|
|
147
|
+
* @returns {OmitFirstArg} - The generated wrapped function
|
|
148
|
+
*/
|
|
149
|
+
generateWriteFunction = (path, dependencies, exportName = 'default') => this.importGenerator(path, dependencies, exportName, 'write');
|
|
127
150
|
/**
|
|
128
151
|
* Generates a wrapped function from raw and decode exports
|
|
129
152
|
* @param {string} path - The path of the exported function
|
|
@@ -194,32 +217,22 @@ class ENS {
|
|
|
194
217
|
universalWrapper = this.generateRawFunction('initialGetters', ['contracts'], 'universalWrapper');
|
|
195
218
|
resolverMulticallWrapper = this.generateRawFunction('initialGetters', ['contracts'], 'resolverMulticallWrapper');
|
|
196
219
|
multicallWrapper = this.generateRawFunction('initialGetters', ['contracts'], 'multicallWrapper');
|
|
197
|
-
setName = this.
|
|
198
|
-
'contracts',
|
|
199
|
-
'provider',
|
|
200
|
-
]);
|
|
201
|
-
setRecords = this.generateFunction('setRecords', [
|
|
202
|
-
'contracts',
|
|
203
|
-
'provider',
|
|
204
|
-
'getResolver',
|
|
205
|
-
]);
|
|
206
|
-
setResolver = this.generateFunction('setResolver', ['contracts', 'provider']);
|
|
207
|
-
transferName = this.generateFunction('transferName', ['contracts', 'provider']);
|
|
208
|
-
wrapName = this.generateFunction('wrapName', [
|
|
220
|
+
setName = this.generateWriteFunction('setName', [
|
|
209
221
|
'contracts',
|
|
210
|
-
'provider',
|
|
211
222
|
]);
|
|
212
|
-
|
|
223
|
+
setRecords = this.generateWriteFunction('setRecords', ['contracts', 'provider', 'getResolver']);
|
|
224
|
+
setResolver = this.generateWriteFunction('setResolver', ['contracts']);
|
|
225
|
+
transferName = this.generateWriteFunction('transferName', ['contracts']);
|
|
226
|
+
wrapName = this.generateWriteFunction('wrapName', [
|
|
213
227
|
'contracts',
|
|
214
|
-
'provider',
|
|
215
228
|
]);
|
|
216
|
-
|
|
229
|
+
unwrapName = this.generateWriteFunction('unwrapName', ['contracts']);
|
|
230
|
+
burnFuses = this.generateWriteFunction('burnFuses', [
|
|
217
231
|
'contracts',
|
|
218
|
-
'provider',
|
|
219
232
|
]);
|
|
220
|
-
createSubname = this.
|
|
221
|
-
deleteSubname = this.
|
|
222
|
-
transferSubname = this.
|
|
233
|
+
createSubname = this.generateWriteFunction('createSubname', ['contracts']);
|
|
234
|
+
deleteSubname = this.generateWriteFunction('deleteSubname', ['transferSubname']);
|
|
235
|
+
transferSubname = this.generateWriteFunction('transferSubname', ['contracts']);
|
|
223
236
|
getDNSOwner = this.generateFunction('getDNSOwner', []);
|
|
224
237
|
}
|
|
225
238
|
exports.ENS = ENS;
|
|
@@ -1,3 +1,5 @@
|
|
|
1
1
|
import { ENSArgs } from '..';
|
|
2
2
|
import { FuseOptions } from '../@types/FuseOptions';
|
|
3
|
-
export default function ({ contracts,
|
|
3
|
+
export default function ({ contracts, signer }: ENSArgs<'contracts' | 'signer'>, name: string, { fusesToBurn, }: {
|
|
4
|
+
fusesToBurn: FuseOptions;
|
|
5
|
+
}): Promise<import("ethers").ContractTransaction>;
|
|
@@ -1,10 +1,6 @@
|
|
|
1
1
|
import generateFuseInput from '../utils/generateFuseInput';
|
|
2
2
|
import { namehash } from '../utils/normalise';
|
|
3
|
-
export default async function ({ contracts,
|
|
4
|
-
const signer = provider?.getSigner();
|
|
5
|
-
if (!signer) {
|
|
6
|
-
throw new Error('No signer found');
|
|
7
|
-
}
|
|
3
|
+
export default async function ({ contracts, signer }, name, { fusesToBurn, }) {
|
|
8
4
|
const nameWrapper = (await contracts?.getNameWrapper()).connect(signer);
|
|
9
5
|
const hash = namehash(name);
|
|
10
6
|
const encodedFuses = generateFuseInput(fusesToBurn);
|
|
@@ -2,18 +2,14 @@ import { ethers } from 'ethers';
|
|
|
2
2
|
import { ENSArgs } from '..';
|
|
3
3
|
import { FuseOptions } from '../@types/FuseOptions';
|
|
4
4
|
declare type BaseArgs = {
|
|
5
|
-
name: string;
|
|
6
5
|
owner: string;
|
|
7
6
|
resolverAddress?: string;
|
|
8
7
|
contract: 'registry' | 'nameWrapper';
|
|
9
|
-
options?: {
|
|
10
|
-
addressOrIndex?: string | number;
|
|
11
|
-
};
|
|
12
8
|
};
|
|
13
9
|
declare type NameWrapperArgs = {
|
|
14
10
|
contract: 'nameWrapper';
|
|
15
11
|
fuses?: FuseOptions;
|
|
16
12
|
} & BaseArgs;
|
|
17
13
|
declare type Args = BaseArgs | NameWrapperArgs;
|
|
18
|
-
export default function ({ contracts,
|
|
14
|
+
export default function ({ contracts, signer }: ENSArgs<'contracts' | 'signer'>, name: string, { owner, resolverAddress, contract, ...wrapperArgs }: Args): Promise<ethers.ContractTransaction>;
|
|
19
15
|
export {};
|
|
@@ -1,11 +1,7 @@
|
|
|
1
1
|
import { ethers } from 'ethers';
|
|
2
2
|
import generateFuseInput from '../utils/generateFuseInput';
|
|
3
3
|
import { namehash } from '../utils/normalise';
|
|
4
|
-
export default async function ({ contracts,
|
|
5
|
-
const signer = provider?.getSigner(options?.addressOrIndex);
|
|
6
|
-
if (!signer) {
|
|
7
|
-
throw new Error('No signer found');
|
|
8
|
-
}
|
|
4
|
+
export default async function ({ contracts, signer }, name, { owner, resolverAddress, contract, ...wrapperArgs }) {
|
|
9
5
|
const labels = name.split('.');
|
|
10
6
|
if (labels.length === 1) {
|
|
11
7
|
throw new Error('Subnames in ENS.js can only be created for 2LDs, not TLDs');
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { ENSArgs } from '..';
|
|
2
|
-
export default function ({
|
|
3
|
-
|
|
2
|
+
export default function ({ transferSubname }: ENSArgs<'transferSubname'>, name: string, { contract, }: {
|
|
3
|
+
contract: 'registry' | 'nameWrapper';
|
|
4
4
|
}): Promise<import("ethers").ContractTransaction>;
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
-
export default async function ({
|
|
2
|
-
return transferSubname(name,
|
|
1
|
+
export default async function ({ transferSubname }, name, { contract, }) {
|
|
2
|
+
return transferSubname(name, {
|
|
3
|
+
contract,
|
|
4
|
+
address: '0x0000000000000000000000000000000000000000',
|
|
5
|
+
});
|
|
3
6
|
}
|