@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,603 +0,0 @@
|
|
|
1
|
-
import validations from './validations';
|
|
2
|
-
|
|
3
|
-
const chai = require('chai');
|
|
4
|
-
|
|
5
|
-
const { expect, assert } = chai;
|
|
6
|
-
|
|
7
|
-
describe('Validations', () => {
|
|
8
|
-
describe('global checks', () => {
|
|
9
|
-
describe('exists', () => {
|
|
10
|
-
it('should return true when passed any value', () => validations.exists('x').should.be.true);
|
|
11
|
-
|
|
12
|
-
it('should return false when not passed a value', () => validations.exists().should.be.false);
|
|
13
|
-
});
|
|
14
|
-
|
|
15
|
-
describe('nonEmpty', () => {
|
|
16
|
-
it('should return true when passed any value with a length', () => validations.nonEmpty('x').should.be.true
|
|
17
|
-
&& validations.nonEmpty(['x']));
|
|
18
|
-
|
|
19
|
-
it('should return false when passed a value without a length', () => validations.nonEmpty().should.be.false
|
|
20
|
-
&& validations.nonEmpty({}).should.be.false
|
|
21
|
-
&& validations.nonEmpty(null).should.be.false
|
|
22
|
-
&& validations.nonEmpty(undefined).should.be.false);
|
|
23
|
-
});
|
|
24
|
-
|
|
25
|
-
describe('isNonEmptyString', () => {
|
|
26
|
-
it('should return true when passed a string of any length', () => validations.isNonEmptyString('x').should.be.true
|
|
27
|
-
&& validations.isNonEmptyString('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.').should.be.true);
|
|
28
|
-
|
|
29
|
-
it('should return false when passed an empty string or something that is not a string', () => validations.isNonEmptyString('').should.be.false
|
|
30
|
-
&& validations.isNonEmptyString(['x']).should.be.false
|
|
31
|
-
&& validations.isNonEmptyString({ key: 'val' }).should.be.false);
|
|
32
|
-
});
|
|
33
|
-
|
|
34
|
-
describe('ensureShortEnough', () => {
|
|
35
|
-
it('should return true when the given string is shorter in length than the given length', () => validations.ensureShortEnough(3, 'foo').should.be.true
|
|
36
|
-
&& validations.ensureShortEnough(3, 'fo').should.be.true);
|
|
37
|
-
|
|
38
|
-
it('should throw a BadRequest error if the given string is longer than the given length', () => {
|
|
39
|
-
expect(() => validations.ensureShortEnough(3, 'foo!')).to.throw('Max query size exceeded: 4 / 3');
|
|
40
|
-
});
|
|
41
|
-
|
|
42
|
-
it('should throw a BadRequest error if the given string is null or undefined', () => {
|
|
43
|
-
expect(() => validations.ensureShortEnough(3, null)).to.throw('Max query size exceeded: undefined / 3');
|
|
44
|
-
expect(() => validations.ensureShortEnough(3, undefined)).to.throw('Max query size exceeded: undefined / 3');
|
|
45
|
-
});
|
|
46
|
-
});
|
|
47
|
-
|
|
48
|
-
describe('ensure', () => {
|
|
49
|
-
it('should return true if the first argument is not null or undefined', () => validations.ensure('thing', 'Error message').should.be.true
|
|
50
|
-
&& validations.ensure(['array'], 'Error message').should.be.true
|
|
51
|
-
&& validations.ensure({ key: 'val' }).should.be.true);
|
|
52
|
-
it('should throw a BadRequest error if the first argument is null or undefined', () => {
|
|
53
|
-
expect(() => validations.ensure(null, 'Error message').to.throw('Error message'));
|
|
54
|
-
expect(() => validations.ensure(undefined, 'Error message').to.throw('Error message'));
|
|
55
|
-
});
|
|
56
|
-
});
|
|
57
|
-
describe('isSafeString', () => {
|
|
58
|
-
it('should return true if the first argument is a safe string', () => {
|
|
59
|
-
validations.isSafeString('aaaaa').should.be.true;
|
|
60
|
-
validations.isSafeString('Customer reference').should.be.true;
|
|
61
|
-
validations.isSafeString('Safe-String-01827!@').should.be.true;
|
|
62
|
-
validations.isSafeString('NewSafeCharacters $ £ & - $').should.be.true;
|
|
63
|
-
});
|
|
64
|
-
it('should return false if the first argument is not a safe string', () => {
|
|
65
|
-
validations.isSafeString('{customer}').should.be.false;
|
|
66
|
-
validations.isSafeString('<string>').should.be.false;
|
|
67
|
-
});
|
|
68
|
-
});
|
|
69
|
-
});
|
|
70
|
-
|
|
71
|
-
describe('check', () => {
|
|
72
|
-
describe('matches', () => {
|
|
73
|
-
it('should return true when passed two arrays that exactly match', () => validations.check.matches([1, 2, 3, 4, 5], [1, 2, 3, 4, 5], 'error message').should.be.true);
|
|
74
|
-
|
|
75
|
-
it('should throw an error when passed two arrays that do not exactly match', () => {
|
|
76
|
-
expect(() => validations.check.matches([1, 2, 3, 4], [1, 2, 3, 4, 5], 'Error message').to.throw('Error message'));
|
|
77
|
-
});
|
|
78
|
-
});
|
|
79
|
-
|
|
80
|
-
describe('wasFound', () => {
|
|
81
|
-
it('should return the string passed if this is not null', () => {
|
|
82
|
-
expect(validations.check.wasFound()('string')).to.equal('string');
|
|
83
|
-
});
|
|
84
|
-
it('should throw an error if the item is null', () => {
|
|
85
|
-
expect(() => validations.check.wasFound('no value')()).to.throw('Unknown no value');
|
|
86
|
-
});
|
|
87
|
-
});
|
|
88
|
-
|
|
89
|
-
describe('wasCreated', () => {
|
|
90
|
-
it('should return the array passed if it is not empty', () => {
|
|
91
|
-
expect(validations.check.wasCreated()([1, 2, 3])).to.eql([1, 2, 3]);
|
|
92
|
-
});
|
|
93
|
-
|
|
94
|
-
it('should throw an error if the array is empty', () => {
|
|
95
|
-
expect(() => validations.check.wasCreated('Oh no! No array!')([])).to.throw('Oh no! No array!');
|
|
96
|
-
});
|
|
97
|
-
});
|
|
98
|
-
|
|
99
|
-
describe('isTrue', () => {
|
|
100
|
-
const count = 2;
|
|
101
|
-
|
|
102
|
-
it('should return true when the first arg is truthy', () => {
|
|
103
|
-
assert(validations.check.isTrue(count === 2, 'Count equals 2'), 'isTrue should be false');
|
|
104
|
-
});
|
|
105
|
-
|
|
106
|
-
it('should throw an error when the first arg is falsy', () => {
|
|
107
|
-
expect(() => validations.check.isTrue(count <= 1, 'Count is greater than 1')).to.throw('Count is greater than 1');
|
|
108
|
-
});
|
|
109
|
-
});
|
|
110
|
-
|
|
111
|
-
describe('isFalse', () => {
|
|
112
|
-
const count = 2;
|
|
113
|
-
|
|
114
|
-
it('should return true when the first arg is falsy', () => {
|
|
115
|
-
assert(validations.check.isFalse(count === 3, 'Count should not equal 3'), 'isFalse should be true');
|
|
116
|
-
});
|
|
117
|
-
|
|
118
|
-
it('should throw an error when the first arg is truthy', () => {
|
|
119
|
-
expect(() => validations.check.isFalse(count > 1, 'Count should be greater than 1')).to.throw('Count should be greater than 1');
|
|
120
|
-
});
|
|
121
|
-
});
|
|
122
|
-
|
|
123
|
-
describe('isCustomerReference', () => {
|
|
124
|
-
it('should return true if the string is longer than 0 and less than or equal to 100 characters', () => {
|
|
125
|
-
assert(validations.isCustomerReference('1'), 'isCustomerReference fails when the string length is 1');
|
|
126
|
-
assert(validations.isCustomerReference('Spots of sunshine lie on the surface of the water dance, dance, and their reflections wobble.'), 'isCustomerReference fails when the string length is 100');
|
|
127
|
-
});
|
|
128
|
-
|
|
129
|
-
it('should return false when passed an empty string or one longer than 100 characters, or a non-string', () => {
|
|
130
|
-
assert(!validations.isCustomerReference(''), 'isCustomerReference passes when passed an empty string');
|
|
131
|
-
assert(!validations.isCustomerReference('Little spots of sunshine lie on the surface of the water and dance, dance, and their reflections wobble deliciously over the ceiling;'), 'isCustomerReference passes with string over 100 characters');
|
|
132
|
-
assert(!validations.isCustomerReference(['array']), 'isCustomerReference passes when passed a non-string');
|
|
133
|
-
});
|
|
134
|
-
});
|
|
135
|
-
|
|
136
|
-
describe('isCustomerLabelName', () => {
|
|
137
|
-
it('should return true if the string is longer than 0 and less than or equal to 50 characters', () => {
|
|
138
|
-
assert(validations.isCustomerLabelName('1'), 'isCustomerLabelName fails when the string length is 1');
|
|
139
|
-
assert(validations.isCustomerLabelName('William Shakespeare was poet, playwright and actor'), 'isCustomerLabelName fails when the string length is 50');
|
|
140
|
-
});
|
|
141
|
-
|
|
142
|
-
it('should return false when passed an empty string or one longer than 50 characters, or a non-string', () => {
|
|
143
|
-
assert(!validations.isCustomerLabelName(''), 'isCustomerLabelName passes when passed an empty string');
|
|
144
|
-
assert(!validations.isCustomerLabelName("Many of Shakespeare's plays were published in editions of varying quality and accuracy in his lifetime."), 'isCustomerLabelName passes with string over 50 characters');
|
|
145
|
-
assert(!validations.isCustomerLabelName(['array']), 'isCustomerLabelName passes when passed a non-string');
|
|
146
|
-
});
|
|
147
|
-
});
|
|
148
|
-
});
|
|
149
|
-
|
|
150
|
-
describe('BCH', () => {
|
|
151
|
-
describe('isAddress', () => {
|
|
152
|
-
it('should correctly validate valid BCH addresses', () => validations.bitcoinCash.isAddress('bitcoincash:qrrfmt57avxfd2476gqxqq54djtcvjuzjc2qtsrzcw').should.be.true
|
|
153
|
-
&& validations.bitcoinCash.isAddress('qqrxa0h9jqnc7v4wmj9ysetsp3y7w9l36u8gnnjulq').should.be.true);
|
|
154
|
-
|
|
155
|
-
it('should correctly validate an incorrect BCH address', () => validations.bitcoinCash.isAddress('qqrxa0h9jqnc7v4wmj3y7w9l36u8gnnjulq').should.be.false);
|
|
156
|
-
});
|
|
157
|
-
|
|
158
|
-
describe('isTxHash', () => {
|
|
159
|
-
it('should correctly validate a valid BCH hash', () => validations.bitcoinCash.isTxHash('a32c4d2f9f2e322f19867dbacb7609a1be63c914b8f41775082b50d3ee1a0ce6').should.be.true);
|
|
160
|
-
|
|
161
|
-
it('should correctly validate an incorrect BCH hash', () => validations.bitcoinCash.isTxHash('cd1bdc201022ca9386d8757b1c49ecc6ee3769cad2d42ab6e7f9e7bd831').should.be.false);
|
|
162
|
-
|
|
163
|
-
it('should return false when passed a non-hex string', () => validations.bitcoinCash.isTxHash('Not a hex string!').should.be.false);
|
|
164
|
-
});
|
|
165
|
-
});
|
|
166
|
-
|
|
167
|
-
describe('BNB', () => {
|
|
168
|
-
describe('isAddress', () => {
|
|
169
|
-
it('should correctly validate valid BNB addresses', () => validations.binanceChain.isAddress('bnb1z35wusfv8twfele77vddclka9z84ugywug48gn').should.be.true);
|
|
170
|
-
|
|
171
|
-
it('should correctly validate an incorrect BNB address', () => validations.binanceChain.isAddress('bnb1z35wusfv8twfele77vddclka9z84ugywug48gn1').should.be.false);
|
|
172
|
-
});
|
|
173
|
-
|
|
174
|
-
describe('isTxHash', () => {
|
|
175
|
-
it('should correctly validate a valid BNB hash', () => validations.binanceChain.isTxHash('E68C2D178F989DE296FA1B513D1AA138B234C436B52E0D755C6664A70F7EEF7B').should.be.true);
|
|
176
|
-
|
|
177
|
-
it('should correctly validate an incorrect BNB hash', () => validations.binanceChain.isTxHash('E68C2D178F989DE296FA1B513D1AA138B234C436B52E0D755C6664A70F7EEF7B1').should.be.false);
|
|
178
|
-
|
|
179
|
-
it('should return false when passed a non-hex string', () => validations.binanceChain.isTxHash('Not a hex string!').should.be.false);
|
|
180
|
-
});
|
|
181
|
-
});
|
|
182
|
-
|
|
183
|
-
describe('BTC', () => {
|
|
184
|
-
describe('isAddress', () => {
|
|
185
|
-
it('should correctly validate a valid BTC address', () => validations.bitcoin.isAddress('1LFnX5KT4CMKud7KB9xaXFZFkD3H8bUD16').should.be.true);
|
|
186
|
-
|
|
187
|
-
it('should correctly validate an incorrect BTC address', () => validations.bitcoin.isAddress('1LFnX5KT4CMKud7KB9xaXFZFkD3H8b').should.be.false);
|
|
188
|
-
});
|
|
189
|
-
|
|
190
|
-
describe('isBech32Address', () => {
|
|
191
|
-
it('should correctly validate a Bech32 address', () => validations.bitcoin.isBech32Address('bc1qar0srrr7xfkvy5l643lydnw9re59gtzzwf5mdq').should.be.true);
|
|
192
|
-
it('should correctly validate an invalide Bech32 address', () => validations.bitcoin.isBech32Address('4ef47f6eb681d5d9fa2f7e16336cd629303c635e8da51e425b76088be9c8744c').should.be.false);
|
|
193
|
-
});
|
|
194
|
-
|
|
195
|
-
describe('isHDPublicKey', () => {
|
|
196
|
-
it('should return true when passed an HD public key', () => validations.bitcoin.isHDPublicKey('xprv9s21ZrQH143K3QTDL4LXw2F7HEK3wJUD2nW2nRk4stbPy6cq3jPPqjiChkVvvNKmPGJxWUtg6LnF5kejMRNNU3TGtRBeJgk33yuGBxrMPHi').should.be.true);
|
|
197
|
-
it('should return false when not passed an HD public key', () => validations.bitcoin.isHDPublicKey('bc1qar0srrr7xfkvy5l643lydnw9re59gtzzwf5mdq').should.be.false);
|
|
198
|
-
});
|
|
199
|
-
|
|
200
|
-
describe('isPublicKey', () => {
|
|
201
|
-
it('should return true when passed a public key', () => validations.bitcoin.isPublicKey('046c04c02f1138f440e8c5e9099db938bfba93d0389528bb7f6bf423ae203a2edcfba133f0409023d7ea13ac01c5aeedaf0bbfbeb8b82e9b48410d93a296da5b0c').should.be.true);
|
|
202
|
-
it('should return false when not passed a public key', () => validations.bitcoin.isPublicKey('1EHNa6Q4Jz2uvNExL497mE43ikXhwF6kZm').should.be.false);
|
|
203
|
-
});
|
|
204
|
-
|
|
205
|
-
describe('isTxHash', () => {
|
|
206
|
-
it('should correctly validate a valid BTC hash', () => validations.bitcoin.isTxHash('835346f3ea00a23df60ca5dc24afce67810c792ac4505e544410d4b19e7c95a0').should.be.true);
|
|
207
|
-
it('should correctly validate an incorrect BTC hash', () => validations.bitcoin.isTxHash('835346f3ea00a23df60caafce67810c792ac4505e544410d4b19e7c95a0').should.be.false);
|
|
208
|
-
it('should return false if the string passed is not a hex string', () => validations.bitcoin.isTxHex('Definitely not a hex string').should.be.false);
|
|
209
|
-
});
|
|
210
|
-
|
|
211
|
-
describe('isTxHex', () => {
|
|
212
|
-
const hex = '0100000002d8c8df6a6fdd2addaf589a83d860f18b44872d13ee6ec3526b2b470d42a96d4d000000008b483045022100b31557e47191936cb14e013fb421b1860b5e4fd5d2bc5ec1938f4ffb1651dc8902202661c2920771fd29dd91cd4100cefb971269836da4914d970d333861819265ba014104c54f8ea9507f31a05ae325616e3024bd9878cb0a5dff780444002d731577be4e2e69c663ff2da922902a4454841aa1754c1b6292ad7d317150308d8cce0ad7abffffffff2ab3fa4f68a512266134085d3260b94d3b6cfd351450cff021c045a69ba120b2000000008b4830450220230110bc99ef311f1f8bda9d0d968bfe5dfa4af171adbef9ef71678d658823bf022100f956d4fcfa0995a578d84e7e913f9bb1cf5b5be1440bcede07bce9cd5b38115d014104c6ec27cffce0823c3fecb162dbd576c88dd7cda0b7b32b0961188a392b488c94ca174d833ee6a9b71c0996620ae71e799fc7c77901db147fa7d97732e49c8226ffffffff02c0175302000000001976a914a3d89c53bb956f08917b44d113c6b2bcbe0c29b788acc01c3d09000000001976a91408338e1d5e26db3fce21b011795b1c3c8a5a5d0788ac00000000';
|
|
213
|
-
it('should return true if passed a hex string Tx hash', () => validations.bitcoin.isTxHex(hex).should.be.true);
|
|
214
|
-
it('should return false if the string passed is not a hex string', () => validations.bitcoin.isTxHex('definitelyNotAHexString').should.be.false);
|
|
215
|
-
it('should return false if the string passed is a hex string, but is not a tx hash', () => validations.bitcoin.isTxHex('4ef47f6eb681d5d9fa2f7e16336cd629303c635e8da51e425b76088be9c8744c').should.be.false);
|
|
216
|
-
});
|
|
217
|
-
|
|
218
|
-
describe('isHDPath', () => {
|
|
219
|
-
it('should return true when passed a valid HDPrivateKey path', () => validations.bitcoin.isHDPath('xprv9s21ZrQH143K3QTDL4LXw2F7HEK3wJUD2nW2nRk4stbPy6cq3jPPqjiChkVvvNKmPGJxWUtg6LnF5kejMRNNU3TGtRBeJgk33yuGBxrMPHi'));
|
|
220
|
-
it('should return false when passed a string that is not a valid HDPrivateKey path', () => validations.bitcoin.isHDPath('bc1qar0srrr7xfkvy5l643lydnw9re59gtzzwf5mdq').should.be.false);
|
|
221
|
-
});
|
|
222
|
-
|
|
223
|
-
describe('isScriptHex', () => {
|
|
224
|
-
it('should return true when passed a script hex', () => validations.bitcoin.isScriptHex('01000000011e2e8cfdf21d68f90974cd557a30c11894cc8cfec5cd5330e41846c2c84566bd000000006b4830450221009f61f453f44e807fdc538ca21710393d34005dd5709dabd8b6b9ccf09ea0b36a0220420d91a33f43d7b979471220e12cd1025975bd2e6c0bf2a14eb65ad89d578104012102de8f92034b9b3c956c1896d23a628537561e29faa772438aac2265c91ede6519ffffffff0118566202000000001976a914b27f04e510293c3e530e7b7bdf71f59118030e1e88ac00000000').should.be.true);
|
|
225
|
-
it('should return false if the string passed is not a hex string', () => validations.bitcoin.isScriptHex('definitelyNotAHexString').should.be.false);
|
|
226
|
-
it('should return false if the string passed is a hex string, but is not a script hex', () => validations.bitcoin.isScriptHex('mpXwg4jMtRhuSpVq4xS3HFHmCmWp9NyGKt').should.be.false);
|
|
227
|
-
});
|
|
228
|
-
|
|
229
|
-
describe('isTxSignature', () => {
|
|
230
|
-
it('should return true when passed a tx hash that includes a signature', () => validations.bitcoin.isTxSignature('304502206e21798a42fae0e854281abd38bacd1aeed3ee3738d9e1446618c4571d1090db022100e2ac980643b0b82c0e88ffdfec6b64e3e6ba35e7ba5fdd7d5d6cc8d25c6b241501').should.be.true);
|
|
231
|
-
it('should return false when passed a tx hash that does not include a signature', () => validations.bitcoin.isTxSignature('f5d8ee39a430901c91a5917b9f2dc19d6d1a0e9cea205b009ca73dd04470b9a6').should.be.false);
|
|
232
|
-
it('should return false if the string passed is not a hex string', () => validations.bitcoin.isTxSignature('definitelyNotAHexString').should.be.false);
|
|
233
|
-
});
|
|
234
|
-
|
|
235
|
-
describe('isBlockHeight', () => {
|
|
236
|
-
it('should return true when passed a value greater than or equal to 0', () => validations.bitcoin.isBlockHeight(986789).should.be.true
|
|
237
|
-
&& validations.bitcoin.isBlockHeight('987654').should.be.true);
|
|
238
|
-
it('should return false when passed a value that is not greater than or equal to 0', () => validations.bitcoin.isBlockHeight(null).should.be.false
|
|
239
|
-
&& validations.bitcoin.isBlockHeight('string').should.be.false);
|
|
240
|
-
});
|
|
241
|
-
});
|
|
242
|
-
|
|
243
|
-
describe('ETH', () => {
|
|
244
|
-
describe('isAddress', () => {
|
|
245
|
-
it('should return true if the address evaluates as a web3 address', () => validations.ethereum.isAddress('0xa6Bc4b3fe7F2756124d30D896Fe4457711e9d214').should.be.true);
|
|
246
|
-
it('should return false if the address does not evaluate to a web3 address', () => validations.ethereum.isAddress('Bc4b3fe7F2756124d30D896Fe4457711e9d214').should.be.false);
|
|
247
|
-
});
|
|
248
|
-
|
|
249
|
-
describe('isBlockHash', () => {
|
|
250
|
-
it('should return true when given a valid hash', () => validations.ethereum.isBlockHash('0xec6491abd46a1a9a71b78f4b84d96fd49525aa4f66c8d8c3588c489f2f88eb0e').should.be.true);
|
|
251
|
-
it('should return false when given an vinalid hash', () => validations.ethereum.isBlockHash('0xec6491abd46a1a9a71b78f4b84d96fd49525aa4f66c8d8c3588c489eb0e').should.be.false);
|
|
252
|
-
});
|
|
253
|
-
|
|
254
|
-
describe('isTxHash', () => {
|
|
255
|
-
it('should correctly validate a valid ETH hash', () => validations.ethereum.isTxHash('0xec6491abd46a1a9a71b78f4b84d96fd49525aa4f66c8d8c3588c489f2f88eb0e').should.be.true);
|
|
256
|
-
|
|
257
|
-
it('should correctly validate an incorrect ETH hash', () => validations.ethereum.isTxHash('0xec6491abd46a1a9a71b7896fd49525aa4f66c8d8c3588c489f2f88eb0e').should.be.false);
|
|
258
|
-
});
|
|
259
|
-
|
|
260
|
-
describe('isAddressCode', () => {
|
|
261
|
-
it('should return true if the string is a hex address', () => validations.ethereum.isAddressCode('0xa6Bc4b3fe7F2756124d30D896Fe4457711e9d214').should.be.true);
|
|
262
|
-
it('should return false if the string is not a hex address', () => validations.ethereum.isAddressCode('0xa6Bc4b3fe7F27yu124d30D896Fe4457711e9d214').should.be.false);
|
|
263
|
-
});
|
|
264
|
-
|
|
265
|
-
describe('isValidWeiAmount', () => {
|
|
266
|
-
it('should return true when passed an amount that evaluates to wei', () => validations.ethereum.isValidWeiAmount('7000000000000000').should.be.true);
|
|
267
|
-
it('should return false when passed an amount that is not valid in wei', () => validations.ethereum.isValidWeiAmount(7000000000000000).should.be.false
|
|
268
|
-
&& validations.ethereum.isValidWeiAmount('1000.00').should.be.false);
|
|
269
|
-
});
|
|
270
|
-
});
|
|
271
|
-
|
|
272
|
-
describe('LTC', () => {
|
|
273
|
-
describe('isAddress', () => {
|
|
274
|
-
it('should correctly validate valid LTC addresses', () => validations.litecoin.isAddress('LMR7przNNMS3GpaD6Ygq64NxbsJsZAqGgM').should.be.true);
|
|
275
|
-
|
|
276
|
-
it('should correctly validate valid LTC MimbleWimble addresses', () => validations.litecoin.isAddress('ltcmweb1qq2aejfd7svtnqk0uq0cfkd9mr9sszypmx2phdu5qwfhlujazv2nxjqstgy3r5gkxesu5vv2v0tmlwdwhat3se36pwzwtlqm8ypxq3d2fggc8d7nq').should.be.true);
|
|
277
|
-
|
|
278
|
-
it('should correctly validate an incorrect LTC address', () => validations.litecoin.isAddress('t1t8BzkNb8d98o8kpbwrjtUjMX3GMF').should.be.false);
|
|
279
|
-
});
|
|
280
|
-
|
|
281
|
-
describe('isTxHash', () => {
|
|
282
|
-
it('should correctly validate a valid LTC hash', () => validations.litecoin.isTxHash('b0b858b34675cc8f851e6a2174295ada574837422538efe9ca83ef405d2faf29').should.be.true);
|
|
283
|
-
|
|
284
|
-
it('should correctly validate an incorrect LTC hash', () => validations.litecoin.isTxHash('b0b858b34675cc8f851e6a2295ada574837422538efe9ca83ef405d2faf29').should.be.false);
|
|
285
|
-
|
|
286
|
-
it('should return false when passed a non-hex string', () => validations.litecoin.isTxHash('Not a hex code here').should.be.false);
|
|
287
|
-
});
|
|
288
|
-
});
|
|
289
|
-
|
|
290
|
-
describe('XLM', () => {
|
|
291
|
-
describe('isAddress', () => {
|
|
292
|
-
it('should correctly validate valid XLM addresses', () => validations.stellar.isAddress('GBH4TZYZ4IRCPO44CBOLFUHULU2WGALXTAVESQA6432MBJMABBB4GIYI').should.be.true);
|
|
293
|
-
|
|
294
|
-
it('should correctly validate an incorrect XLM address', () => validations.stellar.isAddress('GBH4TZYZ4IRCPO44CAAAAAAULU2WGALXTAVESQA6432MBJMABBB4GIYI').should.be.false);
|
|
295
|
-
});
|
|
296
|
-
|
|
297
|
-
describe('isTxHash', () => {
|
|
298
|
-
it('should correctly validate a valid XLM hash', () => validations.stellar.isTxHash('dcf208070966a0f04dbff0be6abe5bc7ea2d77f16167e89e1869a8efc68ebe44').should.be.true);
|
|
299
|
-
|
|
300
|
-
it('should correctly validate an incorrect XLM hash', () => validations.stellar.isTxHash('8ee1f64137b12d07f8d2ddd3460d78ecbe37ba671aa4e54af34de935cc2bba2ca').should.be.false);
|
|
301
|
-
|
|
302
|
-
it('should return false when passed a non-hex string', () => validations.stellar.isTxHash('Yet again this is not a hex string').should.be.false);
|
|
303
|
-
});
|
|
304
|
-
});
|
|
305
|
-
|
|
306
|
-
describe('XRP', () => {
|
|
307
|
-
describe('isAddress', () => {
|
|
308
|
-
it('should correctly validate valid XRP addresses', () => validations.ripple.isAddress('rDV3RhpWznRCmtpD17RNxg6t4Hg8NPV8mF').should.be.true);
|
|
309
|
-
|
|
310
|
-
it('should correctly validate an incorrect XRP address', () => validations.ripple.isAddress('rDV3RhpWznRCmtpD17RNxg0t4Hg8NPV8mF').should.be.false);
|
|
311
|
-
});
|
|
312
|
-
|
|
313
|
-
describe('isTxHash', () => {
|
|
314
|
-
it('should correctly validate a valid XRP hash', () => validations.ripple.isTxHash('C6593DD2A32ED5120DF1FE80665B84A9CCAF06ADDC2EF89F720CBAC3E8069C0E').should.be.true);
|
|
315
|
-
|
|
316
|
-
it('should correctly validate an incorrect XRP hash', () => validations.ripple.isTxHash('C6593DD2A32ED5120DF1FE84A9CCAF06ADDC2EF89F720CBAC3E8069C0E').should.be.false);
|
|
317
|
-
|
|
318
|
-
it('should return false when passed a non-hex string', () => validations.ripple.isTxHash('Yet again this is not a hex string').should.be.false);
|
|
319
|
-
});
|
|
320
|
-
});
|
|
321
|
-
|
|
322
|
-
describe('ZEC', () => {
|
|
323
|
-
describe('isAddress', () => {
|
|
324
|
-
it('should correctly validate valid ZEC addresses', () => validations.zcash.isAddress('t1Jxptj7GnXQRsLNH5wWnDrGwEipEB3aZtf').should.be.true);
|
|
325
|
-
|
|
326
|
-
it('should correctly validate an incorrect ZEC address', () => validations.zcash.isAddress('t1Jxptj7GnXQRsLNH5wWnDrGwEipEB3aZtf1').should.be.false);
|
|
327
|
-
});
|
|
328
|
-
|
|
329
|
-
describe('isTxHash', () => {
|
|
330
|
-
it('should correctly validate a valid ZEC hash', () => validations.zcash.isTxHash('715c23949b85581de432f174a9e7f4d3f9e74b008064e2c68e7a52b1ec38e961').should.be.true);
|
|
331
|
-
|
|
332
|
-
it('should correctly validate an incorrect ZEC hash', () => validations.zcash.isTxHash('715c23949b85581de432f174a9e7f4d3f9e74b008064e2c68e7a52b1ec38e9611').should.be.false);
|
|
333
|
-
|
|
334
|
-
it('should return false when passed a non-hex string', () => validations.zcash.isTxHash('Yet again this is not a hex string').should.be.false);
|
|
335
|
-
});
|
|
336
|
-
});
|
|
337
|
-
|
|
338
|
-
describe('ZEN', () => {
|
|
339
|
-
describe('isAddress', () => {
|
|
340
|
-
it('should correctly validate valid ZEN addresses', () => validations.horizen.isAddress('znUovxhrE91tep6D7YtgSc3XJZoYQLVDwVn').should.be.true);
|
|
341
|
-
|
|
342
|
-
it('should correctly validate an incorrect ZEN address', () => validations.horizen.isAddress('znUovxhrE91tep6D7YtgSc3XJZoYQLVDwVn1').should.be.false);
|
|
343
|
-
});
|
|
344
|
-
|
|
345
|
-
describe('isTxHash', () => {
|
|
346
|
-
it('should correctly validate a valid ZEN hash', () => validations.horizen.isTxHash('e5d31deb3fee023758f0b79d06489df975fce9aa53351b9b5c8491e4c33c74b7').should.be.true);
|
|
347
|
-
|
|
348
|
-
it('should correctly validate an incorrect ZEN hash', () => validations.horizen.isTxHash('e5d31deb3fee023758f0b79d06489df975fce9aa53351b9b5c8491e4c33c74b71').should.be.false);
|
|
349
|
-
|
|
350
|
-
it('should return false when passed a non-hex string', () => validations.horizen.isTxHash('Yet again this is not a hex string').should.be.false);
|
|
351
|
-
});
|
|
352
|
-
});
|
|
353
|
-
|
|
354
|
-
describe('ZIL', () => {
|
|
355
|
-
describe('isAddress', () => {
|
|
356
|
-
it('should correctly validate valid ZIL addresses', () => validations.zilliqa.isAddress('zil1tw5rpejf96e76ty93l7c3dn0g79h2qhhdm28a4').should.be.true);
|
|
357
|
-
|
|
358
|
-
it('should correctly validate an incorrect ZIL address', () => validations.zilliqa.isAddress('0x14456246cc53d31f0a2EB00FA0248F7aEbD3fa8').should.be.false);
|
|
359
|
-
});
|
|
360
|
-
|
|
361
|
-
describe('isTxHash', () => {
|
|
362
|
-
it('should correctly validate a valid ZIL hash', () => validations.zilliqa.isTxHash('0xb9a04481c546258e339f8ce4cccdee3f179cc37a8f099f0608baf39e0a819f75').should.be.true);
|
|
363
|
-
|
|
364
|
-
it('should correctly validate an incorrect ZIL hash', () => validations.zilliqa.isTxHash('0xb9a04481c546258e339f8ce4cccdee3f179cc37a8f099f0608baf39e0a819f7').should.be.false);
|
|
365
|
-
|
|
366
|
-
it('should return false when passed a non-hex string', () => validations.zilliqa.isTxHash('Yet again this is not a hex string').should.be.false);
|
|
367
|
-
});
|
|
368
|
-
});
|
|
369
|
-
|
|
370
|
-
describe('ALGO', () => {
|
|
371
|
-
describe('isAddress', () => {
|
|
372
|
-
it('should correctly validate valid ALGO addresses', () => validations.algorand.isAddress('GX3XLHSRMFTADVKJBBQBTZ6BKINW6ZO5JHXWGCWB4CPDNPDQ2PIYN4AVHQ').should.be.true);
|
|
373
|
-
|
|
374
|
-
it('should correctly validate an incorrect ALGO address', () => validations.algorand.isAddress('GX3XLHBQBTZ6BKINW6ZO5JHXWGCWB4CPDNPDQ2PIYN4AVHQ').should.be.false);
|
|
375
|
-
});
|
|
376
|
-
|
|
377
|
-
describe('isTxHash', () => {
|
|
378
|
-
it('should correctly validate a valid ALGO hash', () => validations.algorand.isTxHash('TDITWGH5FODF2EUSKBAZ4DDC323NDBCBCE6BSXVXTZBINTCVQVVQ').should.be.true);
|
|
379
|
-
|
|
380
|
-
it('should correctly validate an incorrect ALGO hash', () => validations.algorand.isTxHash('TDITWGH5FOBAZ4DDC323NDBCBCE6BSXVXTZBINTCVQVVQ').should.be.false);
|
|
381
|
-
|
|
382
|
-
it('should return false when passed a non-hex string', () => validations.algorand.isTxHash('Yet again this is not a hex string').should.be.false);
|
|
383
|
-
});
|
|
384
|
-
});
|
|
385
|
-
|
|
386
|
-
describe('DOT', () => {
|
|
387
|
-
describe('isAddress', () => {
|
|
388
|
-
it('should correctly validate valid DOT addresses', () => validations.polkadot.isAddress('14YJztsPZEiKuKhU3qLd6JjiY4awfdUru8Xu7BDdZAUuG8S6').should.be.true);
|
|
389
|
-
|
|
390
|
-
it('should correctly validate an incorrect DOT address', () => validations.polkadot.isAddress('14YJztsPZEiKuKjiY4awfdUru8Xu7BDdZAUuG8S6').should.be.false);
|
|
391
|
-
});
|
|
392
|
-
|
|
393
|
-
describe('isTxHash', () => {
|
|
394
|
-
it('should correctly validate a valid DOT hash', () => validations.polkadot.isTxHash('0x975ba4cfd83dd7f4f6e2c1932f4aeb650391f00d57c3856907d668a99fd90609').should.be.true);
|
|
395
|
-
|
|
396
|
-
it('should correctly validate an incorrect DOT hash', () => validations.polkadot.isTxHash('0x975ba4cfd83dd7f4f2f4aeb650391f00d57c3856907d668a99fd90609').should.be.false);
|
|
397
|
-
|
|
398
|
-
it('should return false when passed a non-hex string', () => validations.polkadot.isTxHash('Yet again this is not a hex string').should.be.false);
|
|
399
|
-
});
|
|
400
|
-
});
|
|
401
|
-
|
|
402
|
-
describe('ATOM', () => {
|
|
403
|
-
describe('isAddress', () => {
|
|
404
|
-
it('should correctly validate valid ATOM addresses', () => validations.cosmos.isAddress('cosmos153lf4zntqt33a4v0sm5cytrxyqn78q7kz8j8x5').should.be.true);
|
|
405
|
-
|
|
406
|
-
it('should correctly validate an incorrect ATOM address', () => validations.cosmos.isAddress('kosmos153lf4zntqt33a4v0sm5cytrxyqn78q7kz8j8x5').should.be.false);
|
|
407
|
-
|
|
408
|
-
it('should correctly validate an incorrect (too long) ATOM address', () => validations.cosmos.isAddress('cosmos153lf4zntqt33a4v0sm5cytrxyqn78q7kz8j8x50').should.be.false);
|
|
409
|
-
});
|
|
410
|
-
|
|
411
|
-
describe('isTxHash', () => {
|
|
412
|
-
it('should correctly validate a valid ATOM hash', () => validations.cosmos.isTxHash('BFA0252193CCAA0592AF2A27541473E7F6422A9AD85CFC9525CF67FA2AA2CD6F').should.be.true);
|
|
413
|
-
|
|
414
|
-
it('should correctly validate an incorrect ATOM hash', () => validations.cosmos.isTxHash('BFA0252193CCAA0592AF2A27541473E7').should.be.false);
|
|
415
|
-
|
|
416
|
-
it('should return false when passed a non-hex string', () => validations.cosmos.isTxHash('ZZA0252193CCAA0592AF2A27541473E7F6422A9AD85CFC9525CF67FA2AA2CD6F').should.be.false);
|
|
417
|
-
});
|
|
418
|
-
});
|
|
419
|
-
|
|
420
|
-
describe('SOL', () => {
|
|
421
|
-
describe('isAddress', () => {
|
|
422
|
-
it('should correctly validate valid SOL addresses', () => validations.solana.isAddress('A4JXQF7p9sHR5apRy2hVgKFAHHs7jdpQv9kFGLDit24T').should.be.true);
|
|
423
|
-
|
|
424
|
-
it('should correctly validate an incorrect SOL address', () => validations.solana.isAddress('L0JXQF7p9sHR5apRy2hVgKFAHHs7jdpQv9kFGLDit24T').should.be.false);
|
|
425
|
-
|
|
426
|
-
it('should correctly validate an incorrect (too long) SOL address', () => validations.solana.isAddress('A4JXQF7p9sHR5apRy2hVgKFAHHs7jdpQv9kFGLDit24TAAAAAAAAAAAAAAA').should.be.false);
|
|
427
|
-
});
|
|
428
|
-
|
|
429
|
-
describe('isTxHash', () => {
|
|
430
|
-
it('should correctly validate a valid SOL hash', () => validations.solana.isTxHash('2WcPszZnXBLpu9WzLbGRfwzETPHfTRi4E8fmVedFT4bPYc1BiELG3Ldway6oPTSXpVJZRM4mqEdz2Uuh5n9VQp8x').should.be.true);
|
|
431
|
-
|
|
432
|
-
it('should correctly validate an incorrect SOL hash', () => validations.solana.isTxHash('2WcPszZnXBLpu9WzLbGRfwzET').should.be.false);
|
|
433
|
-
});
|
|
434
|
-
});
|
|
435
|
-
|
|
436
|
-
describe('BSC', () => {
|
|
437
|
-
describe('isAddress', () => {
|
|
438
|
-
it('should correctly validate valid BSC addresses', () => validations.binanceSmartChain.isAddress('0x5616e2b8acff064bf902b8a93cbd5da2ca1edc7c').should.be.true);
|
|
439
|
-
|
|
440
|
-
it('should correctly validate an incorrect BSC address', () => validations.binanceSmartChain.isAddress('0xz616e2b8acff064bf902b8a93cbd5da2ca1edc7c').should.be.false);
|
|
441
|
-
|
|
442
|
-
it('should correctly validate an incorrect (too long) BSC address', () => validations.binanceSmartChain.isAddress('0x5616e2b8acff064bf902b8a93cbd5da2ca1edc7caaaaa').should.be.false);
|
|
443
|
-
});
|
|
444
|
-
|
|
445
|
-
describe('isTxHash', () => {
|
|
446
|
-
it('should correctly validate a valid BSC hash', () => validations.binanceSmartChain.isTxHash('0x1a17145af3bec32f653d8ebd4c2c1b800214b17a7f8abfdda020cb1f39abe269').should.be.true);
|
|
447
|
-
|
|
448
|
-
it('should correctly validate an incorrect BSC hash', () => validations.binanceSmartChain.isTxHash('0x1a17145af3bec32f653d8ebd4c2c1b800214b17').should.be.false);
|
|
449
|
-
});
|
|
450
|
-
});
|
|
451
|
-
|
|
452
|
-
describe('Doge', () => {
|
|
453
|
-
describe('isAddress', () => {
|
|
454
|
-
it('should correctly validate valid Doge addresses', () => {
|
|
455
|
-
validations.doge.isAddress('9t3fCHSQz3j7XERcopTCUwMF3bZxJW99As').should.be.true;
|
|
456
|
-
validations.doge.isAddress('DQe2B39m3V68sXZPfUvdjv3QecYGAE2dBv').should.be.true;
|
|
457
|
-
});
|
|
458
|
-
|
|
459
|
-
it('should correctly validate an incorrect Doge address', () => validations.doge.isAddress('DQe2B39m3V68sXZPfUvdjv3QecYGAE2dB_').should.be.false);
|
|
460
|
-
|
|
461
|
-
it('should correctly validate an incorrect (too long) Doge address', () => validations.doge.isAddress('DQe2B39m3V68sXZPfUvdjv3QecYGAE2dBvQ').should.be.false);
|
|
462
|
-
});
|
|
463
|
-
|
|
464
|
-
describe('isTxHash', () => {
|
|
465
|
-
it('should correctly validate a valid Doge hash', () => validations.doge.isTxHash('ee3b8c45d4b84c07c7dc9e1c82752920ba6e7cda73354c0f399f81949513d418').should.be.true);
|
|
466
|
-
|
|
467
|
-
it('should correctly validate an incorrect Doge hash', () => validations.doge.isTxHash('ee3b8c45d4b84c07c7dc9e1c82752920ba6e7cda73354c0f399f81949513d41').should.be.false);
|
|
468
|
-
});
|
|
469
|
-
});
|
|
470
|
-
|
|
471
|
-
describe('Polygon', () => {
|
|
472
|
-
describe('isAddress', () => {
|
|
473
|
-
it('should correctly validate valid Polygon addresses', () => validations.polygon.isAddress('0x286c2bd6e0585f396647cbfdbfe14b92600365bb').should.be.true);
|
|
474
|
-
|
|
475
|
-
it('should correctly validate an incorrect Polygon address', () => validations.polygon.isAddress('0xz286c2bd6e0585f396647cbfdbfe14b92600365bb').should.be.false);
|
|
476
|
-
|
|
477
|
-
it('should correctly validate an incorrect (too long) Polygon address', () => validations.polygon.isAddress('0x286c2bd6e0585f396647cbfdbfe14b92600365bba').should.be.false);
|
|
478
|
-
});
|
|
479
|
-
|
|
480
|
-
describe('isTxHash', () => {
|
|
481
|
-
it('should correctly validate a valid Polygon hash', () => validations.polygon.isTxHash('0x45a491048477568dd2047a0a9b6be9cc491382e74823ea1bd53bbc67db54a867').should.be.true);
|
|
482
|
-
|
|
483
|
-
it('should correctly validate an incorrect Polygon hash', () => validations.polygon.isTxHash('0x45a491048477568dd2047a0a9b6be9cc491382e74823e').should.be.false);
|
|
484
|
-
});
|
|
485
|
-
});
|
|
486
|
-
|
|
487
|
-
describe('Filecoin', () => {
|
|
488
|
-
describe('isAddress', () => {
|
|
489
|
-
it('should correctly validate a valid Filecoin f0 address', () => validations.filecoin.isAddress('f01825161').should.be.true);
|
|
490
|
-
|
|
491
|
-
it('should correctly validate a valid Filecoin f1 address', () => validations.filecoin.isAddress('f1xafi3wsh7q553efnumhgeomathrehwwd2mye7oy').should.be.true);
|
|
492
|
-
|
|
493
|
-
it('should correctly validate a valid Filecoin f2 address', () => validations.filecoin.isAddress('f2vrab2ft4qc22mgfxgdrphd7ovvz6zs3nq3fv4oy').should.be.true);
|
|
494
|
-
|
|
495
|
-
it('should correctly validate a valid Filecoin f3 address', () => validations.filecoin.isAddress('f3ug2ti4finql5bxyl5q56udn5lt462miuadjg3ur467wrj6bvbrksglxyv65zoxyz4mgte3joyce3oxkk4q7q').should.be.true);
|
|
496
|
-
|
|
497
|
-
it('should correctly validate an invalid Filecoin address', () => validations.filecoin.isAddress('f4zvcxzvcxzvczvcasdgwere').should.be.false);
|
|
498
|
-
});
|
|
499
|
-
|
|
500
|
-
describe('isTxHash', () => {
|
|
501
|
-
it('should correctly validate a valid Filecoin hash', () => validations.filecoin.isTxHash('bafy2bzacedcrpcs76f2ws445wnjix2kktsgca4vv6qbd7zua7pc5mnkpveg7m').should.be.true);
|
|
502
|
-
|
|
503
|
-
it('should correctly validate an invalid Filecoin hash', () => validations.filecoin.isTxHash('bafy2bzacedcrpcs76f2ws445wnjix2kktsgca4vv6qbd7zua7pc5mnkpveg7').should.be.false);
|
|
504
|
-
|
|
505
|
-
it('should correctly validate an invalid Filecoin hash', () => validations.filecoin.isTxHash('fafy2bzacedcrpcs76f2ws445wnjix2kktsgca4vv6qbd7zua7pc5mnkpveg7m').should.be.false);
|
|
506
|
-
});
|
|
507
|
-
});
|
|
508
|
-
describe('Optimism', () => {
|
|
509
|
-
describe('isAddress', () => {
|
|
510
|
-
describe('isAddress', () => {
|
|
511
|
-
it('should return true if the address evaluates as a web3 address', () => validations.optimism.isAddress('0xa6Bc4b3fe7F2756124d30D896Fe4457711e9d214').should.be.true);
|
|
512
|
-
it('should return false if the address does not evaluate to a web3 address', () => validations.optimism.isAddress('Bc4b3fe7F2756124d30D896Fe4457711e9d214').should.be.false);
|
|
513
|
-
});
|
|
514
|
-
describe('isTxHash', () => {
|
|
515
|
-
it('should correctly validate a valid OP hash', () => validations.optimism.isTxHash('0xec6491abd46a1a9a71b78f4b84d96fd49525aa4f66c8d8c3588c489f2f88eb0e').should.be.true);
|
|
516
|
-
|
|
517
|
-
it('should correctly validate an incorrect OP hash', () => validations.optimism.isTxHash('0xec6491abd46a1a9a71b7896fd49525aa4f66c8d8c3588c489f2f88eb0e').should.be.false);
|
|
518
|
-
});
|
|
519
|
-
});
|
|
520
|
-
});
|
|
521
|
-
describe('Avalanche', () => {
|
|
522
|
-
describe('isAddress', () => {
|
|
523
|
-
describe('isAddress', () => {
|
|
524
|
-
it('should return true if the address evaluates as a web3 address', () => validations.avalanche.isAddress('0xa6Bc4b3fe7F2756124d30D896Fe4457711e9d214').should.be.true);
|
|
525
|
-
it('should return false if the address does not evaluate to a web3 address', () => validations.avalanche.isAddress('Bc4b3fe7F2756124d30D896Fe4457711e9d214').should.be.false);
|
|
526
|
-
});
|
|
527
|
-
describe('isTxHash', () => {
|
|
528
|
-
it('should correctly validate a valid AVAX hash', () => validations.avalanche.isTxHash('0xec6491abd46a1a9a71b78f4b84d96fd49525aa4f66c8d8c3588c489f2f88eb0e').should.be.true);
|
|
529
|
-
|
|
530
|
-
it('should correctly validate an incorrect AVAX hash', () => validations.avalanche.isTxHash('0xec6491abd46a1a9a71b7896fd49525aa4f66c8d8c3588c489f2f88eb0e').should.be.false);
|
|
531
|
-
});
|
|
532
|
-
});
|
|
533
|
-
});
|
|
534
|
-
describe('Arbitrum', () => {
|
|
535
|
-
describe('isAddress', () => {
|
|
536
|
-
describe('isAddress', () => {
|
|
537
|
-
it('should return true if the address evaluates as a web3 address', () => validations.arbitrum.isAddress('0xa6Bc4b3fe7F2756124d30D896Fe4457711e9d214').should.be.true);
|
|
538
|
-
it('should return false if the address does not evaluate to a web3 address', () => validations.arbitrum.isAddress('Bc4b3fe7F2756124d30D896Fe4457711e9d214').should.be.false);
|
|
539
|
-
});
|
|
540
|
-
describe('isTxHash', () => {
|
|
541
|
-
it('should correctly validate a valid Arbitrum hash', () => validations.arbitrum.isTxHash('0xec6491abd46a1a9a71b78f4b84d96fd49525aa4f66c8d8c3588c489f2f88eb0e').should.be.true);
|
|
542
|
-
|
|
543
|
-
it('should correctly validate an incorrect Arbitrum hash', () => validations.arbitrum.isTxHash('0xec6491abd46a1a9a71b7896fd49525aa4f66c8d8c3588c489f2f88eb0e').should.be.false);
|
|
544
|
-
});
|
|
545
|
-
});
|
|
546
|
-
});
|
|
547
|
-
|
|
548
|
-
describe('Tron', () => {
|
|
549
|
-
describe('isAddress', () => {
|
|
550
|
-
it('should correctly validate a valid Tron address', () => validations.tron.isAddress('TPCCPf13PDPp5nEGCiMrE7WXKstpZhmfDw').should.be.true);
|
|
551
|
-
|
|
552
|
-
it('should correctly validate an invalid Tron address', () => validations.tron.isAddress('TPCCPf13PDPp5nEGCiMrE7WXKstpZhmfDwZ').should.be.false);
|
|
553
|
-
});
|
|
554
|
-
|
|
555
|
-
describe('isTxHash', () => {
|
|
556
|
-
it('should correctly validate a valid Tron hash', () => validations.tron.isTxHash('2f63fad2b3f8ccce75490545c8a0dacbb0730ebd7d551a89b015d8ca4ab458f2').should.be.true);
|
|
557
|
-
|
|
558
|
-
it('should correctly validate an invalid Tron hash', () => validations.tron.isTxHash('2f63fad2b3f8ccce75490545c8a0dacbb0730ebd7d551a89b015d8ca4ab458fz').should.be.false);
|
|
559
|
-
|
|
560
|
-
it('should correctly validate an invalid Tron hash', () => validations.tron.isTxHash('2f63fad2b3f8ccce75490545c8a0dacbb0730ebd7d551a89b015d8ca4ab458f21').should.be.false);
|
|
561
|
-
});
|
|
562
|
-
});
|
|
563
|
-
|
|
564
|
-
describe('Fantom', () => {
|
|
565
|
-
describe('isAddress', () => {
|
|
566
|
-
describe('isAddress', () => {
|
|
567
|
-
it('should return true if the address evaluates as a web3 address', () => validations.fantom.isAddress('0xa6Bc4b3fe7F2756124d30D896Fe4457711e9d214').should.be.true);
|
|
568
|
-
it('should return false if the address does not evaluate to a web3 address', () => validations.fantom.isAddress('Bc4b3fe7F2756124d30D896Fe4457711e9d214').should.be.false);
|
|
569
|
-
});
|
|
570
|
-
describe('isTxHash', () => {
|
|
571
|
-
it('should correctly validate a valid Fantom hash', () => validations.fantom.isTxHash('0xec6491abd46a1a9a71b78f4b84d96fd49525aa4f66c8d8c3588c489f2f88eb0e').should.be.true);
|
|
572
|
-
|
|
573
|
-
it('should correctly validate an incorrect Fantom hash', () => validations.fantom.isTxHash('0xec6491abd46a1a9a71b7896fd49525aa4f66c8d8c3588c489f2f88eb0e').should.be.false);
|
|
574
|
-
});
|
|
575
|
-
});
|
|
576
|
-
});
|
|
577
|
-
|
|
578
|
-
describe('CELO', () => {
|
|
579
|
-
describe('isAddress', () => {
|
|
580
|
-
it('should return true if the address evaluates as a web3 address', () => validations.celo.isAddress('0x711520A753A23a3760B0361e0EB8d3A0eD472326').should.be.true);
|
|
581
|
-
it('should return false if the address does not evaluate to a web3 address', () => validations.celo.isAddress('0x711520A753A23a3760B0361e0EB8d3A0eD47232G').should.be.false);
|
|
582
|
-
});
|
|
583
|
-
|
|
584
|
-
describe('isTxHash', () => {
|
|
585
|
-
it('should correctly validate a valid CELO hash', () => validations.celo.isTxHash('0xad90ee6159a7760fda9c594dc0bb9a3fec8b5c57dc61e391b65e4f8d0efc2fab').should.be.true);
|
|
586
|
-
|
|
587
|
-
it('should correctly validate an incorrect CELO hash', () => validations.celo.isTxHash('0xad90ee6159a7760fda9c594dc0bb9a3fec8b5c57dc61e391b65e4f8d0efc2faG').should.be.false);
|
|
588
|
-
});
|
|
589
|
-
});
|
|
590
|
-
|
|
591
|
-
describe('ETC', () => {
|
|
592
|
-
describe('isAddress', () => {
|
|
593
|
-
it('should return true if the address evaluates as a web3 address', () => validations.ethereumClassic.isAddress('0x667B248015b02f35F0dBb7e02695f9D081CC5d26').should.be.true);
|
|
594
|
-
it('should return false if the address does not evaluate to a web3 address', () => validations.ethereumClassic.isAddress('0x667B248015b02f35F0dBb7e02695f9D081CC5d2G').should.be.false);
|
|
595
|
-
});
|
|
596
|
-
|
|
597
|
-
describe('isTxHash', () => {
|
|
598
|
-
it('should correctly validate a valid ETC hash', () => validations.ethereumClassic.isTxHash('0x5b410a65887837fe8c2b6fadf3bad8808411cef67ed22eba27f75f6d446673de').should.be.true);
|
|
599
|
-
|
|
600
|
-
it('should correctly validate an incorrect ETC hash', () => validations.ethereumClassic.isTxHash('0x5b410a65887837fe8c2b6fadf3bad8808411cef67ed22eba27f75f6d446673de!').should.be.false);
|
|
601
|
-
});
|
|
602
|
-
});
|
|
603
|
-
});
|
package/tsconfig.json
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"compilerOptions": {
|
|
3
|
-
"target": "es2018",
|
|
4
|
-
"module": "commonjs",
|
|
5
|
-
"lib": ["es2018"],
|
|
6
|
-
"declaration": true,
|
|
7
|
-
"outDir": "./dist",
|
|
8
|
-
"rootDir": "./lib",
|
|
9
|
-
"downlevelIteration": true,
|
|
10
|
-
"strict": true,
|
|
11
|
-
"strictNullChecks": true,
|
|
12
|
-
"strictFunctionTypes": true,
|
|
13
|
-
"strictPropertyInitialization": true,
|
|
14
|
-
"noImplicitThis": true,
|
|
15
|
-
"alwaysStrict": true,
|
|
16
|
-
"allowJs": true,
|
|
17
|
-
"noUnusedLocals": true,
|
|
18
|
-
"noImplicitReturns": true,
|
|
19
|
-
"noFallthroughCasesInSwitch": true,
|
|
20
|
-
"moduleResolution": "node",
|
|
21
|
-
"baseUrl": "./",
|
|
22
|
-
"types": ["node", "mocha", "chai"],
|
|
23
|
-
"esModuleInterop": true
|
|
24
|
-
},
|
|
25
|
-
"include": ["lib"]
|
|
26
|
-
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|