@ensdomains/ensjs 3.0.0-alpha.46 → 3.0.0-alpha.47
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/deleteSubname.js +17 -7
- package/dist/cjs/functions/transferSubname.js +4 -9
- package/dist/cjs/index.js +1 -1
- package/dist/cjs/utils/registry.js +32 -0
- package/dist/cjs/utils/wrapper.js +14 -9
- package/dist/esm/functions/deleteSubname.mjs +17 -7
- package/dist/esm/functions/transferSubname.mjs +5 -10
- package/dist/esm/index.mjs +1 -1
- package/dist/esm/utils/registry.mjs +13 -0
- package/dist/esm/utils/wrapper.mjs +14 -9
- package/dist/types/functions/deleteSubname.d.ts +8 -2
- package/dist/types/functions/transferSubname.d.ts +1 -1
- package/dist/types/utils/registry.d.ts +2 -0
- package/dist/types/utils/wrapper.d.ts +1 -0
- package/package.json +1 -1
- package/src/functions/deleteSubname.test.ts +139 -6
- package/src/functions/deleteSubname.ts +28 -11
- package/src/functions/getNames.test.ts +11 -1
- package/src/functions/getSubnames.test.ts +1178 -324
- package/src/functions/getWrapperData.test.ts +0 -1
- package/src/functions/transferSubname.test.ts +120 -18
- package/src/functions/transferSubname.ts +5 -10
- package/src/index.ts +1 -1
- package/src/utils/registry.ts +14 -0
- package/src/utils/wrapper.ts +12 -9
|
@@ -141,8 +141,8 @@ describe('getSubnames', () => {
|
|
|
141
141
|
})
|
|
142
142
|
|
|
143
143
|
expect(result).toBeTruthy()
|
|
144
|
-
expect(result.subnames.length).toBe(
|
|
145
|
-
expect(result.subnameCount).toBe(
|
|
144
|
+
expect(result.subnames.length).toBe(4)
|
|
145
|
+
expect(result.subnameCount).toBe(4)
|
|
146
146
|
expect(result.subnames[0].fuses).toBeDefined()
|
|
147
147
|
})
|
|
148
148
|
it('should return expiry as undefined if 0', async () => {
|
|
@@ -186,15 +186,17 @@ describe('getSubnames', () => {
|
|
|
186
186
|
it('should get paginated subnames for a name ordered by createdAt in desc order', async () => {
|
|
187
187
|
const result = await ensInstance.getSubnames({
|
|
188
188
|
name: 'with-subnames.eth',
|
|
189
|
-
pageSize:
|
|
189
|
+
pageSize: 10,
|
|
190
190
|
orderBy: 'createdAt',
|
|
191
191
|
orderDirection: 'desc',
|
|
192
192
|
})
|
|
193
193
|
expect(result).toBeTruthy()
|
|
194
|
-
expect(result.subnames.length).toBe(
|
|
194
|
+
expect(result.subnames.length).toBe(4)
|
|
195
195
|
expect(result.subnameCount).toBe(4)
|
|
196
196
|
expect(result.subnames[0].name).toEqual('addr.with-subnames.eth')
|
|
197
197
|
expect(result.subnames[1].name).toEqual('xyz.with-subnames.eth')
|
|
198
|
+
expect(result.subnames[2].name).toEqual('legacy.with-subnames.eth')
|
|
199
|
+
expect(result.subnames[3].name).toEqual('test.with-subnames.eth')
|
|
198
200
|
expect(
|
|
199
201
|
result.subnames.every((subname, i, arr) => {
|
|
200
202
|
if (arr[i + 1]) {
|
|
@@ -213,50 +215,22 @@ describe('getSubnames', () => {
|
|
|
213
215
|
'owner',
|
|
214
216
|
'truncatedName',
|
|
215
217
|
)
|
|
216
|
-
const result2 = await ensInstance.getSubnames({
|
|
217
|
-
name: 'with-subnames.eth',
|
|
218
|
-
pageSize: 2,
|
|
219
|
-
orderBy: 'createdAt',
|
|
220
|
-
orderDirection: 'desc',
|
|
221
|
-
lastSubnames: result.subnames,
|
|
222
|
-
})
|
|
223
|
-
expect(result2).toBeTruthy()
|
|
224
|
-
expect(result2.subnames.length).toBe(2)
|
|
225
|
-
expect(result2.subnameCount).toBe(4)
|
|
226
|
-
expect(result2.subnames[0].name).toEqual('legacy.with-subnames.eth')
|
|
227
|
-
expect(result2.subnames[1].name).toEqual('test.with-subnames.eth')
|
|
228
|
-
expect(
|
|
229
|
-
result2.subnames.every((subname, i, arr) => {
|
|
230
|
-
if (arr[i + 1]) {
|
|
231
|
-
return (subname as any).createdAt >= (arr[i + 1] as any).createdAt
|
|
232
|
-
}
|
|
233
|
-
return true
|
|
234
|
-
}),
|
|
235
|
-
).toBe(true)
|
|
236
|
-
testProperties(
|
|
237
|
-
result2.subnames[0],
|
|
238
|
-
'id',
|
|
239
|
-
'labelName',
|
|
240
|
-
'labelhash',
|
|
241
|
-
'name',
|
|
242
|
-
'isMigrated',
|
|
243
|
-
'owner',
|
|
244
|
-
'truncatedName',
|
|
245
|
-
)
|
|
246
218
|
})
|
|
247
219
|
|
|
248
|
-
it('should get
|
|
220
|
+
it('should get the subnames for a name ordered by createdAt in asc order', async () => {
|
|
249
221
|
const result = await ensInstance.getSubnames({
|
|
250
222
|
name: 'with-subnames.eth',
|
|
251
|
-
pageSize:
|
|
223
|
+
pageSize: 10,
|
|
252
224
|
orderBy: 'createdAt',
|
|
253
225
|
orderDirection: 'asc',
|
|
254
226
|
})
|
|
255
227
|
expect(result).toBeTruthy()
|
|
256
|
-
expect(result.subnames.length).toBe(
|
|
228
|
+
expect(result.subnames.length).toBe(4)
|
|
257
229
|
expect(result.subnameCount).toBe(4)
|
|
258
230
|
expect(result.subnames[0].name).toEqual('test.with-subnames.eth')
|
|
259
231
|
expect(result.subnames[1].name).toEqual('legacy.with-subnames.eth')
|
|
232
|
+
expect(result.subnames[2].name).toEqual('xyz.with-subnames.eth')
|
|
233
|
+
expect(result.subnames[3].name).toEqual('addr.with-subnames.eth')
|
|
260
234
|
expect(
|
|
261
235
|
result.subnames.every((subname, i, arr) => {
|
|
262
236
|
if (arr[i + 1]) {
|
|
@@ -275,74 +249,22 @@ describe('getSubnames', () => {
|
|
|
275
249
|
'owner',
|
|
276
250
|
'truncatedName',
|
|
277
251
|
)
|
|
278
|
-
const result2 = await ensInstance.getSubnames({
|
|
279
|
-
name: 'with-subnames.eth',
|
|
280
|
-
page: 0,
|
|
281
|
-
pageSize: 2,
|
|
282
|
-
orderBy: 'createdAt',
|
|
283
|
-
orderDirection: 'asc',
|
|
284
|
-
lastSubnames: result.subnames,
|
|
285
|
-
})
|
|
286
|
-
|
|
287
|
-
expect(result2).toBeTruthy()
|
|
288
|
-
expect(result2.subnames.length).toBe(2)
|
|
289
|
-
expect(result2.subnameCount).toBe(4)
|
|
290
|
-
expect(result2.subnames[0].name).toEqual('xyz.with-subnames.eth')
|
|
291
|
-
expect(result2.subnames[1].name).toEqual('addr.with-subnames.eth')
|
|
292
|
-
expect(
|
|
293
|
-
result2.subnames.every((subname, i, arr) => {
|
|
294
|
-
if (arr[i + 1]) {
|
|
295
|
-
return (subname as any).createdAt <= (arr[i + 1] as any).createdAt
|
|
296
|
-
}
|
|
297
|
-
return true
|
|
298
|
-
}),
|
|
299
|
-
).toBe(true)
|
|
300
|
-
testProperties(
|
|
301
|
-
result2.subnames[0],
|
|
302
|
-
'id',
|
|
303
|
-
'labelName',
|
|
304
|
-
'labelhash',
|
|
305
|
-
'name',
|
|
306
|
-
'isMigrated',
|
|
307
|
-
'owner',
|
|
308
|
-
'truncatedName',
|
|
309
|
-
)
|
|
310
252
|
})
|
|
311
253
|
|
|
312
|
-
it('should get
|
|
254
|
+
it('should get the subnames for a name by labelName in desc order', async () => {
|
|
313
255
|
const result = await ensInstance.getSubnames({
|
|
314
256
|
name: 'with-subnames.eth',
|
|
315
|
-
pageSize:
|
|
257
|
+
pageSize: 10,
|
|
316
258
|
orderBy: 'labelName',
|
|
317
259
|
orderDirection: 'desc',
|
|
318
260
|
})
|
|
319
261
|
expect(result).toBeTruthy()
|
|
320
|
-
expect(result.subnames.length).toBe(
|
|
262
|
+
expect(result.subnames.length).toBe(4)
|
|
321
263
|
expect(result.subnameCount).toBe(4)
|
|
322
264
|
expect(result.subnames[0].name).toEqual('xyz.with-subnames.eth')
|
|
323
265
|
expect(result.subnames[1].name).toEqual('test.with-subnames.eth')
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
'id',
|
|
327
|
-
'labelName',
|
|
328
|
-
'labelhash',
|
|
329
|
-
'name',
|
|
330
|
-
'isMigrated',
|
|
331
|
-
'owner',
|
|
332
|
-
'truncatedName',
|
|
333
|
-
)
|
|
334
|
-
const result2 = await ensInstance.getSubnames({
|
|
335
|
-
name: 'with-subnames.eth',
|
|
336
|
-
pageSize: 2,
|
|
337
|
-
orderBy: 'labelName',
|
|
338
|
-
orderDirection: 'desc',
|
|
339
|
-
lastSubnames: result.subnames,
|
|
340
|
-
})
|
|
341
|
-
expect(result2).toBeTruthy()
|
|
342
|
-
expect(result2.subnames.length).toBe(2)
|
|
343
|
-
expect(result2.subnameCount).toBe(4)
|
|
344
|
-
expect(result2.subnames[0].name).toEqual('legacy.with-subnames.eth')
|
|
345
|
-
expect(result2.subnames[1].name).toEqual('addr.with-subnames.eth')
|
|
266
|
+
expect(result.subnames[2].name).toEqual('legacy.with-subnames.eth')
|
|
267
|
+
expect(result.subnames[3].name).toEqual('addr.with-subnames.eth')
|
|
346
268
|
testProperties(
|
|
347
269
|
result.subnames[0],
|
|
348
270
|
'id',
|
|
@@ -355,19 +277,20 @@ describe('getSubnames', () => {
|
|
|
355
277
|
)
|
|
356
278
|
})
|
|
357
279
|
|
|
358
|
-
it('should get
|
|
280
|
+
it('should get the subnames for a name by labelName in asc order', async () => {
|
|
359
281
|
const result = await ensInstance.getSubnames({
|
|
360
282
|
name: 'with-subnames.eth',
|
|
361
|
-
pageSize:
|
|
283
|
+
pageSize: 10,
|
|
362
284
|
orderBy: 'labelName',
|
|
363
285
|
orderDirection: 'asc',
|
|
364
286
|
})
|
|
365
287
|
expect(result).toBeTruthy()
|
|
366
|
-
expect(result.subnames.length).toBe(
|
|
288
|
+
expect(result.subnames.length).toBe(4)
|
|
367
289
|
expect(result.subnameCount).toBe(4)
|
|
368
290
|
expect(result.subnames[0].name).toEqual('addr.with-subnames.eth')
|
|
369
291
|
expect(result.subnames[1].name).toEqual('legacy.with-subnames.eth')
|
|
370
|
-
|
|
292
|
+
expect(result.subnames[2].name).toEqual('test.with-subnames.eth')
|
|
293
|
+
expect(result.subnames[3].name).toEqual('xyz.with-subnames.eth')
|
|
371
294
|
testProperties(
|
|
372
295
|
result.subnames[0],
|
|
373
296
|
'id',
|
|
@@ -378,47 +301,568 @@ describe('getSubnames', () => {
|
|
|
378
301
|
'owner',
|
|
379
302
|
'truncatedName',
|
|
380
303
|
)
|
|
304
|
+
})
|
|
381
305
|
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
306
|
+
describe('with pagination', () => {
|
|
307
|
+
it('should get paginated subnames for a name ordered by createdAt in desc order', async () => {
|
|
308
|
+
const result = await ensInstance.getSubnames({
|
|
309
|
+
name: 'with-subnames.eth',
|
|
310
|
+
pageSize: 2,
|
|
311
|
+
orderBy: 'createdAt',
|
|
312
|
+
orderDirection: 'desc',
|
|
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('xyz.with-subnames.eth')
|
|
319
|
+
expect(
|
|
320
|
+
result.subnames.every((subname, i, arr) => {
|
|
321
|
+
if (arr[i + 1]) {
|
|
322
|
+
return (subname as any).createdAt >= (arr[i + 1] as any).createdAt
|
|
323
|
+
}
|
|
324
|
+
return true
|
|
325
|
+
}),
|
|
326
|
+
).toBe(true)
|
|
327
|
+
testProperties(
|
|
328
|
+
result.subnames[0],
|
|
329
|
+
'id',
|
|
330
|
+
'labelName',
|
|
331
|
+
'labelhash',
|
|
332
|
+
'name',
|
|
333
|
+
'isMigrated',
|
|
334
|
+
'owner',
|
|
335
|
+
'truncatedName',
|
|
336
|
+
)
|
|
337
|
+
const result2 = await ensInstance.getSubnames({
|
|
338
|
+
name: 'with-subnames.eth',
|
|
339
|
+
pageSize: 2,
|
|
340
|
+
orderBy: 'createdAt',
|
|
341
|
+
orderDirection: 'desc',
|
|
342
|
+
lastSubnames: result.subnames,
|
|
343
|
+
})
|
|
344
|
+
expect(result2).toBeTruthy()
|
|
345
|
+
expect(result2.subnames.length).toBe(2)
|
|
346
|
+
expect(result2.subnameCount).toBe(4)
|
|
347
|
+
expect(result2.subnames[0].name).toEqual('legacy.with-subnames.eth')
|
|
348
|
+
expect(result2.subnames[1].name).toEqual('test.with-subnames.eth')
|
|
349
|
+
expect(
|
|
350
|
+
result2.subnames.every((subname, i, arr) => {
|
|
351
|
+
if (arr[i + 1]) {
|
|
352
|
+
return (subname as any).createdAt >= (arr[i + 1] as any).createdAt
|
|
353
|
+
}
|
|
354
|
+
return true
|
|
355
|
+
}),
|
|
356
|
+
).toBe(true)
|
|
357
|
+
testProperties(
|
|
358
|
+
result2.subnames[0],
|
|
359
|
+
'id',
|
|
360
|
+
'labelName',
|
|
361
|
+
'labelhash',
|
|
362
|
+
'name',
|
|
363
|
+
'isMigrated',
|
|
364
|
+
'owner',
|
|
365
|
+
'truncatedName',
|
|
366
|
+
)
|
|
388
367
|
})
|
|
389
|
-
expect(result2).toBeTruthy()
|
|
390
|
-
expect(result2.subnames.length).toBe(2)
|
|
391
|
-
expect(result2.subnameCount).toBe(4)
|
|
392
|
-
expect(result2.subnames[0].name).toEqual('test.with-subnames.eth')
|
|
393
|
-
expect(result2.subnames[1].name).toEqual('xyz.with-subnames.eth')
|
|
394
368
|
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
369
|
+
it('should get paginated subnames for a name ordered by createdAt in asc order', async () => {
|
|
370
|
+
const result = await ensInstance.getSubnames({
|
|
371
|
+
name: 'with-subnames.eth',
|
|
372
|
+
pageSize: 2,
|
|
373
|
+
orderBy: 'createdAt',
|
|
374
|
+
orderDirection: 'asc',
|
|
375
|
+
})
|
|
376
|
+
expect(result).toBeTruthy()
|
|
377
|
+
expect(result.subnames.length).toBe(2)
|
|
378
|
+
expect(result.subnameCount).toBe(4)
|
|
379
|
+
expect(result.subnames[0].name).toEqual('test.with-subnames.eth')
|
|
380
|
+
expect(result.subnames[1].name).toEqual('legacy.with-subnames.eth')
|
|
381
|
+
expect(
|
|
382
|
+
result.subnames.every((subname, i, arr) => {
|
|
383
|
+
if (arr[i + 1]) {
|
|
384
|
+
return (subname as any).createdAt <= (arr[i + 1] as any).createdAt
|
|
385
|
+
}
|
|
386
|
+
return true
|
|
387
|
+
}),
|
|
388
|
+
).toBe(true)
|
|
389
|
+
testProperties(
|
|
390
|
+
result.subnames[0],
|
|
391
|
+
'id',
|
|
392
|
+
'labelName',
|
|
393
|
+
'labelhash',
|
|
394
|
+
'name',
|
|
395
|
+
'isMigrated',
|
|
396
|
+
'owner',
|
|
397
|
+
'truncatedName',
|
|
398
|
+
)
|
|
399
|
+
const result2 = await ensInstance.getSubnames({
|
|
400
|
+
name: 'with-subnames.eth',
|
|
401
|
+
page: 0,
|
|
402
|
+
pageSize: 2,
|
|
403
|
+
orderBy: 'createdAt',
|
|
404
|
+
orderDirection: 'asc',
|
|
405
|
+
lastSubnames: result.subnames,
|
|
406
|
+
})
|
|
407
|
+
|
|
408
|
+
expect(result2).toBeTruthy()
|
|
409
|
+
expect(result2.subnames.length).toBe(2)
|
|
410
|
+
expect(result2.subnameCount).toBe(4)
|
|
411
|
+
expect(result2.subnames[0].name).toEqual('xyz.with-subnames.eth')
|
|
412
|
+
expect(result2.subnames[1].name).toEqual('addr.with-subnames.eth')
|
|
413
|
+
expect(
|
|
414
|
+
result2.subnames.every((subname, i, arr) => {
|
|
415
|
+
if (arr[i + 1]) {
|
|
416
|
+
return (subname as any).createdAt <= (arr[i + 1] as any).createdAt
|
|
417
|
+
}
|
|
418
|
+
return true
|
|
419
|
+
}),
|
|
420
|
+
).toBe(true)
|
|
421
|
+
testProperties(
|
|
422
|
+
result2.subnames[0],
|
|
423
|
+
'id',
|
|
424
|
+
'labelName',
|
|
425
|
+
'labelhash',
|
|
426
|
+
'name',
|
|
427
|
+
'isMigrated',
|
|
428
|
+
'owner',
|
|
429
|
+
'truncatedName',
|
|
430
|
+
)
|
|
431
|
+
})
|
|
432
|
+
|
|
433
|
+
it('should get paginated subnames for a name by labelName in desc order', async () => {
|
|
434
|
+
const result = await ensInstance.getSubnames({
|
|
435
|
+
name: 'with-subnames.eth',
|
|
436
|
+
pageSize: 2,
|
|
437
|
+
orderBy: 'labelName',
|
|
438
|
+
orderDirection: 'desc',
|
|
439
|
+
})
|
|
440
|
+
expect(result).toBeTruthy()
|
|
441
|
+
expect(result.subnames.length).toBe(2)
|
|
442
|
+
expect(result.subnameCount).toBe(4)
|
|
443
|
+
expect(result.subnames[0].name).toEqual('xyz.with-subnames.eth')
|
|
444
|
+
expect(result.subnames[1].name).toEqual('test.with-subnames.eth')
|
|
445
|
+
testProperties(
|
|
446
|
+
result.subnames[0],
|
|
447
|
+
'id',
|
|
448
|
+
'labelName',
|
|
449
|
+
'labelhash',
|
|
450
|
+
'name',
|
|
451
|
+
'isMigrated',
|
|
452
|
+
'owner',
|
|
453
|
+
'truncatedName',
|
|
454
|
+
)
|
|
455
|
+
const result2 = await ensInstance.getSubnames({
|
|
456
|
+
name: 'with-subnames.eth',
|
|
457
|
+
pageSize: 2,
|
|
458
|
+
orderBy: 'labelName',
|
|
459
|
+
orderDirection: 'desc',
|
|
460
|
+
lastSubnames: result.subnames,
|
|
461
|
+
})
|
|
462
|
+
expect(result2).toBeTruthy()
|
|
463
|
+
expect(result2.subnames.length).toBe(2)
|
|
464
|
+
expect(result2.subnameCount).toBe(4)
|
|
465
|
+
expect(result2.subnames[0].name).toEqual('legacy.with-subnames.eth')
|
|
466
|
+
expect(result2.subnames[1].name).toEqual('addr.with-subnames.eth')
|
|
467
|
+
testProperties(
|
|
468
|
+
result.subnames[0],
|
|
469
|
+
'id',
|
|
470
|
+
'labelName',
|
|
471
|
+
'labelhash',
|
|
472
|
+
'name',
|
|
473
|
+
'isMigrated',
|
|
474
|
+
'owner',
|
|
475
|
+
'truncatedName',
|
|
476
|
+
)
|
|
477
|
+
})
|
|
478
|
+
|
|
479
|
+
it('should get paginated subnames for a name by labelName in asc order', async () => {
|
|
480
|
+
const result = await ensInstance.getSubnames({
|
|
481
|
+
name: 'with-subnames.eth',
|
|
482
|
+
pageSize: 2,
|
|
483
|
+
orderBy: 'labelName',
|
|
484
|
+
orderDirection: 'asc',
|
|
485
|
+
})
|
|
486
|
+
expect(result).toBeTruthy()
|
|
487
|
+
expect(result.subnames.length).toBe(2)
|
|
488
|
+
expect(result.subnameCount).toBe(4)
|
|
489
|
+
expect(result.subnames[0].name).toEqual('addr.with-subnames.eth')
|
|
490
|
+
expect(result.subnames[1].name).toEqual('legacy.with-subnames.eth')
|
|
491
|
+
|
|
492
|
+
testProperties(
|
|
493
|
+
result.subnames[0],
|
|
494
|
+
'id',
|
|
495
|
+
'labelName',
|
|
496
|
+
'labelhash',
|
|
497
|
+
'name',
|
|
498
|
+
'isMigrated',
|
|
499
|
+
'owner',
|
|
500
|
+
'truncatedName',
|
|
501
|
+
)
|
|
502
|
+
|
|
503
|
+
const result2 = await ensInstance.getSubnames({
|
|
504
|
+
name: 'with-subnames.eth',
|
|
505
|
+
pageSize: 2,
|
|
506
|
+
orderBy: 'labelName',
|
|
507
|
+
orderDirection: 'asc',
|
|
508
|
+
lastSubnames: result.subnames,
|
|
509
|
+
})
|
|
510
|
+
expect(result2).toBeTruthy()
|
|
511
|
+
expect(result2.subnames.length).toBe(2)
|
|
512
|
+
expect(result2.subnameCount).toBe(4)
|
|
513
|
+
expect(result2.subnames[0].name).toEqual('test.with-subnames.eth')
|
|
514
|
+
expect(result2.subnames[1].name).toEqual('xyz.with-subnames.eth')
|
|
515
|
+
|
|
516
|
+
testProperties(
|
|
517
|
+
result2.subnames[0],
|
|
518
|
+
'id',
|
|
519
|
+
'labelName',
|
|
520
|
+
'labelhash',
|
|
521
|
+
'name',
|
|
522
|
+
'isMigrated',
|
|
523
|
+
'owner',
|
|
524
|
+
'truncatedName',
|
|
525
|
+
)
|
|
526
|
+
})
|
|
527
|
+
})
|
|
528
|
+
|
|
529
|
+
describe('With search query', () => {
|
|
530
|
+
it('should get the searched subnames for a name ordered by createdAt in desc order', async () => {
|
|
531
|
+
const result = await ensInstance.getSubnames({
|
|
532
|
+
name: 'with-subnames.eth',
|
|
533
|
+
pageSize: 10,
|
|
534
|
+
orderBy: 'createdAt',
|
|
535
|
+
orderDirection: 'desc',
|
|
536
|
+
search: 'a',
|
|
537
|
+
})
|
|
538
|
+
expect(result).toBeTruthy()
|
|
539
|
+
expect(result.subnames.length).toBe(2)
|
|
540
|
+
expect(result.subnameCount).toBe(4)
|
|
541
|
+
expect(result.subnames[0].name).toEqual('addr.with-subnames.eth')
|
|
542
|
+
expect(result.subnames[1].name).toEqual('legacy.with-subnames.eth')
|
|
543
|
+
expect(
|
|
544
|
+
result.subnames.every((subname, i, arr) => {
|
|
545
|
+
if (arr[i + 1]) {
|
|
546
|
+
return (subname as any).createdAt >= (arr[i + 1] as any).createdAt
|
|
547
|
+
}
|
|
548
|
+
return true
|
|
549
|
+
}),
|
|
550
|
+
).toBe(true)
|
|
551
|
+
testProperties(
|
|
552
|
+
result.subnames[0],
|
|
553
|
+
'id',
|
|
554
|
+
'labelName',
|
|
555
|
+
'labelhash',
|
|
556
|
+
'name',
|
|
557
|
+
'isMigrated',
|
|
558
|
+
'owner',
|
|
559
|
+
'truncatedName',
|
|
560
|
+
)
|
|
561
|
+
})
|
|
562
|
+
|
|
563
|
+
it('should get the searched subnames for a name ordered by createdAt in asc order', async () => {
|
|
564
|
+
const result = await ensInstance.getSubnames({
|
|
565
|
+
name: 'with-subnames.eth',
|
|
566
|
+
page: 0,
|
|
567
|
+
pageSize: 10,
|
|
568
|
+
orderBy: 'createdAt',
|
|
569
|
+
orderDirection: 'asc',
|
|
570
|
+
search: 'a',
|
|
571
|
+
})
|
|
572
|
+
expect(result).toBeTruthy()
|
|
573
|
+
expect(result.subnames.length).toBe(2)
|
|
574
|
+
expect(result.subnameCount).toBe(4)
|
|
575
|
+
expect(result.subnames[0].name).toEqual('legacy.with-subnames.eth')
|
|
576
|
+
expect(result.subnames[1].name).toEqual('addr.with-subnames.eth')
|
|
577
|
+
expect(
|
|
578
|
+
result.subnames.every((subname, i, arr) => {
|
|
579
|
+
if (arr[i + 1]) {
|
|
580
|
+
return (subname as any).createdAt <= (arr[i + 1] as any).createdAt
|
|
581
|
+
}
|
|
582
|
+
return true
|
|
583
|
+
}),
|
|
584
|
+
).toBe(true)
|
|
585
|
+
testProperties(
|
|
586
|
+
result.subnames[0],
|
|
587
|
+
'id',
|
|
588
|
+
'labelName',
|
|
589
|
+
'labelhash',
|
|
590
|
+
'name',
|
|
591
|
+
'isMigrated',
|
|
592
|
+
'owner',
|
|
593
|
+
'truncatedName',
|
|
594
|
+
)
|
|
595
|
+
})
|
|
596
|
+
|
|
597
|
+
it('should get the subnames for a name by labelName in desc order', async () => {
|
|
598
|
+
const result = await ensInstance.getSubnames({
|
|
599
|
+
name: 'with-subnames.eth',
|
|
600
|
+
pageSize: 10,
|
|
601
|
+
orderBy: 'labelName',
|
|
602
|
+
orderDirection: 'desc',
|
|
603
|
+
search: 'a',
|
|
604
|
+
})
|
|
605
|
+
expect(result).toBeTruthy()
|
|
606
|
+
expect(result.subnames.length).toBe(2)
|
|
607
|
+
expect(result.subnameCount).toBe(4)
|
|
608
|
+
expect(result.subnames[0].name).toEqual('legacy.with-subnames.eth')
|
|
609
|
+
expect(result.subnames[1].name).toEqual('addr.with-subnames.eth')
|
|
610
|
+
testProperties(
|
|
611
|
+
result.subnames[0],
|
|
612
|
+
'id',
|
|
613
|
+
'labelName',
|
|
614
|
+
'labelhash',
|
|
615
|
+
'name',
|
|
616
|
+
'isMigrated',
|
|
617
|
+
'owner',
|
|
618
|
+
'truncatedName',
|
|
619
|
+
)
|
|
620
|
+
})
|
|
621
|
+
|
|
622
|
+
it('should get the subnames for a name by labelName in asc order', async () => {
|
|
623
|
+
const result = await ensInstance.getSubnames({
|
|
624
|
+
name: 'with-subnames.eth',
|
|
625
|
+
pageSize: 10,
|
|
626
|
+
orderBy: 'labelName',
|
|
627
|
+
orderDirection: 'asc',
|
|
628
|
+
search: 'a',
|
|
629
|
+
})
|
|
630
|
+
expect(result).toBeTruthy()
|
|
631
|
+
expect(result.subnames.length).toBe(2)
|
|
632
|
+
expect(result.subnameCount).toBe(4)
|
|
633
|
+
expect(result.subnames[0].name).toEqual('addr.with-subnames.eth')
|
|
634
|
+
expect(result.subnames[1].name).toEqual('legacy.with-subnames.eth')
|
|
635
|
+
testProperties(
|
|
636
|
+
result.subnames[0],
|
|
637
|
+
'id',
|
|
638
|
+
'labelName',
|
|
639
|
+
'labelhash',
|
|
640
|
+
'name',
|
|
641
|
+
'isMigrated',
|
|
642
|
+
'owner',
|
|
643
|
+
'truncatedName',
|
|
644
|
+
)
|
|
645
|
+
})
|
|
646
|
+
})
|
|
647
|
+
|
|
648
|
+
describe('with search query and pagination', () => {
|
|
649
|
+
it('should get paginated subnames for a name ordered by createdAt in desc order', async () => {
|
|
650
|
+
const result = await ensInstance.getSubnames({
|
|
651
|
+
name: 'with-subnames.eth',
|
|
652
|
+
pageSize: 1,
|
|
653
|
+
orderBy: 'createdAt',
|
|
654
|
+
orderDirection: 'desc',
|
|
655
|
+
search: 'a',
|
|
656
|
+
})
|
|
657
|
+
expect(result).toBeTruthy()
|
|
658
|
+
expect(result.subnames.length).toBe(1)
|
|
659
|
+
expect(result.subnameCount).toBe(4)
|
|
660
|
+
expect(result.subnames[0].name).toEqual('addr.with-subnames.eth')
|
|
661
|
+
testProperties(
|
|
662
|
+
result.subnames[0],
|
|
663
|
+
'id',
|
|
664
|
+
'labelName',
|
|
665
|
+
'labelhash',
|
|
666
|
+
'name',
|
|
667
|
+
'isMigrated',
|
|
668
|
+
'owner',
|
|
669
|
+
'truncatedName',
|
|
670
|
+
)
|
|
671
|
+
const result2 = await ensInstance.getSubnames({
|
|
672
|
+
name: 'with-subnames.eth',
|
|
673
|
+
pageSize: 1,
|
|
674
|
+
orderBy: 'createdAt',
|
|
675
|
+
orderDirection: 'desc',
|
|
676
|
+
lastSubnames: result.subnames,
|
|
677
|
+
search: 'a',
|
|
678
|
+
})
|
|
679
|
+
expect(result2).toBeTruthy()
|
|
680
|
+
expect(result2.subnames.length).toBe(1)
|
|
681
|
+
expect(result2.subnameCount).toBe(4)
|
|
682
|
+
expect(result2.subnames[0].name).toEqual('legacy.with-subnames.eth')
|
|
683
|
+
testProperties(
|
|
684
|
+
result2.subnames[0],
|
|
685
|
+
'id',
|
|
686
|
+
'labelName',
|
|
687
|
+
'labelhash',
|
|
688
|
+
'name',
|
|
689
|
+
'isMigrated',
|
|
690
|
+
'owner',
|
|
691
|
+
'truncatedName',
|
|
692
|
+
)
|
|
693
|
+
})
|
|
694
|
+
|
|
695
|
+
it('should get paginated subnames for a name ordered by createdAt in asc order', async () => {
|
|
696
|
+
const result = await ensInstance.getSubnames({
|
|
697
|
+
name: 'with-subnames.eth',
|
|
698
|
+
pageSize: 1,
|
|
699
|
+
orderBy: 'createdAt',
|
|
700
|
+
orderDirection: 'asc',
|
|
701
|
+
search: 'a',
|
|
702
|
+
})
|
|
703
|
+
expect(result).toBeTruthy()
|
|
704
|
+
expect(result.subnames.length).toBe(1)
|
|
705
|
+
expect(result.subnameCount).toBe(4)
|
|
706
|
+
expect(result.subnames[0].name).toEqual('legacy.with-subnames.eth')
|
|
707
|
+
expect(
|
|
708
|
+
result.subnames.every((subname, i, arr) => {
|
|
709
|
+
if (arr[i + 1]) {
|
|
710
|
+
return (subname as any).createdAt <= (arr[i + 1] as any).createdAt
|
|
711
|
+
}
|
|
712
|
+
return true
|
|
713
|
+
}),
|
|
714
|
+
).toBe(true)
|
|
715
|
+
testProperties(
|
|
716
|
+
result.subnames[0],
|
|
717
|
+
'id',
|
|
718
|
+
'labelName',
|
|
719
|
+
'labelhash',
|
|
720
|
+
'name',
|
|
721
|
+
'isMigrated',
|
|
722
|
+
'owner',
|
|
723
|
+
'truncatedName',
|
|
724
|
+
)
|
|
725
|
+
const result2 = await ensInstance.getSubnames({
|
|
726
|
+
name: 'with-subnames.eth',
|
|
727
|
+
page: 0,
|
|
728
|
+
pageSize: 2,
|
|
729
|
+
orderBy: 'createdAt',
|
|
730
|
+
orderDirection: 'asc',
|
|
731
|
+
lastSubnames: result.subnames,
|
|
732
|
+
search: 'a',
|
|
733
|
+
})
|
|
734
|
+
|
|
735
|
+
expect(result2).toBeTruthy()
|
|
736
|
+
expect(result2.subnames.length).toBe(1)
|
|
737
|
+
expect(result2.subnameCount).toBe(4)
|
|
738
|
+
expect(result2.subnames[0].name).toEqual('addr.with-subnames.eth')
|
|
739
|
+
|
|
740
|
+
testProperties(
|
|
741
|
+
result2.subnames[0],
|
|
742
|
+
'id',
|
|
743
|
+
'labelName',
|
|
744
|
+
'labelhash',
|
|
745
|
+
'name',
|
|
746
|
+
'isMigrated',
|
|
747
|
+
'owner',
|
|
748
|
+
'truncatedName',
|
|
749
|
+
)
|
|
750
|
+
})
|
|
751
|
+
|
|
752
|
+
it('should get paginated subnames for a name by labelName in desc order', async () => {
|
|
753
|
+
const result = await ensInstance.getSubnames({
|
|
754
|
+
name: 'with-subnames.eth',
|
|
755
|
+
pageSize: 1,
|
|
756
|
+
orderBy: 'labelName',
|
|
757
|
+
orderDirection: 'desc',
|
|
758
|
+
search: 'a',
|
|
759
|
+
})
|
|
760
|
+
expect(result).toBeTruthy()
|
|
761
|
+
expect(result.subnames.length).toBe(1)
|
|
762
|
+
expect(result.subnameCount).toBe(4)
|
|
763
|
+
expect(result.subnames[0].name).toEqual('legacy.with-subnames.eth')
|
|
764
|
+
testProperties(
|
|
765
|
+
result.subnames[0],
|
|
766
|
+
'id',
|
|
767
|
+
'labelName',
|
|
768
|
+
'labelhash',
|
|
769
|
+
'name',
|
|
770
|
+
'isMigrated',
|
|
771
|
+
'owner',
|
|
772
|
+
'truncatedName',
|
|
773
|
+
)
|
|
774
|
+
const result2 = await ensInstance.getSubnames({
|
|
775
|
+
name: 'with-subnames.eth',
|
|
776
|
+
pageSize: 1,
|
|
777
|
+
orderBy: 'labelName',
|
|
778
|
+
orderDirection: 'desc',
|
|
779
|
+
lastSubnames: result.subnames,
|
|
780
|
+
search: 'a',
|
|
781
|
+
})
|
|
782
|
+
expect(result2).toBeTruthy()
|
|
783
|
+
expect(result2.subnames.length).toBe(1)
|
|
784
|
+
expect(result2.subnameCount).toBe(4)
|
|
785
|
+
expect(result2.subnames[0].name).toEqual('addr.with-subnames.eth')
|
|
786
|
+
testProperties(
|
|
787
|
+
result.subnames[0],
|
|
788
|
+
'id',
|
|
789
|
+
'labelName',
|
|
790
|
+
'labelhash',
|
|
791
|
+
'name',
|
|
792
|
+
'isMigrated',
|
|
793
|
+
'owner',
|
|
794
|
+
'truncatedName',
|
|
795
|
+
)
|
|
796
|
+
})
|
|
797
|
+
|
|
798
|
+
it('should get paginated subnames for a name by labelName in asc order', async () => {
|
|
799
|
+
const result = await ensInstance.getSubnames({
|
|
800
|
+
name: 'with-subnames.eth',
|
|
801
|
+
pageSize: 1,
|
|
802
|
+
orderBy: 'labelName',
|
|
803
|
+
orderDirection: 'asc',
|
|
804
|
+
search: 'a',
|
|
805
|
+
})
|
|
806
|
+
expect(result).toBeTruthy()
|
|
807
|
+
expect(result.subnames.length).toBe(1)
|
|
808
|
+
expect(result.subnameCount).toBe(4)
|
|
809
|
+
expect(result.subnames[0].name).toEqual('addr.with-subnames.eth')
|
|
810
|
+
|
|
811
|
+
testProperties(
|
|
812
|
+
result.subnames[0],
|
|
813
|
+
'id',
|
|
814
|
+
'labelName',
|
|
815
|
+
'labelhash',
|
|
816
|
+
'name',
|
|
817
|
+
'isMigrated',
|
|
818
|
+
'owner',
|
|
819
|
+
'truncatedName',
|
|
820
|
+
)
|
|
821
|
+
|
|
822
|
+
const result2 = await ensInstance.getSubnames({
|
|
823
|
+
name: 'with-subnames.eth',
|
|
824
|
+
pageSize: 1,
|
|
825
|
+
orderBy: 'labelName',
|
|
826
|
+
orderDirection: 'asc',
|
|
827
|
+
lastSubnames: result.subnames,
|
|
828
|
+
search: 'a',
|
|
829
|
+
})
|
|
830
|
+
expect(result2).toBeTruthy()
|
|
831
|
+
expect(result2.subnames.length).toBe(1)
|
|
832
|
+
expect(result2.subnameCount).toBe(4)
|
|
833
|
+
expect(result2.subnames[0].name).toEqual('legacy.with-subnames.eth')
|
|
834
|
+
|
|
835
|
+
testProperties(
|
|
836
|
+
result2.subnames[0],
|
|
837
|
+
'id',
|
|
838
|
+
'labelName',
|
|
839
|
+
'labelhash',
|
|
840
|
+
'name',
|
|
841
|
+
'isMigrated',
|
|
842
|
+
'owner',
|
|
843
|
+
'truncatedName',
|
|
844
|
+
)
|
|
845
|
+
})
|
|
405
846
|
})
|
|
406
847
|
})
|
|
407
848
|
|
|
408
|
-
describe('
|
|
409
|
-
it('should get the
|
|
849
|
+
describe('wrapped', () => {
|
|
850
|
+
it('should get the subnames for a name ordered by createdAt in desc order', async () => {
|
|
410
851
|
const result = await ensInstance.getSubnames({
|
|
411
|
-
name: 'with-subnames.eth',
|
|
852
|
+
name: 'wrapped-with-subnames.eth',
|
|
412
853
|
pageSize: 10,
|
|
413
854
|
orderBy: 'createdAt',
|
|
414
855
|
orderDirection: 'desc',
|
|
415
|
-
search: 'a',
|
|
416
856
|
})
|
|
417
857
|
expect(result).toBeTruthy()
|
|
418
|
-
expect(result.subnames.length).toBe(
|
|
858
|
+
expect(result.subnames.length).toBe(4)
|
|
419
859
|
expect(result.subnameCount).toBe(4)
|
|
420
|
-
expect(result.subnames[0].name).toEqual('addr.with-subnames.eth')
|
|
421
|
-
expect(result.subnames[1].name).toEqual('
|
|
860
|
+
expect(result.subnames[0].name).toEqual('addr.wrapped-with-subnames.eth')
|
|
861
|
+
expect(result.subnames[1].name).toEqual('xyz.wrapped-with-subnames.eth')
|
|
862
|
+
expect(result.subnames[2].name).toEqual(
|
|
863
|
+
'legacy.wrapped-with-subnames.eth',
|
|
864
|
+
)
|
|
865
|
+
expect(result.subnames[3].name).toEqual('test.wrapped-with-subnames.eth')
|
|
422
866
|
expect(
|
|
423
867
|
result.subnames.every((subname, i, arr) => {
|
|
424
868
|
if (arr[i + 1]) {
|
|
@@ -439,20 +883,22 @@ describe('getSubnames', () => {
|
|
|
439
883
|
)
|
|
440
884
|
})
|
|
441
885
|
|
|
442
|
-
it('should get the
|
|
886
|
+
it('should get the subnames for a name ordered by createdAt in asc order', async () => {
|
|
443
887
|
const result = await ensInstance.getSubnames({
|
|
444
|
-
name: 'with-subnames.eth',
|
|
445
|
-
page: 0,
|
|
888
|
+
name: 'wrapped-with-subnames.eth',
|
|
446
889
|
pageSize: 10,
|
|
447
890
|
orderBy: 'createdAt',
|
|
448
891
|
orderDirection: 'asc',
|
|
449
|
-
search: 'a',
|
|
450
892
|
})
|
|
451
893
|
expect(result).toBeTruthy()
|
|
452
|
-
expect(result.subnames.length).toBe(
|
|
894
|
+
expect(result.subnames.length).toBe(4)
|
|
453
895
|
expect(result.subnameCount).toBe(4)
|
|
454
|
-
expect(result.subnames[0].name).toEqual('
|
|
455
|
-
expect(result.subnames[1].name).toEqual(
|
|
896
|
+
expect(result.subnames[0].name).toEqual('test.wrapped-with-subnames.eth')
|
|
897
|
+
expect(result.subnames[1].name).toEqual(
|
|
898
|
+
'legacy.wrapped-with-subnames.eth',
|
|
899
|
+
)
|
|
900
|
+
expect(result.subnames[2].name).toEqual('xyz.wrapped-with-subnames.eth')
|
|
901
|
+
expect(result.subnames[3].name).toEqual('addr.wrapped-with-subnames.eth')
|
|
456
902
|
expect(
|
|
457
903
|
result.subnames.every((subname, i, arr) => {
|
|
458
904
|
if (arr[i + 1]) {
|
|
@@ -475,17 +921,20 @@ describe('getSubnames', () => {
|
|
|
475
921
|
|
|
476
922
|
it('should get the subnames for a name by labelName in desc order', async () => {
|
|
477
923
|
const result = await ensInstance.getSubnames({
|
|
478
|
-
name: 'with-subnames.eth',
|
|
924
|
+
name: 'wrapped-with-subnames.eth',
|
|
479
925
|
pageSize: 10,
|
|
480
926
|
orderBy: 'labelName',
|
|
481
927
|
orderDirection: 'desc',
|
|
482
|
-
search: 'a',
|
|
483
928
|
})
|
|
484
929
|
expect(result).toBeTruthy()
|
|
485
|
-
expect(result.subnames.length).toBe(
|
|
930
|
+
expect(result.subnames.length).toBe(4)
|
|
486
931
|
expect(result.subnameCount).toBe(4)
|
|
487
|
-
expect(result.subnames[0].name).toEqual('
|
|
488
|
-
expect(result.subnames[1].name).toEqual('
|
|
932
|
+
expect(result.subnames[0].name).toEqual('xyz.wrapped-with-subnames.eth')
|
|
933
|
+
expect(result.subnames[1].name).toEqual('test.wrapped-with-subnames.eth')
|
|
934
|
+
expect(result.subnames[2].name).toEqual(
|
|
935
|
+
'legacy.wrapped-with-subnames.eth',
|
|
936
|
+
)
|
|
937
|
+
expect(result.subnames[3].name).toEqual('addr.wrapped-with-subnames.eth')
|
|
489
938
|
testProperties(
|
|
490
939
|
result.subnames[0],
|
|
491
940
|
'id',
|
|
@@ -500,17 +949,20 @@ describe('getSubnames', () => {
|
|
|
500
949
|
|
|
501
950
|
it('should get the subnames for a name by labelName in asc order', async () => {
|
|
502
951
|
const result = await ensInstance.getSubnames({
|
|
503
|
-
name: 'with-subnames.eth',
|
|
952
|
+
name: 'wrapped-with-subnames.eth',
|
|
504
953
|
pageSize: 10,
|
|
505
954
|
orderBy: 'labelName',
|
|
506
955
|
orderDirection: 'asc',
|
|
507
|
-
search: 'a',
|
|
508
956
|
})
|
|
509
957
|
expect(result).toBeTruthy()
|
|
510
|
-
expect(result.subnames.length).toBe(
|
|
958
|
+
expect(result.subnames.length).toBe(4)
|
|
511
959
|
expect(result.subnameCount).toBe(4)
|
|
512
|
-
expect(result.subnames[0].name).toEqual('addr.with-subnames.eth')
|
|
513
|
-
expect(result.subnames[1].name).toEqual(
|
|
960
|
+
expect(result.subnames[0].name).toEqual('addr.wrapped-with-subnames.eth')
|
|
961
|
+
expect(result.subnames[1].name).toEqual(
|
|
962
|
+
'legacy.wrapped-with-subnames.eth',
|
|
963
|
+
)
|
|
964
|
+
expect(result.subnames[2].name).toEqual('test.wrapped-with-subnames.eth')
|
|
965
|
+
expect(result.subnames[3].name).toEqual('xyz.wrapped-with-subnames.eth')
|
|
514
966
|
testProperties(
|
|
515
967
|
result.subnames[0],
|
|
516
968
|
'id',
|
|
@@ -522,205 +974,607 @@ describe('getSubnames', () => {
|
|
|
522
974
|
'truncatedName',
|
|
523
975
|
)
|
|
524
976
|
})
|
|
525
|
-
})
|
|
526
977
|
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
result.subnames[
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
978
|
+
describe('with pagination', () => {
|
|
979
|
+
it('should get paginated subnames for a name ordered by createdAt in desc order', async () => {
|
|
980
|
+
const result = await ensInstance.getSubnames({
|
|
981
|
+
name: 'wrapped-with-subnames.eth',
|
|
982
|
+
pageSize: 2,
|
|
983
|
+
orderBy: 'createdAt',
|
|
984
|
+
orderDirection: 'desc',
|
|
985
|
+
})
|
|
986
|
+
expect(result).toBeTruthy()
|
|
987
|
+
expect(result.subnames.length).toBe(2)
|
|
988
|
+
expect(result.subnameCount).toBe(4)
|
|
989
|
+
expect(result.subnames[0].name).toEqual(
|
|
990
|
+
'addr.wrapped-with-subnames.eth',
|
|
991
|
+
)
|
|
992
|
+
expect(result.subnames[1].name).toEqual('xyz.wrapped-with-subnames.eth')
|
|
993
|
+
expect(
|
|
994
|
+
result.subnames.every((subname, i, arr) => {
|
|
995
|
+
if (arr[i + 1]) {
|
|
996
|
+
return (subname as any).createdAt >= (arr[i + 1] as any).createdAt
|
|
997
|
+
}
|
|
998
|
+
return true
|
|
999
|
+
}),
|
|
1000
|
+
).toBe(true)
|
|
1001
|
+
testProperties(
|
|
1002
|
+
result.subnames[0],
|
|
1003
|
+
'id',
|
|
1004
|
+
'labelName',
|
|
1005
|
+
'labelhash',
|
|
1006
|
+
'name',
|
|
1007
|
+
'isMigrated',
|
|
1008
|
+
'owner',
|
|
1009
|
+
'truncatedName',
|
|
1010
|
+
)
|
|
1011
|
+
const result2 = await ensInstance.getSubnames({
|
|
1012
|
+
name: 'wrapped-with-subnames.eth',
|
|
1013
|
+
pageSize: 2,
|
|
1014
|
+
orderBy: 'createdAt',
|
|
1015
|
+
orderDirection: 'desc',
|
|
1016
|
+
lastSubnames: result.subnames,
|
|
1017
|
+
})
|
|
1018
|
+
expect(result2).toBeTruthy()
|
|
1019
|
+
expect(result2.subnames.length).toBe(2)
|
|
1020
|
+
expect(result2.subnameCount).toBe(4)
|
|
1021
|
+
expect(result2.subnames[0].name).toEqual(
|
|
1022
|
+
'legacy.wrapped-with-subnames.eth',
|
|
1023
|
+
)
|
|
1024
|
+
expect(result2.subnames[1].name).toEqual(
|
|
1025
|
+
'test.wrapped-with-subnames.eth',
|
|
1026
|
+
)
|
|
1027
|
+
expect(
|
|
1028
|
+
result2.subnames.every((subname, i, arr) => {
|
|
1029
|
+
if (arr[i + 1]) {
|
|
1030
|
+
return (subname as any).createdAt >= (arr[i + 1] as any).createdAt
|
|
1031
|
+
}
|
|
1032
|
+
return true
|
|
1033
|
+
}),
|
|
1034
|
+
).toBe(true)
|
|
1035
|
+
testProperties(
|
|
1036
|
+
result2.subnames[0],
|
|
1037
|
+
'id',
|
|
1038
|
+
'labelName',
|
|
1039
|
+
'labelhash',
|
|
1040
|
+
'name',
|
|
1041
|
+
'isMigrated',
|
|
1042
|
+
'owner',
|
|
1043
|
+
'truncatedName',
|
|
1044
|
+
)
|
|
557
1045
|
})
|
|
558
|
-
expect(result2).toBeTruthy()
|
|
559
|
-
expect(result2.subnames.length).toBe(1)
|
|
560
|
-
expect(result2.subnameCount).toBe(4)
|
|
561
|
-
expect(result2.subnames[0].name).toEqual('legacy.with-subnames.eth')
|
|
562
|
-
testProperties(
|
|
563
|
-
result2.subnames[0],
|
|
564
|
-
'id',
|
|
565
|
-
'labelName',
|
|
566
|
-
'labelhash',
|
|
567
|
-
'name',
|
|
568
|
-
'isMigrated',
|
|
569
|
-
'owner',
|
|
570
|
-
'truncatedName',
|
|
571
|
-
)
|
|
572
|
-
})
|
|
573
1046
|
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
1047
|
+
it('should get paginated subnames for a name ordered by createdAt in asc order', async () => {
|
|
1048
|
+
const result = await ensInstance.getSubnames({
|
|
1049
|
+
name: 'wrapped-with-subnames.eth',
|
|
1050
|
+
pageSize: 2,
|
|
1051
|
+
orderBy: 'createdAt',
|
|
1052
|
+
orderDirection: 'asc',
|
|
1053
|
+
})
|
|
1054
|
+
expect(result).toBeTruthy()
|
|
1055
|
+
expect(result.subnames.length).toBe(2)
|
|
1056
|
+
expect(result.subnameCount).toBe(4)
|
|
1057
|
+
expect(result.subnames[0].name).toEqual(
|
|
1058
|
+
'test.wrapped-with-subnames.eth',
|
|
1059
|
+
)
|
|
1060
|
+
expect(result.subnames[1].name).toEqual(
|
|
1061
|
+
'legacy.wrapped-with-subnames.eth',
|
|
1062
|
+
)
|
|
1063
|
+
expect(
|
|
1064
|
+
result.subnames.every((subname, i, arr) => {
|
|
1065
|
+
if (arr[i + 1]) {
|
|
1066
|
+
return (subname as any).createdAt <= (arr[i + 1] as any).createdAt
|
|
1067
|
+
}
|
|
1068
|
+
return true
|
|
1069
|
+
}),
|
|
1070
|
+
).toBe(true)
|
|
1071
|
+
testProperties(
|
|
1072
|
+
result.subnames[0],
|
|
1073
|
+
'id',
|
|
1074
|
+
'labelName',
|
|
1075
|
+
'labelhash',
|
|
1076
|
+
'name',
|
|
1077
|
+
'isMigrated',
|
|
1078
|
+
'owner',
|
|
1079
|
+
'truncatedName',
|
|
1080
|
+
)
|
|
1081
|
+
const result2 = await ensInstance.getSubnames({
|
|
1082
|
+
name: 'wrapped-with-subnames.eth',
|
|
1083
|
+
page: 0,
|
|
1084
|
+
pageSize: 2,
|
|
1085
|
+
orderBy: 'createdAt',
|
|
1086
|
+
orderDirection: 'asc',
|
|
1087
|
+
lastSubnames: result.subnames,
|
|
1088
|
+
})
|
|
1089
|
+
|
|
1090
|
+
expect(result2).toBeTruthy()
|
|
1091
|
+
expect(result2.subnames.length).toBe(2)
|
|
1092
|
+
expect(result2.subnameCount).toBe(4)
|
|
1093
|
+
expect(result2.subnames[0].name).toEqual(
|
|
1094
|
+
'xyz.wrapped-with-subnames.eth',
|
|
1095
|
+
)
|
|
1096
|
+
expect(result2.subnames[1].name).toEqual(
|
|
1097
|
+
'addr.wrapped-with-subnames.eth',
|
|
1098
|
+
)
|
|
1099
|
+
expect(
|
|
1100
|
+
result2.subnames.every((subname, i, arr) => {
|
|
1101
|
+
if (arr[i + 1]) {
|
|
1102
|
+
return (subname as any).createdAt <= (arr[i + 1] as any).createdAt
|
|
1103
|
+
}
|
|
1104
|
+
return true
|
|
1105
|
+
}),
|
|
1106
|
+
).toBe(true)
|
|
1107
|
+
testProperties(
|
|
1108
|
+
result2.subnames[0],
|
|
1109
|
+
'id',
|
|
1110
|
+
'labelName',
|
|
1111
|
+
'labelhash',
|
|
1112
|
+
'name',
|
|
1113
|
+
'isMigrated',
|
|
1114
|
+
'owner',
|
|
1115
|
+
'truncatedName',
|
|
1116
|
+
)
|
|
581
1117
|
})
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
1118
|
+
|
|
1119
|
+
it('should get paginated subnames for a name by labelName in desc order', async () => {
|
|
1120
|
+
const result = await ensInstance.getSubnames({
|
|
1121
|
+
name: 'wrapped-with-subnames.eth',
|
|
1122
|
+
pageSize: 2,
|
|
1123
|
+
orderBy: 'labelName',
|
|
1124
|
+
orderDirection: 'desc',
|
|
1125
|
+
})
|
|
1126
|
+
expect(result).toBeTruthy()
|
|
1127
|
+
expect(result.subnames.length).toBe(2)
|
|
1128
|
+
expect(result.subnameCount).toBe(4)
|
|
1129
|
+
expect(result.subnames[0].name).toEqual('xyz.wrapped-with-subnames.eth')
|
|
1130
|
+
expect(result.subnames[1].name).toEqual(
|
|
1131
|
+
'test.wrapped-with-subnames.eth',
|
|
1132
|
+
)
|
|
1133
|
+
testProperties(
|
|
1134
|
+
result.subnames[0],
|
|
1135
|
+
'id',
|
|
1136
|
+
'labelName',
|
|
1137
|
+
'labelhash',
|
|
1138
|
+
'name',
|
|
1139
|
+
'isMigrated',
|
|
1140
|
+
'owner',
|
|
1141
|
+
'truncatedName',
|
|
1142
|
+
)
|
|
1143
|
+
const result2 = await ensInstance.getSubnames({
|
|
1144
|
+
name: 'wrapped-with-subnames.eth',
|
|
1145
|
+
pageSize: 2,
|
|
1146
|
+
orderBy: 'labelName',
|
|
1147
|
+
orderDirection: 'desc',
|
|
1148
|
+
lastSubnames: result.subnames,
|
|
1149
|
+
})
|
|
1150
|
+
expect(result2).toBeTruthy()
|
|
1151
|
+
expect(result2.subnames.length).toBe(2)
|
|
1152
|
+
expect(result2.subnameCount).toBe(4)
|
|
1153
|
+
expect(result2.subnames[0].name).toEqual(
|
|
1154
|
+
'legacy.wrapped-with-subnames.eth',
|
|
1155
|
+
)
|
|
1156
|
+
expect(result2.subnames[1].name).toEqual(
|
|
1157
|
+
'addr.wrapped-with-subnames.eth',
|
|
1158
|
+
)
|
|
1159
|
+
testProperties(
|
|
1160
|
+
result.subnames[0],
|
|
1161
|
+
'id',
|
|
1162
|
+
'labelName',
|
|
1163
|
+
'labelhash',
|
|
1164
|
+
'name',
|
|
1165
|
+
'isMigrated',
|
|
1166
|
+
'owner',
|
|
1167
|
+
'truncatedName',
|
|
1168
|
+
)
|
|
612
1169
|
})
|
|
613
1170
|
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
1171
|
+
it('should get paginated subnames for a name by labelName in asc order', async () => {
|
|
1172
|
+
const result = await ensInstance.getSubnames({
|
|
1173
|
+
name: 'wrapped-with-subnames.eth',
|
|
1174
|
+
pageSize: 2,
|
|
1175
|
+
orderBy: 'labelName',
|
|
1176
|
+
orderDirection: 'asc',
|
|
1177
|
+
})
|
|
1178
|
+
expect(result).toBeTruthy()
|
|
1179
|
+
expect(result.subnames.length).toBe(2)
|
|
1180
|
+
expect(result.subnameCount).toBe(4)
|
|
1181
|
+
expect(result.subnames[0].name).toEqual(
|
|
1182
|
+
'addr.wrapped-with-subnames.eth',
|
|
1183
|
+
)
|
|
1184
|
+
expect(result.subnames[1].name).toEqual(
|
|
1185
|
+
'legacy.wrapped-with-subnames.eth',
|
|
1186
|
+
)
|
|
618
1187
|
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
1188
|
+
testProperties(
|
|
1189
|
+
result.subnames[0],
|
|
1190
|
+
'id',
|
|
1191
|
+
'labelName',
|
|
1192
|
+
'labelhash',
|
|
1193
|
+
'name',
|
|
1194
|
+
'isMigrated',
|
|
1195
|
+
'owner',
|
|
1196
|
+
'truncatedName',
|
|
1197
|
+
)
|
|
1198
|
+
|
|
1199
|
+
const result2 = await ensInstance.getSubnames({
|
|
1200
|
+
name: 'wrapped-with-subnames.eth',
|
|
1201
|
+
pageSize: 2,
|
|
1202
|
+
orderBy: 'labelName',
|
|
1203
|
+
orderDirection: 'asc',
|
|
1204
|
+
lastSubnames: result.subnames,
|
|
1205
|
+
})
|
|
1206
|
+
expect(result2).toBeTruthy()
|
|
1207
|
+
expect(result2.subnames.length).toBe(2)
|
|
1208
|
+
expect(result2.subnameCount).toBe(4)
|
|
1209
|
+
expect(result2.subnames[0].name).toEqual(
|
|
1210
|
+
'test.wrapped-with-subnames.eth',
|
|
1211
|
+
)
|
|
1212
|
+
expect(result2.subnames[1].name).toEqual(
|
|
1213
|
+
'xyz.wrapped-with-subnames.eth',
|
|
1214
|
+
)
|
|
1215
|
+
|
|
1216
|
+
testProperties(
|
|
1217
|
+
result2.subnames[0],
|
|
1218
|
+
'id',
|
|
1219
|
+
'labelName',
|
|
1220
|
+
'labelhash',
|
|
1221
|
+
'name',
|
|
1222
|
+
'isMigrated',
|
|
1223
|
+
'owner',
|
|
1224
|
+
'truncatedName',
|
|
1225
|
+
)
|
|
1226
|
+
})
|
|
629
1227
|
})
|
|
630
1228
|
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
1229
|
+
describe('With search query', () => {
|
|
1230
|
+
it('should get the searched subnames for a name ordered by createdAt in desc order', async () => {
|
|
1231
|
+
const result = await ensInstance.getSubnames({
|
|
1232
|
+
name: 'wrapped-with-subnames.eth',
|
|
1233
|
+
pageSize: 10,
|
|
1234
|
+
orderBy: 'createdAt',
|
|
1235
|
+
orderDirection: 'desc',
|
|
1236
|
+
search: 'a',
|
|
1237
|
+
})
|
|
1238
|
+
expect(result).toBeTruthy()
|
|
1239
|
+
expect(result.subnames.length).toBe(2)
|
|
1240
|
+
expect(result.subnameCount).toBe(4)
|
|
1241
|
+
expect(result.subnames[0].name).toEqual(
|
|
1242
|
+
'addr.wrapped-with-subnames.eth',
|
|
1243
|
+
)
|
|
1244
|
+
expect(result.subnames[1].name).toEqual(
|
|
1245
|
+
'legacy.wrapped-with-subnames.eth',
|
|
1246
|
+
)
|
|
1247
|
+
expect(
|
|
1248
|
+
result.subnames.every((subname, i, arr) => {
|
|
1249
|
+
if (arr[i + 1]) {
|
|
1250
|
+
return (subname as any).createdAt >= (arr[i + 1] as any).createdAt
|
|
1251
|
+
}
|
|
1252
|
+
return true
|
|
1253
|
+
}),
|
|
1254
|
+
).toBe(true)
|
|
1255
|
+
testProperties(
|
|
1256
|
+
result.subnames[0],
|
|
1257
|
+
'id',
|
|
1258
|
+
'labelName',
|
|
1259
|
+
'labelhash',
|
|
1260
|
+
'name',
|
|
1261
|
+
'isMigrated',
|
|
1262
|
+
'owner',
|
|
1263
|
+
'truncatedName',
|
|
1264
|
+
)
|
|
638
1265
|
})
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
1266
|
+
|
|
1267
|
+
it('should get the searched subnames for a name ordered by createdAt in asc order', async () => {
|
|
1268
|
+
const result = await ensInstance.getSubnames({
|
|
1269
|
+
name: 'wrapped-with-subnames.eth',
|
|
1270
|
+
page: 0,
|
|
1271
|
+
pageSize: 10,
|
|
1272
|
+
orderBy: 'createdAt',
|
|
1273
|
+
orderDirection: 'asc',
|
|
1274
|
+
search: 'a',
|
|
1275
|
+
})
|
|
1276
|
+
expect(result).toBeTruthy()
|
|
1277
|
+
expect(result.subnames.length).toBe(2)
|
|
1278
|
+
expect(result.subnameCount).toBe(4)
|
|
1279
|
+
expect(result.subnames[0].name).toEqual(
|
|
1280
|
+
'legacy.wrapped-with-subnames.eth',
|
|
1281
|
+
)
|
|
1282
|
+
expect(result.subnames[1].name).toEqual(
|
|
1283
|
+
'addr.wrapped-with-subnames.eth',
|
|
1284
|
+
)
|
|
1285
|
+
expect(
|
|
1286
|
+
result.subnames.every((subname, i, arr) => {
|
|
1287
|
+
if (arr[i + 1]) {
|
|
1288
|
+
return (subname as any).createdAt <= (arr[i + 1] as any).createdAt
|
|
1289
|
+
}
|
|
1290
|
+
return true
|
|
1291
|
+
}),
|
|
1292
|
+
).toBe(true)
|
|
1293
|
+
testProperties(
|
|
1294
|
+
result.subnames[0],
|
|
1295
|
+
'id',
|
|
1296
|
+
'labelName',
|
|
1297
|
+
'labelhash',
|
|
1298
|
+
'name',
|
|
1299
|
+
'isMigrated',
|
|
1300
|
+
'owner',
|
|
1301
|
+
'truncatedName',
|
|
1302
|
+
)
|
|
1303
|
+
})
|
|
1304
|
+
|
|
1305
|
+
it('should get the subnames for a name by labelName in desc order', async () => {
|
|
1306
|
+
const result = await ensInstance.getSubnames({
|
|
1307
|
+
name: 'wrapped-with-subnames.eth',
|
|
1308
|
+
pageSize: 10,
|
|
1309
|
+
orderBy: 'labelName',
|
|
1310
|
+
orderDirection: 'desc',
|
|
1311
|
+
search: 'a',
|
|
1312
|
+
})
|
|
1313
|
+
expect(result).toBeTruthy()
|
|
1314
|
+
expect(result.subnames.length).toBe(2)
|
|
1315
|
+
expect(result.subnameCount).toBe(4)
|
|
1316
|
+
expect(result.subnames[0].name).toEqual(
|
|
1317
|
+
'legacy.wrapped-with-subnames.eth',
|
|
1318
|
+
)
|
|
1319
|
+
expect(result.subnames[1].name).toEqual(
|
|
1320
|
+
'addr.wrapped-with-subnames.eth',
|
|
1321
|
+
)
|
|
1322
|
+
testProperties(
|
|
1323
|
+
result.subnames[0],
|
|
1324
|
+
'id',
|
|
1325
|
+
'labelName',
|
|
1326
|
+
'labelhash',
|
|
1327
|
+
'name',
|
|
1328
|
+
'isMigrated',
|
|
1329
|
+
'owner',
|
|
1330
|
+
'truncatedName',
|
|
1331
|
+
)
|
|
1332
|
+
})
|
|
1333
|
+
|
|
1334
|
+
it('should get the subnames for a name by labelName in asc order', async () => {
|
|
1335
|
+
const result = await ensInstance.getSubnames({
|
|
1336
|
+
name: 'wrapped-with-subnames.eth',
|
|
1337
|
+
pageSize: 10,
|
|
1338
|
+
orderBy: 'labelName',
|
|
1339
|
+
orderDirection: 'asc',
|
|
1340
|
+
search: 'a',
|
|
1341
|
+
})
|
|
1342
|
+
expect(result).toBeTruthy()
|
|
1343
|
+
expect(result.subnames.length).toBe(2)
|
|
1344
|
+
expect(result.subnameCount).toBe(4)
|
|
1345
|
+
expect(result.subnames[0].name).toEqual(
|
|
1346
|
+
'addr.wrapped-with-subnames.eth',
|
|
1347
|
+
)
|
|
1348
|
+
expect(result.subnames[1].name).toEqual(
|
|
1349
|
+
'legacy.wrapped-with-subnames.eth',
|
|
1350
|
+
)
|
|
1351
|
+
testProperties(
|
|
1352
|
+
result.subnames[0],
|
|
1353
|
+
'id',
|
|
1354
|
+
'labelName',
|
|
1355
|
+
'labelhash',
|
|
1356
|
+
'name',
|
|
1357
|
+
'isMigrated',
|
|
1358
|
+
'owner',
|
|
1359
|
+
'truncatedName',
|
|
1360
|
+
)
|
|
660
1361
|
})
|
|
661
|
-
expect(result2).toBeTruthy()
|
|
662
|
-
expect(result2.subnames.length).toBe(1)
|
|
663
|
-
expect(result2.subnameCount).toBe(4)
|
|
664
|
-
expect(result2.subnames[0].name).toEqual('addr.with-subnames.eth')
|
|
665
|
-
testProperties(
|
|
666
|
-
result.subnames[0],
|
|
667
|
-
'id',
|
|
668
|
-
'labelName',
|
|
669
|
-
'labelhash',
|
|
670
|
-
'name',
|
|
671
|
-
'isMigrated',
|
|
672
|
-
'owner',
|
|
673
|
-
'truncatedName',
|
|
674
|
-
)
|
|
675
1362
|
})
|
|
676
1363
|
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
1364
|
+
describe('with search query and pagination', () => {
|
|
1365
|
+
it('should get paginated subnames for a name ordered by createdAt in desc order', async () => {
|
|
1366
|
+
const result = await ensInstance.getSubnames({
|
|
1367
|
+
name: 'wrapped-with-subnames.eth',
|
|
1368
|
+
pageSize: 1,
|
|
1369
|
+
orderBy: 'createdAt',
|
|
1370
|
+
orderDirection: 'desc',
|
|
1371
|
+
search: 'a',
|
|
1372
|
+
})
|
|
1373
|
+
expect(result).toBeTruthy()
|
|
1374
|
+
expect(result.subnames.length).toBe(1)
|
|
1375
|
+
expect(result.subnameCount).toBe(4)
|
|
1376
|
+
expect(result.subnames[0].name).toEqual(
|
|
1377
|
+
'addr.wrapped-with-subnames.eth',
|
|
1378
|
+
)
|
|
1379
|
+
testProperties(
|
|
1380
|
+
result.subnames[0],
|
|
1381
|
+
'id',
|
|
1382
|
+
'labelName',
|
|
1383
|
+
'labelhash',
|
|
1384
|
+
'name',
|
|
1385
|
+
'isMigrated',
|
|
1386
|
+
'owner',
|
|
1387
|
+
'truncatedName',
|
|
1388
|
+
)
|
|
1389
|
+
const result2 = await ensInstance.getSubnames({
|
|
1390
|
+
name: 'wrapped-with-subnames.eth',
|
|
1391
|
+
pageSize: 1,
|
|
1392
|
+
orderBy: 'createdAt',
|
|
1393
|
+
orderDirection: 'desc',
|
|
1394
|
+
lastSubnames: result.subnames,
|
|
1395
|
+
search: 'a',
|
|
1396
|
+
})
|
|
1397
|
+
expect(result2).toBeTruthy()
|
|
1398
|
+
expect(result2.subnames.length).toBe(1)
|
|
1399
|
+
expect(result2.subnameCount).toBe(4)
|
|
1400
|
+
expect(result2.subnames[0].name).toEqual(
|
|
1401
|
+
'legacy.wrapped-with-subnames.eth',
|
|
1402
|
+
)
|
|
1403
|
+
testProperties(
|
|
1404
|
+
result2.subnames[0],
|
|
1405
|
+
'id',
|
|
1406
|
+
'labelName',
|
|
1407
|
+
'labelhash',
|
|
1408
|
+
'name',
|
|
1409
|
+
'isMigrated',
|
|
1410
|
+
'owner',
|
|
1411
|
+
'truncatedName',
|
|
1412
|
+
)
|
|
684
1413
|
})
|
|
685
|
-
expect(result).toBeTruthy()
|
|
686
|
-
expect(result.subnames.length).toBe(1)
|
|
687
|
-
expect(result.subnameCount).toBe(4)
|
|
688
|
-
expect(result.subnames[0].name).toEqual('addr.with-subnames.eth')
|
|
689
1414
|
|
|
690
|
-
|
|
691
|
-
result.
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
1415
|
+
it('should get paginated subnames for a name ordered by createdAt in asc order', async () => {
|
|
1416
|
+
const result = await ensInstance.getSubnames({
|
|
1417
|
+
name: 'wrapped-with-subnames.eth',
|
|
1418
|
+
pageSize: 1,
|
|
1419
|
+
orderBy: 'createdAt',
|
|
1420
|
+
orderDirection: 'asc',
|
|
1421
|
+
search: 'a',
|
|
1422
|
+
})
|
|
1423
|
+
expect(result).toBeTruthy()
|
|
1424
|
+
expect(result.subnames.length).toBe(1)
|
|
1425
|
+
expect(result.subnameCount).toBe(4)
|
|
1426
|
+
expect(result.subnames[0].name).toEqual(
|
|
1427
|
+
'legacy.wrapped-with-subnames.eth',
|
|
1428
|
+
)
|
|
1429
|
+
expect(
|
|
1430
|
+
result.subnames.every((subname, i, arr) => {
|
|
1431
|
+
if (arr[i + 1]) {
|
|
1432
|
+
return (subname as any).createdAt <= (arr[i + 1] as any).createdAt
|
|
1433
|
+
}
|
|
1434
|
+
return true
|
|
1435
|
+
}),
|
|
1436
|
+
).toBe(true)
|
|
1437
|
+
testProperties(
|
|
1438
|
+
result.subnames[0],
|
|
1439
|
+
'id',
|
|
1440
|
+
'labelName',
|
|
1441
|
+
'labelhash',
|
|
1442
|
+
'name',
|
|
1443
|
+
'isMigrated',
|
|
1444
|
+
'owner',
|
|
1445
|
+
'truncatedName',
|
|
1446
|
+
)
|
|
1447
|
+
const result2 = await ensInstance.getSubnames({
|
|
1448
|
+
name: 'wrapped-with-subnames.eth',
|
|
1449
|
+
page: 0,
|
|
1450
|
+
pageSize: 2,
|
|
1451
|
+
orderBy: 'createdAt',
|
|
1452
|
+
orderDirection: 'asc',
|
|
1453
|
+
lastSubnames: result.subnames,
|
|
1454
|
+
search: 'a',
|
|
1455
|
+
})
|
|
700
1456
|
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
1457
|
+
expect(result2).toBeTruthy()
|
|
1458
|
+
expect(result2.subnames.length).toBe(1)
|
|
1459
|
+
expect(result2.subnameCount).toBe(4)
|
|
1460
|
+
expect(result2.subnames[0].name).toEqual(
|
|
1461
|
+
'addr.wrapped-with-subnames.eth',
|
|
1462
|
+
)
|
|
1463
|
+
|
|
1464
|
+
testProperties(
|
|
1465
|
+
result2.subnames[0],
|
|
1466
|
+
'id',
|
|
1467
|
+
'labelName',
|
|
1468
|
+
'labelhash',
|
|
1469
|
+
'name',
|
|
1470
|
+
'isMigrated',
|
|
1471
|
+
'owner',
|
|
1472
|
+
'truncatedName',
|
|
1473
|
+
)
|
|
708
1474
|
})
|
|
709
|
-
expect(result2).toBeTruthy()
|
|
710
|
-
expect(result2.subnames.length).toBe(1)
|
|
711
|
-
expect(result2.subnameCount).toBe(4)
|
|
712
|
-
expect(result2.subnames[0].name).toEqual('legacy.with-subnames.eth')
|
|
713
1475
|
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
1476
|
+
it('should get paginated subnames for a name by labelName in desc order', async () => {
|
|
1477
|
+
const result = await ensInstance.getSubnames({
|
|
1478
|
+
name: 'wrapped-with-subnames.eth',
|
|
1479
|
+
pageSize: 1,
|
|
1480
|
+
orderBy: 'labelName',
|
|
1481
|
+
orderDirection: 'desc',
|
|
1482
|
+
search: 'a',
|
|
1483
|
+
})
|
|
1484
|
+
expect(result).toBeTruthy()
|
|
1485
|
+
expect(result.subnames.length).toBe(1)
|
|
1486
|
+
expect(result.subnameCount).toBe(4)
|
|
1487
|
+
expect(result.subnames[0].name).toEqual(
|
|
1488
|
+
'legacy.wrapped-with-subnames.eth',
|
|
1489
|
+
)
|
|
1490
|
+
testProperties(
|
|
1491
|
+
result.subnames[0],
|
|
1492
|
+
'id',
|
|
1493
|
+
'labelName',
|
|
1494
|
+
'labelhash',
|
|
1495
|
+
'name',
|
|
1496
|
+
'isMigrated',
|
|
1497
|
+
'owner',
|
|
1498
|
+
'truncatedName',
|
|
1499
|
+
)
|
|
1500
|
+
const result2 = await ensInstance.getSubnames({
|
|
1501
|
+
name: 'wrapped-with-subnames.eth',
|
|
1502
|
+
pageSize: 1,
|
|
1503
|
+
orderBy: 'labelName',
|
|
1504
|
+
orderDirection: 'desc',
|
|
1505
|
+
lastSubnames: result.subnames,
|
|
1506
|
+
search: 'a',
|
|
1507
|
+
})
|
|
1508
|
+
expect(result2).toBeTruthy()
|
|
1509
|
+
expect(result2.subnames.length).toBe(1)
|
|
1510
|
+
expect(result2.subnameCount).toBe(4)
|
|
1511
|
+
expect(result2.subnames[0].name).toEqual(
|
|
1512
|
+
'addr.wrapped-with-subnames.eth',
|
|
1513
|
+
)
|
|
1514
|
+
testProperties(
|
|
1515
|
+
result.subnames[0],
|
|
1516
|
+
'id',
|
|
1517
|
+
'labelName',
|
|
1518
|
+
'labelhash',
|
|
1519
|
+
'name',
|
|
1520
|
+
'isMigrated',
|
|
1521
|
+
'owner',
|
|
1522
|
+
'truncatedName',
|
|
1523
|
+
)
|
|
1524
|
+
})
|
|
1525
|
+
|
|
1526
|
+
it('should get paginated subnames for a name by labelName in asc order', async () => {
|
|
1527
|
+
const result = await ensInstance.getSubnames({
|
|
1528
|
+
name: 'wrapped-with-subnames.eth',
|
|
1529
|
+
pageSize: 1,
|
|
1530
|
+
orderBy: 'labelName',
|
|
1531
|
+
orderDirection: 'asc',
|
|
1532
|
+
search: 'a',
|
|
1533
|
+
})
|
|
1534
|
+
expect(result).toBeTruthy()
|
|
1535
|
+
expect(result.subnames.length).toBe(1)
|
|
1536
|
+
expect(result.subnameCount).toBe(4)
|
|
1537
|
+
expect(result.subnames[0].name).toEqual(
|
|
1538
|
+
'addr.wrapped-with-subnames.eth',
|
|
1539
|
+
)
|
|
1540
|
+
|
|
1541
|
+
testProperties(
|
|
1542
|
+
result.subnames[0],
|
|
1543
|
+
'id',
|
|
1544
|
+
'labelName',
|
|
1545
|
+
'labelhash',
|
|
1546
|
+
'name',
|
|
1547
|
+
'isMigrated',
|
|
1548
|
+
'owner',
|
|
1549
|
+
'truncatedName',
|
|
1550
|
+
)
|
|
1551
|
+
|
|
1552
|
+
const result2 = await ensInstance.getSubnames({
|
|
1553
|
+
name: 'wrapped-with-subnames.eth',
|
|
1554
|
+
pageSize: 1,
|
|
1555
|
+
orderBy: 'labelName',
|
|
1556
|
+
orderDirection: 'asc',
|
|
1557
|
+
lastSubnames: result.subnames,
|
|
1558
|
+
search: 'a',
|
|
1559
|
+
})
|
|
1560
|
+
expect(result2).toBeTruthy()
|
|
1561
|
+
expect(result2.subnames.length).toBe(1)
|
|
1562
|
+
expect(result2.subnameCount).toBe(4)
|
|
1563
|
+
expect(result2.subnames[0].name).toEqual(
|
|
1564
|
+
'legacy.wrapped-with-subnames.eth',
|
|
1565
|
+
)
|
|
1566
|
+
|
|
1567
|
+
testProperties(
|
|
1568
|
+
result2.subnames[0],
|
|
1569
|
+
'id',
|
|
1570
|
+
'labelName',
|
|
1571
|
+
'labelhash',
|
|
1572
|
+
'name',
|
|
1573
|
+
'isMigrated',
|
|
1574
|
+
'owner',
|
|
1575
|
+
'truncatedName',
|
|
1576
|
+
)
|
|
1577
|
+
})
|
|
724
1578
|
})
|
|
725
1579
|
})
|
|
726
1580
|
})
|