@ensdomains/ensjs 3.0.0-alpha.21 → 3.0.0-alpha.23
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.js +1 -38
- package/dist/cjs/functions/commitName.js +2 -0
- package/dist/cjs/functions/createSubname.js +3 -2
- package/dist/cjs/functions/getHistory.js +19 -14
- package/dist/cjs/functions/getNames.js +1 -1
- package/dist/cjs/functions/{getFuses.js → getWrapperData.js} +10 -11
- package/dist/cjs/functions/registerName.js +2 -0
- package/dist/cjs/functions/renewNames.js +23 -3
- package/dist/cjs/functions/transferController.js +42 -0
- package/dist/cjs/functions/transferSubname.js +2 -2
- package/dist/cjs/functions/wrapName.js +3 -2
- package/dist/cjs/generated/factories/ETHRegistrarController__factory.js +137 -0
- package/dist/cjs/generated/factories/NameWrapper__factory.js +63 -39
- package/dist/cjs/generated/factories/PublicResolver__factory.js +69 -14
- package/dist/cjs/generated/factories/ReverseRegistrar__factory.js +13 -0
- package/dist/cjs/index.js +6 -3
- package/dist/cjs/utils/fuses.js +43 -1
- package/dist/cjs/utils/recordHelpers.js +5 -0
- package/dist/cjs/utils/registerHelpers.js +3 -1
- package/dist/cjs/utils/{wrapperExpiry.js → wrapper.js} +11 -4
- package/dist/esm/functions/burnFuses.mjs +2 -42
- package/dist/esm/functions/commitName.mjs +2 -0
- package/dist/esm/functions/createSubname.mjs +2 -1
- package/dist/esm/functions/getHistory.mjs +19 -14
- package/dist/esm/functions/getNames.mjs +1 -1
- package/dist/esm/functions/{getFuses.mjs → getWrapperData.mjs} +8 -9
- package/dist/esm/functions/registerName.mjs +2 -0
- package/dist/esm/functions/renewNames.mjs +23 -3
- package/dist/esm/functions/transferController.mjs +23 -0
- package/dist/esm/functions/transferSubname.mjs +1 -1
- package/dist/esm/functions/wrapName.mjs +2 -1
- package/dist/esm/generated/factories/ETHRegistrarController__factory.mjs +137 -0
- package/dist/esm/generated/factories/NameWrapper__factory.mjs +63 -39
- package/dist/esm/generated/factories/PublicResolver__factory.mjs +69 -14
- package/dist/esm/generated/factories/ReverseRegistrar__factory.mjs +13 -0
- package/dist/esm/index.mjs +6 -3
- package/dist/esm/utils/fuses.mjs +43 -1
- package/dist/esm/utils/recordHelpers.mjs +5 -0
- package/dist/esm/utils/registerHelpers.mjs +3 -1
- package/dist/esm/utils/{wrapperExpiry.mjs → wrapper.mjs} +9 -2
- package/dist/types/functions/burnFuses.d.ts +1 -11
- package/dist/types/functions/commitName.d.ts +1 -1
- package/dist/types/functions/createSubname.d.ts +1 -1
- package/dist/types/functions/{getFuses.d.ts → getWrapperData.d.ts} +1 -1
- package/dist/types/functions/registerName.d.ts +2 -5
- package/dist/types/functions/renewNames.d.ts +9 -2
- package/dist/types/functions/transferController.d.ts +6 -0
- package/dist/types/functions/transferSubname.d.ts +1 -1
- package/dist/types/functions/wrapName.d.ts +1 -1
- package/dist/types/generated/ETHRegistrarController.d.ts +42 -1
- package/dist/types/generated/NameWrapper.d.ts +66 -78
- package/dist/types/generated/PublicResolver.d.ts +51 -23
- package/dist/types/generated/ReverseRegistrar.d.ts +11 -0
- package/dist/types/generated/factories/ETHRegistrarController__factory.d.ts +12 -1
- package/dist/types/index.d.ts +5 -2
- package/dist/types/utils/fuses.d.ts +13 -0
- package/dist/types/utils/recordHelpers.d.ts +1 -0
- package/dist/types/utils/registerHelpers.d.ts +14 -9
- package/dist/types/utils/{wrapperExpiry.d.ts → wrapper.d.ts} +2 -1
- package/package.json +5 -4
- package/src/functions/burnFuses.test.ts +4 -4
- package/src/functions/burnFuses.ts +2 -65
- package/src/functions/commitName.ts +3 -0
- package/src/functions/createSubname.ts +2 -1
- package/src/functions/getHistory.ts +19 -13
- package/src/functions/getNames.test.ts +0 -1
- package/src/functions/getNames.ts +1 -1
- package/src/functions/getPrice.test.ts +9 -6
- package/src/functions/getProfile.test.ts +5 -6
- package/src/functions/getResolver.test.ts +2 -2
- package/src/functions/{getFuses.test.ts → getWrapperData.test.ts} +8 -6
- package/src/functions/{getFuses.ts → getWrapperData.ts} +6 -7
- package/src/functions/registerName.ts +5 -5
- package/src/functions/renewNames.test.ts +3 -3
- package/src/functions/renewNames.ts +36 -6
- package/src/functions/transferController.ts +28 -0
- package/src/functions/transferSubname.ts +1 -1
- package/src/functions/wrapName.test.ts +12 -3
- package/src/functions/wrapName.ts +3 -1
- package/src/generated/ETHRegistrarController.ts +104 -0
- package/src/generated/NameWrapper.ts +127 -90
- package/src/generated/PublicResolver.ts +114 -33
- package/src/generated/ReverseRegistrar.ts +20 -0
- package/src/generated/factories/ETHRegistrarController__factory.ts +137 -0
- package/src/generated/factories/NameWrapper__factory.ts +63 -39
- package/src/generated/factories/PublicResolver__factory.ts +69 -14
- package/src/generated/factories/ReverseRegistrar__factory.ts +13 -0
- package/src/index.ts +19 -5
- package/src/utils/fuses.ts +67 -1
- package/src/utils/recordHelpers.ts +7 -0
- package/src/utils/registerHelpers.ts +18 -9
- package/src/utils/{wrapperExpiry.ts → wrapper.ts} +8 -1
|
@@ -3,7 +3,7 @@ import { ENSArgs } from '..'
|
|
|
3
3
|
import { FuseOptions } from '../@types/FuseOptions'
|
|
4
4
|
import generateFuseInput from '../utils/generateFuseInput'
|
|
5
5
|
import { namehash } from '../utils/normalise'
|
|
6
|
-
import { Expiry, makeExpiry } from '../utils/
|
|
6
|
+
import { Expiry, makeExpiry, wrappedLabelLengthCheck } from '../utils/wrapper'
|
|
7
7
|
|
|
8
8
|
type BaseArgs = {
|
|
9
9
|
owner: string
|
|
@@ -59,6 +59,7 @@ export default async function (
|
|
|
59
59
|
)
|
|
60
60
|
}
|
|
61
61
|
case 'nameWrapper': {
|
|
62
|
+
wrappedLabelLengthCheck(label)
|
|
62
63
|
const nameWrapper = (await contracts!.getNameWrapper()!).connect(signer)
|
|
63
64
|
const expiry: BigNumber = await makeExpiry(
|
|
64
65
|
{ getExpiry },
|
|
@@ -2,6 +2,8 @@ import { formatsByCoinType } from '@ensdomains/address-encoder'
|
|
|
2
2
|
import { ethers } from 'ethers'
|
|
3
3
|
import { ENSArgs } from '..'
|
|
4
4
|
import { decodeContenthash } from '../utils/contentHash'
|
|
5
|
+
import { labelhash } from '../utils/labels'
|
|
6
|
+
import { namehash } from '../utils/normalise'
|
|
5
7
|
|
|
6
8
|
type DomainEvent = 'NewOwner' | 'NewResolver' | 'Transfer' | 'NewTTL'
|
|
7
9
|
type RegistrationEvent = 'NameRegistered' | 'NameRenewed' | 'NameTransferred'
|
|
@@ -102,8 +104,8 @@ export async function getHistory(
|
|
|
102
104
|
) {
|
|
103
105
|
const { client } = gqlInstance
|
|
104
106
|
const query = gqlInstance.gql`
|
|
105
|
-
query getHistory($
|
|
106
|
-
|
|
107
|
+
query getHistory($namehash: String!, $labelhash: String!) {
|
|
108
|
+
domain(id: $namehash) {
|
|
107
109
|
events {
|
|
108
110
|
id
|
|
109
111
|
blockNumber
|
|
@@ -129,7 +131,7 @@ export async function getHistory(
|
|
|
129
131
|
}
|
|
130
132
|
}
|
|
131
133
|
owner {
|
|
132
|
-
registrations (where: {
|
|
134
|
+
registrations (where: { id: $labelhash }) {
|
|
133
135
|
events {
|
|
134
136
|
id
|
|
135
137
|
blockNumber
|
|
@@ -201,19 +203,23 @@ export async function getHistory(
|
|
|
201
203
|
|
|
202
204
|
const label = name.split('.')[0]
|
|
203
205
|
|
|
204
|
-
const
|
|
206
|
+
const nameHash = namehash(name)
|
|
207
|
+
const labelHash = labelhash(label)
|
|
205
208
|
|
|
206
|
-
|
|
209
|
+
const { domain } = await client.request(query, {
|
|
210
|
+
namehash: nameHash,
|
|
211
|
+
labelhash: labelHash,
|
|
212
|
+
})
|
|
207
213
|
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
},
|
|
214
|
-
resolver: { events: resolverEvents },
|
|
214
|
+
if (!domain) return
|
|
215
|
+
|
|
216
|
+
const {
|
|
217
|
+
events: domainEvents,
|
|
218
|
+
owner: {
|
|
219
|
+
registrations: [{ events: registrationEvents }],
|
|
215
220
|
},
|
|
216
|
-
|
|
221
|
+
resolver: { events: resolverEvents },
|
|
222
|
+
} = domain
|
|
217
223
|
|
|
218
224
|
const domainHistory = mapEvents(domainEvents, 'Domain')
|
|
219
225
|
const registrationHistory = mapEvents(registrationEvents, 'Registration')
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { BigNumber } from 'ethers'
|
|
1
2
|
import { ENS } from '..'
|
|
2
3
|
import setup from '../tests/setup'
|
|
3
4
|
|
|
@@ -7,14 +8,16 @@ beforeAll(async () => {
|
|
|
7
8
|
;({ ensInstance } = await setup())
|
|
8
9
|
})
|
|
9
10
|
|
|
11
|
+
const yearCost = BigNumber.from('8561643835626')
|
|
12
|
+
|
|
10
13
|
describe('getPrice', () => {
|
|
11
|
-
it('should return a base and premium price for
|
|
14
|
+
it('should return a base and premium price for a name', async () => {
|
|
12
15
|
const { base, premium } = (await ensInstance.getPrice(
|
|
13
16
|
'test123',
|
|
14
17
|
86400,
|
|
15
18
|
false,
|
|
16
19
|
))!
|
|
17
|
-
expect(base.
|
|
20
|
+
expect(base.eq(yearCost)).toBe(true)
|
|
18
21
|
expect(premium.toNumber()).toBe(0)
|
|
19
22
|
})
|
|
20
23
|
|
|
@@ -24,18 +27,18 @@ describe('getPrice', () => {
|
|
|
24
27
|
86400,
|
|
25
28
|
false,
|
|
26
29
|
))!
|
|
27
|
-
expect(base.
|
|
30
|
+
expect(base.eq(yearCost.mul(2))).toBe(true)
|
|
28
31
|
expect(premium.toNumber()).toBe(0)
|
|
29
32
|
})
|
|
30
33
|
|
|
31
34
|
describe('legacy mode', () => {
|
|
32
|
-
it('should return a base and premium price for
|
|
35
|
+
it('should return a base and premium price for a name', async () => {
|
|
33
36
|
const { base, premium } = (await ensInstance.getPrice(
|
|
34
37
|
'test123',
|
|
35
38
|
86400,
|
|
36
39
|
true,
|
|
37
40
|
))!
|
|
38
|
-
expect(base.
|
|
41
|
+
expect(base.eq(yearCost)).toBe(true)
|
|
39
42
|
expect(premium.toNumber()).toBe(0)
|
|
40
43
|
})
|
|
41
44
|
|
|
@@ -45,7 +48,7 @@ describe('getPrice', () => {
|
|
|
45
48
|
86400,
|
|
46
49
|
true,
|
|
47
50
|
))!
|
|
48
|
-
expect(base.
|
|
51
|
+
expect(base.eq(yearCost.mul(2))).toBe(true)
|
|
49
52
|
expect(premium.toNumber()).toBe(0)
|
|
50
53
|
})
|
|
51
54
|
})
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { ethers } from 'ethers'
|
|
2
1
|
import dotenv from 'dotenv'
|
|
2
|
+
import { ethers } from 'ethers'
|
|
3
3
|
import { ENS } from '..'
|
|
4
|
-
import setup from '../tests/setup'
|
|
4
|
+
import setup, { deploymentAddresses } from '../tests/setup'
|
|
5
5
|
|
|
6
6
|
dotenv.config()
|
|
7
7
|
|
|
@@ -29,7 +29,7 @@ const checkRecords = (
|
|
|
29
29
|
expect(result.records?.texts).toHaveLength(textLength)
|
|
30
30
|
expect(result.records?.coinTypes).toHaveLength(coinTypeLength)
|
|
31
31
|
expect(result.resolverAddress).toBe(
|
|
32
|
-
|
|
32
|
+
deploymentAddresses.LegacyPublicResolver,
|
|
33
33
|
)
|
|
34
34
|
}
|
|
35
35
|
}
|
|
@@ -107,12 +107,12 @@ describe('getProfile', () => {
|
|
|
107
107
|
})
|
|
108
108
|
await tx.wait()
|
|
109
109
|
const result = await ensInstance.getProfile('test123.eth', {
|
|
110
|
-
resolverAddress:
|
|
110
|
+
resolverAddress: deploymentAddresses.LegacyPublicResolver,
|
|
111
111
|
})
|
|
112
112
|
expect(result).toBeDefined()
|
|
113
113
|
expect(result?.address).toBe(accounts[1])
|
|
114
114
|
expect(result?.resolverAddress).toBe(
|
|
115
|
-
|
|
115
|
+
deploymentAddresses.LegacyPublicResolver,
|
|
116
116
|
)
|
|
117
117
|
})
|
|
118
118
|
it('should return undefined for an unregistered name', async () => {
|
|
@@ -123,7 +123,6 @@ describe('getProfile', () => {
|
|
|
123
123
|
describe('with an old resolver', () => {
|
|
124
124
|
it('should use fallback methods for a name with an older resolver (no multicall)', async () => {
|
|
125
125
|
const result = await ensInstance.getProfile('with-legacy-resolver.eth')
|
|
126
|
-
const deploymentAddresses = JSON.parse(process.env.DEPLOYMENT_ADDRESSES!)
|
|
127
126
|
expect(result).toBeDefined()
|
|
128
127
|
if (result) {
|
|
129
128
|
expect(result.address).toBe(
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ENS } from '..'
|
|
2
|
-
import setup from '../tests/setup'
|
|
2
|
+
import setup, { deploymentAddresses } from '../tests/setup'
|
|
3
3
|
|
|
4
4
|
let ensInstance: ENS
|
|
5
5
|
|
|
@@ -10,6 +10,6 @@ beforeAll(async () => {
|
|
|
10
10
|
describe('getResolver', () => {
|
|
11
11
|
it('should find the resolver for a name with a resolver', async () => {
|
|
12
12
|
const result = await ensInstance.getResolver('with-profile.eth')
|
|
13
|
-
expect(result).toBe(
|
|
13
|
+
expect(result).toBe(deploymentAddresses.LegacyPublicResolver)
|
|
14
14
|
})
|
|
15
15
|
})
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { BigNumber } from 'ethers'
|
|
2
|
-
import { ENS } from '
|
|
2
|
+
import { ENS } from '../index'
|
|
3
3
|
import setup from '../tests/setup'
|
|
4
4
|
|
|
5
5
|
let ensInstance: ENS
|
|
@@ -38,15 +38,17 @@ afterAll(async () => {
|
|
|
38
38
|
await revert()
|
|
39
39
|
})
|
|
40
40
|
|
|
41
|
-
describe('
|
|
41
|
+
describe('getWrapperData', () => {
|
|
42
42
|
it('should return default data for an unwrapped name', async () => {
|
|
43
|
-
const result = await ensInstance.
|
|
43
|
+
const result = await ensInstance.getWrapperData('with-profile.eth')
|
|
44
44
|
expect({ ...result, expiryDate: result?.expiryDate.toString() }).toEqual(
|
|
45
45
|
unwrappedNameDefault,
|
|
46
46
|
)
|
|
47
47
|
})
|
|
48
48
|
it('should return with CAN_DO_EVERYTHING set to true for a name with no fuses burned', async () => {
|
|
49
|
-
const result = await ensInstance.
|
|
49
|
+
const result = await ensInstance.getWrapperData(
|
|
50
|
+
'test.wrapped-with-subnames.eth',
|
|
51
|
+
)
|
|
50
52
|
expect(result).toBeTruthy()
|
|
51
53
|
if (result) {
|
|
52
54
|
expect(result.fuseObj.CAN_DO_EVERYTHING).toBe(true)
|
|
@@ -70,7 +72,7 @@ describe('getFuses', () => {
|
|
|
70
72
|
})
|
|
71
73
|
await tx.wait()
|
|
72
74
|
|
|
73
|
-
const result = await ensInstance.
|
|
75
|
+
const result = await ensInstance.getWrapperData('wrapped.eth')
|
|
74
76
|
expect(result).toBeTruthy()
|
|
75
77
|
if (result) {
|
|
76
78
|
expect(result.fuseObj).toMatchObject({
|
|
@@ -87,7 +89,7 @@ describe('getFuses', () => {
|
|
|
87
89
|
}
|
|
88
90
|
})
|
|
89
91
|
it('should return correct expiry', async () => {
|
|
90
|
-
const result = await ensInstance.
|
|
92
|
+
const result = await ensInstance.getWrapperData('wrapped.eth')
|
|
91
93
|
expect(result).toBeTruthy()
|
|
92
94
|
if (result) {
|
|
93
95
|
expect(result.expiryDate).toBeInstanceOf(Date)
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { BigNumber } from 'ethers'
|
|
2
|
-
import { ENSArgs } from '
|
|
2
|
+
import { ENSArgs } from '../index'
|
|
3
3
|
import { CurrentFuses, fuseEnum } from '../utils/fuses'
|
|
4
4
|
import { namehash } from '../utils/normalise'
|
|
5
5
|
|
|
@@ -14,11 +14,10 @@ const raw = async ({ contracts }: ENSArgs<'contracts'>, name: string) => {
|
|
|
14
14
|
const decode = async ({ contracts }: ENSArgs<'contracts'>, data: string) => {
|
|
15
15
|
const nameWrapper = await contracts?.getNameWrapper()!
|
|
16
16
|
try {
|
|
17
|
-
const
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
} = nameWrapper.interface.decodeFunctionResult('getData', data)
|
|
17
|
+
const [owner, _fuses, expiry] = nameWrapper.interface.decodeFunctionResult(
|
|
18
|
+
'getData',
|
|
19
|
+
data,
|
|
20
|
+
)
|
|
22
21
|
|
|
23
22
|
const fuses = BigNumber.from(_fuses)
|
|
24
23
|
|
|
@@ -44,7 +43,7 @@ const decode = async ({ contracts }: ENSArgs<'contracts'>, data: string) => {
|
|
|
44
43
|
owner,
|
|
45
44
|
}
|
|
46
45
|
} catch (e) {
|
|
47
|
-
console.error('Error decoding
|
|
46
|
+
console.error('Error decoding wrapper data: ', e)
|
|
48
47
|
return
|
|
49
48
|
}
|
|
50
49
|
}
|
|
@@ -1,14 +1,12 @@
|
|
|
1
1
|
import { BigNumber } from 'ethers'
|
|
2
2
|
import { ENSArgs } from '..'
|
|
3
3
|
import {
|
|
4
|
-
|
|
4
|
+
BaseRegistrationParams,
|
|
5
5
|
makeRegistrationData,
|
|
6
6
|
} from '../utils/registerHelpers'
|
|
7
|
+
import { wrappedLabelLengthCheck } from '../utils/wrapper'
|
|
7
8
|
|
|
8
|
-
type Params =
|
|
9
|
-
resolverAddress?: string
|
|
10
|
-
secret: string
|
|
11
|
-
wrapperExpiry: number
|
|
9
|
+
type Params = BaseRegistrationParams & {
|
|
12
10
|
value: BigNumber
|
|
13
11
|
}
|
|
14
12
|
|
|
@@ -21,6 +19,8 @@ export default async function (
|
|
|
21
19
|
if (labels.length !== 2 || labels[1] !== 'eth')
|
|
22
20
|
throw new Error('Currently only .eth TLD registrations are supported')
|
|
23
21
|
|
|
22
|
+
wrappedLabelLengthCheck(labels[0])
|
|
23
|
+
|
|
24
24
|
const controller = await contracts!.getEthRegistrarController()
|
|
25
25
|
const _resolver = await contracts!.getPublicResolver(
|
|
26
26
|
undefined,
|
|
@@ -34,7 +34,7 @@ describe('renewNames', () => {
|
|
|
34
34
|
const tx = await ensInstance.renewNames(name, {
|
|
35
35
|
value: price.mul(2),
|
|
36
36
|
duration,
|
|
37
|
-
addressOrIndex: accounts[
|
|
37
|
+
addressOrIndex: accounts[0],
|
|
38
38
|
})
|
|
39
39
|
await tx.wait()
|
|
40
40
|
|
|
@@ -48,8 +48,8 @@ describe('renewNames', () => {
|
|
|
48
48
|
const duration = 31536000
|
|
49
49
|
const baseRegistrar = await ensInstance.contracts!.getBaseRegistrar()!
|
|
50
50
|
const oldExpiry = await baseRegistrar.nameExpires(labelhash(label))
|
|
51
|
-
const
|
|
52
|
-
const
|
|
51
|
+
const bulkRenewal = await ensInstance.contracts!.getBulkRenewal()!
|
|
52
|
+
const price = await bulkRenewal.rentPrice(names, duration)
|
|
53
53
|
|
|
54
54
|
const tx = await ensInstance.renewNames(names, {
|
|
55
55
|
value: price.mul(4),
|
|
@@ -1,16 +1,46 @@
|
|
|
1
|
-
import { BigNumber } from 'ethers'
|
|
1
|
+
import { BigNumber, BigNumberish } from 'ethers'
|
|
2
2
|
import { ENSArgs } from '..'
|
|
3
|
+
import { FuseProps, validateFuses } from '../utils/fuses'
|
|
4
|
+
import { MAX_INT_64 } from '../utils/registerHelpers'
|
|
3
5
|
|
|
4
|
-
|
|
6
|
+
type BaseProps = {
|
|
7
|
+
duration: number
|
|
8
|
+
value: BigNumber
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export async function renewNameWithData(
|
|
5
12
|
{ contracts }: ENSArgs<'contracts'>,
|
|
6
|
-
|
|
13
|
+
name: string,
|
|
7
14
|
{
|
|
8
15
|
duration,
|
|
9
16
|
value,
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
17
|
+
fuses,
|
|
18
|
+
wrapperExpiry = MAX_INT_64,
|
|
19
|
+
}: BaseProps & {
|
|
20
|
+
fuses?: FuseProps
|
|
21
|
+
wrapperExpiry?: BigNumberish
|
|
13
22
|
},
|
|
23
|
+
) {
|
|
24
|
+
const labels = name.split('.')
|
|
25
|
+
if (labels.length !== 2 || labels[1] !== 'eth') {
|
|
26
|
+
throw new Error('Currently only .eth TLD renewals are supported')
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const encodedFuses = fuses ? validateFuses(fuses) : 0
|
|
30
|
+
const controller = await contracts!.getEthRegistrarController()
|
|
31
|
+
return controller.populateTransaction.renewWithFuses(
|
|
32
|
+
labels[0],
|
|
33
|
+
duration,
|
|
34
|
+
encodedFuses,
|
|
35
|
+
wrapperExpiry,
|
|
36
|
+
{ value },
|
|
37
|
+
)
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export default async function (
|
|
41
|
+
{ contracts }: ENSArgs<'contracts'>,
|
|
42
|
+
nameOrNames: string | string[],
|
|
43
|
+
{ duration, value }: BaseProps,
|
|
14
44
|
) {
|
|
15
45
|
const names = Array.isArray(nameOrNames) ? nameOrNames : [nameOrNames]
|
|
16
46
|
const labels = names.map((name) => {
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { ethers } from 'ethers'
|
|
2
|
+
import { ENSArgs } from '..'
|
|
3
|
+
|
|
4
|
+
export default async function (
|
|
5
|
+
{ contracts, signer }: ENSArgs<'contracts' | 'signer'>,
|
|
6
|
+
name: string,
|
|
7
|
+
{
|
|
8
|
+
newOwner,
|
|
9
|
+
isOwner,
|
|
10
|
+
}: {
|
|
11
|
+
newOwner: string
|
|
12
|
+
isOwner: boolean
|
|
13
|
+
},
|
|
14
|
+
) {
|
|
15
|
+
const baseRegistrar = (await contracts?.getBaseRegistrar())!.connect(signer)
|
|
16
|
+
const registry = (await contracts?.getRegistry())!.connect(signer)
|
|
17
|
+
const labels = name.split('.')
|
|
18
|
+
if (isOwner) {
|
|
19
|
+
return registry.populateTransaction.setOwner(
|
|
20
|
+
ethers.utils.solidityKeccak256(['string'], [labels[0]]),
|
|
21
|
+
newOwner,
|
|
22
|
+
)
|
|
23
|
+
}
|
|
24
|
+
return baseRegistrar.populateTransaction.reclaim(
|
|
25
|
+
ethers.utils.solidityKeccak256(['string'], [labels[0]]),
|
|
26
|
+
newOwner,
|
|
27
|
+
)
|
|
28
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ethers } from 'ethers'
|
|
2
2
|
import { ENSArgs } from '..'
|
|
3
3
|
import { namehash } from '../utils/normalise'
|
|
4
|
-
import { Expiry, makeExpiry } from '../utils/
|
|
4
|
+
import { Expiry, makeExpiry } from '../utils/wrapper'
|
|
5
5
|
|
|
6
6
|
type BaseArgs = {
|
|
7
7
|
owner: string
|
|
@@ -44,7 +44,7 @@ describe('wrapName', () => {
|
|
|
44
44
|
await tx.wait()
|
|
45
45
|
|
|
46
46
|
const nameWrapper = await ensInstance.contracts!.getNameWrapper()!
|
|
47
|
-
const [fuses] = await nameWrapper.
|
|
47
|
+
const [, fuses] = await nameWrapper.getData(namehash('test123.eth'))
|
|
48
48
|
|
|
49
49
|
// parent cannot control
|
|
50
50
|
expect(fuses).toBe(64)
|
|
@@ -62,7 +62,7 @@ describe('wrapName', () => {
|
|
|
62
62
|
await tx.wait()
|
|
63
63
|
|
|
64
64
|
const nameWrapper = await ensInstance.contracts!.getNameWrapper()!
|
|
65
|
-
const [fuses] = await nameWrapper.
|
|
65
|
+
const [, fuses] = await nameWrapper.getData(namehash('test123.eth'))
|
|
66
66
|
expect(fuses).toBe(81)
|
|
67
67
|
})
|
|
68
68
|
it('should allow an initial resolver address', async () => {
|
|
@@ -81,6 +81,15 @@ describe('wrapName', () => {
|
|
|
81
81
|
)
|
|
82
82
|
expect(result).toBe('0x42D63ae25990889E35F215bC95884039Ba354115')
|
|
83
83
|
})
|
|
84
|
+
it('should throw an error for labels longer than 255 bytes', async () => {
|
|
85
|
+
const label = 'a'.repeat(256)
|
|
86
|
+
await expect(
|
|
87
|
+
ensInstance.wrapName(`${label}.eth`, {
|
|
88
|
+
wrappedOwner: accounts[2],
|
|
89
|
+
addressOrIndex: 1,
|
|
90
|
+
}),
|
|
91
|
+
).rejects.toThrow("Label can't be longer than 255 bytes")
|
|
92
|
+
})
|
|
84
93
|
})
|
|
85
94
|
describe('other', () => {
|
|
86
95
|
it('should return a wrap name transaction and succeed', async () => {
|
|
@@ -94,7 +103,7 @@ describe('wrapName', () => {
|
|
|
94
103
|
await tx.wait()
|
|
95
104
|
|
|
96
105
|
const nameWrapper = await ensInstance.contracts!.getNameWrapper()!
|
|
97
|
-
const [fuses] = await nameWrapper.
|
|
106
|
+
const [, fuses] = await nameWrapper.getData(
|
|
98
107
|
namehash('test.with-subnames.eth'),
|
|
99
108
|
)
|
|
100
109
|
|
|
@@ -3,7 +3,7 @@ import { ENSArgs } from '..'
|
|
|
3
3
|
import type { FuseOptions } from '../@types/FuseOptions'
|
|
4
4
|
import generateFuseInput from '../utils/generateFuseInput'
|
|
5
5
|
import { hexEncodeName } from '../utils/hexEncodedName'
|
|
6
|
-
import { Expiry, makeExpiry } from '../utils/
|
|
6
|
+
import { Expiry, makeExpiry, wrappedLabelLengthCheck } from '../utils/wrapper'
|
|
7
7
|
|
|
8
8
|
async function wrapETH(
|
|
9
9
|
{ contracts }: ENSArgs<'contracts'>,
|
|
@@ -86,6 +86,8 @@ export default async function (
|
|
|
86
86
|
if (!resolverAddress) resolverAddress = publicResolver.address
|
|
87
87
|
|
|
88
88
|
const labels = name.split('.')
|
|
89
|
+
wrappedLabelLengthCheck(labels[0])
|
|
90
|
+
|
|
89
91
|
if (labels.length === 2 && labels[1] === 'eth') {
|
|
90
92
|
switch (typeof fuseOptions) {
|
|
91
93
|
case 'object': {
|