@ellipticltd/aml-utils 0.16.27 → 0.16.28
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/README.md +11 -43
- package/lib/errors/errors.js +19 -30
- package/lib/errors/errors.js.map +1 -0
- package/{dist → lib}/file-parser/errors.js +1 -1
- package/lib/file-parser/errors.js.map +1 -0
- package/{dist → lib}/file-parser/file-parser.d.ts +2 -4
- package/lib/file-parser/file-parser.js +59 -0
- package/lib/file-parser/file-parser.js.map +1 -0
- package/{dist/structured-file-parser → lib/file-parser}/parse-row.js +2 -1
- package/lib/file-parser/parse-row.js.map +1 -0
- package/{dist/file-parser/sanitzeRows.d.ts → lib/file-parser/sanitizeRows.d.ts} +3 -1
- package/lib/file-parser/sanitizeRows.js +15 -0
- package/lib/file-parser/sanitizeRows.js.map +1 -0
- package/lib/formatting/formatting.js +11 -12
- package/lib/formatting/formatting.js.map +1 -0
- package/{dist → lib}/index.d.ts +1 -1
- package/lib/index.js +21 -0
- package/lib/index.js.map +1 -0
- package/lib/middleware/middleware.js +14 -17
- package/lib/middleware/middleware.js.map +1 -0
- package/lib/orm-helpers/ormHelpers.js +12 -13
- package/lib/orm-helpers/ormHelpers.js.map +1 -0
- package/{dist → lib}/structured-file-parser/errors.js +1 -0
- package/lib/structured-file-parser/errors.js.map +1 -0
- package/{dist/file-parser → lib/structured-file-parser}/parse-row.js +2 -1
- package/lib/structured-file-parser/parse-row.js.map +1 -0
- package/{dist → lib}/structured-file-parser/sanitize-rows.js +3 -4
- package/lib/structured-file-parser/sanitize-rows.js.map +1 -0
- package/{dist → lib}/structured-file-parser/structured-file-parser.d.ts +2 -2
- package/lib/structured-file-parser/structured-file-parser.js +95 -0
- package/lib/structured-file-parser/structured-file-parser.js.map +1 -0
- package/{dist → lib}/types/types.d.ts +0 -6
- package/lib/types/types.js +191 -203
- package/lib/types/types.js.map +1 -0
- package/{dist → lib}/validations/validations.d.ts +133 -82
- package/lib/validations/validations.js +672 -453
- package/lib/validations/validations.js.map +1 -0
- package/package.json +7 -60
- package/.circleci/config.yml +0 -87
- package/.claude/settings.local.json +0 -7
- package/.eslintrc +0 -45
- package/.huskyrc +0 -5
- package/.mocharc.json +0 -3
- package/.nvmrc +0 -1
- package/.nycrc.json +0 -11
- package/.releaserc.json +0 -18
- package/.snyk +0 -12
- package/codecov.yml +0 -29
- package/commitlint.config.js +0 -1
- package/dist/errors/errors.js +0 -42
- package/dist/errors/errors.spec.d.ts +0 -1
- package/dist/errors/errors.spec.js +0 -23
- package/dist/file-parser/__tests/file-parser.spec.d.ts +0 -1
- package/dist/file-parser/__tests/file-parser.spec.js +0 -109
- package/dist/file-parser/__tests/parse-row.spec.d.ts +0 -1
- package/dist/file-parser/__tests/parse-row.spec.js +0 -29
- package/dist/file-parser/__tests/sanitize-rows.spec.d.ts +0 -1
- package/dist/file-parser/__tests/sanitize-rows.spec.js +0 -78
- package/dist/file-parser/file-parser.js +0 -55
- package/dist/file-parser/sanitzeRows.js +0 -18
- package/dist/formatting/formatting.js +0 -17
- package/dist/formatting/formatting.spec.d.ts +0 -1
- package/dist/formatting/formatting.spec.js +0 -37
- package/dist/index.js +0 -22
- package/dist/middleware/middleware.js +0 -22
- package/dist/orm-helpers/ormHelpers.js +0 -17
- package/dist/orm-helpers/ormHelpers.spec.d.ts +0 -1
- package/dist/orm-helpers/ormHelpers.spec.js +0 -38
- package/dist/structured-file-parser/structured-file-parser.js +0 -98
- package/dist/types/types.js +0 -203
- package/dist/validations/validations.js +0 -470
- package/dist/validations/validations.spec.d.ts +0 -1
- package/dist/validations/validations.spec.js +0 -463
- package/lib/errors/errors.spec.js +0 -37
- package/lib/file-parser/__tests/file-parser.spec.js +0 -107
- package/lib/file-parser/__tests/parse-row.spec.js +0 -35
- package/lib/file-parser/__tests/sanitize-rows.spec.js +0 -88
- package/lib/file-parser/errors.ts +0 -7
- package/lib/file-parser/file-parser.ts +0 -84
- package/lib/file-parser/parse-row.ts +0 -52
- package/lib/file-parser/sanitzeRows.ts +0 -32
- package/lib/formatting/formatting.spec.js +0 -45
- package/lib/index.ts +0 -19
- package/lib/orm-helpers/ormHelpers.spec.js +0 -41
- package/lib/structured-file-parser/errors.ts +0 -25
- package/lib/structured-file-parser/parse-row.ts +0 -52
- package/lib/structured-file-parser/sanitize-rows.ts +0 -24
- package/lib/structured-file-parser/structured-file-parser.ts +0 -155
- package/lib/validations/validations.spec.js +0 -603
- package/tsconfig.json +0 -26
- /package/{dist → lib}/errors/errors.d.ts +0 -0
- /package/{dist → lib}/file-parser/errors.d.ts +0 -0
- /package/{dist → lib}/file-parser/parse-row.d.ts +0 -0
- /package/{dist → lib}/formatting/formatting.d.ts +0 -0
- /package/{dist → lib}/middleware/middleware.d.ts +0 -0
- /package/{dist → lib}/orm-helpers/ormHelpers.d.ts +0 -0
- /package/{dist → lib}/structured-file-parser/errors.d.ts +0 -0
- /package/{dist → lib}/structured-file-parser/parse-row.d.ts +0 -0
- /package/{dist → lib}/structured-file-parser/sanitize-rows.d.ts +0 -0
|
@@ -1,478 +1,697 @@
|
|
|
1
|
+
/* eslint no-underscore-dangle: 0 */
|
|
1
2
|
const V = require('validator');
|
|
2
3
|
const _ = require('lodash');
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
HDPrivateKey,
|
|
6
|
-
HDPublicKey,
|
|
7
|
-
PublicKey,
|
|
8
|
-
Script,
|
|
9
|
-
Transaction,
|
|
10
|
-
} = require('bitcore-lib');
|
|
11
|
-
const addressValidator = require('multicoin-address-validator');
|
|
4
|
+
// Importing directly from dist to make sure we import the browser-friendly version of the library
|
|
5
|
+
const addressValidator = require('multicoin-address-validator/dist/wallet-address-validator');
|
|
12
6
|
const eip55 = require('eip55');
|
|
13
|
-
const
|
|
7
|
+
const stellarBase = require('@stellar/stellar-base');
|
|
14
8
|
const E = require('../errors/errors');
|
|
15
|
-
|
|
16
9
|
const cryptoValidators = {
|
|
17
|
-
|
|
18
|
-
isAddress(str) {
|
|
19
|
-
if (typeof str !== 'string' || !/^0x[0-9a-fA-F]{40}$/.test(str)) return false;
|
|
20
|
-
return eip55.verify(str, true);
|
|
21
|
-
},
|
|
22
|
-
isHexStrict(str) {
|
|
23
|
-
return typeof str === 'string' && /^0x[0-9a-fA-F]*$/.test(str);
|
|
24
|
-
},
|
|
25
|
-
isHex(str) {
|
|
26
|
-
return typeof str === 'string' && /^(0x)?[0-9a-fA-F]*$/.test(str);
|
|
27
|
-
},
|
|
28
|
-
isValidWeiAmount(str) {
|
|
29
|
-
return typeof str === 'string' && /^[0-9]+$/.test(str);
|
|
30
|
-
},
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
const validations = {
|
|
34
|
-
_validate(Err, pred, x, msg) {
|
|
35
|
-
if (pred(x)) {
|
|
36
|
-
return x;
|
|
37
|
-
}
|
|
38
|
-
throw new Err(msg);
|
|
39
|
-
},
|
|
40
|
-
_validateArg(pred, x, msg) {
|
|
41
|
-
return this._validate(E.InvalidArguments, pred, x, msg);
|
|
42
|
-
},
|
|
43
|
-
_tryCheck(fn, arg) {
|
|
44
|
-
try {
|
|
45
|
-
fn(arg);
|
|
46
|
-
return true;
|
|
47
|
-
} catch (error) {
|
|
48
|
-
return false;
|
|
49
|
-
}
|
|
50
|
-
},
|
|
51
|
-
|
|
52
|
-
exists(x) {
|
|
53
|
-
return x != null;
|
|
54
|
-
},
|
|
55
|
-
nonEmpty(x) {
|
|
56
|
-
return (x != null ? x.length : undefined) > 0;
|
|
57
|
-
},
|
|
58
|
-
isNonEmptyString(x) {
|
|
59
|
-
return _.isString(x) && (x != null ? x.length : undefined) > 0;
|
|
60
|
-
},
|
|
61
|
-
isSafeString(str) {
|
|
62
|
-
// eslint-disable-next-line no-useless-escape
|
|
63
|
-
return RegExp(/^(\p{L}|[0-9]|-|=|!|\.|:|\s|@|\+|_|,|\$|£|&)+$/, 'u').test(str);
|
|
64
|
-
},
|
|
65
|
-
ensureShortEnough(limit, x) {
|
|
66
|
-
const l = x != null ? x.length : undefined;
|
|
67
|
-
if (l <= limit) {
|
|
68
|
-
return true;
|
|
69
|
-
}
|
|
70
|
-
throw new E.BadRequest(`Max query size exceeded: ${l} / ${limit}`);
|
|
71
|
-
},
|
|
72
|
-
ensure(crit, msg) {
|
|
73
|
-
if (crit) {
|
|
74
|
-
return true;
|
|
75
|
-
}
|
|
76
|
-
throw new E.BadRequest(msg);
|
|
77
|
-
},
|
|
78
|
-
argExists(x, msg) {
|
|
79
|
-
return this._validateArg(this.exists, x, msg);
|
|
80
|
-
},
|
|
81
|
-
|
|
82
|
-
check: {
|
|
83
|
-
matches(required, given, msg) {
|
|
84
|
-
const newGiven = _.uniq(given);
|
|
85
|
-
const crit = _.intersection(newGiven, required).length === given.length;
|
|
86
|
-
if (crit) {
|
|
87
|
-
return true;
|
|
88
|
-
}
|
|
89
|
-
throw new E.BadRequest(msg);
|
|
90
|
-
},
|
|
91
|
-
wasFound(type) {
|
|
92
|
-
return (item) => {
|
|
93
|
-
if (item == null) {
|
|
94
|
-
throw new E.NotFound(`Unknown ${type}`);
|
|
95
|
-
} else {
|
|
96
|
-
return item;
|
|
97
|
-
}
|
|
98
|
-
};
|
|
99
|
-
},
|
|
100
|
-
wasCreated(msg) {
|
|
101
|
-
return (arr) => {
|
|
102
|
-
if (!arr[1]) {
|
|
103
|
-
throw new E.BadRequest(msg);
|
|
104
|
-
} else {
|
|
105
|
-
return arr;
|
|
106
|
-
}
|
|
107
|
-
};
|
|
108
|
-
},
|
|
109
|
-
isTrue(crit, msg) {
|
|
110
|
-
if (crit) {
|
|
111
|
-
return true;
|
|
112
|
-
}
|
|
113
|
-
throw new E.BadRequest(msg);
|
|
114
|
-
},
|
|
115
|
-
isFalse(crit, msg) {
|
|
116
|
-
if (!crit) {
|
|
117
|
-
return true;
|
|
118
|
-
}
|
|
119
|
-
throw new E.BadRequest(msg);
|
|
120
|
-
},
|
|
121
|
-
},
|
|
122
|
-
|
|
123
|
-
isCustomerReference(x) {
|
|
124
|
-
return (
|
|
125
|
-
_.isString(x)
|
|
126
|
-
&& (x != null ? x.length : undefined) > 0
|
|
127
|
-
&& (x != null ? x.length : undefined) <= 100
|
|
128
|
-
);
|
|
129
|
-
},
|
|
130
|
-
isCustomerLabelName(x) {
|
|
131
|
-
return (
|
|
132
|
-
_.isString(x)
|
|
133
|
-
&& (x != null ? x.length : undefined) > 0
|
|
134
|
-
&& (x != null ? x.length : undefined) <= 50
|
|
135
|
-
);
|
|
136
|
-
},
|
|
137
|
-
binanceChain: {
|
|
138
|
-
isAddress(str) {
|
|
139
|
-
return /^(bnb)([a-z0-9]{39})$/.test(str);
|
|
140
|
-
},
|
|
141
|
-
isTxHash(str) {
|
|
142
|
-
if (!V.isHexadecimal(str)) {
|
|
143
|
-
return false;
|
|
144
|
-
}
|
|
145
|
-
return str.length === 64;
|
|
146
|
-
},
|
|
147
|
-
},
|
|
148
|
-
bitcoin: {
|
|
149
|
-
isAddress(str) {
|
|
150
|
-
const network = process.env.BITCOIN_NETWORK === 'testnet' ? 'testnet' : 'prod';
|
|
151
|
-
return typeof str === 'string' && addressValidator.validate(str.trim(), 'btc', network);
|
|
152
|
-
},
|
|
153
|
-
isBech32Address(str) {
|
|
154
|
-
return /^bc1[ac-hj-np-z02-9]{6,86}|^BC1[AC-HJ-NP-Z02-9]{6,86}/.test(str);
|
|
155
|
-
},
|
|
156
|
-
isHDPublicKey(str) {
|
|
157
|
-
try {
|
|
158
|
-
HDPublicKey(str);
|
|
159
|
-
return true;
|
|
160
|
-
} catch (error) {
|
|
161
|
-
return false;
|
|
162
|
-
}
|
|
163
|
-
},
|
|
164
|
-
isPublicKey(str) {
|
|
165
|
-
try {
|
|
166
|
-
PublicKey(str);
|
|
167
|
-
return true;
|
|
168
|
-
} catch (error) {
|
|
169
|
-
return false;
|
|
170
|
-
}
|
|
171
|
-
},
|
|
172
|
-
isTxHash(str) {
|
|
173
|
-
if (!V.isHexadecimal(str)) {
|
|
174
|
-
return false;
|
|
175
|
-
}
|
|
176
|
-
return str.length === 64;
|
|
177
|
-
},
|
|
178
|
-
isTxHex(str) {
|
|
179
|
-
if (!V.isHexadecimal(str)) {
|
|
180
|
-
return false;
|
|
181
|
-
}
|
|
182
|
-
try {
|
|
183
|
-
Transaction(str);
|
|
184
|
-
return true;
|
|
185
|
-
} catch (error) {
|
|
186
|
-
return false;
|
|
187
|
-
}
|
|
188
|
-
},
|
|
189
|
-
isHDPath(str) {
|
|
190
|
-
return HDPrivateKey.isValidPath(str);
|
|
191
|
-
},
|
|
192
|
-
isScriptHex(str) {
|
|
193
|
-
if (!V.isHexadecimal(str)) {
|
|
194
|
-
return false;
|
|
195
|
-
}
|
|
196
|
-
try {
|
|
197
|
-
Script(str);
|
|
198
|
-
return true;
|
|
199
|
-
} catch (error) {
|
|
200
|
-
return false;
|
|
201
|
-
}
|
|
202
|
-
},
|
|
203
|
-
isTxSignature(str) {
|
|
204
|
-
if (!V.isHexadecimal(str)) {
|
|
205
|
-
return false;
|
|
206
|
-
}
|
|
207
|
-
try {
|
|
208
|
-
const b = Buffer.from(str, 'hex');
|
|
209
|
-
Signature.fromTxFormat(b);
|
|
210
|
-
return true;
|
|
211
|
-
} catch (error) {
|
|
212
|
-
return false;
|
|
213
|
-
}
|
|
214
|
-
},
|
|
215
|
-
isBlockHeight(obj) {
|
|
216
|
-
return _.isInteger(+obj) && parseInt(obj, 10) >= 0;
|
|
217
|
-
},
|
|
218
|
-
},
|
|
219
|
-
bitcoinCash: {
|
|
220
|
-
isAddress(str) {
|
|
221
|
-
return /^[13][a-km-zA-HJ-NP-Z1-9]{25,34}$|^(bitcoincash:)?[q|p][a-z0-9]{41}$|^(BITCOINCASH:)?[Q|P][A-Z0-9]{41}$/.test(str);
|
|
222
|
-
},
|
|
223
|
-
isTxHash(str) {
|
|
224
|
-
if (!V.isHexadecimal(str)) {
|
|
225
|
-
return false;
|
|
226
|
-
}
|
|
227
|
-
return str.length === 64;
|
|
228
|
-
},
|
|
229
|
-
},
|
|
230
|
-
ethereum: {
|
|
10
|
+
// Here we use our regex to validate the shape of the address, and eip55 to validate the checksum
|
|
231
11
|
isAddress(str) {
|
|
232
|
-
|
|
12
|
+
if (typeof str !== 'string' || !/^0x[0-9a-fA-F]{40}$/.test(str))
|
|
13
|
+
return false;
|
|
14
|
+
return eip55.verify(str, true);
|
|
233
15
|
},
|
|
234
|
-
|
|
235
|
-
|
|
16
|
+
isHexStrict(str) {
|
|
17
|
+
return typeof str === 'string' && /^0x[0-9a-fA-F]*$/.test(str);
|
|
236
18
|
},
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
},
|
|
240
|
-
isAddressCode(str) {
|
|
241
|
-
return cryptoValidators.isHexStrict(str);
|
|
19
|
+
isHex(str) {
|
|
20
|
+
return typeof str === 'string' && /^(0x)?[0-9a-fA-F]*$/.test(str);
|
|
242
21
|
},
|
|
243
22
|
isValidWeiAmount(str) {
|
|
244
|
-
|
|
245
|
-
},
|
|
246
|
-
},
|
|
247
|
-
horizen: {
|
|
248
|
-
isAddress(str) {
|
|
249
|
-
return addressValidator.validate(str, 'zen');
|
|
250
|
-
},
|
|
251
|
-
isTxHash(str) {
|
|
252
|
-
if (!V.isHexadecimal(str)) {
|
|
253
|
-
return false;
|
|
254
|
-
}
|
|
255
|
-
return str.length === 64;
|
|
256
|
-
},
|
|
257
|
-
},
|
|
258
|
-
litecoin: {
|
|
259
|
-
isAddress(str) {
|
|
260
|
-
return /^[3LM][a-km-zA-HJ-NP-Z1-9]{24,33}$|^ltc1[ac-hj-np-z02-9]{6,86}$|^LTC1[AC-HJ-NP-Z02-9]{6,86}$|^ltcmweb[a-zA-Z0-9]{114}$/.test(str);
|
|
261
|
-
},
|
|
262
|
-
isTxHash(str) {
|
|
263
|
-
if (!V.isHexadecimal(str)) {
|
|
264
|
-
return false;
|
|
265
|
-
}
|
|
266
|
-
return str.length === 64;
|
|
267
|
-
},
|
|
268
|
-
},
|
|
269
|
-
ripple: {
|
|
270
|
-
isAddress(str) {
|
|
271
|
-
return addressValidator.validate(str, 'xrp');
|
|
272
|
-
},
|
|
273
|
-
isTxHash(str) {
|
|
274
|
-
if (!V.isHexadecimal(str)) {
|
|
275
|
-
return false;
|
|
276
|
-
}
|
|
277
|
-
return str.length === 64;
|
|
278
|
-
},
|
|
279
|
-
},
|
|
280
|
-
stellar: {
|
|
281
|
-
isAddress(str) {
|
|
282
|
-
return stellarSDK.StrKey.isValidEd25519PublicKey(str);
|
|
283
|
-
},
|
|
284
|
-
isTxHash(str) {
|
|
285
|
-
if (!V.isHexadecimal(str)) {
|
|
286
|
-
return false;
|
|
287
|
-
}
|
|
288
|
-
return str.length === 64;
|
|
289
|
-
},
|
|
290
|
-
},
|
|
291
|
-
zcash: {
|
|
292
|
-
isAddress(str) {
|
|
293
|
-
return addressValidator.validate(str, 'zec');
|
|
294
|
-
},
|
|
295
|
-
isTxHash(str) {
|
|
296
|
-
if (!V.isHexadecimal(str)) {
|
|
297
|
-
return false;
|
|
298
|
-
}
|
|
299
|
-
return str.length === 64;
|
|
300
|
-
},
|
|
301
|
-
},
|
|
302
|
-
zilliqa: {
|
|
303
|
-
isAddress(str) {
|
|
304
|
-
// https://pub.dev/documentation/laksadart/latest/laksadart/isBech32.html
|
|
305
|
-
return !!str.match(/^zil1[qpzry9x8gf2tvdw0s3jn54khce6mua7l]{38}$/);
|
|
306
|
-
},
|
|
307
|
-
isTxHash(str) {
|
|
308
|
-
return str.length === 66 && cryptoValidators.isHexStrict(str);
|
|
309
|
-
},
|
|
310
|
-
},
|
|
311
|
-
algorand: {
|
|
312
|
-
isAddress(str) {
|
|
313
|
-
return addressValidator.validate(str, 'algo');
|
|
314
|
-
},
|
|
315
|
-
isTxHash(str) {
|
|
316
|
-
return str.length === 52;
|
|
317
|
-
},
|
|
318
|
-
},
|
|
319
|
-
tezos: {
|
|
320
|
-
isAddress(str) {
|
|
321
|
-
return str[0] !== 'o' && addressValidator.validate(str, 'xtz');
|
|
322
|
-
},
|
|
323
|
-
isTxHash(str) {
|
|
324
|
-
return str.length === 51;
|
|
325
|
-
},
|
|
326
|
-
},
|
|
327
|
-
polkadot: {
|
|
328
|
-
isAddress(str) {
|
|
329
|
-
return addressValidator.validate(str, 'dot');
|
|
330
|
-
},
|
|
331
|
-
isTxHash(str) {
|
|
332
|
-
return str.length === 66 && cryptoValidators.isHexStrict(str);
|
|
333
|
-
},
|
|
334
|
-
},
|
|
335
|
-
cardano: {
|
|
336
|
-
isAddress(str) {
|
|
337
|
-
return addressValidator.validate(str, 'ada');
|
|
338
|
-
},
|
|
339
|
-
isTxHash(str) {
|
|
340
|
-
if (!V.isHexadecimal(str)) {
|
|
341
|
-
return false;
|
|
342
|
-
}
|
|
343
|
-
return str.length === 64;
|
|
23
|
+
return typeof str === 'string' && /^[0-9]+$/.test(str);
|
|
344
24
|
},
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
return false;
|
|
353
|
-
}
|
|
354
|
-
return str.length === 64;
|
|
355
|
-
},
|
|
356
|
-
},
|
|
357
|
-
near: {
|
|
358
|
-
isAddress(str) {
|
|
359
|
-
// https://nomicon.io/DataStructures/Account
|
|
360
|
-
return /^(([a-z\d]+[-_])*[a-z\d]+\.)*([a-z\d]+[-_])*[a-z\d]+$/.test(str);
|
|
361
|
-
},
|
|
362
|
-
isTxHash(str) {
|
|
363
|
-
return str.length === 44 || str.length === 43;
|
|
364
|
-
},
|
|
365
|
-
},
|
|
366
|
-
doge: {
|
|
367
|
-
isAddress(str) {
|
|
368
|
-
return /^[a-zA-Z\d]{34}$/.test(str);
|
|
369
|
-
},
|
|
370
|
-
isTxHash(str) {
|
|
371
|
-
return str.length === 64;
|
|
372
|
-
},
|
|
373
|
-
},
|
|
374
|
-
cosmos: {
|
|
375
|
-
isAddress(str) {
|
|
376
|
-
return /^cosmos{1}[a-zA-Z\d]{39}$/.test(str);
|
|
377
|
-
},
|
|
378
|
-
isTxHash(str) {
|
|
379
|
-
return str.length === 64 && cryptoValidators.isHex(str);
|
|
380
|
-
},
|
|
381
|
-
},
|
|
382
|
-
solana: {
|
|
383
|
-
isAddress(str) {
|
|
384
|
-
return /^[1-9A-HJ-NP-Za-km-z]{32,44}$/.test(str);
|
|
385
|
-
},
|
|
386
|
-
isTxHash(str) {
|
|
387
|
-
return /^[1-9A-HJ-NP-Za-km-z]{77,88}$/.test(str);
|
|
388
|
-
},
|
|
389
|
-
},
|
|
390
|
-
binanceSmartChain: {
|
|
391
|
-
isAddress(str) {
|
|
392
|
-
return cryptoValidators.isAddress(str);
|
|
393
|
-
},
|
|
394
|
-
isTxHash(str) {
|
|
395
|
-
return str.length === 66 && cryptoValidators.isHexStrict(str);
|
|
396
|
-
},
|
|
397
|
-
},
|
|
398
|
-
polygon: {
|
|
399
|
-
isAddress(str) {
|
|
400
|
-
return cryptoValidators.isAddress(str);
|
|
401
|
-
},
|
|
402
|
-
isTxHash(str) {
|
|
403
|
-
return str.length === 66 && cryptoValidators.isHexStrict(str);
|
|
404
|
-
},
|
|
405
|
-
},
|
|
406
|
-
filecoin: {
|
|
407
|
-
isAddress(str) {
|
|
408
|
-
return /^(f0|f1|f2|f3)/.test(str);
|
|
409
|
-
},
|
|
410
|
-
isTxHash(str) {
|
|
411
|
-
return str.length === 62 && /^bafy2bza/.test(str);
|
|
412
|
-
},
|
|
413
|
-
},
|
|
414
|
-
optimism: {
|
|
415
|
-
isAddress(str) {
|
|
416
|
-
return cryptoValidators.isAddress(str);
|
|
417
|
-
},
|
|
418
|
-
isTxHash(str) {
|
|
419
|
-
return str.length === 66 && cryptoValidators.isHexStrict(str);
|
|
420
|
-
},
|
|
421
|
-
},
|
|
422
|
-
avalanche: {
|
|
423
|
-
isAddress(str) {
|
|
424
|
-
return cryptoValidators.isAddress(str);
|
|
425
|
-
},
|
|
426
|
-
isTxHash(str) {
|
|
427
|
-
return str.length === 66 && cryptoValidators.isHexStrict(str);
|
|
428
|
-
},
|
|
429
|
-
},
|
|
430
|
-
arbitrum: {
|
|
431
|
-
isAddress(str) {
|
|
432
|
-
return cryptoValidators.isAddress(str);
|
|
25
|
+
};
|
|
26
|
+
const validations = {
|
|
27
|
+
_validate(Err, pred, x, msg) {
|
|
28
|
+
if (pred(x)) {
|
|
29
|
+
return x;
|
|
30
|
+
}
|
|
31
|
+
throw new Err(msg);
|
|
433
32
|
},
|
|
434
|
-
|
|
435
|
-
|
|
33
|
+
_validateArg(pred, x, msg) {
|
|
34
|
+
return this._validate(E.InvalidArguments, pred, x, msg);
|
|
436
35
|
},
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
36
|
+
_tryCheck(fn, arg) {
|
|
37
|
+
try {
|
|
38
|
+
fn(arg);
|
|
39
|
+
return true;
|
|
40
|
+
}
|
|
41
|
+
catch (error) {
|
|
42
|
+
return false;
|
|
43
|
+
}
|
|
441
44
|
},
|
|
442
|
-
|
|
443
|
-
|
|
45
|
+
exists(x) {
|
|
46
|
+
return x != null;
|
|
444
47
|
},
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
isAddress(str) {
|
|
448
|
-
return cryptoValidators.isAddress(str);
|
|
48
|
+
nonEmpty(x) {
|
|
49
|
+
return (x != null ? x.length : undefined) > 0;
|
|
449
50
|
},
|
|
450
|
-
|
|
451
|
-
|
|
51
|
+
isNonEmptyString(x) {
|
|
52
|
+
return _.isString(x) && (x != null ? x.length : undefined) > 0;
|
|
452
53
|
},
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
return cryptoValidators.isAddress(str);
|
|
54
|
+
isSafeString(str) {
|
|
55
|
+
// eslint-disable-next-line no-useless-escape, prefer-regex-literals
|
|
56
|
+
return RegExp(/^(\p{L}|[0-9]|-|=|!|\.|:|\s|@|\+|_|,|\$|£|&)+$/, 'u').test(str);
|
|
457
57
|
},
|
|
458
|
-
|
|
459
|
-
|
|
58
|
+
isAssetSafeString(str) {
|
|
59
|
+
// eslint-disable-next-line no-useless-escape, prefer-regex-literals
|
|
60
|
+
return RegExp(/^(\p{L}|[0-9]|-|=|!|\.|:|\s|@|\+|_|,|\$|£|&|\/)+$/, 'u').test(str);
|
|
460
61
|
},
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
62
|
+
ensureShortEnough(limit, x) {
|
|
63
|
+
const l = x != null ? x.length : undefined;
|
|
64
|
+
if (l <= limit) {
|
|
65
|
+
return true;
|
|
66
|
+
}
|
|
67
|
+
throw new E.BadRequest(`Max query size exceeded: ${l} / ${limit}`);
|
|
465
68
|
},
|
|
466
|
-
|
|
467
|
-
|
|
69
|
+
ensure(crit, msg) {
|
|
70
|
+
if (crit) {
|
|
71
|
+
return true;
|
|
72
|
+
}
|
|
73
|
+
throw new E.BadRequest(msg);
|
|
74
|
+
},
|
|
75
|
+
argExists(x, msg) {
|
|
76
|
+
return this._validateArg(this.exists, x, msg);
|
|
77
|
+
},
|
|
78
|
+
check: {
|
|
79
|
+
matches(required, given, msg) {
|
|
80
|
+
const newGiven = _.uniq(given);
|
|
81
|
+
const crit = _.intersection(newGiven, required).length === given.length;
|
|
82
|
+
if (crit) {
|
|
83
|
+
return true;
|
|
84
|
+
}
|
|
85
|
+
throw new E.BadRequest(msg);
|
|
86
|
+
},
|
|
87
|
+
wasFound(type) {
|
|
88
|
+
return (item) => {
|
|
89
|
+
if (item == null) {
|
|
90
|
+
throw new E.NotFound(`Unknown ${type}`);
|
|
91
|
+
}
|
|
92
|
+
else {
|
|
93
|
+
return item;
|
|
94
|
+
}
|
|
95
|
+
};
|
|
96
|
+
},
|
|
97
|
+
wasCreated(msg) {
|
|
98
|
+
return (arr) => {
|
|
99
|
+
if (!arr[1]) {
|
|
100
|
+
throw new E.BadRequest(msg);
|
|
101
|
+
}
|
|
102
|
+
else {
|
|
103
|
+
return arr;
|
|
104
|
+
}
|
|
105
|
+
};
|
|
106
|
+
},
|
|
107
|
+
isTrue(crit, msg) {
|
|
108
|
+
if (crit) {
|
|
109
|
+
return true;
|
|
110
|
+
}
|
|
111
|
+
throw new E.BadRequest(msg);
|
|
112
|
+
},
|
|
113
|
+
isFalse(crit, msg) {
|
|
114
|
+
if (!crit) {
|
|
115
|
+
return true;
|
|
116
|
+
}
|
|
117
|
+
throw new E.BadRequest(msg);
|
|
118
|
+
},
|
|
119
|
+
},
|
|
120
|
+
isCustomerReference(x) {
|
|
121
|
+
return _.isString(x) && (x != null ? x.length : undefined) > 0 && (x != null ? x.length : undefined) <= 100;
|
|
122
|
+
},
|
|
123
|
+
isCustomerLabelName(x) {
|
|
124
|
+
return _.isString(x) && (x != null ? x.length : undefined) > 0 && (x != null ? x.length : undefined) <= 50;
|
|
125
|
+
},
|
|
126
|
+
binanceChain: {
|
|
127
|
+
isAddress(str) {
|
|
128
|
+
return /^(bnb)([a-z0-9]{39})$/.test(str);
|
|
129
|
+
},
|
|
130
|
+
isTxHash(str) {
|
|
131
|
+
if (!V.isHexadecimal(str)) {
|
|
132
|
+
return false;
|
|
133
|
+
}
|
|
134
|
+
return str.length === 64;
|
|
135
|
+
},
|
|
136
|
+
},
|
|
137
|
+
bitcoin: {
|
|
138
|
+
isAddress(str, asset) {
|
|
139
|
+
if (asset === 'lightning') {
|
|
140
|
+
return validations.isNonEmptyString(str);
|
|
141
|
+
}
|
|
142
|
+
return typeof str === 'string' && addressValidator.validate(str.trim(), 'btc', 'prod');
|
|
143
|
+
},
|
|
144
|
+
isTxHash(str) {
|
|
145
|
+
if (!V.isHexadecimal(str)) {
|
|
146
|
+
return false;
|
|
147
|
+
}
|
|
148
|
+
return str.length === 64;
|
|
149
|
+
},
|
|
150
|
+
},
|
|
151
|
+
bitcoinCash: {
|
|
152
|
+
isAddress(str) {
|
|
153
|
+
return /^[13][a-km-zA-HJ-NP-Z1-9]{25,34}$|^(bitcoincash:)?[q|p][a-z0-9]{41}$|^(BITCOINCASH:)?[Q|P][A-Z0-9]{41}$/.test(str);
|
|
154
|
+
},
|
|
155
|
+
isTxHash(str) {
|
|
156
|
+
if (!V.isHexadecimal(str)) {
|
|
157
|
+
return false;
|
|
158
|
+
}
|
|
159
|
+
return str.length === 64;
|
|
160
|
+
},
|
|
161
|
+
},
|
|
162
|
+
ethereum: {
|
|
163
|
+
isAddress(str) {
|
|
164
|
+
return cryptoValidators.isAddress(str);
|
|
165
|
+
},
|
|
166
|
+
isBlockHash(str) {
|
|
167
|
+
return str.length === 66 && cryptoValidators.isHexStrict(str);
|
|
168
|
+
},
|
|
169
|
+
isTxHash(str) {
|
|
170
|
+
return str.length === 66 && cryptoValidators.isHexStrict(str);
|
|
171
|
+
},
|
|
172
|
+
isAddressCode(str) {
|
|
173
|
+
return cryptoValidators.isHexStrict(str);
|
|
174
|
+
},
|
|
175
|
+
isValidWeiAmount(str) {
|
|
176
|
+
return cryptoValidators.isValidWeiAmount(str);
|
|
177
|
+
},
|
|
178
|
+
},
|
|
179
|
+
horizen: {
|
|
180
|
+
isAddress(str) {
|
|
181
|
+
return addressValidator.validate(str, 'zen');
|
|
182
|
+
},
|
|
183
|
+
isTxHash(str) {
|
|
184
|
+
if (!V.isHexadecimal(str)) {
|
|
185
|
+
return false;
|
|
186
|
+
}
|
|
187
|
+
return str.length === 64;
|
|
188
|
+
},
|
|
189
|
+
},
|
|
190
|
+
litecoin: {
|
|
191
|
+
isAddress(str) {
|
|
192
|
+
return /^[3LM][a-km-zA-HJ-NP-Z1-9]{24,33}$|^ltc1[ac-hj-np-z02-9]{6,86}$|^LTC1[AC-HJ-NP-Z02-9]{6,86}$|^ltcmweb[a-zA-Z0-9]{114}$/.test(str);
|
|
193
|
+
},
|
|
194
|
+
isTxHash(str) {
|
|
195
|
+
if (!V.isHexadecimal(str)) {
|
|
196
|
+
return false;
|
|
197
|
+
}
|
|
198
|
+
return str.length === 64;
|
|
199
|
+
},
|
|
200
|
+
},
|
|
201
|
+
ripple: {
|
|
202
|
+
isAddress(str) {
|
|
203
|
+
return addressValidator.validate(str, 'xrp');
|
|
204
|
+
},
|
|
205
|
+
isTxHash(str) {
|
|
206
|
+
if (!V.isHexadecimal(str)) {
|
|
207
|
+
return false;
|
|
208
|
+
}
|
|
209
|
+
return str.length === 64;
|
|
210
|
+
},
|
|
211
|
+
},
|
|
212
|
+
stellar: {
|
|
213
|
+
isAddress(str) {
|
|
214
|
+
return stellarBase.StrKey.isValidEd25519PublicKey(str);
|
|
215
|
+
},
|
|
216
|
+
isTxHash(str) {
|
|
217
|
+
if (!V.isHexadecimal(str)) {
|
|
218
|
+
return false;
|
|
219
|
+
}
|
|
220
|
+
return str.length === 64;
|
|
221
|
+
},
|
|
222
|
+
},
|
|
223
|
+
zcash: {
|
|
224
|
+
isAddress(str) {
|
|
225
|
+
return addressValidator.validate(str, 'zec');
|
|
226
|
+
},
|
|
227
|
+
isTxHash(str) {
|
|
228
|
+
if (!V.isHexadecimal(str)) {
|
|
229
|
+
return false;
|
|
230
|
+
}
|
|
231
|
+
return str.length === 64;
|
|
232
|
+
},
|
|
233
|
+
},
|
|
234
|
+
zilliqa: {
|
|
235
|
+
isAddress(str) {
|
|
236
|
+
// https://pub.dev/documentation/laksadart/latest/laksadart/isBech32.html
|
|
237
|
+
return !!str.match(/^zil1[qpzry9x8gf2tvdw0s3jn54khce6mua7l]{38}$/);
|
|
238
|
+
},
|
|
239
|
+
isTxHash(str) {
|
|
240
|
+
return str.length === 66 && cryptoValidators.isHexStrict(str);
|
|
241
|
+
},
|
|
242
|
+
},
|
|
243
|
+
algorand: {
|
|
244
|
+
isAddress(str) {
|
|
245
|
+
return addressValidator.validate(str, 'algo');
|
|
246
|
+
},
|
|
247
|
+
isTxHash(str) {
|
|
248
|
+
return str.length === 52;
|
|
249
|
+
},
|
|
250
|
+
},
|
|
251
|
+
tezos: {
|
|
252
|
+
isAddress(str) {
|
|
253
|
+
return str[0] !== 'o' && addressValidator.validate(str, 'xtz');
|
|
254
|
+
},
|
|
255
|
+
isTxHash(str) {
|
|
256
|
+
return str.length === 51;
|
|
257
|
+
},
|
|
258
|
+
},
|
|
259
|
+
polkadot: {
|
|
260
|
+
isAddress(str) {
|
|
261
|
+
return addressValidator.validate(str, 'dot');
|
|
262
|
+
},
|
|
263
|
+
isTxHash(str) {
|
|
264
|
+
return str.length === 66 && cryptoValidators.isHexStrict(str);
|
|
265
|
+
},
|
|
266
|
+
},
|
|
267
|
+
cardano: {
|
|
268
|
+
isAddress(str) {
|
|
269
|
+
return addressValidator.validate(str, 'ada');
|
|
270
|
+
},
|
|
271
|
+
isTxHash(str) {
|
|
272
|
+
if (!V.isHexadecimal(str)) {
|
|
273
|
+
return false;
|
|
274
|
+
}
|
|
275
|
+
return str.length === 64;
|
|
276
|
+
},
|
|
277
|
+
},
|
|
278
|
+
cryptocom: {
|
|
279
|
+
isAddress(str) {
|
|
280
|
+
return addressValidator.validate(str, 'cro');
|
|
281
|
+
},
|
|
282
|
+
isTxHash(str) {
|
|
283
|
+
if (!V.isHexadecimal(str)) {
|
|
284
|
+
return false;
|
|
285
|
+
}
|
|
286
|
+
return str.length === 64;
|
|
287
|
+
},
|
|
288
|
+
},
|
|
289
|
+
near: {
|
|
290
|
+
isAddress(str) {
|
|
291
|
+
// https://nomicon.io/DataStructures/Account
|
|
292
|
+
return /^(([a-z\d]+[-_])*[a-z\d]+\.)*([a-z\d]+[-_])*[a-z\d]+$/.test(str);
|
|
293
|
+
},
|
|
294
|
+
isTxHash(str) {
|
|
295
|
+
return str.length === 44 || str.length === 43;
|
|
296
|
+
},
|
|
297
|
+
},
|
|
298
|
+
doge: {
|
|
299
|
+
isAddress(str) {
|
|
300
|
+
return /^[a-zA-Z\d]{34}$/.test(str);
|
|
301
|
+
},
|
|
302
|
+
isTxHash(str) {
|
|
303
|
+
return str.length === 64;
|
|
304
|
+
},
|
|
305
|
+
},
|
|
306
|
+
cosmos: {
|
|
307
|
+
isAddress(str) {
|
|
308
|
+
return /^cosmos{1}[a-zA-Z\d]{39}$/.test(str);
|
|
309
|
+
},
|
|
310
|
+
isTxHash(str) {
|
|
311
|
+
return str.length === 64 && cryptoValidators.isHex(str);
|
|
312
|
+
},
|
|
313
|
+
},
|
|
314
|
+
solana: {
|
|
315
|
+
isAddress(str) {
|
|
316
|
+
return /^[1-9A-HJ-NP-Za-km-z]{32,44}$/.test(str);
|
|
317
|
+
},
|
|
318
|
+
isTxHash(str) {
|
|
319
|
+
return /^[1-9A-HJ-NP-Za-km-z]{77,88}$/.test(str);
|
|
320
|
+
},
|
|
321
|
+
},
|
|
322
|
+
binanceSmartChain: {
|
|
323
|
+
isAddress(str) {
|
|
324
|
+
return cryptoValidators.isAddress(str);
|
|
325
|
+
},
|
|
326
|
+
isTxHash(str) {
|
|
327
|
+
return str.length === 66 && cryptoValidators.isHexStrict(str);
|
|
328
|
+
},
|
|
329
|
+
},
|
|
330
|
+
polygon: {
|
|
331
|
+
isAddress(str) {
|
|
332
|
+
return cryptoValidators.isAddress(str);
|
|
333
|
+
},
|
|
334
|
+
isTxHash(str) {
|
|
335
|
+
return str.length === 66 && cryptoValidators.isHexStrict(str);
|
|
336
|
+
},
|
|
337
|
+
},
|
|
338
|
+
filecoin: {
|
|
339
|
+
isAddress(str) {
|
|
340
|
+
return /^(f0|f1|f2|f3)/.test(str);
|
|
341
|
+
},
|
|
342
|
+
isTxHash(str) {
|
|
343
|
+
return str.length === 62 && /^bafy2bza/.test(str);
|
|
344
|
+
},
|
|
345
|
+
},
|
|
346
|
+
optimism: {
|
|
347
|
+
isAddress(str) {
|
|
348
|
+
return cryptoValidators.isAddress(str);
|
|
349
|
+
},
|
|
350
|
+
isTxHash(str) {
|
|
351
|
+
return str.length === 66 && cryptoValidators.isHexStrict(str);
|
|
352
|
+
},
|
|
353
|
+
},
|
|
354
|
+
avalanche: {
|
|
355
|
+
isAddress(str) {
|
|
356
|
+
return cryptoValidators.isAddress(str);
|
|
357
|
+
},
|
|
358
|
+
isTxHash(str) {
|
|
359
|
+
return str.length === 66 && cryptoValidators.isHexStrict(str);
|
|
360
|
+
},
|
|
361
|
+
},
|
|
362
|
+
arbitrum: {
|
|
363
|
+
isAddress(str) {
|
|
364
|
+
return cryptoValidators.isAddress(str);
|
|
365
|
+
},
|
|
366
|
+
isTxHash(str) {
|
|
367
|
+
return str.length === 66 && cryptoValidators.isHexStrict(str);
|
|
368
|
+
},
|
|
369
|
+
},
|
|
370
|
+
tron: {
|
|
371
|
+
isAddress(str) {
|
|
372
|
+
return addressValidator.validate(str, 'tron');
|
|
373
|
+
},
|
|
374
|
+
isTxHash(str) {
|
|
375
|
+
return str.length === 64 && cryptoValidators.isHex(str);
|
|
376
|
+
},
|
|
377
|
+
},
|
|
378
|
+
fantom: {
|
|
379
|
+
isAddress(str) {
|
|
380
|
+
return cryptoValidators.isAddress(str);
|
|
381
|
+
},
|
|
382
|
+
isTxHash(str) {
|
|
383
|
+
return str.length === 66 && cryptoValidators.isHexStrict(str);
|
|
384
|
+
},
|
|
385
|
+
},
|
|
386
|
+
celo: {
|
|
387
|
+
isAddress(str) {
|
|
388
|
+
return cryptoValidators.isAddress(str);
|
|
389
|
+
},
|
|
390
|
+
isTxHash(str) {
|
|
391
|
+
return str.length === 66 && cryptoValidators.isHexStrict(str);
|
|
392
|
+
},
|
|
393
|
+
},
|
|
394
|
+
ethereumClassic: {
|
|
395
|
+
isAddress(str) {
|
|
396
|
+
return cryptoValidators.isAddress(str);
|
|
397
|
+
},
|
|
398
|
+
isTxHash(str) {
|
|
399
|
+
return str.length === 66 && cryptoValidators.isHexStrict(str);
|
|
400
|
+
},
|
|
401
|
+
},
|
|
402
|
+
mobilecoin: {
|
|
403
|
+
isAddress(str) {
|
|
404
|
+
return str.length === 24 && /^[A-Za-z0-9+/]+={0,2}$/.test(str);
|
|
405
|
+
},
|
|
406
|
+
isTxHash(str) {
|
|
407
|
+
return str.length === 64 && cryptoValidators.isHex(str);
|
|
408
|
+
},
|
|
409
|
+
},
|
|
410
|
+
sui: {
|
|
411
|
+
isAddress(str) {
|
|
412
|
+
return str.length === 66 && /^[A-Za-z0-9+/]+$/.test(str);
|
|
413
|
+
},
|
|
414
|
+
isTxHash(str) {
|
|
415
|
+
return str.length === 44;
|
|
416
|
+
},
|
|
417
|
+
},
|
|
418
|
+
flare: {
|
|
419
|
+
isAddress(str) {
|
|
420
|
+
return str.length === 42 && /^[A-Za-z0-9+/]+$/.test(str);
|
|
421
|
+
},
|
|
422
|
+
isTxHash(str) {
|
|
423
|
+
return str.length === 66;
|
|
424
|
+
},
|
|
425
|
+
},
|
|
426
|
+
ton: {
|
|
427
|
+
isAddress(str) {
|
|
428
|
+
return /^[A-Za-z0-9+/]{64}$/.test(str);
|
|
429
|
+
},
|
|
430
|
+
isTxHash(str) {
|
|
431
|
+
return /^[A-Za-z0-9+/]{64}$/.test(str);
|
|
432
|
+
},
|
|
433
|
+
},
|
|
434
|
+
gnosis: {
|
|
435
|
+
isAddress(str) {
|
|
436
|
+
return cryptoValidators.isAddress(str);
|
|
437
|
+
},
|
|
438
|
+
isTxHash(str) {
|
|
439
|
+
return str.length === 66 && cryptoValidators.isHexStrict(str);
|
|
440
|
+
},
|
|
441
|
+
},
|
|
442
|
+
dydx: {
|
|
443
|
+
isAddress(str) {
|
|
444
|
+
return /^[a-z]+1[a-zA-Z0-9]{38}$/.test(str) || str === 'dydx_chain';
|
|
445
|
+
},
|
|
446
|
+
isTxHash(str) {
|
|
447
|
+
return str.length === 64 && cryptoValidators.isHex(str);
|
|
448
|
+
},
|
|
449
|
+
},
|
|
450
|
+
hederaHashgraph: {
|
|
451
|
+
isAddress(str) {
|
|
452
|
+
return /^\d+\.\d+\.\d+$/.test(str);
|
|
453
|
+
},
|
|
454
|
+
isTxHash(str) {
|
|
455
|
+
return /^[xa-f0-9+/]{98}$/.test(str);
|
|
456
|
+
},
|
|
457
|
+
},
|
|
458
|
+
aptos: {
|
|
459
|
+
isAddress(str) {
|
|
460
|
+
return str.length <= 66 && cryptoValidators.isHex(str);
|
|
461
|
+
},
|
|
462
|
+
isTxHash(str) {
|
|
463
|
+
return cryptoValidators.isHex(str);
|
|
464
|
+
},
|
|
465
|
+
},
|
|
466
|
+
zksync: {
|
|
467
|
+
isAddress(str) {
|
|
468
|
+
return cryptoValidators.isAddress(str);
|
|
469
|
+
},
|
|
470
|
+
isTxHash(str) {
|
|
471
|
+
return str.length === 66 && cryptoValidators.isHexStrict(str);
|
|
472
|
+
},
|
|
473
|
+
},
|
|
474
|
+
haqq: {
|
|
475
|
+
isAddress(str) {
|
|
476
|
+
return cryptoValidators.isAddress(str);
|
|
477
|
+
},
|
|
478
|
+
isTxHash(str) {
|
|
479
|
+
return str.length === 64 && cryptoValidators.isHex(str);
|
|
480
|
+
},
|
|
481
|
+
},
|
|
482
|
+
base: {
|
|
483
|
+
isAddress(str) {
|
|
484
|
+
return cryptoValidators.isAddress(str);
|
|
485
|
+
},
|
|
486
|
+
isTxHash(str) {
|
|
487
|
+
return str.length === 66 && cryptoValidators.isHexStrict(str);
|
|
488
|
+
},
|
|
489
|
+
},
|
|
490
|
+
corechain: {
|
|
491
|
+
isAddress(str) {
|
|
492
|
+
return cryptoValidators.isAddress(str);
|
|
493
|
+
},
|
|
494
|
+
isTxHash(str) {
|
|
495
|
+
return str.length === 66 && cryptoValidators.isHexStrict(str);
|
|
496
|
+
},
|
|
497
|
+
},
|
|
498
|
+
worldchain: {
|
|
499
|
+
isAddress(str) {
|
|
500
|
+
return cryptoValidators.isAddress(str);
|
|
501
|
+
},
|
|
502
|
+
isTxHash(str) {
|
|
503
|
+
return str.length === 66 && cryptoValidators.isHexStrict(str);
|
|
504
|
+
},
|
|
505
|
+
},
|
|
506
|
+
injective: {
|
|
507
|
+
isAddress(str) {
|
|
508
|
+
return /^[a-z0-9]+$/i.test(str);
|
|
509
|
+
},
|
|
510
|
+
isTxHash(str) {
|
|
511
|
+
return str.length === 64 && cryptoValidators.isHex(str);
|
|
512
|
+
},
|
|
513
|
+
},
|
|
514
|
+
linea: {
|
|
515
|
+
isAddress(str) {
|
|
516
|
+
return cryptoValidators.isAddress(str);
|
|
517
|
+
},
|
|
518
|
+
isTxHash(str) {
|
|
519
|
+
return str.length === 66 && cryptoValidators.isHexStrict(str);
|
|
520
|
+
},
|
|
521
|
+
},
|
|
522
|
+
xdc: {
|
|
523
|
+
isAddress(str) {
|
|
524
|
+
return cryptoValidators.isAddress(str);
|
|
525
|
+
},
|
|
526
|
+
isTxHash(str) {
|
|
527
|
+
return str.length === 66 && cryptoValidators.isHexStrict(str);
|
|
528
|
+
},
|
|
529
|
+
},
|
|
530
|
+
internetcomputer: {
|
|
531
|
+
isAddress(str) {
|
|
532
|
+
return cryptoValidators.isHex(str);
|
|
533
|
+
},
|
|
534
|
+
isTxHash(str) {
|
|
535
|
+
return cryptoValidators.isHex(str);
|
|
536
|
+
},
|
|
537
|
+
},
|
|
538
|
+
unichain: {
|
|
539
|
+
isAddress(str) {
|
|
540
|
+
return cryptoValidators.isAddress(str);
|
|
541
|
+
},
|
|
542
|
+
isTxHash(str) {
|
|
543
|
+
return str.length === 66 && cryptoValidators.isHexStrict(str);
|
|
544
|
+
},
|
|
545
|
+
},
|
|
546
|
+
sei: {
|
|
547
|
+
isAddress(str) {
|
|
548
|
+
return /^[a-z0-9]+$/i.test(str);
|
|
549
|
+
},
|
|
550
|
+
isTxHash(str) {
|
|
551
|
+
return (str.length === 64 && cryptoValidators.isHex(str)) || (str.length === 66 && cryptoValidators.isHexStrict(str));
|
|
552
|
+
},
|
|
553
|
+
},
|
|
554
|
+
bittensor: {
|
|
555
|
+
isAddress(str) {
|
|
556
|
+
return addressValidator.validate(str, 'dot');
|
|
557
|
+
},
|
|
558
|
+
isTxHash(str) {
|
|
559
|
+
return str.length === 66 && cryptoValidators.isHexStrict(str);
|
|
560
|
+
},
|
|
561
|
+
},
|
|
562
|
+
codex: {
|
|
563
|
+
isAddress(str) {
|
|
564
|
+
return cryptoValidators.isAddress(str);
|
|
565
|
+
},
|
|
566
|
+
isTxHash(str) {
|
|
567
|
+
return str.length === 66 && cryptoValidators.isHexStrict(str);
|
|
568
|
+
},
|
|
569
|
+
},
|
|
570
|
+
mantra: {
|
|
571
|
+
isAddress(str) {
|
|
572
|
+
return /^[a-z0-9]+$/i.test(str);
|
|
573
|
+
},
|
|
574
|
+
isTxHash(str) {
|
|
575
|
+
return str.length === 64 && cryptoValidators.isHex(str);
|
|
576
|
+
},
|
|
577
|
+
},
|
|
578
|
+
nillion: {
|
|
579
|
+
isAddress(str) {
|
|
580
|
+
return /^[a-z0-9]+$/i.test(str);
|
|
581
|
+
},
|
|
582
|
+
isTxHash(str) {
|
|
583
|
+
return str.length === 64 && cryptoValidators.isHex(str);
|
|
584
|
+
},
|
|
585
|
+
},
|
|
586
|
+
canton: {
|
|
587
|
+
isAddress(str) {
|
|
588
|
+
return str.length > 1;
|
|
589
|
+
},
|
|
590
|
+
isTxHash(str) {
|
|
591
|
+
return cryptoValidators.isHex(str) && str.length === 68;
|
|
592
|
+
},
|
|
593
|
+
},
|
|
594
|
+
starknet: {
|
|
595
|
+
isAddress(str) {
|
|
596
|
+
return cryptoValidators.isHex(str);
|
|
597
|
+
},
|
|
598
|
+
isTxHash(str) {
|
|
599
|
+
return cryptoValidators.isHex(str);
|
|
600
|
+
},
|
|
601
|
+
},
|
|
602
|
+
noble: {
|
|
603
|
+
isAddress(str) {
|
|
604
|
+
return /^[a-z0-9]+$/i.test(str);
|
|
605
|
+
},
|
|
606
|
+
isTxHash(str) {
|
|
607
|
+
return str.length === 64 && cryptoValidators.isHex(str);
|
|
608
|
+
},
|
|
609
|
+
},
|
|
610
|
+
assethub: {
|
|
611
|
+
isAddress(str) {
|
|
612
|
+
return addressValidator.validate(str, 'dot');
|
|
613
|
+
},
|
|
614
|
+
isTxHash(str) {
|
|
615
|
+
return str.length === 66 && cryptoValidators.isHexStrict(str);
|
|
616
|
+
},
|
|
617
|
+
},
|
|
618
|
+
plasma: {
|
|
619
|
+
isAddress(str) {
|
|
620
|
+
return cryptoValidators.isAddress(str);
|
|
621
|
+
},
|
|
622
|
+
isTxHash(str) {
|
|
623
|
+
return str.length === 66 && cryptoValidators.isHexStrict(str);
|
|
624
|
+
},
|
|
625
|
+
},
|
|
626
|
+
ink: {
|
|
627
|
+
isAddress(str) {
|
|
628
|
+
return cryptoValidators.isAddress(str);
|
|
629
|
+
},
|
|
630
|
+
isTxHash(str) {
|
|
631
|
+
return str.length === 66 && cryptoValidators.isHexStrict(str);
|
|
632
|
+
},
|
|
633
|
+
},
|
|
634
|
+
xlayer: {
|
|
635
|
+
isAddress(str) {
|
|
636
|
+
return cryptoValidators.isAddress(str);
|
|
637
|
+
},
|
|
638
|
+
isTxHash(str) {
|
|
639
|
+
return str.length === 66 && cryptoValidators.isHexStrict(str);
|
|
640
|
+
},
|
|
641
|
+
},
|
|
642
|
+
monad: {
|
|
643
|
+
isAddress(str) {
|
|
644
|
+
return cryptoValidators.isAddress(str);
|
|
645
|
+
},
|
|
646
|
+
isTxHash(str) {
|
|
647
|
+
return str.length === 66 && cryptoValidators.isHexStrict(str);
|
|
648
|
+
},
|
|
649
|
+
},
|
|
650
|
+
hyperevm: {
|
|
651
|
+
isAddress(str) {
|
|
652
|
+
return cryptoValidators.isAddress(str);
|
|
653
|
+
},
|
|
654
|
+
isTxHash(str) {
|
|
655
|
+
return str.length === 66 && cryptoValidators.isHexStrict(str);
|
|
656
|
+
},
|
|
657
|
+
},
|
|
658
|
+
tempo: {
|
|
659
|
+
isAddress(str) {
|
|
660
|
+
return cryptoValidators.isAddress(str);
|
|
661
|
+
},
|
|
662
|
+
isTxHash(str) {
|
|
663
|
+
return str.length === 66 && cryptoValidators.isHexStrict(str);
|
|
664
|
+
},
|
|
665
|
+
},
|
|
666
|
+
morph: {
|
|
667
|
+
isAddress(str) {
|
|
668
|
+
return cryptoValidators.isAddress(str);
|
|
669
|
+
},
|
|
670
|
+
isTxHash(str) {
|
|
671
|
+
return str.length === 66 && cryptoValidators.isHexStrict(str);
|
|
672
|
+
},
|
|
673
|
+
},
|
|
674
|
+
etherlink: {
|
|
675
|
+
isAddress(str) {
|
|
676
|
+
return cryptoValidators.isAddress(str);
|
|
677
|
+
},
|
|
678
|
+
isTxHash(str) {
|
|
679
|
+
return str.length === 66 && cryptoValidators.isHexStrict(str);
|
|
680
|
+
},
|
|
681
|
+
},
|
|
682
|
+
edgex: {
|
|
683
|
+
isAddress(str) {
|
|
684
|
+
return cryptoValidators.isAddress(str);
|
|
685
|
+
},
|
|
686
|
+
isTxHash(str) {
|
|
687
|
+
return str.length === 66 && cryptoValidators.isHexStrict(str);
|
|
688
|
+
},
|
|
468
689
|
},
|
|
469
|
-
},
|
|
470
690
|
};
|
|
471
|
-
|
|
472
691
|
Object.keys(V).forEach((k) => {
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
692
|
+
const v = V[k];
|
|
693
|
+
// don't trigger validation with null values (prevents swagger 500 error)
|
|
694
|
+
validations[k] = (x) => (x === null ? false : v(x));
|
|
476
695
|
});
|
|
477
|
-
|
|
478
696
|
module.exports = validations;
|
|
697
|
+
//# sourceMappingURL=validations.js.map
|