@ellipticltd/aml-utils 0.10.0 → 0.12.0-SCR-283.0

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.
@@ -0,0 +1,12 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <module type="WEB_MODULE" version="4">
3
+ <component name="NewModuleRootManager">
4
+ <content url="file://$MODULE_DIR$">
5
+ <excludeFolder url="file://$MODULE_DIR$/temp" />
6
+ <excludeFolder url="file://$MODULE_DIR$/.tmp" />
7
+ <excludeFolder url="file://$MODULE_DIR$/tmp" />
8
+ </content>
9
+ <orderEntry type="inheritedJdk" />
10
+ <orderEntry type="sourceFolder" forTests="false" />
11
+ </component>
12
+ </module>
@@ -0,0 +1,94 @@
1
+ <component name="ProjectCodeStyleConfiguration">
2
+ <code_scheme name="Project" version="173">
3
+ <option name="SOFT_MARGINS" value="80" />
4
+ <DBN-PSQL>
5
+ <case-options enabled="false">
6
+ <option name="KEYWORD_CASE" value="lower" />
7
+ <option name="FUNCTION_CASE" value="lower" />
8
+ <option name="PARAMETER_CASE" value="lower" />
9
+ <option name="DATATYPE_CASE" value="lower" />
10
+ <option name="OBJECT_CASE" value="preserve" />
11
+ </case-options>
12
+ <formatting-settings enabled="false" />
13
+ </DBN-PSQL>
14
+ <DBN-SQL>
15
+ <case-options enabled="false">
16
+ <option name="KEYWORD_CASE" value="lower" />
17
+ <option name="FUNCTION_CASE" value="lower" />
18
+ <option name="PARAMETER_CASE" value="lower" />
19
+ <option name="DATATYPE_CASE" value="lower" />
20
+ <option name="OBJECT_CASE" value="preserve" />
21
+ </case-options>
22
+ <formatting-settings enabled="false">
23
+ <option name="STATEMENT_SPACING" value="one_line" />
24
+ <option name="CLAUSE_CHOP_DOWN" value="chop_down_if_statement_long" />
25
+ <option name="ITERATION_ELEMENTS_WRAPPING" value="chop_down_if_not_single" />
26
+ </formatting-settings>
27
+ </DBN-SQL>
28
+ <HTMLCodeStyleSettings>
29
+ <option name="HTML_SPACE_INSIDE_EMPTY_TAG" value="true" />
30
+ <option name="HTML_DO_NOT_INDENT_CHILDREN_OF" value="html,body" />
31
+ </HTMLCodeStyleSettings>
32
+ <JSCodeStyleSettings version="0">
33
+ <option name="FORCE_SEMICOLON_STYLE" value="true" />
34
+ <option name="USE_DOUBLE_QUOTES" value="false" />
35
+ <option name="FORCE_QUOTE_STYlE" value="true" />
36
+ <option name="ENFORCE_TRAILING_COMMA" value="WhenMultiline" />
37
+ <option name="JSX_ATTRIBUTE_VALUE" value="Based on type" />
38
+ <option name="VAR_DECLARATION_WRAP" value="2" />
39
+ <option name="OBJECT_LITERAL_WRAP" value="2" />
40
+ <option name="SPACES_WITHIN_OBJECT_LITERAL_BRACES" value="true" />
41
+ <option name="SPACES_WITHIN_IMPORTS" value="true" />
42
+ <option name="IMPORT_SORT_MODULE_NAME" value="true" />
43
+ </JSCodeStyleSettings>
44
+ <MarkdownNavigatorCodeStyleSettings>
45
+ <option name="RIGHT_MARGIN" value="72" />
46
+ </MarkdownNavigatorCodeStyleSettings>
47
+ <PostgresCodeStyleSettings version="2">
48
+ <option name="KEYWORD_CASE" value="0" />
49
+ </PostgresCodeStyleSettings>
50
+ <SqlCodeStyleSettings version="2">
51
+ <option name="KEYWORD_CASE" value="0" />
52
+ </SqlCodeStyleSettings>
53
+ <TypeScriptCodeStyleSettings version="0">
54
+ <option name="FORCE_SEMICOLON_STYLE" value="true" />
55
+ <option name="USE_DOUBLE_QUOTES" value="false" />
56
+ <option name="FORCE_QUOTE_STYlE" value="true" />
57
+ <option name="ENFORCE_TRAILING_COMMA" value="WhenMultiline" />
58
+ <option name="SPACES_WITHIN_OBJECT_LITERAL_BRACES" value="true" />
59
+ <option name="SPACES_WITHIN_IMPORTS" value="true" />
60
+ </TypeScriptCodeStyleSettings>
61
+ <codeStyleSettings language="JSON">
62
+ <indentOptions>
63
+ <option name="INDENT_SIZE" value="4" />
64
+ </indentOptions>
65
+ </codeStyleSettings>
66
+ <codeStyleSettings language="JavaScript">
67
+ <option name="RIGHT_MARGIN" value="100" />
68
+ <option name="KEEP_BLANK_LINES_IN_CODE" value="1" />
69
+ <option name="ALIGN_MULTILINE_PARAMETERS" value="false" />
70
+ <option name="ALIGN_MULTILINE_FOR" value="false" />
71
+ <option name="METHOD_PARAMETERS_WRAP" value="1" />
72
+ <option name="METHOD_PARAMETERS_LPAREN_ON_NEXT_LINE" value="true" />
73
+ <option name="METHOD_CALL_CHAIN_WRAP" value="2" />
74
+ <option name="IF_BRACE_FORCE" value="1" />
75
+ <option name="DOWHILE_BRACE_FORCE" value="1" />
76
+ <option name="WHILE_BRACE_FORCE" value="1" />
77
+ <option name="FOR_BRACE_FORCE" value="1" />
78
+ <indentOptions>
79
+ <option name="INDENT_SIZE" value="2" />
80
+ <option name="CONTINUATION_INDENT_SIZE" value="2" />
81
+ <option name="TAB_SIZE" value="2" />
82
+ </indentOptions>
83
+ </codeStyleSettings>
84
+ <codeStyleSettings language="TypeScript">
85
+ <option name="ALIGN_MULTILINE_PARAMETERS" value="false" />
86
+ <option name="METHOD_PARAMETERS_WRAP" value="1" />
87
+ <indentOptions>
88
+ <option name="INDENT_SIZE" value="2" />
89
+ <option name="CONTINUATION_INDENT_SIZE" value="2" />
90
+ <option name="TAB_SIZE" value="2" />
91
+ </indentOptions>
92
+ </codeStyleSettings>
93
+ </code_scheme>
94
+ </component>
@@ -0,0 +1,5 @@
1
+ <component name="ProjectCodeStyleConfiguration">
2
+ <state>
3
+ <option name="USE_PER_PROJECT_SETTINGS" value="true" />
4
+ </state>
5
+ </component>
@@ -0,0 +1,6 @@
1
+ <component name="InspectionProjectProfileManager">
2
+ <profile version="1.0">
3
+ <option name="myName" value="Project Default" />
4
+ <inspection_tool class="Eslint" enabled="true" level="WARNING" enabled_by_default="true" />
5
+ </profile>
6
+ </component>
@@ -0,0 +1,8 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="ProjectModuleManager">
4
+ <modules>
5
+ <module fileurl="file://$PROJECT_DIR$/.idea/aml-utils.iml" filepath="$PROJECT_DIR$/.idea/aml-utils.iml" />
6
+ </modules>
7
+ </component>
8
+ </project>
package/.idea/vcs.xml ADDED
@@ -0,0 +1,6 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="VcsDirectoryMappings">
4
+ <mapping directory="$PROJECT_DIR$" vcs="Git" />
5
+ </component>
6
+ </project>
@@ -116,3 +116,21 @@ export namespace zilliqa {
116
116
  function isTxHash(str: any): any;
117
117
  function isTxHash(str: any): any;
118
118
  }
119
+ export namespace algorand {
120
+ function isAddress(str: any): any;
121
+ function isAddress(str: any): any;
122
+ function isTxHash(str: any): boolean;
123
+ function isTxHash(str: any): boolean;
124
+ }
125
+ export namespace tezos {
126
+ function isAddress(str: any): any;
127
+ function isAddress(str: any): any;
128
+ function isTxHash(str: any): boolean;
129
+ function isTxHash(str: any): boolean;
130
+ }
131
+ export namespace polkadot {
132
+ function isAddress(str: any): any;
133
+ function isAddress(str: any): any;
134
+ function isTxHash(str: any): any;
135
+ function isTxHash(str: any): any;
136
+ }
@@ -2,7 +2,7 @@
2
2
  const V = require('validator');
3
3
  const _ = require('lodash');
4
4
  const { crypto: { Signature }, HDPrivateKey, HDPublicKey, PublicKey, Script, Transaction, } = require('bitcore-lib');
5
- const addressValidator = require('wallet-address-validator');
5
+ const addressValidator = require('multicoin-address-validator');
6
6
  const zilUtils = require('@zilliqa-js/util');
7
7
  const web3 = require('web3-utils');
8
8
  const stellarSDK = require('stellar-sdk');
@@ -121,7 +121,7 @@ const validations = {
121
121
  bitcoin: {
122
122
  isAddress(str) {
123
123
  const network = process.env.BITCOIN_NETWORK === 'testnet' ? 'testnet' : 'prod';
124
- return typeof str === 'string' && addressValidator.validate(str.trim(), 'BTC', network);
124
+ return typeof str === 'string' && addressValidator.validate(str.trim(), 'btc', network);
125
125
  },
126
126
  isBech32Address(str) {
127
127
  return /^bc1[ac-hj-np-z02-9]{6,86}|^BC1[AC-HJ-NP-Z02-9]{6,86}/.test(str);
@@ -230,7 +230,7 @@ const validations = {
230
230
  },
231
231
  horizen: {
232
232
  isAddress(str) {
233
- return addressValidator.validate(str, 'ZEN');
233
+ return addressValidator.validate(str, 'zen');
234
234
  },
235
235
  isTxHash(str) {
236
236
  if (!V.isHexadecimal(str)) {
@@ -252,7 +252,7 @@ const validations = {
252
252
  },
253
253
  ripple: {
254
254
  isAddress(str) {
255
- return addressValidator.validate(str, 'XRP');
255
+ return addressValidator.validate(str, 'xrp');
256
256
  },
257
257
  isTxHash(str) {
258
258
  if (!V.isHexadecimal(str)) {
@@ -274,7 +274,7 @@ const validations = {
274
274
  },
275
275
  zcash: {
276
276
  isAddress(str) {
277
- return addressValidator.validate(str, 'ZEC');
277
+ return addressValidator.validate(str, 'zec');
278
278
  },
279
279
  isTxHash(str) {
280
280
  if (!V.isHexadecimal(str)) {
@@ -291,6 +291,30 @@ const validations = {
291
291
  return str.length === 66 && web3.isHexStrict(str);
292
292
  },
293
293
  },
294
+ algorand: {
295
+ isAddress(str) {
296
+ return addressValidator.validate(str, 'algo');
297
+ },
298
+ isTxHash(str) {
299
+ return str.length === 52;
300
+ },
301
+ },
302
+ tezos: {
303
+ isAddress(str) {
304
+ return addressValidator.validate(str, 'xtz');
305
+ },
306
+ isTxHash(str) {
307
+ return str.length === 51;
308
+ },
309
+ },
310
+ polkadot: {
311
+ isAddress(str) {
312
+ return addressValidator.validate(str, 'dot');
313
+ },
314
+ isTxHash(str) {
315
+ return str.length === 66 && web3.isHexStrict(str);
316
+ },
317
+ },
294
318
  };
295
319
  Object.keys(V).forEach((k) => {
296
320
  const v = V[k];
@@ -285,4 +285,26 @@ describe('Validations', () => {
285
285
  it('should return false when passed a non-hex string', () => validations_1.default.zilliqa.isTxHash('Yet again this is not a hex string').should.be.false);
286
286
  });
287
287
  });
288
+ describe('ALGO', () => {
289
+ describe('isAddress', () => {
290
+ it('should correctly validate valid ALGO addresses', () => validations_1.default.algorand.isAddress('GX3XLHSRMFTADVKJBBQBTZ6BKINW6ZO5JHXWGCWB4CPDNPDQ2PIYN4AVHQ').should.be.true);
291
+ it('should correctly validate an incorrect ALGO address', () => validations_1.default.algorand.isAddress('GX3XLHBQBTZ6BKINW6ZO5JHXWGCWB4CPDNPDQ2PIYN4AVHQ').should.be.false);
292
+ });
293
+ describe('isTxHash', () => {
294
+ it('should correctly validate a valid ALGO hash', () => validations_1.default.algorand.isTxHash('TDITWGH5FODF2EUSKBAZ4DDC323NDBCBCE6BSXVXTZBINTCVQVVQ').should.be.true);
295
+ it('should correctly validate an incorrect ALGO hash', () => validations_1.default.algorand.isTxHash('TDITWGH5FOBAZ4DDC323NDBCBCE6BSXVXTZBINTCVQVVQ').should.be.false);
296
+ it('should return false when passed a non-hex string', () => validations_1.default.algorand.isTxHash('Yet again this is not a hex string').should.be.false);
297
+ });
298
+ });
299
+ describe('DOT', () => {
300
+ describe('isAddress', () => {
301
+ it('should correctly validate valid DOT addresses', () => validations_1.default.polkadot.isAddress('14YJztsPZEiKuKhU3qLd6JjiY4awfdUru8Xu7BDdZAUuG8S6').should.be.true);
302
+ it('should correctly validate an incorrect DOT address', () => validations_1.default.polkadot.isAddress('14YJztsPZEiKuKjiY4awfdUru8Xu7BDdZAUuG8S6').should.be.false);
303
+ });
304
+ describe('isTxHash', () => {
305
+ it('should correctly validate a valid DOT hash', () => validations_1.default.polkadot.isTxHash('0x975ba4cfd83dd7f4f6e2c1932f4aeb650391f00d57c3856907d668a99fd90609').should.be.true);
306
+ it('should correctly validate an incorrect DOT hash', () => validations_1.default.polkadot.isTxHash('0x975ba4cfd83dd7f4f2f4aeb650391f00d57c3856907d668a99fd90609').should.be.false);
307
+ it('should return false when passed a non-hex string', () => validations_1.default.polkadot.isTxHash('Yet again this is not a hex string').should.be.false);
308
+ });
309
+ });
288
310
  });
@@ -8,7 +8,7 @@ const {
8
8
  Script,
9
9
  Transaction,
10
10
  } = require('bitcore-lib');
11
- const addressValidator = require('wallet-address-validator');
11
+ const addressValidator = require('multicoin-address-validator');
12
12
  const zilUtils = require('@zilliqa-js/util');
13
13
  const web3 = require('web3-utils');
14
14
  const stellarSDK = require('stellar-sdk');
@@ -132,7 +132,7 @@ const validations = {
132
132
  bitcoin: {
133
133
  isAddress(str) {
134
134
  const network = process.env.BITCOIN_NETWORK === 'testnet' ? 'testnet' : 'prod';
135
- return typeof str === 'string' && addressValidator.validate(str.trim(), 'BTC', network);
135
+ return typeof str === 'string' && addressValidator.validate(str.trim(), 'btc', network);
136
136
  },
137
137
  isBech32Address(str) {
138
138
  return /^bc1[ac-hj-np-z02-9]{6,86}|^BC1[AC-HJ-NP-Z02-9]{6,86}/.test(str);
@@ -235,7 +235,7 @@ const validations = {
235
235
  },
236
236
  horizen: {
237
237
  isAddress(str) {
238
- return addressValidator.validate(str, 'ZEN');
238
+ return addressValidator.validate(str, 'zen');
239
239
  },
240
240
  isTxHash(str) {
241
241
  if (!V.isHexadecimal(str)) {
@@ -257,7 +257,7 @@ const validations = {
257
257
  },
258
258
  ripple: {
259
259
  isAddress(str) {
260
- return addressValidator.validate(str, 'XRP');
260
+ return addressValidator.validate(str, 'xrp');
261
261
  },
262
262
  isTxHash(str) {
263
263
  if (!V.isHexadecimal(str)) {
@@ -279,7 +279,7 @@ const validations = {
279
279
  },
280
280
  zcash: {
281
281
  isAddress(str) {
282
- return addressValidator.validate(str, 'ZEC');
282
+ return addressValidator.validate(str, 'zec');
283
283
  },
284
284
  isTxHash(str) {
285
285
  if (!V.isHexadecimal(str)) {
@@ -296,6 +296,30 @@ const validations = {
296
296
  return str.length === 66 && web3.isHexStrict(str);
297
297
  },
298
298
  },
299
+ algorand: {
300
+ isAddress(str) {
301
+ return addressValidator.validate(str, 'algo');
302
+ },
303
+ isTxHash(str) {
304
+ return str.length === 52;
305
+ },
306
+ },
307
+ tezos: {
308
+ isAddress(str) {
309
+ return addressValidator.validate(str, 'xtz');
310
+ },
311
+ isTxHash(str) {
312
+ return str.length === 51;
313
+ },
314
+ },
315
+ polkadot: {
316
+ isAddress(str) {
317
+ return addressValidator.validate(str, 'dot');
318
+ },
319
+ isTxHash(str) {
320
+ return str.length === 66 && web3.isHexStrict(str);
321
+ },
322
+ },
299
323
  };
300
324
 
301
325
  Object.keys(V).forEach((k) => {
@@ -364,4 +364,36 @@ describe('Validations', () => {
364
364
  it('should return false when passed a non-hex string', () => validations.zilliqa.isTxHash('Yet again this is not a hex string').should.be.false);
365
365
  });
366
366
  });
367
+
368
+ describe('ALGO', () => {
369
+ describe('isAddress', () => {
370
+ it('should correctly validate valid ALGO addresses', () => validations.algorand.isAddress('GX3XLHSRMFTADVKJBBQBTZ6BKINW6ZO5JHXWGCWB4CPDNPDQ2PIYN4AVHQ').should.be.true);
371
+
372
+ it('should correctly validate an incorrect ALGO address', () => validations.algorand.isAddress('GX3XLHBQBTZ6BKINW6ZO5JHXWGCWB4CPDNPDQ2PIYN4AVHQ').should.be.false);
373
+ });
374
+
375
+ describe('isTxHash', () => {
376
+ it('should correctly validate a valid ALGO hash', () => validations.algorand.isTxHash('TDITWGH5FODF2EUSKBAZ4DDC323NDBCBCE6BSXVXTZBINTCVQVVQ').should.be.true);
377
+
378
+ it('should correctly validate an incorrect ALGO hash', () => validations.algorand.isTxHash('TDITWGH5FOBAZ4DDC323NDBCBCE6BSXVXTZBINTCVQVVQ').should.be.false);
379
+
380
+ it('should return false when passed a non-hex string', () => validations.algorand.isTxHash('Yet again this is not a hex string').should.be.false);
381
+ });
382
+ });
383
+
384
+ describe('DOT', () => {
385
+ describe('isAddress', () => {
386
+ it('should correctly validate valid DOT addresses', () => validations.polkadot.isAddress('14YJztsPZEiKuKhU3qLd6JjiY4awfdUru8Xu7BDdZAUuG8S6').should.be.true);
387
+
388
+ it('should correctly validate an incorrect DOT address', () => validations.polkadot.isAddress('14YJztsPZEiKuKjiY4awfdUru8Xu7BDdZAUuG8S6').should.be.false);
389
+ });
390
+
391
+ describe('isTxHash', () => {
392
+ it('should correctly validate a valid DOT hash', () => validations.polkadot.isTxHash('0x975ba4cfd83dd7f4f6e2c1932f4aeb650391f00d57c3856907d668a99fd90609').should.be.true);
393
+
394
+ it('should correctly validate an incorrect DOT hash', () => validations.polkadot.isTxHash('0x975ba4cfd83dd7f4f2f4aeb650391f00d57c3856907d668a99fd90609').should.be.false);
395
+
396
+ it('should return false when passed a non-hex string', () => validations.polkadot.isTxHash('Yet again this is not a hex string').should.be.false);
397
+ });
398
+ });
367
399
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ellipticltd/aml-utils",
3
- "version": "0.10.0",
3
+ "version": "0.12.0-SCR-283.0",
4
4
  "description": "Utilities, helpers, validations, type-checking, etc",
5
5
  "engines": {
6
6
  "node": "10.1.0",
@@ -28,10 +28,10 @@
28
28
  "bitcore-lib": "^8.10.1",
29
29
  "create-error": "0.3.1",
30
30
  "lodash": "^4.17.15",
31
+ "multicoin-address-validator": "^0.5.2",
31
32
  "stellar-sdk": "4.0.2",
32
33
  "type-check": "0.3.2",
33
34
  "validator": "10.10.0",
34
- "wallet-address-validator": "0.2.4",
35
35
  "web3-utils": "1.0.0"
36
36
  },
37
37
  "devDependencies": {