@xyo-network/xns-record-payload-plugins 4.1.1 → 5.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (47) hide show
  1. package/dist/browser/DNS/Witness/Payload/Request.d.ts +2 -2
  2. package/dist/browser/DNS/Witness/Payload/Request.d.ts.map +1 -1
  3. package/dist/browser/DNS/Witness/Payload/Response.d.ts +2 -2
  4. package/dist/browser/DNS/Witness/Payload/Response.d.ts.map +1 -1
  5. package/dist/browser/Domain/Domain.d.ts +2 -2
  6. package/dist/browser/Domain/Domain.d.ts.map +1 -1
  7. package/dist/browser/Domain/DomainLease.d.ts +2 -2
  8. package/dist/browser/Domain/DomainLease.d.ts.map +1 -1
  9. package/dist/browser/DomainRegistration/DomainRegistration.d.ts +2 -2
  10. package/dist/browser/DomainRegistration/DomainRegistration.d.ts.map +1 -1
  11. package/dist/browser/DomainRegistration/DomainRegistrationLease.d.ts +2 -2
  12. package/dist/browser/DomainRegistration/DomainRegistrationLease.d.ts.map +1 -1
  13. package/dist/browser/index.d.ts +9 -414
  14. package/dist/neutral/DNS/Witness/Payload/Request.d.ts +2 -2
  15. package/dist/neutral/DNS/Witness/Payload/Request.d.ts.map +1 -1
  16. package/dist/neutral/DNS/Witness/Payload/Response.d.ts +2 -2
  17. package/dist/neutral/DNS/Witness/Payload/Response.d.ts.map +1 -1
  18. package/dist/neutral/Domain/Domain.d.ts +2 -2
  19. package/dist/neutral/Domain/Domain.d.ts.map +1 -1
  20. package/dist/neutral/Domain/DomainLease.d.ts +2 -2
  21. package/dist/neutral/Domain/DomainLease.d.ts.map +1 -1
  22. package/dist/neutral/DomainRegistration/DomainRegistration.d.ts +2 -2
  23. package/dist/neutral/DomainRegistration/DomainRegistration.d.ts.map +1 -1
  24. package/dist/neutral/DomainRegistration/DomainRegistrationLease.d.ts +2 -2
  25. package/dist/neutral/DomainRegistration/DomainRegistrationLease.d.ts.map +1 -1
  26. package/dist/neutral/index.d.ts +9 -414
  27. package/dist/node/DNS/Witness/Payload/Request.d.ts +2 -2
  28. package/dist/node/DNS/Witness/Payload/Request.d.ts.map +1 -1
  29. package/dist/node/DNS/Witness/Payload/Response.d.ts +2 -2
  30. package/dist/node/DNS/Witness/Payload/Response.d.ts.map +1 -1
  31. package/dist/node/Domain/Domain.d.ts +2 -2
  32. package/dist/node/Domain/Domain.d.ts.map +1 -1
  33. package/dist/node/Domain/DomainLease.d.ts +2 -2
  34. package/dist/node/Domain/DomainLease.d.ts.map +1 -1
  35. package/dist/node/DomainRegistration/DomainRegistration.d.ts +2 -2
  36. package/dist/node/DomainRegistration/DomainRegistration.d.ts.map +1 -1
  37. package/dist/node/DomainRegistration/DomainRegistrationLease.d.ts +2 -2
  38. package/dist/node/DomainRegistration/DomainRegistrationLease.d.ts.map +1 -1
  39. package/dist/node/index.d.ts +9 -414
  40. package/package.json +23 -20
  41. package/src/Duration/validation/spec/validateBoundWitness.spec.ts +46 -0
  42. package/src/Duration/validation/spec/validateBoundWitnessWithRecord.spec.ts +49 -0
  43. package/src/Duration/validation/spec/validateNameserverRecord.spec.ts +61 -0
  44. package/src/Duration/validation/spec/validateRecord.spec.ts +37 -0
  45. package/src/diviner/lib/spec/__snapshots__/parseEstimatesFromArray.spec.ts.snap +481 -0
  46. package/src/diviner/lib/spec/parseEstimatesFromArray.spec.ts +116 -0
  47. package/typedoc.json +0 -5
@@ -0,0 +1,37 @@
1
+ import '@xylabs/vitest-extended'
2
+
3
+ import type { Payload } from '@xyo-network/payload-model'
4
+ import {
5
+ describe, expect, it,
6
+ } from 'vitest'
7
+
8
+ import type { DurationFields } from '../../Duration.ts'
9
+ import { validateDuration } from '../validateDuration.ts'
10
+
11
+ describe('validateRecord', () => {
12
+ const schema = 'network.xyo.test'
13
+ const recordPayload = {
14
+ domain: 'foo.xyo',
15
+ exp: Date.now() + 1_000_000,
16
+ nameserver: ['e007fb034344d8e559b224156fe08627e5c8ea1c'],
17
+ nbf: Date.now(),
18
+ schema,
19
+ }
20
+ describe('returns true', () => {
21
+ it('with valid record', () => {
22
+ expect(validateDuration(recordPayload)).toBeTrue()
23
+ })
24
+ })
25
+ describe('returns false', () => {
26
+ describe('with invalid time range', () => {
27
+ it('when current time is before nbf', () => {
28
+ const payload: Payload<DurationFields> = { ...recordPayload, nbf: Date.now() + 10_000 }
29
+ expect(validateDuration(payload)).toBeFalse()
30
+ })
31
+ it('when current time is after exp', () => {
32
+ const payload: Payload<DurationFields> = { ...recordPayload, exp: Date.now() - 1 }
33
+ expect(validateDuration(payload)).toBeFalse()
34
+ })
35
+ })
36
+ })
37
+ })
@@ -0,0 +1,481 @@
1
+ // Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
2
+
3
+ exports[`parseEstimatesFromArray > with valid jagged data > parses estimates from array 1`] = `[]`;
4
+
5
+ exports[`parseEstimatesFromArray > with valid jagged data > parses estimates from array 2`] = `[]`;
6
+
7
+ exports[`parseEstimatesFromArray > with valid jagged data > parses estimates from array 3`] = `
8
+ [
9
+ [
10
+ {
11
+ "$signatures": [
12
+ "91519424f721376751b19865433ff80e3d47b2a59be6f7478e7e003e0366ccc730c1dd7eeaa642ced9e78a40c5a5a3ab33044a6d620f5a4467dfbd0e2d9dc4d8",
13
+ ],
14
+ "addresses": [
15
+ "9146761e29463d783e28161848feeeb43196227b",
16
+ ],
17
+ "payload_hashes": [
18
+ "abb7ecb2cfc51e1a95f85477b3a4210a72886d5b22fcf32043736c48e2873f2c",
19
+ "3ed825d48507b899395ca943e1dd6ec9a7c948e1cd1573a6cfda66de83af4b11",
20
+ ],
21
+ "payload_schemas": [
22
+ "network.xyo.hash.lease.estimate",
23
+ "network.xyo.ns.domain.registration.lease",
24
+ ],
25
+ "previous_hashes": [
26
+ null,
27
+ ],
28
+ "schema": "network.xyo.boundwitness",
29
+ },
30
+ {
31
+ "$sources": [
32
+ "90259bc9ecde9d4c0061bc92dbfcf32e0f7b2603e49443d9f3c67a6d7e82c7d5",
33
+ ],
34
+ "currency": "USD",
35
+ "exp": 1725225514773,
36
+ "nbf": 1724966314773,
37
+ "price": 16,
38
+ "schema": "network.xyo.hash.lease.estimate",
39
+ },
40
+ {
41
+ "$sources": [
42
+ "407ed63c0c36fadae7ae8d16a42b678551e0ea6aa5357b76f0ffc1bce3ba2f22",
43
+ "ced04c0a3f65bbefde58ba0d15767fcee20b6e25d3820f90c55f44f18effa70f",
44
+ ],
45
+ "domain": "testb88a0ee2-9665-48b3-b9c6-047eadc475ee",
46
+ "exp": 1756502314773,
47
+ "nbf": 1724966314773,
48
+ "registrant": [
49
+ "1b2c45910fb0d32cb1d1cd010cbc594bf05969b5",
50
+ ],
51
+ "registrar": [
52
+ "846c35ce6ec62e4608a1215e14b5b16471904153",
53
+ ],
54
+ "schema": "network.xyo.ns.domain.registration.lease",
55
+ "tld": "xyo",
56
+ },
57
+ ],
58
+ ]
59
+ `;
60
+
61
+ exports[`parseEstimatesFromArray > with valid jagged data > parses estimates from array 4`] = `
62
+ [
63
+ [
64
+ {
65
+ "$signatures": [
66
+ "2a59fea264bf71603f9908ac557cf5816ddd1898ce26a2cbb8081195cf5a19381bf42cc2e583a9a2a768dc324c6ac1344eb4ec06f41b19b06970734b30340226",
67
+ ],
68
+ "addresses": [
69
+ "ce5ba87678f8b5e2d0dbccf2fabff65f79191f73",
70
+ ],
71
+ "payload_hashes": [
72
+ "49699c9d1cfb1a8643037c9557123a9e643a3dd938f619af39b94966ecfdd6ff",
73
+ "af31f9d6afd8f7cbbe5c3310f2a2da9e1af31d1b7cf8dae7d9786848de1e5bd7",
74
+ ],
75
+ "payload_schemas": [
76
+ "network.xyo.hash.lease.estimate",
77
+ "network.xyo.ns.domain.registration.lease",
78
+ ],
79
+ "previous_hashes": [
80
+ null,
81
+ ],
82
+ "schema": "network.xyo.boundwitness",
83
+ },
84
+ {
85
+ "$sources": [
86
+ "dcc7ab18c86d90311bb1b59361f6698e2714294a91aa3126c554aa8483a7ae37",
87
+ ],
88
+ "currency": "USD",
89
+ "exp": 1725225427392,
90
+ "nbf": 1724966227392,
91
+ "price": 16,
92
+ "schema": "network.xyo.hash.lease.estimate",
93
+ },
94
+ {
95
+ "$sources": [
96
+ "fccd06633e70c2168c8eb0eb5e25b22e34c1c417a46d5073034ec977dfc1995d",
97
+ "d7f40698fb0b0261834ef694ed275b4e6547e329cedc1c56708f098a5608b93a",
98
+ ],
99
+ "domain": "test8446e171-46ca-47d5-a3b7-1a658cb7f451",
100
+ "exp": 1756502227392,
101
+ "nbf": 1724966227392,
102
+ "registrant": [
103
+ "1b2c45910fb0d32cb1d1cd010cbc594bf05969b5",
104
+ ],
105
+ "registrar": [
106
+ "846c35ce6ec62e4608a1215e14b5b16471904153",
107
+ ],
108
+ "schema": "network.xyo.ns.domain.registration.lease",
109
+ "tld": "xyo",
110
+ },
111
+ ],
112
+ ]
113
+ `;
114
+
115
+ exports[`parseEstimatesFromArray > with valid jagged data > parses estimates from array 5`] = `
116
+ [
117
+ [
118
+ {
119
+ "$signatures": [
120
+ "91519424f721376751b19865433ff80e3d47b2a59be6f7478e7e003e0366ccc730c1dd7eeaa642ced9e78a40c5a5a3ab33044a6d620f5a4467dfbd0e2d9dc4d8",
121
+ ],
122
+ "addresses": [
123
+ "9146761e29463d783e28161848feeeb43196227b",
124
+ ],
125
+ "payload_hashes": [
126
+ "abb7ecb2cfc51e1a95f85477b3a4210a72886d5b22fcf32043736c48e2873f2c",
127
+ "3ed825d48507b899395ca943e1dd6ec9a7c948e1cd1573a6cfda66de83af4b11",
128
+ ],
129
+ "payload_schemas": [
130
+ "network.xyo.hash.lease.estimate",
131
+ "network.xyo.ns.domain.registration.lease",
132
+ ],
133
+ "previous_hashes": [
134
+ null,
135
+ ],
136
+ "schema": "network.xyo.boundwitness",
137
+ },
138
+ {
139
+ "$sources": [
140
+ "90259bc9ecde9d4c0061bc92dbfcf32e0f7b2603e49443d9f3c67a6d7e82c7d5",
141
+ ],
142
+ "currency": "USD",
143
+ "exp": 1725225514773,
144
+ "nbf": 1724966314773,
145
+ "price": 16,
146
+ "schema": "network.xyo.hash.lease.estimate",
147
+ },
148
+ {
149
+ "$sources": [
150
+ "407ed63c0c36fadae7ae8d16a42b678551e0ea6aa5357b76f0ffc1bce3ba2f22",
151
+ "ced04c0a3f65bbefde58ba0d15767fcee20b6e25d3820f90c55f44f18effa70f",
152
+ ],
153
+ "domain": "testb88a0ee2-9665-48b3-b9c6-047eadc475ee",
154
+ "exp": 1756502314773,
155
+ "nbf": 1724966314773,
156
+ "registrant": [
157
+ "1b2c45910fb0d32cb1d1cd010cbc594bf05969b5",
158
+ ],
159
+ "registrar": [
160
+ "846c35ce6ec62e4608a1215e14b5b16471904153",
161
+ ],
162
+ "schema": "network.xyo.ns.domain.registration.lease",
163
+ "tld": "xyo",
164
+ },
165
+ ],
166
+ ]
167
+ `;
168
+
169
+ exports[`parseEstimatesFromArray > with valid symmetric data > parses estimates from array 1`] = `
170
+ [
171
+ [
172
+ {
173
+ "$signatures": [
174
+ "2a59fea264bf71603f9908ac557cf5816ddd1898ce26a2cbb8081195cf5a19381bf42cc2e583a9a2a768dc324c6ac1344eb4ec06f41b19b06970734b30340226",
175
+ ],
176
+ "addresses": [
177
+ "ce5ba87678f8b5e2d0dbccf2fabff65f79191f73",
178
+ ],
179
+ "payload_hashes": [
180
+ "49699c9d1cfb1a8643037c9557123a9e643a3dd938f619af39b94966ecfdd6ff",
181
+ "af31f9d6afd8f7cbbe5c3310f2a2da9e1af31d1b7cf8dae7d9786848de1e5bd7",
182
+ ],
183
+ "payload_schemas": [
184
+ "network.xyo.hash.lease.estimate",
185
+ "network.xyo.ns.domain.registration.lease",
186
+ ],
187
+ "previous_hashes": [
188
+ null,
189
+ ],
190
+ "schema": "network.xyo.boundwitness",
191
+ },
192
+ {
193
+ "$sources": [
194
+ "dcc7ab18c86d90311bb1b59361f6698e2714294a91aa3126c554aa8483a7ae37",
195
+ ],
196
+ "currency": "USD",
197
+ "exp": 1725225427392,
198
+ "nbf": 1724966227392,
199
+ "price": 16,
200
+ "schema": "network.xyo.hash.lease.estimate",
201
+ },
202
+ {
203
+ "$sources": [
204
+ "fccd06633e70c2168c8eb0eb5e25b22e34c1c417a46d5073034ec977dfc1995d",
205
+ "d7f40698fb0b0261834ef694ed275b4e6547e329cedc1c56708f098a5608b93a",
206
+ ],
207
+ "domain": "test8446e171-46ca-47d5-a3b7-1a658cb7f451",
208
+ "exp": 1756502227392,
209
+ "nbf": 1724966227392,
210
+ "registrant": [
211
+ "1b2c45910fb0d32cb1d1cd010cbc594bf05969b5",
212
+ ],
213
+ "registrar": [
214
+ "846c35ce6ec62e4608a1215e14b5b16471904153",
215
+ ],
216
+ "schema": "network.xyo.ns.domain.registration.lease",
217
+ "tld": "xyo",
218
+ },
219
+ ],
220
+ ]
221
+ `;
222
+
223
+ exports[`parseEstimatesFromArray > with valid symmetric data > parses estimates from array 2`] = `
224
+ [
225
+ [
226
+ {
227
+ "$signatures": [
228
+ "91519424f721376751b19865433ff80e3d47b2a59be6f7478e7e003e0366ccc730c1dd7eeaa642ced9e78a40c5a5a3ab33044a6d620f5a4467dfbd0e2d9dc4d8",
229
+ ],
230
+ "addresses": [
231
+ "9146761e29463d783e28161848feeeb43196227b",
232
+ ],
233
+ "payload_hashes": [
234
+ "abb7ecb2cfc51e1a95f85477b3a4210a72886d5b22fcf32043736c48e2873f2c",
235
+ "3ed825d48507b899395ca943e1dd6ec9a7c948e1cd1573a6cfda66de83af4b11",
236
+ ],
237
+ "payload_schemas": [
238
+ "network.xyo.hash.lease.estimate",
239
+ "network.xyo.ns.domain.registration.lease",
240
+ ],
241
+ "previous_hashes": [
242
+ null,
243
+ ],
244
+ "schema": "network.xyo.boundwitness",
245
+ },
246
+ {
247
+ "$sources": [
248
+ "90259bc9ecde9d4c0061bc92dbfcf32e0f7b2603e49443d9f3c67a6d7e82c7d5",
249
+ ],
250
+ "currency": "USD",
251
+ "exp": 1725225514773,
252
+ "nbf": 1724966314773,
253
+ "price": 16,
254
+ "schema": "network.xyo.hash.lease.estimate",
255
+ },
256
+ {
257
+ "$sources": [
258
+ "407ed63c0c36fadae7ae8d16a42b678551e0ea6aa5357b76f0ffc1bce3ba2f22",
259
+ "ced04c0a3f65bbefde58ba0d15767fcee20b6e25d3820f90c55f44f18effa70f",
260
+ ],
261
+ "domain": "testb88a0ee2-9665-48b3-b9c6-047eadc475ee",
262
+ "exp": 1756502314773,
263
+ "nbf": 1724966314773,
264
+ "registrant": [
265
+ "1b2c45910fb0d32cb1d1cd010cbc594bf05969b5",
266
+ ],
267
+ "registrar": [
268
+ "846c35ce6ec62e4608a1215e14b5b16471904153",
269
+ ],
270
+ "schema": "network.xyo.ns.domain.registration.lease",
271
+ "tld": "xyo",
272
+ },
273
+ ],
274
+ ]
275
+ `;
276
+
277
+ exports[`parseEstimatesFromArray > with valid symmetric data > parses estimates from array 3`] = `
278
+ [
279
+ [
280
+ {
281
+ "$signatures": [
282
+ "2a59fea264bf71603f9908ac557cf5816ddd1898ce26a2cbb8081195cf5a19381bf42cc2e583a9a2a768dc324c6ac1344eb4ec06f41b19b06970734b30340226",
283
+ ],
284
+ "addresses": [
285
+ "ce5ba87678f8b5e2d0dbccf2fabff65f79191f73",
286
+ ],
287
+ "payload_hashes": [
288
+ "49699c9d1cfb1a8643037c9557123a9e643a3dd938f619af39b94966ecfdd6ff",
289
+ "af31f9d6afd8f7cbbe5c3310f2a2da9e1af31d1b7cf8dae7d9786848de1e5bd7",
290
+ ],
291
+ "payload_schemas": [
292
+ "network.xyo.hash.lease.estimate",
293
+ "network.xyo.ns.domain.registration.lease",
294
+ ],
295
+ "previous_hashes": [
296
+ null,
297
+ ],
298
+ "schema": "network.xyo.boundwitness",
299
+ },
300
+ {
301
+ "$sources": [
302
+ "dcc7ab18c86d90311bb1b59361f6698e2714294a91aa3126c554aa8483a7ae37",
303
+ ],
304
+ "currency": "USD",
305
+ "exp": 1725225427392,
306
+ "nbf": 1724966227392,
307
+ "price": 16,
308
+ "schema": "network.xyo.hash.lease.estimate",
309
+ },
310
+ {
311
+ "$sources": [
312
+ "fccd06633e70c2168c8eb0eb5e25b22e34c1c417a46d5073034ec977dfc1995d",
313
+ "d7f40698fb0b0261834ef694ed275b4e6547e329cedc1c56708f098a5608b93a",
314
+ ],
315
+ "domain": "test8446e171-46ca-47d5-a3b7-1a658cb7f451",
316
+ "exp": 1756502227392,
317
+ "nbf": 1724966227392,
318
+ "registrant": [
319
+ "1b2c45910fb0d32cb1d1cd010cbc594bf05969b5",
320
+ ],
321
+ "registrar": [
322
+ "846c35ce6ec62e4608a1215e14b5b16471904153",
323
+ ],
324
+ "schema": "network.xyo.ns.domain.registration.lease",
325
+ "tld": "xyo",
326
+ },
327
+ ],
328
+ [
329
+ {
330
+ "$signatures": [
331
+ "91519424f721376751b19865433ff80e3d47b2a59be6f7478e7e003e0366ccc730c1dd7eeaa642ced9e78a40c5a5a3ab33044a6d620f5a4467dfbd0e2d9dc4d8",
332
+ ],
333
+ "addresses": [
334
+ "9146761e29463d783e28161848feeeb43196227b",
335
+ ],
336
+ "payload_hashes": [
337
+ "abb7ecb2cfc51e1a95f85477b3a4210a72886d5b22fcf32043736c48e2873f2c",
338
+ "3ed825d48507b899395ca943e1dd6ec9a7c948e1cd1573a6cfda66de83af4b11",
339
+ ],
340
+ "payload_schemas": [
341
+ "network.xyo.hash.lease.estimate",
342
+ "network.xyo.ns.domain.registration.lease",
343
+ ],
344
+ "previous_hashes": [
345
+ null,
346
+ ],
347
+ "schema": "network.xyo.boundwitness",
348
+ },
349
+ {
350
+ "$sources": [
351
+ "90259bc9ecde9d4c0061bc92dbfcf32e0f7b2603e49443d9f3c67a6d7e82c7d5",
352
+ ],
353
+ "currency": "USD",
354
+ "exp": 1725225514773,
355
+ "nbf": 1724966314773,
356
+ "price": 16,
357
+ "schema": "network.xyo.hash.lease.estimate",
358
+ },
359
+ {
360
+ "$sources": [
361
+ "407ed63c0c36fadae7ae8d16a42b678551e0ea6aa5357b76f0ffc1bce3ba2f22",
362
+ "ced04c0a3f65bbefde58ba0d15767fcee20b6e25d3820f90c55f44f18effa70f",
363
+ ],
364
+ "domain": "testb88a0ee2-9665-48b3-b9c6-047eadc475ee",
365
+ "exp": 1756502314773,
366
+ "nbf": 1724966314773,
367
+ "registrant": [
368
+ "1b2c45910fb0d32cb1d1cd010cbc594bf05969b5",
369
+ ],
370
+ "registrar": [
371
+ "846c35ce6ec62e4608a1215e14b5b16471904153",
372
+ ],
373
+ "schema": "network.xyo.ns.domain.registration.lease",
374
+ "tld": "xyo",
375
+ },
376
+ ],
377
+ ]
378
+ `;
379
+
380
+ exports[`parseEstimatesFromArray > with valid symmetric data > parses estimates from array 4`] = `
381
+ [
382
+ [
383
+ {
384
+ "$signatures": [
385
+ "91519424f721376751b19865433ff80e3d47b2a59be6f7478e7e003e0366ccc730c1dd7eeaa642ced9e78a40c5a5a3ab33044a6d620f5a4467dfbd0e2d9dc4d8",
386
+ ],
387
+ "addresses": [
388
+ "9146761e29463d783e28161848feeeb43196227b",
389
+ ],
390
+ "payload_hashes": [
391
+ "abb7ecb2cfc51e1a95f85477b3a4210a72886d5b22fcf32043736c48e2873f2c",
392
+ "3ed825d48507b899395ca943e1dd6ec9a7c948e1cd1573a6cfda66de83af4b11",
393
+ ],
394
+ "payload_schemas": [
395
+ "network.xyo.hash.lease.estimate",
396
+ "network.xyo.ns.domain.registration.lease",
397
+ ],
398
+ "previous_hashes": [
399
+ null,
400
+ ],
401
+ "schema": "network.xyo.boundwitness",
402
+ },
403
+ {
404
+ "$sources": [
405
+ "90259bc9ecde9d4c0061bc92dbfcf32e0f7b2603e49443d9f3c67a6d7e82c7d5",
406
+ ],
407
+ "currency": "USD",
408
+ "exp": 1725225514773,
409
+ "nbf": 1724966314773,
410
+ "price": 16,
411
+ "schema": "network.xyo.hash.lease.estimate",
412
+ },
413
+ {
414
+ "$sources": [
415
+ "407ed63c0c36fadae7ae8d16a42b678551e0ea6aa5357b76f0ffc1bce3ba2f22",
416
+ "ced04c0a3f65bbefde58ba0d15767fcee20b6e25d3820f90c55f44f18effa70f",
417
+ ],
418
+ "domain": "testb88a0ee2-9665-48b3-b9c6-047eadc475ee",
419
+ "exp": 1756502314773,
420
+ "nbf": 1724966314773,
421
+ "registrant": [
422
+ "1b2c45910fb0d32cb1d1cd010cbc594bf05969b5",
423
+ ],
424
+ "registrar": [
425
+ "846c35ce6ec62e4608a1215e14b5b16471904153",
426
+ ],
427
+ "schema": "network.xyo.ns.domain.registration.lease",
428
+ "tld": "xyo",
429
+ },
430
+ ],
431
+ [
432
+ {
433
+ "$signatures": [
434
+ "2a59fea264bf71603f9908ac557cf5816ddd1898ce26a2cbb8081195cf5a19381bf42cc2e583a9a2a768dc324c6ac1344eb4ec06f41b19b06970734b30340226",
435
+ ],
436
+ "addresses": [
437
+ "ce5ba87678f8b5e2d0dbccf2fabff65f79191f73",
438
+ ],
439
+ "payload_hashes": [
440
+ "49699c9d1cfb1a8643037c9557123a9e643a3dd938f619af39b94966ecfdd6ff",
441
+ "af31f9d6afd8f7cbbe5c3310f2a2da9e1af31d1b7cf8dae7d9786848de1e5bd7",
442
+ ],
443
+ "payload_schemas": [
444
+ "network.xyo.hash.lease.estimate",
445
+ "network.xyo.ns.domain.registration.lease",
446
+ ],
447
+ "previous_hashes": [
448
+ null,
449
+ ],
450
+ "schema": "network.xyo.boundwitness",
451
+ },
452
+ {
453
+ "$sources": [
454
+ "dcc7ab18c86d90311bb1b59361f6698e2714294a91aa3126c554aa8483a7ae37",
455
+ ],
456
+ "currency": "USD",
457
+ "exp": 1725225427392,
458
+ "nbf": 1724966227392,
459
+ "price": 16,
460
+ "schema": "network.xyo.hash.lease.estimate",
461
+ },
462
+ {
463
+ "$sources": [
464
+ "fccd06633e70c2168c8eb0eb5e25b22e34c1c417a46d5073034ec977dfc1995d",
465
+ "d7f40698fb0b0261834ef694ed275b4e6547e329cedc1c56708f098a5608b93a",
466
+ ],
467
+ "domain": "test8446e171-46ca-47d5-a3b7-1a658cb7f451",
468
+ "exp": 1756502227392,
469
+ "nbf": 1724966227392,
470
+ "registrant": [
471
+ "1b2c45910fb0d32cb1d1cd010cbc594bf05969b5",
472
+ ],
473
+ "registrar": [
474
+ "846c35ce6ec62e4608a1215e14b5b16471904153",
475
+ ],
476
+ "schema": "network.xyo.ns.domain.registration.lease",
477
+ "tld": "xyo",
478
+ },
479
+ ],
480
+ ]
481
+ `;
@@ -0,0 +1,116 @@
1
+ import { matchers } from '@xylabs/vitest-matchers'
2
+ import type { Payload } from '@xyo-network/payload-model'
3
+ import {
4
+ describe, expect, it,
5
+ } from 'vitest'
6
+
7
+ import type { Estimate } from '../parseEstimatesFromArray.ts'
8
+ import { parseEstimatesFromArray } from '../parseEstimatesFromArray.ts'
9
+
10
+ expect.extend(matchers)
11
+
12
+ describe('parseEstimatesFromArray', () => {
13
+ const estimateA = [
14
+ {
15
+ addresses: ['ce5ba87678f8b5e2d0dbccf2fabff65f79191f73'],
16
+ payload_hashes: [
17
+ '49699c9d1cfb1a8643037c9557123a9e643a3dd938f619af39b94966ecfdd6ff',
18
+ 'af31f9d6afd8f7cbbe5c3310f2a2da9e1af31d1b7cf8dae7d9786848de1e5bd7',
19
+ ],
20
+ payload_schemas: [
21
+ 'network.xyo.hash.lease.estimate',
22
+ 'network.xyo.ns.domain.registration.lease',
23
+ ],
24
+ previous_hashes: [null],
25
+ schema: 'network.xyo.boundwitness',
26
+ $signatures: [
27
+ '2a59fea264bf71603f9908ac557cf5816ddd1898ce26a2cbb8081195cf5a19381bf42cc2e583a9a2a768dc324c6ac1344eb4ec06f41b19b06970734b30340226',
28
+ ],
29
+ },
30
+ {
31
+ schema: 'network.xyo.hash.lease.estimate',
32
+ currency: 'USD',
33
+ exp: 1_725_225_427_392,
34
+ nbf: 1_724_966_227_392,
35
+ price: 16,
36
+ $sources: ['dcc7ab18c86d90311bb1b59361f6698e2714294a91aa3126c554aa8483a7ae37'],
37
+ },
38
+ {
39
+ schema: 'network.xyo.ns.domain.registration.lease',
40
+ domain: 'test8446e171-46ca-47d5-a3b7-1a658cb7f451',
41
+ exp: 1_756_502_227_392,
42
+ nbf: 1_724_966_227_392,
43
+ registrant: ['1b2c45910fb0d32cb1d1cd010cbc594bf05969b5'],
44
+ registrar: ['846c35ce6ec62e4608a1215e14b5b16471904153'],
45
+ $sources: ['fccd06633e70c2168c8eb0eb5e25b22e34c1c417a46d5073034ec977dfc1995d', 'd7f40698fb0b0261834ef694ed275b4e6547e329cedc1c56708f098a5608b93a'],
46
+ tld: 'xyo',
47
+ },
48
+ ] as Estimate
49
+ const estimateB = [
50
+ {
51
+ addresses: ['9146761e29463d783e28161848feeeb43196227b'],
52
+ payload_hashes: [
53
+ 'abb7ecb2cfc51e1a95f85477b3a4210a72886d5b22fcf32043736c48e2873f2c',
54
+ '3ed825d48507b899395ca943e1dd6ec9a7c948e1cd1573a6cfda66de83af4b11',
55
+ ],
56
+ payload_schemas: [
57
+ 'network.xyo.hash.lease.estimate',
58
+ 'network.xyo.ns.domain.registration.lease',
59
+ ],
60
+ previous_hashes: [null],
61
+ schema: 'network.xyo.boundwitness',
62
+ $signatures: [
63
+ '91519424f721376751b19865433ff80e3d47b2a59be6f7478e7e003e0366ccc730c1dd7eeaa642ced9e78a40c5a5a3ab33044a6d620f5a4467dfbd0e2d9dc4d8',
64
+ ],
65
+ },
66
+ {
67
+ schema: 'network.xyo.hash.lease.estimate',
68
+ currency: 'USD',
69
+ exp: 1_725_225_514_773,
70
+ nbf: 1_724_966_314_773,
71
+ price: 16,
72
+ $sources: ['90259bc9ecde9d4c0061bc92dbfcf32e0f7b2603e49443d9f3c67a6d7e82c7d5'],
73
+ },
74
+ {
75
+ schema: 'network.xyo.ns.domain.registration.lease',
76
+ domain: 'testb88a0ee2-9665-48b3-b9c6-047eadc475ee',
77
+ exp: 1_756_502_314_773,
78
+ nbf: 1_724_966_314_773,
79
+ registrant: ['1b2c45910fb0d32cb1d1cd010cbc594bf05969b5'],
80
+ registrar: ['846c35ce6ec62e4608a1215e14b5b16471904153'],
81
+ $sources: ['407ed63c0c36fadae7ae8d16a42b678551e0ea6aa5357b76f0ffc1bce3ba2f22', 'ced04c0a3f65bbefde58ba0d15767fcee20b6e25d3820f90c55f44f18effa70f'],
82
+ tld: 'xyo',
83
+ },
84
+ ] as Estimate
85
+ describe('with valid symmetric data', () => {
86
+ const cases: Payload[][] = [
87
+ [...estimateA],
88
+ [...estimateB],
89
+ [...estimateA, ...estimateB],
90
+ [...estimateB, ...estimateA],
91
+ ]
92
+ it.each(cases)('parses estimates from array', async (...data) => {
93
+ const parsed = await parseEstimatesFromArray(data)
94
+ expect(parsed).toMatchSnapshot()
95
+ })
96
+ })
97
+ describe('with valid jagged data', () => {
98
+ const cases: Payload[][] = [
99
+ estimateA.slice(0, -1),
100
+ estimateB.slice(0, -1),
101
+ [...estimateB],
102
+ [...estimateA, ...estimateB.slice(0, -1)],
103
+ [...estimateB, ...estimateA.slice(0, -1)],
104
+ ]
105
+ it.each(cases)('parses estimates from array', async (...data) => {
106
+ const parsed = await parseEstimatesFromArray(data)
107
+ expect(parsed).toMatchSnapshot()
108
+ })
109
+ })
110
+ describe('with no data', () => {
111
+ it('returns empty array', async () => {
112
+ const parsed = await parseEstimatesFromArray([])
113
+ expect(parsed).toBeArrayOfSize(0)
114
+ })
115
+ })
116
+ })
package/typedoc.json DELETED
@@ -1,5 +0,0 @@
1
- {
2
- "$schema": "https://typedoc.org/schema.json",
3
- "entryPoints": ["./src/index.ts"],
4
- "tsconfig": "./tsconfig.typedoc.json"
5
- }