@ensdomains/ensjs 3.0.0-alpha.45 → 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/getNames.js +25 -13
- package/dist/cjs/functions/getSubnames.js +32 -8
- package/dist/cjs/functions/transferSubname.js +4 -9
- package/dist/cjs/index.js +1 -1
- package/dist/cjs/utils/consts.js +1 -1
- package/dist/cjs/utils/fuses.js +2 -0
- 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/getNames.mjs +26 -14
- package/dist/esm/functions/getSubnames.mjs +32 -8
- package/dist/esm/functions/transferSubname.mjs +5 -10
- package/dist/esm/index.mjs +1 -1
- package/dist/esm/utils/consts.mjs +1 -1
- package/dist/esm/utils/fuses.mjs +2 -0
- 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/getSubnames.d.ts +16 -4
- package/dist/types/functions/transferSubname.d.ts +1 -1
- package/dist/types/index.d.ts +62 -4
- package/dist/types/utils/fuses.d.ts +1 -0
- 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 +15 -2
- package/src/functions/getNames.ts +46 -22
- package/src/functions/getSubnames.test.ts +1227 -322
- package/src/functions/getSubnames.ts +62 -13
- 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/consts.ts +1 -1
- package/src/utils/fuses.ts +3 -0
- package/src/utils/registry.ts +14 -0
- package/src/utils/wrapper.ts +12 -9
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { ENS } from '..'
|
|
2
2
|
import setup from '../tests/setup'
|
|
3
|
+
import { decodeFuses } from '../utils/fuses'
|
|
3
4
|
|
|
4
5
|
let ensInstance: ENS
|
|
5
6
|
|
|
@@ -130,20 +131,72 @@ describe('getSubnames', () => {
|
|
|
130
131
|
'truncatedName',
|
|
131
132
|
)
|
|
132
133
|
})
|
|
134
|
+
describe('wrapped subnames', () => {
|
|
135
|
+
it('should return fuses', async () => {
|
|
136
|
+
const result = await ensInstance.getSubnames({
|
|
137
|
+
name: 'wrapped-with-subnames.eth',
|
|
138
|
+
pageSize: 10,
|
|
139
|
+
orderBy: 'createdAt',
|
|
140
|
+
orderDirection: 'desc',
|
|
141
|
+
})
|
|
142
|
+
|
|
143
|
+
expect(result).toBeTruthy()
|
|
144
|
+
expect(result.subnames.length).toBe(4)
|
|
145
|
+
expect(result.subnameCount).toBe(4)
|
|
146
|
+
expect(result.subnames[0].fuses).toBeDefined()
|
|
147
|
+
})
|
|
148
|
+
it('should return expiry as undefined if 0', async () => {
|
|
149
|
+
const result = await ensInstance.getSubnames({
|
|
150
|
+
name: 'wrapped-with-expiring-subnames.eth',
|
|
151
|
+
pageSize: 10,
|
|
152
|
+
orderBy: 'createdAt',
|
|
153
|
+
orderDirection: 'desc',
|
|
154
|
+
})
|
|
155
|
+
|
|
156
|
+
expect(result).toBeTruthy()
|
|
157
|
+
expect(result.subnames[1].expiryDate).toBeUndefined()
|
|
158
|
+
})
|
|
159
|
+
it('should return expiry', async () => {
|
|
160
|
+
const result = await ensInstance.getSubnames({
|
|
161
|
+
name: 'wrapped-with-expiring-subnames.eth',
|
|
162
|
+
pageSize: 10,
|
|
163
|
+
orderBy: 'createdAt',
|
|
164
|
+
orderDirection: 'desc',
|
|
165
|
+
})
|
|
166
|
+
|
|
167
|
+
expect(result).toBeTruthy()
|
|
168
|
+
expect(result.subnames[2].expiryDate).toBeInstanceOf(Date)
|
|
169
|
+
})
|
|
170
|
+
it('should return owner as undefined, fuses as 0, and pccExpired as true if pcc expired', async () => {
|
|
171
|
+
const result = await ensInstance.getSubnames({
|
|
172
|
+
name: 'wrapped-with-expiring-subnames.eth',
|
|
173
|
+
pageSize: 10,
|
|
174
|
+
orderBy: 'createdAt',
|
|
175
|
+
orderDirection: 'desc',
|
|
176
|
+
})
|
|
177
|
+
|
|
178
|
+
expect(result).toBeTruthy()
|
|
179
|
+
expect(result.subnames[0].owner).toBeUndefined()
|
|
180
|
+
expect(result.subnames[0].fuses).toStrictEqual(decodeFuses(0))
|
|
181
|
+
expect(result.subnames[0].pccExpired).toBe(true)
|
|
182
|
+
})
|
|
183
|
+
})
|
|
133
184
|
|
|
134
185
|
describe('with pagination', () => {
|
|
135
186
|
it('should get paginated subnames for a name ordered by createdAt in desc order', async () => {
|
|
136
187
|
const result = await ensInstance.getSubnames({
|
|
137
188
|
name: 'with-subnames.eth',
|
|
138
|
-
pageSize:
|
|
189
|
+
pageSize: 10,
|
|
139
190
|
orderBy: 'createdAt',
|
|
140
191
|
orderDirection: 'desc',
|
|
141
192
|
})
|
|
142
193
|
expect(result).toBeTruthy()
|
|
143
|
-
expect(result.subnames.length).toBe(
|
|
194
|
+
expect(result.subnames.length).toBe(4)
|
|
144
195
|
expect(result.subnameCount).toBe(4)
|
|
145
196
|
expect(result.subnames[0].name).toEqual('addr.with-subnames.eth')
|
|
146
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')
|
|
147
200
|
expect(
|
|
148
201
|
result.subnames.every((subname, i, arr) => {
|
|
149
202
|
if (arr[i + 1]) {
|
|
@@ -162,50 +215,22 @@ describe('getSubnames', () => {
|
|
|
162
215
|
'owner',
|
|
163
216
|
'truncatedName',
|
|
164
217
|
)
|
|
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
218
|
})
|
|
196
219
|
|
|
197
|
-
it('should get
|
|
220
|
+
it('should get the subnames for a name ordered by createdAt in asc order', async () => {
|
|
198
221
|
const result = await ensInstance.getSubnames({
|
|
199
222
|
name: 'with-subnames.eth',
|
|
200
|
-
pageSize:
|
|
223
|
+
pageSize: 10,
|
|
201
224
|
orderBy: 'createdAt',
|
|
202
225
|
orderDirection: 'asc',
|
|
203
226
|
})
|
|
204
227
|
expect(result).toBeTruthy()
|
|
205
|
-
expect(result.subnames.length).toBe(
|
|
228
|
+
expect(result.subnames.length).toBe(4)
|
|
206
229
|
expect(result.subnameCount).toBe(4)
|
|
207
230
|
expect(result.subnames[0].name).toEqual('test.with-subnames.eth')
|
|
208
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')
|
|
209
234
|
expect(
|
|
210
235
|
result.subnames.every((subname, i, arr) => {
|
|
211
236
|
if (arr[i + 1]) {
|
|
@@ -224,74 +249,22 @@ describe('getSubnames', () => {
|
|
|
224
249
|
'owner',
|
|
225
250
|
'truncatedName',
|
|
226
251
|
)
|
|
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
252
|
})
|
|
260
253
|
|
|
261
|
-
it('should get
|
|
254
|
+
it('should get the subnames for a name by labelName in desc order', async () => {
|
|
262
255
|
const result = await ensInstance.getSubnames({
|
|
263
256
|
name: 'with-subnames.eth',
|
|
264
|
-
pageSize:
|
|
257
|
+
pageSize: 10,
|
|
265
258
|
orderBy: 'labelName',
|
|
266
259
|
orderDirection: 'desc',
|
|
267
260
|
})
|
|
268
261
|
expect(result).toBeTruthy()
|
|
269
|
-
expect(result.subnames.length).toBe(
|
|
262
|
+
expect(result.subnames.length).toBe(4)
|
|
270
263
|
expect(result.subnameCount).toBe(4)
|
|
271
264
|
expect(result.subnames[0].name).toEqual('xyz.with-subnames.eth')
|
|
272
265
|
expect(result.subnames[1].name).toEqual('test.with-subnames.eth')
|
|
273
|
-
|
|
274
|
-
|
|
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')
|
|
266
|
+
expect(result.subnames[2].name).toEqual('legacy.with-subnames.eth')
|
|
267
|
+
expect(result.subnames[3].name).toEqual('addr.with-subnames.eth')
|
|
295
268
|
testProperties(
|
|
296
269
|
result.subnames[0],
|
|
297
270
|
'id',
|
|
@@ -304,19 +277,20 @@ describe('getSubnames', () => {
|
|
|
304
277
|
)
|
|
305
278
|
})
|
|
306
279
|
|
|
307
|
-
it('should get
|
|
280
|
+
it('should get the subnames for a name by labelName in asc order', async () => {
|
|
308
281
|
const result = await ensInstance.getSubnames({
|
|
309
282
|
name: 'with-subnames.eth',
|
|
310
|
-
pageSize:
|
|
283
|
+
pageSize: 10,
|
|
311
284
|
orderBy: 'labelName',
|
|
312
285
|
orderDirection: 'asc',
|
|
313
286
|
})
|
|
314
287
|
expect(result).toBeTruthy()
|
|
315
|
-
expect(result.subnames.length).toBe(
|
|
288
|
+
expect(result.subnames.length).toBe(4)
|
|
316
289
|
expect(result.subnameCount).toBe(4)
|
|
317
290
|
expect(result.subnames[0].name).toEqual('addr.with-subnames.eth')
|
|
318
291
|
expect(result.subnames[1].name).toEqual('legacy.with-subnames.eth')
|
|
319
|
-
|
|
292
|
+
expect(result.subnames[2].name).toEqual('test.with-subnames.eth')
|
|
293
|
+
expect(result.subnames[3].name).toEqual('xyz.with-subnames.eth')
|
|
320
294
|
testProperties(
|
|
321
295
|
result.subnames[0],
|
|
322
296
|
'id',
|
|
@@ -327,47 +301,568 @@ describe('getSubnames', () => {
|
|
|
327
301
|
'owner',
|
|
328
302
|
'truncatedName',
|
|
329
303
|
)
|
|
304
|
+
})
|
|
330
305
|
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
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
|
+
)
|
|
337
367
|
})
|
|
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
368
|
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
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
|
+
})
|
|
354
846
|
})
|
|
355
847
|
})
|
|
356
848
|
|
|
357
|
-
describe('
|
|
358
|
-
it('should get the
|
|
849
|
+
describe('wrapped', () => {
|
|
850
|
+
it('should get the subnames for a name ordered by createdAt in desc order', async () => {
|
|
359
851
|
const result = await ensInstance.getSubnames({
|
|
360
|
-
name: 'with-subnames.eth',
|
|
852
|
+
name: 'wrapped-with-subnames.eth',
|
|
361
853
|
pageSize: 10,
|
|
362
854
|
orderBy: 'createdAt',
|
|
363
855
|
orderDirection: 'desc',
|
|
364
|
-
search: 'a',
|
|
365
856
|
})
|
|
366
857
|
expect(result).toBeTruthy()
|
|
367
|
-
expect(result.subnames.length).toBe(
|
|
858
|
+
expect(result.subnames.length).toBe(4)
|
|
368
859
|
expect(result.subnameCount).toBe(4)
|
|
369
|
-
expect(result.subnames[0].name).toEqual('addr.with-subnames.eth')
|
|
370
|
-
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')
|
|
371
866
|
expect(
|
|
372
867
|
result.subnames.every((subname, i, arr) => {
|
|
373
868
|
if (arr[i + 1]) {
|
|
@@ -388,20 +883,22 @@ describe('getSubnames', () => {
|
|
|
388
883
|
)
|
|
389
884
|
})
|
|
390
885
|
|
|
391
|
-
it('should get the
|
|
886
|
+
it('should get the subnames for a name ordered by createdAt in asc order', async () => {
|
|
392
887
|
const result = await ensInstance.getSubnames({
|
|
393
|
-
name: 'with-subnames.eth',
|
|
394
|
-
page: 0,
|
|
888
|
+
name: 'wrapped-with-subnames.eth',
|
|
395
889
|
pageSize: 10,
|
|
396
890
|
orderBy: 'createdAt',
|
|
397
891
|
orderDirection: 'asc',
|
|
398
|
-
search: 'a',
|
|
399
892
|
})
|
|
400
893
|
expect(result).toBeTruthy()
|
|
401
|
-
expect(result.subnames.length).toBe(
|
|
894
|
+
expect(result.subnames.length).toBe(4)
|
|
402
895
|
expect(result.subnameCount).toBe(4)
|
|
403
|
-
expect(result.subnames[0].name).toEqual('
|
|
404
|
-
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')
|
|
405
902
|
expect(
|
|
406
903
|
result.subnames.every((subname, i, arr) => {
|
|
407
904
|
if (arr[i + 1]) {
|
|
@@ -424,17 +921,20 @@ describe('getSubnames', () => {
|
|
|
424
921
|
|
|
425
922
|
it('should get the subnames for a name by labelName in desc order', async () => {
|
|
426
923
|
const result = await ensInstance.getSubnames({
|
|
427
|
-
name: 'with-subnames.eth',
|
|
924
|
+
name: 'wrapped-with-subnames.eth',
|
|
428
925
|
pageSize: 10,
|
|
429
926
|
orderBy: 'labelName',
|
|
430
927
|
orderDirection: 'desc',
|
|
431
|
-
search: 'a',
|
|
432
928
|
})
|
|
433
929
|
expect(result).toBeTruthy()
|
|
434
|
-
expect(result.subnames.length).toBe(
|
|
930
|
+
expect(result.subnames.length).toBe(4)
|
|
435
931
|
expect(result.subnameCount).toBe(4)
|
|
436
|
-
expect(result.subnames[0].name).toEqual('
|
|
437
|
-
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')
|
|
438
938
|
testProperties(
|
|
439
939
|
result.subnames[0],
|
|
440
940
|
'id',
|
|
@@ -449,17 +949,20 @@ describe('getSubnames', () => {
|
|
|
449
949
|
|
|
450
950
|
it('should get the subnames for a name by labelName in asc order', async () => {
|
|
451
951
|
const result = await ensInstance.getSubnames({
|
|
452
|
-
name: 'with-subnames.eth',
|
|
952
|
+
name: 'wrapped-with-subnames.eth',
|
|
453
953
|
pageSize: 10,
|
|
454
954
|
orderBy: 'labelName',
|
|
455
955
|
orderDirection: 'asc',
|
|
456
|
-
search: 'a',
|
|
457
956
|
})
|
|
458
957
|
expect(result).toBeTruthy()
|
|
459
|
-
expect(result.subnames.length).toBe(
|
|
958
|
+
expect(result.subnames.length).toBe(4)
|
|
460
959
|
expect(result.subnameCount).toBe(4)
|
|
461
|
-
expect(result.subnames[0].name).toEqual('addr.with-subnames.eth')
|
|
462
|
-
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')
|
|
463
966
|
testProperties(
|
|
464
967
|
result.subnames[0],
|
|
465
968
|
'id',
|
|
@@ -471,205 +974,607 @@ describe('getSubnames', () => {
|
|
|
471
974
|
'truncatedName',
|
|
472
975
|
)
|
|
473
976
|
})
|
|
474
|
-
})
|
|
475
977
|
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
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
|
+
)
|
|
484
1045
|
})
|
|
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
1046
|
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
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
|
+
)
|
|
530
1117
|
})
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
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
|
+
)
|
|
561
1169
|
})
|
|
562
1170
|
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
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
|
+
)
|
|
567
1187
|
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
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
|
+
})
|
|
578
1227
|
})
|
|
579
1228
|
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
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
|
+
)
|
|
587
1265
|
})
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
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
|
+
)
|
|
609
1361
|
})
|
|
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
1362
|
})
|
|
625
1363
|
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
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
|
+
)
|
|
633
1413
|
})
|
|
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
1414
|
|
|
639
|
-
|
|
640
|
-
result.
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
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
|
+
})
|
|
649
1456
|
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
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
|
+
)
|
|
657
1474
|
})
|
|
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
1475
|
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
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
|
+
})
|
|
673
1578
|
})
|
|
674
1579
|
})
|
|
675
1580
|
})
|