@ensdomains/ensjs 3.0.0-alpha.4 → 3.0.0-alpha.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/functions/burnFuses.d.ts +3 -1
- package/dist/cjs/functions/burnFuses.js +1 -5
- package/dist/cjs/functions/createSubname.d.ts +1 -5
- package/dist/cjs/functions/createSubname.js +1 -5
- package/dist/cjs/functions/deleteSubname.d.ts +2 -2
- package/dist/cjs/functions/deleteSubname.js +5 -2
- package/dist/cjs/functions/setName.d.ts +3 -2
- package/dist/cjs/functions/setName.js +3 -8
- package/dist/cjs/functions/setRecords.d.ts +4 -1
- package/dist/cjs/functions/setRecords.js +10 -8
- package/dist/cjs/functions/setResolver.d.ts +3 -2
- package/dist/cjs/functions/setResolver.js +3 -9
- package/dist/cjs/functions/transferName.d.ts +3 -2
- package/dist/cjs/functions/transferName.js +5 -10
- package/dist/cjs/functions/transferSubname.d.ts +3 -2
- package/dist/cjs/functions/transferSubname.js +1 -5
- package/dist/cjs/functions/unwrapName.d.ts +3 -2
- package/dist/cjs/functions/unwrapName.js +1 -6
- package/dist/cjs/functions/wrapName.d.ts +4 -2
- package/dist/cjs/functions/wrapName.js +6 -10
- package/dist/cjs/index.d.ts +51 -34
- package/dist/cjs/index.js +35 -22
- package/dist/esm/functions/burnFuses.d.ts +3 -1
- package/dist/esm/functions/burnFuses.js +1 -5
- package/dist/esm/functions/createSubname.d.ts +1 -5
- package/dist/esm/functions/createSubname.js +1 -5
- package/dist/esm/functions/deleteSubname.d.ts +2 -2
- package/dist/esm/functions/deleteSubname.js +5 -2
- package/dist/esm/functions/setName.d.ts +3 -2
- package/dist/esm/functions/setName.js +3 -8
- package/dist/esm/functions/setRecords.d.ts +4 -1
- package/dist/esm/functions/setRecords.js +10 -8
- package/dist/esm/functions/setResolver.d.ts +3 -2
- package/dist/esm/functions/setResolver.js +3 -9
- package/dist/esm/functions/transferName.d.ts +3 -2
- package/dist/esm/functions/transferName.js +5 -10
- package/dist/esm/functions/transferSubname.d.ts +3 -2
- package/dist/esm/functions/transferSubname.js +1 -5
- package/dist/esm/functions/unwrapName.d.ts +3 -2
- package/dist/esm/functions/unwrapName.js +1 -6
- package/dist/esm/functions/wrapName.d.ts +4 -2
- package/dist/esm/functions/wrapName.js +6 -10
- package/dist/esm/index.d.ts +51 -34
- package/dist/esm/index.js +35 -22
- package/package.json +3 -3
- package/src/functions/burnFuses.test.ts +9 -8
- package/src/functions/burnFuses.ts +6 -8
- package/src/functions/createSubname.test.ts +8 -11
- package/src/functions/createSubname.ts +3 -10
- package/src/functions/deleteSubname.test.ts +28 -27
- package/src/functions/deleteSubname.ts +9 -12
- package/src/functions/getFuses.test.ts +11 -9
- package/src/functions/getOwner.test.ts +3 -1
- package/src/functions/setName.test.ts +3 -2
- package/src/functions/setName.ts +10 -12
- package/src/functions/setRecords.test.ts +7 -5
- package/src/functions/setRecords.ts +18 -12
- package/src/functions/setResolver.test.ts +12 -15
- package/src/functions/setResolver.ts +10 -18
- package/src/functions/transferName.test.ts +27 -29
- package/src/functions/transferName.ts +12 -18
- package/src/functions/transferSubname.test.ts +30 -29
- package/src/functions/transferSubname.ts +8 -10
- package/src/functions/unwrapName.test.ts +22 -22
- package/src/functions/unwrapName.ts +8 -12
- package/src/functions/wrapName.test.ts +15 -12
- package/src/functions/wrapName.ts +16 -15
- package/src/index.ts +80 -30
- package/src/tests/signerInjection.test.ts +42 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ethers, utils } 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,17 +22,15 @@ describe('unwrapName', () => {
|
|
|
22
22
|
await revert()
|
|
23
23
|
})
|
|
24
24
|
it('should return a .eth unwrap name transaction and succeed', async () => {
|
|
25
|
-
const wrapNameTx = await ENSInstance.wrapName(
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
)
|
|
25
|
+
const wrapNameTx = await ENSInstance.wrapName('parthtejpal.eth', {
|
|
26
|
+
wrappedOwner: accounts[0],
|
|
27
|
+
})
|
|
29
28
|
await wrapNameTx.wait()
|
|
30
29
|
|
|
31
|
-
const tx = await ENSInstance.unwrapName(
|
|
32
|
-
|
|
33
|
-
accounts[0],
|
|
34
|
-
|
|
35
|
-
)
|
|
30
|
+
const tx = await ENSInstance.unwrapName('parthtejpal.eth', {
|
|
31
|
+
newController: accounts[0],
|
|
32
|
+
newRegistrant: accounts[0],
|
|
33
|
+
})
|
|
36
34
|
expect(tx).toBeTruthy()
|
|
37
35
|
await tx.wait()
|
|
38
36
|
|
|
@@ -43,21 +41,23 @@ describe('unwrapName', () => {
|
|
|
43
41
|
expect(result).toBe(accounts[0])
|
|
44
42
|
})
|
|
45
43
|
it('should return a regular unwrap name transaction and succeed', async () => {
|
|
46
|
-
const wrapNameTx = await ENSInstance.wrapName(
|
|
47
|
-
|
|
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
|
-
shouldWrap: true,
|
|
56
|
-
options: { addressOrIndex: 0 },
|
|
44
|
+
const wrapNameTx = await ENSInstance.wrapName('parthtejpal.eth', {
|
|
45
|
+
wrappedOwner: accounts[0],
|
|
57
46
|
})
|
|
47
|
+
await wrapNameTx.wait()
|
|
48
|
+
const createSubnameTx = await ENSInstance.createSubname(
|
|
49
|
+
'test.parthtejpal.eth',
|
|
50
|
+
{
|
|
51
|
+
contract: 'nameWrapper',
|
|
52
|
+
owner: accounts[0],
|
|
53
|
+
addressOrIndex: 0,
|
|
54
|
+
},
|
|
55
|
+
)
|
|
58
56
|
await createSubnameTx.wait()
|
|
59
57
|
|
|
60
|
-
const tx = await ENSInstance.unwrapName('test.parthtejpal.eth',
|
|
58
|
+
const tx = await ENSInstance.unwrapName('test.parthtejpal.eth', {
|
|
59
|
+
newController: accounts[0],
|
|
60
|
+
})
|
|
61
61
|
expect(tx).toBeTruthy()
|
|
62
62
|
await tx.wait()
|
|
63
63
|
|
|
@@ -3,20 +3,16 @@ import { ENSArgs } from '..'
|
|
|
3
3
|
import { namehash } from '../utils/normalise'
|
|
4
4
|
|
|
5
5
|
export default async function (
|
|
6
|
-
{ contracts,
|
|
6
|
+
{ contracts, signer }: ENSArgs<'contracts' | 'signer'>,
|
|
7
7
|
name: string,
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
8
|
+
{
|
|
9
|
+
newController,
|
|
10
|
+
newRegistrant,
|
|
11
|
+
}: {
|
|
12
|
+
newController: string
|
|
13
|
+
newRegistrant?: string
|
|
14
|
+
},
|
|
11
15
|
) {
|
|
12
|
-
const signer = provider?.getSigner(options?.addressOrIndex)
|
|
13
|
-
|
|
14
|
-
const address = await signer?.getAddress()
|
|
15
|
-
|
|
16
|
-
if (!signer || !address) {
|
|
17
|
-
throw new Error('No signer found')
|
|
18
|
-
}
|
|
19
|
-
|
|
20
16
|
const labels = name.split('.')
|
|
21
17
|
const labelhash = utils.solidityKeccak256(['string'], [labels[0]])
|
|
22
18
|
const parentNodehash = namehash(labels.slice(1).join('.'))
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { BigNumber, ethers } from 'ethers'
|
|
2
2
|
import { ENS } from '..'
|
|
3
|
+
import setup from '../tests/setup'
|
|
3
4
|
import { hexEncodeName } from '../utils/hexEncodedName'
|
|
4
5
|
import { namehash } from '../utils/normalise'
|
|
5
|
-
import setup from '../tests/setup'
|
|
6
6
|
|
|
7
7
|
let ENSInstance: ENS
|
|
8
8
|
let revert: Awaited<ReturnType<typeof setup>>['revert']
|
|
@@ -24,7 +24,9 @@ describe('wrapName', () => {
|
|
|
24
24
|
await revert()
|
|
25
25
|
})
|
|
26
26
|
it('should return a wrap name transaction and succeed', async () => {
|
|
27
|
-
const tx = await ENSInstance.wrapName('parthtejpal.eth',
|
|
27
|
+
const tx = await ENSInstance.wrapName('parthtejpal.eth', {
|
|
28
|
+
wrappedOwner: accounts[0],
|
|
29
|
+
})
|
|
28
30
|
expect(tx).toBeTruthy()
|
|
29
31
|
await tx.wait()
|
|
30
32
|
|
|
@@ -33,24 +35,25 @@ describe('wrapName', () => {
|
|
|
33
35
|
expect((result as BigNumber).toHexString()).toBe('0x40')
|
|
34
36
|
})
|
|
35
37
|
it('should allow initial fuses', async () => {
|
|
36
|
-
const tx = await ENSInstance.wrapName('parthtejpal.eth',
|
|
37
|
-
|
|
38
|
-
|
|
38
|
+
const tx = await ENSInstance.wrapName('parthtejpal.eth', {
|
|
39
|
+
wrappedOwner: accounts[0],
|
|
40
|
+
fuseOptions: {
|
|
41
|
+
cannotUnwrap: true,
|
|
42
|
+
cannotSetTtl: true,
|
|
43
|
+
},
|
|
39
44
|
})
|
|
40
45
|
expect(tx).toBeTruthy()
|
|
41
46
|
await tx.wait()
|
|
42
47
|
|
|
43
48
|
const nameWrapper = await ENSInstance.contracts!.getNameWrapper()!
|
|
44
49
|
const [result] = await nameWrapper.getFuses(namehash('parthtejpal.eth'))
|
|
45
|
-
expect((result as BigNumber).toHexString()).toBe('
|
|
50
|
+
expect((result as BigNumber).toHexString()).toBe('0x40')
|
|
46
51
|
})
|
|
47
52
|
it('should allow an initial resolver address', async () => {
|
|
48
|
-
const tx = await ENSInstance.wrapName(
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
'0x42D63ae25990889E35F215bC95884039Ba354115',
|
|
53
|
-
)
|
|
53
|
+
const tx = await ENSInstance.wrapName('parthtejpal.eth', {
|
|
54
|
+
wrappedOwner: accounts[0],
|
|
55
|
+
resolverAddress: '0x42D63ae25990889E35F215bC95884039Ba354115',
|
|
56
|
+
})
|
|
54
57
|
expect(tx).toBeTruthy()
|
|
55
58
|
await tx.wait()
|
|
56
59
|
|
|
@@ -19,8 +19,8 @@ async function wrapETH(
|
|
|
19
19
|
const labelhash = ethers.utils.solidityKeccak256(['string'], [labels[0]])
|
|
20
20
|
|
|
21
21
|
const data = ethers.utils.defaultAbiCoder.encode(
|
|
22
|
-
['string', 'address', '
|
|
23
|
-
[labels[0], wrappedOwner, decodedFuses, resolverAddress],
|
|
22
|
+
['string', 'address', 'uint32', 'uint64', 'address'],
|
|
23
|
+
[labels[0], wrappedOwner, '0x0', decodedFuses, resolverAddress],
|
|
24
24
|
)
|
|
25
25
|
|
|
26
26
|
return baseRegistrar['safeTransferFrom(address,address,uint256,bytes)'](
|
|
@@ -38,8 +38,9 @@ async function wrapOther(
|
|
|
38
38
|
decodedFuses: string,
|
|
39
39
|
resolverAddress: string,
|
|
40
40
|
address: string,
|
|
41
|
+
signer: ethers.Signer,
|
|
41
42
|
) {
|
|
42
|
-
const nameWrapper = await contracts?.getNameWrapper()!
|
|
43
|
+
const nameWrapper = (await contracts?.getNameWrapper()!).connect(signer)
|
|
43
44
|
const registry = await contracts?.getRegistry()!
|
|
44
45
|
|
|
45
46
|
const hasApproval = await registry.isApprovedForAll(
|
|
@@ -62,20 +63,19 @@ async function wrapOther(
|
|
|
62
63
|
}
|
|
63
64
|
|
|
64
65
|
export default async function (
|
|
65
|
-
{ contracts,
|
|
66
|
+
{ contracts, signer }: ENSArgs<'contracts' | 'signer'>,
|
|
66
67
|
name: string,
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
68
|
+
{
|
|
69
|
+
wrappedOwner,
|
|
70
|
+
fuseOptions,
|
|
71
|
+
resolverAddress,
|
|
72
|
+
}: {
|
|
73
|
+
wrappedOwner: string
|
|
74
|
+
fuseOptions?: FuseOptions | string | number
|
|
75
|
+
resolverAddress?: string
|
|
76
|
+
},
|
|
71
77
|
) {
|
|
72
|
-
const
|
|
73
|
-
|
|
74
|
-
const address = await signer?.getAddress()
|
|
75
|
-
|
|
76
|
-
if (!signer || !address) {
|
|
77
|
-
throw new Error('No signer found')
|
|
78
|
-
}
|
|
78
|
+
const address = await signer.getAddress()
|
|
79
79
|
|
|
80
80
|
let decodedFuses: string
|
|
81
81
|
|
|
@@ -123,6 +123,7 @@ export default async function (
|
|
|
123
123
|
decodedFuses,
|
|
124
124
|
resolverAddress,
|
|
125
125
|
address,
|
|
126
|
+
signer,
|
|
126
127
|
)
|
|
127
128
|
}
|
|
128
129
|
}
|
package/src/index.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ethers } from 'ethers'
|
|
1
|
+
import { ethers, Signer } from 'ethers'
|
|
2
2
|
import ContractManager from './contracts'
|
|
3
3
|
import { getContractAddress as _getContractAddress } from './contracts/getContractAddress'
|
|
4
4
|
import { SupportedNetworkId } from './contracts/types'
|
|
@@ -11,6 +11,7 @@ import type {
|
|
|
11
11
|
import type burnFuses from './functions/burnFuses'
|
|
12
12
|
import type createSubname from './functions/createSubname'
|
|
13
13
|
import type deleteSubname from './functions/deleteSubname'
|
|
14
|
+
import type getDNSOwner from './functions/getDNSOwner'
|
|
14
15
|
import type getExpiry from './functions/getExpiry'
|
|
15
16
|
import type getFuses from './functions/getFuses'
|
|
16
17
|
import type {
|
|
@@ -41,7 +42,6 @@ import type transferName from './functions/transferName'
|
|
|
41
42
|
import type transferSubname from './functions/transferSubname'
|
|
42
43
|
import type unwrapName from './functions/unwrapName'
|
|
43
44
|
import type wrapName from './functions/wrapName'
|
|
44
|
-
import type getDNSOwner from './functions/getDNSOwner'
|
|
45
45
|
import GqlManager from './GqlManager'
|
|
46
46
|
import singleCall from './utils/singleCall'
|
|
47
47
|
|
|
@@ -53,6 +53,7 @@ type ENSOptions = {
|
|
|
53
53
|
export type InternalENS = {
|
|
54
54
|
options?: ENSOptions
|
|
55
55
|
provider?: ethers.providers.Provider
|
|
56
|
+
signer: Signer
|
|
56
57
|
graphURI?: string | null
|
|
57
58
|
} & ENS
|
|
58
59
|
|
|
@@ -76,6 +77,21 @@ type FirstArg<F> = F extends (x: infer A, ...args: any[]) => any ? A : never
|
|
|
76
77
|
|
|
77
78
|
type FunctionDeps<F> = Extract<keyof FirstArg<F>, string>[]
|
|
78
79
|
|
|
80
|
+
type WriteOptions = {
|
|
81
|
+
addressOrIndex?: string | number
|
|
82
|
+
signer?: Signer
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
type WriteFunction<F> = F extends (
|
|
86
|
+
x: any,
|
|
87
|
+
arg_0: infer Z,
|
|
88
|
+
options?: infer P,
|
|
89
|
+
) => infer R
|
|
90
|
+
? (name: Z, options?: P & WriteOptions) => R
|
|
91
|
+
: F extends (x: any, arg_0: infer Z, options: infer P) => infer R
|
|
92
|
+
? (name: Z, options: P & WriteOptions) => R
|
|
93
|
+
: never
|
|
94
|
+
|
|
79
95
|
const graphURIEndpoints: Record<string, string> = {
|
|
80
96
|
1: 'https://api.thegraph.com/subgraphs/name/ensdomains/ens',
|
|
81
97
|
3: 'https://api.thegraph.com/subgraphs/name/ensdomains/ensropsten',
|
|
@@ -172,7 +188,7 @@ export class ENS {
|
|
|
172
188
|
path: string,
|
|
173
189
|
dependencies: FunctionDeps<F>,
|
|
174
190
|
exportName: string = 'default',
|
|
175
|
-
subFunc?: 'raw' | 'decode' | 'combine' | 'batch',
|
|
191
|
+
subFunc?: 'raw' | 'decode' | 'combine' | 'batch' | 'write',
|
|
176
192
|
passthrough?: RawFunction,
|
|
177
193
|
): Function => {
|
|
178
194
|
// if batch is specified, create batch func
|
|
@@ -194,10 +210,29 @@ export class ENS {
|
|
|
194
210
|
// otherwise, create a function from the raw and decode functions
|
|
195
211
|
if (subFunc !== 'combine') {
|
|
196
212
|
// get the function to call
|
|
197
|
-
const func =
|
|
213
|
+
const func =
|
|
214
|
+
subFunc && subFunc !== 'write'
|
|
215
|
+
? mod[exportName][subFunc]
|
|
216
|
+
: mod[exportName]
|
|
198
217
|
// get the dependencies to forward to the function as the first arg
|
|
199
|
-
|
|
218
|
+
let dependenciesToForward =
|
|
200
219
|
thisRef.forwardDependenciesFromArray<F>(dependencies)
|
|
220
|
+
|
|
221
|
+
// if func is write func, inject signer into dependencies
|
|
222
|
+
if (subFunc === 'write') {
|
|
223
|
+
const options = (args[1] || {}) as WriteOptions
|
|
224
|
+
const signer =
|
|
225
|
+
options.signer ||
|
|
226
|
+
thisRef.provider?.getSigner(options.addressOrIndex)
|
|
227
|
+
if (!signer) {
|
|
228
|
+
throw new Error('No signer specified')
|
|
229
|
+
}
|
|
230
|
+
delete options.addressOrIndex
|
|
231
|
+
delete options.signer
|
|
232
|
+
dependenciesToForward = { ...dependenciesToForward, signer }
|
|
233
|
+
return func(dependenciesToForward, args[0], options)
|
|
234
|
+
}
|
|
235
|
+
|
|
201
236
|
// return the function with the dependencies forwarded
|
|
202
237
|
return func(dependenciesToForward, ...args)
|
|
203
238
|
} else {
|
|
@@ -256,6 +291,25 @@ export class ENS {
|
|
|
256
291
|
): OmitFirstArg<F> =>
|
|
257
292
|
this.importGenerator<F>(path, dependencies, exportName) as OmitFirstArg<F>
|
|
258
293
|
|
|
294
|
+
/**
|
|
295
|
+
* Generates a write wrapped function
|
|
296
|
+
* @param {string} path - The path of the exported function
|
|
297
|
+
* @param {FunctionDeps} dependencies - An array of ENS properties
|
|
298
|
+
* @param {string} exportName - The export name of the target function
|
|
299
|
+
* @returns {OmitFirstArg} - The generated wrapped function
|
|
300
|
+
*/
|
|
301
|
+
private generateWriteFunction = <F>(
|
|
302
|
+
path: string,
|
|
303
|
+
dependencies: FunctionDeps<F>,
|
|
304
|
+
exportName: string = 'default',
|
|
305
|
+
): WriteFunction<F> =>
|
|
306
|
+
this.importGenerator<F>(
|
|
307
|
+
path,
|
|
308
|
+
dependencies,
|
|
309
|
+
exportName,
|
|
310
|
+
'write',
|
|
311
|
+
) as WriteFunction<F>
|
|
312
|
+
|
|
259
313
|
/**
|
|
260
314
|
* Generates a wrapped function from raw and decode exports
|
|
261
315
|
* @param {string} path - The path of the exported function
|
|
@@ -455,55 +509,51 @@ export class ENS {
|
|
|
455
509
|
'multicallWrapper',
|
|
456
510
|
)
|
|
457
511
|
|
|
458
|
-
public setName = this.
|
|
512
|
+
public setName = this.generateWriteFunction<typeof setName>('setName', [
|
|
459
513
|
'contracts',
|
|
460
|
-
'provider',
|
|
461
514
|
])
|
|
462
515
|
|
|
463
|
-
public setRecords = this.
|
|
464
|
-
'
|
|
465
|
-
'provider',
|
|
466
|
-
|
|
467
|
-
])
|
|
516
|
+
public setRecords = this.generateWriteFunction<typeof setRecords>(
|
|
517
|
+
'setRecords',
|
|
518
|
+
['contracts', 'provider', 'getResolver'],
|
|
519
|
+
)
|
|
468
520
|
|
|
469
|
-
public setResolver = this.
|
|
521
|
+
public setResolver = this.generateWriteFunction<typeof setResolver>(
|
|
470
522
|
'setResolver',
|
|
471
|
-
['contracts'
|
|
523
|
+
['contracts'],
|
|
472
524
|
)
|
|
473
525
|
|
|
474
|
-
public transferName = this.
|
|
526
|
+
public transferName = this.generateWriteFunction<typeof transferName>(
|
|
475
527
|
'transferName',
|
|
476
|
-
['contracts'
|
|
528
|
+
['contracts'],
|
|
477
529
|
)
|
|
478
530
|
|
|
479
|
-
public wrapName = this.
|
|
531
|
+
public wrapName = this.generateWriteFunction<typeof wrapName>('wrapName', [
|
|
480
532
|
'contracts',
|
|
481
|
-
'provider',
|
|
482
533
|
])
|
|
483
534
|
|
|
484
|
-
public unwrapName = this.
|
|
485
|
-
'
|
|
486
|
-
'
|
|
487
|
-
|
|
535
|
+
public unwrapName = this.generateWriteFunction<typeof unwrapName>(
|
|
536
|
+
'unwrapName',
|
|
537
|
+
['contracts'],
|
|
538
|
+
)
|
|
488
539
|
|
|
489
|
-
public burnFuses = this.
|
|
540
|
+
public burnFuses = this.generateWriteFunction<typeof burnFuses>('burnFuses', [
|
|
490
541
|
'contracts',
|
|
491
|
-
'provider',
|
|
492
542
|
])
|
|
493
543
|
|
|
494
|
-
public createSubname = this.
|
|
544
|
+
public createSubname = this.generateWriteFunction<typeof createSubname>(
|
|
495
545
|
'createSubname',
|
|
496
|
-
['contracts'
|
|
546
|
+
['contracts'],
|
|
497
547
|
)
|
|
498
548
|
|
|
499
|
-
public deleteSubname = this.
|
|
549
|
+
public deleteSubname = this.generateWriteFunction<typeof deleteSubname>(
|
|
500
550
|
'deleteSubname',
|
|
501
|
-
['
|
|
551
|
+
['transferSubname'],
|
|
502
552
|
)
|
|
503
553
|
|
|
504
|
-
public transferSubname = this.
|
|
554
|
+
public transferSubname = this.generateWriteFunction<typeof transferSubname>(
|
|
505
555
|
'transferSubname',
|
|
506
|
-
['contracts'
|
|
556
|
+
['contracts'],
|
|
507
557
|
)
|
|
508
558
|
|
|
509
559
|
public getDNSOwner = this.generateFunction<typeof getDNSOwner>(
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { ethers } from 'ethers'
|
|
2
|
+
import { ENS } from '..'
|
|
3
|
+
import setup from '../tests/setup'
|
|
4
|
+
|
|
5
|
+
let ENSInstance: ENS
|
|
6
|
+
let revert: Awaited<ReturnType<typeof setup>>['revert']
|
|
7
|
+
let provider: ethers.providers.JsonRpcProvider
|
|
8
|
+
let accounts: string[]
|
|
9
|
+
|
|
10
|
+
beforeAll(async () => {
|
|
11
|
+
;({ ENSInstance, revert, provider } = await setup())
|
|
12
|
+
accounts = await provider.listAccounts()
|
|
13
|
+
})
|
|
14
|
+
|
|
15
|
+
afterAll(async () => {
|
|
16
|
+
await revert()
|
|
17
|
+
})
|
|
18
|
+
|
|
19
|
+
jest.setTimeout(20000)
|
|
20
|
+
|
|
21
|
+
describe('Signer Injection', () => {
|
|
22
|
+
beforeEach(async () => {
|
|
23
|
+
await revert()
|
|
24
|
+
})
|
|
25
|
+
it('should return a transaction successfully for a custom signer', async () => {
|
|
26
|
+
const signer = provider.getSigner(accounts[3])
|
|
27
|
+
const tx = await ENSInstance.setName('fleek.eth', { signer })
|
|
28
|
+
expect(tx).toBeTruthy()
|
|
29
|
+
if (tx) {
|
|
30
|
+
await tx.wait()
|
|
31
|
+
expect(tx.from).toBe(accounts[3])
|
|
32
|
+
}
|
|
33
|
+
})
|
|
34
|
+
it('should return a transaction succesfully for a custom signer index', async () => {
|
|
35
|
+
const tx = await ENSInstance.setName('fleek.eth', { addressOrIndex: 3 })
|
|
36
|
+
expect(tx).toBeTruthy()
|
|
37
|
+
if (tx) {
|
|
38
|
+
await tx.wait()
|
|
39
|
+
expect(tx.from).toBe(accounts[3])
|
|
40
|
+
}
|
|
41
|
+
})
|
|
42
|
+
})
|