@ensdomains/ensjs 3.0.0-alpha.3 → 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 +3 -1
- package/dist/cjs/functions/burnFuses.js +2 -6
- package/dist/cjs/functions/createSubname.d.ts +1 -5
- package/dist/cjs/functions/createSubname.js +3 -7
- package/dist/cjs/functions/deleteSubname.d.ts +3 -3
- package/dist/cjs/functions/deleteSubname.js +5 -2
- package/dist/cjs/functions/getDNSOwner.d.ts +1 -1
- package/dist/cjs/functions/getDNSOwner.js +1 -1
- package/dist/cjs/functions/setName.d.ts +4 -3
- package/dist/cjs/functions/setName.js +5 -10
- package/dist/cjs/functions/setRecords.d.ts +4 -1
- package/dist/cjs/functions/setRecords.js +11 -9
- package/dist/cjs/functions/setResolver.d.ts +4 -3
- package/dist/cjs/functions/setResolver.js +5 -11
- package/dist/cjs/functions/transferName.d.ts +4 -3
- package/dist/cjs/functions/transferName.js +8 -13
- package/dist/cjs/functions/transferSubname.d.ts +4 -3
- package/dist/cjs/functions/transferSubname.js +3 -7
- package/dist/cjs/functions/unwrapName.d.ts +4 -3
- package/dist/cjs/functions/unwrapName.js +3 -8
- package/dist/cjs/functions/wrapName.d.ts +5 -3
- package/dist/cjs/functions/wrapName.js +8 -12
- package/dist/cjs/index.d.ts +41 -45
- package/dist/cjs/index.js +39 -25
- package/dist/cjs/utils/writeTx.d.ts +4 -0
- package/dist/cjs/utils/writeTx.js +3 -0
- package/dist/esm/functions/burnFuses.d.ts +3 -1
- package/dist/esm/functions/burnFuses.js +2 -6
- package/dist/esm/functions/createSubname.d.ts +1 -5
- package/dist/esm/functions/createSubname.js +3 -7
- package/dist/esm/functions/deleteSubname.d.ts +3 -3
- package/dist/esm/functions/deleteSubname.js +5 -2
- package/dist/esm/functions/getDNSOwner.d.ts +1 -1
- package/dist/esm/functions/getDNSOwner.js +1 -1
- package/dist/esm/functions/setName.d.ts +4 -3
- package/dist/esm/functions/setName.js +5 -10
- package/dist/esm/functions/setRecords.d.ts +4 -1
- package/dist/esm/functions/setRecords.js +11 -9
- package/dist/esm/functions/setResolver.d.ts +4 -3
- package/dist/esm/functions/setResolver.js +5 -11
- package/dist/esm/functions/transferName.d.ts +4 -3
- package/dist/esm/functions/transferName.js +8 -13
- package/dist/esm/functions/transferSubname.d.ts +4 -3
- package/dist/esm/functions/transferSubname.js +3 -7
- package/dist/esm/functions/unwrapName.d.ts +4 -3
- package/dist/esm/functions/unwrapName.js +3 -8
- package/dist/esm/functions/wrapName.d.ts +5 -3
- package/dist/esm/functions/wrapName.js +8 -12
- package/dist/esm/index.d.ts +41 -45
- package/dist/esm/index.js +39 -25
- 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.test.ts +9 -8
- package/src/functions/burnFuses.ts +7 -9
- package/src/functions/createSubname.test.ts +8 -11
- package/src/functions/createSubname.ts +5 -12
- package/src/functions/deleteSubname.test.ts +28 -27
- package/src/functions/deleteSubname.ts +9 -12
- package/src/functions/getDNSOwner.test.ts +2 -2
- package/src/functions/getDNSOwner.ts +1 -1
- 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 +15 -17
- package/src/functions/setRecords.test.ts +7 -5
- package/src/functions/setRecords.ts +19 -13
- package/src/functions/setResolver.test.ts +12 -15
- package/src/functions/setResolver.ts +14 -19
- package/src/functions/transferName.test.ts +27 -29
- package/src/functions/transferName.ts +17 -21
- package/src/functions/transferSubname.test.ts +30 -29
- package/src/functions/transferSubname.ts +19 -12
- package/src/functions/unwrapName.test.ts +22 -22
- package/src/functions/unwrapName.ts +18 -14
- package/src/functions/wrapName.test.ts +15 -12
- package/src/functions/wrapName.ts +20 -22
- package/src/index.ts +105 -33
- package/src/tests/populateTransaction.test.ts +40 -0
- package/src/tests/signerInjection.test.ts +46 -0
- package/src/utils/writeTx.ts +6 -0
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,13 +95,25 @@ 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 ? mod[exportName][subFunc] : mod[exportName];
|
|
99
|
-
if (dependencies.length === 0) {
|
|
100
|
-
return func(...args);
|
|
101
|
-
}
|
|
100
|
+
const func = subFunc && !writeable ? mod[exportName][subFunc] : mod[exportName];
|
|
102
101
|
// get the dependencies to forward to the function as the first arg
|
|
103
|
-
|
|
102
|
+
let dependenciesToForward = thisRef.forwardDependenciesFromArray(dependencies);
|
|
103
|
+
// if func is write func, inject signer into dependencies
|
|
104
|
+
if (writeable) {
|
|
105
|
+
const options = (args[1] || {});
|
|
106
|
+
const signer = options.signer ||
|
|
107
|
+
thisRef.provider?.getSigner(options.addressOrIndex);
|
|
108
|
+
const populate = subFunc === 'populateTransaction';
|
|
109
|
+
if (!signer) {
|
|
110
|
+
throw new Error('No signer specified');
|
|
111
|
+
}
|
|
112
|
+
delete options.addressOrIndex;
|
|
113
|
+
delete options.signer;
|
|
114
|
+
dependenciesToForward = { ...dependenciesToForward, signer };
|
|
115
|
+
return func(dependenciesToForward, args[0], options).then((0, writeTx_1.default)(signer, populate));
|
|
116
|
+
}
|
|
104
117
|
// return the function with the dependencies forwarded
|
|
105
118
|
return func(dependenciesToForward, ...args);
|
|
106
119
|
}
|
|
@@ -117,6 +130,9 @@ class ENS {
|
|
|
117
130
|
mainFunc.decode = this.importGenerator(path, dependencies, exportName, 'decode');
|
|
118
131
|
mainFunc.batch = this.importGenerator(path, dependencies, exportName, 'batch', { raw: mainFunc.raw, decode: mainFunc.decode });
|
|
119
132
|
}
|
|
133
|
+
else if (subFunc === 'write') {
|
|
134
|
+
mainFunc.populateTransaction = this.importGenerator(path, dependencies, exportName, 'populateTransaction');
|
|
135
|
+
}
|
|
120
136
|
return mainFunc;
|
|
121
137
|
};
|
|
122
138
|
/**
|
|
@@ -127,6 +143,14 @@ class ENS {
|
|
|
127
143
|
* @returns {OmitFirstArg} - The generated wrapped function
|
|
128
144
|
*/
|
|
129
145
|
generateFunction = (path, dependencies, exportName = 'default') => this.importGenerator(path, dependencies, exportName);
|
|
146
|
+
/**
|
|
147
|
+
* Generates a write wrapped function
|
|
148
|
+
* @param {string} path - The path of the exported function
|
|
149
|
+
* @param {FunctionDeps} dependencies - An array of ENS properties
|
|
150
|
+
* @param {string} exportName - The export name of the target function
|
|
151
|
+
* @returns {OmitFirstArg} - The generated wrapped function
|
|
152
|
+
*/
|
|
153
|
+
generateWriteFunction = (path, dependencies, exportName = 'default') => this.importGenerator(path, dependencies, exportName, 'write');
|
|
130
154
|
/**
|
|
131
155
|
* Generates a wrapped function from raw and decode exports
|
|
132
156
|
* @param {string} path - The path of the exported function
|
|
@@ -197,32 +221,22 @@ class ENS {
|
|
|
197
221
|
universalWrapper = this.generateRawFunction('initialGetters', ['contracts'], 'universalWrapper');
|
|
198
222
|
resolverMulticallWrapper = this.generateRawFunction('initialGetters', ['contracts'], 'resolverMulticallWrapper');
|
|
199
223
|
multicallWrapper = this.generateRawFunction('initialGetters', ['contracts'], 'multicallWrapper');
|
|
200
|
-
setName = this.
|
|
201
|
-
'contracts',
|
|
202
|
-
'provider',
|
|
203
|
-
]);
|
|
204
|
-
setRecords = this.generateFunction('setRecords', [
|
|
205
|
-
'contracts',
|
|
206
|
-
'provider',
|
|
207
|
-
'getResolver',
|
|
208
|
-
]);
|
|
209
|
-
setResolver = this.generateFunction('setResolver', ['contracts', 'provider']);
|
|
210
|
-
transferName = this.generateFunction('transferName', ['contracts', 'provider']);
|
|
211
|
-
wrapName = this.generateFunction('wrapName', [
|
|
224
|
+
setName = this.generateWriteFunction('setName', [
|
|
212
225
|
'contracts',
|
|
213
|
-
'provider',
|
|
214
226
|
]);
|
|
215
|
-
|
|
227
|
+
setRecords = this.generateWriteFunction('setRecords', ['contracts', 'provider', 'getResolver']);
|
|
228
|
+
setResolver = this.generateWriteFunction('setResolver', ['contracts']);
|
|
229
|
+
transferName = this.generateWriteFunction('transferName', ['contracts']);
|
|
230
|
+
wrapName = this.generateWriteFunction('wrapName', [
|
|
216
231
|
'contracts',
|
|
217
|
-
'provider',
|
|
218
232
|
]);
|
|
219
|
-
|
|
233
|
+
unwrapName = this.generateWriteFunction('unwrapName', ['contracts']);
|
|
234
|
+
burnFuses = this.generateWriteFunction('burnFuses', [
|
|
220
235
|
'contracts',
|
|
221
|
-
'provider',
|
|
222
236
|
]);
|
|
223
|
-
createSubname = this.
|
|
224
|
-
deleteSubname = this.
|
|
225
|
-
transferSubname = this.
|
|
237
|
+
createSubname = this.generateWriteFunction('createSubname', ['contracts']);
|
|
238
|
+
deleteSubname = this.generateWriteFunction('deleteSubname', ['transferSubname']);
|
|
239
|
+
transferSubname = this.generateWriteFunction('transferSubname', ['contracts']);
|
|
226
240
|
getDNSOwner = this.generateFunction('getDNSOwner', []);
|
|
227
241
|
}
|
|
228
242
|
exports.ENS = ENS;
|
|
@@ -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;
|
|
@@ -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").PopulatedTransaction>;
|
|
@@ -1,12 +1,8 @@
|
|
|
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);
|
|
11
|
-
return nameWrapper.burnFuses(hash, encodedFuses);
|
|
7
|
+
return nameWrapper.populateTransaction.burnFuses(hash, encodedFuses);
|
|
12
8
|
}
|
|
@@ -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.PopulatedTransaction>;
|
|
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');
|
|
@@ -22,14 +18,14 @@ export default async function ({ contracts, provider }, { name, owner, resolverA
|
|
|
22
18
|
switch (contract) {
|
|
23
19
|
case 'registry': {
|
|
24
20
|
const registry = (await contracts?.getRegistry()).connect(signer);
|
|
25
|
-
return registry.setSubnodeRecord(parentNodehash, labelhash, owner, resolverAddress, 0);
|
|
21
|
+
return registry.populateTransaction.setSubnodeRecord(parentNodehash, labelhash, owner, resolverAddress, 0);
|
|
26
22
|
}
|
|
27
23
|
case 'nameWrapper': {
|
|
28
24
|
const nameWrapper = (await contracts?.getNameWrapper()).connect(signer);
|
|
29
25
|
const generatedFuses = 'fuses' in wrapperArgs && wrapperArgs.fuses
|
|
30
26
|
? generateFuseInput(wrapperArgs.fuses)
|
|
31
27
|
: '0';
|
|
32
|
-
return nameWrapper.setSubnodeRecord(parentNodehash, label, owner, resolverAddress, 0, generatedFuses);
|
|
28
|
+
return nameWrapper.populateTransaction.setSubnodeRecord(parentNodehash, label, owner, resolverAddress, 0, generatedFuses);
|
|
33
29
|
}
|
|
34
30
|
default: {
|
|
35
31
|
throw new Error(`Unknown contract: ${contract}`);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { ENSArgs } from '..';
|
|
2
|
-
export default function ({
|
|
3
|
-
|
|
4
|
-
}): Promise<import("ethers").
|
|
2
|
+
export default function ({ transferSubname }: ENSArgs<'transferSubname'>, name: string, { contract, }: {
|
|
3
|
+
contract: 'registry' | 'nameWrapper';
|
|
4
|
+
}): Promise<import("ethers").PopulatedTransaction>;
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
-
export default async function ({
|
|
2
|
-
return transferSubname(name,
|
|
1
|
+
export default async function ({ transferSubname }, name, { contract, }) {
|
|
2
|
+
return transferSubname.populateTransaction(name, {
|
|
3
|
+
contract,
|
|
4
|
+
address: '0x0000000000000000000000000000000000000000',
|
|
5
|
+
});
|
|
3
6
|
}
|
|
@@ -4,4 +4,4 @@ export declare function encodeURLParams(p: {
|
|
|
4
4
|
}): string;
|
|
5
5
|
export declare const getDNS: (q: packet.Packet) => Promise<packet.Packet>;
|
|
6
6
|
export declare const dnsQuery: (qtype: string, qname: string) => Promise<packet.Packet>;
|
|
7
|
-
export default function (dnsName: string): Promise<any>;
|
|
7
|
+
export default function (_: any, dnsName: string): Promise<any>;
|
|
@@ -44,7 +44,7 @@ export const dnsQuery = async (qtype, qname) => {
|
|
|
44
44
|
}
|
|
45
45
|
return response;
|
|
46
46
|
};
|
|
47
|
-
export default async function (dnsName) {
|
|
47
|
+
export default async function (_, dnsName) {
|
|
48
48
|
const result = await dnsQuery('TXT', `_ens.${dnsName}`);
|
|
49
49
|
const address = result?.answers?.[0]?.data?.[0]?.toString()?.split('=')?.[1];
|
|
50
50
|
return address;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { ENSArgs } from '..';
|
|
2
|
-
export default function ({ contracts,
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
export default function ({ contracts, signer }: ENSArgs<'contracts' | 'signer'>, name: string, { address, resolver, }?: {
|
|
3
|
+
address?: string;
|
|
4
|
+
resolver?: string;
|
|
5
|
+
}): Promise<import("ethers").PopulatedTransaction>;
|
|
@@ -1,14 +1,9 @@
|
|
|
1
|
-
export default async function ({ contracts,
|
|
2
|
-
const signerAddress = await
|
|
3
|
-
|
|
4
|
-
.getAddress();
|
|
5
|
-
if (!signerAddress) {
|
|
6
|
-
throw new Error('No signer found');
|
|
7
|
-
}
|
|
8
|
-
const reverseRegistrar = (await contracts?.getReverseRegistrar())?.connect(provider?.getSigner());
|
|
1
|
+
export default async function ({ contracts, signer }, name, { address, resolver, } = {}) {
|
|
2
|
+
const signerAddress = await signer.getAddress();
|
|
3
|
+
const reverseRegistrar = (await contracts?.getReverseRegistrar())?.connect(signer);
|
|
9
4
|
if (address) {
|
|
10
5
|
const publicResolver = await contracts?.getPublicResolver();
|
|
11
|
-
return reverseRegistrar
|
|
6
|
+
return reverseRegistrar.populateTransaction.setNameForAddr(address, signerAddress, resolver || publicResolver.address, name);
|
|
12
7
|
}
|
|
13
|
-
return reverseRegistrar
|
|
8
|
+
return reverseRegistrar.populateTransaction.setName(name);
|
|
14
9
|
}
|
|
@@ -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").PopulatedTransaction>;
|
|
@@ -1,19 +1,21 @@
|
|
|
1
1
|
import { namehash } from '../utils/normalise';
|
|
2
2
|
import { generateRecordCallArray } from '../utils/recordHelpers';
|
|
3
|
-
export default async function ({ contracts, provider, getResolver, }, name, records) {
|
|
3
|
+
export default async function ({ contracts, provider, getResolver, signer, }, name, { records, resolverAddress, }) {
|
|
4
4
|
if (!name.includes('.')) {
|
|
5
5
|
throw new Error('Input is not an ENS name');
|
|
6
6
|
}
|
|
7
|
-
|
|
8
|
-
if (
|
|
9
|
-
|
|
7
|
+
let resolverToUse;
|
|
8
|
+
if (resolverAddress) {
|
|
9
|
+
resolverToUse = resolverAddress;
|
|
10
|
+
}
|
|
11
|
+
else {
|
|
12
|
+
resolverToUse = await getResolver(name);
|
|
10
13
|
}
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
throw new Error('No signer found');
|
|
14
|
+
if (!resolverToUse) {
|
|
15
|
+
throw new Error('No resolver found for input address');
|
|
14
16
|
}
|
|
15
|
-
const resolver = (await contracts?.getPublicResolver(provider,
|
|
17
|
+
const resolver = (await contracts?.getPublicResolver(provider, resolverToUse))?.connect(signer);
|
|
16
18
|
const hash = namehash(name);
|
|
17
19
|
const calls = generateRecordCallArray(hash, records, resolver);
|
|
18
|
-
return resolver
|
|
20
|
+
return resolver.populateTransaction.multicall(calls);
|
|
19
21
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { ENSArgs } from '..';
|
|
2
|
-
export default function ({ contracts,
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
export default function ({ contracts, signer }: ENSArgs<'contracts' | 'signer'>, name: string, { contract, resolver, }: {
|
|
3
|
+
contract: 'registry' | 'nameWrapper';
|
|
4
|
+
resolver?: string;
|
|
5
|
+
}): Promise<import("ethers").PopulatedTransaction>;
|
|
@@ -1,22 +1,16 @@
|
|
|
1
1
|
import { namehash } from '../utils/normalise';
|
|
2
|
-
export default async function ({ contracts,
|
|
3
|
-
const address = await provider
|
|
4
|
-
?.getSigner(options?.addressOrIndex)
|
|
5
|
-
.getAddress();
|
|
6
|
-
if (!address) {
|
|
7
|
-
throw new Error('No signer found');
|
|
8
|
-
}
|
|
2
|
+
export default async function ({ contracts, signer }, name, { contract, resolver, }) {
|
|
9
3
|
if (!resolver) {
|
|
10
4
|
resolver = (await contracts?.getPublicResolver()).address;
|
|
11
5
|
}
|
|
12
6
|
switch (contract) {
|
|
13
7
|
case 'registry': {
|
|
14
|
-
const registry = (await contracts?.getRegistry()).connect(
|
|
15
|
-
return registry.setResolver(namehash(name), resolver);
|
|
8
|
+
const registry = (await contracts?.getRegistry()).connect(signer);
|
|
9
|
+
return registry.populateTransaction.setResolver(namehash(name), resolver);
|
|
16
10
|
}
|
|
17
11
|
case 'nameWrapper': {
|
|
18
|
-
const nameWrapper = (await contracts?.getNameWrapper()).connect(
|
|
19
|
-
return nameWrapper.setResolver(namehash(name), resolver);
|
|
12
|
+
const nameWrapper = (await contracts?.getNameWrapper()).connect(signer);
|
|
13
|
+
return nameWrapper.populateTransaction.setResolver(namehash(name), resolver);
|
|
20
14
|
}
|
|
21
15
|
default: {
|
|
22
16
|
throw new Error(`Unknown contract: ${contract}`);
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { ethers } from 'ethers';
|
|
2
2
|
import { ENSArgs } from '..';
|
|
3
|
-
export default function ({ contracts,
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
export default function ({ contracts, signer }: ENSArgs<'contracts' | 'signer'>, name: string, { newOwner, contract, }: {
|
|
4
|
+
newOwner: string;
|
|
5
|
+
contract: 'registry' | 'nameWrapper' | 'baseRegistrar';
|
|
6
|
+
}): Promise<ethers.PopulatedTransaction>;
|
|
@@ -1,28 +1,23 @@
|
|
|
1
1
|
import { ethers } from 'ethers';
|
|
2
2
|
import { namehash } from '../utils/normalise';
|
|
3
|
-
export default async function ({ contracts,
|
|
4
|
-
const address = await
|
|
5
|
-
?.getSigner(options?.addressOrIndex)
|
|
6
|
-
.getAddress();
|
|
7
|
-
if (!address) {
|
|
8
|
-
throw new Error('No signer found');
|
|
9
|
-
}
|
|
3
|
+
export default async function ({ contracts, signer }, name, { newOwner, contract, }) {
|
|
4
|
+
const address = await signer.getAddress();
|
|
10
5
|
switch (contract) {
|
|
11
6
|
case 'registry': {
|
|
12
|
-
const registry = (await contracts?.getRegistry()).connect(
|
|
13
|
-
return registry.setOwner(namehash(name), newOwner);
|
|
7
|
+
const registry = (await contracts?.getRegistry()).connect(signer);
|
|
8
|
+
return registry.populateTransaction.setOwner(namehash(name), newOwner);
|
|
14
9
|
}
|
|
15
10
|
case 'baseRegistrar': {
|
|
16
|
-
const baseRegistrar = (await contracts?.getBaseRegistrar()).connect(
|
|
11
|
+
const baseRegistrar = (await contracts?.getBaseRegistrar()).connect(signer);
|
|
17
12
|
const labels = name.split('.');
|
|
18
13
|
if (labels.length > 2 || labels[labels.length - 1] !== 'eth') {
|
|
19
14
|
throw new Error('Invalid name for baseRegistrar');
|
|
20
15
|
}
|
|
21
|
-
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]]));
|
|
22
17
|
}
|
|
23
18
|
case 'nameWrapper': {
|
|
24
|
-
const nameWrapper = (await contracts?.getNameWrapper()).connect(
|
|
25
|
-
return nameWrapper.safeTransferFrom(address, newOwner, namehash(name), 1, '0x');
|
|
19
|
+
const nameWrapper = (await contracts?.getNameWrapper()).connect(signer);
|
|
20
|
+
return nameWrapper.populateTransaction.safeTransferFrom(address, newOwner, namehash(name), 1, '0x');
|
|
26
21
|
}
|
|
27
22
|
default: {
|
|
28
23
|
throw new Error(`Unknown contract: ${contract}`);
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { ethers } from 'ethers';
|
|
2
2
|
import { ENSArgs } from '..';
|
|
3
|
-
export default function ({ contracts,
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
export default function ({ contracts, signer }: ENSArgs<'contracts' | 'signer'>, name: string, { contract, address, }: {
|
|
4
|
+
contract: 'registry' | 'nameWrapper';
|
|
5
|
+
address: string;
|
|
6
|
+
}): Promise<ethers.PopulatedTransaction>;
|
|
@@ -1,10 +1,6 @@
|
|
|
1
1
|
import { ethers } from 'ethers';
|
|
2
2
|
import { namehash } from '../utils/normalise';
|
|
3
|
-
export default async function ({ contracts,
|
|
4
|
-
const signer = provider?.getSigner(options?.addressOrIndex);
|
|
5
|
-
if (!signer) {
|
|
6
|
-
throw new Error('No signer found');
|
|
7
|
-
}
|
|
3
|
+
export default async function ({ contracts, signer }, name, { contract, address, }) {
|
|
8
4
|
const labels = name.split('.');
|
|
9
5
|
const label = labels.shift();
|
|
10
6
|
const labelhash = ethers.utils.solidityKeccak256(['string'], [label]);
|
|
@@ -12,11 +8,11 @@ export default async function ({ contracts, provider }, name, contract, address,
|
|
|
12
8
|
switch (contract) {
|
|
13
9
|
case 'registry': {
|
|
14
10
|
const registry = (await contracts?.getRegistry()).connect(signer);
|
|
15
|
-
return registry.setSubnodeOwner(parentNodehash, labelhash, address);
|
|
11
|
+
return registry.populateTransaction.setSubnodeOwner(parentNodehash, labelhash, address);
|
|
16
12
|
}
|
|
17
13
|
case 'nameWrapper': {
|
|
18
14
|
const nameWrapper = (await contracts?.getNameWrapper()).connect(signer);
|
|
19
|
-
return nameWrapper.setSubnodeOwner(parentNodehash, label, address, '0');
|
|
15
|
+
return nameWrapper.populateTransaction.setSubnodeOwner(parentNodehash, label, address, '0');
|
|
20
16
|
}
|
|
21
17
|
default: {
|
|
22
18
|
throw new Error(`Unknown contract: ${contract}`);
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { ENSArgs } from '..';
|
|
2
|
-
export default function ({ contracts,
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
export default function ({ contracts, signer }: ENSArgs<'contracts' | 'signer'>, name: string, { newController, newRegistrant, }: {
|
|
3
|
+
newController: string;
|
|
4
|
+
newRegistrant?: string;
|
|
5
|
+
}): Promise<import("ethers").PopulatedTransaction>;
|
|
@@ -1,11 +1,6 @@
|
|
|
1
1
|
import { utils } from 'ethers';
|
|
2
2
|
import { namehash } from '../utils/normalise';
|
|
3
|
-
export default async function ({ contracts,
|
|
4
|
-
const signer = provider?.getSigner(options?.addressOrIndex);
|
|
5
|
-
const address = await signer?.getAddress();
|
|
6
|
-
if (!signer || !address) {
|
|
7
|
-
throw new Error('No signer found');
|
|
8
|
-
}
|
|
3
|
+
export default async function ({ contracts, signer }, name, { newController, newRegistrant, }) {
|
|
9
4
|
const labels = name.split('.');
|
|
10
5
|
const labelhash = utils.solidityKeccak256(['string'], [labels[0]]);
|
|
11
6
|
const parentNodehash = namehash(labels.slice(1).join('.'));
|
|
@@ -14,12 +9,12 @@ export default async function ({ contracts, provider }, name, newController, new
|
|
|
14
9
|
if (!newRegistrant) {
|
|
15
10
|
throw new Error('newRegistrant must be specified for .eth names');
|
|
16
11
|
}
|
|
17
|
-
return nameWrapper.unwrapETH2LD(labelhash, newRegistrant, newController);
|
|
12
|
+
return nameWrapper.populateTransaction.unwrapETH2LD(labelhash, newRegistrant, newController);
|
|
18
13
|
}
|
|
19
14
|
else {
|
|
20
15
|
if (newRegistrant) {
|
|
21
16
|
throw new Error('newRegistrant can only be specified for .eth names');
|
|
22
17
|
}
|
|
23
|
-
return nameWrapper.unwrap(parentNodehash, labelhash, newController);
|
|
18
|
+
return nameWrapper.populateTransaction.unwrap(parentNodehash, labelhash, newController);
|
|
24
19
|
}
|
|
25
20
|
}
|
|
@@ -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
|
-
|
|
6
|
-
|
|
4
|
+
export default function ({ contracts, signer, populate }: ENSArgs<'contracts' | 'signer' | 'populate'>, name: string, { wrappedOwner, fuseOptions, resolverAddress, }: {
|
|
5
|
+
wrappedOwner: string;
|
|
6
|
+
fuseOptions?: FuseOptions | string | number;
|
|
7
|
+
resolverAddress?: string;
|
|
8
|
+
}): Promise<ethers.PopulatedTransaction>;
|
|
@@ -5,24 +5,20 @@ async function wrapETH({ contracts }, labels, wrappedOwner, decodedFuses, resolv
|
|
|
5
5
|
const nameWrapper = await contracts?.getNameWrapper();
|
|
6
6
|
const baseRegistrar = (await contracts?.getBaseRegistrar()).connect(signer);
|
|
7
7
|
const labelhash = ethers.utils.solidityKeccak256(['string'], [labels[0]]);
|
|
8
|
-
const data = ethers.utils.defaultAbiCoder.encode(['string', 'address', '
|
|
9
|
-
return baseRegistrar['safeTransferFrom(address,address,uint256,bytes)'](address, nameWrapper.address, labelhash, data);
|
|
8
|
+
const data = ethers.utils.defaultAbiCoder.encode(['string', 'address', 'uint32', 'uint64', 'address'], [labels[0], wrappedOwner, '0x0', decodedFuses, resolverAddress]);
|
|
9
|
+
return baseRegistrar.populateTransaction['safeTransferFrom(address,address,uint256,bytes)'](address, nameWrapper.address, labelhash, data);
|
|
10
10
|
}
|
|
11
|
-
async function wrapOther({ contracts }, name, wrappedOwner, decodedFuses, resolverAddress, address) {
|
|
12
|
-
const nameWrapper = await contracts?.getNameWrapper();
|
|
11
|
+
async function wrapOther({ contracts }, name, wrappedOwner, decodedFuses, resolverAddress, address, signer) {
|
|
12
|
+
const nameWrapper = (await contracts?.getNameWrapper()).connect(signer);
|
|
13
13
|
const registry = await contracts?.getRegistry();
|
|
14
14
|
const hasApproval = await registry.isApprovedForAll(address, nameWrapper.address);
|
|
15
15
|
if (!hasApproval) {
|
|
16
16
|
throw new Error('NameWrapper must have approval to wrap a name from this address.');
|
|
17
17
|
}
|
|
18
|
-
return nameWrapper.wrap(hexEncodeName(name), wrappedOwner, decodedFuses, resolverAddress);
|
|
18
|
+
return nameWrapper.populateTransaction.wrap(hexEncodeName(name), wrappedOwner, decodedFuses, resolverAddress);
|
|
19
19
|
}
|
|
20
|
-
export default async function ({ contracts,
|
|
21
|
-
const
|
|
22
|
-
const address = await signer?.getAddress();
|
|
23
|
-
if (!signer || !address) {
|
|
24
|
-
throw new Error('No signer found');
|
|
25
|
-
}
|
|
20
|
+
export default async function ({ contracts, signer, populate }, name, { wrappedOwner, fuseOptions, resolverAddress, }) {
|
|
21
|
+
const address = await signer.getAddress();
|
|
26
22
|
let decodedFuses;
|
|
27
23
|
switch (typeof fuseOptions) {
|
|
28
24
|
case 'object': {
|
|
@@ -53,6 +49,6 @@ export default async function ({ contracts, provider }, name, wrappedOwner, fuse
|
|
|
53
49
|
return wrapETH({ contracts }, labels, wrappedOwner, decodedFuses, resolverAddress, signer, address);
|
|
54
50
|
}
|
|
55
51
|
else {
|
|
56
|
-
return wrapOther({ contracts }, name, wrappedOwner, decodedFuses, resolverAddress, address);
|
|
52
|
+
return wrapOther({ contracts }, name, wrappedOwner, decodedFuses, resolverAddress, address, signer);
|
|
57
53
|
}
|
|
58
54
|
}
|