@ellipticltd/aml-utils 0.12.2 → 0.13.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.
package/.idea/aws.xml ADDED
@@ -0,0 +1,17 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="accountSettings">
4
+ <option name="activeProfile" value="profile:default" />
5
+ <option name="activeRegion" value="eu-west-1" />
6
+ <option name="recentlyUsedProfiles">
7
+ <list>
8
+ <option value="profile:default" />
9
+ </list>
10
+ </option>
11
+ <option name="recentlyUsedRegions">
12
+ <list>
13
+ <option value="eu-west-1" />
14
+ </list>
15
+ </option>
16
+ </component>
17
+ </project>
@@ -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>
@@ -34,7 +34,7 @@ export function isCustomerReference(x: any): boolean;
34
34
  export function isCustomerReference(x: any): boolean;
35
35
  export function isCustomerLabelName(x: any): boolean;
36
36
  export function isCustomerLabelName(x: any): boolean;
37
- export namespace binanceChain {
37
+ export namespace binanceCoin {
38
38
  function isAddress(str: any): boolean;
39
39
  function isAddress(str: any): boolean;
40
40
  function isTxHash(str: any): boolean;
@@ -134,3 +134,21 @@ export namespace polkadot {
134
134
  function isTxHash(str: any): any;
135
135
  function isTxHash(str: any): any;
136
136
  }
137
+ export namespace cardano {
138
+ function isAddress(str: any): any;
139
+ function isAddress(str: any): any;
140
+ function isTxHash(str: any): boolean;
141
+ function isTxHash(str: any): boolean;
142
+ }
143
+ export namespace cryptocom {
144
+ function isAddress(str: any): any;
145
+ function isAddress(str: any): any;
146
+ function isTxHash(str: any): boolean;
147
+ function isTxHash(str: any): boolean;
148
+ }
149
+ export namespace near {
150
+ function isAddress(str: any): boolean;
151
+ function isAddress(str: any): boolean;
152
+ function isTxHash(str: any): boolean;
153
+ function isTxHash(str: any): boolean;
154
+ }
@@ -107,7 +107,7 @@ const validations = {
107
107
  && (x != null ? x.length : undefined) > 0
108
108
  && (x != null ? x.length : undefined) <= 50);
109
109
  },
110
- binanceChain: {
110
+ binanceCoin: {
111
111
  isAddress(str) {
112
112
  return /^(bnb)([a-z0-9]{39})$/.test(str);
113
113
  },
@@ -315,6 +315,37 @@ const validations = {
315
315
  return str.length === 66 && web3.isHexStrict(str);
316
316
  },
317
317
  },
318
+ cardano: {
319
+ isAddress(str) {
320
+ return addressValidator.validate(str, 'ada');
321
+ },
322
+ isTxHash(str) {
323
+ if (!V.isHexadecimal(str)) {
324
+ return false;
325
+ }
326
+ return str.length === 64;
327
+ },
328
+ },
329
+ cryptocom: {
330
+ isAddress(str) {
331
+ return addressValidator.validate(str, 'cro');
332
+ },
333
+ isTxHash(str) {
334
+ if (!V.isHexadecimal(str)) {
335
+ return false;
336
+ }
337
+ return str.length === 64;
338
+ },
339
+ },
340
+ near: {
341
+ isAddress(str) {
342
+ // https://nomicon.io/DataStructures/Account
343
+ return /^(([a-z\d]+[-_])*[a-z\d]+\.)*([a-z\d]+[-_])*[a-z\d]+$/.test(str);
344
+ },
345
+ isTxHash(str) {
346
+ return str.length === 44;
347
+ },
348
+ },
318
349
  };
319
350
  Object.keys(V).forEach((k) => {
320
351
  const v = V[k];
@@ -138,13 +138,13 @@ describe('Validations', () => {
138
138
  });
139
139
  describe('BNB', () => {
140
140
  describe('isAddress', () => {
141
- it('should correctly validate valid BNB addresses', () => validations_1.default.binanceChain.isAddress('bnb1z35wusfv8twfele77vddclka9z84ugywug48gn').should.be.true);
142
- it('should correctly validate an incorrect BNB address', () => validations_1.default.binanceChain.isAddress('bnb1z35wusfv8twfele77vddclka9z84ugywug48gn1').should.be.false);
141
+ it('should correctly validate valid BNB addresses', () => validations_1.default.binanceCoin.isAddress('bnb1z35wusfv8twfele77vddclka9z84ugywug48gn').should.be.true);
142
+ it('should correctly validate an incorrect BNB address', () => validations_1.default.binanceCoin.isAddress('bnb1z35wusfv8twfele77vddclka9z84ugywug48gn1').should.be.false);
143
143
  });
144
144
  describe('isTxHash', () => {
145
- it('should correctly validate a valid BNB hash', () => validations_1.default.binanceChain.isTxHash('E68C2D178F989DE296FA1B513D1AA138B234C436B52E0D755C6664A70F7EEF7B').should.be.true);
146
- it('should correctly validate an incorrect BNB hash', () => validations_1.default.binanceChain.isTxHash('E68C2D178F989DE296FA1B513D1AA138B234C436B52E0D755C6664A70F7EEF7B1').should.be.false);
147
- it('should return false when passed a non-hex string', () => validations_1.default.binanceChain.isTxHash('Not a hex string!').should.be.false);
145
+ it('should correctly validate a valid BNB hash', () => validations_1.default.binanceCoin.isTxHash('E68C2D178F989DE296FA1B513D1AA138B234C436B52E0D755C6664A70F7EEF7B').should.be.true);
146
+ it('should correctly validate an incorrect BNB hash', () => validations_1.default.binanceCoin.isTxHash('E68C2D178F989DE296FA1B513D1AA138B234C436B52E0D755C6664A70F7EEF7B1').should.be.false);
147
+ it('should return false when passed a non-hex string', () => validations_1.default.binanceCoin.isTxHash('Not a hex string!').should.be.false);
148
148
  });
149
149
  });
150
150
  describe('BTC', () => {
@@ -118,7 +118,7 @@ const validations = {
118
118
  && (x != null ? x.length : undefined) <= 50
119
119
  );
120
120
  },
121
- binanceChain: {
121
+ binanceCoin: {
122
122
  isAddress(str) {
123
123
  return /^(bnb)([a-z0-9]{39})$/.test(str);
124
124
  },
@@ -320,6 +320,37 @@ const validations = {
320
320
  return str.length === 66 && web3.isHexStrict(str);
321
321
  },
322
322
  },
323
+ cardano: {
324
+ isAddress(str) {
325
+ return addressValidator.validate(str, 'ada');
326
+ },
327
+ isTxHash(str) {
328
+ if (!V.isHexadecimal(str)) {
329
+ return false;
330
+ }
331
+ return str.length === 64;
332
+ },
333
+ },
334
+ cryptocom: {
335
+ isAddress(str) {
336
+ return addressValidator.validate(str, 'cro');
337
+ },
338
+ isTxHash(str) {
339
+ if (!V.isHexadecimal(str)) {
340
+ return false;
341
+ }
342
+ return str.length === 64;
343
+ },
344
+ },
345
+ near: {
346
+ isAddress(str) {
347
+ // https://nomicon.io/DataStructures/Account
348
+ return /^(([a-z\d]+[-_])*[a-z\d]+\.)*([a-z\d]+[-_])*[a-z\d]+$/.test(str);
349
+ },
350
+ isTxHash(str) {
351
+ return str.length === 44;
352
+ },
353
+ },
323
354
  };
324
355
 
325
356
  Object.keys(V).forEach((k) => {
@@ -166,17 +166,17 @@ describe('Validations', () => {
166
166
 
167
167
  describe('BNB', () => {
168
168
  describe('isAddress', () => {
169
- it('should correctly validate valid BNB addresses', () => validations.binanceChain.isAddress('bnb1z35wusfv8twfele77vddclka9z84ugywug48gn').should.be.true);
169
+ it('should correctly validate valid BNB addresses', () => validations.binanceCoin.isAddress('bnb1z35wusfv8twfele77vddclka9z84ugywug48gn').should.be.true);
170
170
 
171
- it('should correctly validate an incorrect BNB address', () => validations.binanceChain.isAddress('bnb1z35wusfv8twfele77vddclka9z84ugywug48gn1').should.be.false);
171
+ it('should correctly validate an incorrect BNB address', () => validations.binanceCoin.isAddress('bnb1z35wusfv8twfele77vddclka9z84ugywug48gn1').should.be.false);
172
172
  });
173
173
 
174
174
  describe('isTxHash', () => {
175
- it('should correctly validate a valid BNB hash', () => validations.binanceChain.isTxHash('E68C2D178F989DE296FA1B513D1AA138B234C436B52E0D755C6664A70F7EEF7B').should.be.true);
175
+ it('should correctly validate a valid BNB hash', () => validations.binanceCoin.isTxHash('E68C2D178F989DE296FA1B513D1AA138B234C436B52E0D755C6664A70F7EEF7B').should.be.true);
176
176
 
177
- it('should correctly validate an incorrect BNB hash', () => validations.binanceChain.isTxHash('E68C2D178F989DE296FA1B513D1AA138B234C436B52E0D755C6664A70F7EEF7B1').should.be.false);
177
+ it('should correctly validate an incorrect BNB hash', () => validations.binanceCoin.isTxHash('E68C2D178F989DE296FA1B513D1AA138B234C436B52E0D755C6664A70F7EEF7B1').should.be.false);
178
178
 
179
- it('should return false when passed a non-hex string', () => validations.binanceChain.isTxHash('Not a hex string!').should.be.false);
179
+ it('should return false when passed a non-hex string', () => validations.binanceCoin.isTxHash('Not a hex string!').should.be.false);
180
180
  });
181
181
  });
182
182
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ellipticltd/aml-utils",
3
- "version": "0.12.2",
3
+ "version": "0.13.0",
4
4
  "description": "Utilities, helpers, validations, type-checking, etc",
5
5
  "engines": {
6
6
  "node": "10.1.0",