@ellipticltd/aml-utils 0.15.20 → 0.15.21

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.
Files changed (67) hide show
  1. package/lib/errors/errors.d.ts +9 -0
  2. package/lib/errors/errors.js +19 -30
  3. package/lib/errors/errors.js.map +1 -0
  4. package/lib/file-parser/errors.d.ts +3 -0
  5. package/lib/file-parser/errors.js +11 -0
  6. package/lib/file-parser/errors.js.map +1 -0
  7. package/lib/file-parser/file-parser.d.ts +6 -0
  8. package/lib/file-parser/file-parser.js +60 -0
  9. package/lib/file-parser/file-parser.js.map +1 -0
  10. package/lib/file-parser/parse-row.d.ts +2 -0
  11. package/lib/file-parser/parse-row.js +40 -0
  12. package/lib/file-parser/parse-row.js.map +1 -0
  13. package/lib/file-parser/sanitizeRows.d.ts +5 -0
  14. package/lib/file-parser/sanitizeRows.js +15 -0
  15. package/lib/file-parser/sanitizeRows.js.map +1 -0
  16. package/lib/formatting/formatting.d.ts +2 -0
  17. package/lib/formatting/formatting.js +11 -12
  18. package/lib/formatting/formatting.js.map +1 -0
  19. package/lib/{index.ts → index.d.ts} +0 -1
  20. package/lib/index.js +21 -0
  21. package/lib/index.js.map +1 -0
  22. package/lib/middleware/middleware.d.ts +4 -0
  23. package/lib/middleware/middleware.js +14 -17
  24. package/lib/middleware/middleware.js.map +1 -0
  25. package/lib/orm-helpers/ormHelpers.d.ts +1 -0
  26. package/lib/orm-helpers/ormHelpers.js +7 -9
  27. package/lib/orm-helpers/ormHelpers.js.map +1 -0
  28. package/lib/structured-file-parser/errors.d.ts +12 -0
  29. package/lib/structured-file-parser/errors.js +33 -0
  30. package/lib/structured-file-parser/errors.js.map +1 -0
  31. package/lib/structured-file-parser/parse-row.d.ts +2 -0
  32. package/lib/structured-file-parser/parse-row.js +40 -0
  33. package/lib/structured-file-parser/parse-row.js.map +1 -0
  34. package/lib/structured-file-parser/sanitize-rows.d.ts +2 -0
  35. package/lib/structured-file-parser/sanitize-rows.js +14 -0
  36. package/lib/structured-file-parser/sanitize-rows.js.map +1 -0
  37. package/lib/structured-file-parser/structured-file-parser.d.ts +10 -0
  38. package/lib/structured-file-parser/structured-file-parser.js +96 -0
  39. package/lib/structured-file-parser/structured-file-parser.js.map +1 -0
  40. package/lib/types/types.d.ts +11 -0
  41. package/lib/types/types.js +190 -200
  42. package/lib/types/types.js.map +1 -0
  43. package/lib/validations/validations.d.ts +159 -0
  44. package/lib/validations/validations.js +460 -465
  45. package/lib/validations/validations.js.map +1 -0
  46. package/package.json +15 -1
  47. package/.eslintrc.js +0 -22
  48. package/dist/libs/aml-utils/libs/aml-utils/README.md +0 -19
  49. package/jest.config.ts +0 -13
  50. package/lib/errors/errors.spec.js +0 -49
  51. package/lib/file-parser/__tests/parse-row.spec.js +0 -34
  52. package/lib/file-parser/__tests/sanitize-rows.spec.js +0 -85
  53. package/lib/file-parser/errors.ts +0 -6
  54. package/lib/file-parser/file-parser.ts +0 -67
  55. package/lib/file-parser/parse-row.ts +0 -46
  56. package/lib/file-parser/sanitizeRows.ts +0 -22
  57. package/lib/formatting/formatting.spec.js +0 -47
  58. package/lib/orm-helpers/ormHelpers.spec.js +0 -47
  59. package/lib/structured-file-parser/errors.ts +0 -25
  60. package/lib/structured-file-parser/parse-row.ts +0 -46
  61. package/lib/structured-file-parser/sanitize-rows.ts +0 -17
  62. package/lib/structured-file-parser/structured-file-parser.ts +0 -129
  63. package/lib/validations/validations.spec.js +0 -869
  64. package/project.json +0 -55
  65. package/tsconfig.json +0 -13
  66. package/tsconfig.lib.json +0 -13
  67. package/tsconfig.spec.json +0 -10
@@ -1,869 +0,0 @@
1
- import validations from './validations';
2
-
3
- describe('Validations', () => {
4
- describe('global checks', () => {
5
- describe('exists', () => {
6
- it('should return true when passed any value', () => expect(validations.exists('x')).toEqual(true));
7
-
8
- it('should return false when not passed a value', () => expect(validations.exists()).toEqual(false));
9
- });
10
-
11
- describe('nonEmpty', () => {
12
- it('should return true when passed any value with a length', () =>
13
- expect(validations.nonEmpty('x')).toEqual(true) && validations.nonEmpty(['x']));
14
-
15
- it('should return false when passed a value without a length', () =>
16
- expect(validations.nonEmpty()).toEqual(false) &&
17
- expect(validations.nonEmpty({})).toEqual(false) &&
18
- expect(validations.nonEmpty(null)).toEqual(false) &&
19
- expect(validations.nonEmpty(undefined)).toEqual(false));
20
- });
21
-
22
- describe('isNonEmptyString', () => {
23
- it('should return true when passed a string of any length', () =>
24
- expect(validations.isNonEmptyString('x')).toEqual(true) &&
25
- expect(
26
- validations.isNonEmptyString(
27
- 'Do not go gentle into that good night, Old age should burn and rage at close of day; Rage, rage against the dying of the light.'
28
- )
29
- ).toEqual(true));
30
-
31
- it('should return false when passed an empty string or something that is not a string', () =>
32
- expect(validations.isNonEmptyString('')).toEqual(false) &&
33
- expect(validations.isNonEmptyString(['x'])).toEqual(false) &&
34
- expect(validations.isNonEmptyString({ key: 'val' })).toEqual(false));
35
- });
36
-
37
- describe('ensureShortEnough', () => {
38
- it('should return true when the given string is shorter in length than the given length', () =>
39
- expect(validations.ensureShortEnough(3, 'foo')).toEqual(true) && expect(validations.ensureShortEnough(3, 'fo')).toEqual(true));
40
-
41
- it('should throw a BadRequest error if the given string is longer than the given length', () => {
42
- expect(() => validations.ensureShortEnough(3, 'foo!')).toThrow('Max query size exceeded: 4 / 3');
43
- });
44
-
45
- it('should throw a BadRequest error if the given string is null or undefined', () => {
46
- expect(() => validations.ensureShortEnough(3, null)).toThrow('Max query size exceeded: undefined / 3');
47
- expect(() => validations.ensureShortEnough(3, undefined)).toThrow('Max query size exceeded: undefined / 3');
48
- });
49
- });
50
-
51
- describe('ensure', () => {
52
- it('should return true if the first argument is not null or undefined', () =>
53
- expect(validations.ensure('thing', 'Error message')).toEqual(true) &&
54
- expect(validations.ensure(['array'], 'Error message')).toEqual(true) &&
55
- expect(validations.ensure({ key: 'val' })).toEqual(true));
56
- it('should throw a BadRequest error if the first argument is null or undefined', () => {
57
- expect(() => validations.ensure(null, 'Error message').toThrow('Error message'));
58
- expect(() => validations.ensure(undefined, 'Error message').toThrow('Error message'));
59
- });
60
- });
61
- describe('isSafeString', () => {
62
- it('should return true if the first argument is a safe string', () => {
63
- expect(validations.isSafeString('aaaaa')).toEqual(true);
64
- expect(validations.isSafeString('Customer reference')).toEqual(true);
65
- expect(validations.isSafeString('Safe-String-01827!@')).toEqual(true);
66
- expect(validations.isSafeString('NewSafeCharacters $ £ & - $')).toEqual(true);
67
- });
68
- it('should return false if the first argument is not a safe string', () => {
69
- expect(validations.isSafeString('{customer}')).toEqual(false);
70
- expect(validations.isSafeString('<string>')).toEqual(false);
71
- });
72
- });
73
- describe('isAssetSafeString', () => {
74
- it('should return true if the first argument is a safe string', () => {
75
- expect(validations.isAssetSafeString('aaaaa')).toEqual(true);
76
- expect(validations.isAssetSafeString('Customer reference')).toEqual(true);
77
- expect(validations.isAssetSafeString('Safe-String-01827!@')).toEqual(true);
78
- expect(validations.isAssetSafeString('tRMEp/nPBdH76nQtomHxbw==')).toEqual(true);
79
- });
80
- it('should return false if the first argument is not a safe string', () => {
81
- expect(validations.isAssetSafeString('{customer}')).toEqual(false);
82
- expect(validations.isAssetSafeString('<string>')).toEqual(false);
83
- });
84
- });
85
- });
86
-
87
- describe('check', () => {
88
- describe('matches', () => {
89
- it('should return true when passed two arrays that exactly match', () =>
90
- expect(validations.check.matches([1, 2, 3, 4, 5], [1, 2, 3, 4, 5], 'error message')).toEqual(true));
91
-
92
- it('should throw an error when passed two arrays that do not exactly match', () => {
93
- expect(() => validations.check.matches([1, 2, 3, 4], [1, 2, 3, 4, 5], 'Error message').toThrow('Error message'));
94
- });
95
- });
96
-
97
- describe('wasFound', () => {
98
- it('should return the string passed if this is not null', () => {
99
- expect(validations.check.wasFound()('string')).toEqual('string');
100
- });
101
- it('should throw an error if the item is null', () => {
102
- expect(() => validations.check.wasFound('no value')()).toThrow('Unknown no value');
103
- });
104
- });
105
-
106
- describe('wasCreated', () => {
107
- it('should return the array passed if it is not empty', () => {
108
- expect(validations.check.wasCreated()([1, 2, 3])).toEqual([1, 2, 3]);
109
- });
110
-
111
- it('should throw an error if the array is empty', () => {
112
- expect(() => validations.check.wasCreated('Oh no! No array!')([])).toThrow('Oh no! No array!');
113
- });
114
- });
115
-
116
- describe('isTrue', () => {
117
- const count = 2;
118
-
119
- it('should return true when the first arg is truthy', () => {
120
- expect(validations.check.isTrue(count === 2, 'Count equals 2')).toEqual(true);
121
- });
122
-
123
- it('should throw an error when the first arg is falsy', () => {
124
- expect(() => validations.check.isTrue(count <= 1, 'Count is greater than 1')).toThrow('Count is greater than 1');
125
- });
126
- });
127
-
128
- describe('isFalse', () => {
129
- const count = 2;
130
-
131
- it('should return true when the first arg is falsy', () => {
132
- expect(validations.check.isFalse(count === 3, 'Count should not equal 3')).toEqual(true);
133
- });
134
-
135
- it('should throw an error when the first arg is truthy', () => {
136
- expect(() => validations.check.isFalse(count > 1, 'Count should be greater than 1')).toThrow('Count should be greater than 1');
137
- });
138
- });
139
-
140
- describe('isCustomerReference', () => {
141
- it('should return true if the string is longer than 0 characters', () => {
142
- expect(validations.isCustomerReference('1')).toEqual(true);
143
- });
144
- it('should return true if the string is less than or equal to 100 characters', () => {
145
- expect(
146
- validations.isCustomerReference('Spots of sunshine lie on the surface of the water dance, dance, and their reflections wobble.')
147
- ).toEqual(true);
148
- });
149
-
150
- it('should return false when passed an empty string', () => {
151
- expect(validations.isCustomerReference('')).toEqual(false);
152
- });
153
-
154
- it('should return false when passed a string of longer than 100 characters', () => {
155
- expect(
156
- validations.isCustomerReference(
157
- 'Little spots of sunshine lie on the surface of the water and dance, dance, and their reflections wobble deliciously over the ceiling;'
158
- )
159
- ).toEqual(false);
160
- });
161
-
162
- it('should return false when passed a non-string', () => {
163
- expect(validations.isCustomerReference(['array'])).toEqual(false);
164
- });
165
- });
166
-
167
- describe('isCustomerLabelName', () => {
168
- it('should return true if the string is longer than 0 characters', () => {
169
- expect(validations.isCustomerLabelName('1'));
170
- });
171
- it('should return true if the string is less than or equal to 50 characters', () => {
172
- expect(validations.isCustomerLabelName('William Shakespeare was poet, playwright and actor'));
173
- });
174
-
175
- it('should return false when passed an empty string', () => {
176
- expect(validations.isCustomerLabelName('')).toEqual(false);
177
- });
178
-
179
- it('should return false when passed a string of longer than 50 characters', () => {
180
- expect(
181
- validations.isCustomerLabelName(
182
- "Many of Shakespeare's plays were published in editions of varying quality and accuracy in his lifetime."
183
- )
184
- ).toEqual(false);
185
- });
186
-
187
- it('should return false when passed a non-string', () => {
188
- expect(validations.isCustomerLabelName(['array'])).toEqual(false);
189
- });
190
- });
191
- });
192
-
193
- describe('BCH', () => {
194
- describe('isAddress', () => {
195
- it('should correctly validate valid BCH addresses', () =>
196
- expect(validations.bitcoinCash.isAddress('bitcoincash:qrrfmt57avxfd2476gqxqq54djtcvjuzjc2qtsrzcw')).toEqual(true) &&
197
- validations.bitcoinCash.isAddress('qqrxa0h9jqnc7v4wmj9ysetsp3y7w9l36u8gnnjulq').toEqual(true));
198
-
199
- it('should correctly validate an incorrect BCH address', () =>
200
- expect(validations.bitcoinCash.isAddress('qqrxa0h9jqnc7v4wmj3y7w9l36u8gnnjulq')).toEqual(false));
201
- });
202
-
203
- describe('isTxHash', () => {
204
- it('should correctly validate a valid BCH hash', () =>
205
- expect(validations.bitcoinCash.isTxHash('a32c4d2f9f2e322f19867dbacb7609a1be63c914b8f41775082b50d3ee1a0ce6')).toEqual(true));
206
-
207
- it('should correctly validate an incorrect BCH hash', () =>
208
- expect(validations.bitcoinCash.isTxHash('cd1bdc201022ca9386d8757b1c49ecc6ee3769cad2d42ab6e7f9e7bd831')).toEqual(false));
209
-
210
- it('should return false when passed a non-hex string', () =>
211
- expect(validations.bitcoinCash.isTxHash('Not a hex string!')).toEqual(false));
212
- });
213
- });
214
-
215
- describe('BNB', () => {
216
- describe('isAddress', () => {
217
- it('should correctly validate valid BNB addresses', () =>
218
- expect(validations.binanceChain.isAddress('bnb1z35wusfv8twfele77vddclka9z84ugywug48gn')).toEqual(true));
219
-
220
- it('should correctly validate an incorrect BNB address', () =>
221
- expect(validations.binanceChain.isAddress('bnb1z35wusfv8twfele77vddclka9z84ugywug48gn1')).toEqual(false));
222
- });
223
-
224
- describe('isTxHash', () => {
225
- it('should correctly validate a valid BNB hash', () =>
226
- expect(validations.binanceChain.isTxHash('E68C2D178F989DE296FA1B513D1AA138B234C436B52E0D755C6664A70F7EEF7B')).toEqual(true));
227
-
228
- it('should correctly validate an incorrect BNB hash', () =>
229
- expect(validations.binanceChain.isTxHash('E68C2D178F989DE296FA1B513D1AA138B234C436B52E0D755C6664A70F7EEF7B1')).toEqual(false));
230
-
231
- it('should return false when passed a non-hex string', () =>
232
- expect(validations.binanceChain.isTxHash('Not a hex string!')).toEqual(false));
233
- });
234
- });
235
-
236
- describe('BTC', () => {
237
- describe('isAddress', () => {
238
- it('should correctly validate a valid BTC address', () =>
239
- expect(validations.bitcoin.isAddress('1LFnX5KT4CMKud7KB9xaXFZFkD3H8bUD16')).toEqual(true));
240
-
241
- it('should correctly validate an incorrect BTC address', () =>
242
- expect(validations.bitcoin.isAddress('1LFnX5KT4CMKud7KB9xaXFZFkD3H8b')).toEqual(false));
243
- });
244
-
245
- describe('isBech32Address', () => {
246
- it('should correctly validate a Bech32 address', () =>
247
- expect(validations.bitcoin.isBech32Address('bc1qar0srrr7xfkvy5l643lydnw9re59gtzzwf5mdq')).toEqual(true));
248
- it('should correctly validate an invalide Bech32 address', () =>
249
- expect(validations.bitcoin.isBech32Address('4ef47f6eb681d5d9fa2f7e16336cd629303c635e8da51e425b76088be9c8744c')).toEqual(false));
250
- });
251
-
252
- describe('isHDPublicKey', () => {
253
- it('should return true when passed an HD public key', () =>
254
- expect(
255
- validations.bitcoin.isHDPublicKey(
256
- 'xprv9s21ZrQH143K3QTDL4LXw2F7HEK3wJUD2nW2nRk4stbPy6cq3jPPqjiChkVvvNKmPGJxWUtg6LnF5kejMRNNU3TGtRBeJgk33yuGBxrMPHi'
257
- )
258
- ).toEqual(true));
259
- it('should return false when not passed an HD public key', () =>
260
- expect(validations.bitcoin.isHDPublicKey('bc1qar0srrr7xfkvy5l643lydnw9re59gtzzwf5mdq')).toEqual(false));
261
- });
262
-
263
- describe('isPublicKey', () => {
264
- it('should return true when passed a public key', () =>
265
- expect(
266
- validations.bitcoin.isPublicKey(
267
- '046c04c02f1138f440e8c5e9099db938bfba93d0389528bb7f6bf423ae203a2edcfba133f0409023d7ea13ac01c5aeedaf0bbfbeb8b82e9b48410d93a296da5b0c'
268
- )
269
- ).toEqual(true));
270
- it('should return false when not passed a public key', () =>
271
- expect(validations.bitcoin.isPublicKey('1EHNa6Q4Jz2uvNExL497mE43ikXhwF6kZm')).toEqual(false));
272
- });
273
-
274
- describe('isTxHash', () => {
275
- it('should correctly validate a valid BTC hash', () =>
276
- expect(validations.bitcoin.isTxHash('835346f3ea00a23df60ca5dc24afce67810c792ac4505e544410d4b19e7c95a0')).toEqual(true));
277
- it('should correctly validate an incorrect BTC hash', () =>
278
- expect(validations.bitcoin.isTxHash('835346f3ea00a23df60caafce67810c792ac4505e544410d4b19e7c95a0')).toEqual(false));
279
- it('should return false if the string passed is not a hex string', () =>
280
- expect(validations.bitcoin.isTxHex('Definitely not a hex string')).toEqual(false));
281
- });
282
-
283
- describe('isTxHex', () => {
284
- const hex =
285
- '0100000002d8c8df6a6fdd2addaf589a83d860f18b44872d13ee6ec3526b2b470d42a96d4d000000008b483045022100b31557e47191936cb14e013fb421b1860b5e4fd5d2bc5ec1938f4ffb1651dc8902202661c2920771fd29dd91cd4100cefb971269836da4914d970d333861819265ba014104c54f8ea9507f31a05ae325616e3024bd9878cb0a5dff780444002d731577be4e2e69c663ff2da922902a4454841aa1754c1b6292ad7d317150308d8cce0ad7abffffffff2ab3fa4f68a512266134085d3260b94d3b6cfd351450cff021c045a69ba120b2000000008b4830450220230110bc99ef311f1f8bda9d0d968bfe5dfa4af171adbef9ef71678d658823bf022100f956d4fcfa0995a578d84e7e913f9bb1cf5b5be1440bcede07bce9cd5b38115d014104c6ec27cffce0823c3fecb162dbd576c88dd7cda0b7b32b0961188a392b488c94ca174d833ee6a9b71c0996620ae71e799fc7c77901db147fa7d97732e49c8226ffffffff02c0175302000000001976a914a3d89c53bb956f08917b44d113c6b2bcbe0c29b788acc01c3d09000000001976a91408338e1d5e26db3fce21b011795b1c3c8a5a5d0788ac00000000';
286
- it('should return true if passed a hex string Tx hash', () => expect(validations.bitcoin.isTxHex(hex)).toEqual(true));
287
- it('should return false if the string passed is not a hex string', () =>
288
- expect(validations.bitcoin.isTxHex('definitelyNotAHexString')).toEqual(false));
289
- it('should return false if the string passed is a hex string, but is not a tx hash', () =>
290
- expect(validations.bitcoin.isTxHex('4ef47f6eb681d5d9fa2f7e16336cd629303c635e8da51e425b76088be9c8744c')).toEqual(false));
291
- });
292
-
293
- describe('isHDPath', () => {
294
- // this test has not worked since its creation, it needs an actual working HD key
295
-
296
- // it('should return true when passed a valid HDPrivateKey path', () =>
297
- // expect(
298
- // validations.bitcoin.isHDPath(
299
- // 'xprv9s21ZrQH143K3QTDL4LXw2F7HEK3wJUD2nW2nRk4stbPy6cq3jPPqjiChkVvvNKmPGJxWUtg6LnF5kejMRNNU3TGtRBeJgk33yuGBxrMPHi'
300
- // )
301
- // ).toEqual(true));
302
- it('should return false when passed a string that is not a valid HDPrivateKey path', () =>
303
- expect(validations.bitcoin.isHDPath('bc1qar0srrr7xfkvy5l643lydnw9re59gtzzwf5mdq')).toEqual(false));
304
- });
305
-
306
- describe('isScriptHex', () => {
307
- it('should return true when passed a script hex', () =>
308
- expect(
309
- validations.bitcoin.isScriptHex(
310
- '01000000011e2e8cfdf21d68f90974cd557a30c11894cc8cfec5cd5330e41846c2c84566bd000000006b4830450221009f61f453f44e807fdc538ca21710393d34005dd5709dabd8b6b9ccf09ea0b36a0220420d91a33f43d7b979471220e12cd1025975bd2e6c0bf2a14eb65ad89d578104012102de8f92034b9b3c956c1896d23a628537561e29faa772438aac2265c91ede6519ffffffff0118566202000000001976a914b27f04e510293c3e530e7b7bdf71f59118030e1e88ac00000000'
311
- )
312
- ).toEqual(true));
313
- it('should return false if the string passed is not a hex string', () =>
314
- expect(validations.bitcoin.isScriptHex('definitelyNotAHexString')).toEqual(false));
315
- it('should return false if the string passed is a hex string, but is not a script hex', () =>
316
- expect(validations.bitcoin.isScriptHex('mpXwg4jMtRhuSpVq4xS3HFHmCmWp9NyGKt')).toEqual(false));
317
- });
318
-
319
- describe('isTxSignature', () => {
320
- it('should return true when passed a tx hash that includes a signature', () =>
321
- expect(
322
- validations.bitcoin.isTxSignature(
323
- '304502206e21798a42fae0e854281abd38bacd1aeed3ee3738d9e1446618c4571d1090db022100e2ac980643b0b82c0e88ffdfec6b64e3e6ba35e7ba5fdd7d5d6cc8d25c6b241501'
324
- )
325
- ).toEqual(true));
326
- it('should return false when passed a tx hash that does not include a signature', () =>
327
- expect(validations.bitcoin.isTxSignature('f5d8ee39a430901c91a5917b9f2dc19d6d1a0e9cea205b009ca73dd04470b9a6')).toEqual(false));
328
- it('should return false if the string passed is not a hex string', () =>
329
- expect(validations.bitcoin.isTxSignature('definitelyNotAHexString')).toEqual(false));
330
- });
331
-
332
- describe('isBlockHeight', () => {
333
- it('should return true when passed a value greater than or equal to 0', () =>
334
- expect(validations.bitcoin.isBlockHeight(986789)).toEqual(true) &&
335
- expect(validations.bitcoin.isBlockHeight('987654')).toEqual(true));
336
- it('should return false when passed a value that is not greater than or equal to 0', () =>
337
- expect(validations.bitcoin.isBlockHeight(null)).toEqual(false) &&
338
- expect(validations.bitcoin.isBlockHeight('string')).toEqual(false));
339
- });
340
- });
341
-
342
- describe('ETH', () => {
343
- describe('isAddress', () => {
344
- it('should return true if the address evaluates as a web3 address', () =>
345
- expect(validations.ethereum.isAddress('0xa6Bc4b3fe7F2756124d30D896Fe4457711e9d214')).toEqual(true));
346
- it('should return false if the address does not evaluate to a web3 address', () =>
347
- expect(validations.ethereum.isAddress('Bc4b3fe7F2756124d30D896Fe4457711e9d214')).toEqual(false));
348
- });
349
-
350
- describe('isBlockHash', () => {
351
- it('should return true when given a valid hash', () =>
352
- expect(validations.ethereum.isBlockHash('0xec6491abd46a1a9a71b78f4b84d96fd49525aa4f66c8d8c3588c489f2f88eb0e')).toEqual(true));
353
- it('should return false when given an vinalid hash', () =>
354
- expect(validations.ethereum.isBlockHash('0xec6491abd46a1a9a71b78f4b84d96fd49525aa4f66c8d8c3588c489eb0e')).toEqual(false));
355
- });
356
-
357
- describe('isTxHash', () => {
358
- it('should correctly validate a valid ETH hash', () =>
359
- expect(validations.ethereum.isTxHash('0xec6491abd46a1a9a71b78f4b84d96fd49525aa4f66c8d8c3588c489f2f88eb0e')).toEqual(true));
360
-
361
- it('should correctly validate an incorrect ETH hash', () =>
362
- expect(validations.ethereum.isTxHash('0xec6491abd46a1a9a71b7896fd49525aa4f66c8d8c3588c489f2f88eb0e')).toEqual(false));
363
- });
364
-
365
- describe('isAddressCode', () => {
366
- it('should return true if the string is a hex address', () =>
367
- expect(validations.ethereum.isAddressCode('0xa6Bc4b3fe7F2756124d30D896Fe4457711e9d214')).toEqual(true));
368
- it('should return false if the string is not a hex address', () =>
369
- expect(validations.ethereum.isAddressCode('0xa6Bc4b3fe7F27yu124d30D896Fe4457711e9d214')).toEqual(false));
370
- });
371
-
372
- describe('isValidWeiAmount', () => {
373
- it('should return true when passed an amount that evaluates to wei', () =>
374
- expect(validations.ethereum.isValidWeiAmount('7000000000000000')).toEqual(true));
375
- it('should return false when passed an amount that is not valid in wei', () =>
376
- expect(validations.ethereum.isValidWeiAmount(7000000000000000)).toEqual(false) &&
377
- validations.ethereum.isValidWeiAmount('1000.00').toEqual(false));
378
- });
379
- });
380
-
381
- describe('LTC', () => {
382
- describe('isAddress', () => {
383
- it('should correctly validate valid LTC addresses', () =>
384
- expect(validations.litecoin.isAddress('LMR7przNNMS3GpaD6Ygq64NxbsJsZAqGgM')).toEqual(true));
385
-
386
- it('should correctly validate valid LTC MimbleWimble addresses', () =>
387
- expect(
388
- validations.litecoin.isAddress(
389
- 'ltcmweb1qq2aejfd7svtnqk0uq0cfkd9mr9sszypmx2phdu5qwfhlujazv2nxjqstgy3r5gkxesu5vv2v0tmlwdwhat3se36pwzwtlqm8ypxq3d2fggc8d7nq'
390
- )
391
- ).toEqual(true));
392
-
393
- it('should correctly validate an incorrect LTC address', () =>
394
- expect(validations.litecoin.isAddress('t1t8BzkNb8d98o8kpbwrjtUjMX3GMF')).toEqual(false));
395
- });
396
-
397
- describe('isTxHash', () => {
398
- it('should correctly validate a valid LTC hash', () =>
399
- expect(validations.litecoin.isTxHash('b0b858b34675cc8f851e6a2174295ada574837422538efe9ca83ef405d2faf29')).toEqual(true));
400
-
401
- it('should correctly validate an incorrect LTC hash', () =>
402
- expect(validations.litecoin.isTxHash('b0b858b34675cc8f851e6a2295ada574837422538efe9ca83ef405d2faf29')).toEqual(false));
403
-
404
- it('should return false when passed a non-hex string', () =>
405
- expect(validations.litecoin.isTxHash('Not a hex code here')).toEqual(false));
406
- });
407
- });
408
-
409
- describe('XLM', () => {
410
- describe('isAddress', () => {
411
- it('should correctly validate valid XLM addresses', () =>
412
- expect(validations.stellar.isAddress('GBH4TZYZ4IRCPO44CBOLFUHULU2WGALXTAVESQA6432MBJMABBB4GIYI')).toEqual(true));
413
-
414
- it('should correctly validate an incorrect XLM address', () =>
415
- expect(validations.stellar.isAddress('GBH4TZYZ4IRCPO44CAAAAAAULU2WGALXTAVESQA6432MBJMABBB4GIYI')).toEqual(false));
416
- });
417
-
418
- describe('isTxHash', () => {
419
- it('should correctly validate a valid XLM hash', () =>
420
- expect(validations.stellar.isTxHash('dcf208070966a0f04dbff0be6abe5bc7ea2d77f16167e89e1869a8efc68ebe44')).toEqual(true));
421
-
422
- it('should correctly validate an incorrect XLM hash', () =>
423
- expect(validations.stellar.isTxHash('8ee1f64137b12d07f8d2ddd3460d78ecbe37ba671aa4e54af34de935cc2bba2ca')).toEqual(false));
424
-
425
- it('should return false when passed a non-hex string', () =>
426
- expect(validations.stellar.isTxHash('Yet again this is not a hex string')).toEqual(false));
427
- });
428
- });
429
-
430
- describe('XRP', () => {
431
- describe('isAddress', () => {
432
- it('should correctly validate valid XRP addresses', () =>
433
- expect(validations.ripple.isAddress('rDV3RhpWznRCmtpD17RNxg6t4Hg8NPV8mF')).toEqual(true));
434
-
435
- it('should correctly validate an incorrect XRP address', () =>
436
- expect(validations.ripple.isAddress('rDV3RhpWznRCmtpD17RNxg0t4Hg8NPV8mF')).toEqual(false));
437
- });
438
-
439
- describe('isTxHash', () => {
440
- it('should correctly validate a valid XRP hash', () =>
441
- expect(validations.ripple.isTxHash('C6593DD2A32ED5120DF1FE80665B84A9CCAF06ADDC2EF89F720CBAC3E8069C0E')).toEqual(true));
442
-
443
- it('should correctly validate an incorrect XRP hash', () =>
444
- expect(validations.ripple.isTxHash('C6593DD2A32ED5120DF1FE84A9CCAF06ADDC2EF89F720CBAC3E8069C0E')).toEqual(false));
445
-
446
- it('should return false when passed a non-hex string', () =>
447
- expect(validations.ripple.isTxHash('Yet again this is not a hex string')).toEqual(false));
448
- });
449
- });
450
-
451
- describe('ZEC', () => {
452
- describe('isAddress', () => {
453
- it('should correctly validate valid ZEC addresses', () =>
454
- expect(validations.zcash.isAddress('t1Jxptj7GnXQRsLNH5wWnDrGwEipEB3aZtf')).toEqual(true));
455
-
456
- it('should correctly validate an incorrect ZEC address', () =>
457
- expect(validations.zcash.isAddress('t1Jxptj7GnXQRsLNH5wWnDrGwEipEB3aZtf1')).toEqual(false));
458
- });
459
-
460
- describe('isTxHash', () => {
461
- it('should correctly validate a valid ZEC hash', () =>
462
- expect(validations.zcash.isTxHash('715c23949b85581de432f174a9e7f4d3f9e74b008064e2c68e7a52b1ec38e961')).toEqual(true));
463
-
464
- it('should correctly validate an incorrect ZEC hash', () =>
465
- expect(validations.zcash.isTxHash('715c23949b85581de432f174a9e7f4d3f9e74b008064e2c68e7a52b1ec38e9611')).toEqual(false));
466
-
467
- it('should return false when passed a non-hex string', () =>
468
- expect(validations.zcash.isTxHash('Yet again this is not a hex string')).toEqual(false));
469
- });
470
- });
471
-
472
- describe('ZEN', () => {
473
- describe('isAddress', () => {
474
- it('should correctly validate valid ZEN addresses', () =>
475
- expect(validations.horizen.isAddress('znUovxhrE91tep6D7YtgSc3XJZoYQLVDwVn')).toEqual(true));
476
-
477
- it('should correctly validate an incorrect ZEN address', () =>
478
- expect(validations.horizen.isAddress('znUovxhrE91tep6D7YtgSc3XJZoYQLVDwVn1')).toEqual(false));
479
- });
480
-
481
- describe('isTxHash', () => {
482
- it('should correctly validate a valid ZEN hash', () =>
483
- expect(validations.horizen.isTxHash('e5d31deb3fee023758f0b79d06489df975fce9aa53351b9b5c8491e4c33c74b7')).toEqual(true));
484
-
485
- it('should correctly validate an incorrect ZEN hash', () =>
486
- expect(validations.horizen.isTxHash('e5d31deb3fee023758f0b79d06489df975fce9aa53351b9b5c8491e4c33c74b71')).toEqual(false));
487
-
488
- it('should return false when passed a non-hex string', () =>
489
- expect(validations.horizen.isTxHash('Yet again this is not a hex string')).toEqual(false));
490
- });
491
- });
492
-
493
- describe('ZIL', () => {
494
- describe('isAddress', () => {
495
- it('should correctly validate valid ZIL addresses', () =>
496
- expect(validations.zilliqa.isAddress('zil1tw5rpejf96e76ty93l7c3dn0g79h2qhhdm28a4')).toEqual(true));
497
-
498
- it('should correctly validate an incorrect ZIL address', () =>
499
- expect(validations.zilliqa.isAddress('0x14456246cc53d31f0a2EB00FA0248F7aEbD3fa8')).toEqual(false));
500
- });
501
-
502
- describe('isTxHash', () => {
503
- it('should correctly validate a valid ZIL hash', () =>
504
- expect(validations.zilliqa.isTxHash('0xb9a04481c546258e339f8ce4cccdee3f179cc37a8f099f0608baf39e0a819f75')).toEqual(true));
505
-
506
- it('should correctly validate an incorrect ZIL hash', () =>
507
- expect(validations.zilliqa.isTxHash('0xb9a04481c546258e339f8ce4cccdee3f179cc37a8f099f0608baf39e0a819f7')).toEqual(false));
508
-
509
- it('should return false when passed a non-hex string', () =>
510
- expect(validations.zilliqa.isTxHash('Yet again this is not a hex string')).toEqual(false));
511
- });
512
- });
513
-
514
- describe('ALGO', () => {
515
- describe('isAddress', () => {
516
- it('should correctly validate valid ALGO addresses', () =>
517
- expect(validations.algorand.isAddress('GX3XLHSRMFTADVKJBBQBTZ6BKINW6ZO5JHXWGCWB4CPDNPDQ2PIYN4AVHQ')).toEqual(true));
518
-
519
- it('should correctly validate an incorrect ALGO address', () =>
520
- expect(validations.algorand.isAddress('GX3XLHBQBTZ6BKINW6ZO5JHXWGCWB4CPDNPDQ2PIYN4AVHQ')).toEqual(false));
521
- });
522
-
523
- describe('isTxHash', () => {
524
- it('should correctly validate a valid ALGO hash', () =>
525
- expect(validations.algorand.isTxHash('TDITWGH5FODF2EUSKBAZ4DDC323NDBCBCE6BSXVXTZBINTCVQVVQ')).toEqual(true));
526
-
527
- it('should correctly validate an incorrect ALGO hash', () =>
528
- expect(validations.algorand.isTxHash('TDITWGH5FOBAZ4DDC323NDBCBCE6BSXVXTZBINTCVQVVQ')).toEqual(false));
529
-
530
- it('should return false when passed a non-hex string', () =>
531
- expect(validations.algorand.isTxHash('Yet again this is not a hex string')).toEqual(false));
532
- });
533
- });
534
-
535
- describe('DOT', () => {
536
- describe('isAddress', () => {
537
- it('should correctly validate valid DOT addresses', () =>
538
- expect(validations.polkadot.isAddress('14YJztsPZEiKuKhU3qLd6JjiY4awfdUru8Xu7BDdZAUuG8S6')).toEqual(true));
539
-
540
- it('should correctly validate an incorrect DOT address', () =>
541
- expect(validations.polkadot.isAddress('14YJztsPZEiKuKjiY4awfdUru8Xu7BDdZAUuG8S6')).toEqual(false));
542
- });
543
-
544
- describe('isTxHash', () => {
545
- it('should correctly validate a valid DOT hash', () =>
546
- expect(validations.polkadot.isTxHash('0x975ba4cfd83dd7f4f6e2c1932f4aeb650391f00d57c3856907d668a99fd90609')).toEqual(true));
547
-
548
- it('should correctly validate an incorrect DOT hash', () =>
549
- expect(validations.polkadot.isTxHash('0x975ba4cfd83dd7f4f2f4aeb650391f00d57c3856907d668a99fd90609')).toEqual(false));
550
-
551
- it('should return false when passed a non-hex string', () =>
552
- expect(validations.polkadot.isTxHash('Yet again this is not a hex string')).toEqual(false));
553
- });
554
- });
555
-
556
- describe('ATOM', () => {
557
- describe('isAddress', () => {
558
- it('should correctly validate valid ATOM addresses', () =>
559
- expect(validations.cosmos.isAddress('cosmos153lf4zntqt33a4v0sm5cytrxyqn78q7kz8j8x5')).toEqual(true));
560
-
561
- it('should correctly validate an incorrect ATOM address', () =>
562
- expect(validations.cosmos.isAddress('kosmos153lf4zntqt33a4v0sm5cytrxyqn78q7kz8j8x5')).toEqual(false));
563
-
564
- it('should correctly validate an incorrect (too long) ATOM address', () =>
565
- expect(validations.cosmos.isAddress('cosmos153lf4zntqt33a4v0sm5cytrxyqn78q7kz8j8x50')).toEqual(false));
566
- });
567
-
568
- describe('isTxHash', () => {
569
- it('should correctly validate a valid ATOM hash', () =>
570
- expect(validations.cosmos.isTxHash('BFA0252193CCAA0592AF2A27541473E7F6422A9AD85CFC9525CF67FA2AA2CD6F')).toEqual(true));
571
-
572
- it('should correctly validate an incorrect ATOM hash', () =>
573
- expect(validations.cosmos.isTxHash('BFA0252193CCAA0592AF2A27541473E7')).toEqual(false));
574
-
575
- it('should return false when passed a non-hex string', () =>
576
- expect(validations.cosmos.isTxHash('ZZA0252193CCAA0592AF2A27541473E7F6422A9AD85CFC9525CF67FA2AA2CD6F')).toEqual(false));
577
- });
578
- });
579
-
580
- describe('SOL', () => {
581
- describe('isAddress', () => {
582
- it('should correctly validate valid SOL addresses', () =>
583
- expect(validations.solana.isAddress('A4JXQF7p9sHR5apRy2hVgKFAHHs7jdpQv9kFGLDit24T')).toEqual(true));
584
-
585
- it('should correctly validate an incorrect SOL address', () =>
586
- expect(validations.solana.isAddress('L0JXQF7p9sHR5apRy2hVgKFAHHs7jdpQv9kFGLDit24T')).toEqual(false));
587
-
588
- it('should correctly validate an incorrect (too long) SOL address', () =>
589
- expect(validations.solana.isAddress('A4JXQF7p9sHR5apRy2hVgKFAHHs7jdpQv9kFGLDit24TAAAAAAAAAAAAAAA')).toEqual(false));
590
- });
591
-
592
- describe('isTxHash', () => {
593
- it('should correctly validate a valid SOL hash', () =>
594
- expect(
595
- validations.solana.isTxHash('2WcPszZnXBLpu9WzLbGRfwzETPHfTRi4E8fmVedFT4bPYc1BiELG3Ldway6oPTSXpVJZRM4mqEdz2Uuh5n9VQp8x')
596
- ).toEqual(true));
597
-
598
- it('should correctly validate an incorrect SOL hash', () =>
599
- expect(validations.solana.isTxHash('2WcPszZnXBLpu9WzLbGRfwzET')).toEqual(false));
600
- });
601
- });
602
-
603
- describe('BSC', () => {
604
- describe('isAddress', () => {
605
- it('should correctly validate valid BSC addresses', () =>
606
- expect(validations.binanceSmartChain.isAddress('0x5616e2b8acff064bf902b8a93cbd5da2ca1edc7c')).toEqual(true));
607
-
608
- it('should correctly validate an incorrect BSC address', () =>
609
- expect(validations.binanceSmartChain.isAddress('0xz616e2b8acff064bf902b8a93cbd5da2ca1edc7c')).toEqual(false));
610
-
611
- it('should correctly validate an incorrect (too long) BSC address', () =>
612
- expect(validations.binanceSmartChain.isAddress('0x5616e2b8acff064bf902b8a93cbd5da2ca1edc7caaaaa')).toEqual(false));
613
- });
614
-
615
- describe('isTxHash', () => {
616
- it('should correctly validate a valid BSC hash', () =>
617
- expect(validations.binanceSmartChain.isTxHash('0x1a17145af3bec32f653d8ebd4c2c1b800214b17a7f8abfdda020cb1f39abe269')).toEqual(true));
618
-
619
- it('should correctly validate an incorrect BSC hash', () =>
620
- expect(validations.binanceSmartChain.isTxHash('0x1a17145af3bec32f653d8ebd4c2c1b800214b17')).toEqual(false));
621
- });
622
- });
623
-
624
- describe('Doge', () => {
625
- describe('isAddress', () => {
626
- it('should correctly validate valid Doge addresses', () => {
627
- expect(validations.doge.isAddress('9t3fCHSQz3j7XERcopTCUwMF3bZxJW99As')).toEqual(true);
628
- expect(validations.doge.isAddress('DQe2B39m3V68sXZPfUvdjv3QecYGAE2dBv')).toEqual(true);
629
- });
630
-
631
- it('should correctly validate an incorrect Doge address', () =>
632
- expect(validations.doge.isAddress('DQe2B39m3V68sXZPfUvdjv3QecYGAE2dB_')).toEqual(false));
633
-
634
- it('should correctly validate an incorrect (too long) Doge address', () =>
635
- expect(validations.doge.isAddress('DQe2B39m3V68sXZPfUvdjv3QecYGAE2dBvQ')).toEqual(false));
636
- });
637
-
638
- describe('isTxHash', () => {
639
- it('should correctly validate a valid Doge hash', () =>
640
- expect(validations.doge.isTxHash('ee3b8c45d4b84c07c7dc9e1c82752920ba6e7cda73354c0f399f81949513d418')).toEqual(true));
641
-
642
- it('should correctly validate an incorrect Doge hash', () =>
643
- expect(validations.doge.isTxHash('ee3b8c45d4b84c07c7dc9e1c82752920ba6e7cda73354c0f399f81949513d41')).toEqual(false));
644
- });
645
- });
646
-
647
- describe('Polygon', () => {
648
- describe('isAddress', () => {
649
- it('should correctly validate valid Polygon addresses', () =>
650
- expect(validations.polygon.isAddress('0x286c2bd6e0585f396647cbfdbfe14b92600365bb')).toEqual(true));
651
-
652
- it('should correctly validate an incorrect Polygon address', () =>
653
- expect(validations.polygon.isAddress('0xz286c2bd6e0585f396647cbfdbfe14b92600365bb')).toEqual(false));
654
-
655
- it('should correctly validate an incorrect (too long) Polygon address', () =>
656
- expect(validations.polygon.isAddress('0x286c2bd6e0585f396647cbfdbfe14b92600365bba')).toEqual(false));
657
- });
658
-
659
- describe('isTxHash', () => {
660
- it('should correctly validate a valid Polygon hash', () =>
661
- expect(validations.polygon.isTxHash('0x45a491048477568dd2047a0a9b6be9cc491382e74823ea1bd53bbc67db54a867')).toEqual(true));
662
-
663
- it('should correctly validate an incorrect Polygon hash', () =>
664
- expect(validations.polygon.isTxHash('0x45a491048477568dd2047a0a9b6be9cc491382e74823e')).toEqual(false));
665
- });
666
- });
667
-
668
- describe('Filecoin', () => {
669
- describe('isAddress', () => {
670
- it('should correctly validate a valid Filecoin f0 address', () => expect(validations.filecoin.isAddress('f01825161')).toEqual(true));
671
-
672
- it('should correctly validate a valid Filecoin f1 address', () =>
673
- expect(validations.filecoin.isAddress('f1xafi3wsh7q553efnumhgeomathrehwwd2mye7oy')).toEqual(true));
674
-
675
- it('should correctly validate a valid Filecoin f2 address', () =>
676
- expect(validations.filecoin.isAddress('f2vrab2ft4qc22mgfxgdrphd7ovvz6zs3nq3fv4oy')).toEqual(true));
677
-
678
- it('should correctly validate a valid Filecoin f3 address', () =>
679
- expect(
680
- validations.filecoin.isAddress('f3ug2ti4finql5bxyl5q56udn5lt462miuadjg3ur467wrj6bvbrksglxyv65zoxyz4mgte3joyce3oxkk4q7)q')
681
- ).toEqual(true));
682
-
683
- it('should correctly validate an invalid Filecoin address', () =>
684
- expect(validations.filecoin.isAddress('f4zvcxzvcxzvczvcasdgwere')).toEqual(false));
685
- });
686
-
687
- describe('isTxHash', () => {
688
- it('should correctly validate a valid Filecoin hash', () =>
689
- expect(validations.filecoin.isTxHash('bafy2bzacedcrpcs76f2ws445wnjix2kktsgca4vv6qbd7zua7pc5mnkpveg7m')).toEqual(true));
690
-
691
- it('should correctly validate an invalid Filecoin hash', () =>
692
- expect(validations.filecoin.isTxHash('bafy2bzacedcrpcs76f2ws445wnjix2kktsgca4vv6qbd7zua7pc5mnkpveg7')).toEqual(false));
693
-
694
- it('should correctly validate an invalid Filecoin hash', () =>
695
- expect(validations.filecoin.isTxHash('fafy2bzacedcrpcs76f2ws445wnjix2kktsgca4vv6qbd7zua7pc5mnkpveg7m')).toEqual(false));
696
- });
697
- });
698
- describe('Optimism', () => {
699
- describe('isAddress', () => {
700
- describe('isAddress', () => {
701
- it('should return true if the address evaluates as a web3 address', () =>
702
- expect(validations.optimism.isAddress('0xa6Bc4b3fe7F2756124d30D896Fe4457711e9d214')).toEqual(true));
703
- it('should return false if the address does not evaluate to a web3 address', () =>
704
- expect(validations.optimism.isAddress('Bc4b3fe7F2756124d30D896Fe4457711e9d214')).toEqual(false));
705
- });
706
- describe('isTxHash', () => {
707
- it('should correctly validate a valid OP hash', () =>
708
- expect(validations.optimism.isTxHash('0xec6491abd46a1a9a71b78f4b84d96fd49525aa4f66c8d8c3588c489f2f88eb0e')).toEqual(true));
709
-
710
- it('should correctly validate an incorrect OP hash', () =>
711
- expect(validations.optimism.isTxHash('0xec6491abd46a1a9a71b7896fd49525aa4f66c8d8c3588c489f2f88eb0e')).toEqual(false));
712
- });
713
- });
714
- });
715
- describe('Avalanche', () => {
716
- describe('isAddress', () => {
717
- describe('isAddress', () => {
718
- it('should return true if the address evaluates as a web3 address', () =>
719
- expect(validations.avalanche.isAddress('0xa6Bc4b3fe7F2756124d30D896Fe4457711e9d214')).toEqual(true));
720
- it('should return false if the address does not evaluate to a web3 address', () =>
721
- expect(validations.avalanche.isAddress('Bc4b3fe7F2756124d30D896Fe4457711e9d214')).toEqual(false));
722
- });
723
- describe('isTxHash', () => {
724
- it('should correctly validate a valid AVAX hash', () =>
725
- expect(validations.avalanche.isTxHash('0xec6491abd46a1a9a71b78f4b84d96fd49525aa4f66c8d8c3588c489f2f88eb0e')).toEqual(true));
726
-
727
- it('should correctly validate an incorrect AVAX hash', () =>
728
- expect(validations.avalanche.isTxHash('0xec6491abd46a1a9a71b7896fd49525aa4f66c8d8c3588c489f2f88eb0e')).toEqual(false));
729
- });
730
- });
731
- });
732
- describe('Arbitrum', () => {
733
- describe('isAddress', () => {
734
- describe('isAddress', () => {
735
- it('should return true if the address evaluates as a web3 address', () =>
736
- expect(validations.arbitrum.isAddress('0xa6Bc4b3fe7F2756124d30D896Fe4457711e9d214')).toEqual(true));
737
- it('should return false if the address does not evaluate to a web3 address', () =>
738
- expect(validations.arbitrum.isAddress('Bc4b3fe7F2756124d30D896Fe4457711e9d214')).toEqual(false));
739
- });
740
- describe('isTxHash', () => {
741
- it('should correctly validate a valid Arbitrum hash', () =>
742
- expect(validations.arbitrum.isTxHash('0xec6491abd46a1a9a71b78f4b84d96fd49525aa4f66c8d8c3588c489f2f88eb0e')).toEqual(true));
743
-
744
- it('should correctly validate an incorrect Arbitrum hash', () =>
745
- expect(validations.arbitrum.isTxHash('0xec6491abd46a1a9a71b7896fd49525aa4f66c8d8c3588c489f2f88eb0e')).toEqual(false));
746
- });
747
- });
748
- });
749
-
750
- describe('Tron', () => {
751
- describe('isAddress', () => {
752
- it('should correctly validate a valid Tron address', () =>
753
- expect(validations.tron.isAddress('TPCCPf13PDPp5nEGCiMrE7WXKstpZhmfDw')).toEqual(true));
754
-
755
- it('should correctly validate an invalid Tron address', () =>
756
- expect(validations.tron.isAddress('TPCCPf13PDPp5nEGCiMrE7WXKstpZhmfDwZ')).toEqual(false));
757
- });
758
-
759
- describe('isTxHash', () => {
760
- it('should correctly validate a valid Tron hash', () =>
761
- expect(validations.tron.isTxHash('2f63fad2b3f8ccce75490545c8a0dacbb0730ebd7d551a89b015d8ca4ab458f2')).toEqual(true));
762
-
763
- it('should correctly validate an invalid Tron hash', () =>
764
- expect(validations.tron.isTxHash('2f63fad2b3f8ccce75490545c8a0dacbb0730ebd7d551a89b015d8ca4ab458fz')).toEqual(false));
765
-
766
- it('should correctly validate an invalid Tron hash', () =>
767
- expect(validations.tron.isTxHash('2f63fad2b3f8ccce75490545c8a0dacbb0730ebd7d551a89b015d8ca4ab458f21')).toEqual(false));
768
- });
769
- });
770
-
771
- describe('Fantom', () => {
772
- describe('isAddress', () => {
773
- describe('isAddress', () => {
774
- it('should return true if the address evaluates as a web3 address', () =>
775
- expect(validations.fantom.isAddress('0xa6Bc4b3fe7F2756124d30D896Fe4457711e9d214')).toEqual(true));
776
- it('should return false if the address does not evaluate to a web3 address', () =>
777
- expect(validations.fantom.isAddress('Bc4b3fe7F2756124d30D896Fe4457711e9d214')).toEqual(false));
778
- });
779
- describe('isTxHash', () => {
780
- it('should correctly validate a valid Fantom hash', () =>
781
- expect(validations.fantom.isTxHash('0xec6491abd46a1a9a71b78f4b84d96fd49525aa4f66c8d8c3588c489f2f88eb0e')).toEqual(true));
782
-
783
- it('should correctly validate an incorrect Fantom hash', () =>
784
- expect(validations.fantom.isTxHash('0xec6491abd46a1a9a71b7896fd49525aa4f66c8d8c3588c489f2f88eb0e')).toEqual(false));
785
- });
786
- });
787
- });
788
-
789
- describe('CELO', () => {
790
- describe('isAddress', () => {
791
- it('should return true if the address evaluates as a web3 address', () =>
792
- expect(validations.celo.isAddress('0x711520A753A23a3760B0361e0EB8d3A0eD472326')).toEqual(true));
793
- it('should return false if the address does not evaluate to a web3 address', () =>
794
- expect(validations.celo.isAddress('0x711520A753A23a3760B0361e0EB8d3A0eD47232G')).toEqual(false));
795
- });
796
-
797
- describe('isTxHash', () => {
798
- it('should correctly validate a valid CELO hash', () =>
799
- expect(validations.celo.isTxHash('0xad90ee6159a7760fda9c594dc0bb9a3fec8b5c57dc61e391b65e4f8d0efc2fab')).toEqual(true));
800
-
801
- it('should correctly validate an incorrect CELO hash', () =>
802
- expect(validations.celo.isTxHash('0xad90ee6159a7760fda9c594dc0bb9a3fec8b5c57dc61e391b65e4f8d0efc2faG')).toEqual(false));
803
- });
804
- });
805
-
806
- describe('ETC', () => {
807
- describe('isAddress', () => {
808
- it('should return true if the address evaluates as a web3 address', () =>
809
- expect(validations.ethereumClassic.isAddress('0x667B248015b02f35F0dBb7e02695f9D081CC5d26')).toEqual(true));
810
- it('should return false if the address does not evaluate to a web3 address', () =>
811
- expect(validations.ethereumClassic.isAddress('0x667B248015b02f35F0dBb7e02695f9D081CC5d2G')).toEqual(false));
812
- });
813
-
814
- describe('isTxHash', () => {
815
- it('should correctly validate a valid ETC hash', () =>
816
- expect(validations.ethereumClassic.isTxHash('0x5b410a65887837fe8c2b6fadf3bad8808411cef67ed22eba27f75f6d446673de')).toEqual(true));
817
-
818
- it('should correctly validate an incorrect ETC hash', () =>
819
- expect(validations.ethereumClassic.isTxHash('0x5b410a65887837fe8c2b6fadf3bad8808411cef67ed22eba27f75f6d446673de!')).toEqual(false));
820
- });
821
- });
822
-
823
- describe('MOB', () => {
824
- describe('isAddress', () => {
825
- it('should return true if the address matches criteria', () =>
826
- expect(validations.mobilecoin.isAddress('tRMEp/nPBdH76nQtomHxbw==')).toEqual(true));
827
- it('should return false if the address does not evaluate to a web3 address', () =>
828
- expect(validations.mobilecoin.isAddress('34242d8f17c440e584f416843e65a81030df000a3b4cc0d8aefdeca7330e1708')).toEqual(false));
829
- });
830
-
831
- describe('isTxHash', () => {
832
- it('should correctly validate a valid MOB hash', () =>
833
- expect(validations.mobilecoin.isTxHash('c8200fd70350f117367cf4eae6981b1fcb694813d8603d615e81a7ddba9cd54a')).toEqual(true));
834
-
835
- it('should correctly validate an incorrect MOB hash', () =>
836
- expect(validations.mobilecoin.isTxHash('c8200fd70350f117367cf4eae6981b1fcb694813d8603d615e81a7ddba9cd54a!')).toEqual(false));
837
- });
838
-
839
- describe('SUI', () => {
840
- describe('isAddress', () => {
841
- it('should return true if the address matches criteria', () =>
842
- expect(validations.sui.isAddress('0x6f8b96cf9ca872902c9308b025697749ffe5c91eff0840fd6206a364b1007e92')).toEqual(true));
843
- it('should return false if the address does not evaluate to a web3 address', () =>
844
- expect(validations.sui.isAddress('KLMNFADSAdsaaf8b96cf9ca872902c9308b025697749ffe5c91eff0840fd6206a364b1007e92')).toEqual(false));
845
- });
846
- describe('isTxHash', () => {
847
- it('should correctly validate a valid SUI hash', () =>
848
- expect(validations.sui.isTxHash('6PCZCFiPr3nTR1EoAt4NFY8n2CfJfAgUWRMExifGzcnz')).toEqual(true));
849
- it('should correctly validate an incorrect SUI hash', () =>
850
- expect(validations.sui.isTxHash('6PCZCFiPr3nTR1EoAt4NFY8n2CfJfAgUWRMExifGzcnz!?')).toEqual(false));
851
- });
852
- });
853
-
854
- describe('Flare', () => {
855
- describe('isAddress', () => {
856
- it('should return true if the address matches criteria', () =>
857
- expect(validations.flare.isAddress('0xefc66e65c64b000778f487a0262664b802ba773c')).toEqual(true));
858
- it('should return false if the address does not evaluate to a web3 address', () =>
859
- expect(validations.flare.isAddress('0xefc66e65c64b000778f487a0262664b802ba773c+A')).toEqual(false));
860
- });
861
- describe('isTxHash', () => {
862
- it('should correctly validate a valid Flare hash', () =>
863
- expect(validations.flare.isTxHash('0xa852639ff095dff22e05e6a3a6d8cbfaf4efe48e1c1e08bc4b235c805756cea7')).toEqual(true));
864
- it('should correctly validate an incorrect Flare hash', () =>
865
- expect(validations.flare.isTxHash('0xa852639ff095dff22e05e6a3a6d8cbfaf4efe48e1c1e08bc4b235c805756cea7AA!?')).toEqual(false));
866
- });
867
- });
868
- });
869
- });