@xyo-network/xns-record-payloadset-plugins 5.1.3 → 5.1.5
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/package.json +21 -18
- package/dist/browser/estimate/lib/spec/parseDomainEstimates.spec.d.ts +0 -2
- package/dist/browser/estimate/lib/spec/parseDomainEstimates.spec.d.ts.map +0 -1
- package/dist/browser/validation/name/spec/Name.spec.d.ts +0 -2
- package/dist/browser/validation/name/spec/Name.spec.d.ts.map +0 -1
- package/dist/browser/validation/validation/factory/spec/validators.spec.d.ts +0 -2
- package/dist/browser/validation/validation/factory/spec/validators.spec.d.ts.map +0 -1
- package/dist/browser/validation/validation/validators/spec/validators.spec.d.ts +0 -2
- package/dist/browser/validation/validation/validators/spec/validators.spec.d.ts.map +0 -1
- package/dist/neutral/estimate/lib/spec/parseDomainEstimates.spec.d.ts +0 -2
- package/dist/neutral/estimate/lib/spec/parseDomainEstimates.spec.d.ts.map +0 -1
- package/dist/neutral/validation/name/spec/Name.spec.d.ts +0 -2
- package/dist/neutral/validation/name/spec/Name.spec.d.ts.map +0 -1
- package/dist/neutral/validation/validation/factory/spec/validators.spec.d.ts +0 -2
- package/dist/neutral/validation/validation/factory/spec/validators.spec.d.ts.map +0 -1
- package/dist/neutral/validation/validation/validators/spec/validators.spec.d.ts +0 -2
- package/dist/neutral/validation/validation/validators/spec/validators.spec.d.ts.map +0 -1
- package/dist/node/estimate/lib/spec/parseDomainEstimates.spec.d.ts +0 -2
- package/dist/node/estimate/lib/spec/parseDomainEstimates.spec.d.ts.map +0 -1
- package/dist/node/validation/name/spec/Name.spec.d.ts +0 -2
- package/dist/node/validation/name/spec/Name.spec.d.ts.map +0 -1
- package/dist/node/validation/validation/factory/spec/validators.spec.d.ts +0 -2
- package/dist/node/validation/validation/factory/spec/validators.spec.d.ts.map +0 -1
- package/dist/node/validation/validation/validators/spec/validators.spec.d.ts +0 -2
- package/dist/node/validation/validation/validators/spec/validators.spec.d.ts.map +0 -1
- package/src/estimate/lib/spec/__snapshots__/parseDomainEstimates.spec.ts.snap +0 -481
- package/src/estimate/lib/spec/parseDomainEstimates.spec.ts +0 -115
- package/src/validation/name/spec/Name.spec.ts +0 -154
- package/src/validation/validation/factory/spec/validators.spec.ts +0 -87
- package/src/validation/validation/validators/spec/validators.spec.ts +0 -187
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xyo-network/xns-record-payloadset-plugins",
|
|
3
|
-
"version": "5.1.
|
|
3
|
+
"version": "5.1.5",
|
|
4
4
|
"description": "Typescript/Javascript Plugins for XYO Platform",
|
|
5
5
|
"homepage": "https://xyo.network",
|
|
6
6
|
"bugs": {
|
|
@@ -30,27 +30,30 @@
|
|
|
30
30
|
"types": "dist/neutral/index.d.ts",
|
|
31
31
|
"files": [
|
|
32
32
|
"dist",
|
|
33
|
-
"src"
|
|
33
|
+
"src",
|
|
34
|
+
"!**/*.bench.*",
|
|
35
|
+
"!**/*.spec.*",
|
|
36
|
+
"!**/*.test.*"
|
|
34
37
|
],
|
|
35
38
|
"dependencies": {
|
|
36
|
-
"@xylabs/array": "~5.0.
|
|
37
|
-
"@xylabs/assert": "~5.0.
|
|
38
|
-
"@xylabs/exists": "~5.0.
|
|
39
|
-
"@xylabs/hex": "~5.0.
|
|
40
|
-
"@xylabs/promise": "~5.0.
|
|
41
|
-
"@xyo-network/boundwitness-model": "~5.1.
|
|
42
|
-
"@xyo-network/diviner-hash-lease": "~5.1.
|
|
43
|
-
"@xyo-network/module-model": "~5.1.
|
|
44
|
-
"@xyo-network/payload-builder": "~5.1.
|
|
45
|
-
"@xyo-network/payload-model": "~5.1.
|
|
46
|
-
"@xyo-network/xns-record-payload-plugins": "~5.1.
|
|
39
|
+
"@xylabs/array": "~5.0.37",
|
|
40
|
+
"@xylabs/assert": "~5.0.37",
|
|
41
|
+
"@xylabs/exists": "~5.0.37",
|
|
42
|
+
"@xylabs/hex": "~5.0.37",
|
|
43
|
+
"@xylabs/promise": "~5.0.37",
|
|
44
|
+
"@xyo-network/boundwitness-model": "~5.1.23",
|
|
45
|
+
"@xyo-network/diviner-hash-lease": "~5.1.23",
|
|
46
|
+
"@xyo-network/module-model": "~5.1.23",
|
|
47
|
+
"@xyo-network/payload-builder": "~5.1.23",
|
|
48
|
+
"@xyo-network/payload-model": "~5.1.23",
|
|
49
|
+
"@xyo-network/xns-record-payload-plugins": "~5.1.5"
|
|
47
50
|
},
|
|
48
51
|
"devDependencies": {
|
|
49
|
-
"@xylabs/ts-scripts-yarn3": "~7.
|
|
50
|
-
"@xylabs/tsconfig": "~7.
|
|
51
|
-
"@xylabs/vitest-extended": "~5.0.
|
|
52
|
-
"typescript": "~5.9.
|
|
53
|
-
"vitest": "~
|
|
52
|
+
"@xylabs/ts-scripts-yarn3": "~7.2.8",
|
|
53
|
+
"@xylabs/tsconfig": "~7.2.8",
|
|
54
|
+
"@xylabs/vitest-extended": "~5.0.37",
|
|
55
|
+
"typescript": "~5.9.3",
|
|
56
|
+
"vitest": "~4.0.10"
|
|
54
57
|
},
|
|
55
58
|
"publishConfig": {
|
|
56
59
|
"access": "public"
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"parseDomainEstimates.spec.d.ts","sourceRoot":"","sources":["../../../../../src/estimate/lib/spec/parseDomainEstimates.spec.ts"],"names":[],"mappings":""}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Name.spec.d.ts","sourceRoot":"","sources":["../../../../../src/validation/name/spec/Name.spec.ts"],"names":[],"mappings":"AAAA,OAAO,yBAAyB,CAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"validators.spec.d.ts","sourceRoot":"","sources":["../../../../../../src/validation/validation/factory/spec/validators.spec.ts"],"names":[],"mappings":"AAAA,OAAO,yBAAyB,CAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"validators.spec.d.ts","sourceRoot":"","sources":["../../../../../../src/validation/validation/validators/spec/validators.spec.ts"],"names":[],"mappings":"AAYA,OAAO,yBAAyB,CAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"parseDomainEstimates.spec.d.ts","sourceRoot":"","sources":["../../../../../src/estimate/lib/spec/parseDomainEstimates.spec.ts"],"names":[],"mappings":""}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Name.spec.d.ts","sourceRoot":"","sources":["../../../../../src/validation/name/spec/Name.spec.ts"],"names":[],"mappings":"AAAA,OAAO,yBAAyB,CAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"validators.spec.d.ts","sourceRoot":"","sources":["../../../../../../src/validation/validation/factory/spec/validators.spec.ts"],"names":[],"mappings":"AAAA,OAAO,yBAAyB,CAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"validators.spec.d.ts","sourceRoot":"","sources":["../../../../../../src/validation/validation/validators/spec/validators.spec.ts"],"names":[],"mappings":"AAYA,OAAO,yBAAyB,CAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"parseDomainEstimates.spec.d.ts","sourceRoot":"","sources":["../../../../../src/estimate/lib/spec/parseDomainEstimates.spec.ts"],"names":[],"mappings":""}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Name.spec.d.ts","sourceRoot":"","sources":["../../../../../src/validation/name/spec/Name.spec.ts"],"names":[],"mappings":"AAAA,OAAO,yBAAyB,CAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"validators.spec.d.ts","sourceRoot":"","sources":["../../../../../../src/validation/validation/factory/spec/validators.spec.ts"],"names":[],"mappings":"AAAA,OAAO,yBAAyB,CAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"validators.spec.d.ts","sourceRoot":"","sources":["../../../../../../src/validation/validation/validators/spec/validators.spec.ts"],"names":[],"mappings":"AAYA,OAAO,yBAAyB,CAAA"}
|
|
@@ -1,481 +0,0 @@
|
|
|
1
|
-
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
|
|
2
|
-
|
|
3
|
-
exports[`parseDomainEstimates > with valid jagged data > parses estimates from array 1`] = `[]`;
|
|
4
|
-
|
|
5
|
-
exports[`parseDomainEstimates > with valid jagged data > parses estimates from array 2`] = `[]`;
|
|
6
|
-
|
|
7
|
-
exports[`parseDomainEstimates > with valid jagged data > parses estimates from array 3`] = `
|
|
8
|
-
[
|
|
9
|
-
[
|
|
10
|
-
{
|
|
11
|
-
"$signatures": [
|
|
12
|
-
"2ff62a32daaa97f1b316dc07eaeae594a3d57c07bb03fa38c44dd803b192d13b47311a0954440233826a3ae10f6540d991947dad64c8a563e74ae78cd245657f",
|
|
13
|
-
],
|
|
14
|
-
"addresses": [
|
|
15
|
-
"6a2cb2545c71f84235346643a9f562a973d6adef",
|
|
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[`parseDomainEstimates > with valid jagged data > parses estimates from array 4`] = `
|
|
62
|
-
[
|
|
63
|
-
[
|
|
64
|
-
{
|
|
65
|
-
"$signatures": [
|
|
66
|
-
"6595022e974dae953b6ea145e6c0ca75211afd713a88b6d989e9d00da4e183ad427df8a8175ba46688c5345349464645befe1f2250ecfdc6bdb3cf9c27b65931",
|
|
67
|
-
],
|
|
68
|
-
"addresses": [
|
|
69
|
-
"93130bb7cf9b059ed6e29b50f29b569a2094bd5e",
|
|
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[`parseDomainEstimates > with valid jagged data > parses estimates from array 5`] = `
|
|
116
|
-
[
|
|
117
|
-
[
|
|
118
|
-
{
|
|
119
|
-
"$signatures": [
|
|
120
|
-
"2ff62a32daaa97f1b316dc07eaeae594a3d57c07bb03fa38c44dd803b192d13b47311a0954440233826a3ae10f6540d991947dad64c8a563e74ae78cd245657f",
|
|
121
|
-
],
|
|
122
|
-
"addresses": [
|
|
123
|
-
"6a2cb2545c71f84235346643a9f562a973d6adef",
|
|
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[`parseDomainEstimates > with valid symmetric data > parses estimates from array 1`] = `
|
|
170
|
-
[
|
|
171
|
-
[
|
|
172
|
-
{
|
|
173
|
-
"$signatures": [
|
|
174
|
-
"6595022e974dae953b6ea145e6c0ca75211afd713a88b6d989e9d00da4e183ad427df8a8175ba46688c5345349464645befe1f2250ecfdc6bdb3cf9c27b65931",
|
|
175
|
-
],
|
|
176
|
-
"addresses": [
|
|
177
|
-
"93130bb7cf9b059ed6e29b50f29b569a2094bd5e",
|
|
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[`parseDomainEstimates > with valid symmetric data > parses estimates from array 2`] = `
|
|
224
|
-
[
|
|
225
|
-
[
|
|
226
|
-
{
|
|
227
|
-
"$signatures": [
|
|
228
|
-
"2ff62a32daaa97f1b316dc07eaeae594a3d57c07bb03fa38c44dd803b192d13b47311a0954440233826a3ae10f6540d991947dad64c8a563e74ae78cd245657f",
|
|
229
|
-
],
|
|
230
|
-
"addresses": [
|
|
231
|
-
"6a2cb2545c71f84235346643a9f562a973d6adef",
|
|
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[`parseDomainEstimates > with valid symmetric data > parses estimates from array 3`] = `
|
|
278
|
-
[
|
|
279
|
-
[
|
|
280
|
-
{
|
|
281
|
-
"$signatures": [
|
|
282
|
-
"6595022e974dae953b6ea145e6c0ca75211afd713a88b6d989e9d00da4e183ad427df8a8175ba46688c5345349464645befe1f2250ecfdc6bdb3cf9c27b65931",
|
|
283
|
-
],
|
|
284
|
-
"addresses": [
|
|
285
|
-
"93130bb7cf9b059ed6e29b50f29b569a2094bd5e",
|
|
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
|
-
"2ff62a32daaa97f1b316dc07eaeae594a3d57c07bb03fa38c44dd803b192d13b47311a0954440233826a3ae10f6540d991947dad64c8a563e74ae78cd245657f",
|
|
332
|
-
],
|
|
333
|
-
"addresses": [
|
|
334
|
-
"6a2cb2545c71f84235346643a9f562a973d6adef",
|
|
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[`parseDomainEstimates > with valid symmetric data > parses estimates from array 4`] = `
|
|
381
|
-
[
|
|
382
|
-
[
|
|
383
|
-
{
|
|
384
|
-
"$signatures": [
|
|
385
|
-
"2ff62a32daaa97f1b316dc07eaeae594a3d57c07bb03fa38c44dd803b192d13b47311a0954440233826a3ae10f6540d991947dad64c8a563e74ae78cd245657f",
|
|
386
|
-
],
|
|
387
|
-
"addresses": [
|
|
388
|
-
"6a2cb2545c71f84235346643a9f562a973d6adef",
|
|
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
|
-
"6595022e974dae953b6ea145e6c0ca75211afd713a88b6d989e9d00da4e183ad427df8a8175ba46688c5345349464645befe1f2250ecfdc6bdb3cf9c27b65931",
|
|
435
|
-
],
|
|
436
|
-
"addresses": [
|
|
437
|
-
"93130bb7cf9b059ed6e29b50f29b569a2094bd5e",
|
|
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
|
-
`;
|
|
@@ -1,115 +0,0 @@
|
|
|
1
|
-
import type { Payload } from '@xyo-network/payload-model'
|
|
2
|
-
import type { DomainEstimate, Estimate } from '@xyo-network/xns-record-payload-plugins'
|
|
3
|
-
import {
|
|
4
|
-
describe, expect, it,
|
|
5
|
-
} from 'vitest'
|
|
6
|
-
|
|
7
|
-
import { parseDomainEstimates } from '../parseDomainEstimates.ts'
|
|
8
|
-
import { matchers } from './matchers/index.ts'
|
|
9
|
-
|
|
10
|
-
expect.extend(matchers)
|
|
11
|
-
|
|
12
|
-
describe('parseDomainEstimates', () => {
|
|
13
|
-
const estimateA = [
|
|
14
|
-
{
|
|
15
|
-
addresses: ['93130bb7cf9b059ed6e29b50f29b569a2094bd5e'],
|
|
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
|
-
'6595022e974dae953b6ea145e6c0ca75211afd713a88b6d989e9d00da4e183ad427df8a8175ba46688c5345349464645befe1f2250ecfdc6bdb3cf9c27b65931',
|
|
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 DomainEstimate
|
|
49
|
-
const estimateB = [
|
|
50
|
-
{
|
|
51
|
-
addresses: ['6a2cb2545c71f84235346643a9f562a973d6adef'],
|
|
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
|
-
'2ff62a32daaa97f1b316dc07eaeae594a3d57c07bb03fa38c44dd803b192d13b47311a0954440233826a3ae10f6540d991947dad64c8a563e74ae78cd245657f',
|
|
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 signer = await HDWallet.random()
|
|
94
|
-
// const [bw] = await new BoundWitnessBuilder().signer(signer).payloads([estimateB[1], estimateB[2]]).build()
|
|
95
|
-
expect(await parseDomainEstimates(data)).toMatchSnapshot()
|
|
96
|
-
})
|
|
97
|
-
})
|
|
98
|
-
describe('with valid jagged data', () => {
|
|
99
|
-
const cases: Payload[][] = [
|
|
100
|
-
estimateA.slice(0, -1),
|
|
101
|
-
estimateB.slice(0, -1),
|
|
102
|
-
[...estimateB],
|
|
103
|
-
[...estimateA, ...estimateB.slice(0, -1)],
|
|
104
|
-
[...estimateB, ...estimateA.slice(0, -1)],
|
|
105
|
-
]
|
|
106
|
-
it.each(cases)('parses estimates from array', async (...data) => {
|
|
107
|
-
expect(await parseDomainEstimates(data)).toMatchSnapshot()
|
|
108
|
-
})
|
|
109
|
-
})
|
|
110
|
-
describe('with no data', () => {
|
|
111
|
-
it('returns empty array', async () => {
|
|
112
|
-
expect(await parseDomainEstimates([])).toBeArrayOfSize(0)
|
|
113
|
-
})
|
|
114
|
-
})
|
|
115
|
-
})
|
|
@@ -1,154 +0,0 @@
|
|
|
1
|
-
import '@xylabs/vitest-extended'
|
|
2
|
-
|
|
3
|
-
import type { Domain } from '@xyo-network/xns-record-payload-plugins'
|
|
4
|
-
import { DomainSchema } from '@xyo-network/xns-record-payload-plugins'
|
|
5
|
-
import {
|
|
6
|
-
describe, expect, it,
|
|
7
|
-
} from 'vitest'
|
|
8
|
-
|
|
9
|
-
import { MAX_DOMAIN_LENGTH } from '../../validation/index.ts'
|
|
10
|
-
import { XnsNameHelper } from '../Name.ts'
|
|
11
|
-
|
|
12
|
-
describe('XnsNameHelper', () => {
|
|
13
|
-
const validDomain: Domain = {
|
|
14
|
-
schema: DomainSchema, domain: 'example', tld: 'xyo',
|
|
15
|
-
}
|
|
16
|
-
describe('domain getter', () => {
|
|
17
|
-
it('should return the domain if set', async () => {
|
|
18
|
-
const helper = await XnsNameHelper.fromPayload(validDomain)
|
|
19
|
-
expect(helper.domain).toBe('example')
|
|
20
|
-
})
|
|
21
|
-
|
|
22
|
-
it('should throw an error if domain is not set', async () => {
|
|
23
|
-
const domain: Domain = {
|
|
24
|
-
schema: DomainSchema, domain: '', tld: 'xyo',
|
|
25
|
-
}
|
|
26
|
-
const helper = await XnsNameHelper.fromPayload(domain)
|
|
27
|
-
expect(() => helper.domain).toThrow('domain not found in payload')
|
|
28
|
-
})
|
|
29
|
-
})
|
|
30
|
-
|
|
31
|
-
describe('tld getter', () => {
|
|
32
|
-
it('should return the tld if set', async () => {
|
|
33
|
-
const helper = await XnsNameHelper.fromPayload(validDomain)
|
|
34
|
-
expect(helper.tld).toBe('xyo')
|
|
35
|
-
})
|
|
36
|
-
|
|
37
|
-
it('should throw an error if tld is not set', async () => {
|
|
38
|
-
const domain: Domain = {
|
|
39
|
-
schema: DomainSchema, domain: 'example', tld: '' as 'xyo',
|
|
40
|
-
}
|
|
41
|
-
const helper = await XnsNameHelper.fromPayload(domain)
|
|
42
|
-
expect(() => helper.tld).toThrow('tld not found in payload')
|
|
43
|
-
})
|
|
44
|
-
})
|
|
45
|
-
|
|
46
|
-
describe('xnsName getter', () => {
|
|
47
|
-
it('should return the xnsName if set', async () => {
|
|
48
|
-
const helper = await XnsNameHelper.fromPayload(validDomain)
|
|
49
|
-
expect(helper.xnsName).toEqual(validDomain)
|
|
50
|
-
})
|
|
51
|
-
|
|
52
|
-
it('should throw an error if xnsName is not set', async () => {
|
|
53
|
-
const helper = await XnsNameHelper.fromPayload(undefined as unknown as Domain)
|
|
54
|
-
expect(() => helper.xnsName).toThrow('XnsNameHelper xnsName not set')
|
|
55
|
-
})
|
|
56
|
-
})
|
|
57
|
-
|
|
58
|
-
describe('fromString', () => {
|
|
59
|
-
it('should create an instance from a valid xnsName string', () => {
|
|
60
|
-
const { domain, tld } = validDomain
|
|
61
|
-
const helper = XnsNameHelper.fromString(`${domain}.${tld}`)
|
|
62
|
-
expect(helper.domain).toBe(domain)
|
|
63
|
-
expect(helper.xnsName.domain).toBe(domain)
|
|
64
|
-
expect(helper.tld).toBe(tld)
|
|
65
|
-
expect(helper.xnsName.tld).toBe(tld)
|
|
66
|
-
})
|
|
67
|
-
|
|
68
|
-
it('should throw an error if xnsName string is invalid', () => {
|
|
69
|
-
expect(() => XnsNameHelper.fromString('invalid')).toThrow('Unable to parse xnsName')
|
|
70
|
-
})
|
|
71
|
-
})
|
|
72
|
-
|
|
73
|
-
describe('isXnsNameOrHash', () => {
|
|
74
|
-
it('should return "xnsName" if the source ends with a valid TLD', () => {
|
|
75
|
-
expect(XnsNameHelper.isPotentialXnsNameOrHash('example.xyo')).toBe('xnsName')
|
|
76
|
-
})
|
|
77
|
-
|
|
78
|
-
it('should return "hash" if the source is a valid hash', () => {
|
|
79
|
-
expect(XnsNameHelper.isPotentialXnsNameOrHash('c3ab8ff13720e8ad9047dd39466b3c8974e592c2fa383d4a3960714caef0c4f2')).toBe('hash')
|
|
80
|
-
})
|
|
81
|
-
|
|
82
|
-
it('should return null if the source is neither a valid xnsName nor a hash', () => {
|
|
83
|
-
expect(XnsNameHelper.isPotentialXnsNameOrHash('invalid')).toBe(null)
|
|
84
|
-
})
|
|
85
|
-
})
|
|
86
|
-
|
|
87
|
-
describe('isValid', () => {
|
|
88
|
-
it('should return true for valid xns names', async () => {
|
|
89
|
-
expect(await XnsNameHelper.isValid(validDomain)).toBe(true)
|
|
90
|
-
})
|
|
91
|
-
|
|
92
|
-
it('should return false for invalid xns names', async () => {
|
|
93
|
-
const domain: Domain = {
|
|
94
|
-
schema: DomainSchema, domain: 'example-', tld: 'xyo',
|
|
95
|
-
}
|
|
96
|
-
expect(await XnsNameHelper.isValid(domain)).toBe(false)
|
|
97
|
-
})
|
|
98
|
-
})
|
|
99
|
-
|
|
100
|
-
describe('mask', () => {
|
|
101
|
-
describe('with invalid input', () => {
|
|
102
|
-
it('should throw an error', () => {
|
|
103
|
-
expect(() => XnsNameHelper.mask('a'.repeat(MAX_DOMAIN_LENGTH + 1)))
|
|
104
|
-
.toThrow('Domain name too long: 129 exceeds max length: 128')
|
|
105
|
-
})
|
|
106
|
-
})
|
|
107
|
-
|
|
108
|
-
const cases = [
|
|
109
|
-
['Example$123', 'example123'],
|
|
110
|
-
['Example/123', 'example123'],
|
|
111
|
-
['Example.123', 'example123'],
|
|
112
|
-
['Example-123', 'example-123'],
|
|
113
|
-
['Example 123', 'example123'],
|
|
114
|
-
['Example_123', 'example123'],
|
|
115
|
-
['Example-123', 'example-123'],
|
|
116
|
-
]
|
|
117
|
-
|
|
118
|
-
describe.each(cases)('mask(%s)', (input, expected) => {
|
|
119
|
-
it(`should return ${expected}`, () => {
|
|
120
|
-
expect(XnsNameHelper.mask(input)).toBe(expected)
|
|
121
|
-
})
|
|
122
|
-
})
|
|
123
|
-
|
|
124
|
-
describe('with options', () => {
|
|
125
|
-
const options = { maskStartEndHyphens: true }
|
|
126
|
-
const cases = [
|
|
127
|
-
['-Example_123-', 'example123'],
|
|
128
|
-
['-Example_123', 'example123'],
|
|
129
|
-
['Example_123-', 'example123'],
|
|
130
|
-
['--Example_123', 'example123'],
|
|
131
|
-
['Example_123--', 'example123'],
|
|
132
|
-
['--Example_123--', 'example123'],
|
|
133
|
-
['- Example_123 -', 'example123'],
|
|
134
|
-
]
|
|
135
|
-
|
|
136
|
-
describe('stripDashes: true', () => {
|
|
137
|
-
describe.each(cases)('mask(%s)', (input, expected) => {
|
|
138
|
-
it(`should return ${expected}`, () => {
|
|
139
|
-
expect(XnsNameHelper.mask(input, options)).toBe(expected)
|
|
140
|
-
})
|
|
141
|
-
})
|
|
142
|
-
})
|
|
143
|
-
})
|
|
144
|
-
})
|
|
145
|
-
|
|
146
|
-
describe('validate', () => {
|
|
147
|
-
it('should validate and return errors', async () => {
|
|
148
|
-
const helper = XnsNameHelper.fromString('Example.Xyo')
|
|
149
|
-
const [valid, errors] = await helper.validate()
|
|
150
|
-
expect(valid).toBe(false)
|
|
151
|
-
expect(errors).toEqual(['name must be lowercase', 'TLD must be lowercase', 'Only XYO TLD currently supported'])
|
|
152
|
-
})
|
|
153
|
-
})
|
|
154
|
-
})
|
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
import '@xylabs/vitest-extended'
|
|
2
|
-
|
|
3
|
-
import type { Domain } from '@xyo-network/xns-record-payload-plugins'
|
|
4
|
-
import { DomainSchema } from '@xyo-network/xns-record-payload-plugins'
|
|
5
|
-
import {
|
|
6
|
-
describe, expect,
|
|
7
|
-
it,
|
|
8
|
-
} from 'vitest'
|
|
9
|
-
|
|
10
|
-
import {
|
|
11
|
-
getDomainReservedFragmentsValidator, getDomainReservedNamesValidator, getDomainReservedStringsValidator,
|
|
12
|
-
} from '../validators.ts'
|
|
13
|
-
|
|
14
|
-
const baseDomainFields: Domain = {
|
|
15
|
-
domain: '',
|
|
16
|
-
schema: DomainSchema,
|
|
17
|
-
tld: 'xyo',
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
describe('XNS Name', () => {
|
|
21
|
-
describe('Factory Validators', () => {
|
|
22
|
-
const cases = [
|
|
23
|
-
{
|
|
24
|
-
getValidator: getDomainReservedStringsValidator,
|
|
25
|
-
name: 'ReservedStringsValidator',
|
|
26
|
-
reservedList: ['foo'],
|
|
27
|
-
valid: ['bar'],
|
|
28
|
-
invalid: ['foo'],
|
|
29
|
-
},
|
|
30
|
-
{
|
|
31
|
-
getValidator: getDomainReservedStringsValidator,
|
|
32
|
-
name: 'ReservedStringsValidator',
|
|
33
|
-
reservedList: [],
|
|
34
|
-
valid: ['bar', 'foobar'],
|
|
35
|
-
invalid: [''],
|
|
36
|
-
},
|
|
37
|
-
{
|
|
38
|
-
getValidator: getDomainReservedFragmentsValidator,
|
|
39
|
-
name: 'ReservedFragmentsValidator',
|
|
40
|
-
reservedList: ['foo'],
|
|
41
|
-
valid: ['bar'],
|
|
42
|
-
invalid: ['foobar', 'bar-foo'],
|
|
43
|
-
},
|
|
44
|
-
{
|
|
45
|
-
getValidator: getDomainReservedFragmentsValidator,
|
|
46
|
-
name: 'ReservedFragmentsValidator',
|
|
47
|
-
reservedList: [],
|
|
48
|
-
valid: ['foobar', 'bar-foo'],
|
|
49
|
-
invalid: [''],
|
|
50
|
-
},
|
|
51
|
-
{
|
|
52
|
-
getValidator: getDomainReservedNamesValidator,
|
|
53
|
-
name: 'ReservedNamesValidator',
|
|
54
|
-
reservedList: ['john doe'],
|
|
55
|
-
valid: ['john1'],
|
|
56
|
-
invalid: ['johndoe', 'doejohn'],
|
|
57
|
-
},
|
|
58
|
-
{
|
|
59
|
-
getValidator: getDomainReservedNamesValidator,
|
|
60
|
-
name: 'ReservedNamesValidator',
|
|
61
|
-
reservedList: [],
|
|
62
|
-
valid: ['john', 'doe'],
|
|
63
|
-
invalid: [''],
|
|
64
|
-
},
|
|
65
|
-
]
|
|
66
|
-
|
|
67
|
-
describe.each(cases)('$name', ({
|
|
68
|
-
getValidator, valid, invalid, reservedList,
|
|
69
|
-
}) => {
|
|
70
|
-
const validator = getValidator(reservedList)
|
|
71
|
-
describe('Valid', () => {
|
|
72
|
-
it.each(valid)('should return true for %s', (domain) => {
|
|
73
|
-
const payload: Domain = { ...baseDomainFields, domain }
|
|
74
|
-
expect(validator(payload)).toBe(true)
|
|
75
|
-
})
|
|
76
|
-
})
|
|
77
|
-
describe('Invalid', () => {
|
|
78
|
-
it.each(invalid)('should return false for %s', (domain) => {
|
|
79
|
-
if (domain) {
|
|
80
|
-
const payload: Domain = { ...baseDomainFields, domain }
|
|
81
|
-
expect(validator(payload)).toBe(false)
|
|
82
|
-
}
|
|
83
|
-
})
|
|
84
|
-
})
|
|
85
|
-
})
|
|
86
|
-
})
|
|
87
|
-
})
|
|
@@ -1,187 +0,0 @@
|
|
|
1
|
-
import type { Payload } from '@xyo-network/payload-model'
|
|
2
|
-
import type { Domain } from '@xyo-network/xns-record-payload-plugins'
|
|
3
|
-
import { DomainSchema } from '@xyo-network/xns-record-payload-plugins'
|
|
4
|
-
|
|
5
|
-
import { MAX_DOMAIN_LENGTH, MIN_DOMAIN_LENGTH } from '../../Constants.ts'
|
|
6
|
-
|
|
7
|
-
const baseDomainFields: Payload<Domain> = {
|
|
8
|
-
domain: '',
|
|
9
|
-
tld: 'xyo',
|
|
10
|
-
schema: DomainSchema,
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
import '@xylabs/vitest-extended'
|
|
14
|
-
|
|
15
|
-
import {
|
|
16
|
-
describe, expect,
|
|
17
|
-
it, vi,
|
|
18
|
-
} from 'vitest'
|
|
19
|
-
|
|
20
|
-
import {
|
|
21
|
-
domainCasingValidator, domainModuleNameValidator, domainTldValidator, getDomainAllowedHyphensValidator, getDomainLengthValidator,
|
|
22
|
-
} from '../validators.ts'
|
|
23
|
-
|
|
24
|
-
describe('XNS Name', () => {
|
|
25
|
-
describe('Validators', () => {
|
|
26
|
-
const cases = [
|
|
27
|
-
{
|
|
28
|
-
name: 'domainCasingValidator',
|
|
29
|
-
validator: domainCasingValidator,
|
|
30
|
-
valid: ['example'],
|
|
31
|
-
invalid: [['Example', ['name must be lowercase']]] as [string, string[]][],
|
|
32
|
-
},
|
|
33
|
-
{
|
|
34
|
-
name: 'domainModuleNameValidator',
|
|
35
|
-
validator: domainModuleNameValidator,
|
|
36
|
-
valid: ['valid-domain'],
|
|
37
|
-
invalid: [['invalid_domain', ['Domain is not a valid module name: invalid_domain']]] as [string, string[]][],
|
|
38
|
-
},
|
|
39
|
-
]
|
|
40
|
-
|
|
41
|
-
describe.each(cases)('$name', ({
|
|
42
|
-
validator, valid, invalid,
|
|
43
|
-
}) => {
|
|
44
|
-
const onErrors = vi.fn()
|
|
45
|
-
|
|
46
|
-
describe('Valid', () => {
|
|
47
|
-
it.each(valid)('should return true for %s', (domain) => {
|
|
48
|
-
const payload: Domain = { ...baseDomainFields, domain }
|
|
49
|
-
expect(validator(payload)).toBe(true)
|
|
50
|
-
expect(onErrors).not.toHaveBeenCalled()
|
|
51
|
-
})
|
|
52
|
-
})
|
|
53
|
-
|
|
54
|
-
describe('Invalid', () => {
|
|
55
|
-
it.each(invalid)('should return false for %s', (domain, expectedErrorMessage) => {
|
|
56
|
-
const payload: Domain = { ...baseDomainFields, domain }
|
|
57
|
-
expect(validator(payload, onErrors)).toBe(false)
|
|
58
|
-
expect(onErrors).toHaveBeenCalledWith(expectedErrorMessage)
|
|
59
|
-
})
|
|
60
|
-
})
|
|
61
|
-
})
|
|
62
|
-
|
|
63
|
-
const casesTld = [
|
|
64
|
-
{
|
|
65
|
-
name: 'domainTldValidator',
|
|
66
|
-
valid: ['xyo'],
|
|
67
|
-
invalid: [
|
|
68
|
-
['com', ['Only XYO TLD currently supported']],
|
|
69
|
-
['Xyo', ['TLD must be lowercase', 'Only XYO TLD currently supported']],
|
|
70
|
-
] as [string, string[]][],
|
|
71
|
-
},
|
|
72
|
-
]
|
|
73
|
-
|
|
74
|
-
describe.each(casesTld)('$name', ({ valid, invalid }) => {
|
|
75
|
-
const onErrors = vi.fn()
|
|
76
|
-
|
|
77
|
-
describe('Valid', () => {
|
|
78
|
-
it.each(valid)('should return true for %s', (tld) => {
|
|
79
|
-
const payload: Domain = { ...baseDomainFields, tld: tld as unknown as 'xyo' }
|
|
80
|
-
expect(domainTldValidator(payload)).toBe(true)
|
|
81
|
-
expect(onErrors).not.toHaveBeenCalled()
|
|
82
|
-
})
|
|
83
|
-
})
|
|
84
|
-
|
|
85
|
-
describe('Invalid', () => {
|
|
86
|
-
it.each(invalid)('should return false for %s', (tld, expectedErrorMessages) => {
|
|
87
|
-
const payload: Domain = { ...baseDomainFields, tld: tld as unknown as 'xyo' }
|
|
88
|
-
expect(domainTldValidator(payload, onErrors)).toBe(false)
|
|
89
|
-
expect(onErrors).toHaveBeenCalledWith(expectedErrorMessages)
|
|
90
|
-
})
|
|
91
|
-
})
|
|
92
|
-
})
|
|
93
|
-
|
|
94
|
-
const casesLength = [
|
|
95
|
-
{
|
|
96
|
-
name: 'getDomainLengthValidator',
|
|
97
|
-
valid: ['abc', 'abcd'],
|
|
98
|
-
invalid: [
|
|
99
|
-
['', [`name must be at least ${MIN_DOMAIN_LENGTH} characters`]],
|
|
100
|
-
['a', [`name must be at least ${MIN_DOMAIN_LENGTH} characters`]],
|
|
101
|
-
['a'.repeat(MAX_DOMAIN_LENGTH + 1), [`name must be no more than ${MAX_DOMAIN_LENGTH} characters`]],
|
|
102
|
-
] as [string, string[]][],
|
|
103
|
-
},
|
|
104
|
-
]
|
|
105
|
-
|
|
106
|
-
describe.each(casesLength)('$name', ({ valid, invalid }) => {
|
|
107
|
-
const onErrors = vi.fn()
|
|
108
|
-
|
|
109
|
-
describe('Valid', () => {
|
|
110
|
-
it.each(valid)('should return true for %s', (domain) => {
|
|
111
|
-
const payload: Domain = { ...baseDomainFields, domain }
|
|
112
|
-
expect(getDomainLengthValidator()(payload)).toBe(true)
|
|
113
|
-
expect(onErrors).not.toHaveBeenCalled()
|
|
114
|
-
})
|
|
115
|
-
})
|
|
116
|
-
|
|
117
|
-
describe('Invalid', () => {
|
|
118
|
-
it.each(invalid)('should return false for %s', (domain, expectedErrorMessage) => {
|
|
119
|
-
const payload: Domain = { ...baseDomainFields, domain }
|
|
120
|
-
expect(getDomainLengthValidator()(payload, onErrors)).toBe(false)
|
|
121
|
-
expect(onErrors).toHaveBeenCalledWith(expectedErrorMessage)
|
|
122
|
-
})
|
|
123
|
-
})
|
|
124
|
-
})
|
|
125
|
-
|
|
126
|
-
const startErrorMessage = 'name cannot start with hyphen'
|
|
127
|
-
const endErrorMessage = 'name cannot end with hyphen'
|
|
128
|
-
const casesHyphens = [
|
|
129
|
-
{
|
|
130
|
-
name: 'getDomainAllowedHyphensValidator',
|
|
131
|
-
options: {},
|
|
132
|
-
valid: ['example'],
|
|
133
|
-
invalid: [
|
|
134
|
-
['example-', [endErrorMessage]],
|
|
135
|
-
['-example', [startErrorMessage]],
|
|
136
|
-
['-example-', [startErrorMessage, endErrorMessage]],
|
|
137
|
-
] as [string, string[]][],
|
|
138
|
-
},
|
|
139
|
-
{
|
|
140
|
-
name: 'getDomainAllowedHyphensValidator',
|
|
141
|
-
options: { start: true },
|
|
142
|
-
valid: ['example', '-example'],
|
|
143
|
-
invalid: [['example-', [endErrorMessage]], ['-example-', [endErrorMessage]]] as [string, string[]][],
|
|
144
|
-
},
|
|
145
|
-
{
|
|
146
|
-
name: 'getDomainAllowedHyphensValidator',
|
|
147
|
-
options: { end: true },
|
|
148
|
-
valid: ['example', 'example-'],
|
|
149
|
-
invalid: [['-example', [startErrorMessage]], ['-example-', [startErrorMessage]]] as [string, string[]][],
|
|
150
|
-
},
|
|
151
|
-
{
|
|
152
|
-
name: 'getDomainAllowedHyphensValidator',
|
|
153
|
-
options: { start: true, end: true },
|
|
154
|
-
valid: ['example', '-example', 'example-', '-example-'],
|
|
155
|
-
invalid: [['', [] as string[]] as [string, string[]]],
|
|
156
|
-
},
|
|
157
|
-
]
|
|
158
|
-
|
|
159
|
-
describe.each(casesHyphens)('$name with $options', ({
|
|
160
|
-
options, valid, invalid,
|
|
161
|
-
}) => {
|
|
162
|
-
const validator = getDomainAllowedHyphensValidator(options)
|
|
163
|
-
|
|
164
|
-
describe('Valid', () => {
|
|
165
|
-
it.each(valid)('should return true for %s', (domain) => {
|
|
166
|
-
const payload: Domain = { ...baseDomainFields, domain }
|
|
167
|
-
const onErrors = vi.fn()
|
|
168
|
-
expect(validator(payload)).toBe(true)
|
|
169
|
-
expect(onErrors).not.toHaveBeenCalled()
|
|
170
|
-
})
|
|
171
|
-
})
|
|
172
|
-
|
|
173
|
-
describe('Invalid', () => {
|
|
174
|
-
it.each(invalid)('should return false for %s', (domain, expectedErrorMessage) => {
|
|
175
|
-
if (domain) {
|
|
176
|
-
const payload: Domain = { ...baseDomainFields, domain }
|
|
177
|
-
const onErrors = vi.fn()
|
|
178
|
-
expect(validator(payload, onErrors)).toBe(false)
|
|
179
|
-
if (expectedErrorMessage) expect(onErrors).toHaveBeenCalledWith(expectedErrorMessage)
|
|
180
|
-
} else {
|
|
181
|
-
return
|
|
182
|
-
}
|
|
183
|
-
})
|
|
184
|
-
})
|
|
185
|
-
})
|
|
186
|
-
})
|
|
187
|
-
})
|