@xyo-network/xns-record-payload-plugins 4.2.0 → 5.0.1
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/browser/DNS/Witness/Payload/Request.d.ts +2 -2
- package/dist/browser/DNS/Witness/Payload/Request.d.ts.map +1 -1
- package/dist/browser/DNS/Witness/Payload/Response.d.ts +2 -2
- package/dist/browser/DNS/Witness/Payload/Response.d.ts.map +1 -1
- package/dist/browser/Domain/Domain.d.ts +2 -2
- package/dist/browser/Domain/Domain.d.ts.map +1 -1
- package/dist/browser/Domain/DomainLease.d.ts +2 -2
- package/dist/browser/Domain/DomainLease.d.ts.map +1 -1
- package/dist/browser/DomainRegistration/DomainRegistration.d.ts +2 -2
- package/dist/browser/DomainRegistration/DomainRegistration.d.ts.map +1 -1
- package/dist/browser/DomainRegistration/DomainRegistrationLease.d.ts +2 -2
- package/dist/browser/DomainRegistration/DomainRegistrationLease.d.ts.map +1 -1
- package/dist/neutral/DNS/Witness/Payload/Request.d.ts +2 -2
- package/dist/neutral/DNS/Witness/Payload/Request.d.ts.map +1 -1
- package/dist/neutral/DNS/Witness/Payload/Response.d.ts +2 -2
- package/dist/neutral/DNS/Witness/Payload/Response.d.ts.map +1 -1
- package/dist/neutral/Domain/Domain.d.ts +2 -2
- package/dist/neutral/Domain/Domain.d.ts.map +1 -1
- package/dist/neutral/Domain/DomainLease.d.ts +2 -2
- package/dist/neutral/Domain/DomainLease.d.ts.map +1 -1
- package/dist/neutral/DomainRegistration/DomainRegistration.d.ts +2 -2
- package/dist/neutral/DomainRegistration/DomainRegistration.d.ts.map +1 -1
- package/dist/neutral/DomainRegistration/DomainRegistrationLease.d.ts +2 -2
- package/dist/neutral/DomainRegistration/DomainRegistrationLease.d.ts.map +1 -1
- package/dist/node/DNS/Witness/Payload/Request.d.ts +2 -2
- package/dist/node/DNS/Witness/Payload/Request.d.ts.map +1 -1
- package/dist/node/DNS/Witness/Payload/Response.d.ts +2 -2
- package/dist/node/DNS/Witness/Payload/Response.d.ts.map +1 -1
- package/dist/node/Domain/Domain.d.ts +2 -2
- package/dist/node/Domain/Domain.d.ts.map +1 -1
- package/dist/node/Domain/DomainLease.d.ts +2 -2
- package/dist/node/Domain/DomainLease.d.ts.map +1 -1
- package/dist/node/DomainRegistration/DomainRegistration.d.ts +2 -2
- package/dist/node/DomainRegistration/DomainRegistration.d.ts.map +1 -1
- package/dist/node/DomainRegistration/DomainRegistrationLease.d.ts +2 -2
- package/dist/node/DomainRegistration/DomainRegistrationLease.d.ts.map +1 -1
- package/package.json +25 -21
- package/src/Duration/validation/spec/validateBoundWitness.spec.ts +46 -0
- package/src/Duration/validation/spec/validateBoundWitnessWithRecord.spec.ts +49 -0
- package/src/Duration/validation/spec/validateNameserverRecord.spec.ts +61 -0
- package/src/Duration/validation/spec/validateRecord.spec.ts +37 -0
- package/src/diviner/lib/spec/__snapshots__/parseEstimatesFromArray.spec.ts.snap +481 -0
- package/src/diviner/lib/spec/parseEstimatesFromArray.spec.ts +116 -0
- package/typedoc.json +0 -5
|
@@ -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
|
+
})
|