@ensdomains/ensjs 3.0.0-alpha.5 → 3.0.0-alpha.6
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 +1 -1
- package/dist/cjs/functions/burnFuses.js +1 -1
- package/dist/cjs/functions/createSubname.d.ts +1 -1
- package/dist/cjs/functions/createSubname.js +2 -2
- package/dist/cjs/functions/deleteSubname.d.ts +1 -1
- package/dist/cjs/functions/deleteSubname.js +1 -1
- package/dist/cjs/functions/setName.d.ts +1 -1
- package/dist/cjs/functions/setName.js +2 -2
- package/dist/cjs/functions/setRecords.d.ts +1 -1
- package/dist/cjs/functions/setRecords.js +1 -1
- package/dist/cjs/functions/setResolver.d.ts +1 -1
- package/dist/cjs/functions/setResolver.js +2 -2
- package/dist/cjs/functions/transferName.d.ts +1 -1
- package/dist/cjs/functions/transferName.js +3 -3
- package/dist/cjs/functions/transferSubname.d.ts +1 -1
- package/dist/cjs/functions/transferSubname.js +2 -2
- package/dist/cjs/functions/unwrapName.d.ts +1 -1
- package/dist/cjs/functions/unwrapName.js +2 -2
- package/dist/cjs/functions/wrapName.d.ts +2 -2
- package/dist/cjs/functions/wrapName.js +3 -3
- package/dist/cjs/index.d.ts +29 -50
- package/dist/cjs/index.js +9 -5
- package/dist/cjs/utils/writeTx.d.ts +4 -0
- package/dist/cjs/utils/writeTx.js +3 -0
- package/dist/esm/functions/burnFuses.d.ts +1 -1
- package/dist/esm/functions/burnFuses.js +1 -1
- package/dist/esm/functions/createSubname.d.ts +1 -1
- package/dist/esm/functions/createSubname.js +2 -2
- package/dist/esm/functions/deleteSubname.d.ts +1 -1
- package/dist/esm/functions/deleteSubname.js +1 -1
- package/dist/esm/functions/setName.d.ts +1 -1
- package/dist/esm/functions/setName.js +2 -2
- package/dist/esm/functions/setRecords.d.ts +1 -1
- package/dist/esm/functions/setRecords.js +1 -1
- package/dist/esm/functions/setResolver.d.ts +1 -1
- package/dist/esm/functions/setResolver.js +2 -2
- package/dist/esm/functions/transferName.d.ts +1 -1
- package/dist/esm/functions/transferName.js +3 -3
- package/dist/esm/functions/transferSubname.d.ts +1 -1
- package/dist/esm/functions/transferSubname.js +2 -2
- package/dist/esm/functions/unwrapName.d.ts +1 -1
- package/dist/esm/functions/unwrapName.js +2 -2
- package/dist/esm/functions/wrapName.d.ts +2 -2
- package/dist/esm/functions/wrapName.js +3 -3
- package/dist/esm/index.d.ts +29 -50
- package/dist/esm/index.js +9 -5
- package/dist/esm/utils/writeTx.d.ts +4 -0
- package/dist/esm/utils/writeTx.js +1 -0
- package/package.json +3 -3
- package/src/functions/burnFuses.ts +1 -1
- package/src/functions/createSubname.ts +2 -2
- package/src/functions/deleteSubname.ts +1 -1
- package/src/functions/setName.ts +5 -5
- package/src/functions/setRecords.ts +2 -2
- package/src/functions/setResolver.ts +5 -2
- package/src/functions/transferName.ts +5 -3
- package/src/functions/transferSubname.ts +11 -2
- package/src/functions/unwrapName.ts +10 -2
- package/src/functions/wrapName.ts +5 -8
- package/src/index.ts +36 -11
- package/src/tests/populateTransaction.test.ts +40 -0
- package/src/tests/signerInjection.test.ts +7 -3
- package/src/utils/writeTx.ts +6 -0
|
@@ -2,4 +2,4 @@ import { ENSArgs } from '..';
|
|
|
2
2
|
import { FuseOptions } from '../@types/FuseOptions';
|
|
3
3
|
export default function ({ contracts, signer }: ENSArgs<'contracts' | 'signer'>, name: string, { fusesToBurn, }: {
|
|
4
4
|
fusesToBurn: FuseOptions;
|
|
5
|
-
}): Promise<import("ethers").
|
|
5
|
+
}): Promise<import("ethers").PopulatedTransaction>;
|
|
@@ -9,6 +9,6 @@ async function default_1({ contracts, signer }, name, { fusesToBurn, }) {
|
|
|
9
9
|
const nameWrapper = (await contracts?.getNameWrapper()).connect(signer);
|
|
10
10
|
const hash = (0, normalise_1.namehash)(name);
|
|
11
11
|
const encodedFuses = (0, generateFuseInput_1.default)(fusesToBurn);
|
|
12
|
-
return nameWrapper.burnFuses(hash, encodedFuses);
|
|
12
|
+
return nameWrapper.populateTransaction.burnFuses(hash, encodedFuses);
|
|
13
13
|
}
|
|
14
14
|
exports.default = default_1;
|
|
@@ -11,5 +11,5 @@ declare type NameWrapperArgs = {
|
|
|
11
11
|
fuses?: FuseOptions;
|
|
12
12
|
} & BaseArgs;
|
|
13
13
|
declare type Args = BaseArgs | NameWrapperArgs;
|
|
14
|
-
export default function ({ contracts, signer }: ENSArgs<'contracts' | 'signer'>, name: string, { owner, resolverAddress, contract, ...wrapperArgs }: Args): Promise<ethers.
|
|
14
|
+
export default function ({ contracts, signer }: ENSArgs<'contracts' | 'signer'>, name: string, { owner, resolverAddress, contract, ...wrapperArgs }: Args): Promise<ethers.PopulatedTransaction>;
|
|
15
15
|
export {};
|
|
@@ -23,14 +23,14 @@ async function default_1({ contracts, signer }, name, { owner, resolverAddress,
|
|
|
23
23
|
switch (contract) {
|
|
24
24
|
case 'registry': {
|
|
25
25
|
const registry = (await contracts?.getRegistry()).connect(signer);
|
|
26
|
-
return registry.setSubnodeRecord(parentNodehash, labelhash, owner, resolverAddress, 0);
|
|
26
|
+
return registry.populateTransaction.setSubnodeRecord(parentNodehash, labelhash, owner, resolverAddress, 0);
|
|
27
27
|
}
|
|
28
28
|
case 'nameWrapper': {
|
|
29
29
|
const nameWrapper = (await contracts?.getNameWrapper()).connect(signer);
|
|
30
30
|
const generatedFuses = 'fuses' in wrapperArgs && wrapperArgs.fuses
|
|
31
31
|
? (0, generateFuseInput_1.default)(wrapperArgs.fuses)
|
|
32
32
|
: '0';
|
|
33
|
-
return nameWrapper.setSubnodeRecord(parentNodehash, label, owner, resolverAddress, 0, generatedFuses);
|
|
33
|
+
return nameWrapper.populateTransaction.setSubnodeRecord(parentNodehash, label, owner, resolverAddress, 0, generatedFuses);
|
|
34
34
|
}
|
|
35
35
|
default: {
|
|
36
36
|
throw new Error(`Unknown contract: ${contract}`);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { ENSArgs } from '..';
|
|
2
2
|
export default function ({ transferSubname }: ENSArgs<'transferSubname'>, name: string, { contract, }: {
|
|
3
3
|
contract: 'registry' | 'nameWrapper';
|
|
4
|
-
}): Promise<import("ethers").
|
|
4
|
+
}): Promise<import("ethers").PopulatedTransaction>;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
async function default_1({ transferSubname }, name, { contract, }) {
|
|
4
|
-
return transferSubname(name, {
|
|
4
|
+
return transferSubname.populateTransaction(name, {
|
|
5
5
|
contract,
|
|
6
6
|
address: '0x0000000000000000000000000000000000000000',
|
|
7
7
|
});
|
|
@@ -2,4 +2,4 @@ import { ENSArgs } from '..';
|
|
|
2
2
|
export default function ({ contracts, signer }: ENSArgs<'contracts' | 'signer'>, name: string, { address, resolver, }?: {
|
|
3
3
|
address?: string;
|
|
4
4
|
resolver?: string;
|
|
5
|
-
}): Promise<import("ethers").
|
|
5
|
+
}): Promise<import("ethers").PopulatedTransaction>;
|
|
@@ -5,8 +5,8 @@ async function default_1({ contracts, signer }, name, { address, resolver, } = {
|
|
|
5
5
|
const reverseRegistrar = (await contracts?.getReverseRegistrar())?.connect(signer);
|
|
6
6
|
if (address) {
|
|
7
7
|
const publicResolver = await contracts?.getPublicResolver();
|
|
8
|
-
return reverseRegistrar
|
|
8
|
+
return reverseRegistrar.populateTransaction.setNameForAddr(address, signerAddress, resolver || publicResolver.address, name);
|
|
9
9
|
}
|
|
10
|
-
return reverseRegistrar
|
|
10
|
+
return reverseRegistrar.populateTransaction.setName(name);
|
|
11
11
|
}
|
|
12
12
|
exports.default = default_1;
|
|
@@ -3,4 +3,4 @@ import { RecordOptions } from '../utils/recordHelpers';
|
|
|
3
3
|
export default function ({ contracts, provider, getResolver, signer, }: ENSArgs<'contracts' | 'provider' | 'getResolver' | 'signer'>, name: string, { records, resolverAddress, }: {
|
|
4
4
|
records: RecordOptions;
|
|
5
5
|
resolverAddress?: string;
|
|
6
|
-
}): Promise<import("ethers").
|
|
6
|
+
}): Promise<import("ethers").PopulatedTransaction>;
|
|
@@ -19,6 +19,6 @@ async function default_1({ contracts, provider, getResolver, signer, }, name, {
|
|
|
19
19
|
const resolver = (await contracts?.getPublicResolver(provider, resolverToUse))?.connect(signer);
|
|
20
20
|
const hash = (0, normalise_1.namehash)(name);
|
|
21
21
|
const calls = (0, recordHelpers_1.generateRecordCallArray)(hash, records, resolver);
|
|
22
|
-
return resolver
|
|
22
|
+
return resolver.populateTransaction.multicall(calls);
|
|
23
23
|
}
|
|
24
24
|
exports.default = default_1;
|
|
@@ -2,4 +2,4 @@ import { ENSArgs } from '..';
|
|
|
2
2
|
export default function ({ contracts, signer }: ENSArgs<'contracts' | 'signer'>, name: string, { contract, resolver, }: {
|
|
3
3
|
contract: 'registry' | 'nameWrapper';
|
|
4
4
|
resolver?: string;
|
|
5
|
-
}): Promise<import("ethers").
|
|
5
|
+
}): Promise<import("ethers").PopulatedTransaction>;
|
|
@@ -8,11 +8,11 @@ async function default_1({ contracts, signer }, name, { contract, resolver, }) {
|
|
|
8
8
|
switch (contract) {
|
|
9
9
|
case 'registry': {
|
|
10
10
|
const registry = (await contracts?.getRegistry()).connect(signer);
|
|
11
|
-
return registry.setResolver((0, normalise_1.namehash)(name), resolver);
|
|
11
|
+
return registry.populateTransaction.setResolver((0, normalise_1.namehash)(name), resolver);
|
|
12
12
|
}
|
|
13
13
|
case 'nameWrapper': {
|
|
14
14
|
const nameWrapper = (await contracts?.getNameWrapper()).connect(signer);
|
|
15
|
-
return nameWrapper.setResolver((0, normalise_1.namehash)(name), resolver);
|
|
15
|
+
return nameWrapper.populateTransaction.setResolver((0, normalise_1.namehash)(name), resolver);
|
|
16
16
|
}
|
|
17
17
|
default: {
|
|
18
18
|
throw new Error(`Unknown contract: ${contract}`);
|
|
@@ -3,4 +3,4 @@ import { ENSArgs } from '..';
|
|
|
3
3
|
export default function ({ contracts, signer }: ENSArgs<'contracts' | 'signer'>, name: string, { newOwner, contract, }: {
|
|
4
4
|
newOwner: string;
|
|
5
5
|
contract: 'registry' | 'nameWrapper' | 'baseRegistrar';
|
|
6
|
-
}): Promise<ethers.
|
|
6
|
+
}): Promise<ethers.PopulatedTransaction>;
|
|
@@ -7,7 +7,7 @@ async function default_1({ contracts, signer }, name, { newOwner, contract, }) {
|
|
|
7
7
|
switch (contract) {
|
|
8
8
|
case 'registry': {
|
|
9
9
|
const registry = (await contracts?.getRegistry()).connect(signer);
|
|
10
|
-
return registry.setOwner((0, normalise_1.namehash)(name), newOwner);
|
|
10
|
+
return registry.populateTransaction.setOwner((0, normalise_1.namehash)(name), newOwner);
|
|
11
11
|
}
|
|
12
12
|
case 'baseRegistrar': {
|
|
13
13
|
const baseRegistrar = (await contracts?.getBaseRegistrar()).connect(signer);
|
|
@@ -15,11 +15,11 @@ async function default_1({ contracts, signer }, name, { newOwner, contract, }) {
|
|
|
15
15
|
if (labels.length > 2 || labels[labels.length - 1] !== 'eth') {
|
|
16
16
|
throw new Error('Invalid name for baseRegistrar');
|
|
17
17
|
}
|
|
18
|
-
return baseRegistrar['safeTransferFrom(address,address,uint256)'](address, newOwner, ethers_1.ethers.utils.solidityKeccak256(['string'], [labels[0]]));
|
|
18
|
+
return baseRegistrar.populateTransaction['safeTransferFrom(address,address,uint256)'](address, newOwner, ethers_1.ethers.utils.solidityKeccak256(['string'], [labels[0]]));
|
|
19
19
|
}
|
|
20
20
|
case 'nameWrapper': {
|
|
21
21
|
const nameWrapper = (await contracts?.getNameWrapper()).connect(signer);
|
|
22
|
-
return nameWrapper.safeTransferFrom(address, newOwner, (0, normalise_1.namehash)(name), 1, '0x');
|
|
22
|
+
return nameWrapper.populateTransaction.safeTransferFrom(address, newOwner, (0, normalise_1.namehash)(name), 1, '0x');
|
|
23
23
|
}
|
|
24
24
|
default: {
|
|
25
25
|
throw new Error(`Unknown contract: ${contract}`);
|
|
@@ -3,4 +3,4 @@ import { ENSArgs } from '..';
|
|
|
3
3
|
export default function ({ contracts, signer }: ENSArgs<'contracts' | 'signer'>, name: string, { contract, address, }: {
|
|
4
4
|
contract: 'registry' | 'nameWrapper';
|
|
5
5
|
address: string;
|
|
6
|
-
}): Promise<ethers.
|
|
6
|
+
}): Promise<ethers.PopulatedTransaction>;
|
|
@@ -10,11 +10,11 @@ async function default_1({ contracts, signer }, name, { contract, address, }) {
|
|
|
10
10
|
switch (contract) {
|
|
11
11
|
case 'registry': {
|
|
12
12
|
const registry = (await contracts?.getRegistry()).connect(signer);
|
|
13
|
-
return registry.setSubnodeOwner(parentNodehash, labelhash, address);
|
|
13
|
+
return registry.populateTransaction.setSubnodeOwner(parentNodehash, labelhash, address);
|
|
14
14
|
}
|
|
15
15
|
case 'nameWrapper': {
|
|
16
16
|
const nameWrapper = (await contracts?.getNameWrapper()).connect(signer);
|
|
17
|
-
return nameWrapper.setSubnodeOwner(parentNodehash, label, address, '0');
|
|
17
|
+
return nameWrapper.populateTransaction.setSubnodeOwner(parentNodehash, label, address, '0');
|
|
18
18
|
}
|
|
19
19
|
default: {
|
|
20
20
|
throw new Error(`Unknown contract: ${contract}`);
|
|
@@ -2,4 +2,4 @@ import { ENSArgs } from '..';
|
|
|
2
2
|
export default function ({ contracts, signer }: ENSArgs<'contracts' | 'signer'>, name: string, { newController, newRegistrant, }: {
|
|
3
3
|
newController: string;
|
|
4
4
|
newRegistrant?: string;
|
|
5
|
-
}): Promise<import("ethers").
|
|
5
|
+
}): Promise<import("ethers").PopulatedTransaction>;
|
|
@@ -11,13 +11,13 @@ async function default_1({ contracts, signer }, name, { newController, newRegist
|
|
|
11
11
|
if (!newRegistrant) {
|
|
12
12
|
throw new Error('newRegistrant must be specified for .eth names');
|
|
13
13
|
}
|
|
14
|
-
return nameWrapper.unwrapETH2LD(labelhash, newRegistrant, newController);
|
|
14
|
+
return nameWrapper.populateTransaction.unwrapETH2LD(labelhash, newRegistrant, newController);
|
|
15
15
|
}
|
|
16
16
|
else {
|
|
17
17
|
if (newRegistrant) {
|
|
18
18
|
throw new Error('newRegistrant can only be specified for .eth names');
|
|
19
19
|
}
|
|
20
|
-
return nameWrapper.unwrap(parentNodehash, labelhash, newController);
|
|
20
|
+
return nameWrapper.populateTransaction.unwrap(parentNodehash, labelhash, newController);
|
|
21
21
|
}
|
|
22
22
|
}
|
|
23
23
|
exports.default = default_1;
|
|
@@ -1,8 +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, signer }: ENSArgs<'contracts' | 'signer'>, name: string, { wrappedOwner, fuseOptions, resolverAddress, }: {
|
|
4
|
+
export default function ({ contracts, signer, populate }: ENSArgs<'contracts' | 'signer' | 'populate'>, name: string, { wrappedOwner, fuseOptions, resolverAddress, }: {
|
|
5
5
|
wrappedOwner: string;
|
|
6
6
|
fuseOptions?: FuseOptions | string | number;
|
|
7
7
|
resolverAddress?: string;
|
|
8
|
-
}): Promise<ethers.
|
|
8
|
+
}): Promise<ethers.PopulatedTransaction>;
|
|
@@ -11,7 +11,7 @@ async function wrapETH({ contracts }, labels, wrappedOwner, decodedFuses, resolv
|
|
|
11
11
|
const baseRegistrar = (await contracts?.getBaseRegistrar()).connect(signer);
|
|
12
12
|
const labelhash = ethers_1.ethers.utils.solidityKeccak256(['string'], [labels[0]]);
|
|
13
13
|
const data = ethers_1.ethers.utils.defaultAbiCoder.encode(['string', 'address', 'uint32', 'uint64', 'address'], [labels[0], wrappedOwner, '0x0', decodedFuses, resolverAddress]);
|
|
14
|
-
return baseRegistrar['safeTransferFrom(address,address,uint256,bytes)'](address, nameWrapper.address, labelhash, data);
|
|
14
|
+
return baseRegistrar.populateTransaction['safeTransferFrom(address,address,uint256,bytes)'](address, nameWrapper.address, labelhash, data);
|
|
15
15
|
}
|
|
16
16
|
async function wrapOther({ contracts }, name, wrappedOwner, decodedFuses, resolverAddress, address, signer) {
|
|
17
17
|
const nameWrapper = (await contracts?.getNameWrapper()).connect(signer);
|
|
@@ -20,9 +20,9 @@ async function wrapOther({ contracts }, name, wrappedOwner, decodedFuses, resolv
|
|
|
20
20
|
if (!hasApproval) {
|
|
21
21
|
throw new Error('NameWrapper must have approval to wrap a name from this address.');
|
|
22
22
|
}
|
|
23
|
-
return nameWrapper.wrap((0, hexEncodedName_1.hexEncodeName)(name), wrappedOwner, decodedFuses, resolverAddress);
|
|
23
|
+
return nameWrapper.populateTransaction.wrap((0, hexEncodedName_1.hexEncodeName)(name), wrappedOwner, decodedFuses, resolverAddress);
|
|
24
24
|
}
|
|
25
|
-
async function default_1({ contracts, signer }, name, { wrappedOwner, fuseOptions, resolverAddress, }) {
|
|
25
|
+
async function default_1({ contracts, signer, populate }, name, { wrappedOwner, fuseOptions, resolverAddress, }) {
|
|
26
26
|
const address = await signer.getAddress();
|
|
27
27
|
let decodedFuses;
|
|
28
28
|
switch (typeof fuseOptions) {
|
package/dist/cjs/index.d.ts
CHANGED
|
@@ -1,7 +1,18 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { JsonRpcSigner } from '@ethersproject/providers';
|
|
2
|
+
import { ContractTransaction, ethers, PopulatedTransaction } from 'ethers';
|
|
2
3
|
import ContractManager from './contracts';
|
|
3
4
|
import { getContractAddress as _getContractAddress } from './contracts/getContractAddress';
|
|
4
5
|
import { SupportedNetworkId } from './contracts/types';
|
|
6
|
+
import type burnFuses from './functions/burnFuses';
|
|
7
|
+
import type createSubname from './functions/createSubname';
|
|
8
|
+
import type deleteSubname from './functions/deleteSubname';
|
|
9
|
+
import type setName from './functions/setName';
|
|
10
|
+
import type setRecords from './functions/setRecords';
|
|
11
|
+
import type setResolver from './functions/setResolver';
|
|
12
|
+
import type transferName from './functions/transferName';
|
|
13
|
+
import type transferSubname from './functions/transferSubname';
|
|
14
|
+
import type unwrapName from './functions/unwrapName';
|
|
15
|
+
import type wrapName from './functions/wrapName';
|
|
5
16
|
import GqlManager from './GqlManager';
|
|
6
17
|
declare type ENSOptions = {
|
|
7
18
|
graphURI?: string | null;
|
|
@@ -10,7 +21,7 @@ declare type ENSOptions = {
|
|
|
10
21
|
export declare type InternalENS = {
|
|
11
22
|
options?: ENSOptions;
|
|
12
23
|
provider?: ethers.providers.Provider;
|
|
13
|
-
signer:
|
|
24
|
+
signer: JsonRpcSigner;
|
|
14
25
|
graphURI?: string | null;
|
|
15
26
|
} & ENS;
|
|
16
27
|
export declare type ENSArgs<K extends keyof InternalENS> = {
|
|
@@ -20,8 +31,13 @@ declare type OmitFirstArg<F> = F extends (x: any, ...args: infer P) => infer R ?
|
|
|
20
31
|
declare type OmitFirstTwoArgs<F> = F extends (x: any, y: any, ...args: infer P) => infer R ? (...args: P) => R : never;
|
|
21
32
|
declare type WriteOptions = {
|
|
22
33
|
addressOrIndex?: string | number;
|
|
23
|
-
signer?:
|
|
34
|
+
signer?: JsonRpcSigner;
|
|
24
35
|
};
|
|
36
|
+
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;
|
|
37
|
+
interface WriteFunction<F extends (...args: any) => any> extends Function {
|
|
38
|
+
(...args: Parameters<OptionalWriteOptions<F>>): Promise<ContractTransaction>;
|
|
39
|
+
populateTransaction: (...args: Parameters<OptionalWriteOptions<F>>) => Promise<PopulatedTransaction>;
|
|
40
|
+
}
|
|
25
41
|
export declare type RawFunction = {
|
|
26
42
|
raw: (...args: any[]) => Promise<{
|
|
27
43
|
to: string;
|
|
@@ -436,53 +452,16 @@ export declare class ENS {
|
|
|
436
452
|
}>;
|
|
437
453
|
decode: ({ contracts }: ENSArgs<"contracts">, data: string) => Promise<any>;
|
|
438
454
|
}>;
|
|
439
|
-
setName:
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
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: ({
|
|
468
|
-
owner: string;
|
|
469
|
-
resolverAddress?: string | undefined;
|
|
470
|
-
contract: "nameWrapper" | "registry";
|
|
471
|
-
} | ({
|
|
472
|
-
contract: "nameWrapper";
|
|
473
|
-
fuses?: import("./@types/FuseOptions").FuseOptions | undefined;
|
|
474
|
-
} & {
|
|
475
|
-
owner: string;
|
|
476
|
-
resolverAddress?: string | undefined;
|
|
477
|
-
contract: "nameWrapper" | "registry";
|
|
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>;
|
|
455
|
+
setName: WriteFunction<typeof setName>;
|
|
456
|
+
setRecords: WriteFunction<typeof setRecords>;
|
|
457
|
+
setResolver: WriteFunction<typeof setResolver>;
|
|
458
|
+
transferName: WriteFunction<typeof transferName>;
|
|
459
|
+
wrapName: WriteFunction<typeof wrapName>;
|
|
460
|
+
unwrapName: WriteFunction<typeof unwrapName>;
|
|
461
|
+
burnFuses: WriteFunction<typeof burnFuses>;
|
|
462
|
+
createSubname: WriteFunction<typeof createSubname>;
|
|
463
|
+
deleteSubname: WriteFunction<typeof deleteSubname>;
|
|
464
|
+
transferSubname: WriteFunction<typeof transferSubname>;
|
|
486
465
|
getDNSOwner: (dnsName: string) => Promise<any>;
|
|
487
466
|
}
|
|
488
467
|
export {};
|
package/dist/cjs/index.js
CHANGED
|
@@ -31,6 +31,7 @@ const contracts_1 = __importDefault(require("./contracts"));
|
|
|
31
31
|
const getContractAddress_1 = require("./contracts/getContractAddress");
|
|
32
32
|
const GqlManager_1 = __importDefault(require("./GqlManager"));
|
|
33
33
|
const singleCall_1 = __importDefault(require("./utils/singleCall"));
|
|
34
|
+
const writeTx_1 = __importDefault(require("./utils/writeTx"));
|
|
34
35
|
const graphURIEndpoints = {
|
|
35
36
|
1: 'https://api.thegraph.com/subgraphs/name/ensdomains/ens',
|
|
36
37
|
3: 'https://api.thegraph.com/subgraphs/name/ensdomains/ensropsten',
|
|
@@ -94,24 +95,24 @@ class ENS {
|
|
|
94
95
|
// if combine isn't specified, run normally
|
|
95
96
|
// otherwise, create a function from the raw and decode functions
|
|
96
97
|
if (subFunc !== 'combine') {
|
|
98
|
+
const writeable = subFunc === 'write' || subFunc === 'populateTransaction';
|
|
97
99
|
// get the function to call
|
|
98
|
-
const func = subFunc && subFunc
|
|
99
|
-
? mod[exportName][subFunc]
|
|
100
|
-
: mod[exportName];
|
|
100
|
+
const func = subFunc && !writeable ? mod[exportName][subFunc] : mod[exportName];
|
|
101
101
|
// get the dependencies to forward to the function as the first arg
|
|
102
102
|
let dependenciesToForward = thisRef.forwardDependenciesFromArray(dependencies);
|
|
103
103
|
// if func is write func, inject signer into dependencies
|
|
104
|
-
if (
|
|
104
|
+
if (writeable) {
|
|
105
105
|
const options = (args[1] || {});
|
|
106
106
|
const signer = options.signer ||
|
|
107
107
|
thisRef.provider?.getSigner(options.addressOrIndex);
|
|
108
|
+
const populate = subFunc === 'populateTransaction';
|
|
108
109
|
if (!signer) {
|
|
109
110
|
throw new Error('No signer specified');
|
|
110
111
|
}
|
|
111
112
|
delete options.addressOrIndex;
|
|
112
113
|
delete options.signer;
|
|
113
114
|
dependenciesToForward = { ...dependenciesToForward, signer };
|
|
114
|
-
return func(dependenciesToForward, args[0], options);
|
|
115
|
+
return func(dependenciesToForward, args[0], options).then((0, writeTx_1.default)(signer, populate));
|
|
115
116
|
}
|
|
116
117
|
// return the function with the dependencies forwarded
|
|
117
118
|
return func(dependenciesToForward, ...args);
|
|
@@ -129,6 +130,9 @@ class ENS {
|
|
|
129
130
|
mainFunc.decode = this.importGenerator(path, dependencies, exportName, 'decode');
|
|
130
131
|
mainFunc.batch = this.importGenerator(path, dependencies, exportName, 'batch', { raw: mainFunc.raw, decode: mainFunc.decode });
|
|
131
132
|
}
|
|
133
|
+
else if (subFunc === 'write') {
|
|
134
|
+
mainFunc.populateTransaction = this.importGenerator(path, dependencies, exportName, 'populateTransaction');
|
|
135
|
+
}
|
|
132
136
|
return mainFunc;
|
|
133
137
|
};
|
|
134
138
|
/**
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { JsonRpcSigner } from '@ethersproject/providers';
|
|
2
|
+
import type { PopulatedTransaction } from 'ethers';
|
|
3
|
+
declare const _default: (signer: JsonRpcSigner, populate: boolean) => (tx: PopulatedTransaction) => PopulatedTransaction | Promise<import("@ethersproject/abstract-provider").TransactionResponse>;
|
|
4
|
+
export default _default;
|
|
@@ -2,4 +2,4 @@ import { ENSArgs } from '..';
|
|
|
2
2
|
import { FuseOptions } from '../@types/FuseOptions';
|
|
3
3
|
export default function ({ contracts, signer }: ENSArgs<'contracts' | 'signer'>, name: string, { fusesToBurn, }: {
|
|
4
4
|
fusesToBurn: FuseOptions;
|
|
5
|
-
}): Promise<import("ethers").
|
|
5
|
+
}): Promise<import("ethers").PopulatedTransaction>;
|
|
@@ -4,5 +4,5 @@ export default async function ({ contracts, signer }, name, { fusesToBurn, }) {
|
|
|
4
4
|
const nameWrapper = (await contracts?.getNameWrapper()).connect(signer);
|
|
5
5
|
const hash = namehash(name);
|
|
6
6
|
const encodedFuses = generateFuseInput(fusesToBurn);
|
|
7
|
-
return nameWrapper.burnFuses(hash, encodedFuses);
|
|
7
|
+
return nameWrapper.populateTransaction.burnFuses(hash, encodedFuses);
|
|
8
8
|
}
|
|
@@ -11,5 +11,5 @@ declare type NameWrapperArgs = {
|
|
|
11
11
|
fuses?: FuseOptions;
|
|
12
12
|
} & BaseArgs;
|
|
13
13
|
declare type Args = BaseArgs | NameWrapperArgs;
|
|
14
|
-
export default function ({ contracts, signer }: ENSArgs<'contracts' | 'signer'>, name: string, { owner, resolverAddress, contract, ...wrapperArgs }: Args): Promise<ethers.
|
|
14
|
+
export default function ({ contracts, signer }: ENSArgs<'contracts' | 'signer'>, name: string, { owner, resolverAddress, contract, ...wrapperArgs }: Args): Promise<ethers.PopulatedTransaction>;
|
|
15
15
|
export {};
|
|
@@ -18,14 +18,14 @@ export default async function ({ contracts, signer }, name, { owner, resolverAdd
|
|
|
18
18
|
switch (contract) {
|
|
19
19
|
case 'registry': {
|
|
20
20
|
const registry = (await contracts?.getRegistry()).connect(signer);
|
|
21
|
-
return registry.setSubnodeRecord(parentNodehash, labelhash, owner, resolverAddress, 0);
|
|
21
|
+
return registry.populateTransaction.setSubnodeRecord(parentNodehash, labelhash, owner, resolverAddress, 0);
|
|
22
22
|
}
|
|
23
23
|
case 'nameWrapper': {
|
|
24
24
|
const nameWrapper = (await contracts?.getNameWrapper()).connect(signer);
|
|
25
25
|
const generatedFuses = 'fuses' in wrapperArgs && wrapperArgs.fuses
|
|
26
26
|
? generateFuseInput(wrapperArgs.fuses)
|
|
27
27
|
: '0';
|
|
28
|
-
return nameWrapper.setSubnodeRecord(parentNodehash, label, owner, resolverAddress, 0, generatedFuses);
|
|
28
|
+
return nameWrapper.populateTransaction.setSubnodeRecord(parentNodehash, label, owner, resolverAddress, 0, generatedFuses);
|
|
29
29
|
}
|
|
30
30
|
default: {
|
|
31
31
|
throw new Error(`Unknown contract: ${contract}`);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { ENSArgs } from '..';
|
|
2
2
|
export default function ({ transferSubname }: ENSArgs<'transferSubname'>, name: string, { contract, }: {
|
|
3
3
|
contract: 'registry' | 'nameWrapper';
|
|
4
|
-
}): Promise<import("ethers").
|
|
4
|
+
}): Promise<import("ethers").PopulatedTransaction>;
|
|
@@ -2,4 +2,4 @@ import { ENSArgs } from '..';
|
|
|
2
2
|
export default function ({ contracts, signer }: ENSArgs<'contracts' | 'signer'>, name: string, { address, resolver, }?: {
|
|
3
3
|
address?: string;
|
|
4
4
|
resolver?: string;
|
|
5
|
-
}): Promise<import("ethers").
|
|
5
|
+
}): Promise<import("ethers").PopulatedTransaction>;
|
|
@@ -3,7 +3,7 @@ export default async function ({ contracts, signer }, name, { address, resolver,
|
|
|
3
3
|
const reverseRegistrar = (await contracts?.getReverseRegistrar())?.connect(signer);
|
|
4
4
|
if (address) {
|
|
5
5
|
const publicResolver = await contracts?.getPublicResolver();
|
|
6
|
-
return reverseRegistrar
|
|
6
|
+
return reverseRegistrar.populateTransaction.setNameForAddr(address, signerAddress, resolver || publicResolver.address, name);
|
|
7
7
|
}
|
|
8
|
-
return reverseRegistrar
|
|
8
|
+
return reverseRegistrar.populateTransaction.setName(name);
|
|
9
9
|
}
|
|
@@ -3,4 +3,4 @@ import { RecordOptions } from '../utils/recordHelpers';
|
|
|
3
3
|
export default function ({ contracts, provider, getResolver, signer, }: ENSArgs<'contracts' | 'provider' | 'getResolver' | 'signer'>, name: string, { records, resolverAddress, }: {
|
|
4
4
|
records: RecordOptions;
|
|
5
5
|
resolverAddress?: string;
|
|
6
|
-
}): Promise<import("ethers").
|
|
6
|
+
}): Promise<import("ethers").PopulatedTransaction>;
|
|
@@ -17,5 +17,5 @@ export default async function ({ contracts, provider, getResolver, signer, }, na
|
|
|
17
17
|
const resolver = (await contracts?.getPublicResolver(provider, resolverToUse))?.connect(signer);
|
|
18
18
|
const hash = namehash(name);
|
|
19
19
|
const calls = generateRecordCallArray(hash, records, resolver);
|
|
20
|
-
return resolver
|
|
20
|
+
return resolver.populateTransaction.multicall(calls);
|
|
21
21
|
}
|
|
@@ -2,4 +2,4 @@ import { ENSArgs } from '..';
|
|
|
2
2
|
export default function ({ contracts, signer }: ENSArgs<'contracts' | 'signer'>, name: string, { contract, resolver, }: {
|
|
3
3
|
contract: 'registry' | 'nameWrapper';
|
|
4
4
|
resolver?: string;
|
|
5
|
-
}): Promise<import("ethers").
|
|
5
|
+
}): Promise<import("ethers").PopulatedTransaction>;
|
|
@@ -6,11 +6,11 @@ export default async function ({ contracts, signer }, name, { contract, resolver
|
|
|
6
6
|
switch (contract) {
|
|
7
7
|
case 'registry': {
|
|
8
8
|
const registry = (await contracts?.getRegistry()).connect(signer);
|
|
9
|
-
return registry.setResolver(namehash(name), resolver);
|
|
9
|
+
return registry.populateTransaction.setResolver(namehash(name), resolver);
|
|
10
10
|
}
|
|
11
11
|
case 'nameWrapper': {
|
|
12
12
|
const nameWrapper = (await contracts?.getNameWrapper()).connect(signer);
|
|
13
|
-
return nameWrapper.setResolver(namehash(name), resolver);
|
|
13
|
+
return nameWrapper.populateTransaction.setResolver(namehash(name), resolver);
|
|
14
14
|
}
|
|
15
15
|
default: {
|
|
16
16
|
throw new Error(`Unknown contract: ${contract}`);
|
|
@@ -3,4 +3,4 @@ import { ENSArgs } from '..';
|
|
|
3
3
|
export default function ({ contracts, signer }: ENSArgs<'contracts' | 'signer'>, name: string, { newOwner, contract, }: {
|
|
4
4
|
newOwner: string;
|
|
5
5
|
contract: 'registry' | 'nameWrapper' | 'baseRegistrar';
|
|
6
|
-
}): Promise<ethers.
|
|
6
|
+
}): Promise<ethers.PopulatedTransaction>;
|
|
@@ -5,7 +5,7 @@ export default async function ({ contracts, signer }, name, { newOwner, contract
|
|
|
5
5
|
switch (contract) {
|
|
6
6
|
case 'registry': {
|
|
7
7
|
const registry = (await contracts?.getRegistry()).connect(signer);
|
|
8
|
-
return registry.setOwner(namehash(name), newOwner);
|
|
8
|
+
return registry.populateTransaction.setOwner(namehash(name), newOwner);
|
|
9
9
|
}
|
|
10
10
|
case 'baseRegistrar': {
|
|
11
11
|
const baseRegistrar = (await contracts?.getBaseRegistrar()).connect(signer);
|
|
@@ -13,11 +13,11 @@ export default async function ({ contracts, signer }, name, { newOwner, contract
|
|
|
13
13
|
if (labels.length > 2 || labels[labels.length - 1] !== 'eth') {
|
|
14
14
|
throw new Error('Invalid name for baseRegistrar');
|
|
15
15
|
}
|
|
16
|
-
return baseRegistrar['safeTransferFrom(address,address,uint256)'](address, newOwner, ethers.utils.solidityKeccak256(['string'], [labels[0]]));
|
|
16
|
+
return baseRegistrar.populateTransaction['safeTransferFrom(address,address,uint256)'](address, newOwner, ethers.utils.solidityKeccak256(['string'], [labels[0]]));
|
|
17
17
|
}
|
|
18
18
|
case 'nameWrapper': {
|
|
19
19
|
const nameWrapper = (await contracts?.getNameWrapper()).connect(signer);
|
|
20
|
-
return nameWrapper.safeTransferFrom(address, newOwner, namehash(name), 1, '0x');
|
|
20
|
+
return nameWrapper.populateTransaction.safeTransferFrom(address, newOwner, namehash(name), 1, '0x');
|
|
21
21
|
}
|
|
22
22
|
default: {
|
|
23
23
|
throw new Error(`Unknown contract: ${contract}`);
|
|
@@ -3,4 +3,4 @@ import { ENSArgs } from '..';
|
|
|
3
3
|
export default function ({ contracts, signer }: ENSArgs<'contracts' | 'signer'>, name: string, { contract, address, }: {
|
|
4
4
|
contract: 'registry' | 'nameWrapper';
|
|
5
5
|
address: string;
|
|
6
|
-
}): Promise<ethers.
|
|
6
|
+
}): Promise<ethers.PopulatedTransaction>;
|
|
@@ -8,11 +8,11 @@ export default async function ({ contracts, signer }, name, { contract, address,
|
|
|
8
8
|
switch (contract) {
|
|
9
9
|
case 'registry': {
|
|
10
10
|
const registry = (await contracts?.getRegistry()).connect(signer);
|
|
11
|
-
return registry.setSubnodeOwner(parentNodehash, labelhash, address);
|
|
11
|
+
return registry.populateTransaction.setSubnodeOwner(parentNodehash, labelhash, address);
|
|
12
12
|
}
|
|
13
13
|
case 'nameWrapper': {
|
|
14
14
|
const nameWrapper = (await contracts?.getNameWrapper()).connect(signer);
|
|
15
|
-
return nameWrapper.setSubnodeOwner(parentNodehash, label, address, '0');
|
|
15
|
+
return nameWrapper.populateTransaction.setSubnodeOwner(parentNodehash, label, address, '0');
|
|
16
16
|
}
|
|
17
17
|
default: {
|
|
18
18
|
throw new Error(`Unknown contract: ${contract}`);
|
|
@@ -2,4 +2,4 @@ import { ENSArgs } from '..';
|
|
|
2
2
|
export default function ({ contracts, signer }: ENSArgs<'contracts' | 'signer'>, name: string, { newController, newRegistrant, }: {
|
|
3
3
|
newController: string;
|
|
4
4
|
newRegistrant?: string;
|
|
5
|
-
}): Promise<import("ethers").
|
|
5
|
+
}): Promise<import("ethers").PopulatedTransaction>;
|
|
@@ -9,12 +9,12 @@ export default async function ({ contracts, signer }, name, { newController, new
|
|
|
9
9
|
if (!newRegistrant) {
|
|
10
10
|
throw new Error('newRegistrant must be specified for .eth names');
|
|
11
11
|
}
|
|
12
|
-
return nameWrapper.unwrapETH2LD(labelhash, newRegistrant, newController);
|
|
12
|
+
return nameWrapper.populateTransaction.unwrapETH2LD(labelhash, newRegistrant, newController);
|
|
13
13
|
}
|
|
14
14
|
else {
|
|
15
15
|
if (newRegistrant) {
|
|
16
16
|
throw new Error('newRegistrant can only be specified for .eth names');
|
|
17
17
|
}
|
|
18
|
-
return nameWrapper.unwrap(parentNodehash, labelhash, newController);
|
|
18
|
+
return nameWrapper.populateTransaction.unwrap(parentNodehash, labelhash, newController);
|
|
19
19
|
}
|
|
20
20
|
}
|
|
@@ -1,8 +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, signer }: ENSArgs<'contracts' | 'signer'>, name: string, { wrappedOwner, fuseOptions, resolverAddress, }: {
|
|
4
|
+
export default function ({ contracts, signer, populate }: ENSArgs<'contracts' | 'signer' | 'populate'>, name: string, { wrappedOwner, fuseOptions, resolverAddress, }: {
|
|
5
5
|
wrappedOwner: string;
|
|
6
6
|
fuseOptions?: FuseOptions | string | number;
|
|
7
7
|
resolverAddress?: string;
|
|
8
|
-
}): Promise<ethers.
|
|
8
|
+
}): Promise<ethers.PopulatedTransaction>;
|