@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.
Files changed (81) hide show
  1. package/dist/cjs/functions/burnFuses.d.ts +3 -1
  2. package/dist/cjs/functions/burnFuses.js +2 -6
  3. package/dist/cjs/functions/createSubname.d.ts +1 -5
  4. package/dist/cjs/functions/createSubname.js +3 -7
  5. package/dist/cjs/functions/deleteSubname.d.ts +3 -3
  6. package/dist/cjs/functions/deleteSubname.js +5 -2
  7. package/dist/cjs/functions/getDNSOwner.d.ts +1 -1
  8. package/dist/cjs/functions/getDNSOwner.js +1 -1
  9. package/dist/cjs/functions/setName.d.ts +4 -3
  10. package/dist/cjs/functions/setName.js +5 -10
  11. package/dist/cjs/functions/setRecords.d.ts +4 -1
  12. package/dist/cjs/functions/setRecords.js +11 -9
  13. package/dist/cjs/functions/setResolver.d.ts +4 -3
  14. package/dist/cjs/functions/setResolver.js +5 -11
  15. package/dist/cjs/functions/transferName.d.ts +4 -3
  16. package/dist/cjs/functions/transferName.js +8 -13
  17. package/dist/cjs/functions/transferSubname.d.ts +4 -3
  18. package/dist/cjs/functions/transferSubname.js +3 -7
  19. package/dist/cjs/functions/unwrapName.d.ts +4 -3
  20. package/dist/cjs/functions/unwrapName.js +3 -8
  21. package/dist/cjs/functions/wrapName.d.ts +5 -3
  22. package/dist/cjs/functions/wrapName.js +8 -12
  23. package/dist/cjs/index.d.ts +41 -45
  24. package/dist/cjs/index.js +39 -25
  25. package/dist/cjs/utils/writeTx.d.ts +4 -0
  26. package/dist/cjs/utils/writeTx.js +3 -0
  27. package/dist/esm/functions/burnFuses.d.ts +3 -1
  28. package/dist/esm/functions/burnFuses.js +2 -6
  29. package/dist/esm/functions/createSubname.d.ts +1 -5
  30. package/dist/esm/functions/createSubname.js +3 -7
  31. package/dist/esm/functions/deleteSubname.d.ts +3 -3
  32. package/dist/esm/functions/deleteSubname.js +5 -2
  33. package/dist/esm/functions/getDNSOwner.d.ts +1 -1
  34. package/dist/esm/functions/getDNSOwner.js +1 -1
  35. package/dist/esm/functions/setName.d.ts +4 -3
  36. package/dist/esm/functions/setName.js +5 -10
  37. package/dist/esm/functions/setRecords.d.ts +4 -1
  38. package/dist/esm/functions/setRecords.js +11 -9
  39. package/dist/esm/functions/setResolver.d.ts +4 -3
  40. package/dist/esm/functions/setResolver.js +5 -11
  41. package/dist/esm/functions/transferName.d.ts +4 -3
  42. package/dist/esm/functions/transferName.js +8 -13
  43. package/dist/esm/functions/transferSubname.d.ts +4 -3
  44. package/dist/esm/functions/transferSubname.js +3 -7
  45. package/dist/esm/functions/unwrapName.d.ts +4 -3
  46. package/dist/esm/functions/unwrapName.js +3 -8
  47. package/dist/esm/functions/wrapName.d.ts +5 -3
  48. package/dist/esm/functions/wrapName.js +8 -12
  49. package/dist/esm/index.d.ts +41 -45
  50. package/dist/esm/index.js +39 -25
  51. package/dist/esm/utils/writeTx.d.ts +4 -0
  52. package/dist/esm/utils/writeTx.js +1 -0
  53. package/package.json +3 -3
  54. package/src/functions/burnFuses.test.ts +9 -8
  55. package/src/functions/burnFuses.ts +7 -9
  56. package/src/functions/createSubname.test.ts +8 -11
  57. package/src/functions/createSubname.ts +5 -12
  58. package/src/functions/deleteSubname.test.ts +28 -27
  59. package/src/functions/deleteSubname.ts +9 -12
  60. package/src/functions/getDNSOwner.test.ts +2 -2
  61. package/src/functions/getDNSOwner.ts +1 -1
  62. package/src/functions/getFuses.test.ts +11 -9
  63. package/src/functions/getOwner.test.ts +3 -1
  64. package/src/functions/setName.test.ts +3 -2
  65. package/src/functions/setName.ts +15 -17
  66. package/src/functions/setRecords.test.ts +7 -5
  67. package/src/functions/setRecords.ts +19 -13
  68. package/src/functions/setResolver.test.ts +12 -15
  69. package/src/functions/setResolver.ts +14 -19
  70. package/src/functions/transferName.test.ts +27 -29
  71. package/src/functions/transferName.ts +17 -21
  72. package/src/functions/transferSubname.test.ts +30 -29
  73. package/src/functions/transferSubname.ts +19 -12
  74. package/src/functions/unwrapName.test.ts +22 -22
  75. package/src/functions/unwrapName.ts +18 -14
  76. package/src/functions/wrapName.test.ts +15 -12
  77. package/src/functions/wrapName.ts +20 -22
  78. package/src/index.ts +105 -33
  79. package/src/tests/populateTransaction.test.ts +40 -0
  80. package/src/tests/signerInjection.test.ts +46 -0
  81. package/src/utils/writeTx.ts +6 -0
@@ -1,7 +1,18 @@
1
- import { ethers } from 'ethers';
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,6 +21,7 @@ declare type ENSOptions = {
10
21
  export declare type InternalENS = {
11
22
  options?: ENSOptions;
12
23
  provider?: ethers.providers.Provider;
24
+ signer: JsonRpcSigner;
13
25
  graphURI?: string | null;
14
26
  } & ENS;
15
27
  export declare type ENSArgs<K extends keyof InternalENS> = {
@@ -17,6 +29,15 @@ export declare type ENSArgs<K extends keyof InternalENS> = {
17
29
  };
18
30
  declare type OmitFirstArg<F> = F extends (x: any, ...args: infer P) => infer R ? (...args: P) => R : never;
19
31
  declare type OmitFirstTwoArgs<F> = F extends (x: any, y: any, ...args: infer P) => infer R ? (...args: P) => R : never;
32
+ declare type WriteOptions = {
33
+ addressOrIndex?: string | number;
34
+ signer?: JsonRpcSigner;
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
+ }
20
41
  export declare type RawFunction = {
21
42
  raw: (...args: any[]) => Promise<{
22
43
  to: string;
@@ -77,6 +98,14 @@ export declare class ENS {
77
98
  * @returns {OmitFirstArg} - The generated wrapped function
78
99
  */
79
100
  private generateFunction;
101
+ /**
102
+ * Generates a write wrapped function
103
+ * @param {string} path - The path of the exported function
104
+ * @param {FunctionDeps} dependencies - An array of ENS properties
105
+ * @param {string} exportName - The export name of the target function
106
+ * @returns {OmitFirstArg} - The generated wrapped function
107
+ */
108
+ private generateWriteFunction;
80
109
  /**
81
110
  * Generates a wrapped function from raw and decode exports
82
111
  * @param {string} path - The path of the exported function
@@ -423,49 +452,16 @@ export declare class ENS {
423
452
  }>;
424
453
  decode: ({ contracts }: ENSArgs<"contracts">, data: string) => Promise<any>;
425
454
  }>;
426
- setName: (name: string, address?: string | undefined, resolver?: string | undefined, options?: {
427
- addressOrIndex?: string | number | undefined;
428
- } | undefined) => Promise<ethers.ContractTransaction | undefined>;
429
- setRecords: (name: string, records: import("./utils/recordHelpers").RecordOptions) => Promise<ethers.ContractTransaction | undefined>;
430
- setResolver: (name: string, contract: "nameWrapper" | "registry", resolver?: string | undefined, options?: {
431
- addressOrIndex?: string | number | undefined;
432
- } | undefined) => Promise<ethers.ContractTransaction>;
433
- transferName: (name: string, newOwner: string, contract: "nameWrapper" | "registry" | "baseRegistrar", options?: {
434
- addressOrIndex?: string | number | undefined;
435
- } | undefined) => Promise<ethers.ContractTransaction>;
436
- wrapName: (name: string, wrappedOwner: string, fuseOptions?: string | number | import("./@types/FuseOptions").FuseOptions | undefined, resolverAddress?: string | undefined, options?: {
437
- addressOrIndex?: string | number | undefined;
438
- } | undefined) => Promise<ethers.ContractTransaction>;
439
- unwrapName: (name: string, newController: string, newRegistrant?: string | undefined, options?: {
440
- addressOrIndex?: string | number | undefined;
441
- } | undefined) => Promise<ethers.ContractTransaction>;
442
- burnFuses: (name: string, fusesToBurn: import("./@types/FuseOptions").FuseOptions) => Promise<ethers.ContractTransaction>;
443
- createSubname: (args_0: {
444
- name: string;
445
- owner: string;
446
- resolverAddress?: string | undefined;
447
- contract: "nameWrapper" | "registry";
448
- options?: {
449
- addressOrIndex?: string | number | undefined;
450
- } | undefined;
451
- } | ({
452
- contract: "nameWrapper";
453
- fuses?: import("./@types/FuseOptions").FuseOptions | undefined;
454
- } & {
455
- name: string;
456
- owner: string;
457
- resolverAddress?: string | undefined;
458
- contract: "nameWrapper" | "registry";
459
- options?: {
460
- addressOrIndex?: string | number | undefined;
461
- } | undefined;
462
- })) => Promise<ethers.ContractTransaction>;
463
- deleteSubname: (name: string, contract: "nameWrapper" | "registry", options?: {
464
- addressOrIndex?: string | number | undefined;
465
- } | undefined) => Promise<ethers.ContractTransaction>;
466
- transferSubname: (name: string, contract: "nameWrapper" | "registry", address: string, options?: {
467
- addressOrIndex?: string | number | undefined;
468
- } | undefined) => Promise<ethers.ContractTransaction>;
469
- getDNSOwner: () => Promise<any>;
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>;
465
+ getDNSOwner: (dnsName: string) => Promise<any>;
470
466
  }
471
467
  export {};
package/dist/esm/index.js CHANGED
@@ -2,6 +2,7 @@ import ContractManager from './contracts';
2
2
  import { getContractAddress as _getContractAddress } from './contracts/getContractAddress';
3
3
  import GqlManager from './GqlManager';
4
4
  import singleCall from './utils/singleCall';
5
+ import writeTx from './utils/writeTx';
5
6
  const graphURIEndpoints = {
6
7
  1: 'https://api.thegraph.com/subgraphs/name/ensdomains/ens',
7
8
  3: 'https://api.thegraph.com/subgraphs/name/ensdomains/ensropsten',
@@ -57,13 +58,25 @@ export class ENS {
57
58
  // if combine isn't specified, run normally
58
59
  // otherwise, create a function from the raw and decode functions
59
60
  if (subFunc !== 'combine') {
61
+ const writeable = subFunc === 'write' || subFunc === 'populateTransaction';
60
62
  // get the function to call
61
- const func = subFunc ? mod[exportName][subFunc] : mod[exportName];
62
- if (dependencies.length === 0) {
63
- return func(...args);
64
- }
63
+ const func = subFunc && !writeable ? mod[exportName][subFunc] : mod[exportName];
65
64
  // get the dependencies to forward to the function as the first arg
66
- const dependenciesToForward = thisRef.forwardDependenciesFromArray(dependencies);
65
+ let dependenciesToForward = thisRef.forwardDependenciesFromArray(dependencies);
66
+ // if func is write func, inject signer into dependencies
67
+ if (writeable) {
68
+ const options = (args[1] || {});
69
+ const signer = options.signer ||
70
+ thisRef.provider?.getSigner(options.addressOrIndex);
71
+ const populate = subFunc === 'populateTransaction';
72
+ if (!signer) {
73
+ throw new Error('No signer specified');
74
+ }
75
+ delete options.addressOrIndex;
76
+ delete options.signer;
77
+ dependenciesToForward = { ...dependenciesToForward, signer };
78
+ return func(dependenciesToForward, args[0], options).then(writeTx(signer, populate));
79
+ }
67
80
  // return the function with the dependencies forwarded
68
81
  return func(dependenciesToForward, ...args);
69
82
  }
@@ -80,6 +93,9 @@ export class ENS {
80
93
  mainFunc.decode = this.importGenerator(path, dependencies, exportName, 'decode');
81
94
  mainFunc.batch = this.importGenerator(path, dependencies, exportName, 'batch', { raw: mainFunc.raw, decode: mainFunc.decode });
82
95
  }
96
+ else if (subFunc === 'write') {
97
+ mainFunc.populateTransaction = this.importGenerator(path, dependencies, exportName, 'populateTransaction');
98
+ }
83
99
  return mainFunc;
84
100
  };
85
101
  /**
@@ -90,6 +106,14 @@ export class ENS {
90
106
  * @returns {OmitFirstArg} - The generated wrapped function
91
107
  */
92
108
  this.generateFunction = (path, dependencies, exportName = 'default') => this.importGenerator(path, dependencies, exportName);
109
+ /**
110
+ * Generates a write wrapped function
111
+ * @param {string} path - The path of the exported function
112
+ * @param {FunctionDeps} dependencies - An array of ENS properties
113
+ * @param {string} exportName - The export name of the target function
114
+ * @returns {OmitFirstArg} - The generated wrapped function
115
+ */
116
+ this.generateWriteFunction = (path, dependencies, exportName = 'default') => this.importGenerator(path, dependencies, exportName, 'write');
93
117
  /**
94
118
  * Generates a wrapped function from raw and decode exports
95
119
  * @param {string} path - The path of the exported function
@@ -160,32 +184,22 @@ export class ENS {
160
184
  this.universalWrapper = this.generateRawFunction('initialGetters', ['contracts'], 'universalWrapper');
161
185
  this.resolverMulticallWrapper = this.generateRawFunction('initialGetters', ['contracts'], 'resolverMulticallWrapper');
162
186
  this.multicallWrapper = this.generateRawFunction('initialGetters', ['contracts'], 'multicallWrapper');
163
- this.setName = this.generateFunction('setName', [
164
- 'contracts',
165
- 'provider',
166
- ]);
167
- this.setRecords = this.generateFunction('setRecords', [
168
- 'contracts',
169
- 'provider',
170
- 'getResolver',
171
- ]);
172
- this.setResolver = this.generateFunction('setResolver', ['contracts', 'provider']);
173
- this.transferName = this.generateFunction('transferName', ['contracts', 'provider']);
174
- this.wrapName = this.generateFunction('wrapName', [
187
+ this.setName = this.generateWriteFunction('setName', [
175
188
  'contracts',
176
- 'provider',
177
189
  ]);
178
- this.unwrapName = this.generateFunction('unwrapName', [
190
+ this.setRecords = this.generateWriteFunction('setRecords', ['contracts', 'provider', 'getResolver']);
191
+ this.setResolver = this.generateWriteFunction('setResolver', ['contracts']);
192
+ this.transferName = this.generateWriteFunction('transferName', ['contracts']);
193
+ this.wrapName = this.generateWriteFunction('wrapName', [
179
194
  'contracts',
180
- 'provider',
181
195
  ]);
182
- this.burnFuses = this.generateFunction('burnFuses', [
196
+ this.unwrapName = this.generateWriteFunction('unwrapName', ['contracts']);
197
+ this.burnFuses = this.generateWriteFunction('burnFuses', [
183
198
  'contracts',
184
- 'provider',
185
199
  ]);
186
- this.createSubname = this.generateFunction('createSubname', ['contracts', 'provider']);
187
- this.deleteSubname = this.generateFunction('deleteSubname', ['contracts', 'provider', 'transferSubname']);
188
- this.transferSubname = this.generateFunction('transferSubname', ['contracts', 'provider']);
200
+ this.createSubname = this.generateWriteFunction('createSubname', ['contracts']);
201
+ this.deleteSubname = this.generateWriteFunction('deleteSubname', ['transferSubname']);
202
+ this.transferSubname = this.generateWriteFunction('transferSubname', ['contracts']);
189
203
  this.getDNSOwner = this.generateFunction('getDNSOwner', []);
190
204
  this.options = options;
191
205
  this.getContractAddress = options?.getContractAddress || _getContractAddress;
@@ -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;
@@ -0,0 +1 @@
1
+ export default (signer, populate) => (tx) => populate ? tx : signer.sendTransaction(tx);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ensdomains/ensjs",
3
- "version": "3.0.0-alpha.3",
3
+ "version": "3.0.0-alpha.6",
4
4
  "description": "ENS javascript library for contract interaction",
5
5
  "main": "./dist/cjs/index.js",
6
6
  "types": "./dist/cjs/index.d.ts",
@@ -51,7 +51,7 @@
51
51
  },
52
52
  "devDependencies": {
53
53
  "@ensdomains/buffer": "^0.0.13",
54
- "@ensdomains/ens-test-env": "0.1.0",
54
+ "@ensdomains/ens-test-env": "0.1.4",
55
55
  "@ethersproject/abi": "^5.6.0",
56
56
  "@ethersproject/providers": "^5.6.2",
57
57
  "@nomiclabs/hardhat-ethers": "^2.0.5",
@@ -81,5 +81,5 @@
81
81
  "peerDependencies": {
82
82
  "ethers": "*"
83
83
  },
84
- "stableVersion": "3.0.0-alpha.2"
84
+ "stableVersion": "3.0.0-alpha.5"
85
85
  }
@@ -1,7 +1,7 @@
1
1
  import { BigNumber, ethers } from 'ethers'
2
2
  import { ENS } from '..'
3
- import { namehash } from '../utils/normalise'
4
3
  import setup from '../tests/setup'
4
+ import { namehash } from '../utils/normalise'
5
5
 
6
6
  let ENSInstance: ENS
7
7
  let revert: Awaited<ReturnType<typeof setup>>['revert']
@@ -22,16 +22,17 @@ describe('burnFuses', () => {
22
22
  await revert()
23
23
  })
24
24
  it('should return a burnFuses transaction and succeed', async () => {
25
- const wrapNameTx = await ENSInstance.wrapName(
26
- 'parthtejpal.eth',
27
- accounts[0],
28
- )
25
+ const wrapNameTx = await ENSInstance.wrapName('parthtejpal.eth', {
26
+ wrappedOwner: accounts[0],
27
+ })
29
28
  await wrapNameTx.wait()
30
29
 
31
30
  const tx = await ENSInstance.burnFuses('parthtejpal.eth', {
32
- cannotUnwrap: true,
33
- cannotCreateSubdomain: true,
34
- cannotSetTtl: true,
31
+ fusesToBurn: {
32
+ cannotUnwrap: true,
33
+ cannotCreateSubdomain: true,
34
+ cannotSetTtl: true,
35
+ },
35
36
  })
36
37
  expect(tx).toBeTruthy()
37
38
  await tx.wait()
@@ -4,20 +4,18 @@ import generateFuseInput from '../utils/generateFuseInput'
4
4
  import { namehash } from '../utils/normalise'
5
5
 
6
6
  export default async function (
7
- { contracts, provider }: ENSArgs<'contracts' | 'provider'>,
7
+ { contracts, signer }: ENSArgs<'contracts' | 'signer'>,
8
8
  name: string,
9
- fusesToBurn: FuseOptions,
9
+ {
10
+ fusesToBurn,
11
+ }: {
12
+ fusesToBurn: FuseOptions
13
+ },
10
14
  ) {
11
- const signer = provider?.getSigner()
12
-
13
- if (!signer) {
14
- throw new Error('No signer found')
15
- }
16
-
17
15
  const nameWrapper = (await contracts?.getNameWrapper()!).connect(signer)
18
16
  const hash = namehash(name)
19
17
 
20
18
  const encodedFuses = generateFuseInput(fusesToBurn)
21
19
 
22
- return nameWrapper.burnFuses(hash, encodedFuses)
20
+ return nameWrapper.populateTransaction.burnFuses(hash, encodedFuses)
23
21
  }
@@ -1,7 +1,7 @@
1
1
  import { ethers } from 'ethers'
2
2
  import { ENS } from '..'
3
- import { namehash } from '../utils/normalise'
4
3
  import setup from '../tests/setup'
4
+ import { namehash } from '../utils/normalise'
5
5
 
6
6
  let ENSInstance: ENS
7
7
  let revert: Awaited<ReturnType<typeof setup>>['revert']
@@ -23,11 +23,10 @@ describe('createSubname', () => {
23
23
  await revert()
24
24
  })
25
25
  it('should allow creating a subname on the registry', async () => {
26
- const tx = await ENSInstance.createSubname({
26
+ const tx = await ENSInstance.createSubname('test.parthtejpal.eth', {
27
27
  contract: 'registry',
28
- name: 'test.parthtejpal.eth',
29
28
  owner: accounts[0],
30
- options: { addressOrIndex: 0 },
29
+ addressOrIndex: 0,
31
30
  })
32
31
  expect(tx).toBeTruthy()
33
32
  await tx.wait()
@@ -37,16 +36,14 @@ describe('createSubname', () => {
37
36
  expect(result).toBe(accounts[0])
38
37
  })
39
38
  it('should allow creating a subname on the namewrapper', async () => {
40
- const wrapNameTx = await ENSInstance.wrapName(
41
- 'parthtejpal.eth',
42
- accounts[0],
43
- )
39
+ const wrapNameTx = await ENSInstance.wrapName('parthtejpal.eth', {
40
+ wrappedOwner: accounts[0],
41
+ })
44
42
  await wrapNameTx.wait()
45
- const tx = await ENSInstance.createSubname({
43
+ const tx = await ENSInstance.createSubname('test.parthtejpal.eth', {
46
44
  contract: 'nameWrapper',
47
- name: 'test.parthtejpal.eth',
48
45
  owner: accounts[0],
49
- options: { addressOrIndex: 0 },
46
+ addressOrIndex: 0,
50
47
  })
51
48
  expect(tx).toBeTruthy()
52
49
  await tx.wait()
@@ -5,11 +5,9 @@ import generateFuseInput from '../utils/generateFuseInput'
5
5
  import { namehash } from '../utils/normalise'
6
6
 
7
7
  type BaseArgs = {
8
- name: string
9
8
  owner: string
10
9
  resolverAddress?: string
11
10
  contract: 'registry' | 'nameWrapper'
12
- options?: { addressOrIndex?: string | number }
13
11
  }
14
12
 
15
13
  type NameWrapperArgs = {
@@ -20,15 +18,10 @@ type NameWrapperArgs = {
20
18
  type Args = BaseArgs | NameWrapperArgs
21
19
 
22
20
  export default async function (
23
- { contracts, provider }: ENSArgs<'contracts' | 'provider'>,
24
- { name, owner, resolverAddress, contract, options, ...wrapperArgs }: Args,
21
+ { contracts, signer }: ENSArgs<'contracts' | 'signer'>,
22
+ name: string,
23
+ { owner, resolverAddress, contract, ...wrapperArgs }: Args,
25
24
  ) {
26
- const signer = provider?.getSigner(options?.addressOrIndex)
27
-
28
- if (!signer) {
29
- throw new Error('No signer found')
30
- }
31
-
32
25
  const labels = name.split('.')
33
26
 
34
27
  if (labels.length === 1) {
@@ -51,7 +44,7 @@ export default async function (
51
44
  case 'registry': {
52
45
  const registry = (await contracts?.getRegistry()!).connect(signer)
53
46
 
54
- return registry.setSubnodeRecord(
47
+ return registry.populateTransaction.setSubnodeRecord(
55
48
  parentNodehash,
56
49
  labelhash,
57
50
  owner,
@@ -67,7 +60,7 @@ export default async function (
67
60
  ? generateFuseInput(wrapperArgs.fuses)
68
61
  : '0'
69
62
 
70
- return nameWrapper.setSubnodeRecord(
63
+ return nameWrapper.populateTransaction.setSubnodeRecord(
71
64
  parentNodehash,
72
65
  label,
73
66
  owner,
@@ -1,7 +1,7 @@
1
1
  import { ethers } from 'ethers'
2
2
  import { ENS } from '..'
3
- import { namehash } from '../utils/normalise'
4
3
  import setup from '../tests/setup'
4
+ import { namehash } from '../utils/normalise'
5
5
 
6
6
  let ENSInstance: ENS
7
7
  let revert: Awaited<ReturnType<typeof setup>>['revert']
@@ -22,19 +22,20 @@ describe('deleteSubname', () => {
22
22
  await revert()
23
23
  })
24
24
  it('should allow deleting a subname on the registry', async () => {
25
- const createSubnameTx = await ENSInstance.createSubname({
26
- contract: 'registry',
27
- name: 'test.parthtejpal.eth',
28
- owner: accounts[0],
29
- options: { addressOrIndex: 0 },
30
- })
31
- await createSubnameTx.wait()
32
-
33
- const tx = await ENSInstance.deleteSubname(
25
+ const createSubnameTx = await ENSInstance.createSubname(
34
26
  'test.parthtejpal.eth',
35
- 'registry',
36
- { addressOrIndex: 0 },
27
+ {
28
+ contract: 'registry',
29
+ owner: accounts[0],
30
+ addressOrIndex: 0,
31
+ },
37
32
  )
33
+ await createSubnameTx.wait()
34
+
35
+ const tx = await ENSInstance.deleteSubname('test.parthtejpal.eth', {
36
+ contract: 'registry',
37
+ addressOrIndex: 0,
38
+ })
38
39
  expect(tx).toBeTruthy()
39
40
  await tx.wait()
40
41
 
@@ -43,24 +44,24 @@ describe('deleteSubname', () => {
43
44
  expect(result).toBe('0x0000000000000000000000000000000000000000')
44
45
  })
45
46
  it('should allow deleting a subname on the nameWrapper', async () => {
46
- const wrapNameTx = await ENSInstance.wrapName(
47
- 'parthtejpal.eth',
48
- accounts[0],
49
- )
50
- await wrapNameTx.wait()
51
- const createSubnameTx = await ENSInstance.createSubname({
52
- contract: 'nameWrapper',
53
- name: 'test.parthtejpal.eth',
54
- owner: accounts[0],
55
- options: { addressOrIndex: 0 },
47
+ const wrapNameTx = await ENSInstance.wrapName('parthtejpal.eth', {
48
+ wrappedOwner: accounts[0],
56
49
  })
57
- await createSubnameTx.wait()
58
-
59
- const tx = await ENSInstance.deleteSubname(
50
+ await wrapNameTx.wait()
51
+ const createSubnameTx = await ENSInstance.createSubname(
60
52
  'test.parthtejpal.eth',
61
- 'nameWrapper',
62
- { addressOrIndex: 0 },
53
+ {
54
+ contract: 'nameWrapper',
55
+ owner: accounts[0],
56
+ addressOrIndex: 0,
57
+ },
63
58
  )
59
+ await createSubnameTx.wait()
60
+
61
+ const tx = await ENSInstance.deleteSubname('test.parthtejpal.eth', {
62
+ contract: 'nameWrapper',
63
+ addressOrIndex: 0,
64
+ })
64
65
  expect(tx).toBeTruthy()
65
66
  await tx.wait()
66
67
 
@@ -1,19 +1,16 @@
1
1
  import { ENSArgs } from '..'
2
2
 
3
3
  export default async function (
4
- {
5
- contracts,
6
- provider,
7
- transferSubname,
8
- }: ENSArgs<'contracts' | 'provider' | 'transferSubname'>,
4
+ { transferSubname }: ENSArgs<'transferSubname'>,
9
5
  name: string,
10
- contract: 'registry' | 'nameWrapper',
11
- options?: { addressOrIndex?: string | number },
6
+ {
7
+ contract,
8
+ }: {
9
+ contract: 'registry' | 'nameWrapper'
10
+ },
12
11
  ) {
13
- return transferSubname(
14
- name,
12
+ return transferSubname.populateTransaction(name, {
15
13
  contract,
16
- '0x0000000000000000000000000000000000000000',
17
- options,
18
- )
14
+ address: '0x0000000000000000000000000000000000000000',
15
+ })
19
16
  }
@@ -70,7 +70,7 @@ describe('getDNSOwner', () => {
70
70
  '726c2b1d3bab6b74-TPE',
71
71
  ],
72
72
  )
73
- expect(await getDNSOwner(dnsName)).toEqual(
73
+ expect(await getDNSOwner({}, dnsName)).toEqual(
74
74
  '0x983110309620D911731Ac0932219af06091b6744',
75
75
  )
76
76
  })
@@ -114,7 +114,7 @@ describe('getDNSOwner', () => {
114
114
  ],
115
115
  )
116
116
  try {
117
- await getDNSOwner(dnsName)
117
+ await getDNSOwner({}, dnsName)
118
118
  } catch (error) {
119
119
  expect(error.message).toEqual('DNS query failed: NXDOMAIN')
120
120
  }
@@ -54,7 +54,7 @@ export const dnsQuery = async (
54
54
  return response
55
55
  }
56
56
 
57
- export default async function (dnsName: string) {
57
+ export default async function (_: any, dnsName: string) {
58
58
  const result = await dnsQuery('TXT', `_ens.${dnsName}`)
59
59
  const address = result?.answers?.[0]?.data?.[0]?.toString()?.split('=')?.[1]
60
60
  return address
@@ -12,7 +12,9 @@ let withWrappedSnapshot: any
12
12
  beforeAll(async () => {
13
13
  ;({ ENSInstance, revert, provider, createSnapshot } = await setup())
14
14
  accounts = await provider.listAccounts()
15
- const tx = await ENSInstance.wrapName('parthtejpal.eth', accounts[0])
15
+ const tx = await ENSInstance.wrapName('parthtejpal.eth', {
16
+ wrappedOwner: accounts[0],
17
+ })
16
18
  await tx.wait()
17
19
 
18
20
  withWrappedSnapshot = await createSnapshot()
@@ -33,11 +35,10 @@ describe('getFuses', () => {
33
35
  expect(result).toBeUndefined()
34
36
  })
35
37
  it('should return with canDoEverything set to true for a name with no fuses burned', async () => {
36
- const tx = await ENSInstance.createSubname({
38
+ const tx = await ENSInstance.createSubname('test.parthtejpal.eth', {
37
39
  contract: 'nameWrapper',
38
- name: 'test.parthtejpal.eth',
39
40
  owner: accounts[0],
40
- options: { addressOrIndex: 0 },
41
+ addressOrIndex: 0,
41
42
  })
42
43
  await tx.wait()
43
44
 
@@ -56,9 +57,11 @@ describe('getFuses', () => {
56
57
  })
57
58
  it('should return with other correct fuses', async () => {
58
59
  const tx = await ENSInstance.burnFuses('parthtejpal.eth', {
59
- cannotUnwrap: true,
60
- cannotSetTtl: true,
61
- cannotCreateSubdomain: true,
60
+ fusesToBurn: {
61
+ cannotUnwrap: true,
62
+ cannotSetTtl: true,
63
+ cannotCreateSubdomain: true,
64
+ },
62
65
  })
63
66
  await tx.wait()
64
67
  const result = await ENSInstance.getFuses('parthtejpal.eth')
@@ -86,8 +89,7 @@ describe('getFuses', () => {
86
89
  }
87
90
  })
88
91
  it('should return correct vulnerability data for a vulnerable node', async () => {
89
- const tx = await ENSInstance.createSubname({
90
- name: 'test.parthtejpal.eth',
92
+ const tx = await ENSInstance.createSubname('test.parthtejpal.eth', {
91
93
  owner: accounts[0],
92
94
  contract: 'nameWrapper',
93
95
  })
@@ -10,7 +10,9 @@ let accounts: string[]
10
10
  beforeAll(async () => {
11
11
  ;({ ENSInstance, revert, provider } = await setup())
12
12
  accounts = await provider.listAccounts()
13
- const tx = await ENSInstance.wrapName('parthtejpal.eth', accounts[0])
13
+ const tx = await ENSInstance.wrapName('parthtejpal.eth', {
14
+ wrappedOwner: accounts[0],
15
+ })
14
16
  await tx.wait()
15
17
  })
16
18
 
@@ -1,7 +1,7 @@
1
1
  import { ethers } from 'ethers'
2
2
  import { ENS } from '..'
3
- import { hexEncodeName } from '../utils/hexEncodedName'
4
3
  import setup from '../tests/setup'
4
+ import { hexEncodeName } from '../utils/hexEncodedName'
5
5
 
6
6
  let ENSInstance: ENS
7
7
  let revert: Awaited<ReturnType<typeof setup>>['revert']
@@ -43,7 +43,8 @@ describe('setName', () => {
43
43
  )
44
44
  await setApprovedForAllTx?.wait()
45
45
 
46
- const tx = await ENSInstance.setName('fleek.eth', accounts[0], undefined, {
46
+ const tx = await ENSInstance.setName('fleek.eth', {
47
+ address: accounts[0],
47
48
  addressOrIndex: 1,
48
49
  })
49
50
  expect(tx).toBeTruthy()