@ensdomains/ensjs 3.0.0-alpha.2 → 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/getDNSOwner.d.ts +7 -0
- package/dist/cjs/functions/getDNSOwner.js +81 -0
- 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 +52 -34
- package/dist/cjs/index.js +36 -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/getDNSOwner.d.ts +7 -0
- package/dist/esm/functions/getDNSOwner.js +51 -0
- 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 +52 -34
- package/dist/esm/index.js +36 -22
- package/package.json +10 -5
- package/src/@types/dns-packet/index.d.ts +114 -0
- package/src/{tests → functions}/batch.test.ts +1 -1
- package/src/{tests → functions}/batchWrappers.test.ts +1 -1
- package/src/{tests → functions}/burnFuses.test.ts +9 -8
- package/src/functions/burnFuses.ts +6 -8
- package/src/{tests → functions}/createSubname.test.ts +8 -11
- package/src/functions/createSubname.ts +3 -10
- package/src/{tests → functions}/deleteSubname.test.ts +28 -27
- package/src/functions/deleteSubname.ts +9 -12
- package/src/functions/getDNSOwner.test.ts +122 -0
- package/src/functions/getDNSOwner.ts +61 -0
- package/src/{tests → functions}/getExpiry.test.ts +1 -1
- package/src/{tests → functions}/getFuses.test.ts +12 -10
- package/src/{tests → functions}/getHistory.test.ts +1 -1
- package/src/{tests → functions}/getName.test.ts +1 -1
- package/src/{tests → functions}/getNames.test.ts +1 -1
- package/src/{tests → functions}/getOwner.test.ts +4 -2
- package/src/{tests → functions}/getProfile.test.ts +1 -1
- package/src/{tests → functions}/getResolver.test.ts +1 -1
- package/src/{tests → functions}/getSpecificRecord.test.ts +1 -1
- package/src/{tests → functions}/getSubnames.test.ts +1 -1
- package/src/{tests → functions}/makeCommitment.test.ts +1 -1
- package/src/{tests → functions}/normalise.test.ts +0 -0
- package/src/{tests → functions}/setName.test.ts +3 -2
- package/src/functions/setName.ts +10 -12
- package/src/{tests → functions}/setRecords.test.ts +7 -5
- package/src/functions/setRecords.ts +18 -12
- package/src/{tests → functions}/setResolver.test.ts +12 -15
- package/src/functions/setResolver.ts +10 -18
- package/src/{tests → functions}/transferName.test.ts +27 -29
- package/src/functions/transferName.ts +12 -18
- package/src/{tests → functions}/transferSubname.test.ts +30 -29
- package/src/functions/transferSubname.ts +8 -10
- package/src/{tests → functions}/unwrapName.test.ts +22 -22
- package/src/functions/unwrapName.ts +8 -12
- package/src/{tests → functions}/wrapName.test.ts +15 -12
- package/src/functions/wrapName.ts +16 -15
- package/src/index.ts +85 -29
- package/src/tests/signerInjection.test.ts +42 -0
- package/src/tests/withProvider.test.ts +1 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ethers } from 'ethers'
|
|
2
2
|
import { ENS } from '..'
|
|
3
|
-
import setup from '
|
|
3
|
+
import setup from '../tests/setup'
|
|
4
4
|
|
|
5
5
|
let ENSInstance: ENS
|
|
6
6
|
let revert: Awaited<ReturnType<typeof setup>>['revert']
|
|
@@ -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',
|
|
13
|
+
const tx = await ENSInstance.wrapName('parthtejpal.eth', {
|
|
14
|
+
wrappedOwner: accounts[0],
|
|
15
|
+
})
|
|
14
16
|
await tx.wait()
|
|
15
17
|
})
|
|
16
18
|
|
|
File without changes
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ethers } from 'ethers'
|
|
2
2
|
import { ENS } from '..'
|
|
3
|
+
import setup from '../tests/setup'
|
|
3
4
|
import { hexEncodeName } from '../utils/hexEncodedName'
|
|
4
|
-
import setup from './setup'
|
|
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',
|
|
46
|
+
const tx = await ENSInstance.setName('fleek.eth', {
|
|
47
|
+
address: accounts[0],
|
|
47
48
|
addressOrIndex: 1,
|
|
48
49
|
})
|
|
49
50
|
expect(tx).toBeTruthy()
|
package/src/functions/setName.ts
CHANGED
|
@@ -1,22 +1,20 @@
|
|
|
1
1
|
import { ENSArgs } from '..'
|
|
2
2
|
|
|
3
3
|
export default async function (
|
|
4
|
-
{ contracts,
|
|
4
|
+
{ contracts, signer }: ENSArgs<'contracts' | 'signer'>,
|
|
5
5
|
name: string,
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
{
|
|
7
|
+
address,
|
|
8
|
+
resolver,
|
|
9
|
+
}: {
|
|
10
|
+
address?: string
|
|
11
|
+
resolver?: string
|
|
12
|
+
} = {},
|
|
9
13
|
) {
|
|
10
|
-
const signerAddress = await
|
|
11
|
-
?.getSigner(options?.addressOrIndex)
|
|
12
|
-
.getAddress()
|
|
13
|
-
|
|
14
|
-
if (!signerAddress) {
|
|
15
|
-
throw new Error('No signer found')
|
|
16
|
-
}
|
|
14
|
+
const signerAddress = await signer.getAddress()
|
|
17
15
|
|
|
18
16
|
const reverseRegistrar = (await contracts?.getReverseRegistrar())?.connect(
|
|
19
|
-
|
|
17
|
+
signer,
|
|
20
18
|
)
|
|
21
19
|
|
|
22
20
|
if (address) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ENS } from '..'
|
|
2
|
+
import setup from '../tests/setup'
|
|
2
3
|
import { hexEncodeName } from '../utils/hexEncodedName'
|
|
3
4
|
import { namehash } from '../utils/normalise'
|
|
4
|
-
import setup from './setup'
|
|
5
5
|
|
|
6
6
|
let ENSInstance: ENS
|
|
7
7
|
let revert: Awaited<ReturnType<typeof setup>>['revert']
|
|
@@ -17,10 +17,12 @@ afterAll(async () => {
|
|
|
17
17
|
describe('setRecords', () => {
|
|
18
18
|
it('should return a transaction to the resolver and set successfully', async () => {
|
|
19
19
|
const tx = await ENSInstance.setRecords('parthtejpal.eth', {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
20
|
+
records: {
|
|
21
|
+
coinTypes: [
|
|
22
|
+
{ key: 'ETC', value: '0x42D63ae25990889E35F215bC95884039Ba354115' },
|
|
23
|
+
],
|
|
24
|
+
texts: [{ key: 'foo', value: 'bar' }],
|
|
25
|
+
},
|
|
24
26
|
})
|
|
25
27
|
expect(tx).toBeTruthy()
|
|
26
28
|
await tx.wait()
|
|
@@ -7,29 +7,35 @@ export default async function (
|
|
|
7
7
|
contracts,
|
|
8
8
|
provider,
|
|
9
9
|
getResolver,
|
|
10
|
-
|
|
10
|
+
signer,
|
|
11
|
+
}: ENSArgs<'contracts' | 'provider' | 'getResolver' | 'signer'>,
|
|
11
12
|
name: string,
|
|
12
|
-
|
|
13
|
+
{
|
|
14
|
+
records,
|
|
15
|
+
resolverAddress,
|
|
16
|
+
}: {
|
|
17
|
+
records: RecordOptions
|
|
18
|
+
resolverAddress?: string
|
|
19
|
+
},
|
|
13
20
|
) {
|
|
14
21
|
if (!name.includes('.')) {
|
|
15
22
|
throw new Error('Input is not an ENS name')
|
|
16
23
|
}
|
|
17
24
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
25
|
+
let resolverToUse: string
|
|
26
|
+
if (resolverAddress) {
|
|
27
|
+
resolverToUse = resolverAddress
|
|
28
|
+
} else {
|
|
29
|
+
resolverToUse = await getResolver(name)
|
|
22
30
|
}
|
|
23
31
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
if (!address) {
|
|
27
|
-
throw new Error('No signer found')
|
|
32
|
+
if (!resolverToUse) {
|
|
33
|
+
throw new Error('No resolver found for input address')
|
|
28
34
|
}
|
|
29
35
|
|
|
30
36
|
const resolver = (
|
|
31
|
-
await contracts?.getPublicResolver(provider,
|
|
32
|
-
)?.connect(
|
|
37
|
+
await contracts?.getPublicResolver(provider, resolverToUse)
|
|
38
|
+
)?.connect(signer)
|
|
33
39
|
const hash = namehash(name)
|
|
34
40
|
|
|
35
41
|
const calls: string[] = generateRecordCallArray(hash, records, resolver!)
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ethers } from 'ethers'
|
|
2
2
|
import { ENS } from '..'
|
|
3
|
+
import setup from '../tests/setup'
|
|
3
4
|
import { hexEncodeName } from '../utils/hexEncodedName'
|
|
4
|
-
import setup from './setup'
|
|
5
5
|
|
|
6
6
|
let ENSInstance: ENS
|
|
7
7
|
let revert: Awaited<ReturnType<typeof setup>>['revert']
|
|
@@ -20,11 +20,10 @@ describe('setResolver', () => {
|
|
|
20
20
|
await revert()
|
|
21
21
|
})
|
|
22
22
|
it('should return a transaction to the registry and set successfully', async () => {
|
|
23
|
-
const tx = await ENSInstance.setResolver(
|
|
24
|
-
'
|
|
25
|
-
'
|
|
26
|
-
|
|
27
|
-
)
|
|
23
|
+
const tx = await ENSInstance.setResolver('parthtejpal.eth', {
|
|
24
|
+
contract: 'registry',
|
|
25
|
+
resolver: '0xAEfF4f4d8e2cB51854BEa2244B3C5Fb36b41C7fC',
|
|
26
|
+
})
|
|
28
27
|
expect(tx).toBeTruthy()
|
|
29
28
|
await tx.wait()
|
|
30
29
|
|
|
@@ -37,16 +36,14 @@ describe('setResolver', () => {
|
|
|
37
36
|
})
|
|
38
37
|
it('should return a transaction to the namewrapper and set successfully', async () => {
|
|
39
38
|
const accounts = await provider.listAccounts()
|
|
40
|
-
const wrapNameTx = await ENSInstance.wrapName(
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
)
|
|
39
|
+
const wrapNameTx = await ENSInstance.wrapName('parthtejpal.eth', {
|
|
40
|
+
wrappedOwner: accounts[0],
|
|
41
|
+
})
|
|
44
42
|
await wrapNameTx.wait()
|
|
45
|
-
const tx = await ENSInstance.setResolver(
|
|
46
|
-
'
|
|
47
|
-
'
|
|
48
|
-
|
|
49
|
-
)
|
|
43
|
+
const tx = await ENSInstance.setResolver('parthtejpal.eth', {
|
|
44
|
+
contract: 'nameWrapper',
|
|
45
|
+
resolver: '0xAEfF4f4d8e2cB51854BEa2244B3C5Fb36b41C7fC',
|
|
46
|
+
})
|
|
50
47
|
expect(tx).toBeTruthy()
|
|
51
48
|
await tx.wait()
|
|
52
49
|
|
|
@@ -2,35 +2,27 @@ import { ENSArgs } from '..'
|
|
|
2
2
|
import { namehash } from '../utils/normalise'
|
|
3
3
|
|
|
4
4
|
export default async function (
|
|
5
|
-
{ contracts,
|
|
5
|
+
{ contracts, signer }: ENSArgs<'contracts' | 'signer'>,
|
|
6
6
|
name: string,
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
{
|
|
8
|
+
contract,
|
|
9
|
+
resolver,
|
|
10
|
+
}: {
|
|
11
|
+
contract: 'registry' | 'nameWrapper'
|
|
12
|
+
resolver?: string
|
|
13
|
+
},
|
|
10
14
|
) {
|
|
11
|
-
const address = await provider
|
|
12
|
-
?.getSigner(options?.addressOrIndex)
|
|
13
|
-
.getAddress()
|
|
14
|
-
|
|
15
|
-
if (!address) {
|
|
16
|
-
throw new Error('No signer found')
|
|
17
|
-
}
|
|
18
|
-
|
|
19
15
|
if (!resolver) {
|
|
20
16
|
resolver = (await contracts?.getPublicResolver()!).address
|
|
21
17
|
}
|
|
22
18
|
|
|
23
19
|
switch (contract) {
|
|
24
20
|
case 'registry': {
|
|
25
|
-
const registry = (await contracts?.getRegistry())!.connect(
|
|
26
|
-
provider?.getSigner(options?.addressOrIndex)!,
|
|
27
|
-
)
|
|
21
|
+
const registry = (await contracts?.getRegistry())!.connect(signer)
|
|
28
22
|
return registry.setResolver(namehash(name), resolver)
|
|
29
23
|
}
|
|
30
24
|
case 'nameWrapper': {
|
|
31
|
-
const nameWrapper = (await contracts?.getNameWrapper())!.connect(
|
|
32
|
-
provider?.getSigner(options?.addressOrIndex)!,
|
|
33
|
-
)
|
|
25
|
+
const nameWrapper = (await contracts?.getNameWrapper())!.connect(signer)
|
|
34
26
|
return nameWrapper.setResolver(namehash(name), resolver)
|
|
35
27
|
}
|
|
36
28
|
default: {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ethers, utils } from 'ethers'
|
|
2
2
|
import { ENS } from '..'
|
|
3
|
+
import setup from '../tests/setup'
|
|
3
4
|
import { namehash } from '../utils/normalise'
|
|
4
|
-
import setup from './setup'
|
|
5
5
|
|
|
6
6
|
let ENSInstance: ENS
|
|
7
7
|
let revert: Awaited<ReturnType<typeof setup>>['revert']
|
|
@@ -22,12 +22,11 @@ describe('transferName', () => {
|
|
|
22
22
|
await revert()
|
|
23
23
|
})
|
|
24
24
|
it('should allow a transfer on the registrar', async () => {
|
|
25
|
-
const tx = await ENSInstance.transferName(
|
|
26
|
-
'
|
|
27
|
-
accounts[1],
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
)
|
|
25
|
+
const tx = await ENSInstance.transferName('parthtejpal.eth', {
|
|
26
|
+
contract: 'baseRegistrar',
|
|
27
|
+
newOwner: accounts[1],
|
|
28
|
+
addressOrIndex: 0,
|
|
29
|
+
})
|
|
31
30
|
expect(tx).toBeTruthy()
|
|
32
31
|
await tx.wait()
|
|
33
32
|
|
|
@@ -38,17 +37,15 @@ describe('transferName', () => {
|
|
|
38
37
|
expect(result).toBe(accounts[1])
|
|
39
38
|
})
|
|
40
39
|
it('should allow a transfer on the namewrapper', async () => {
|
|
41
|
-
const wrapNameTx = await ENSInstance.wrapName(
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
)
|
|
40
|
+
const wrapNameTx = await ENSInstance.wrapName('parthtejpal.eth', {
|
|
41
|
+
wrappedOwner: accounts[0],
|
|
42
|
+
})
|
|
45
43
|
await wrapNameTx.wait()
|
|
46
|
-
const tx = await ENSInstance.transferName(
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
)
|
|
44
|
+
const tx = await ENSInstance.transferName('parthtejpal.eth', {
|
|
45
|
+
newOwner: accounts[1],
|
|
46
|
+
contract: 'nameWrapper',
|
|
47
|
+
addressOrIndex: 0,
|
|
48
|
+
})
|
|
52
49
|
expect(tx).toBeTruthy()
|
|
53
50
|
await tx.wait()
|
|
54
51
|
|
|
@@ -57,20 +54,21 @@ describe('transferName', () => {
|
|
|
57
54
|
expect(result).toBe(accounts[1])
|
|
58
55
|
})
|
|
59
56
|
it('should allow a transfer on the registry', async () => {
|
|
60
|
-
const createSubnameTx = await ENSInstance.createSubname(
|
|
61
|
-
name: 'test.parthtejpal.eth',
|
|
62
|
-
contract: 'registry',
|
|
63
|
-
owner: accounts[0],
|
|
64
|
-
options: { addressOrIndex: accounts[0] },
|
|
65
|
-
})
|
|
66
|
-
await createSubnameTx.wait()
|
|
67
|
-
|
|
68
|
-
const tx = await ENSInstance.transferName(
|
|
57
|
+
const createSubnameTx = await ENSInstance.createSubname(
|
|
69
58
|
'test.parthtejpal.eth',
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
59
|
+
{
|
|
60
|
+
contract: 'registry',
|
|
61
|
+
owner: accounts[0],
|
|
62
|
+
addressOrIndex: accounts[0],
|
|
63
|
+
},
|
|
73
64
|
)
|
|
65
|
+
await createSubnameTx.wait()
|
|
66
|
+
|
|
67
|
+
const tx = await ENSInstance.transferName('test.parthtejpal.eth', {
|
|
68
|
+
newOwner: accounts[1],
|
|
69
|
+
contract: 'registry',
|
|
70
|
+
addressOrIndex: accounts[0],
|
|
71
|
+
})
|
|
74
72
|
expect(tx).toBeTruthy()
|
|
75
73
|
await tx.wait()
|
|
76
74
|
|
|
@@ -3,30 +3,26 @@ 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
|
+
newOwner,
|
|
10
|
+
contract,
|
|
11
|
+
}: {
|
|
12
|
+
newOwner: string
|
|
13
|
+
contract: 'registry' | 'nameWrapper' | 'baseRegistrar'
|
|
14
|
+
},
|
|
11
15
|
) {
|
|
12
|
-
const address = await
|
|
13
|
-
?.getSigner(options?.addressOrIndex)
|
|
14
|
-
.getAddress()
|
|
15
|
-
|
|
16
|
-
if (!address) {
|
|
17
|
-
throw new Error('No signer found')
|
|
18
|
-
}
|
|
16
|
+
const address = await signer.getAddress()
|
|
19
17
|
|
|
20
18
|
switch (contract) {
|
|
21
19
|
case 'registry': {
|
|
22
|
-
const registry = (await contracts?.getRegistry())!.connect(
|
|
23
|
-
provider?.getSigner(options?.addressOrIndex)!,
|
|
24
|
-
)
|
|
20
|
+
const registry = (await contracts?.getRegistry())!.connect(signer)
|
|
25
21
|
return registry.setOwner(namehash(name), newOwner)
|
|
26
22
|
}
|
|
27
23
|
case 'baseRegistrar': {
|
|
28
24
|
const baseRegistrar = (await contracts?.getBaseRegistrar())!.connect(
|
|
29
|
-
|
|
25
|
+
signer,
|
|
30
26
|
)
|
|
31
27
|
const labels = name.split('.')
|
|
32
28
|
if (labels.length > 2 || labels[labels.length - 1] !== 'eth') {
|
|
@@ -39,9 +35,7 @@ export default async function (
|
|
|
39
35
|
)
|
|
40
36
|
}
|
|
41
37
|
case 'nameWrapper': {
|
|
42
|
-
const nameWrapper = (await contracts?.getNameWrapper())!.connect(
|
|
43
|
-
provider?.getSigner(options?.addressOrIndex)!,
|
|
44
|
-
)
|
|
38
|
+
const nameWrapper = (await contracts?.getNameWrapper())!.connect(signer)
|
|
45
39
|
return nameWrapper.safeTransferFrom(
|
|
46
40
|
address,
|
|
47
41
|
newOwner,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ethers } from 'ethers'
|
|
2
2
|
import { ENS } from '..'
|
|
3
|
+
import setup from '../tests/setup'
|
|
3
4
|
import { namehash } from '../utils/normalise'
|
|
4
|
-
import setup from './setup'
|
|
5
5
|
|
|
6
6
|
let ENSInstance: ENS
|
|
7
7
|
let revert: Awaited<ReturnType<typeof setup>>['revert']
|
|
@@ -22,20 +22,21 @@ describe('transferSubname', () => {
|
|
|
22
22
|
await revert()
|
|
23
23
|
})
|
|
24
24
|
it('should allow transferring 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.transferSubname(
|
|
25
|
+
const createSubnameTx = await ENSInstance.createSubname(
|
|
34
26
|
'test.parthtejpal.eth',
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
27
|
+
{
|
|
28
|
+
contract: 'registry',
|
|
29
|
+
owner: accounts[0],
|
|
30
|
+
addressOrIndex: 0,
|
|
31
|
+
},
|
|
38
32
|
)
|
|
33
|
+
await createSubnameTx.wait()
|
|
34
|
+
|
|
35
|
+
const tx = await ENSInstance.transferSubname('test.parthtejpal.eth', {
|
|
36
|
+
contract: 'registry',
|
|
37
|
+
address: accounts[1],
|
|
38
|
+
addressOrIndex: 0,
|
|
39
|
+
})
|
|
39
40
|
expect(tx).toBeTruthy()
|
|
40
41
|
await tx.wait()
|
|
41
42
|
|
|
@@ -44,25 +45,25 @@ describe('transferSubname', () => {
|
|
|
44
45
|
expect(result).toBe(accounts[1])
|
|
45
46
|
})
|
|
46
47
|
it('should allow transferring a subname on the nameWrapper', async () => {
|
|
47
|
-
const wrapNameTx = await ENSInstance.wrapName(
|
|
48
|
-
|
|
49
|
-
accounts[0],
|
|
50
|
-
)
|
|
51
|
-
await wrapNameTx.wait()
|
|
52
|
-
const createSubnameTx = await ENSInstance.createSubname({
|
|
53
|
-
contract: 'nameWrapper',
|
|
54
|
-
name: 'test.parthtejpal.eth',
|
|
55
|
-
owner: accounts[0],
|
|
56
|
-
options: { addressOrIndex: 0 },
|
|
48
|
+
const wrapNameTx = await ENSInstance.wrapName('parthtejpal.eth', {
|
|
49
|
+
wrappedOwner: accounts[0],
|
|
57
50
|
})
|
|
58
|
-
await
|
|
59
|
-
|
|
60
|
-
const tx = await ENSInstance.transferSubname(
|
|
51
|
+
await wrapNameTx.wait()
|
|
52
|
+
const createSubnameTx = await ENSInstance.createSubname(
|
|
61
53
|
'test.parthtejpal.eth',
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
54
|
+
{
|
|
55
|
+
contract: 'nameWrapper',
|
|
56
|
+
owner: accounts[0],
|
|
57
|
+
addressOrIndex: 0,
|
|
58
|
+
},
|
|
65
59
|
)
|
|
60
|
+
await createSubnameTx.wait()
|
|
61
|
+
|
|
62
|
+
const tx = await ENSInstance.transferSubname('test.parthtejpal.eth', {
|
|
63
|
+
contract: 'nameWrapper',
|
|
64
|
+
address: accounts[1],
|
|
65
|
+
addressOrIndex: 0,
|
|
66
|
+
})
|
|
66
67
|
expect(tx).toBeTruthy()
|
|
67
68
|
await tx.wait()
|
|
68
69
|
|
|
@@ -3,18 +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
|
+
contract,
|
|
10
|
+
address,
|
|
11
|
+
}: {
|
|
12
|
+
contract: 'registry' | 'nameWrapper'
|
|
13
|
+
address: string
|
|
14
|
+
},
|
|
11
15
|
) {
|
|
12
|
-
const signer = provider?.getSigner(options?.addressOrIndex)
|
|
13
|
-
|
|
14
|
-
if (!signer) {
|
|
15
|
-
throw new Error('No signer found')
|
|
16
|
-
}
|
|
17
|
-
|
|
18
16
|
const labels = name.split('.')
|
|
19
17
|
const label = labels.shift() as string
|
|
20
18
|
const labelhash = ethers.utils.solidityKeccak256(['string'], [label])
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ethers, utils } from 'ethers'
|
|
2
2
|
import { ENS } from '..'
|
|
3
|
+
import setup from '../tests/setup'
|
|
3
4
|
import { namehash } from '../utils/normalise'
|
|
4
|
-
import setup from './setup'
|
|
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('.'))
|