@ensdomains/ensjs 3.0.0-alpha.20 → 3.0.0-alpha.22

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (66) hide show
  1. package/dist/cjs/{functions/renewName.js → contracts/bulkRenewal.js} +6 -14
  2. package/dist/cjs/contracts/getContractAddress.js +2 -1
  3. package/dist/cjs/contracts/index.js +5 -0
  4. package/dist/cjs/functions/deleteSubname.js +40 -8
  5. package/dist/cjs/functions/getPrice.js +55 -8
  6. package/dist/cjs/functions/getSubnames.js +30 -94
  7. package/dist/cjs/functions/renewNames.js +42 -0
  8. package/dist/cjs/generated/BulkRenewal.js +16 -0
  9. package/dist/cjs/generated/factories/BulkRenewal__factory.js +120 -0
  10. package/dist/cjs/generated/factories/index.js +2 -0
  11. package/dist/cjs/generated/index.js +2 -0
  12. package/dist/cjs/index.js +5 -4
  13. package/dist/cjs/utils/registerHelpers.js +2 -1
  14. package/dist/esm/contracts/bulkRenewal.mjs +6 -0
  15. package/dist/esm/contracts/getContractAddress.mjs +2 -1
  16. package/dist/esm/contracts/index.mjs +5 -0
  17. package/dist/esm/functions/deleteSubname.mjs +40 -8
  18. package/dist/esm/functions/getPrice.mjs +56 -9
  19. package/dist/esm/functions/getSubnames.mjs +30 -94
  20. package/dist/esm/functions/renewNames.mjs +23 -0
  21. package/dist/esm/generated/BulkRenewal.mjs +0 -0
  22. package/dist/esm/generated/factories/BulkRenewal__factory.mjs +108 -0
  23. package/dist/esm/generated/factories/index.mjs +2 -0
  24. package/dist/esm/generated/index.mjs +2 -0
  25. package/dist/esm/index.mjs +5 -4
  26. package/dist/esm/utils/registerHelpers.mjs +2 -1
  27. package/dist/types/contracts/bulkRenewal.d.ts +3 -0
  28. package/dist/types/contracts/index.d.ts +1 -0
  29. package/dist/types/contracts/types.d.ts +1 -1
  30. package/dist/types/functions/commitName.d.ts +1 -1
  31. package/dist/types/functions/deleteSubname.d.ts +5 -2
  32. package/dist/types/functions/getPrice.d.ts +2 -2
  33. package/dist/types/functions/getSubnames.d.ts +1 -1
  34. package/dist/types/functions/registerName.d.ts +2 -5
  35. package/dist/types/functions/{renewName.d.ts → renewNames.d.ts} +2 -2
  36. package/dist/types/generated/BulkRenewal.d.ts +76 -0
  37. package/dist/types/generated/factories/BulkRenewal__factory.d.ts +32 -0
  38. package/dist/types/generated/factories/index.d.ts +1 -0
  39. package/dist/types/generated/index.d.ts +2 -0
  40. package/dist/types/index.d.ts +5 -5
  41. package/dist/types/utils/fuses.d.ts +2 -0
  42. package/dist/types/utils/registerHelpers.d.ts +13 -9
  43. package/package.json +1 -1
  44. package/src/contracts/bulkRenewal.ts +6 -0
  45. package/src/contracts/getContractAddress.ts +1 -0
  46. package/src/contracts/index.ts +6 -0
  47. package/src/contracts/types.ts +1 -0
  48. package/src/functions/deleteSubname.ts +51 -11
  49. package/src/functions/getNames.test.ts +10 -1
  50. package/src/functions/getPrice.test.ts +52 -0
  51. package/src/functions/getPrice.ts +61 -9
  52. package/src/functions/getProfile.test.ts +5 -1
  53. package/src/functions/getSubnames.test.ts +669 -29
  54. package/src/functions/getSubnames.ts +39 -98
  55. package/src/functions/registerName.ts +2 -5
  56. package/src/functions/{renewName.test.ts → renewNames.test.ts} +22 -2
  57. package/src/functions/renewNames.ts +30 -0
  58. package/src/generated/BulkRenewal.ts +197 -0
  59. package/src/generated/factories/BulkRenewal__factory.ts +108 -0
  60. package/src/generated/factories/index.ts +1 -0
  61. package/src/generated/index.ts +2 -0
  62. package/src/index.ts +6 -5
  63. package/src/utils/fuses.ts +3 -1
  64. package/src/utils/registerHelpers.ts +18 -9
  65. package/dist/esm/functions/renewName.mjs +0 -14
  66. package/src/functions/renewName.ts +0 -22
@@ -1,35 +1,675 @@
1
- // import { ENS } from '..'
2
- // import setup from '../tests/setup'
1
+ import { ENS } from '..'
2
+ import setup from '../tests/setup'
3
3
 
4
- // let ensInstance: ENS
4
+ let ensInstance: ENS
5
5
 
6
- // beforeAll(async () => {
7
- // ;({ ensInstance } = await setup())
8
- // })
6
+ beforeAll(async () => {
7
+ ;({ ensInstance } = await setup())
8
+ })
9
9
 
10
- // const testProperties = (obj: object, ...properties: string[]) =>
11
- // properties.map((property) => expect(obj).toHaveProperty(property))
10
+ const testProperties = (obj: object, ...properties: string[]) =>
11
+ properties.map((property) => expect(obj).toHaveProperty(property))
12
12
 
13
13
  describe('getSubnames', () => {
14
- it.todo('should get the subnames for a name')
15
- // it('should get the subnames for a name', async () => {
16
- // const result = await ensInstance.getSubnames({
17
- // name: 'with-profile.eth',
18
- // })
19
- // expect(result).toBeTruthy()
20
- // if (result) {
21
- // console.log(result)
22
- // expect(result.length).toBeGreaterThan(0)
23
- // testProperties(
24
- // result[0],
25
- // 'id',
26
- // 'labelName',
27
- // 'labelhash',
28
- // 'name',
29
- // 'isMigrated',
30
- // 'owner',
31
- // 'truncatedName',
32
- // )
33
- // }
34
- // })
14
+ it('should get the subnames for a name ordered by createdAt in desc order', async () => {
15
+ const result = await ensInstance.getSubnames({
16
+ name: 'with-subnames.eth',
17
+ pageSize: 10,
18
+ orderBy: 'createdAt',
19
+ orderDirection: 'desc',
20
+ })
21
+ expect(result).toBeTruthy()
22
+ expect(result.subnames.length).toBe(4)
23
+ expect(result.subnameCount).toBe(4)
24
+ expect(result.subnames[0].name).toEqual('addr.with-subnames.eth')
25
+ expect(result.subnames[1].name).toEqual('xyz.with-subnames.eth')
26
+ expect(result.subnames[2].name).toEqual('legacy.with-subnames.eth')
27
+ expect(result.subnames[3].name).toEqual('test.with-subnames.eth')
28
+ expect(
29
+ result.subnames.every((subname, i, arr) => {
30
+ if (arr[i + 1]) {
31
+ return (subname as any).createdAt >= (arr[i + 1] as any).createdAt
32
+ }
33
+ return true
34
+ }),
35
+ ).toBe(true)
36
+ testProperties(
37
+ result.subnames[0],
38
+ 'id',
39
+ 'labelName',
40
+ 'labelhash',
41
+ 'name',
42
+ 'isMigrated',
43
+ 'owner',
44
+ 'truncatedName',
45
+ )
46
+ })
47
+
48
+ it('should get the subnames for a name ordered by createdAt in asc order', async () => {
49
+ const result = await ensInstance.getSubnames({
50
+ name: 'with-subnames.eth',
51
+ pageSize: 10,
52
+ orderBy: 'createdAt',
53
+ orderDirection: 'asc',
54
+ })
55
+ expect(result).toBeTruthy()
56
+ expect(result.subnames.length).toBe(4)
57
+ expect(result.subnameCount).toBe(4)
58
+ expect(result.subnames[0].name).toEqual('test.with-subnames.eth')
59
+ expect(result.subnames[1].name).toEqual('legacy.with-subnames.eth')
60
+ expect(result.subnames[2].name).toEqual('xyz.with-subnames.eth')
61
+ expect(result.subnames[3].name).toEqual('addr.with-subnames.eth')
62
+ expect(
63
+ result.subnames.every((subname, i, arr) => {
64
+ if (arr[i + 1]) {
65
+ return (subname as any).createdAt <= (arr[i + 1] as any).createdAt
66
+ }
67
+ return true
68
+ }),
69
+ ).toBe(true)
70
+ testProperties(
71
+ result.subnames[0],
72
+ 'id',
73
+ 'labelName',
74
+ 'labelhash',
75
+ 'name',
76
+ 'isMigrated',
77
+ 'owner',
78
+ 'truncatedName',
79
+ )
80
+ })
81
+
82
+ it('should get the subnames for a name by labelName in desc order', async () => {
83
+ const result = await ensInstance.getSubnames({
84
+ name: 'with-subnames.eth',
85
+ pageSize: 10,
86
+ orderBy: 'labelName',
87
+ orderDirection: 'desc',
88
+ })
89
+ expect(result).toBeTruthy()
90
+ expect(result.subnames.length).toBe(4)
91
+ expect(result.subnameCount).toBe(4)
92
+ expect(result.subnames[0].name).toEqual('xyz.with-subnames.eth')
93
+ expect(result.subnames[1].name).toEqual('test.with-subnames.eth')
94
+ expect(result.subnames[2].name).toEqual('legacy.with-subnames.eth')
95
+ expect(result.subnames[3].name).toEqual('addr.with-subnames.eth')
96
+ testProperties(
97
+ result.subnames[0],
98
+ 'id',
99
+ 'labelName',
100
+ 'labelhash',
101
+ 'name',
102
+ 'isMigrated',
103
+ 'owner',
104
+ 'truncatedName',
105
+ )
106
+ })
107
+
108
+ it('should get the subnames for a name by labelName in asc order', async () => {
109
+ const result = await ensInstance.getSubnames({
110
+ name: 'with-subnames.eth',
111
+ pageSize: 10,
112
+ orderBy: 'labelName',
113
+ orderDirection: 'asc',
114
+ })
115
+ expect(result).toBeTruthy()
116
+ expect(result.subnames.length).toBe(4)
117
+ expect(result.subnameCount).toBe(4)
118
+ expect(result.subnames[0].name).toEqual('addr.with-subnames.eth')
119
+ expect(result.subnames[1].name).toEqual('legacy.with-subnames.eth')
120
+ expect(result.subnames[2].name).toEqual('test.with-subnames.eth')
121
+ expect(result.subnames[3].name).toEqual('xyz.with-subnames.eth')
122
+ testProperties(
123
+ result.subnames[0],
124
+ 'id',
125
+ 'labelName',
126
+ 'labelhash',
127
+ 'name',
128
+ 'isMigrated',
129
+ 'owner',
130
+ 'truncatedName',
131
+ )
132
+ })
133
+
134
+ describe('with pagination', () => {
135
+ it('should get paginated subnames for a name ordered by createdAt in desc order', async () => {
136
+ const result = await ensInstance.getSubnames({
137
+ name: 'with-subnames.eth',
138
+ pageSize: 2,
139
+ orderBy: 'createdAt',
140
+ orderDirection: 'desc',
141
+ })
142
+ expect(result).toBeTruthy()
143
+ expect(result.subnames.length).toBe(2)
144
+ expect(result.subnameCount).toBe(4)
145
+ expect(result.subnames[0].name).toEqual('addr.with-subnames.eth')
146
+ expect(result.subnames[1].name).toEqual('xyz.with-subnames.eth')
147
+ expect(
148
+ result.subnames.every((subname, i, arr) => {
149
+ if (arr[i + 1]) {
150
+ return (subname as any).createdAt >= (arr[i + 1] as any).createdAt
151
+ }
152
+ return true
153
+ }),
154
+ ).toBe(true)
155
+ testProperties(
156
+ result.subnames[0],
157
+ 'id',
158
+ 'labelName',
159
+ 'labelhash',
160
+ 'name',
161
+ 'isMigrated',
162
+ 'owner',
163
+ 'truncatedName',
164
+ )
165
+ const result2 = await ensInstance.getSubnames({
166
+ name: 'with-subnames.eth',
167
+ pageSize: 2,
168
+ orderBy: 'createdAt',
169
+ orderDirection: 'desc',
170
+ lastSubnames: result.subnames,
171
+ })
172
+ expect(result2).toBeTruthy()
173
+ expect(result2.subnames.length).toBe(2)
174
+ expect(result2.subnameCount).toBe(4)
175
+ expect(result2.subnames[0].name).toEqual('legacy.with-subnames.eth')
176
+ expect(result2.subnames[1].name).toEqual('test.with-subnames.eth')
177
+ expect(
178
+ result2.subnames.every((subname, i, arr) => {
179
+ if (arr[i + 1]) {
180
+ return (subname as any).createdAt >= (arr[i + 1] as any).createdAt
181
+ }
182
+ return true
183
+ }),
184
+ ).toBe(true)
185
+ testProperties(
186
+ result2.subnames[0],
187
+ 'id',
188
+ 'labelName',
189
+ 'labelhash',
190
+ 'name',
191
+ 'isMigrated',
192
+ 'owner',
193
+ 'truncatedName',
194
+ )
195
+ })
196
+
197
+ it('should get paginated subnames for a name ordered by createdAt in asc order', async () => {
198
+ const result = await ensInstance.getSubnames({
199
+ name: 'with-subnames.eth',
200
+ pageSize: 2,
201
+ orderBy: 'createdAt',
202
+ orderDirection: 'asc',
203
+ })
204
+ expect(result).toBeTruthy()
205
+ expect(result.subnames.length).toBe(2)
206
+ expect(result.subnameCount).toBe(4)
207
+ expect(result.subnames[0].name).toEqual('test.with-subnames.eth')
208
+ expect(result.subnames[1].name).toEqual('legacy.with-subnames.eth')
209
+ expect(
210
+ result.subnames.every((subname, i, arr) => {
211
+ if (arr[i + 1]) {
212
+ return (subname as any).createdAt <= (arr[i + 1] as any).createdAt
213
+ }
214
+ return true
215
+ }),
216
+ ).toBe(true)
217
+ testProperties(
218
+ result.subnames[0],
219
+ 'id',
220
+ 'labelName',
221
+ 'labelhash',
222
+ 'name',
223
+ 'isMigrated',
224
+ 'owner',
225
+ 'truncatedName',
226
+ )
227
+ const result2 = await ensInstance.getSubnames({
228
+ name: 'with-subnames.eth',
229
+ page: 0,
230
+ pageSize: 2,
231
+ orderBy: 'createdAt',
232
+ orderDirection: 'asc',
233
+ lastSubnames: result.subnames,
234
+ })
235
+
236
+ expect(result2).toBeTruthy()
237
+ expect(result2.subnames.length).toBe(2)
238
+ expect(result2.subnameCount).toBe(4)
239
+ expect(result2.subnames[0].name).toEqual('xyz.with-subnames.eth')
240
+ expect(result2.subnames[1].name).toEqual('addr.with-subnames.eth')
241
+ expect(
242
+ result2.subnames.every((subname, i, arr) => {
243
+ if (arr[i + 1]) {
244
+ return (subname as any).createdAt <= (arr[i + 1] as any).createdAt
245
+ }
246
+ return true
247
+ }),
248
+ ).toBe(true)
249
+ testProperties(
250
+ result2.subnames[0],
251
+ 'id',
252
+ 'labelName',
253
+ 'labelhash',
254
+ 'name',
255
+ 'isMigrated',
256
+ 'owner',
257
+ 'truncatedName',
258
+ )
259
+ })
260
+
261
+ it('should get paginated subnames for a name by labelName in desc order', async () => {
262
+ const result = await ensInstance.getSubnames({
263
+ name: 'with-subnames.eth',
264
+ pageSize: 2,
265
+ orderBy: 'labelName',
266
+ orderDirection: 'desc',
267
+ })
268
+ expect(result).toBeTruthy()
269
+ expect(result.subnames.length).toBe(2)
270
+ expect(result.subnameCount).toBe(4)
271
+ expect(result.subnames[0].name).toEqual('xyz.with-subnames.eth')
272
+ expect(result.subnames[1].name).toEqual('test.with-subnames.eth')
273
+ testProperties(
274
+ result.subnames[0],
275
+ 'id',
276
+ 'labelName',
277
+ 'labelhash',
278
+ 'name',
279
+ 'isMigrated',
280
+ 'owner',
281
+ 'truncatedName',
282
+ )
283
+ const result2 = await ensInstance.getSubnames({
284
+ name: 'with-subnames.eth',
285
+ pageSize: 2,
286
+ orderBy: 'labelName',
287
+ orderDirection: 'desc',
288
+ lastSubnames: result.subnames,
289
+ })
290
+ expect(result2).toBeTruthy()
291
+ expect(result2.subnames.length).toBe(2)
292
+ expect(result2.subnameCount).toBe(4)
293
+ expect(result2.subnames[0].name).toEqual('legacy.with-subnames.eth')
294
+ expect(result2.subnames[1].name).toEqual('addr.with-subnames.eth')
295
+ testProperties(
296
+ result.subnames[0],
297
+ 'id',
298
+ 'labelName',
299
+ 'labelhash',
300
+ 'name',
301
+ 'isMigrated',
302
+ 'owner',
303
+ 'truncatedName',
304
+ )
305
+ })
306
+
307
+ it('should get paginated subnames for a name by labelName in asc order', async () => {
308
+ const result = await ensInstance.getSubnames({
309
+ name: 'with-subnames.eth',
310
+ pageSize: 2,
311
+ orderBy: 'labelName',
312
+ orderDirection: 'asc',
313
+ })
314
+ expect(result).toBeTruthy()
315
+ expect(result.subnames.length).toBe(2)
316
+ expect(result.subnameCount).toBe(4)
317
+ expect(result.subnames[0].name).toEqual('addr.with-subnames.eth')
318
+ expect(result.subnames[1].name).toEqual('legacy.with-subnames.eth')
319
+
320
+ testProperties(
321
+ result.subnames[0],
322
+ 'id',
323
+ 'labelName',
324
+ 'labelhash',
325
+ 'name',
326
+ 'isMigrated',
327
+ 'owner',
328
+ 'truncatedName',
329
+ )
330
+
331
+ const result2 = await ensInstance.getSubnames({
332
+ name: 'with-subnames.eth',
333
+ pageSize: 2,
334
+ orderBy: 'labelName',
335
+ orderDirection: 'asc',
336
+ lastSubnames: result.subnames,
337
+ })
338
+ expect(result2).toBeTruthy()
339
+ expect(result2.subnames.length).toBe(2)
340
+ expect(result2.subnameCount).toBe(4)
341
+ expect(result2.subnames[0].name).toEqual('test.with-subnames.eth')
342
+ expect(result2.subnames[1].name).toEqual('xyz.with-subnames.eth')
343
+
344
+ testProperties(
345
+ result2.subnames[0],
346
+ 'id',
347
+ 'labelName',
348
+ 'labelhash',
349
+ 'name',
350
+ 'isMigrated',
351
+ 'owner',
352
+ 'truncatedName',
353
+ )
354
+ })
355
+ })
356
+
357
+ describe('With search query', () => {
358
+ it('should get the searched subnames for a name ordered by createdAt in desc order', async () => {
359
+ const result = await ensInstance.getSubnames({
360
+ name: 'with-subnames.eth',
361
+ pageSize: 10,
362
+ orderBy: 'createdAt',
363
+ orderDirection: 'desc',
364
+ search: 'a',
365
+ })
366
+ expect(result).toBeTruthy()
367
+ expect(result.subnames.length).toBe(2)
368
+ expect(result.subnameCount).toBe(4)
369
+ expect(result.subnames[0].name).toEqual('addr.with-subnames.eth')
370
+ expect(result.subnames[1].name).toEqual('legacy.with-subnames.eth')
371
+ expect(
372
+ result.subnames.every((subname, i, arr) => {
373
+ if (arr[i + 1]) {
374
+ return (subname as any).createdAt >= (arr[i + 1] as any).createdAt
375
+ }
376
+ return true
377
+ }),
378
+ ).toBe(true)
379
+ testProperties(
380
+ result.subnames[0],
381
+ 'id',
382
+ 'labelName',
383
+ 'labelhash',
384
+ 'name',
385
+ 'isMigrated',
386
+ 'owner',
387
+ 'truncatedName',
388
+ )
389
+ })
390
+
391
+ it('should get the searched subnames for a name ordered by createdAt in asc order', async () => {
392
+ const result = await ensInstance.getSubnames({
393
+ name: 'with-subnames.eth',
394
+ page: 0,
395
+ pageSize: 10,
396
+ orderBy: 'createdAt',
397
+ orderDirection: 'asc',
398
+ search: 'a',
399
+ })
400
+ expect(result).toBeTruthy()
401
+ expect(result.subnames.length).toBe(2)
402
+ expect(result.subnameCount).toBe(4)
403
+ expect(result.subnames[0].name).toEqual('legacy.with-subnames.eth')
404
+ expect(result.subnames[1].name).toEqual('addr.with-subnames.eth')
405
+ expect(
406
+ result.subnames.every((subname, i, arr) => {
407
+ if (arr[i + 1]) {
408
+ return (subname as any).createdAt <= (arr[i + 1] as any).createdAt
409
+ }
410
+ return true
411
+ }),
412
+ ).toBe(true)
413
+ testProperties(
414
+ result.subnames[0],
415
+ 'id',
416
+ 'labelName',
417
+ 'labelhash',
418
+ 'name',
419
+ 'isMigrated',
420
+ 'owner',
421
+ 'truncatedName',
422
+ )
423
+ })
424
+
425
+ it('should get the subnames for a name by labelName in desc order', async () => {
426
+ const result = await ensInstance.getSubnames({
427
+ name: 'with-subnames.eth',
428
+ pageSize: 10,
429
+ orderBy: 'labelName',
430
+ orderDirection: 'desc',
431
+ search: 'a',
432
+ })
433
+ expect(result).toBeTruthy()
434
+ expect(result.subnames.length).toBe(2)
435
+ expect(result.subnameCount).toBe(4)
436
+ expect(result.subnames[0].name).toEqual('legacy.with-subnames.eth')
437
+ expect(result.subnames[1].name).toEqual('addr.with-subnames.eth')
438
+ testProperties(
439
+ result.subnames[0],
440
+ 'id',
441
+ 'labelName',
442
+ 'labelhash',
443
+ 'name',
444
+ 'isMigrated',
445
+ 'owner',
446
+ 'truncatedName',
447
+ )
448
+ })
449
+
450
+ it('should get the subnames for a name by labelName in asc order', async () => {
451
+ const result = await ensInstance.getSubnames({
452
+ name: 'with-subnames.eth',
453
+ pageSize: 10,
454
+ orderBy: 'labelName',
455
+ orderDirection: 'asc',
456
+ search: 'a',
457
+ })
458
+ expect(result).toBeTruthy()
459
+ expect(result.subnames.length).toBe(2)
460
+ expect(result.subnameCount).toBe(4)
461
+ expect(result.subnames[0].name).toEqual('addr.with-subnames.eth')
462
+ expect(result.subnames[1].name).toEqual('legacy.with-subnames.eth')
463
+ testProperties(
464
+ result.subnames[0],
465
+ 'id',
466
+ 'labelName',
467
+ 'labelhash',
468
+ 'name',
469
+ 'isMigrated',
470
+ 'owner',
471
+ 'truncatedName',
472
+ )
473
+ })
474
+ })
475
+
476
+ describe('with search query and pagination', () => {
477
+ it('should get paginated subnames for a name ordered by createdAt in desc order', async () => {
478
+ const result = await ensInstance.getSubnames({
479
+ name: 'with-subnames.eth',
480
+ pageSize: 1,
481
+ orderBy: 'createdAt',
482
+ orderDirection: 'desc',
483
+ search: 'a',
484
+ })
485
+ expect(result).toBeTruthy()
486
+ expect(result.subnames.length).toBe(1)
487
+ expect(result.subnameCount).toBe(4)
488
+ expect(result.subnames[0].name).toEqual('addr.with-subnames.eth')
489
+ testProperties(
490
+ result.subnames[0],
491
+ 'id',
492
+ 'labelName',
493
+ 'labelhash',
494
+ 'name',
495
+ 'isMigrated',
496
+ 'owner',
497
+ 'truncatedName',
498
+ )
499
+ const result2 = await ensInstance.getSubnames({
500
+ name: 'with-subnames.eth',
501
+ pageSize: 1,
502
+ orderBy: 'createdAt',
503
+ orderDirection: 'desc',
504
+ lastSubnames: result.subnames,
505
+ search: 'a',
506
+ })
507
+ expect(result2).toBeTruthy()
508
+ expect(result2.subnames.length).toBe(1)
509
+ expect(result2.subnameCount).toBe(4)
510
+ expect(result2.subnames[0].name).toEqual('legacy.with-subnames.eth')
511
+ testProperties(
512
+ result2.subnames[0],
513
+ 'id',
514
+ 'labelName',
515
+ 'labelhash',
516
+ 'name',
517
+ 'isMigrated',
518
+ 'owner',
519
+ 'truncatedName',
520
+ )
521
+ })
522
+
523
+ it('should get paginated subnames for a name ordered by createdAt in asc order', async () => {
524
+ const result = await ensInstance.getSubnames({
525
+ name: 'with-subnames.eth',
526
+ pageSize: 1,
527
+ orderBy: 'createdAt',
528
+ orderDirection: 'asc',
529
+ search: 'a',
530
+ })
531
+ expect(result).toBeTruthy()
532
+ expect(result.subnames.length).toBe(1)
533
+ expect(result.subnameCount).toBe(4)
534
+ expect(result.subnames[0].name).toEqual('legacy.with-subnames.eth')
535
+ expect(
536
+ result.subnames.every((subname, i, arr) => {
537
+ if (arr[i + 1]) {
538
+ return (subname as any).createdAt <= (arr[i + 1] as any).createdAt
539
+ }
540
+ return true
541
+ }),
542
+ ).toBe(true)
543
+ testProperties(
544
+ result.subnames[0],
545
+ 'id',
546
+ 'labelName',
547
+ 'labelhash',
548
+ 'name',
549
+ 'isMigrated',
550
+ 'owner',
551
+ 'truncatedName',
552
+ )
553
+ const result2 = await ensInstance.getSubnames({
554
+ name: 'with-subnames.eth',
555
+ page: 0,
556
+ pageSize: 2,
557
+ orderBy: 'createdAt',
558
+ orderDirection: 'asc',
559
+ lastSubnames: result.subnames,
560
+ search: 'a',
561
+ })
562
+
563
+ expect(result2).toBeTruthy()
564
+ expect(result2.subnames.length).toBe(1)
565
+ expect(result2.subnameCount).toBe(4)
566
+ expect(result2.subnames[0].name).toEqual('addr.with-subnames.eth')
567
+
568
+ testProperties(
569
+ result2.subnames[0],
570
+ 'id',
571
+ 'labelName',
572
+ 'labelhash',
573
+ 'name',
574
+ 'isMigrated',
575
+ 'owner',
576
+ 'truncatedName',
577
+ )
578
+ })
579
+
580
+ it('should get paginated subnames for a name by labelName in desc order', async () => {
581
+ const result = await ensInstance.getSubnames({
582
+ name: 'with-subnames.eth',
583
+ pageSize: 1,
584
+ orderBy: 'labelName',
585
+ orderDirection: 'desc',
586
+ search: 'a',
587
+ })
588
+ expect(result).toBeTruthy()
589
+ expect(result.subnames.length).toBe(1)
590
+ expect(result.subnameCount).toBe(4)
591
+ expect(result.subnames[0].name).toEqual('legacy.with-subnames.eth')
592
+ testProperties(
593
+ result.subnames[0],
594
+ 'id',
595
+ 'labelName',
596
+ 'labelhash',
597
+ 'name',
598
+ 'isMigrated',
599
+ 'owner',
600
+ 'truncatedName',
601
+ )
602
+ const result2 = await ensInstance.getSubnames({
603
+ name: 'with-subnames.eth',
604
+ pageSize: 1,
605
+ orderBy: 'labelName',
606
+ orderDirection: 'desc',
607
+ lastSubnames: result.subnames,
608
+ search: 'a',
609
+ })
610
+ expect(result2).toBeTruthy()
611
+ expect(result2.subnames.length).toBe(1)
612
+ expect(result2.subnameCount).toBe(4)
613
+ expect(result2.subnames[0].name).toEqual('addr.with-subnames.eth')
614
+ testProperties(
615
+ result.subnames[0],
616
+ 'id',
617
+ 'labelName',
618
+ 'labelhash',
619
+ 'name',
620
+ 'isMigrated',
621
+ 'owner',
622
+ 'truncatedName',
623
+ )
624
+ })
625
+
626
+ it('should get paginated subnames for a name by labelName in asc order', async () => {
627
+ const result = await ensInstance.getSubnames({
628
+ name: 'with-subnames.eth',
629
+ pageSize: 1,
630
+ orderBy: 'labelName',
631
+ orderDirection: 'asc',
632
+ search: 'a',
633
+ })
634
+ expect(result).toBeTruthy()
635
+ expect(result.subnames.length).toBe(1)
636
+ expect(result.subnameCount).toBe(4)
637
+ expect(result.subnames[0].name).toEqual('addr.with-subnames.eth')
638
+
639
+ testProperties(
640
+ result.subnames[0],
641
+ 'id',
642
+ 'labelName',
643
+ 'labelhash',
644
+ 'name',
645
+ 'isMigrated',
646
+ 'owner',
647
+ 'truncatedName',
648
+ )
649
+
650
+ const result2 = await ensInstance.getSubnames({
651
+ name: 'with-subnames.eth',
652
+ pageSize: 1,
653
+ orderBy: 'labelName',
654
+ orderDirection: 'asc',
655
+ lastSubnames: result.subnames,
656
+ search: 'a',
657
+ })
658
+ expect(result2).toBeTruthy()
659
+ expect(result2.subnames.length).toBe(1)
660
+ expect(result2.subnameCount).toBe(4)
661
+ expect(result2.subnames[0].name).toEqual('legacy.with-subnames.eth')
662
+
663
+ testProperties(
664
+ result2.subnames[0],
665
+ 'id',
666
+ 'labelName',
667
+ 'labelhash',
668
+ 'name',
669
+ 'isMigrated',
670
+ 'owner',
671
+ 'truncatedName',
672
+ )
673
+ })
674
+ })
35
675
  })