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