@exodus/web3-ethereum 1.4.0 → 1.4.2
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/lib/provider/provider.js +3 -4
- package/lib/rpc-handlers/index.d.ts +1 -0
- package/lib/rpc-handlers/index.js +17 -2
- package/lib/rpc-handlers/parseAndValidateTypedData.js +3 -3
- package/lib/rpc-handlers/validator.d.ts +4 -1
- package/lib/rpc-handlers/validator.js +3033 -3
- package/package.json +6 -5
|
@@ -1,3 +1,3033 @@
|
|
|
1
|
-
export
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
export function validateRequest(value) {
|
|
2
|
+
const validate = (function () {
|
|
3
|
+
'use strict'
|
|
4
|
+
const hasOwn = Function.prototype.call.bind(Object.prototype.hasOwnProperty)
|
|
5
|
+
const format0 = new RegExp(
|
|
6
|
+
'^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$',
|
|
7
|
+
'i',
|
|
8
|
+
)
|
|
9
|
+
const pattern0 = new RegExp('^.*$', 'u')
|
|
10
|
+
const stringLength = (string) =>
|
|
11
|
+
/[\uD800-\uDFFF]/.test(string) ? [...string].length : string.length
|
|
12
|
+
const pointerPart = (s) =>
|
|
13
|
+
/~\//.test(s) ? `${s}`.replace(/~/g, '~0').replace(/\//g, '~1') : s
|
|
14
|
+
const pattern1 = new RegExp('^[a-z]+([A-Z][a-z]+)*[A-Z]?$', 'u')
|
|
15
|
+
const format1 = new RegExp('^0x[a-f0-9]*$', 'i')
|
|
16
|
+
const pattern2 = new RegExp('^[a-z]+$', 'u')
|
|
17
|
+
const unique = (array) => {
|
|
18
|
+
if (array.length < 2) return true
|
|
19
|
+
if (array.length === 2) return !deepEqual(array[0], array[1])
|
|
20
|
+
const objects = []
|
|
21
|
+
const primitives = array.length > 20 ? new Set() : null
|
|
22
|
+
let primitivesCount = 0
|
|
23
|
+
let pos = 0
|
|
24
|
+
for (const item of array) {
|
|
25
|
+
if (typeof item === 'object') {
|
|
26
|
+
objects.push(item)
|
|
27
|
+
} else if (primitives) {
|
|
28
|
+
primitives.add(item)
|
|
29
|
+
if (primitives.size !== ++primitivesCount) return false
|
|
30
|
+
} else {
|
|
31
|
+
if (array.indexOf(item, pos + 1) !== -1) return false
|
|
32
|
+
}
|
|
33
|
+
pos++
|
|
34
|
+
}
|
|
35
|
+
for (let i = 1; i < objects.length; i++)
|
|
36
|
+
for (let j = 0; j < i; j++)
|
|
37
|
+
if (deepEqual(objects[i], objects[j])) return false
|
|
38
|
+
return true
|
|
39
|
+
}
|
|
40
|
+
const deepEqual = (obj, obj2) => {
|
|
41
|
+
if (obj === obj2) return true
|
|
42
|
+
if (!obj || !obj2 || typeof obj !== typeof obj2) return false
|
|
43
|
+
if (obj !== obj2 && typeof obj !== 'object') return false
|
|
44
|
+
|
|
45
|
+
const proto = Object.getPrototypeOf(obj)
|
|
46
|
+
if (proto !== Object.getPrototypeOf(obj2)) return false
|
|
47
|
+
|
|
48
|
+
if (proto === Array.prototype) {
|
|
49
|
+
if (!Array.isArray(obj) || !Array.isArray(obj2)) return false
|
|
50
|
+
if (obj.length !== obj2.length) return false
|
|
51
|
+
return obj.every((x, i) => deepEqual(x, obj2[i]))
|
|
52
|
+
} else if (proto === Object.prototype) {
|
|
53
|
+
const [keys, keys2] = [Object.keys(obj), Object.keys(obj2)]
|
|
54
|
+
if (keys.length !== keys2.length) return false
|
|
55
|
+
const keyset2 = new Set([...keys, ...keys2])
|
|
56
|
+
return (
|
|
57
|
+
keyset2.size === keys.length &&
|
|
58
|
+
keys.every((key) => deepEqual(obj[key], obj2[key]))
|
|
59
|
+
)
|
|
60
|
+
}
|
|
61
|
+
return false
|
|
62
|
+
}
|
|
63
|
+
const ref1 = function validate(data) {
|
|
64
|
+
validate.errors = null
|
|
65
|
+
if (!Array.isArray(data)) {
|
|
66
|
+
validate.errors = [{ keywordLocation: '#/type', instanceLocation: '#' }]
|
|
67
|
+
return false
|
|
68
|
+
}
|
|
69
|
+
if (data.length > 3) {
|
|
70
|
+
validate.errors = [
|
|
71
|
+
{ keywordLocation: '#/maxItems', instanceLocation: '#' },
|
|
72
|
+
]
|
|
73
|
+
return false
|
|
74
|
+
}
|
|
75
|
+
if (data.length < 1) {
|
|
76
|
+
validate.errors = [
|
|
77
|
+
{ keywordLocation: '#/minItems', instanceLocation: '#' },
|
|
78
|
+
]
|
|
79
|
+
return false
|
|
80
|
+
}
|
|
81
|
+
for (let i = 0; i < data.length; i++) {
|
|
82
|
+
if (i in data && hasOwn(data, i)) {
|
|
83
|
+
const sub2 = (() => {
|
|
84
|
+
if (!(typeof data[i] === 'boolean')) return false
|
|
85
|
+
return true
|
|
86
|
+
})()
|
|
87
|
+
const sub3 = (() => {
|
|
88
|
+
if (
|
|
89
|
+
!(
|
|
90
|
+
typeof data[i] === 'object' &&
|
|
91
|
+
data[i] &&
|
|
92
|
+
!Array.isArray(data[i])
|
|
93
|
+
)
|
|
94
|
+
)
|
|
95
|
+
return false
|
|
96
|
+
for (const key0 of Object.keys(data[i])) {
|
|
97
|
+
if (key0.length > 20 && stringLength(key0) > 20) return false
|
|
98
|
+
if (!pattern1.test(key0)) return false
|
|
99
|
+
}
|
|
100
|
+
for (const key1 of Object.keys(data[i])) {
|
|
101
|
+
if (data[i][key1] !== undefined) {
|
|
102
|
+
const sub4 = (() => {
|
|
103
|
+
if (!(typeof data[i][key1] === 'string')) return false
|
|
104
|
+
if (!format1.test(data[i][key1])) return false
|
|
105
|
+
return true
|
|
106
|
+
})()
|
|
107
|
+
const sub5 = (() => {
|
|
108
|
+
if (
|
|
109
|
+
!(
|
|
110
|
+
Array.isArray(data[i][key1]) && data[i][key1].length === 0
|
|
111
|
+
)
|
|
112
|
+
)
|
|
113
|
+
return false
|
|
114
|
+
return true
|
|
115
|
+
})()
|
|
116
|
+
if (!(sub4 || sub5)) return false
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
return true
|
|
120
|
+
})()
|
|
121
|
+
const sub6 = (() => {
|
|
122
|
+
if (!(typeof data[i] === 'string')) return false
|
|
123
|
+
if (!format1.test(data[i])) return false
|
|
124
|
+
return true
|
|
125
|
+
})()
|
|
126
|
+
const sub7 = (() => {
|
|
127
|
+
if (!(typeof data[i] === 'string')) return false
|
|
128
|
+
if (!pattern2.test(data[i])) return false
|
|
129
|
+
return true
|
|
130
|
+
})()
|
|
131
|
+
const sub8 = (() => {
|
|
132
|
+
if (!Array.isArray(data[i])) return false
|
|
133
|
+
if (data[i].length < 1) return false
|
|
134
|
+
for (let j = 0; j < data[i].length; j++) {
|
|
135
|
+
if (j in data[i] && hasOwn(data[i], j)) {
|
|
136
|
+
if (!(typeof data[i][j] === 'number')) return false
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
return true
|
|
140
|
+
})()
|
|
141
|
+
const sub9 = (() => {
|
|
142
|
+
if (!(Array.isArray(data[i]) && data[i].length === 0)) return false
|
|
143
|
+
return true
|
|
144
|
+
})()
|
|
145
|
+
if (!(sub2 || sub3 || sub6 || sub7 || sub8 || sub9)) {
|
|
146
|
+
validate.errors = [
|
|
147
|
+
{ keywordLocation: '#/items/anyOf', instanceLocation: '#/' + i },
|
|
148
|
+
]
|
|
149
|
+
return false
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
if (!unique(data)) {
|
|
154
|
+
validate.errors = [
|
|
155
|
+
{ keywordLocation: '#/uniqueItems', instanceLocation: '#' },
|
|
156
|
+
]
|
|
157
|
+
return false
|
|
158
|
+
}
|
|
159
|
+
return true
|
|
160
|
+
}
|
|
161
|
+
const errorMerge = (
|
|
162
|
+
{ keywordLocation, instanceLocation },
|
|
163
|
+
schemaBase,
|
|
164
|
+
dataBase,
|
|
165
|
+
) => ({
|
|
166
|
+
keywordLocation: `${schemaBase}${keywordLocation.slice(1)}`,
|
|
167
|
+
instanceLocation: `${dataBase}${instanceLocation.slice(1)}`,
|
|
168
|
+
})
|
|
169
|
+
const format2 = new RegExp('^0x[0-9a-f]+$', 'i')
|
|
170
|
+
const ref2 = function validate(data) {
|
|
171
|
+
validate.errors = null
|
|
172
|
+
if (!Array.isArray(data)) {
|
|
173
|
+
validate.errors = [{ keywordLocation: '#/type', instanceLocation: '#' }]
|
|
174
|
+
return false
|
|
175
|
+
}
|
|
176
|
+
if (data.length < 1) {
|
|
177
|
+
validate.errors = [
|
|
178
|
+
{ keywordLocation: '#/minItems', instanceLocation: '#' },
|
|
179
|
+
]
|
|
180
|
+
return false
|
|
181
|
+
}
|
|
182
|
+
if (0 in data && hasOwn(data, 0)) {
|
|
183
|
+
if (!(typeof data[0] === 'string')) {
|
|
184
|
+
validate.errors = [
|
|
185
|
+
{ keywordLocation: '#/0/type', instanceLocation: '#/0' },
|
|
186
|
+
]
|
|
187
|
+
return false
|
|
188
|
+
}
|
|
189
|
+
if (!format2.test(data[0])) {
|
|
190
|
+
validate.errors = [
|
|
191
|
+
{ keywordLocation: '#/0/format', instanceLocation: '#/0' },
|
|
192
|
+
]
|
|
193
|
+
return false
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
if (data.length > 1) {
|
|
197
|
+
validate.errors = [
|
|
198
|
+
{ keywordLocation: '#/items', instanceLocation: '#' },
|
|
199
|
+
]
|
|
200
|
+
return false
|
|
201
|
+
}
|
|
202
|
+
return true
|
|
203
|
+
}
|
|
204
|
+
const format3 = new RegExp('^0x[a-f0-9]{40}$', 'i')
|
|
205
|
+
const ref4 = function validate(data) {
|
|
206
|
+
validate.errors = null
|
|
207
|
+
if (!(typeof data === 'object' && data && !Array.isArray(data))) {
|
|
208
|
+
validate.errors = [{ keywordLocation: '#/type', instanceLocation: '#' }]
|
|
209
|
+
return false
|
|
210
|
+
}
|
|
211
|
+
if (!('from' in data && hasOwn(data, 'from'))) {
|
|
212
|
+
validate.errors = [
|
|
213
|
+
{ keywordLocation: '#/required', instanceLocation: '#/from' },
|
|
214
|
+
]
|
|
215
|
+
return false
|
|
216
|
+
}
|
|
217
|
+
if ('chainId' in data && hasOwn(data, 'chainId')) {
|
|
218
|
+
let passes1 = 0
|
|
219
|
+
const sub10 = (() => {
|
|
220
|
+
if (!(typeof data.chainId === 'string')) return false
|
|
221
|
+
if (!format2.test(data.chainId)) return false
|
|
222
|
+
return true
|
|
223
|
+
})()
|
|
224
|
+
if (sub10) passes1++
|
|
225
|
+
const sub11 = (() => {
|
|
226
|
+
if (!(typeof data.chainId === 'number')) return false
|
|
227
|
+
return true
|
|
228
|
+
})()
|
|
229
|
+
if (sub11) passes1++
|
|
230
|
+
if (passes1 !== 1) {
|
|
231
|
+
validate.errors = [
|
|
232
|
+
{
|
|
233
|
+
keywordLocation: '#/properties/chainId/oneOf',
|
|
234
|
+
instanceLocation: '#/chainId',
|
|
235
|
+
},
|
|
236
|
+
]
|
|
237
|
+
return false
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
if (!(typeof data.from === 'string')) {
|
|
241
|
+
validate.errors = [
|
|
242
|
+
{
|
|
243
|
+
keywordLocation: '#/properties/from/type',
|
|
244
|
+
instanceLocation: '#/from',
|
|
245
|
+
},
|
|
246
|
+
]
|
|
247
|
+
return false
|
|
248
|
+
}
|
|
249
|
+
if (!format3.test(data.from)) {
|
|
250
|
+
validate.errors = [
|
|
251
|
+
{
|
|
252
|
+
keywordLocation: '#/properties/from/format',
|
|
253
|
+
instanceLocation: '#/from',
|
|
254
|
+
},
|
|
255
|
+
]
|
|
256
|
+
return false
|
|
257
|
+
}
|
|
258
|
+
if ('to' in data && hasOwn(data, 'to')) {
|
|
259
|
+
if (!(typeof data.to === 'string')) {
|
|
260
|
+
validate.errors = [
|
|
261
|
+
{
|
|
262
|
+
keywordLocation: '#/properties/to/type',
|
|
263
|
+
instanceLocation: '#/to',
|
|
264
|
+
},
|
|
265
|
+
]
|
|
266
|
+
return false
|
|
267
|
+
}
|
|
268
|
+
if (!format3.test(data.to)) {
|
|
269
|
+
validate.errors = [
|
|
270
|
+
{
|
|
271
|
+
keywordLocation: '#/properties/to/format',
|
|
272
|
+
instanceLocation: '#/to',
|
|
273
|
+
},
|
|
274
|
+
]
|
|
275
|
+
return false
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
if ('gas' in data && hasOwn(data, 'gas')) {
|
|
279
|
+
if (!(typeof data.gas === 'string')) {
|
|
280
|
+
validate.errors = [
|
|
281
|
+
{
|
|
282
|
+
keywordLocation: '#/properties/gas/type',
|
|
283
|
+
instanceLocation: '#/gas',
|
|
284
|
+
},
|
|
285
|
+
]
|
|
286
|
+
return false
|
|
287
|
+
}
|
|
288
|
+
if (!format2.test(data.gas)) {
|
|
289
|
+
validate.errors = [
|
|
290
|
+
{
|
|
291
|
+
keywordLocation: '#/properties/gas/format',
|
|
292
|
+
instanceLocation: '#/gas',
|
|
293
|
+
},
|
|
294
|
+
]
|
|
295
|
+
return false
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
if ('gasPrice' in data && hasOwn(data, 'gasPrice')) {
|
|
299
|
+
if (!(typeof data.gasPrice === 'string')) {
|
|
300
|
+
validate.errors = [
|
|
301
|
+
{
|
|
302
|
+
keywordLocation: '#/properties/gasPrice/type',
|
|
303
|
+
instanceLocation: '#/gasPrice',
|
|
304
|
+
},
|
|
305
|
+
]
|
|
306
|
+
return false
|
|
307
|
+
}
|
|
308
|
+
if (!format2.test(data.gasPrice)) {
|
|
309
|
+
validate.errors = [
|
|
310
|
+
{
|
|
311
|
+
keywordLocation: '#/properties/gasPrice/format',
|
|
312
|
+
instanceLocation: '#/gasPrice',
|
|
313
|
+
},
|
|
314
|
+
]
|
|
315
|
+
return false
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
if ('value' in data && hasOwn(data, 'value')) {
|
|
319
|
+
if (!(typeof data.value === 'string')) {
|
|
320
|
+
validate.errors = [
|
|
321
|
+
{
|
|
322
|
+
keywordLocation: '#/properties/value/type',
|
|
323
|
+
instanceLocation: '#/value',
|
|
324
|
+
},
|
|
325
|
+
]
|
|
326
|
+
return false
|
|
327
|
+
}
|
|
328
|
+
if (!format1.test(data.value)) {
|
|
329
|
+
validate.errors = [
|
|
330
|
+
{
|
|
331
|
+
keywordLocation: '#/properties/value/format',
|
|
332
|
+
instanceLocation: '#/value',
|
|
333
|
+
},
|
|
334
|
+
]
|
|
335
|
+
return false
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
if ('data' in data && hasOwn(data, 'data')) {
|
|
339
|
+
if (!(typeof data.data === 'string')) {
|
|
340
|
+
validate.errors = [
|
|
341
|
+
{
|
|
342
|
+
keywordLocation: '#/properties/data/type',
|
|
343
|
+
instanceLocation: '#/data',
|
|
344
|
+
},
|
|
345
|
+
]
|
|
346
|
+
return false
|
|
347
|
+
}
|
|
348
|
+
if (!format1.test(data.data)) {
|
|
349
|
+
validate.errors = [
|
|
350
|
+
{
|
|
351
|
+
keywordLocation: '#/properties/data/format',
|
|
352
|
+
instanceLocation: '#/data',
|
|
353
|
+
},
|
|
354
|
+
]
|
|
355
|
+
return false
|
|
356
|
+
}
|
|
357
|
+
}
|
|
358
|
+
if (
|
|
359
|
+
'maxPriorityFeePerGas' in data &&
|
|
360
|
+
hasOwn(data, 'maxPriorityFeePerGas')
|
|
361
|
+
) {
|
|
362
|
+
let passes2 = 0
|
|
363
|
+
const sub12 = (() => {
|
|
364
|
+
if (!(typeof data.maxPriorityFeePerGas === 'string')) return false
|
|
365
|
+
if (!format1.test(data.maxPriorityFeePerGas)) return false
|
|
366
|
+
return true
|
|
367
|
+
})()
|
|
368
|
+
if (sub12) passes2++
|
|
369
|
+
const sub13 = (() => {
|
|
370
|
+
if (!(data.maxPriorityFeePerGas === null)) return false
|
|
371
|
+
return true
|
|
372
|
+
})()
|
|
373
|
+
if (sub13) passes2++
|
|
374
|
+
if (passes2 !== 1) {
|
|
375
|
+
validate.errors = [
|
|
376
|
+
{
|
|
377
|
+
keywordLocation: '#/properties/maxPriorityFeePerGas/oneOf',
|
|
378
|
+
instanceLocation: '#/maxPriorityFeePerGas',
|
|
379
|
+
},
|
|
380
|
+
]
|
|
381
|
+
return false
|
|
382
|
+
}
|
|
383
|
+
}
|
|
384
|
+
if ('maxFeePerGas' in data && hasOwn(data, 'maxFeePerGas')) {
|
|
385
|
+
let passes3 = 0
|
|
386
|
+
const sub14 = (() => {
|
|
387
|
+
if (!(typeof data.maxFeePerGas === 'string')) return false
|
|
388
|
+
if (!format1.test(data.maxFeePerGas)) return false
|
|
389
|
+
return true
|
|
390
|
+
})()
|
|
391
|
+
if (sub14) passes3++
|
|
392
|
+
const sub15 = (() => {
|
|
393
|
+
if (!(data.maxFeePerGas === null)) return false
|
|
394
|
+
return true
|
|
395
|
+
})()
|
|
396
|
+
if (sub15) passes3++
|
|
397
|
+
if (passes3 !== 1) {
|
|
398
|
+
validate.errors = [
|
|
399
|
+
{
|
|
400
|
+
keywordLocation: '#/properties/maxFeePerGas/oneOf',
|
|
401
|
+
instanceLocation: '#/maxFeePerGas',
|
|
402
|
+
},
|
|
403
|
+
]
|
|
404
|
+
return false
|
|
405
|
+
}
|
|
406
|
+
}
|
|
407
|
+
for (const key2 of Object.keys(data)) {
|
|
408
|
+
if (
|
|
409
|
+
key2 !== 'chainId' &&
|
|
410
|
+
key2 !== 'from' &&
|
|
411
|
+
key2 !== 'to' &&
|
|
412
|
+
key2 !== 'gas' &&
|
|
413
|
+
key2 !== 'gasPrice' &&
|
|
414
|
+
key2 !== 'value' &&
|
|
415
|
+
key2 !== 'data' &&
|
|
416
|
+
key2 !== 'maxPriorityFeePerGas' &&
|
|
417
|
+
key2 !== 'maxFeePerGas'
|
|
418
|
+
)
|
|
419
|
+
delete data[key2]
|
|
420
|
+
}
|
|
421
|
+
return true
|
|
422
|
+
}
|
|
423
|
+
const ref3 = function validate(data) {
|
|
424
|
+
validate.errors = null
|
|
425
|
+
if (!Array.isArray(data)) {
|
|
426
|
+
validate.errors = [{ keywordLocation: '#/type', instanceLocation: '#' }]
|
|
427
|
+
return false
|
|
428
|
+
}
|
|
429
|
+
if (data.length < 1) {
|
|
430
|
+
validate.errors = [
|
|
431
|
+
{ keywordLocation: '#/minItems', instanceLocation: '#' },
|
|
432
|
+
]
|
|
433
|
+
return false
|
|
434
|
+
}
|
|
435
|
+
if (0 in data && hasOwn(data, 0)) {
|
|
436
|
+
const err22 = validate.errors
|
|
437
|
+
const res22 = ref4(data[0])
|
|
438
|
+
const suberr22 = ref4.errors
|
|
439
|
+
validate.errors = err22
|
|
440
|
+
if (!res22) {
|
|
441
|
+
validate.errors = [errorMerge(suberr22[0], '#/0/$ref', '#/0')]
|
|
442
|
+
return false
|
|
443
|
+
}
|
|
444
|
+
}
|
|
445
|
+
if (data.length > 1) {
|
|
446
|
+
validate.errors = [
|
|
447
|
+
{ keywordLocation: '#/items', instanceLocation: '#' },
|
|
448
|
+
]
|
|
449
|
+
return false
|
|
450
|
+
}
|
|
451
|
+
return true
|
|
452
|
+
}
|
|
453
|
+
const ref5 = function validate(data) {
|
|
454
|
+
validate.errors = null
|
|
455
|
+
if (!Array.isArray(data)) {
|
|
456
|
+
validate.errors = [{ keywordLocation: '#/type', instanceLocation: '#' }]
|
|
457
|
+
return false
|
|
458
|
+
}
|
|
459
|
+
if (data.length < 2) {
|
|
460
|
+
validate.errors = [
|
|
461
|
+
{ keywordLocation: '#/minItems', instanceLocation: '#' },
|
|
462
|
+
]
|
|
463
|
+
return false
|
|
464
|
+
}
|
|
465
|
+
if (0 in data && hasOwn(data, 0)) {
|
|
466
|
+
if (!(typeof data[0] === 'string')) {
|
|
467
|
+
validate.errors = [
|
|
468
|
+
{ keywordLocation: '#/0/type', instanceLocation: '#/0' },
|
|
469
|
+
]
|
|
470
|
+
return false
|
|
471
|
+
}
|
|
472
|
+
if (!format3.test(data[0])) {
|
|
473
|
+
validate.errors = [
|
|
474
|
+
{ keywordLocation: '#/0/format', instanceLocation: '#/0' },
|
|
475
|
+
]
|
|
476
|
+
return false
|
|
477
|
+
}
|
|
478
|
+
}
|
|
479
|
+
if (1 in data && hasOwn(data, 1)) {
|
|
480
|
+
if (!(typeof data[1] === 'string')) {
|
|
481
|
+
validate.errors = [
|
|
482
|
+
{ keywordLocation: '#/1/type', instanceLocation: '#/1' },
|
|
483
|
+
]
|
|
484
|
+
return false
|
|
485
|
+
}
|
|
486
|
+
if (!format2.test(data[1])) {
|
|
487
|
+
validate.errors = [
|
|
488
|
+
{ keywordLocation: '#/1/format', instanceLocation: '#/1' },
|
|
489
|
+
]
|
|
490
|
+
return false
|
|
491
|
+
}
|
|
492
|
+
}
|
|
493
|
+
if (data.length > 2) {
|
|
494
|
+
validate.errors = [
|
|
495
|
+
{ keywordLocation: '#/items', instanceLocation: '#' },
|
|
496
|
+
]
|
|
497
|
+
return false
|
|
498
|
+
}
|
|
499
|
+
return true
|
|
500
|
+
}
|
|
501
|
+
const ref6 = function validate(data) {
|
|
502
|
+
validate.errors = null
|
|
503
|
+
if (!Array.isArray(data)) {
|
|
504
|
+
validate.errors = [{ keywordLocation: '#/type', instanceLocation: '#' }]
|
|
505
|
+
return false
|
|
506
|
+
}
|
|
507
|
+
if (data.length < 1) {
|
|
508
|
+
validate.errors = [
|
|
509
|
+
{ keywordLocation: '#/minItems', instanceLocation: '#' },
|
|
510
|
+
]
|
|
511
|
+
return false
|
|
512
|
+
}
|
|
513
|
+
if (0 in data && hasOwn(data, 0)) {
|
|
514
|
+
const err25 = validate.errors
|
|
515
|
+
const res25 = ref4(data[0])
|
|
516
|
+
const suberr25 = ref4.errors
|
|
517
|
+
validate.errors = err25
|
|
518
|
+
if (!res25) {
|
|
519
|
+
validate.errors = [errorMerge(suberr25[0], '#/0/$ref', '#/0')]
|
|
520
|
+
return false
|
|
521
|
+
}
|
|
522
|
+
}
|
|
523
|
+
if (data.length > 1) {
|
|
524
|
+
validate.errors = [
|
|
525
|
+
{ keywordLocation: '#/items', instanceLocation: '#' },
|
|
526
|
+
]
|
|
527
|
+
return false
|
|
528
|
+
}
|
|
529
|
+
return true
|
|
530
|
+
}
|
|
531
|
+
const format4 = new RegExp('^(?!_)(\\n|\\r|.)*$', '')
|
|
532
|
+
const ref7 = function validate(data) {
|
|
533
|
+
validate.errors = null
|
|
534
|
+
if (!Array.isArray(data)) {
|
|
535
|
+
validate.errors = [{ keywordLocation: '#/type', instanceLocation: '#' }]
|
|
536
|
+
return false
|
|
537
|
+
}
|
|
538
|
+
if (data.length < 2) {
|
|
539
|
+
validate.errors = [
|
|
540
|
+
{ keywordLocation: '#/minItems', instanceLocation: '#' },
|
|
541
|
+
]
|
|
542
|
+
return false
|
|
543
|
+
}
|
|
544
|
+
if (0 in data && hasOwn(data, 0)) {
|
|
545
|
+
if (!(typeof data[0] === 'string')) {
|
|
546
|
+
validate.errors = [
|
|
547
|
+
{ keywordLocation: '#/0/type', instanceLocation: '#/0' },
|
|
548
|
+
]
|
|
549
|
+
return false
|
|
550
|
+
}
|
|
551
|
+
if (!format3.test(data[0])) {
|
|
552
|
+
validate.errors = [
|
|
553
|
+
{ keywordLocation: '#/0/format', instanceLocation: '#/0' },
|
|
554
|
+
]
|
|
555
|
+
return false
|
|
556
|
+
}
|
|
557
|
+
}
|
|
558
|
+
if (1 in data && hasOwn(data, 1)) {
|
|
559
|
+
if (!(typeof data[1] === 'string')) {
|
|
560
|
+
validate.errors = [
|
|
561
|
+
{ keywordLocation: '#/1/type', instanceLocation: '#/1' },
|
|
562
|
+
]
|
|
563
|
+
return false
|
|
564
|
+
}
|
|
565
|
+
if (data[1].length > 10000 && stringLength(data[1]) > 10000) {
|
|
566
|
+
validate.errors = [
|
|
567
|
+
{ keywordLocation: '#/1/maxLength', instanceLocation: '#/1' },
|
|
568
|
+
]
|
|
569
|
+
return false
|
|
570
|
+
}
|
|
571
|
+
if (!format4.test(data[1])) {
|
|
572
|
+
validate.errors = [
|
|
573
|
+
{ keywordLocation: '#/1/format', instanceLocation: '#/1' },
|
|
574
|
+
]
|
|
575
|
+
return false
|
|
576
|
+
}
|
|
577
|
+
}
|
|
578
|
+
if (data.length > 2) {
|
|
579
|
+
validate.errors = [
|
|
580
|
+
{ keywordLocation: '#/items', instanceLocation: '#' },
|
|
581
|
+
]
|
|
582
|
+
return false
|
|
583
|
+
}
|
|
584
|
+
return true
|
|
585
|
+
}
|
|
586
|
+
const format5 = new RegExp('^(?!_)[\\s\\w!?.,/()[\\]]+$', '')
|
|
587
|
+
const ref9 = function validate(data) {
|
|
588
|
+
validate.errors = null
|
|
589
|
+
if (!Array.isArray(data)) {
|
|
590
|
+
validate.errors = [{ keywordLocation: '#/type', instanceLocation: '#' }]
|
|
591
|
+
return false
|
|
592
|
+
}
|
|
593
|
+
for (let k = 0; k < data.length; k++) {
|
|
594
|
+
if (k in data && hasOwn(data, k)) {
|
|
595
|
+
if (
|
|
596
|
+
!(typeof data[k] === 'object' && data[k] && !Array.isArray(data[k]))
|
|
597
|
+
) {
|
|
598
|
+
validate.errors = [
|
|
599
|
+
{ keywordLocation: '#/items/type', instanceLocation: '#/' + k },
|
|
600
|
+
]
|
|
601
|
+
return false
|
|
602
|
+
}
|
|
603
|
+
if (!('name' in data[k] && hasOwn(data[k], 'name'))) {
|
|
604
|
+
validate.errors = [
|
|
605
|
+
{
|
|
606
|
+
keywordLocation: '#/items/required',
|
|
607
|
+
instanceLocation: '#/' + k + '/name',
|
|
608
|
+
},
|
|
609
|
+
]
|
|
610
|
+
return false
|
|
611
|
+
}
|
|
612
|
+
if (!('type' in data[k] && hasOwn(data[k], 'type'))) {
|
|
613
|
+
validate.errors = [
|
|
614
|
+
{
|
|
615
|
+
keywordLocation: '#/items/required',
|
|
616
|
+
instanceLocation: '#/' + k + '/type',
|
|
617
|
+
},
|
|
618
|
+
]
|
|
619
|
+
return false
|
|
620
|
+
}
|
|
621
|
+
if (!('value' in data[k] && hasOwn(data[k], 'value'))) {
|
|
622
|
+
validate.errors = [
|
|
623
|
+
{
|
|
624
|
+
keywordLocation: '#/items/required',
|
|
625
|
+
instanceLocation: '#/' + k + '/value',
|
|
626
|
+
},
|
|
627
|
+
]
|
|
628
|
+
return false
|
|
629
|
+
}
|
|
630
|
+
if (!(typeof data[k].name === 'string')) {
|
|
631
|
+
validate.errors = [
|
|
632
|
+
{
|
|
633
|
+
keywordLocation: '#/items/properties/name/type',
|
|
634
|
+
instanceLocation: '#/' + k + '/name',
|
|
635
|
+
},
|
|
636
|
+
]
|
|
637
|
+
return false
|
|
638
|
+
}
|
|
639
|
+
if (data[k].name.length > 50 && stringLength(data[k].name) > 50) {
|
|
640
|
+
validate.errors = [
|
|
641
|
+
{
|
|
642
|
+
keywordLocation: '#/items/properties/name/maxLength',
|
|
643
|
+
instanceLocation: '#/' + k + '/name',
|
|
644
|
+
},
|
|
645
|
+
]
|
|
646
|
+
return false
|
|
647
|
+
}
|
|
648
|
+
if (!format5.test(data[k].name)) {
|
|
649
|
+
validate.errors = [
|
|
650
|
+
{
|
|
651
|
+
keywordLocation: '#/items/properties/name/format',
|
|
652
|
+
instanceLocation: '#/' + k + '/name',
|
|
653
|
+
},
|
|
654
|
+
]
|
|
655
|
+
return false
|
|
656
|
+
}
|
|
657
|
+
if (!(typeof data[k].type === 'string')) {
|
|
658
|
+
validate.errors = [
|
|
659
|
+
{
|
|
660
|
+
keywordLocation: '#/items/properties/type/type',
|
|
661
|
+
instanceLocation: '#/' + k + '/type',
|
|
662
|
+
},
|
|
663
|
+
]
|
|
664
|
+
return false
|
|
665
|
+
}
|
|
666
|
+
if (data[k].type.length > 50 && stringLength(data[k].type) > 50) {
|
|
667
|
+
validate.errors = [
|
|
668
|
+
{
|
|
669
|
+
keywordLocation: '#/items/properties/type/maxLength',
|
|
670
|
+
instanceLocation: '#/' + k + '/type',
|
|
671
|
+
},
|
|
672
|
+
]
|
|
673
|
+
return false
|
|
674
|
+
}
|
|
675
|
+
if (!format5.test(data[k].type)) {
|
|
676
|
+
validate.errors = [
|
|
677
|
+
{
|
|
678
|
+
keywordLocation: '#/items/properties/type/format',
|
|
679
|
+
instanceLocation: '#/' + k + '/type',
|
|
680
|
+
},
|
|
681
|
+
]
|
|
682
|
+
return false
|
|
683
|
+
}
|
|
684
|
+
if (!(typeof data[k].value === 'string')) {
|
|
685
|
+
validate.errors = [
|
|
686
|
+
{
|
|
687
|
+
keywordLocation: '#/items/properties/value/type',
|
|
688
|
+
instanceLocation: '#/' + k + '/value',
|
|
689
|
+
},
|
|
690
|
+
]
|
|
691
|
+
return false
|
|
692
|
+
}
|
|
693
|
+
if (
|
|
694
|
+
data[k].value.length > 10000 &&
|
|
695
|
+
stringLength(data[k].value) > 10000
|
|
696
|
+
) {
|
|
697
|
+
validate.errors = [
|
|
698
|
+
{
|
|
699
|
+
keywordLocation: '#/items/properties/value/maxLength',
|
|
700
|
+
instanceLocation: '#/' + k + '/value',
|
|
701
|
+
},
|
|
702
|
+
]
|
|
703
|
+
return false
|
|
704
|
+
}
|
|
705
|
+
if (!format4.test(data[k].value)) {
|
|
706
|
+
validate.errors = [
|
|
707
|
+
{
|
|
708
|
+
keywordLocation: '#/items/properties/value/format',
|
|
709
|
+
instanceLocation: '#/' + k + '/value',
|
|
710
|
+
},
|
|
711
|
+
]
|
|
712
|
+
return false
|
|
713
|
+
}
|
|
714
|
+
for (const key3 of Object.keys(data[k])) {
|
|
715
|
+
if (key3 !== 'name' && key3 !== 'type' && key3 !== 'value') {
|
|
716
|
+
validate.errors = [
|
|
717
|
+
{
|
|
718
|
+
keywordLocation: '#/items/additionalProperties',
|
|
719
|
+
instanceLocation: '#/' + k + '/' + pointerPart(key3),
|
|
720
|
+
},
|
|
721
|
+
]
|
|
722
|
+
return false
|
|
723
|
+
}
|
|
724
|
+
}
|
|
725
|
+
}
|
|
726
|
+
}
|
|
727
|
+
return true
|
|
728
|
+
}
|
|
729
|
+
const ref8 = function validate(data) {
|
|
730
|
+
validate.errors = null
|
|
731
|
+
if (!Array.isArray(data)) {
|
|
732
|
+
validate.errors = [{ keywordLocation: '#/type', instanceLocation: '#' }]
|
|
733
|
+
return false
|
|
734
|
+
}
|
|
735
|
+
if (data.length < 2) {
|
|
736
|
+
validate.errors = [
|
|
737
|
+
{ keywordLocation: '#/minItems', instanceLocation: '#' },
|
|
738
|
+
]
|
|
739
|
+
return false
|
|
740
|
+
}
|
|
741
|
+
if (0 in data && hasOwn(data, 0)) {
|
|
742
|
+
const err28 = validate.errors
|
|
743
|
+
const res28 = ref9(data[0])
|
|
744
|
+
const suberr28 = ref9.errors
|
|
745
|
+
validate.errors = err28
|
|
746
|
+
if (!res28) {
|
|
747
|
+
validate.errors = [errorMerge(suberr28[0], '#/0/$ref', '#/0')]
|
|
748
|
+
return false
|
|
749
|
+
}
|
|
750
|
+
}
|
|
751
|
+
if (1 in data && hasOwn(data, 1)) {
|
|
752
|
+
if (!(typeof data[1] === 'string')) {
|
|
753
|
+
validate.errors = [
|
|
754
|
+
{ keywordLocation: '#/1/type', instanceLocation: '#/1' },
|
|
755
|
+
]
|
|
756
|
+
return false
|
|
757
|
+
}
|
|
758
|
+
if (!format3.test(data[1])) {
|
|
759
|
+
validate.errors = [
|
|
760
|
+
{ keywordLocation: '#/1/format', instanceLocation: '#/1' },
|
|
761
|
+
]
|
|
762
|
+
return false
|
|
763
|
+
}
|
|
764
|
+
}
|
|
765
|
+
if (data.length > 2) {
|
|
766
|
+
validate.errors = [
|
|
767
|
+
{ keywordLocation: '#/items', instanceLocation: '#' },
|
|
768
|
+
]
|
|
769
|
+
return false
|
|
770
|
+
}
|
|
771
|
+
return true
|
|
772
|
+
}
|
|
773
|
+
const ref10 = function validate(data) {
|
|
774
|
+
validate.errors = null
|
|
775
|
+
if (!Array.isArray(data)) {
|
|
776
|
+
validate.errors = [{ keywordLocation: '#/type', instanceLocation: '#' }]
|
|
777
|
+
return false
|
|
778
|
+
}
|
|
779
|
+
if (data.length < 2) {
|
|
780
|
+
validate.errors = [
|
|
781
|
+
{ keywordLocation: '#/minItems', instanceLocation: '#' },
|
|
782
|
+
]
|
|
783
|
+
return false
|
|
784
|
+
}
|
|
785
|
+
if (0 in data && hasOwn(data, 0)) {
|
|
786
|
+
if (!(typeof data[0] === 'string')) {
|
|
787
|
+
validate.errors = [
|
|
788
|
+
{ keywordLocation: '#/0/type', instanceLocation: '#/0' },
|
|
789
|
+
]
|
|
790
|
+
return false
|
|
791
|
+
}
|
|
792
|
+
if (data[0].length > 10000 && stringLength(data[0]) > 10000) {
|
|
793
|
+
validate.errors = [
|
|
794
|
+
{ keywordLocation: '#/0/maxLength', instanceLocation: '#/0' },
|
|
795
|
+
]
|
|
796
|
+
return false
|
|
797
|
+
}
|
|
798
|
+
if (!format4.test(data[0])) {
|
|
799
|
+
validate.errors = [
|
|
800
|
+
{ keywordLocation: '#/0/format', instanceLocation: '#/0' },
|
|
801
|
+
]
|
|
802
|
+
return false
|
|
803
|
+
}
|
|
804
|
+
}
|
|
805
|
+
if (1 in data && hasOwn(data, 1)) {
|
|
806
|
+
if (!(typeof data[1] === 'string')) {
|
|
807
|
+
validate.errors = [
|
|
808
|
+
{ keywordLocation: '#/1/type', instanceLocation: '#/1' },
|
|
809
|
+
]
|
|
810
|
+
return false
|
|
811
|
+
}
|
|
812
|
+
if (!format3.test(data[1])) {
|
|
813
|
+
validate.errors = [
|
|
814
|
+
{ keywordLocation: '#/1/format', instanceLocation: '#/1' },
|
|
815
|
+
]
|
|
816
|
+
return false
|
|
817
|
+
}
|
|
818
|
+
}
|
|
819
|
+
if (data.length > 2) {
|
|
820
|
+
validate.errors = [
|
|
821
|
+
{ keywordLocation: '#/items', instanceLocation: '#' },
|
|
822
|
+
]
|
|
823
|
+
return false
|
|
824
|
+
}
|
|
825
|
+
return true
|
|
826
|
+
}
|
|
827
|
+
const ref13 = function validate(data) {
|
|
828
|
+
validate.errors = null
|
|
829
|
+
if (!(typeof data === 'object' && data && !Array.isArray(data))) {
|
|
830
|
+
validate.errors = [{ keywordLocation: '#/type', instanceLocation: '#' }]
|
|
831
|
+
return false
|
|
832
|
+
}
|
|
833
|
+
for (const key4 of Object.keys(data)) {
|
|
834
|
+
validate.errors = [
|
|
835
|
+
{
|
|
836
|
+
keywordLocation: '#/additionalProperties',
|
|
837
|
+
instanceLocation: '#/' + pointerPart(key4),
|
|
838
|
+
},
|
|
839
|
+
]
|
|
840
|
+
return false
|
|
841
|
+
}
|
|
842
|
+
return true
|
|
843
|
+
}
|
|
844
|
+
const ref12 = function validate(data) {
|
|
845
|
+
validate.errors = null
|
|
846
|
+
if (!(typeof data === 'object' && data && !Array.isArray(data))) {
|
|
847
|
+
validate.errors = [{ keywordLocation: '#/type', instanceLocation: '#' }]
|
|
848
|
+
return false
|
|
849
|
+
}
|
|
850
|
+
if ('eth_accounts' in data && hasOwn(data, 'eth_accounts')) {
|
|
851
|
+
const err34 = validate.errors
|
|
852
|
+
const res34 = ref13(data.eth_accounts)
|
|
853
|
+
const suberr34 = ref13.errors
|
|
854
|
+
validate.errors = err34
|
|
855
|
+
if (!res34) {
|
|
856
|
+
validate.errors = [
|
|
857
|
+
errorMerge(
|
|
858
|
+
suberr34[0],
|
|
859
|
+
'#/properties/eth_accounts/$ref',
|
|
860
|
+
'#/eth_accounts',
|
|
861
|
+
),
|
|
862
|
+
]
|
|
863
|
+
return false
|
|
864
|
+
}
|
|
865
|
+
}
|
|
866
|
+
for (const key5 of Object.keys(data)) {
|
|
867
|
+
if (key5 !== 'eth_accounts') {
|
|
868
|
+
validate.errors = [
|
|
869
|
+
{
|
|
870
|
+
keywordLocation: '#/additionalProperties',
|
|
871
|
+
instanceLocation: '#/' + pointerPart(key5),
|
|
872
|
+
},
|
|
873
|
+
]
|
|
874
|
+
return false
|
|
875
|
+
}
|
|
876
|
+
}
|
|
877
|
+
return true
|
|
878
|
+
}
|
|
879
|
+
const ref11 = function validate(data) {
|
|
880
|
+
validate.errors = null
|
|
881
|
+
if (!Array.isArray(data)) {
|
|
882
|
+
validate.errors = [{ keywordLocation: '#/type', instanceLocation: '#' }]
|
|
883
|
+
return false
|
|
884
|
+
}
|
|
885
|
+
if (data.length < 1) {
|
|
886
|
+
validate.errors = [
|
|
887
|
+
{ keywordLocation: '#/minItems', instanceLocation: '#' },
|
|
888
|
+
]
|
|
889
|
+
return false
|
|
890
|
+
}
|
|
891
|
+
if (0 in data && hasOwn(data, 0)) {
|
|
892
|
+
const err35 = validate.errors
|
|
893
|
+
const res35 = ref12(data[0])
|
|
894
|
+
const suberr35 = ref12.errors
|
|
895
|
+
validate.errors = err35
|
|
896
|
+
if (!res35) {
|
|
897
|
+
validate.errors = [errorMerge(suberr35[0], '#/0/$ref', '#/0')]
|
|
898
|
+
return false
|
|
899
|
+
}
|
|
900
|
+
}
|
|
901
|
+
if (data.length > 1) {
|
|
902
|
+
validate.errors = [
|
|
903
|
+
{ keywordLocation: '#/items', instanceLocation: '#' },
|
|
904
|
+
]
|
|
905
|
+
return false
|
|
906
|
+
}
|
|
907
|
+
return true
|
|
908
|
+
}
|
|
909
|
+
const format6 = new RegExp(
|
|
910
|
+
"^[a-z][a-z0-9+\\-.]*:(?:\\/?\\/(?:(?:[a-z0-9\\-._~!$&'()*+,;=:]|%[0-9a-f]{2})*@)?(?:\\[(?:(?:(?:(?:[0-9a-f]{1,4}:){6}|::(?:[0-9a-f]{1,4}:){5}|(?:[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){4}|(?:(?:[0-9a-f]{1,4}:){0,1}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){3}|(?:(?:[0-9a-f]{1,4}:){0,2}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){2}|(?:(?:[0-9a-f]{1,4}:){0,3}[0-9a-f]{1,4})?::[0-9a-f]{1,4}:|(?:(?:[0-9a-f]{1,4}:){0,4}[0-9a-f]{1,4})?::)(?:[0-9a-f]{1,4}:[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d\\d?)\\.){3}(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d\\d?))|(?:(?:[0-9a-f]{1,4}:){0,5}[0-9a-f]{1,4})?::[0-9a-f]{1,4}|(?:(?:[0-9a-f]{1,4}:){0,6}[0-9a-f]{1,4})?::)|v[0-9a-f]+\\.[a-z0-9\\-._~!$&'()*+,;=:]+)\\]|(?:(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d\\d?)\\.){3}(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d\\d?)|(?:[a-z0-9\\-._~!$&'()*+,;=]|%[0-9a-f]{2})*)(?::\\d*)?(?:\\/(?:[a-z0-9\\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*|\\/?(?:(?:[a-z0-9\\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\\/(?:[a-z0-9\\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)?)(?:\\?(?:[a-z0-9\\-._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?(?:#(?:[a-z0-9\\-._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?$",
|
|
911
|
+
'i',
|
|
912
|
+
)
|
|
913
|
+
const format7 = (input) =>
|
|
914
|
+
input.length % 4 === 0 && /^[a-z0-9+/]*={0,3}$/i.test(input)
|
|
915
|
+
const ref16 = function validate(data) {
|
|
916
|
+
validate.errors = null
|
|
917
|
+
if (!(typeof data === 'string')) {
|
|
918
|
+
validate.errors = [{ keywordLocation: '#/type', instanceLocation: '#' }]
|
|
919
|
+
return false
|
|
920
|
+
}
|
|
921
|
+
if (data.length < 1 || stringLength(data) < 1) {
|
|
922
|
+
validate.errors = [
|
|
923
|
+
{ keywordLocation: '#/minLength', instanceLocation: '#' },
|
|
924
|
+
]
|
|
925
|
+
return false
|
|
926
|
+
}
|
|
927
|
+
if (!format7(data)) {
|
|
928
|
+
validate.errors = [
|
|
929
|
+
{ keywordLocation: '#/format', instanceLocation: '#' },
|
|
930
|
+
]
|
|
931
|
+
return false
|
|
932
|
+
}
|
|
933
|
+
return true
|
|
934
|
+
}
|
|
935
|
+
const ref15 = function validate(data) {
|
|
936
|
+
validate.errors = null
|
|
937
|
+
if (!(typeof data === 'object' && data && !Array.isArray(data))) {
|
|
938
|
+
validate.errors = [{ keywordLocation: '#/type', instanceLocation: '#' }]
|
|
939
|
+
return false
|
|
940
|
+
}
|
|
941
|
+
if (!('address' in data && hasOwn(data, 'address'))) {
|
|
942
|
+
validate.errors = [
|
|
943
|
+
{ keywordLocation: '#/required', instanceLocation: '#/address' },
|
|
944
|
+
]
|
|
945
|
+
return false
|
|
946
|
+
}
|
|
947
|
+
if (!(typeof data.address === 'string')) {
|
|
948
|
+
validate.errors = [
|
|
949
|
+
{
|
|
950
|
+
keywordLocation: '#/properties/address/type',
|
|
951
|
+
instanceLocation: '#/address',
|
|
952
|
+
},
|
|
953
|
+
]
|
|
954
|
+
return false
|
|
955
|
+
}
|
|
956
|
+
if (!format3.test(data.address)) {
|
|
957
|
+
validate.errors = [
|
|
958
|
+
{
|
|
959
|
+
keywordLocation: '#/properties/address/format',
|
|
960
|
+
instanceLocation: '#/address',
|
|
961
|
+
},
|
|
962
|
+
]
|
|
963
|
+
return false
|
|
964
|
+
}
|
|
965
|
+
if ('symbol' in data && hasOwn(data, 'symbol')) {
|
|
966
|
+
if (!(typeof data.symbol === 'string')) {
|
|
967
|
+
validate.errors = [
|
|
968
|
+
{
|
|
969
|
+
keywordLocation: '#/properties/symbol/type',
|
|
970
|
+
instanceLocation: '#/symbol',
|
|
971
|
+
},
|
|
972
|
+
]
|
|
973
|
+
return false
|
|
974
|
+
}
|
|
975
|
+
if (data.symbol.length > 5 && stringLength(data.symbol) > 5) {
|
|
976
|
+
validate.errors = [
|
|
977
|
+
{
|
|
978
|
+
keywordLocation: '#/properties/symbol/maxLength',
|
|
979
|
+
instanceLocation: '#/symbol',
|
|
980
|
+
},
|
|
981
|
+
]
|
|
982
|
+
return false
|
|
983
|
+
}
|
|
984
|
+
if (!format5.test(data.symbol)) {
|
|
985
|
+
validate.errors = [
|
|
986
|
+
{
|
|
987
|
+
keywordLocation: '#/properties/symbol/format',
|
|
988
|
+
instanceLocation: '#/symbol',
|
|
989
|
+
},
|
|
990
|
+
]
|
|
991
|
+
return false
|
|
992
|
+
}
|
|
993
|
+
}
|
|
994
|
+
if ('decimals' in data && hasOwn(data, 'decimals')) {
|
|
995
|
+
if (!(typeof data.decimals === 'number')) {
|
|
996
|
+
validate.errors = [
|
|
997
|
+
{
|
|
998
|
+
keywordLocation: '#/properties/decimals/type',
|
|
999
|
+
instanceLocation: '#/decimals',
|
|
1000
|
+
},
|
|
1001
|
+
]
|
|
1002
|
+
return false
|
|
1003
|
+
}
|
|
1004
|
+
}
|
|
1005
|
+
if ('image' in data && hasOwn(data, 'image')) {
|
|
1006
|
+
let passes4 = 0
|
|
1007
|
+
const sub16 = (() => {
|
|
1008
|
+
if (!(typeof data.image === 'string')) return false
|
|
1009
|
+
if (!format6.test(data.image)) return false
|
|
1010
|
+
return true
|
|
1011
|
+
})()
|
|
1012
|
+
if (sub16) passes4++
|
|
1013
|
+
const sub17 = (() => {
|
|
1014
|
+
const err37 = validate.errors
|
|
1015
|
+
const res37 = ref16(data.image)
|
|
1016
|
+
const suberr37 = ref16.errors
|
|
1017
|
+
validate.errors = err37
|
|
1018
|
+
if (!res37) return false
|
|
1019
|
+
return true
|
|
1020
|
+
})()
|
|
1021
|
+
if (sub17) passes4++
|
|
1022
|
+
if (passes4 !== 1) {
|
|
1023
|
+
validate.errors = [
|
|
1024
|
+
{
|
|
1025
|
+
keywordLocation: '#/properties/image/oneOf',
|
|
1026
|
+
instanceLocation: '#/image',
|
|
1027
|
+
},
|
|
1028
|
+
]
|
|
1029
|
+
return false
|
|
1030
|
+
}
|
|
1031
|
+
}
|
|
1032
|
+
for (const key6 of Object.keys(data)) {
|
|
1033
|
+
if (
|
|
1034
|
+
key6 !== 'address' &&
|
|
1035
|
+
key6 !== 'symbol' &&
|
|
1036
|
+
key6 !== 'decimals' &&
|
|
1037
|
+
key6 !== 'image'
|
|
1038
|
+
) {
|
|
1039
|
+
validate.errors = [
|
|
1040
|
+
{
|
|
1041
|
+
keywordLocation: '#/additionalProperties',
|
|
1042
|
+
instanceLocation: '#/' + pointerPart(key6),
|
|
1043
|
+
},
|
|
1044
|
+
]
|
|
1045
|
+
return false
|
|
1046
|
+
}
|
|
1047
|
+
}
|
|
1048
|
+
return true
|
|
1049
|
+
}
|
|
1050
|
+
const ref14 = function validate(data) {
|
|
1051
|
+
validate.errors = null
|
|
1052
|
+
if (!(typeof data === 'object' && data && !Array.isArray(data))) {
|
|
1053
|
+
validate.errors = [{ keywordLocation: '#/type', instanceLocation: '#' }]
|
|
1054
|
+
return false
|
|
1055
|
+
}
|
|
1056
|
+
if (!('type' in data && hasOwn(data, 'type'))) {
|
|
1057
|
+
validate.errors = [
|
|
1058
|
+
{ keywordLocation: '#/required', instanceLocation: '#/type' },
|
|
1059
|
+
]
|
|
1060
|
+
return false
|
|
1061
|
+
}
|
|
1062
|
+
if (!('options' in data && hasOwn(data, 'options'))) {
|
|
1063
|
+
validate.errors = [
|
|
1064
|
+
{ keywordLocation: '#/required', instanceLocation: '#/options' },
|
|
1065
|
+
]
|
|
1066
|
+
return false
|
|
1067
|
+
}
|
|
1068
|
+
if (!(typeof data.type === 'string')) {
|
|
1069
|
+
validate.errors = [
|
|
1070
|
+
{
|
|
1071
|
+
keywordLocation: '#/properties/type/type',
|
|
1072
|
+
instanceLocation: '#/type',
|
|
1073
|
+
},
|
|
1074
|
+
]
|
|
1075
|
+
return false
|
|
1076
|
+
}
|
|
1077
|
+
if (data.type.length > 20 && stringLength(data.type) > 20) {
|
|
1078
|
+
validate.errors = [
|
|
1079
|
+
{
|
|
1080
|
+
keywordLocation: '#/properties/type/maxLength',
|
|
1081
|
+
instanceLocation: '#/type',
|
|
1082
|
+
},
|
|
1083
|
+
]
|
|
1084
|
+
return false
|
|
1085
|
+
}
|
|
1086
|
+
if (!format5.test(data.type)) {
|
|
1087
|
+
validate.errors = [
|
|
1088
|
+
{
|
|
1089
|
+
keywordLocation: '#/properties/type/format',
|
|
1090
|
+
instanceLocation: '#/type',
|
|
1091
|
+
},
|
|
1092
|
+
]
|
|
1093
|
+
return false
|
|
1094
|
+
}
|
|
1095
|
+
const err38 = validate.errors
|
|
1096
|
+
const res38 = ref15(data.options)
|
|
1097
|
+
const suberr38 = ref15.errors
|
|
1098
|
+
validate.errors = err38
|
|
1099
|
+
if (!res38) {
|
|
1100
|
+
validate.errors = [
|
|
1101
|
+
errorMerge(suberr38[0], '#/properties/options/$ref', '#/options'),
|
|
1102
|
+
]
|
|
1103
|
+
return false
|
|
1104
|
+
}
|
|
1105
|
+
for (const key7 of Object.keys(data)) {
|
|
1106
|
+
if (key7 !== 'type' && key7 !== 'options') {
|
|
1107
|
+
validate.errors = [
|
|
1108
|
+
{
|
|
1109
|
+
keywordLocation: '#/additionalProperties',
|
|
1110
|
+
instanceLocation: '#/' + pointerPart(key7),
|
|
1111
|
+
},
|
|
1112
|
+
]
|
|
1113
|
+
return false
|
|
1114
|
+
}
|
|
1115
|
+
}
|
|
1116
|
+
return true
|
|
1117
|
+
}
|
|
1118
|
+
const ref0 = function validate(data) {
|
|
1119
|
+
validate.errors = null
|
|
1120
|
+
if (!(typeof data === 'object' && data && !Array.isArray(data))) {
|
|
1121
|
+
validate.errors = [{ keywordLocation: '#/type', instanceLocation: '#' }]
|
|
1122
|
+
return false
|
|
1123
|
+
}
|
|
1124
|
+
if (!('jsonrpc' in data && hasOwn(data, 'jsonrpc'))) {
|
|
1125
|
+
validate.errors = [
|
|
1126
|
+
{ keywordLocation: '#/required', instanceLocation: '#/jsonrpc' },
|
|
1127
|
+
]
|
|
1128
|
+
return false
|
|
1129
|
+
}
|
|
1130
|
+
if (!('id' in data && hasOwn(data, 'id'))) {
|
|
1131
|
+
validate.errors = [
|
|
1132
|
+
{ keywordLocation: '#/required', instanceLocation: '#/id' },
|
|
1133
|
+
]
|
|
1134
|
+
return false
|
|
1135
|
+
}
|
|
1136
|
+
if (!('method' in data && hasOwn(data, 'method'))) {
|
|
1137
|
+
validate.errors = [
|
|
1138
|
+
{ keywordLocation: '#/required', instanceLocation: '#/method' },
|
|
1139
|
+
]
|
|
1140
|
+
return false
|
|
1141
|
+
}
|
|
1142
|
+
if (!(data.jsonrpc === '2.0')) {
|
|
1143
|
+
validate.errors = [
|
|
1144
|
+
{
|
|
1145
|
+
keywordLocation: '#/properties/jsonrpc/const',
|
|
1146
|
+
instanceLocation: '#/jsonrpc',
|
|
1147
|
+
},
|
|
1148
|
+
]
|
|
1149
|
+
return false
|
|
1150
|
+
}
|
|
1151
|
+
let passes0 = 0
|
|
1152
|
+
const sub0 = (() => {
|
|
1153
|
+
if (!(typeof data.id === 'string')) return false
|
|
1154
|
+
if (!format0.test(data.id)) return false
|
|
1155
|
+
return true
|
|
1156
|
+
})()
|
|
1157
|
+
if (sub0) passes0++
|
|
1158
|
+
const sub1 = (() => {
|
|
1159
|
+
if (!Number.isInteger(data.id)) return false
|
|
1160
|
+
return true
|
|
1161
|
+
})()
|
|
1162
|
+
if (sub1) passes0++
|
|
1163
|
+
if (passes0 !== 1) {
|
|
1164
|
+
validate.errors = [
|
|
1165
|
+
{
|
|
1166
|
+
keywordLocation: '#/properties/id/oneOf',
|
|
1167
|
+
instanceLocation: '#/id',
|
|
1168
|
+
},
|
|
1169
|
+
]
|
|
1170
|
+
return false
|
|
1171
|
+
}
|
|
1172
|
+
if (!(typeof data.method === 'string')) {
|
|
1173
|
+
validate.errors = [
|
|
1174
|
+
{
|
|
1175
|
+
keywordLocation: '#/properties/method/type',
|
|
1176
|
+
instanceLocation: '#/method',
|
|
1177
|
+
},
|
|
1178
|
+
]
|
|
1179
|
+
return false
|
|
1180
|
+
}
|
|
1181
|
+
if (!pattern0.test(data.method)) {
|
|
1182
|
+
validate.errors = [
|
|
1183
|
+
{
|
|
1184
|
+
keywordLocation: '#/properties/method/pattern',
|
|
1185
|
+
instanceLocation: '#/method',
|
|
1186
|
+
},
|
|
1187
|
+
]
|
|
1188
|
+
return false
|
|
1189
|
+
}
|
|
1190
|
+
switch (data.method) {
|
|
1191
|
+
case 'eth_accounts':
|
|
1192
|
+
if (!('params' in data && hasOwn(data, 'params'))) {
|
|
1193
|
+
validate.errors = [
|
|
1194
|
+
{
|
|
1195
|
+
keywordLocation: '#/oneOf/0/required',
|
|
1196
|
+
instanceLocation: '#/params',
|
|
1197
|
+
},
|
|
1198
|
+
]
|
|
1199
|
+
return false
|
|
1200
|
+
}
|
|
1201
|
+
if (!(Array.isArray(data.params) && data.params.length === 0)) {
|
|
1202
|
+
validate.errors = [
|
|
1203
|
+
{
|
|
1204
|
+
keywordLocation: '#/oneOf/0/properties/params/const',
|
|
1205
|
+
instanceLocation: '#/params',
|
|
1206
|
+
},
|
|
1207
|
+
]
|
|
1208
|
+
return false
|
|
1209
|
+
}
|
|
1210
|
+
break
|
|
1211
|
+
case 'eth_blockNumber':
|
|
1212
|
+
if (!('params' in data && hasOwn(data, 'params'))) {
|
|
1213
|
+
validate.errors = [
|
|
1214
|
+
{
|
|
1215
|
+
keywordLocation: '#/oneOf/1/required',
|
|
1216
|
+
instanceLocation: '#/params',
|
|
1217
|
+
},
|
|
1218
|
+
]
|
|
1219
|
+
return false
|
|
1220
|
+
}
|
|
1221
|
+
if (!(Array.isArray(data.params) && data.params.length === 0)) {
|
|
1222
|
+
validate.errors = [
|
|
1223
|
+
{
|
|
1224
|
+
keywordLocation: '#/oneOf/1/properties/params/const',
|
|
1225
|
+
instanceLocation: '#/params',
|
|
1226
|
+
},
|
|
1227
|
+
]
|
|
1228
|
+
return false
|
|
1229
|
+
}
|
|
1230
|
+
break
|
|
1231
|
+
case 'eth_chainId':
|
|
1232
|
+
if (!('params' in data && hasOwn(data, 'params'))) {
|
|
1233
|
+
validate.errors = [
|
|
1234
|
+
{
|
|
1235
|
+
keywordLocation: '#/oneOf/2/required',
|
|
1236
|
+
instanceLocation: '#/params',
|
|
1237
|
+
},
|
|
1238
|
+
]
|
|
1239
|
+
return false
|
|
1240
|
+
}
|
|
1241
|
+
if (!(Array.isArray(data.params) && data.params.length === 0)) {
|
|
1242
|
+
validate.errors = [
|
|
1243
|
+
{
|
|
1244
|
+
keywordLocation: '#/oneOf/2/properties/params/const',
|
|
1245
|
+
instanceLocation: '#/params',
|
|
1246
|
+
},
|
|
1247
|
+
]
|
|
1248
|
+
return false
|
|
1249
|
+
}
|
|
1250
|
+
break
|
|
1251
|
+
case 'eth_call':
|
|
1252
|
+
if (!('params' in data && hasOwn(data, 'params'))) {
|
|
1253
|
+
validate.errors = [
|
|
1254
|
+
{
|
|
1255
|
+
keywordLocation: '#/oneOf/3/required',
|
|
1256
|
+
instanceLocation: '#/params',
|
|
1257
|
+
},
|
|
1258
|
+
]
|
|
1259
|
+
return false
|
|
1260
|
+
}
|
|
1261
|
+
const err0 = validate.errors
|
|
1262
|
+
const res0 = ref1(data.params)
|
|
1263
|
+
const suberr0 = ref1.errors
|
|
1264
|
+
validate.errors = err0
|
|
1265
|
+
if (!res0) {
|
|
1266
|
+
validate.errors = [
|
|
1267
|
+
errorMerge(
|
|
1268
|
+
suberr0[0],
|
|
1269
|
+
'#/oneOf/3/properties/params/$ref',
|
|
1270
|
+
'#/params',
|
|
1271
|
+
),
|
|
1272
|
+
]
|
|
1273
|
+
return false
|
|
1274
|
+
}
|
|
1275
|
+
break
|
|
1276
|
+
case 'eth_coinbase':
|
|
1277
|
+
if (!('params' in data && hasOwn(data, 'params'))) {
|
|
1278
|
+
validate.errors = [
|
|
1279
|
+
{
|
|
1280
|
+
keywordLocation: '#/oneOf/4/required',
|
|
1281
|
+
instanceLocation: '#/params',
|
|
1282
|
+
},
|
|
1283
|
+
]
|
|
1284
|
+
return false
|
|
1285
|
+
}
|
|
1286
|
+
if (!(Array.isArray(data.params) && data.params.length === 0)) {
|
|
1287
|
+
validate.errors = [
|
|
1288
|
+
{
|
|
1289
|
+
keywordLocation: '#/oneOf/4/properties/params/const',
|
|
1290
|
+
instanceLocation: '#/params',
|
|
1291
|
+
},
|
|
1292
|
+
]
|
|
1293
|
+
return false
|
|
1294
|
+
}
|
|
1295
|
+
break
|
|
1296
|
+
case 'eth_createAccessList':
|
|
1297
|
+
if (!('params' in data && hasOwn(data, 'params'))) {
|
|
1298
|
+
validate.errors = [
|
|
1299
|
+
{
|
|
1300
|
+
keywordLocation: '#/oneOf/5/required',
|
|
1301
|
+
instanceLocation: '#/params',
|
|
1302
|
+
},
|
|
1303
|
+
]
|
|
1304
|
+
return false
|
|
1305
|
+
}
|
|
1306
|
+
const err1 = validate.errors
|
|
1307
|
+
const res1 = ref1(data.params)
|
|
1308
|
+
const suberr1 = ref1.errors
|
|
1309
|
+
validate.errors = err1
|
|
1310
|
+
if (!res1) {
|
|
1311
|
+
validate.errors = [
|
|
1312
|
+
errorMerge(
|
|
1313
|
+
suberr1[0],
|
|
1314
|
+
'#/oneOf/5/properties/params/$ref',
|
|
1315
|
+
'#/params',
|
|
1316
|
+
),
|
|
1317
|
+
]
|
|
1318
|
+
return false
|
|
1319
|
+
}
|
|
1320
|
+
break
|
|
1321
|
+
case 'eth_estimateGas':
|
|
1322
|
+
if (!('params' in data && hasOwn(data, 'params'))) {
|
|
1323
|
+
validate.errors = [
|
|
1324
|
+
{
|
|
1325
|
+
keywordLocation: '#/oneOf/6/required',
|
|
1326
|
+
instanceLocation: '#/params',
|
|
1327
|
+
},
|
|
1328
|
+
]
|
|
1329
|
+
return false
|
|
1330
|
+
}
|
|
1331
|
+
const err2 = validate.errors
|
|
1332
|
+
const res2 = ref1(data.params)
|
|
1333
|
+
const suberr2 = ref1.errors
|
|
1334
|
+
validate.errors = err2
|
|
1335
|
+
if (!res2) {
|
|
1336
|
+
validate.errors = [
|
|
1337
|
+
errorMerge(
|
|
1338
|
+
suberr2[0],
|
|
1339
|
+
'#/oneOf/6/properties/params/$ref',
|
|
1340
|
+
'#/params',
|
|
1341
|
+
),
|
|
1342
|
+
]
|
|
1343
|
+
return false
|
|
1344
|
+
}
|
|
1345
|
+
break
|
|
1346
|
+
case 'eth_feeHistory':
|
|
1347
|
+
if (!('params' in data && hasOwn(data, 'params'))) {
|
|
1348
|
+
validate.errors = [
|
|
1349
|
+
{
|
|
1350
|
+
keywordLocation: '#/oneOf/7/required',
|
|
1351
|
+
instanceLocation: '#/params',
|
|
1352
|
+
},
|
|
1353
|
+
]
|
|
1354
|
+
return false
|
|
1355
|
+
}
|
|
1356
|
+
const err3 = validate.errors
|
|
1357
|
+
const res3 = ref1(data.params)
|
|
1358
|
+
const suberr3 = ref1.errors
|
|
1359
|
+
validate.errors = err3
|
|
1360
|
+
if (!res3) {
|
|
1361
|
+
validate.errors = [
|
|
1362
|
+
errorMerge(
|
|
1363
|
+
suberr3[0],
|
|
1364
|
+
'#/oneOf/7/properties/params/$ref',
|
|
1365
|
+
'#/params',
|
|
1366
|
+
),
|
|
1367
|
+
]
|
|
1368
|
+
return false
|
|
1369
|
+
}
|
|
1370
|
+
break
|
|
1371
|
+
case 'eth_gasPrice':
|
|
1372
|
+
if (!('params' in data && hasOwn(data, 'params'))) {
|
|
1373
|
+
validate.errors = [
|
|
1374
|
+
{
|
|
1375
|
+
keywordLocation: '#/oneOf/8/required',
|
|
1376
|
+
instanceLocation: '#/params',
|
|
1377
|
+
},
|
|
1378
|
+
]
|
|
1379
|
+
return false
|
|
1380
|
+
}
|
|
1381
|
+
if (!(Array.isArray(data.params) && data.params.length === 0)) {
|
|
1382
|
+
validate.errors = [
|
|
1383
|
+
{
|
|
1384
|
+
keywordLocation: '#/oneOf/8/properties/params/const',
|
|
1385
|
+
instanceLocation: '#/params',
|
|
1386
|
+
},
|
|
1387
|
+
]
|
|
1388
|
+
return false
|
|
1389
|
+
}
|
|
1390
|
+
break
|
|
1391
|
+
case 'eth_getBalance':
|
|
1392
|
+
if (!('params' in data && hasOwn(data, 'params'))) {
|
|
1393
|
+
validate.errors = [
|
|
1394
|
+
{
|
|
1395
|
+
keywordLocation: '#/oneOf/9/required',
|
|
1396
|
+
instanceLocation: '#/params',
|
|
1397
|
+
},
|
|
1398
|
+
]
|
|
1399
|
+
return false
|
|
1400
|
+
}
|
|
1401
|
+
const err4 = validate.errors
|
|
1402
|
+
const res4 = ref1(data.params)
|
|
1403
|
+
const suberr4 = ref1.errors
|
|
1404
|
+
validate.errors = err4
|
|
1405
|
+
if (!res4) {
|
|
1406
|
+
validate.errors = [
|
|
1407
|
+
errorMerge(
|
|
1408
|
+
suberr4[0],
|
|
1409
|
+
'#/oneOf/9/properties/params/$ref',
|
|
1410
|
+
'#/params',
|
|
1411
|
+
),
|
|
1412
|
+
]
|
|
1413
|
+
return false
|
|
1414
|
+
}
|
|
1415
|
+
break
|
|
1416
|
+
case 'eth_getBlockByHash':
|
|
1417
|
+
if (!('params' in data && hasOwn(data, 'params'))) {
|
|
1418
|
+
validate.errors = [
|
|
1419
|
+
{
|
|
1420
|
+
keywordLocation: '#/oneOf/10/required',
|
|
1421
|
+
instanceLocation: '#/params',
|
|
1422
|
+
},
|
|
1423
|
+
]
|
|
1424
|
+
return false
|
|
1425
|
+
}
|
|
1426
|
+
const err5 = validate.errors
|
|
1427
|
+
const res5 = ref1(data.params)
|
|
1428
|
+
const suberr5 = ref1.errors
|
|
1429
|
+
validate.errors = err5
|
|
1430
|
+
if (!res5) {
|
|
1431
|
+
validate.errors = [
|
|
1432
|
+
errorMerge(
|
|
1433
|
+
suberr5[0],
|
|
1434
|
+
'#/oneOf/10/properties/params/$ref',
|
|
1435
|
+
'#/params',
|
|
1436
|
+
),
|
|
1437
|
+
]
|
|
1438
|
+
return false
|
|
1439
|
+
}
|
|
1440
|
+
break
|
|
1441
|
+
case 'eth_getBlockByNumber':
|
|
1442
|
+
if (!('params' in data && hasOwn(data, 'params'))) {
|
|
1443
|
+
validate.errors = [
|
|
1444
|
+
{
|
|
1445
|
+
keywordLocation: '#/oneOf/11/required',
|
|
1446
|
+
instanceLocation: '#/params',
|
|
1447
|
+
},
|
|
1448
|
+
]
|
|
1449
|
+
return false
|
|
1450
|
+
}
|
|
1451
|
+
const err6 = validate.errors
|
|
1452
|
+
const res6 = ref1(data.params)
|
|
1453
|
+
const suberr6 = ref1.errors
|
|
1454
|
+
validate.errors = err6
|
|
1455
|
+
if (!res6) {
|
|
1456
|
+
validate.errors = [
|
|
1457
|
+
errorMerge(
|
|
1458
|
+
suberr6[0],
|
|
1459
|
+
'#/oneOf/11/properties/params/$ref',
|
|
1460
|
+
'#/params',
|
|
1461
|
+
),
|
|
1462
|
+
]
|
|
1463
|
+
return false
|
|
1464
|
+
}
|
|
1465
|
+
break
|
|
1466
|
+
case 'eth_getBlockTransactionCountByHash':
|
|
1467
|
+
if (!('params' in data && hasOwn(data, 'params'))) {
|
|
1468
|
+
validate.errors = [
|
|
1469
|
+
{
|
|
1470
|
+
keywordLocation: '#/oneOf/12/required',
|
|
1471
|
+
instanceLocation: '#/params',
|
|
1472
|
+
},
|
|
1473
|
+
]
|
|
1474
|
+
return false
|
|
1475
|
+
}
|
|
1476
|
+
const err7 = validate.errors
|
|
1477
|
+
const res7 = ref1(data.params)
|
|
1478
|
+
const suberr7 = ref1.errors
|
|
1479
|
+
validate.errors = err7
|
|
1480
|
+
if (!res7) {
|
|
1481
|
+
validate.errors = [
|
|
1482
|
+
errorMerge(
|
|
1483
|
+
suberr7[0],
|
|
1484
|
+
'#/oneOf/12/properties/params/$ref',
|
|
1485
|
+
'#/params',
|
|
1486
|
+
),
|
|
1487
|
+
]
|
|
1488
|
+
return false
|
|
1489
|
+
}
|
|
1490
|
+
break
|
|
1491
|
+
case 'eth_getBlockTransactionCountByNumber':
|
|
1492
|
+
if (!('params' in data && hasOwn(data, 'params'))) {
|
|
1493
|
+
validate.errors = [
|
|
1494
|
+
{
|
|
1495
|
+
keywordLocation: '#/oneOf/13/required',
|
|
1496
|
+
instanceLocation: '#/params',
|
|
1497
|
+
},
|
|
1498
|
+
]
|
|
1499
|
+
return false
|
|
1500
|
+
}
|
|
1501
|
+
const err8 = validate.errors
|
|
1502
|
+
const res8 = ref1(data.params)
|
|
1503
|
+
const suberr8 = ref1.errors
|
|
1504
|
+
validate.errors = err8
|
|
1505
|
+
if (!res8) {
|
|
1506
|
+
validate.errors = [
|
|
1507
|
+
errorMerge(
|
|
1508
|
+
suberr8[0],
|
|
1509
|
+
'#/oneOf/13/properties/params/$ref',
|
|
1510
|
+
'#/params',
|
|
1511
|
+
),
|
|
1512
|
+
]
|
|
1513
|
+
return false
|
|
1514
|
+
}
|
|
1515
|
+
break
|
|
1516
|
+
case 'eth_getCode':
|
|
1517
|
+
if (!('params' in data && hasOwn(data, 'params'))) {
|
|
1518
|
+
validate.errors = [
|
|
1519
|
+
{
|
|
1520
|
+
keywordLocation: '#/oneOf/14/required',
|
|
1521
|
+
instanceLocation: '#/params',
|
|
1522
|
+
},
|
|
1523
|
+
]
|
|
1524
|
+
return false
|
|
1525
|
+
}
|
|
1526
|
+
const err9 = validate.errors
|
|
1527
|
+
const res9 = ref1(data.params)
|
|
1528
|
+
const suberr9 = ref1.errors
|
|
1529
|
+
validate.errors = err9
|
|
1530
|
+
if (!res9) {
|
|
1531
|
+
validate.errors = [
|
|
1532
|
+
errorMerge(
|
|
1533
|
+
suberr9[0],
|
|
1534
|
+
'#/oneOf/14/properties/params/$ref',
|
|
1535
|
+
'#/params',
|
|
1536
|
+
),
|
|
1537
|
+
]
|
|
1538
|
+
return false
|
|
1539
|
+
}
|
|
1540
|
+
break
|
|
1541
|
+
case 'eth_getCompilers':
|
|
1542
|
+
if (!('params' in data && hasOwn(data, 'params'))) {
|
|
1543
|
+
validate.errors = [
|
|
1544
|
+
{
|
|
1545
|
+
keywordLocation: '#/oneOf/15/required',
|
|
1546
|
+
instanceLocation: '#/params',
|
|
1547
|
+
},
|
|
1548
|
+
]
|
|
1549
|
+
return false
|
|
1550
|
+
}
|
|
1551
|
+
if (!(Array.isArray(data.params) && data.params.length === 0)) {
|
|
1552
|
+
validate.errors = [
|
|
1553
|
+
{
|
|
1554
|
+
keywordLocation: '#/oneOf/15/properties/params/const',
|
|
1555
|
+
instanceLocation: '#/params',
|
|
1556
|
+
},
|
|
1557
|
+
]
|
|
1558
|
+
return false
|
|
1559
|
+
}
|
|
1560
|
+
break
|
|
1561
|
+
case 'eth_getLogs':
|
|
1562
|
+
if (!('params' in data && hasOwn(data, 'params'))) {
|
|
1563
|
+
validate.errors = [
|
|
1564
|
+
{
|
|
1565
|
+
keywordLocation: '#/oneOf/16/required',
|
|
1566
|
+
instanceLocation: '#/params',
|
|
1567
|
+
},
|
|
1568
|
+
]
|
|
1569
|
+
return false
|
|
1570
|
+
}
|
|
1571
|
+
const err10 = validate.errors
|
|
1572
|
+
const res10 = ref1(data.params)
|
|
1573
|
+
const suberr10 = ref1.errors
|
|
1574
|
+
validate.errors = err10
|
|
1575
|
+
if (!res10) {
|
|
1576
|
+
validate.errors = [
|
|
1577
|
+
errorMerge(
|
|
1578
|
+
suberr10[0],
|
|
1579
|
+
'#/oneOf/16/properties/params/$ref',
|
|
1580
|
+
'#/params',
|
|
1581
|
+
),
|
|
1582
|
+
]
|
|
1583
|
+
return false
|
|
1584
|
+
}
|
|
1585
|
+
break
|
|
1586
|
+
case 'eth_getProof':
|
|
1587
|
+
if (!('params' in data && hasOwn(data, 'params'))) {
|
|
1588
|
+
validate.errors = [
|
|
1589
|
+
{
|
|
1590
|
+
keywordLocation: '#/oneOf/17/required',
|
|
1591
|
+
instanceLocation: '#/params',
|
|
1592
|
+
},
|
|
1593
|
+
]
|
|
1594
|
+
return false
|
|
1595
|
+
}
|
|
1596
|
+
const err11 = validate.errors
|
|
1597
|
+
const res11 = ref1(data.params)
|
|
1598
|
+
const suberr11 = ref1.errors
|
|
1599
|
+
validate.errors = err11
|
|
1600
|
+
if (!res11) {
|
|
1601
|
+
validate.errors = [
|
|
1602
|
+
errorMerge(
|
|
1603
|
+
suberr11[0],
|
|
1604
|
+
'#/oneOf/17/properties/params/$ref',
|
|
1605
|
+
'#/params',
|
|
1606
|
+
),
|
|
1607
|
+
]
|
|
1608
|
+
return false
|
|
1609
|
+
}
|
|
1610
|
+
break
|
|
1611
|
+
case 'eth_getStorageAt':
|
|
1612
|
+
if (!('params' in data && hasOwn(data, 'params'))) {
|
|
1613
|
+
validate.errors = [
|
|
1614
|
+
{
|
|
1615
|
+
keywordLocation: '#/oneOf/18/required',
|
|
1616
|
+
instanceLocation: '#/params',
|
|
1617
|
+
},
|
|
1618
|
+
]
|
|
1619
|
+
return false
|
|
1620
|
+
}
|
|
1621
|
+
const err12 = validate.errors
|
|
1622
|
+
const res12 = ref1(data.params)
|
|
1623
|
+
const suberr12 = ref1.errors
|
|
1624
|
+
validate.errors = err12
|
|
1625
|
+
if (!res12) {
|
|
1626
|
+
validate.errors = [
|
|
1627
|
+
errorMerge(
|
|
1628
|
+
suberr12[0],
|
|
1629
|
+
'#/oneOf/18/properties/params/$ref',
|
|
1630
|
+
'#/params',
|
|
1631
|
+
),
|
|
1632
|
+
]
|
|
1633
|
+
return false
|
|
1634
|
+
}
|
|
1635
|
+
break
|
|
1636
|
+
case 'eth_getTransactionByBlockHashAndIndex':
|
|
1637
|
+
if (!('params' in data && hasOwn(data, 'params'))) {
|
|
1638
|
+
validate.errors = [
|
|
1639
|
+
{
|
|
1640
|
+
keywordLocation: '#/oneOf/19/required',
|
|
1641
|
+
instanceLocation: '#/params',
|
|
1642
|
+
},
|
|
1643
|
+
]
|
|
1644
|
+
return false
|
|
1645
|
+
}
|
|
1646
|
+
const err13 = validate.errors
|
|
1647
|
+
const res13 = ref1(data.params)
|
|
1648
|
+
const suberr13 = ref1.errors
|
|
1649
|
+
validate.errors = err13
|
|
1650
|
+
if (!res13) {
|
|
1651
|
+
validate.errors = [
|
|
1652
|
+
errorMerge(
|
|
1653
|
+
suberr13[0],
|
|
1654
|
+
'#/oneOf/19/properties/params/$ref',
|
|
1655
|
+
'#/params',
|
|
1656
|
+
),
|
|
1657
|
+
]
|
|
1658
|
+
return false
|
|
1659
|
+
}
|
|
1660
|
+
break
|
|
1661
|
+
case 'eth_getTransactionByBlockNumberAndIndex':
|
|
1662
|
+
if (!('params' in data && hasOwn(data, 'params'))) {
|
|
1663
|
+
validate.errors = [
|
|
1664
|
+
{
|
|
1665
|
+
keywordLocation: '#/oneOf/20/required',
|
|
1666
|
+
instanceLocation: '#/params',
|
|
1667
|
+
},
|
|
1668
|
+
]
|
|
1669
|
+
return false
|
|
1670
|
+
}
|
|
1671
|
+
const err14 = validate.errors
|
|
1672
|
+
const res14 = ref1(data.params)
|
|
1673
|
+
const suberr14 = ref1.errors
|
|
1674
|
+
validate.errors = err14
|
|
1675
|
+
if (!res14) {
|
|
1676
|
+
validate.errors = [
|
|
1677
|
+
errorMerge(
|
|
1678
|
+
suberr14[0],
|
|
1679
|
+
'#/oneOf/20/properties/params/$ref',
|
|
1680
|
+
'#/params',
|
|
1681
|
+
),
|
|
1682
|
+
]
|
|
1683
|
+
return false
|
|
1684
|
+
}
|
|
1685
|
+
break
|
|
1686
|
+
case 'eth_getTransactionByHash':
|
|
1687
|
+
if (!('params' in data && hasOwn(data, 'params'))) {
|
|
1688
|
+
validate.errors = [
|
|
1689
|
+
{
|
|
1690
|
+
keywordLocation: '#/oneOf/21/required',
|
|
1691
|
+
instanceLocation: '#/params',
|
|
1692
|
+
},
|
|
1693
|
+
]
|
|
1694
|
+
return false
|
|
1695
|
+
}
|
|
1696
|
+
const err15 = validate.errors
|
|
1697
|
+
const res15 = ref1(data.params)
|
|
1698
|
+
const suberr15 = ref1.errors
|
|
1699
|
+
validate.errors = err15
|
|
1700
|
+
if (!res15) {
|
|
1701
|
+
validate.errors = [
|
|
1702
|
+
errorMerge(
|
|
1703
|
+
suberr15[0],
|
|
1704
|
+
'#/oneOf/21/properties/params/$ref',
|
|
1705
|
+
'#/params',
|
|
1706
|
+
),
|
|
1707
|
+
]
|
|
1708
|
+
return false
|
|
1709
|
+
}
|
|
1710
|
+
break
|
|
1711
|
+
case 'eth_getTransactionCount':
|
|
1712
|
+
if (!('params' in data && hasOwn(data, 'params'))) {
|
|
1713
|
+
validate.errors = [
|
|
1714
|
+
{
|
|
1715
|
+
keywordLocation: '#/oneOf/22/required',
|
|
1716
|
+
instanceLocation: '#/params',
|
|
1717
|
+
},
|
|
1718
|
+
]
|
|
1719
|
+
return false
|
|
1720
|
+
}
|
|
1721
|
+
const err16 = validate.errors
|
|
1722
|
+
const res16 = ref1(data.params)
|
|
1723
|
+
const suberr16 = ref1.errors
|
|
1724
|
+
validate.errors = err16
|
|
1725
|
+
if (!res16) {
|
|
1726
|
+
validate.errors = [
|
|
1727
|
+
errorMerge(
|
|
1728
|
+
suberr16[0],
|
|
1729
|
+
'#/oneOf/22/properties/params/$ref',
|
|
1730
|
+
'#/params',
|
|
1731
|
+
),
|
|
1732
|
+
]
|
|
1733
|
+
return false
|
|
1734
|
+
}
|
|
1735
|
+
break
|
|
1736
|
+
case 'eth_getTransactionReceipt':
|
|
1737
|
+
if (!('params' in data && hasOwn(data, 'params'))) {
|
|
1738
|
+
validate.errors = [
|
|
1739
|
+
{
|
|
1740
|
+
keywordLocation: '#/oneOf/23/required',
|
|
1741
|
+
instanceLocation: '#/params',
|
|
1742
|
+
},
|
|
1743
|
+
]
|
|
1744
|
+
return false
|
|
1745
|
+
}
|
|
1746
|
+
const err17 = validate.errors
|
|
1747
|
+
const res17 = ref1(data.params)
|
|
1748
|
+
const suberr17 = ref1.errors
|
|
1749
|
+
validate.errors = err17
|
|
1750
|
+
if (!res17) {
|
|
1751
|
+
validate.errors = [
|
|
1752
|
+
errorMerge(
|
|
1753
|
+
suberr17[0],
|
|
1754
|
+
'#/oneOf/23/properties/params/$ref',
|
|
1755
|
+
'#/params',
|
|
1756
|
+
),
|
|
1757
|
+
]
|
|
1758
|
+
return false
|
|
1759
|
+
}
|
|
1760
|
+
break
|
|
1761
|
+
case 'eth_getUncleCountByBlockHash':
|
|
1762
|
+
if (!('params' in data && hasOwn(data, 'params'))) {
|
|
1763
|
+
validate.errors = [
|
|
1764
|
+
{
|
|
1765
|
+
keywordLocation: '#/oneOf/24/required',
|
|
1766
|
+
instanceLocation: '#/params',
|
|
1767
|
+
},
|
|
1768
|
+
]
|
|
1769
|
+
return false
|
|
1770
|
+
}
|
|
1771
|
+
const err18 = validate.errors
|
|
1772
|
+
const res18 = ref1(data.params)
|
|
1773
|
+
const suberr18 = ref1.errors
|
|
1774
|
+
validate.errors = err18
|
|
1775
|
+
if (!res18) {
|
|
1776
|
+
validate.errors = [
|
|
1777
|
+
errorMerge(
|
|
1778
|
+
suberr18[0],
|
|
1779
|
+
'#/oneOf/24/properties/params/$ref',
|
|
1780
|
+
'#/params',
|
|
1781
|
+
),
|
|
1782
|
+
]
|
|
1783
|
+
return false
|
|
1784
|
+
}
|
|
1785
|
+
break
|
|
1786
|
+
case 'eth_getUncleByBlockHashAndIndex':
|
|
1787
|
+
if (!('params' in data && hasOwn(data, 'params'))) {
|
|
1788
|
+
validate.errors = [
|
|
1789
|
+
{
|
|
1790
|
+
keywordLocation: '#/oneOf/25/required',
|
|
1791
|
+
instanceLocation: '#/params',
|
|
1792
|
+
},
|
|
1793
|
+
]
|
|
1794
|
+
return false
|
|
1795
|
+
}
|
|
1796
|
+
const err19 = validate.errors
|
|
1797
|
+
const res19 = ref1(data.params)
|
|
1798
|
+
const suberr19 = ref1.errors
|
|
1799
|
+
validate.errors = err19
|
|
1800
|
+
if (!res19) {
|
|
1801
|
+
validate.errors = [
|
|
1802
|
+
errorMerge(
|
|
1803
|
+
suberr19[0],
|
|
1804
|
+
'#/oneOf/25/properties/params/$ref',
|
|
1805
|
+
'#/params',
|
|
1806
|
+
),
|
|
1807
|
+
]
|
|
1808
|
+
return false
|
|
1809
|
+
}
|
|
1810
|
+
break
|
|
1811
|
+
case 'eth_getUncleByBlockNumberAndIndex':
|
|
1812
|
+
if (!('params' in data && hasOwn(data, 'params'))) {
|
|
1813
|
+
validate.errors = [
|
|
1814
|
+
{
|
|
1815
|
+
keywordLocation: '#/oneOf/26/required',
|
|
1816
|
+
instanceLocation: '#/params',
|
|
1817
|
+
},
|
|
1818
|
+
]
|
|
1819
|
+
return false
|
|
1820
|
+
}
|
|
1821
|
+
const err20 = validate.errors
|
|
1822
|
+
const res20 = ref1(data.params)
|
|
1823
|
+
const suberr20 = ref1.errors
|
|
1824
|
+
validate.errors = err20
|
|
1825
|
+
if (!res20) {
|
|
1826
|
+
validate.errors = [
|
|
1827
|
+
errorMerge(
|
|
1828
|
+
suberr20[0],
|
|
1829
|
+
'#/oneOf/26/properties/params/$ref',
|
|
1830
|
+
'#/params',
|
|
1831
|
+
),
|
|
1832
|
+
]
|
|
1833
|
+
return false
|
|
1834
|
+
}
|
|
1835
|
+
break
|
|
1836
|
+
case 'eth_getWork':
|
|
1837
|
+
if (!('params' in data && hasOwn(data, 'params'))) {
|
|
1838
|
+
validate.errors = [
|
|
1839
|
+
{
|
|
1840
|
+
keywordLocation: '#/oneOf/27/required',
|
|
1841
|
+
instanceLocation: '#/params',
|
|
1842
|
+
},
|
|
1843
|
+
]
|
|
1844
|
+
return false
|
|
1845
|
+
}
|
|
1846
|
+
if (!(Array.isArray(data.params) && data.params.length === 0)) {
|
|
1847
|
+
validate.errors = [
|
|
1848
|
+
{
|
|
1849
|
+
keywordLocation: '#/oneOf/27/properties/params/const',
|
|
1850
|
+
instanceLocation: '#/params',
|
|
1851
|
+
},
|
|
1852
|
+
]
|
|
1853
|
+
return false
|
|
1854
|
+
}
|
|
1855
|
+
break
|
|
1856
|
+
case 'eth_hashrate':
|
|
1857
|
+
if (!('params' in data && hasOwn(data, 'params'))) {
|
|
1858
|
+
validate.errors = [
|
|
1859
|
+
{
|
|
1860
|
+
keywordLocation: '#/oneOf/28/required',
|
|
1861
|
+
instanceLocation: '#/params',
|
|
1862
|
+
},
|
|
1863
|
+
]
|
|
1864
|
+
return false
|
|
1865
|
+
}
|
|
1866
|
+
if (!(Array.isArray(data.params) && data.params.length === 0)) {
|
|
1867
|
+
validate.errors = [
|
|
1868
|
+
{
|
|
1869
|
+
keywordLocation: '#/oneOf/28/properties/params/const',
|
|
1870
|
+
instanceLocation: '#/params',
|
|
1871
|
+
},
|
|
1872
|
+
]
|
|
1873
|
+
return false
|
|
1874
|
+
}
|
|
1875
|
+
break
|
|
1876
|
+
case 'eth_pendingTransactions':
|
|
1877
|
+
if (!('params' in data && hasOwn(data, 'params'))) {
|
|
1878
|
+
validate.errors = [
|
|
1879
|
+
{
|
|
1880
|
+
keywordLocation: '#/oneOf/29/required',
|
|
1881
|
+
instanceLocation: '#/params',
|
|
1882
|
+
},
|
|
1883
|
+
]
|
|
1884
|
+
return false
|
|
1885
|
+
}
|
|
1886
|
+
if (!(Array.isArray(data.params) && data.params.length === 0)) {
|
|
1887
|
+
validate.errors = [
|
|
1888
|
+
{
|
|
1889
|
+
keywordLocation: '#/oneOf/29/properties/params/const',
|
|
1890
|
+
instanceLocation: '#/params',
|
|
1891
|
+
},
|
|
1892
|
+
]
|
|
1893
|
+
return false
|
|
1894
|
+
}
|
|
1895
|
+
break
|
|
1896
|
+
case 'eth_requestAccounts':
|
|
1897
|
+
if (!('params' in data && hasOwn(data, 'params'))) {
|
|
1898
|
+
validate.errors = [
|
|
1899
|
+
{
|
|
1900
|
+
keywordLocation: '#/oneOf/30/required',
|
|
1901
|
+
instanceLocation: '#/params',
|
|
1902
|
+
},
|
|
1903
|
+
]
|
|
1904
|
+
return false
|
|
1905
|
+
}
|
|
1906
|
+
if (!(Array.isArray(data.params) && data.params.length === 0)) {
|
|
1907
|
+
validate.errors = [
|
|
1908
|
+
{
|
|
1909
|
+
keywordLocation: '#/oneOf/30/properties/params/const',
|
|
1910
|
+
instanceLocation: '#/params',
|
|
1911
|
+
},
|
|
1912
|
+
]
|
|
1913
|
+
return false
|
|
1914
|
+
}
|
|
1915
|
+
break
|
|
1916
|
+
case 'eth_sendRawTransaction':
|
|
1917
|
+
if (!('params' in data && hasOwn(data, 'params'))) {
|
|
1918
|
+
validate.errors = [
|
|
1919
|
+
{
|
|
1920
|
+
keywordLocation: '#/oneOf/31/required',
|
|
1921
|
+
instanceLocation: '#/params',
|
|
1922
|
+
},
|
|
1923
|
+
]
|
|
1924
|
+
return false
|
|
1925
|
+
}
|
|
1926
|
+
const err21 = validate.errors
|
|
1927
|
+
const res21 = ref2(data.params)
|
|
1928
|
+
const suberr21 = ref2.errors
|
|
1929
|
+
validate.errors = err21
|
|
1930
|
+
if (!res21) {
|
|
1931
|
+
validate.errors = [
|
|
1932
|
+
errorMerge(
|
|
1933
|
+
suberr21[0],
|
|
1934
|
+
'#/oneOf/31/properties/params/$ref',
|
|
1935
|
+
'#/params',
|
|
1936
|
+
),
|
|
1937
|
+
]
|
|
1938
|
+
return false
|
|
1939
|
+
}
|
|
1940
|
+
break
|
|
1941
|
+
case 'eth_sendTransaction':
|
|
1942
|
+
if (!('params' in data && hasOwn(data, 'params'))) {
|
|
1943
|
+
validate.errors = [
|
|
1944
|
+
{
|
|
1945
|
+
keywordLocation: '#/oneOf/32/required',
|
|
1946
|
+
instanceLocation: '#/params',
|
|
1947
|
+
},
|
|
1948
|
+
]
|
|
1949
|
+
return false
|
|
1950
|
+
}
|
|
1951
|
+
const err23 = validate.errors
|
|
1952
|
+
const res23 = ref3(data.params)
|
|
1953
|
+
const suberr23 = ref3.errors
|
|
1954
|
+
validate.errors = err23
|
|
1955
|
+
if (!res23) {
|
|
1956
|
+
validate.errors = [
|
|
1957
|
+
errorMerge(
|
|
1958
|
+
suberr23[0],
|
|
1959
|
+
'#/oneOf/32/properties/params/$ref',
|
|
1960
|
+
'#/params',
|
|
1961
|
+
),
|
|
1962
|
+
]
|
|
1963
|
+
return false
|
|
1964
|
+
}
|
|
1965
|
+
break
|
|
1966
|
+
case 'eth_sign':
|
|
1967
|
+
if (!('params' in data && hasOwn(data, 'params'))) {
|
|
1968
|
+
validate.errors = [
|
|
1969
|
+
{
|
|
1970
|
+
keywordLocation: '#/oneOf/33/required',
|
|
1971
|
+
instanceLocation: '#/params',
|
|
1972
|
+
},
|
|
1973
|
+
]
|
|
1974
|
+
return false
|
|
1975
|
+
}
|
|
1976
|
+
const err24 = validate.errors
|
|
1977
|
+
const res24 = ref5(data.params)
|
|
1978
|
+
const suberr24 = ref5.errors
|
|
1979
|
+
validate.errors = err24
|
|
1980
|
+
if (!res24) {
|
|
1981
|
+
validate.errors = [
|
|
1982
|
+
errorMerge(
|
|
1983
|
+
suberr24[0],
|
|
1984
|
+
'#/oneOf/33/properties/params/$ref',
|
|
1985
|
+
'#/params',
|
|
1986
|
+
),
|
|
1987
|
+
]
|
|
1988
|
+
return false
|
|
1989
|
+
}
|
|
1990
|
+
break
|
|
1991
|
+
case 'eth_signTransaction':
|
|
1992
|
+
if (!('params' in data && hasOwn(data, 'params'))) {
|
|
1993
|
+
validate.errors = [
|
|
1994
|
+
{
|
|
1995
|
+
keywordLocation: '#/oneOf/34/required',
|
|
1996
|
+
instanceLocation: '#/params',
|
|
1997
|
+
},
|
|
1998
|
+
]
|
|
1999
|
+
return false
|
|
2000
|
+
}
|
|
2001
|
+
const err26 = validate.errors
|
|
2002
|
+
const res26 = ref6(data.params)
|
|
2003
|
+
const suberr26 = ref6.errors
|
|
2004
|
+
validate.errors = err26
|
|
2005
|
+
if (!res26) {
|
|
2006
|
+
validate.errors = [
|
|
2007
|
+
errorMerge(
|
|
2008
|
+
suberr26[0],
|
|
2009
|
+
'#/oneOf/34/properties/params/$ref',
|
|
2010
|
+
'#/params',
|
|
2011
|
+
),
|
|
2012
|
+
]
|
|
2013
|
+
return false
|
|
2014
|
+
}
|
|
2015
|
+
break
|
|
2016
|
+
case 'eth_signTypedData':
|
|
2017
|
+
if (!('params' in data && hasOwn(data, 'params'))) {
|
|
2018
|
+
validate.errors = [
|
|
2019
|
+
{
|
|
2020
|
+
keywordLocation: '#/oneOf/35/required',
|
|
2021
|
+
instanceLocation: '#/params',
|
|
2022
|
+
},
|
|
2023
|
+
]
|
|
2024
|
+
return false
|
|
2025
|
+
}
|
|
2026
|
+
const err27 = validate.errors
|
|
2027
|
+
const res27 = ref7(data.params)
|
|
2028
|
+
const suberr27 = ref7.errors
|
|
2029
|
+
validate.errors = err27
|
|
2030
|
+
if (!res27) {
|
|
2031
|
+
validate.errors = [
|
|
2032
|
+
errorMerge(
|
|
2033
|
+
suberr27[0],
|
|
2034
|
+
'#/oneOf/35/properties/params/$ref',
|
|
2035
|
+
'#/params',
|
|
2036
|
+
),
|
|
2037
|
+
]
|
|
2038
|
+
return false
|
|
2039
|
+
}
|
|
2040
|
+
break
|
|
2041
|
+
case 'eth_signTypedData_v1':
|
|
2042
|
+
if (!('params' in data && hasOwn(data, 'params'))) {
|
|
2043
|
+
validate.errors = [
|
|
2044
|
+
{
|
|
2045
|
+
keywordLocation: '#/oneOf/36/required',
|
|
2046
|
+
instanceLocation: '#/params',
|
|
2047
|
+
},
|
|
2048
|
+
]
|
|
2049
|
+
return false
|
|
2050
|
+
}
|
|
2051
|
+
const err29 = validate.errors
|
|
2052
|
+
const res29 = ref8(data.params)
|
|
2053
|
+
const suberr29 = ref8.errors
|
|
2054
|
+
validate.errors = err29
|
|
2055
|
+
if (!res29) {
|
|
2056
|
+
validate.errors = [
|
|
2057
|
+
errorMerge(
|
|
2058
|
+
suberr29[0],
|
|
2059
|
+
'#/oneOf/36/properties/params/$ref',
|
|
2060
|
+
'#/params',
|
|
2061
|
+
),
|
|
2062
|
+
]
|
|
2063
|
+
return false
|
|
2064
|
+
}
|
|
2065
|
+
break
|
|
2066
|
+
case 'eth_signTypedData_v3':
|
|
2067
|
+
if (!('params' in data && hasOwn(data, 'params'))) {
|
|
2068
|
+
validate.errors = [
|
|
2069
|
+
{
|
|
2070
|
+
keywordLocation: '#/oneOf/37/required',
|
|
2071
|
+
instanceLocation: '#/params',
|
|
2072
|
+
},
|
|
2073
|
+
]
|
|
2074
|
+
return false
|
|
2075
|
+
}
|
|
2076
|
+
const err30 = validate.errors
|
|
2077
|
+
const res30 = ref7(data.params)
|
|
2078
|
+
const suberr30 = ref7.errors
|
|
2079
|
+
validate.errors = err30
|
|
2080
|
+
if (!res30) {
|
|
2081
|
+
validate.errors = [
|
|
2082
|
+
errorMerge(
|
|
2083
|
+
suberr30[0],
|
|
2084
|
+
'#/oneOf/37/properties/params/$ref',
|
|
2085
|
+
'#/params',
|
|
2086
|
+
),
|
|
2087
|
+
]
|
|
2088
|
+
return false
|
|
2089
|
+
}
|
|
2090
|
+
break
|
|
2091
|
+
case 'eth_signTypedData_v4':
|
|
2092
|
+
if (!('params' in data && hasOwn(data, 'params'))) {
|
|
2093
|
+
validate.errors = [
|
|
2094
|
+
{
|
|
2095
|
+
keywordLocation: '#/oneOf/38/required',
|
|
2096
|
+
instanceLocation: '#/params',
|
|
2097
|
+
},
|
|
2098
|
+
]
|
|
2099
|
+
return false
|
|
2100
|
+
}
|
|
2101
|
+
const err31 = validate.errors
|
|
2102
|
+
const res31 = ref7(data.params)
|
|
2103
|
+
const suberr31 = ref7.errors
|
|
2104
|
+
validate.errors = err31
|
|
2105
|
+
if (!res31) {
|
|
2106
|
+
validate.errors = [
|
|
2107
|
+
errorMerge(
|
|
2108
|
+
suberr31[0],
|
|
2109
|
+
'#/oneOf/38/properties/params/$ref',
|
|
2110
|
+
'#/params',
|
|
2111
|
+
),
|
|
2112
|
+
]
|
|
2113
|
+
return false
|
|
2114
|
+
}
|
|
2115
|
+
break
|
|
2116
|
+
case 'eth_submitWork':
|
|
2117
|
+
if (!('params' in data && hasOwn(data, 'params'))) {
|
|
2118
|
+
validate.errors = [
|
|
2119
|
+
{
|
|
2120
|
+
keywordLocation: '#/oneOf/39/required',
|
|
2121
|
+
instanceLocation: '#/params',
|
|
2122
|
+
},
|
|
2123
|
+
]
|
|
2124
|
+
return false
|
|
2125
|
+
}
|
|
2126
|
+
const err32 = validate.errors
|
|
2127
|
+
const res32 = ref1(data.params)
|
|
2128
|
+
const suberr32 = ref1.errors
|
|
2129
|
+
validate.errors = err32
|
|
2130
|
+
if (!res32) {
|
|
2131
|
+
validate.errors = [
|
|
2132
|
+
errorMerge(
|
|
2133
|
+
suberr32[0],
|
|
2134
|
+
'#/oneOf/39/properties/params/$ref',
|
|
2135
|
+
'#/params',
|
|
2136
|
+
),
|
|
2137
|
+
]
|
|
2138
|
+
return false
|
|
2139
|
+
}
|
|
2140
|
+
break
|
|
2141
|
+
case 'personal_sign':
|
|
2142
|
+
if (!('params' in data && hasOwn(data, 'params'))) {
|
|
2143
|
+
validate.errors = [
|
|
2144
|
+
{
|
|
2145
|
+
keywordLocation: '#/oneOf/40/required',
|
|
2146
|
+
instanceLocation: '#/params',
|
|
2147
|
+
},
|
|
2148
|
+
]
|
|
2149
|
+
return false
|
|
2150
|
+
}
|
|
2151
|
+
const err33 = validate.errors
|
|
2152
|
+
const res33 = ref10(data.params)
|
|
2153
|
+
const suberr33 = ref10.errors
|
|
2154
|
+
validate.errors = err33
|
|
2155
|
+
if (!res33) {
|
|
2156
|
+
validate.errors = [
|
|
2157
|
+
errorMerge(
|
|
2158
|
+
suberr33[0],
|
|
2159
|
+
'#/oneOf/40/properties/params/$ref',
|
|
2160
|
+
'#/params',
|
|
2161
|
+
),
|
|
2162
|
+
]
|
|
2163
|
+
return false
|
|
2164
|
+
}
|
|
2165
|
+
break
|
|
2166
|
+
case 'net_version':
|
|
2167
|
+
if (!('params' in data && hasOwn(data, 'params'))) {
|
|
2168
|
+
validate.errors = [
|
|
2169
|
+
{
|
|
2170
|
+
keywordLocation: '#/oneOf/41/required',
|
|
2171
|
+
instanceLocation: '#/params',
|
|
2172
|
+
},
|
|
2173
|
+
]
|
|
2174
|
+
return false
|
|
2175
|
+
}
|
|
2176
|
+
if (!(Array.isArray(data.params) && data.params.length === 0)) {
|
|
2177
|
+
validate.errors = [
|
|
2178
|
+
{
|
|
2179
|
+
keywordLocation: '#/oneOf/41/properties/params/const',
|
|
2180
|
+
instanceLocation: '#/params',
|
|
2181
|
+
},
|
|
2182
|
+
]
|
|
2183
|
+
return false
|
|
2184
|
+
}
|
|
2185
|
+
break
|
|
2186
|
+
case 'wallet_getPermissions':
|
|
2187
|
+
if (!('params' in data && hasOwn(data, 'params'))) {
|
|
2188
|
+
validate.errors = [
|
|
2189
|
+
{
|
|
2190
|
+
keywordLocation: '#/oneOf/42/required',
|
|
2191
|
+
instanceLocation: '#/params',
|
|
2192
|
+
},
|
|
2193
|
+
]
|
|
2194
|
+
return false
|
|
2195
|
+
}
|
|
2196
|
+
if (!(Array.isArray(data.params) && data.params.length === 0)) {
|
|
2197
|
+
validate.errors = [
|
|
2198
|
+
{
|
|
2199
|
+
keywordLocation: '#/oneOf/42/properties/params/const',
|
|
2200
|
+
instanceLocation: '#/params',
|
|
2201
|
+
},
|
|
2202
|
+
]
|
|
2203
|
+
return false
|
|
2204
|
+
}
|
|
2205
|
+
break
|
|
2206
|
+
case 'wallet_requestPermissions':
|
|
2207
|
+
if (!('params' in data && hasOwn(data, 'params'))) {
|
|
2208
|
+
validate.errors = [
|
|
2209
|
+
{
|
|
2210
|
+
keywordLocation: '#/oneOf/43/required',
|
|
2211
|
+
instanceLocation: '#/params',
|
|
2212
|
+
},
|
|
2213
|
+
]
|
|
2214
|
+
return false
|
|
2215
|
+
}
|
|
2216
|
+
const err36 = validate.errors
|
|
2217
|
+
const res36 = ref11(data.params)
|
|
2218
|
+
const suberr36 = ref11.errors
|
|
2219
|
+
validate.errors = err36
|
|
2220
|
+
if (!res36) {
|
|
2221
|
+
validate.errors = [
|
|
2222
|
+
errorMerge(
|
|
2223
|
+
suberr36[0],
|
|
2224
|
+
'#/oneOf/43/properties/params/$ref',
|
|
2225
|
+
'#/params',
|
|
2226
|
+
),
|
|
2227
|
+
]
|
|
2228
|
+
return false
|
|
2229
|
+
}
|
|
2230
|
+
break
|
|
2231
|
+
case 'wallet_watchAsset':
|
|
2232
|
+
if (!('params' in data && hasOwn(data, 'params'))) {
|
|
2233
|
+
validate.errors = [
|
|
2234
|
+
{
|
|
2235
|
+
keywordLocation: '#/oneOf/44/required',
|
|
2236
|
+
instanceLocation: '#/params',
|
|
2237
|
+
},
|
|
2238
|
+
]
|
|
2239
|
+
return false
|
|
2240
|
+
}
|
|
2241
|
+
const err39 = validate.errors
|
|
2242
|
+
const res39 = ref14(data.params)
|
|
2243
|
+
const suberr39 = ref14.errors
|
|
2244
|
+
validate.errors = err39
|
|
2245
|
+
if (!res39) {
|
|
2246
|
+
validate.errors = [
|
|
2247
|
+
errorMerge(
|
|
2248
|
+
suberr39[0],
|
|
2249
|
+
'#/oneOf/44/properties/params/$ref',
|
|
2250
|
+
'#/params',
|
|
2251
|
+
),
|
|
2252
|
+
]
|
|
2253
|
+
return false
|
|
2254
|
+
}
|
|
2255
|
+
break
|
|
2256
|
+
case 'web3_clientVersion':
|
|
2257
|
+
if (!('params' in data && hasOwn(data, 'params'))) {
|
|
2258
|
+
validate.errors = [
|
|
2259
|
+
{
|
|
2260
|
+
keywordLocation: '#/oneOf/45/required',
|
|
2261
|
+
instanceLocation: '#/params',
|
|
2262
|
+
},
|
|
2263
|
+
]
|
|
2264
|
+
return false
|
|
2265
|
+
}
|
|
2266
|
+
if (!(Array.isArray(data.params) && data.params.length === 0)) {
|
|
2267
|
+
validate.errors = [
|
|
2268
|
+
{
|
|
2269
|
+
keywordLocation: '#/oneOf/45/properties/params/const',
|
|
2270
|
+
instanceLocation: '#/params',
|
|
2271
|
+
},
|
|
2272
|
+
]
|
|
2273
|
+
return false
|
|
2274
|
+
}
|
|
2275
|
+
break
|
|
2276
|
+
default:
|
|
2277
|
+
validate.errors = [
|
|
2278
|
+
{ keywordLocation: '#/oneOf', instanceLocation: '#' },
|
|
2279
|
+
]
|
|
2280
|
+
return false
|
|
2281
|
+
}
|
|
2282
|
+
for (const key8 of Object.keys(data)) {
|
|
2283
|
+
if (
|
|
2284
|
+
key8 !== 'id' &&
|
|
2285
|
+
key8 !== 'jsonrpc' &&
|
|
2286
|
+
key8 !== 'method' &&
|
|
2287
|
+
key8 !== 'params'
|
|
2288
|
+
) {
|
|
2289
|
+
validate.errors = [
|
|
2290
|
+
{
|
|
2291
|
+
keywordLocation: '#/unevaluatedProperties',
|
|
2292
|
+
instanceLocation: '#/' + pointerPart(key8),
|
|
2293
|
+
},
|
|
2294
|
+
]
|
|
2295
|
+
return false
|
|
2296
|
+
}
|
|
2297
|
+
}
|
|
2298
|
+
return true
|
|
2299
|
+
}
|
|
2300
|
+
return ref0
|
|
2301
|
+
})()
|
|
2302
|
+
|
|
2303
|
+
const isValid = validate(value)
|
|
2304
|
+
if (!isValid) {
|
|
2305
|
+
const { keywordLocation, instanceLocation } = validate.errors[0]
|
|
2306
|
+
const keyword = keywordLocation.slice(keywordLocation.lastIndexOf('/') + 1)
|
|
2307
|
+
const message = `JSON validation failed for ${keyword} at ${instanceLocation}`
|
|
2308
|
+
// TODO: Throw custom error (maybe -32700 from EIP-1474).
|
|
2309
|
+
throw new Error(message)
|
|
2310
|
+
}
|
|
2311
|
+
|
|
2312
|
+
return value
|
|
2313
|
+
}
|
|
2314
|
+
|
|
2315
|
+
export function parseAndValidateTypedData(value) {
|
|
2316
|
+
const parse = (function () {
|
|
2317
|
+
'use strict'
|
|
2318
|
+
const hasOwn = Function.prototype.call.bind(Object.prototype.hasOwnProperty)
|
|
2319
|
+
const stringLength = (string) =>
|
|
2320
|
+
/[\uD800-\uDFFF]/.test(string) ? [...string].length : string.length
|
|
2321
|
+
const pointerPart = (s) =>
|
|
2322
|
+
/~\//.test(s) ? `${s}`.replace(/~/g, '~0').replace(/\//g, '~1') : s
|
|
2323
|
+
const format0 = new RegExp('^(?!_)[\\s\\w!?.,/()[\\]]+$', '')
|
|
2324
|
+
const ref2 = function validate(data) {
|
|
2325
|
+
validate.errors = null
|
|
2326
|
+
if (!(typeof data === 'object' && data && !Array.isArray(data))) {
|
|
2327
|
+
validate.errors = [{ keywordLocation: '#/type', instanceLocation: '#' }]
|
|
2328
|
+
return false
|
|
2329
|
+
}
|
|
2330
|
+
if (!(data.name !== undefined && hasOwn(data, 'name'))) {
|
|
2331
|
+
validate.errors = [
|
|
2332
|
+
{ keywordLocation: '#/required', instanceLocation: '#/name' },
|
|
2333
|
+
]
|
|
2334
|
+
return false
|
|
2335
|
+
}
|
|
2336
|
+
if (!(data.type !== undefined && hasOwn(data, 'type'))) {
|
|
2337
|
+
validate.errors = [
|
|
2338
|
+
{ keywordLocation: '#/required', instanceLocation: '#/type' },
|
|
2339
|
+
]
|
|
2340
|
+
return false
|
|
2341
|
+
}
|
|
2342
|
+
if (!(typeof data.name === 'string')) {
|
|
2343
|
+
validate.errors = [
|
|
2344
|
+
{
|
|
2345
|
+
keywordLocation: '#/properties/name/type',
|
|
2346
|
+
instanceLocation: '#/name',
|
|
2347
|
+
},
|
|
2348
|
+
]
|
|
2349
|
+
return false
|
|
2350
|
+
}
|
|
2351
|
+
if (data.name.length > 50 && stringLength(data.name) > 50) {
|
|
2352
|
+
validate.errors = [
|
|
2353
|
+
{
|
|
2354
|
+
keywordLocation: '#/properties/name/maxLength',
|
|
2355
|
+
instanceLocation: '#/name',
|
|
2356
|
+
},
|
|
2357
|
+
]
|
|
2358
|
+
return false
|
|
2359
|
+
}
|
|
2360
|
+
if (!format0.test(data.name)) {
|
|
2361
|
+
validate.errors = [
|
|
2362
|
+
{
|
|
2363
|
+
keywordLocation: '#/properties/name/format',
|
|
2364
|
+
instanceLocation: '#/name',
|
|
2365
|
+
},
|
|
2366
|
+
]
|
|
2367
|
+
return false
|
|
2368
|
+
}
|
|
2369
|
+
if (!(typeof data.type === 'string')) {
|
|
2370
|
+
validate.errors = [
|
|
2371
|
+
{
|
|
2372
|
+
keywordLocation: '#/properties/type/type',
|
|
2373
|
+
instanceLocation: '#/type',
|
|
2374
|
+
},
|
|
2375
|
+
]
|
|
2376
|
+
return false
|
|
2377
|
+
}
|
|
2378
|
+
if (data.type.length > 50 && stringLength(data.type) > 50) {
|
|
2379
|
+
validate.errors = [
|
|
2380
|
+
{
|
|
2381
|
+
keywordLocation: '#/properties/type/maxLength',
|
|
2382
|
+
instanceLocation: '#/type',
|
|
2383
|
+
},
|
|
2384
|
+
]
|
|
2385
|
+
return false
|
|
2386
|
+
}
|
|
2387
|
+
if (!format0.test(data.type)) {
|
|
2388
|
+
validate.errors = [
|
|
2389
|
+
{
|
|
2390
|
+
keywordLocation: '#/properties/type/format',
|
|
2391
|
+
instanceLocation: '#/type',
|
|
2392
|
+
},
|
|
2393
|
+
]
|
|
2394
|
+
return false
|
|
2395
|
+
}
|
|
2396
|
+
for (const key1 of Object.keys(data)) {
|
|
2397
|
+
if (key1 !== 'name' && key1 !== 'type') {
|
|
2398
|
+
validate.errors = [
|
|
2399
|
+
{
|
|
2400
|
+
keywordLocation: '#/additionalProperties',
|
|
2401
|
+
instanceLocation: '#/' + pointerPart(key1),
|
|
2402
|
+
},
|
|
2403
|
+
]
|
|
2404
|
+
return false
|
|
2405
|
+
}
|
|
2406
|
+
}
|
|
2407
|
+
return true
|
|
2408
|
+
}
|
|
2409
|
+
const errorMerge = (
|
|
2410
|
+
{ keywordLocation, instanceLocation },
|
|
2411
|
+
schemaBase,
|
|
2412
|
+
dataBase,
|
|
2413
|
+
) => ({
|
|
2414
|
+
keywordLocation: `${schemaBase}${keywordLocation.slice(1)}`,
|
|
2415
|
+
instanceLocation: `${dataBase}${instanceLocation.slice(1)}`,
|
|
2416
|
+
})
|
|
2417
|
+
const format1 = new RegExp(
|
|
2418
|
+
'^(0|[1-9]\\d*)\\.(0|[1-9]\\d*)\\.(0|[1-9]\\d*)(?:-((?:0|[1-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\\.(?:0|[1-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\\+([0-9a-zA-Z-]+(?:\\.[0-9a-zA-Z-]+)*))?$|^[0-9](\\.[0-9]){0,1}$',
|
|
2419
|
+
'',
|
|
2420
|
+
)
|
|
2421
|
+
const pattern0 = new RegExp('^[0-9]+$', 'u')
|
|
2422
|
+
const format2 = new RegExp('^0x[0-9a-f]+$', 'i')
|
|
2423
|
+
const format3 = new RegExp('^(?!_)(\\n|\\r|.)*$', '')
|
|
2424
|
+
const format4 = new RegExp('^0x[a-f0-9]{40}$', 'i')
|
|
2425
|
+
const ref3 = function validate(data) {
|
|
2426
|
+
validate.errors = null
|
|
2427
|
+
if (!(typeof data === 'object' && data && !Array.isArray(data))) {
|
|
2428
|
+
validate.errors = [{ keywordLocation: '#/type', instanceLocation: '#' }]
|
|
2429
|
+
return false
|
|
2430
|
+
}
|
|
2431
|
+
for (const key6 of Object.keys(data)) {
|
|
2432
|
+
if (key6.length > 50 && stringLength(key6) > 50) {
|
|
2433
|
+
validate.errors = [
|
|
2434
|
+
{
|
|
2435
|
+
keywordLocation: '#/propertyNames/maxLength',
|
|
2436
|
+
instanceLocation: '#/' + pointerPart(key6),
|
|
2437
|
+
},
|
|
2438
|
+
]
|
|
2439
|
+
return false
|
|
2440
|
+
}
|
|
2441
|
+
if (!format0.test(key6)) {
|
|
2442
|
+
validate.errors = [
|
|
2443
|
+
{
|
|
2444
|
+
keywordLocation: '#/propertyNames/format',
|
|
2445
|
+
instanceLocation: '#/' + pointerPart(key6),
|
|
2446
|
+
},
|
|
2447
|
+
]
|
|
2448
|
+
return false
|
|
2449
|
+
}
|
|
2450
|
+
}
|
|
2451
|
+
for (const key7 of Object.keys(data)) {
|
|
2452
|
+
const sub16 = (() => {
|
|
2453
|
+
if (
|
|
2454
|
+
!(
|
|
2455
|
+
typeof data[key7] === 'object' &&
|
|
2456
|
+
data[key7] &&
|
|
2457
|
+
!Array.isArray(data[key7]) &&
|
|
2458
|
+
Object.keys(data[key7]).length === 0
|
|
2459
|
+
)
|
|
2460
|
+
)
|
|
2461
|
+
return false
|
|
2462
|
+
return true
|
|
2463
|
+
})()
|
|
2464
|
+
const sub17 = (() => {
|
|
2465
|
+
if (!(typeof data[key7] === 'boolean')) return false
|
|
2466
|
+
return true
|
|
2467
|
+
})()
|
|
2468
|
+
const sub18 = (() => {
|
|
2469
|
+
if (!Number.isInteger(data[key7])) return false
|
|
2470
|
+
return true
|
|
2471
|
+
})()
|
|
2472
|
+
const sub19 = (() => {
|
|
2473
|
+
if (!(typeof data[key7] === 'number')) return false
|
|
2474
|
+
return true
|
|
2475
|
+
})()
|
|
2476
|
+
const sub20 = (() => {
|
|
2477
|
+
if (!(typeof data[key7] === 'string')) return false
|
|
2478
|
+
if (!format2.test(data[key7])) return false
|
|
2479
|
+
return true
|
|
2480
|
+
})()
|
|
2481
|
+
const sub21 = (() => {
|
|
2482
|
+
if (!(typeof data[key7] === 'string')) return false
|
|
2483
|
+
if (data[key7].length > 100 && stringLength(data[key7]) > 100)
|
|
2484
|
+
return false
|
|
2485
|
+
if (!format3.test(data[key7])) return false
|
|
2486
|
+
return true
|
|
2487
|
+
})()
|
|
2488
|
+
const sub22 = (() => {
|
|
2489
|
+
if (!Array.isArray(data[key7])) return false
|
|
2490
|
+
for (let l = 0; l < data[key7].length; l++) {
|
|
2491
|
+
if (data[key7][l] !== undefined && hasOwn(data[key7], l)) {
|
|
2492
|
+
const sub23 = (() => {
|
|
2493
|
+
if (!(typeof data[key7][l] === 'string')) return false
|
|
2494
|
+
if (!format4.test(data[key7][l])) return false
|
|
2495
|
+
return true
|
|
2496
|
+
})()
|
|
2497
|
+
const sub24 = (() => {
|
|
2498
|
+
if (!(typeof data[key7][l] === 'string')) return false
|
|
2499
|
+
if (!format2.test(data[key7][l])) return false
|
|
2500
|
+
return true
|
|
2501
|
+
})()
|
|
2502
|
+
const sub25 = (() => {
|
|
2503
|
+
if (!(typeof data[key7][l] === 'string')) return false
|
|
2504
|
+
if (
|
|
2505
|
+
data[key7][l].length > 100 &&
|
|
2506
|
+
stringLength(data[key7][l]) > 100
|
|
2507
|
+
)
|
|
2508
|
+
return false
|
|
2509
|
+
if (!format3.test(data[key7][l])) return false
|
|
2510
|
+
return true
|
|
2511
|
+
})()
|
|
2512
|
+
const sub26 = (() => {
|
|
2513
|
+
const err2 = validate.errors
|
|
2514
|
+
const res2 = validate(data[key7][l])
|
|
2515
|
+
const suberr2 = validate.errors
|
|
2516
|
+
validate.errors = err2
|
|
2517
|
+
if (!res2) return false
|
|
2518
|
+
return true
|
|
2519
|
+
})()
|
|
2520
|
+
if (!(sub23 || sub24 || sub25 || sub26)) return false
|
|
2521
|
+
}
|
|
2522
|
+
}
|
|
2523
|
+
return true
|
|
2524
|
+
})()
|
|
2525
|
+
const sub27 = (() => {
|
|
2526
|
+
const err3 = validate.errors
|
|
2527
|
+
const res3 = validate(data[key7])
|
|
2528
|
+
const suberr3 = validate.errors
|
|
2529
|
+
validate.errors = err3
|
|
2530
|
+
if (!res3) return false
|
|
2531
|
+
return true
|
|
2532
|
+
})()
|
|
2533
|
+
if (
|
|
2534
|
+
!(
|
|
2535
|
+
sub16 ||
|
|
2536
|
+
sub17 ||
|
|
2537
|
+
sub18 ||
|
|
2538
|
+
sub19 ||
|
|
2539
|
+
sub20 ||
|
|
2540
|
+
sub21 ||
|
|
2541
|
+
sub22 ||
|
|
2542
|
+
sub27
|
|
2543
|
+
)
|
|
2544
|
+
) {
|
|
2545
|
+
validate.errors = [
|
|
2546
|
+
{
|
|
2547
|
+
keywordLocation: '#/additionalProperties/anyOf',
|
|
2548
|
+
instanceLocation: '#/' + pointerPart(key7),
|
|
2549
|
+
},
|
|
2550
|
+
]
|
|
2551
|
+
return false
|
|
2552
|
+
}
|
|
2553
|
+
}
|
|
2554
|
+
return true
|
|
2555
|
+
}
|
|
2556
|
+
const ref1 = function validate(data) {
|
|
2557
|
+
validate.errors = null
|
|
2558
|
+
if (!(typeof data === 'object' && data && !Array.isArray(data))) {
|
|
2559
|
+
validate.errors = [{ keywordLocation: '#/type', instanceLocation: '#' }]
|
|
2560
|
+
return false
|
|
2561
|
+
}
|
|
2562
|
+
if (!(data.domain !== undefined && hasOwn(data, 'domain'))) {
|
|
2563
|
+
validate.errors = [
|
|
2564
|
+
{ keywordLocation: '#/required', instanceLocation: '#/domain' },
|
|
2565
|
+
]
|
|
2566
|
+
return false
|
|
2567
|
+
}
|
|
2568
|
+
if (!(data.message !== undefined && hasOwn(data, 'message'))) {
|
|
2569
|
+
validate.errors = [
|
|
2570
|
+
{ keywordLocation: '#/required', instanceLocation: '#/message' },
|
|
2571
|
+
]
|
|
2572
|
+
return false
|
|
2573
|
+
}
|
|
2574
|
+
if (!(data.primaryType !== undefined && hasOwn(data, 'primaryType'))) {
|
|
2575
|
+
validate.errors = [
|
|
2576
|
+
{ keywordLocation: '#/required', instanceLocation: '#/primaryType' },
|
|
2577
|
+
]
|
|
2578
|
+
return false
|
|
2579
|
+
}
|
|
2580
|
+
if (!(data.types !== undefined && hasOwn(data, 'types'))) {
|
|
2581
|
+
validate.errors = [
|
|
2582
|
+
{ keywordLocation: '#/required', instanceLocation: '#/types' },
|
|
2583
|
+
]
|
|
2584
|
+
return false
|
|
2585
|
+
}
|
|
2586
|
+
if (
|
|
2587
|
+
!(
|
|
2588
|
+
typeof data.types === 'object' &&
|
|
2589
|
+
data.types &&
|
|
2590
|
+
!Array.isArray(data.types)
|
|
2591
|
+
)
|
|
2592
|
+
) {
|
|
2593
|
+
validate.errors = [
|
|
2594
|
+
{
|
|
2595
|
+
keywordLocation: '#/properties/types/type',
|
|
2596
|
+
instanceLocation: '#/types',
|
|
2597
|
+
},
|
|
2598
|
+
]
|
|
2599
|
+
return false
|
|
2600
|
+
}
|
|
2601
|
+
for (const key0 of Object.keys(data.types)) {
|
|
2602
|
+
if (key0.length > 50 && stringLength(key0) > 50) {
|
|
2603
|
+
validate.errors = [
|
|
2604
|
+
{
|
|
2605
|
+
keywordLocation: '#/properties/types/propertyNames/maxLength',
|
|
2606
|
+
instanceLocation: '#/types/' + pointerPart(key0),
|
|
2607
|
+
},
|
|
2608
|
+
]
|
|
2609
|
+
return false
|
|
2610
|
+
}
|
|
2611
|
+
if (!format0.test(key0)) {
|
|
2612
|
+
validate.errors = [
|
|
2613
|
+
{
|
|
2614
|
+
keywordLocation: '#/properties/types/propertyNames/format',
|
|
2615
|
+
instanceLocation: '#/types/' + pointerPart(key0),
|
|
2616
|
+
},
|
|
2617
|
+
]
|
|
2618
|
+
return false
|
|
2619
|
+
}
|
|
2620
|
+
}
|
|
2621
|
+
if (
|
|
2622
|
+
!(
|
|
2623
|
+
data.types.EIP712Domain !== undefined &&
|
|
2624
|
+
hasOwn(data.types, 'EIP712Domain')
|
|
2625
|
+
)
|
|
2626
|
+
) {
|
|
2627
|
+
validate.errors = [
|
|
2628
|
+
{
|
|
2629
|
+
keywordLocation: '#/properties/types/required',
|
|
2630
|
+
instanceLocation: '#/types/EIP712Domain',
|
|
2631
|
+
},
|
|
2632
|
+
]
|
|
2633
|
+
return false
|
|
2634
|
+
}
|
|
2635
|
+
if (!Array.isArray(data.types.EIP712Domain)) {
|
|
2636
|
+
validate.errors = [
|
|
2637
|
+
{
|
|
2638
|
+
keywordLocation: '#/properties/types/properties/EIP712Domain/type',
|
|
2639
|
+
instanceLocation: '#/types/EIP712Domain',
|
|
2640
|
+
},
|
|
2641
|
+
]
|
|
2642
|
+
return false
|
|
2643
|
+
}
|
|
2644
|
+
for (let i = 0; i < data.types.EIP712Domain.length; i++) {
|
|
2645
|
+
if (
|
|
2646
|
+
data.types.EIP712Domain[i] !== undefined &&
|
|
2647
|
+
hasOwn(data.types.EIP712Domain, i)
|
|
2648
|
+
) {
|
|
2649
|
+
const err0 = validate.errors
|
|
2650
|
+
const res0 = ref2(data.types.EIP712Domain[i])
|
|
2651
|
+
const suberr0 = ref2.errors
|
|
2652
|
+
validate.errors = err0
|
|
2653
|
+
if (!res0) {
|
|
2654
|
+
validate.errors = [
|
|
2655
|
+
errorMerge(
|
|
2656
|
+
suberr0[0],
|
|
2657
|
+
'#/properties/types/properties/EIP712Domain/items/$ref',
|
|
2658
|
+
'#/types/EIP712Domain/' + i,
|
|
2659
|
+
),
|
|
2660
|
+
]
|
|
2661
|
+
return false
|
|
2662
|
+
}
|
|
2663
|
+
if (
|
|
2664
|
+
!(
|
|
2665
|
+
typeof data.types.EIP712Domain[i] === 'object' &&
|
|
2666
|
+
data.types.EIP712Domain[i] &&
|
|
2667
|
+
!Array.isArray(data.types.EIP712Domain[i])
|
|
2668
|
+
)
|
|
2669
|
+
) {
|
|
2670
|
+
validate.errors = [
|
|
2671
|
+
{
|
|
2672
|
+
keywordLocation:
|
|
2673
|
+
'#/properties/types/properties/EIP712Domain/items/type',
|
|
2674
|
+
instanceLocation: '#/types/EIP712Domain/' + i,
|
|
2675
|
+
},
|
|
2676
|
+
]
|
|
2677
|
+
return false
|
|
2678
|
+
}
|
|
2679
|
+
}
|
|
2680
|
+
}
|
|
2681
|
+
for (const key2 of Object.keys(data.types)) {
|
|
2682
|
+
if (key2 !== 'EIP712Domain') {
|
|
2683
|
+
if (!Array.isArray(data.types[key2])) {
|
|
2684
|
+
validate.errors = [
|
|
2685
|
+
{
|
|
2686
|
+
keywordLocation: '#/properties/types/additionalProperties/type',
|
|
2687
|
+
instanceLocation: '#/types/' + pointerPart(key2),
|
|
2688
|
+
},
|
|
2689
|
+
]
|
|
2690
|
+
return false
|
|
2691
|
+
}
|
|
2692
|
+
for (let j = 0; j < data.types[key2].length; j++) {
|
|
2693
|
+
if (
|
|
2694
|
+
data.types[key2][j] !== undefined &&
|
|
2695
|
+
hasOwn(data.types[key2], j)
|
|
2696
|
+
) {
|
|
2697
|
+
const err1 = validate.errors
|
|
2698
|
+
const res1 = ref2(data.types[key2][j])
|
|
2699
|
+
const suberr1 = ref2.errors
|
|
2700
|
+
validate.errors = err1
|
|
2701
|
+
if (!res1) {
|
|
2702
|
+
validate.errors = [
|
|
2703
|
+
errorMerge(
|
|
2704
|
+
suberr1[0],
|
|
2705
|
+
'#/properties/types/additionalProperties/items/$ref',
|
|
2706
|
+
'#/types/' + pointerPart(key2) + '/' + j,
|
|
2707
|
+
),
|
|
2708
|
+
]
|
|
2709
|
+
return false
|
|
2710
|
+
}
|
|
2711
|
+
}
|
|
2712
|
+
}
|
|
2713
|
+
}
|
|
2714
|
+
}
|
|
2715
|
+
if (!(typeof data.primaryType === 'string')) {
|
|
2716
|
+
validate.errors = [
|
|
2717
|
+
{
|
|
2718
|
+
keywordLocation: '#/properties/primaryType/type',
|
|
2719
|
+
instanceLocation: '#/primaryType',
|
|
2720
|
+
},
|
|
2721
|
+
]
|
|
2722
|
+
return false
|
|
2723
|
+
}
|
|
2724
|
+
if (data.primaryType.length > 50 && stringLength(data.primaryType) > 50) {
|
|
2725
|
+
validate.errors = [
|
|
2726
|
+
{
|
|
2727
|
+
keywordLocation: '#/properties/primaryType/maxLength',
|
|
2728
|
+
instanceLocation: '#/primaryType',
|
|
2729
|
+
},
|
|
2730
|
+
]
|
|
2731
|
+
return false
|
|
2732
|
+
}
|
|
2733
|
+
if (!format0.test(data.primaryType)) {
|
|
2734
|
+
validate.errors = [
|
|
2735
|
+
{
|
|
2736
|
+
keywordLocation: '#/properties/primaryType/format',
|
|
2737
|
+
instanceLocation: '#/primaryType',
|
|
2738
|
+
},
|
|
2739
|
+
]
|
|
2740
|
+
return false
|
|
2741
|
+
}
|
|
2742
|
+
const sub0 = (() => {
|
|
2743
|
+
if (
|
|
2744
|
+
!(
|
|
2745
|
+
typeof data.domain === 'object' &&
|
|
2746
|
+
data.domain &&
|
|
2747
|
+
!Array.isArray(data.domain) &&
|
|
2748
|
+
Object.keys(data.domain).length === 0
|
|
2749
|
+
)
|
|
2750
|
+
)
|
|
2751
|
+
return false
|
|
2752
|
+
return true
|
|
2753
|
+
})()
|
|
2754
|
+
const sub1 = (() => {
|
|
2755
|
+
if (
|
|
2756
|
+
!(
|
|
2757
|
+
typeof data.domain === 'object' &&
|
|
2758
|
+
data.domain &&
|
|
2759
|
+
!Array.isArray(data.domain)
|
|
2760
|
+
)
|
|
2761
|
+
)
|
|
2762
|
+
return false
|
|
2763
|
+
if (!(data.domain.name !== undefined && hasOwn(data.domain, 'name')))
|
|
2764
|
+
return false
|
|
2765
|
+
if (
|
|
2766
|
+
!(data.domain.version !== undefined && hasOwn(data.domain, 'version'))
|
|
2767
|
+
)
|
|
2768
|
+
return false
|
|
2769
|
+
if (!(typeof data.domain.name === 'string')) return false
|
|
2770
|
+
if (data.domain.name.length > 50 && stringLength(data.domain.name) > 50)
|
|
2771
|
+
return false
|
|
2772
|
+
if (!format0.test(data.domain.name)) return false
|
|
2773
|
+
if (!(typeof data.domain.version === 'string')) return false
|
|
2774
|
+
if (
|
|
2775
|
+
data.domain.version.length > 255 &&
|
|
2776
|
+
stringLength(data.domain.version) > 255
|
|
2777
|
+
)
|
|
2778
|
+
return false
|
|
2779
|
+
if (!format1.test(data.domain.version)) return false
|
|
2780
|
+
if (
|
|
2781
|
+
data.domain.chainId !== undefined &&
|
|
2782
|
+
hasOwn(data.domain, 'chainId')
|
|
2783
|
+
) {
|
|
2784
|
+
let passes0 = 0
|
|
2785
|
+
const sub2 = (() => {
|
|
2786
|
+
if (!Number.isInteger(data.domain.chainId)) return false
|
|
2787
|
+
return true
|
|
2788
|
+
})()
|
|
2789
|
+
if (sub2) passes0++
|
|
2790
|
+
const sub3 = (() => {
|
|
2791
|
+
if (!(typeof data.domain.chainId === 'string')) return false
|
|
2792
|
+
if (!pattern0.test(data.domain.chainId)) return false
|
|
2793
|
+
return true
|
|
2794
|
+
})()
|
|
2795
|
+
if (sub3) passes0++
|
|
2796
|
+
const sub4 = (() => {
|
|
2797
|
+
if (!(typeof data.domain.chainId === 'string')) return false
|
|
2798
|
+
if (!format2.test(data.domain.chainId)) return false
|
|
2799
|
+
return true
|
|
2800
|
+
})()
|
|
2801
|
+
if (sub4) passes0++
|
|
2802
|
+
if (passes0 !== 1) return false
|
|
2803
|
+
}
|
|
2804
|
+
if (
|
|
2805
|
+
data.domain.verifyingContract !== undefined &&
|
|
2806
|
+
hasOwn(data.domain, 'verifyingContract')
|
|
2807
|
+
) {
|
|
2808
|
+
if (!(typeof data.domain.verifyingContract === 'string')) return false
|
|
2809
|
+
if (!format2.test(data.domain.verifyingContract)) return false
|
|
2810
|
+
}
|
|
2811
|
+
if (data.domain.salt !== undefined && hasOwn(data.domain, 'salt')) {
|
|
2812
|
+
if (!(typeof data.domain.salt === 'string')) return false
|
|
2813
|
+
if (!format2.test(data.domain.salt)) return false
|
|
2814
|
+
}
|
|
2815
|
+
for (const key3 of Object.keys(data.domain)) {
|
|
2816
|
+
if (
|
|
2817
|
+
key3 !== 'name' &&
|
|
2818
|
+
key3 !== 'version' &&
|
|
2819
|
+
key3 !== 'chainId' &&
|
|
2820
|
+
key3 !== 'verifyingContract' &&
|
|
2821
|
+
key3 !== 'salt'
|
|
2822
|
+
)
|
|
2823
|
+
return false
|
|
2824
|
+
}
|
|
2825
|
+
return true
|
|
2826
|
+
})()
|
|
2827
|
+
if (!(sub0 || sub1)) {
|
|
2828
|
+
validate.errors = [
|
|
2829
|
+
{
|
|
2830
|
+
keywordLocation: '#/properties/domain/anyOf',
|
|
2831
|
+
instanceLocation: '#/domain',
|
|
2832
|
+
},
|
|
2833
|
+
]
|
|
2834
|
+
return false
|
|
2835
|
+
}
|
|
2836
|
+
if (
|
|
2837
|
+
!(
|
|
2838
|
+
typeof data.message === 'object' &&
|
|
2839
|
+
data.message &&
|
|
2840
|
+
!Array.isArray(data.message)
|
|
2841
|
+
)
|
|
2842
|
+
) {
|
|
2843
|
+
validate.errors = [
|
|
2844
|
+
{
|
|
2845
|
+
keywordLocation: '#/properties/message/type',
|
|
2846
|
+
instanceLocation: '#/message',
|
|
2847
|
+
},
|
|
2848
|
+
]
|
|
2849
|
+
return false
|
|
2850
|
+
}
|
|
2851
|
+
for (const key4 of Object.keys(data.message)) {
|
|
2852
|
+
if (key4.length > 50 && stringLength(key4) > 50) {
|
|
2853
|
+
validate.errors = [
|
|
2854
|
+
{
|
|
2855
|
+
keywordLocation: '#/properties/message/propertyNames/maxLength',
|
|
2856
|
+
instanceLocation: '#/message/' + pointerPart(key4),
|
|
2857
|
+
},
|
|
2858
|
+
]
|
|
2859
|
+
return false
|
|
2860
|
+
}
|
|
2861
|
+
if (!format0.test(key4)) {
|
|
2862
|
+
validate.errors = [
|
|
2863
|
+
{
|
|
2864
|
+
keywordLocation: '#/properties/message/propertyNames/format',
|
|
2865
|
+
instanceLocation: '#/message/' + pointerPart(key4),
|
|
2866
|
+
},
|
|
2867
|
+
]
|
|
2868
|
+
return false
|
|
2869
|
+
}
|
|
2870
|
+
}
|
|
2871
|
+
for (const key5 of Object.keys(data.message)) {
|
|
2872
|
+
const sub5 = (() => {
|
|
2873
|
+
if (
|
|
2874
|
+
!(
|
|
2875
|
+
typeof data.message[key5] === 'object' &&
|
|
2876
|
+
data.message[key5] &&
|
|
2877
|
+
!Array.isArray(data.message[key5]) &&
|
|
2878
|
+
Object.keys(data.message[key5]).length === 0
|
|
2879
|
+
)
|
|
2880
|
+
)
|
|
2881
|
+
return false
|
|
2882
|
+
return true
|
|
2883
|
+
})()
|
|
2884
|
+
const sub6 = (() => {
|
|
2885
|
+
if (!(typeof data.message[key5] === 'boolean')) return false
|
|
2886
|
+
return true
|
|
2887
|
+
})()
|
|
2888
|
+
const sub7 = (() => {
|
|
2889
|
+
if (!Number.isInteger(data.message[key5])) return false
|
|
2890
|
+
return true
|
|
2891
|
+
})()
|
|
2892
|
+
const sub8 = (() => {
|
|
2893
|
+
if (!(typeof data.message[key5] === 'number')) return false
|
|
2894
|
+
return true
|
|
2895
|
+
})()
|
|
2896
|
+
const sub9 = (() => {
|
|
2897
|
+
if (!(typeof data.message[key5] === 'string')) return false
|
|
2898
|
+
if (!format2.test(data.message[key5])) return false
|
|
2899
|
+
return true
|
|
2900
|
+
})()
|
|
2901
|
+
const sub10 = (() => {
|
|
2902
|
+
if (!(typeof data.message[key5] === 'string')) return false
|
|
2903
|
+
if (
|
|
2904
|
+
data.message[key5].length > 100 &&
|
|
2905
|
+
stringLength(data.message[key5]) > 100
|
|
2906
|
+
)
|
|
2907
|
+
return false
|
|
2908
|
+
if (!format3.test(data.message[key5])) return false
|
|
2909
|
+
return true
|
|
2910
|
+
})()
|
|
2911
|
+
const sub11 = (() => {
|
|
2912
|
+
if (!Array.isArray(data.message[key5])) return false
|
|
2913
|
+
for (let k = 0; k < data.message[key5].length; k++) {
|
|
2914
|
+
if (
|
|
2915
|
+
data.message[key5][k] !== undefined &&
|
|
2916
|
+
hasOwn(data.message[key5], k)
|
|
2917
|
+
) {
|
|
2918
|
+
const sub12 = (() => {
|
|
2919
|
+
if (!(typeof data.message[key5][k] === 'string')) return false
|
|
2920
|
+
if (!format4.test(data.message[key5][k])) return false
|
|
2921
|
+
return true
|
|
2922
|
+
})()
|
|
2923
|
+
const sub13 = (() => {
|
|
2924
|
+
if (!(typeof data.message[key5][k] === 'string')) return false
|
|
2925
|
+
if (!format2.test(data.message[key5][k])) return false
|
|
2926
|
+
return true
|
|
2927
|
+
})()
|
|
2928
|
+
const sub14 = (() => {
|
|
2929
|
+
if (!(typeof data.message[key5][k] === 'string')) return false
|
|
2930
|
+
if (
|
|
2931
|
+
data.message[key5][k].length > 100 &&
|
|
2932
|
+
stringLength(data.message[key5][k]) > 100
|
|
2933
|
+
)
|
|
2934
|
+
return false
|
|
2935
|
+
if (!format3.test(data.message[key5][k])) return false
|
|
2936
|
+
return true
|
|
2937
|
+
})()
|
|
2938
|
+
const sub15 = (() => {
|
|
2939
|
+
const err4 = validate.errors
|
|
2940
|
+
const res4 = ref3(data.message[key5][k])
|
|
2941
|
+
const suberr4 = ref3.errors
|
|
2942
|
+
validate.errors = err4
|
|
2943
|
+
if (!res4) return false
|
|
2944
|
+
return true
|
|
2945
|
+
})()
|
|
2946
|
+
if (!(sub12 || sub13 || sub14 || sub15)) return false
|
|
2947
|
+
}
|
|
2948
|
+
}
|
|
2949
|
+
return true
|
|
2950
|
+
})()
|
|
2951
|
+
const sub28 = (() => {
|
|
2952
|
+
const err5 = validate.errors
|
|
2953
|
+
const res5 = ref3(data.message[key5])
|
|
2954
|
+
const suberr5 = ref3.errors
|
|
2955
|
+
validate.errors = err5
|
|
2956
|
+
if (!res5) return false
|
|
2957
|
+
return true
|
|
2958
|
+
})()
|
|
2959
|
+
if (
|
|
2960
|
+
!(sub5 || sub6 || sub7 || sub8 || sub9 || sub10 || sub11 || sub28)
|
|
2961
|
+
) {
|
|
2962
|
+
validate.errors = [
|
|
2963
|
+
{
|
|
2964
|
+
keywordLocation:
|
|
2965
|
+
'#/properties/message/additionalProperties/anyOf',
|
|
2966
|
+
instanceLocation: '#/message/' + pointerPart(key5),
|
|
2967
|
+
},
|
|
2968
|
+
]
|
|
2969
|
+
return false
|
|
2970
|
+
}
|
|
2971
|
+
}
|
|
2972
|
+
for (const key8 of Object.keys(data)) {
|
|
2973
|
+
if (
|
|
2974
|
+
key8 !== 'types' &&
|
|
2975
|
+
key8 !== 'primaryType' &&
|
|
2976
|
+
key8 !== 'domain' &&
|
|
2977
|
+
key8 !== 'message'
|
|
2978
|
+
) {
|
|
2979
|
+
validate.errors = [
|
|
2980
|
+
{
|
|
2981
|
+
keywordLocation: '#/additionalProperties',
|
|
2982
|
+
instanceLocation: '#/' + pointerPart(key8),
|
|
2983
|
+
},
|
|
2984
|
+
]
|
|
2985
|
+
return false
|
|
2986
|
+
}
|
|
2987
|
+
}
|
|
2988
|
+
return true
|
|
2989
|
+
}
|
|
2990
|
+
const ref0 = function validate(data) {
|
|
2991
|
+
validate.errors = null
|
|
2992
|
+
const err6 = validate.errors
|
|
2993
|
+
const res6 = ref1(data)
|
|
2994
|
+
const suberr6 = ref1.errors
|
|
2995
|
+
validate.errors = err6
|
|
2996
|
+
if (!res6) {
|
|
2997
|
+
validate.errors = [errorMerge(suberr6[0], '#/$ref', '#')]
|
|
2998
|
+
return false
|
|
2999
|
+
}
|
|
3000
|
+
return true
|
|
3001
|
+
}
|
|
3002
|
+
const parseWrap = (validate) => (src) => {
|
|
3003
|
+
if (typeof src !== 'string')
|
|
3004
|
+
return { valid: false, error: 'Input is not a string' }
|
|
3005
|
+
try {
|
|
3006
|
+
const value = JSON.parse(src)
|
|
3007
|
+
if (!validate(value)) {
|
|
3008
|
+
const { keywordLocation, instanceLocation } = validate.errors[0]
|
|
3009
|
+
const keyword = keywordLocation.slice(
|
|
3010
|
+
keywordLocation.lastIndexOf('/') + 1,
|
|
3011
|
+
)
|
|
3012
|
+
const error = `JSON validation failed for ${keyword} at ${instanceLocation}`
|
|
3013
|
+
return { valid: false, error, errors: validate.errors }
|
|
3014
|
+
}
|
|
3015
|
+
return { valid: true, value }
|
|
3016
|
+
} catch ({ message }) {
|
|
3017
|
+
return { valid: false, error: message }
|
|
3018
|
+
}
|
|
3019
|
+
}
|
|
3020
|
+
return parseWrap(ref0)
|
|
3021
|
+
})()
|
|
3022
|
+
|
|
3023
|
+
const parsedObject = parse(value)
|
|
3024
|
+
if (!parsedObject.valid) {
|
|
3025
|
+
const { keywordLocation, instanceLocation } = parsedObject.errors[0]
|
|
3026
|
+
const keyword = keywordLocation.slice(keywordLocation.lastIndexOf('/') + 1)
|
|
3027
|
+
const message = `JSON validation failed for ${keyword} at ${instanceLocation}`
|
|
3028
|
+
// TODO: Throw custom error (maybe -32700 from EIP-1474).
|
|
3029
|
+
throw new Error(message)
|
|
3030
|
+
}
|
|
3031
|
+
|
|
3032
|
+
return parsedObject.value
|
|
3033
|
+
}
|