@ensdomains/ensjs 3.0.0-alpha.1 → 3.0.0-alpha.2
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/README.md +2 -0
- package/dist/cjs/functions/burnFuses.d.ts +1 -2
- package/dist/cjs/functions/burnFuses.js +3 -3
- package/dist/cjs/functions/createSubname.js +2 -1
- package/dist/cjs/functions/getFuses.js +3 -2
- package/dist/cjs/functions/getOwner.js +7 -6
- package/dist/cjs/functions/getProfile.d.ts +1 -1
- package/dist/cjs/functions/getProfile.js +49 -15
- package/dist/cjs/functions/getSpecificRecord.js +22 -5
- package/dist/cjs/functions/getSubnames.js +6 -6
- package/dist/cjs/functions/setRecords.d.ts +1 -2
- package/dist/cjs/functions/setRecords.js +3 -3
- package/dist/cjs/functions/setResolver.d.ts +1 -2
- package/dist/cjs/functions/setResolver.js +3 -3
- package/dist/cjs/functions/transferName.js +3 -2
- package/dist/cjs/functions/transferSubname.js +2 -1
- package/dist/cjs/functions/unwrapName.js +2 -1
- package/dist/cjs/index.js +1 -0
- package/dist/cjs/utils/makeHashIndexes.js +2 -2
- package/dist/cjs/utils/normalise.d.ts +1 -0
- package/dist/cjs/utils/normalise.js +20 -1
- package/dist/cjs/utils/registerHelpers.js +3 -4
- package/dist/esm/functions/burnFuses.d.ts +1 -2
- package/dist/esm/functions/burnFuses.js +3 -3
- package/dist/esm/functions/createSubname.js +2 -1
- package/dist/esm/functions/getFuses.js +4 -3
- package/dist/esm/functions/getOwner.js +7 -6
- package/dist/esm/functions/getProfile.d.ts +1 -1
- package/dist/esm/functions/getProfile.js +49 -15
- package/dist/esm/functions/getSpecificRecord.js +22 -5
- package/dist/esm/functions/getSubnames.js +3 -3
- package/dist/esm/functions/setRecords.d.ts +1 -2
- package/dist/esm/functions/setRecords.js +3 -3
- package/dist/esm/functions/setResolver.d.ts +1 -2
- package/dist/esm/functions/setResolver.js +3 -3
- package/dist/esm/functions/transferName.js +3 -2
- package/dist/esm/functions/transferSubname.js +2 -1
- package/dist/esm/functions/unwrapName.js +2 -1
- package/dist/esm/index.js +1 -0
- package/dist/esm/utils/makeHashIndexes.js +2 -2
- package/dist/esm/utils/normalise.d.ts +1 -0
- package/dist/esm/utils/normalise.js +18 -0
- package/dist/esm/utils/registerHelpers.js +3 -4
- package/package.json +3 -2
- package/src/functions/burnFuses.ts +3 -3
- package/src/functions/createSubname.ts +2 -1
- package/src/functions/getFuses.ts +4 -3
- package/src/functions/getOwner.ts +7 -7
- package/src/functions/getProfile.ts +77 -13
- package/src/functions/getSpecificRecord.ts +28 -8
- package/src/functions/getSubnames.ts +68 -66
- package/src/functions/setRecords.ts +3 -3
- package/src/functions/setResolver.ts +3 -3
- package/src/functions/transferName.ts +3 -2
- package/src/functions/transferSubname.ts +2 -1
- package/src/functions/unwrapName.ts +2 -1
- package/src/index.ts +1 -0
- package/src/tests/burnFuses.test.ts +3 -2
- package/src/tests/createSubname.test.ts +4 -5
- package/src/tests/deleteSubname.test.ts +4 -5
- package/src/tests/getOwner.test.ts +10 -0
- package/src/tests/getProfile.test.ts +28 -10
- package/src/tests/normalise.test.ts +22 -0
- package/src/tests/setRecords.test.ts +3 -3
- package/src/tests/transferName.test.ts +3 -2
- package/src/tests/transferSubname.test.ts +4 -5
- package/src/tests/unwrapName.test.ts +2 -1
- package/src/tests/wrapName.test.ts +4 -7
- package/src/utils/makeHashIndexes.ts +4 -4
- package/src/utils/normalise.ts +23 -0
- package/src/utils/registerHelpers.ts +3 -4
|
@@ -96,10 +96,27 @@ const makeMulticallData = async (
|
|
|
96
96
|
return { data: prRawData.data, calls }
|
|
97
97
|
}
|
|
98
98
|
|
|
99
|
-
const
|
|
100
|
-
|
|
101
|
-
|
|
99
|
+
const fetchWithoutResolverMulticall = async (
|
|
100
|
+
{ multicallWrapper }: ENSArgs<'multicallWrapper'>,
|
|
101
|
+
calls: {
|
|
102
|
+
key: string | number
|
|
103
|
+
data: {
|
|
104
|
+
to: string
|
|
105
|
+
data: string
|
|
106
|
+
}
|
|
107
|
+
type: 'addr' | 'text' | 'contentHash'
|
|
108
|
+
}[],
|
|
109
|
+
resolverAddress: string,
|
|
110
|
+
) => {
|
|
111
|
+
const callsWithResolver = calls.map((call) => ({
|
|
112
|
+
to: resolverAddress,
|
|
113
|
+
data: call.data.data,
|
|
114
|
+
}))
|
|
115
|
+
|
|
116
|
+
return (await multicallWrapper(callsWithResolver)).map(
|
|
117
|
+
(x: [boolean, string]) => x[1],
|
|
102
118
|
)
|
|
119
|
+
}
|
|
103
120
|
|
|
104
121
|
const getDataForName = async (
|
|
105
122
|
{
|
|
@@ -108,15 +125,18 @@ const getDataForName = async (
|
|
|
108
125
|
_getContentHash,
|
|
109
126
|
_getText,
|
|
110
127
|
resolverMulticallWrapper,
|
|
128
|
+
multicallWrapper,
|
|
111
129
|
}: ENSArgs<
|
|
112
130
|
| 'contracts'
|
|
113
131
|
| '_getText'
|
|
114
132
|
| '_getAddr'
|
|
115
133
|
| '_getContentHash'
|
|
116
134
|
| 'resolverMulticallWrapper'
|
|
135
|
+
| 'multicallWrapper'
|
|
117
136
|
>,
|
|
118
137
|
name: string,
|
|
119
138
|
options: InternalProfileOptions,
|
|
139
|
+
fallbackResolver: string,
|
|
120
140
|
) => {
|
|
121
141
|
const universalResolver = await contracts?.getUniversalResolver()
|
|
122
142
|
|
|
@@ -126,14 +146,28 @@ const getDataForName = async (
|
|
|
126
146
|
options,
|
|
127
147
|
)
|
|
128
148
|
|
|
129
|
-
let
|
|
149
|
+
let resolvedData: any
|
|
150
|
+
let useFallbackResolver = false
|
|
130
151
|
try {
|
|
131
|
-
|
|
152
|
+
resolvedData = await universalResolver?.resolve(hexEncodeName(name), data)
|
|
132
153
|
} catch {
|
|
133
|
-
|
|
154
|
+
useFallbackResolver = true
|
|
134
155
|
}
|
|
135
156
|
|
|
136
|
-
|
|
157
|
+
let resolverAddress: string
|
|
158
|
+
let recordData: any
|
|
159
|
+
|
|
160
|
+
if (useFallbackResolver) {
|
|
161
|
+
resolverAddress = fallbackResolver
|
|
162
|
+
recordData = await fetchWithoutResolverMulticall(
|
|
163
|
+
{ multicallWrapper },
|
|
164
|
+
calls,
|
|
165
|
+
resolverAddress,
|
|
166
|
+
)
|
|
167
|
+
} else {
|
|
168
|
+
resolverAddress = resolvedData['1']
|
|
169
|
+
;[recordData] = await resolverMulticallWrapper.decode(resolvedData['0'])
|
|
170
|
+
}
|
|
137
171
|
|
|
138
172
|
const matchAddress = recordData[calls.findIndex((x) => x.key === '60')]
|
|
139
173
|
|
|
@@ -145,7 +179,7 @@ const getDataForName = async (
|
|
|
145
179
|
calls,
|
|
146
180
|
options,
|
|
147
181
|
),
|
|
148
|
-
resolverAddress
|
|
182
|
+
resolverAddress,
|
|
149
183
|
}
|
|
150
184
|
}
|
|
151
185
|
|
|
@@ -167,7 +201,7 @@ const formatRecords = async (
|
|
|
167
201
|
key: calls[i].key,
|
|
168
202
|
type: calls[i].type,
|
|
169
203
|
}
|
|
170
|
-
if (itemRet.type === '
|
|
204
|
+
if (itemRet.type === 'contenthash') {
|
|
171
205
|
decodedFromAbi = ethers.utils.defaultAbiCoder.decode(
|
|
172
206
|
['bytes'],
|
|
173
207
|
item,
|
|
@@ -277,6 +311,7 @@ const graphFetch = async (
|
|
|
277
311
|
addr {
|
|
278
312
|
id
|
|
279
313
|
}
|
|
314
|
+
address
|
|
280
315
|
}
|
|
281
316
|
}
|
|
282
317
|
}
|
|
@@ -292,7 +327,14 @@ const graphFetch = async (
|
|
|
292
327
|
|
|
293
328
|
let returnedRecords: ProfileResponse = {}
|
|
294
329
|
|
|
295
|
-
if (!
|
|
330
|
+
if (!resolverResponse) return { isMigrated, createdAt }
|
|
331
|
+
|
|
332
|
+
if (!wantedRecords)
|
|
333
|
+
return {
|
|
334
|
+
isMigrated,
|
|
335
|
+
createdAt,
|
|
336
|
+
graphResolverAddress: resolverResponse.address,
|
|
337
|
+
}
|
|
296
338
|
|
|
297
339
|
Object.keys(wantedRecords).forEach((key: string) => {
|
|
298
340
|
const data = wantedRecords[key as keyof ProfileOptions]
|
|
@@ -305,7 +347,12 @@ const graphFetch = async (
|
|
|
305
347
|
}
|
|
306
348
|
})
|
|
307
349
|
|
|
308
|
-
return {
|
|
350
|
+
return {
|
|
351
|
+
...returnedRecords,
|
|
352
|
+
isMigrated,
|
|
353
|
+
createdAt,
|
|
354
|
+
graphResolverAddress: resolverResponse.address,
|
|
355
|
+
}
|
|
309
356
|
}
|
|
310
357
|
|
|
311
358
|
type ProfileOptions = {
|
|
@@ -322,6 +369,7 @@ const getProfileFromName = async (
|
|
|
322
369
|
_getContentHash,
|
|
323
370
|
_getText,
|
|
324
371
|
resolverMulticallWrapper,
|
|
372
|
+
multicallWrapper,
|
|
325
373
|
}: ENSArgs<
|
|
326
374
|
| 'contracts'
|
|
327
375
|
| 'gqlInstance'
|
|
@@ -329,6 +377,7 @@ const getProfileFromName = async (
|
|
|
329
377
|
| '_getAddr'
|
|
330
378
|
| '_getContentHash'
|
|
331
379
|
| 'resolverMulticallWrapper'
|
|
380
|
+
| 'multicallWrapper'
|
|
332
381
|
>,
|
|
333
382
|
name: string,
|
|
334
383
|
options?: ProfileOptions,
|
|
@@ -342,9 +391,15 @@ const getProfileFromName = async (
|
|
|
342
391
|
const {
|
|
343
392
|
isMigrated,
|
|
344
393
|
createdAt,
|
|
394
|
+
graphResolverAddress,
|
|
345
395
|
...wantedRecords
|
|
346
|
-
}: {
|
|
347
|
-
|
|
396
|
+
}: {
|
|
397
|
+
isMigrated: boolean
|
|
398
|
+
createdAt: string
|
|
399
|
+
graphResolverAddress?: string
|
|
400
|
+
} & InternalProfileOptions = graphResult
|
|
401
|
+
if (!graphResolverAddress)
|
|
402
|
+
return { isMigrated, createdAt, message: "Name doesn't have a resolver" }
|
|
348
403
|
const result = await getDataForName(
|
|
349
404
|
{
|
|
350
405
|
contracts,
|
|
@@ -352,9 +407,11 @@ const getProfileFromName = async (
|
|
|
352
407
|
_getContentHash,
|
|
353
408
|
_getText,
|
|
354
409
|
resolverMulticallWrapper,
|
|
410
|
+
multicallWrapper,
|
|
355
411
|
},
|
|
356
412
|
name,
|
|
357
413
|
usingOptions ? wantedRecords : (options as InternalProfileOptions),
|
|
414
|
+
graphResolverAddress,
|
|
358
415
|
)
|
|
359
416
|
if (!result)
|
|
360
417
|
return { isMigrated, createdAt, message: "Records fetch didn't complete" }
|
|
@@ -370,6 +427,7 @@ const getProfileFromAddress = async (
|
|
|
370
427
|
_getContentHash,
|
|
371
428
|
_getText,
|
|
372
429
|
resolverMulticallWrapper,
|
|
430
|
+
multicallWrapper,
|
|
373
431
|
}: ENSArgs<
|
|
374
432
|
| 'contracts'
|
|
375
433
|
| 'gqlInstance'
|
|
@@ -378,6 +436,7 @@ const getProfileFromAddress = async (
|
|
|
378
436
|
| '_getAddr'
|
|
379
437
|
| '_getContentHash'
|
|
380
438
|
| 'resolverMulticallWrapper'
|
|
439
|
+
| 'multicallWrapper'
|
|
381
440
|
>,
|
|
382
441
|
address: string,
|
|
383
442
|
options?: ProfileOptions,
|
|
@@ -398,6 +457,7 @@ const getProfileFromAddress = async (
|
|
|
398
457
|
_getContentHash,
|
|
399
458
|
_getText,
|
|
400
459
|
resolverMulticallWrapper,
|
|
460
|
+
multicallWrapper,
|
|
401
461
|
},
|
|
402
462
|
name.name,
|
|
403
463
|
options,
|
|
@@ -420,6 +480,7 @@ export default async function (
|
|
|
420
480
|
_getContentHash,
|
|
421
481
|
_getText,
|
|
422
482
|
resolverMulticallWrapper,
|
|
483
|
+
multicallWrapper,
|
|
423
484
|
}: ENSArgs<
|
|
424
485
|
| 'contracts'
|
|
425
486
|
| 'gqlInstance'
|
|
@@ -428,6 +489,7 @@ export default async function (
|
|
|
428
489
|
| '_getAddr'
|
|
429
490
|
| '_getContentHash'
|
|
430
491
|
| 'resolverMulticallWrapper'
|
|
492
|
+
| 'multicallWrapper'
|
|
431
493
|
>,
|
|
432
494
|
nameOrAddress: string,
|
|
433
495
|
options?: ProfileOptions,
|
|
@@ -458,6 +520,7 @@ export default async function (
|
|
|
458
520
|
_getContentHash,
|
|
459
521
|
_getText,
|
|
460
522
|
resolverMulticallWrapper,
|
|
523
|
+
multicallWrapper,
|
|
461
524
|
},
|
|
462
525
|
nameOrAddress,
|
|
463
526
|
options,
|
|
@@ -472,6 +535,7 @@ export default async function (
|
|
|
472
535
|
_getContentHash,
|
|
473
536
|
_getText,
|
|
474
537
|
resolverMulticallWrapper,
|
|
538
|
+
multicallWrapper,
|
|
475
539
|
},
|
|
476
540
|
nameOrAddress,
|
|
477
541
|
options,
|
|
@@ -2,6 +2,7 @@ import { formatsByCoinType, formatsByName } from '@ensdomains/address-encoder'
|
|
|
2
2
|
import { ethers } from 'ethers'
|
|
3
3
|
import { ENSArgs } from '..'
|
|
4
4
|
import { decodeContenthash } from '../utils/contentHash'
|
|
5
|
+
import { namehash } from '../utils/normalise'
|
|
5
6
|
|
|
6
7
|
export const _getContentHash = {
|
|
7
8
|
raw: async ({ contracts }: ENSArgs<'contracts'>, name: string) => {
|
|
@@ -9,7 +10,7 @@ export const _getContentHash = {
|
|
|
9
10
|
return {
|
|
10
11
|
to: '0x0000000000000000000000000000000000000000',
|
|
11
12
|
data: publicResolver.interface.encodeFunctionData('contenthash', [
|
|
12
|
-
|
|
13
|
+
namehash(name),
|
|
13
14
|
]),
|
|
14
15
|
}
|
|
15
16
|
},
|
|
@@ -66,7 +67,7 @@ export const _getText = {
|
|
|
66
67
|
return {
|
|
67
68
|
to: '0x0000000000000000000000000000000000000000',
|
|
68
69
|
data: publicResolver.interface.encodeFunctionData('text', [
|
|
69
|
-
|
|
70
|
+
namehash(name),
|
|
70
71
|
key,
|
|
71
72
|
]),
|
|
72
73
|
}
|
|
@@ -115,12 +116,22 @@ export const _getAddr = {
|
|
|
115
116
|
}
|
|
116
117
|
|
|
117
118
|
const publicResolver = await contracts?.getPublicResolver()!
|
|
119
|
+
|
|
120
|
+
if (coinType === 60 || coinType === '60') {
|
|
121
|
+
return {
|
|
122
|
+
to: '0x0000000000000000000000000000000000000000',
|
|
123
|
+
data: publicResolver.interface.encodeFunctionData('addr(bytes32)', [
|
|
124
|
+
namehash(name),
|
|
125
|
+
]),
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
|
|
118
129
|
if (bypassFormat) {
|
|
119
130
|
return {
|
|
120
131
|
to: '0x0000000000000000000000000000000000000000',
|
|
121
132
|
data: publicResolver.interface.encodeFunctionData(
|
|
122
133
|
'addr(bytes32,uint256)',
|
|
123
|
-
[
|
|
134
|
+
[namehash(name), coinType],
|
|
124
135
|
),
|
|
125
136
|
}
|
|
126
137
|
}
|
|
@@ -139,7 +150,7 @@ export const _getAddr = {
|
|
|
139
150
|
to: '0x0000000000000000000000000000000000000000',
|
|
140
151
|
data: publicResolver.interface.encodeFunctionData(
|
|
141
152
|
'addr(bytes32,uint256)',
|
|
142
|
-
[
|
|
153
|
+
[namehash(name), formatter.coinType],
|
|
143
154
|
),
|
|
144
155
|
}
|
|
145
156
|
},
|
|
@@ -163,10 +174,19 @@ export const _getAddr = {
|
|
|
163
174
|
typeof coinType === 'number' ? coinType : parseInt(coinType)
|
|
164
175
|
]
|
|
165
176
|
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
177
|
+
let response: string
|
|
178
|
+
|
|
179
|
+
if (coinType === 60 || coinType === '60') {
|
|
180
|
+
;[response] = publicResolver.interface.decodeFunctionResult(
|
|
181
|
+
'addr(bytes32)',
|
|
182
|
+
data,
|
|
183
|
+
)
|
|
184
|
+
} else {
|
|
185
|
+
;[response] = publicResolver.interface.decodeFunctionResult(
|
|
186
|
+
'addr(bytes32,uint256)',
|
|
187
|
+
data,
|
|
188
|
+
)
|
|
189
|
+
}
|
|
170
190
|
|
|
171
191
|
if (!response) return
|
|
172
192
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { namehash } from 'ethers/lib/utils';
|
|
2
1
|
import { ENSArgs } from '..'
|
|
3
|
-
import { truncateFormat } from '../utils/format'
|
|
4
|
-
import { decryptName } from '../utils/labels'
|
|
2
|
+
import { truncateFormat } from '../utils/format'
|
|
3
|
+
import { decryptName } from '../utils/labels'
|
|
4
|
+
import { namehash } from '../utils/normalise'
|
|
5
5
|
|
|
6
6
|
type Subname = {
|
|
7
7
|
id: string
|
|
@@ -26,12 +26,12 @@ type Params = {
|
|
|
26
26
|
}
|
|
27
27
|
|
|
28
28
|
const largeQuery = async (
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
const client = gqlInstance.client
|
|
29
|
+
{ gqlInstance }: ENSArgs<'gqlInstance'>,
|
|
30
|
+
{ name, page, pageSize = 10, orderDirection, orderBy, lastSubnames }: Params,
|
|
31
|
+
) => {
|
|
32
|
+
const client = gqlInstance.client
|
|
33
33
|
|
|
34
|
-
let finalQuery = gqlInstance.gql
|
|
34
|
+
let finalQuery = gqlInstance.gql`
|
|
35
35
|
query getSubnames(
|
|
36
36
|
$id: ID!
|
|
37
37
|
$first: Int
|
|
@@ -62,35 +62,35 @@ const largeQuery = async (
|
|
|
62
62
|
}
|
|
63
63
|
}
|
|
64
64
|
}
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
const { domain } = await client.request(finalQuery, queryVars)
|
|
65
|
+
`
|
|
66
|
+
let queryVars = {
|
|
67
|
+
id: namehash(name),
|
|
68
|
+
first: pageSize,
|
|
69
|
+
lastCreatedAt: lastSubnames[lastSubnames.length - 1]?.createdAt,
|
|
70
|
+
orderBy,
|
|
71
|
+
orderDirection,
|
|
72
|
+
}
|
|
73
|
+
const { domain } = await client.request(finalQuery, queryVars)
|
|
74
74
|
const subdomains = domain.subdomains.map((subname: any) => {
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
})
|
|
75
|
+
const decrypted = decryptName(subname.name)
|
|
76
|
+
return {
|
|
77
|
+
...subname,
|
|
78
|
+
name: decrypted,
|
|
79
|
+
truncatedName: truncateFormat(decrypted),
|
|
80
|
+
}
|
|
81
|
+
})
|
|
82
82
|
|
|
83
83
|
return {
|
|
84
84
|
subnames: subdomains,
|
|
85
|
-
subnameCount: domain.subdomainCount
|
|
85
|
+
subnameCount: domain.subdomainCount,
|
|
86
86
|
}
|
|
87
|
-
}
|
|
87
|
+
}
|
|
88
88
|
|
|
89
|
-
const smallQuery =
|
|
90
|
-
{ gqlInstance }
|
|
91
|
-
{ name, page, pageSize = 10, orderDirection, orderBy }
|
|
92
|
-
|
|
93
|
-
const client = gqlInstance.client
|
|
89
|
+
const smallQuery = async (
|
|
90
|
+
{ gqlInstance }: ENSArgs<'gqlInstance'>,
|
|
91
|
+
{ name, page, pageSize = 10, orderDirection, orderBy }: Params,
|
|
92
|
+
) => {
|
|
93
|
+
const client = gqlInstance.client
|
|
94
94
|
const subdomainsGql = `
|
|
95
95
|
id
|
|
96
96
|
labelName
|
|
@@ -102,11 +102,11 @@ const smallQuery = async (
|
|
|
102
102
|
owner {
|
|
103
103
|
id
|
|
104
104
|
}
|
|
105
|
-
|
|
106
|
-
let queryVars = {}
|
|
107
|
-
let finalQuery = ''
|
|
105
|
+
`
|
|
106
|
+
let queryVars = {}
|
|
107
|
+
let finalQuery = ''
|
|
108
108
|
if (typeof page !== 'number') {
|
|
109
|
-
|
|
109
|
+
finalQuery = gqlInstance.gql`
|
|
110
110
|
query getSubnames(
|
|
111
111
|
$id: ID!
|
|
112
112
|
$orderBy: Domain_orderBy
|
|
@@ -123,15 +123,14 @@ const smallQuery = async (
|
|
|
123
123
|
}
|
|
124
124
|
}
|
|
125
125
|
}
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
finalQuery = gqlInstance.gql `
|
|
126
|
+
`
|
|
127
|
+
queryVars = {
|
|
128
|
+
id: namehash(name),
|
|
129
|
+
orderBy,
|
|
130
|
+
orderDirection,
|
|
131
|
+
}
|
|
132
|
+
} else {
|
|
133
|
+
finalQuery = gqlInstance.gql`
|
|
135
134
|
query getSubnames(
|
|
136
135
|
$id: ID!
|
|
137
136
|
$first: Int
|
|
@@ -153,36 +152,39 @@ const smallQuery = async (
|
|
|
153
152
|
}
|
|
154
153
|
}
|
|
155
154
|
}
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
155
|
+
`
|
|
156
|
+
queryVars = {
|
|
157
|
+
id: namehash(name),
|
|
158
|
+
first: pageSize,
|
|
159
|
+
skip: (page || 0) * pageSize,
|
|
160
|
+
orderBy,
|
|
161
|
+
orderDirection,
|
|
162
|
+
}
|
|
164
163
|
}
|
|
165
|
-
const { domain } = await client.request(finalQuery, queryVars)
|
|
164
|
+
const { domain } = await client.request(finalQuery, queryVars)
|
|
166
165
|
const subdomains = domain.subdomains.map((subname: any) => {
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
})
|
|
166
|
+
const decrypted = decryptName(subname.name)
|
|
167
|
+
return {
|
|
168
|
+
...subname,
|
|
169
|
+
name: decrypted,
|
|
170
|
+
truncatedName: truncateFormat(decrypted),
|
|
171
|
+
}
|
|
172
|
+
})
|
|
174
173
|
|
|
175
174
|
return {
|
|
176
175
|
subnames: subdomains,
|
|
177
|
-
subnameCount: domain.subdomainCount
|
|
176
|
+
subnameCount: domain.subdomainCount,
|
|
178
177
|
}
|
|
179
|
-
}
|
|
178
|
+
}
|
|
180
179
|
|
|
181
|
-
const getSubnames = (
|
|
182
|
-
|
|
180
|
+
const getSubnames = (
|
|
181
|
+
injected: ENSArgs<'gqlInstance'>,
|
|
182
|
+
functionArgs: Params,
|
|
183
|
+
): Promise<{ subnames: Subname[]; subnameCount: number }> => {
|
|
184
|
+
if (functionArgs.isLargeQuery) {
|
|
183
185
|
return largeQuery(injected, functionArgs)
|
|
184
|
-
}
|
|
186
|
+
}
|
|
185
187
|
return smallQuery(injected, functionArgs)
|
|
186
188
|
}
|
|
187
189
|
|
|
188
|
-
export default getSubnames
|
|
190
|
+
export default getSubnames
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ethers } from 'ethers'
|
|
2
1
|
import { ENSArgs } from '..'
|
|
2
|
+
import { namehash } from '../utils/normalise'
|
|
3
3
|
import { generateRecordCallArray, RecordOptions } from '../utils/recordHelpers'
|
|
4
4
|
|
|
5
5
|
export default async function (
|
|
@@ -30,9 +30,9 @@ export default async function (
|
|
|
30
30
|
const resolver = (
|
|
31
31
|
await contracts?.getPublicResolver(provider, resolverAddress)
|
|
32
32
|
)?.connect(provider?.getSigner()!)
|
|
33
|
-
const
|
|
33
|
+
const hash = namehash(name)
|
|
34
34
|
|
|
35
|
-
const calls: string[] = generateRecordCallArray(
|
|
35
|
+
const calls: string[] = generateRecordCallArray(hash, records, resolver!)
|
|
36
36
|
|
|
37
37
|
return resolver?.multicall(calls)
|
|
38
38
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ethers } from 'ethers'
|
|
2
1
|
import { ENSArgs } from '..'
|
|
2
|
+
import { namehash } from '../utils/normalise'
|
|
3
3
|
|
|
4
4
|
export default async function (
|
|
5
5
|
{ contracts, provider }: ENSArgs<'contracts' | 'provider'>,
|
|
@@ -25,13 +25,13 @@ export default async function (
|
|
|
25
25
|
const registry = (await contracts?.getRegistry())!.connect(
|
|
26
26
|
provider?.getSigner(options?.addressOrIndex)!,
|
|
27
27
|
)
|
|
28
|
-
return registry.setResolver(
|
|
28
|
+
return registry.setResolver(namehash(name), resolver)
|
|
29
29
|
}
|
|
30
30
|
case 'nameWrapper': {
|
|
31
31
|
const nameWrapper = (await contracts?.getNameWrapper())!.connect(
|
|
32
32
|
provider?.getSigner(options?.addressOrIndex)!,
|
|
33
33
|
)
|
|
34
|
-
return nameWrapper.setResolver(
|
|
34
|
+
return nameWrapper.setResolver(namehash(name), resolver)
|
|
35
35
|
}
|
|
36
36
|
default: {
|
|
37
37
|
throw new Error(`Unknown contract: ${contract}`)
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { ethers } from 'ethers'
|
|
2
2
|
import { ENSArgs } from '..'
|
|
3
|
+
import { namehash } from '../utils/normalise'
|
|
3
4
|
|
|
4
5
|
export default async function (
|
|
5
6
|
{ contracts, provider }: ENSArgs<'contracts' | 'provider'>,
|
|
@@ -21,7 +22,7 @@ export default async function (
|
|
|
21
22
|
const registry = (await contracts?.getRegistry())!.connect(
|
|
22
23
|
provider?.getSigner(options?.addressOrIndex)!,
|
|
23
24
|
)
|
|
24
|
-
return registry.setOwner(
|
|
25
|
+
return registry.setOwner(namehash(name), newOwner)
|
|
25
26
|
}
|
|
26
27
|
case 'baseRegistrar': {
|
|
27
28
|
const baseRegistrar = (await contracts?.getBaseRegistrar())!.connect(
|
|
@@ -44,7 +45,7 @@ export default async function (
|
|
|
44
45
|
return nameWrapper.safeTransferFrom(
|
|
45
46
|
address,
|
|
46
47
|
newOwner,
|
|
47
|
-
|
|
48
|
+
namehash(name),
|
|
48
49
|
1,
|
|
49
50
|
'0x',
|
|
50
51
|
)
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { ethers } from 'ethers'
|
|
2
2
|
import { ENSArgs } from '..'
|
|
3
|
+
import { namehash } from '../utils/normalise'
|
|
3
4
|
|
|
4
5
|
export default async function (
|
|
5
6
|
{ contracts, provider }: ENSArgs<'contracts' | 'provider'>,
|
|
@@ -17,7 +18,7 @@ export default async function (
|
|
|
17
18
|
const labels = name.split('.')
|
|
18
19
|
const label = labels.shift() as string
|
|
19
20
|
const labelhash = ethers.utils.solidityKeccak256(['string'], [label])
|
|
20
|
-
const parentNodehash =
|
|
21
|
+
const parentNodehash = namehash(labels.join('.'))
|
|
21
22
|
|
|
22
23
|
switch (contract) {
|
|
23
24
|
case 'registry': {
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { utils } from 'ethers'
|
|
2
2
|
import { ENSArgs } from '..'
|
|
3
|
+
import { namehash } from '../utils/normalise'
|
|
3
4
|
|
|
4
5
|
export default async function (
|
|
5
6
|
{ contracts, provider }: ENSArgs<'contracts' | 'provider'>,
|
|
@@ -18,7 +19,7 @@ export default async function (
|
|
|
18
19
|
|
|
19
20
|
const labels = name.split('.')
|
|
20
21
|
const labelhash = utils.solidityKeccak256(['string'], [labels[0]])
|
|
21
|
-
const parentNodehash =
|
|
22
|
+
const parentNodehash = namehash(labels.slice(1).join('.'))
|
|
22
23
|
|
|
23
24
|
const nameWrapper = (await contracts?.getNameWrapper()!).connect(signer)
|
|
24
25
|
|
package/src/index.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { BigNumber, ethers
|
|
1
|
+
import { BigNumber, ethers } from 'ethers'
|
|
2
2
|
import { ENS } from '..'
|
|
3
|
+
import { namehash } from '../utils/normalise'
|
|
3
4
|
import setup from './setup'
|
|
4
5
|
|
|
5
6
|
let ENSInstance: ENS
|
|
@@ -36,7 +37,7 @@ describe('burnFuses', () => {
|
|
|
36
37
|
await tx.wait()
|
|
37
38
|
|
|
38
39
|
const nameWrapper = await ENSInstance.contracts!.getNameWrapper()!
|
|
39
|
-
const result = await nameWrapper.getFuses(
|
|
40
|
+
const result = await nameWrapper.getFuses(namehash('parthtejpal.eth'))
|
|
40
41
|
const fuseBN = result.fuses as BigNumber
|
|
41
42
|
expect(fuseBN.toHexString()).toBe('0x71')
|
|
42
43
|
})
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { ethers
|
|
1
|
+
import { ethers } from 'ethers'
|
|
2
2
|
import { ENS } from '..'
|
|
3
|
+
import { namehash } from '../utils/normalise'
|
|
3
4
|
import setup from './setup'
|
|
4
5
|
|
|
5
6
|
let ENSInstance: ENS
|
|
@@ -32,7 +33,7 @@ describe('createSubname', () => {
|
|
|
32
33
|
await tx.wait()
|
|
33
34
|
|
|
34
35
|
const registry = await ENSInstance.contracts!.getRegistry()!
|
|
35
|
-
const result = await registry.owner(
|
|
36
|
+
const result = await registry.owner(namehash('test.parthtejpal.eth'))
|
|
36
37
|
expect(result).toBe(accounts[0])
|
|
37
38
|
})
|
|
38
39
|
it('should allow creating a subname on the namewrapper', async () => {
|
|
@@ -51,9 +52,7 @@ describe('createSubname', () => {
|
|
|
51
52
|
await tx.wait()
|
|
52
53
|
|
|
53
54
|
const nameWrapper = await ENSInstance.contracts!.getNameWrapper()!
|
|
54
|
-
const result = await nameWrapper.ownerOf(
|
|
55
|
-
utils.namehash('test.parthtejpal.eth'),
|
|
56
|
-
)
|
|
55
|
+
const result = await nameWrapper.ownerOf(namehash('test.parthtejpal.eth'))
|
|
57
56
|
expect(result).toBe(accounts[0])
|
|
58
57
|
})
|
|
59
58
|
})
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { ethers
|
|
1
|
+
import { ethers } from 'ethers'
|
|
2
2
|
import { ENS } from '..'
|
|
3
|
+
import { namehash } from '../utils/normalise'
|
|
3
4
|
import setup from './setup'
|
|
4
5
|
|
|
5
6
|
let ENSInstance: ENS
|
|
@@ -38,7 +39,7 @@ describe('deleteSubname', () => {
|
|
|
38
39
|
await tx.wait()
|
|
39
40
|
|
|
40
41
|
const registry = await ENSInstance.contracts!.getRegistry()!
|
|
41
|
-
const result = await registry.owner(
|
|
42
|
+
const result = await registry.owner(namehash('test.parthtejpal.eth'))
|
|
42
43
|
expect(result).toBe('0x0000000000000000000000000000000000000000')
|
|
43
44
|
})
|
|
44
45
|
it('should allow deleting a subname on the nameWrapper', async () => {
|
|
@@ -64,9 +65,7 @@ describe('deleteSubname', () => {
|
|
|
64
65
|
await tx.wait()
|
|
65
66
|
|
|
66
67
|
const nameWrapper = await ENSInstance.contracts!.getNameWrapper()!
|
|
67
|
-
const result = await nameWrapper.ownerOf(
|
|
68
|
-
utils.namehash('test.parthtejpal.eth'),
|
|
69
|
-
)
|
|
68
|
+
const result = await nameWrapper.ownerOf(namehash('test.parthtejpal.eth'))
|
|
70
69
|
expect(result).toBe('0x0000000000000000000000000000000000000000')
|
|
71
70
|
})
|
|
72
71
|
})
|