@ellipticltd/aml-utils 0.3.0 → 0.5.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.
@@ -34,7 +34,9 @@ jobs:
34
34
  at: /tmp
35
35
  - run:
36
36
  name: unit_test
37
- command: npm run test
37
+ command: npm run coverage
38
+ - store_artifacts:
39
+ path: coverage
38
40
 
39
41
  workflows:
40
42
  version: 2.1
package/.eslintrc CHANGED
@@ -1,3 +1,20 @@
1
1
  {
2
- "extends": ["@ellipticltd"]
3
- }
2
+ "extends": [
3
+ "airbnb"
4
+ ],
5
+ "overrides": [
6
+ {
7
+ "files": [
8
+ "*.spec.js",
9
+ ],
10
+ "env": {
11
+ "mocha": true
12
+ }
13
+ }
14
+ ],
15
+ "rules": {
16
+ "no-underscore-dangle": 0,
17
+ "prefer-object-spread": 0,
18
+ "new-parens": 0
19
+ }
20
+ }
@@ -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$/.tmp" />
6
+ <excludeFolder url="file://$MODULE_DIR$/temp" />
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,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="ERROR" enabled_by_default="true" />
5
+ </profile>
6
+ </component>
package/.idea/misc.xml ADDED
@@ -0,0 +1,6 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="JavaScriptSettings">
4
+ <option name="languageLevel" value="ES6" />
5
+ </component>
6
+ </project>
@@ -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>
@@ -0,0 +1,290 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="ChangeListManager">
4
+ <list default="true" id="beae4972-1969-4895-bbc9-d79f09bb9811" name="Default" comment="">
5
+ <change beforePath="$PROJECT_DIR$/package.json" beforeDir="false" afterPath="$PROJECT_DIR$/package.json" afterDir="false" />
6
+ </list>
7
+ <ignored path="$PROJECT_DIR$/.tmp/" />
8
+ <ignored path="$PROJECT_DIR$/temp/" />
9
+ <ignored path="$PROJECT_DIR$/tmp/" />
10
+ <option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" />
11
+ <option name="TRACKING_ENABLED" value="true" />
12
+ <option name="SHOW_DIALOG" value="false" />
13
+ <option name="HIGHLIGHT_CONFLICTS" value="true" />
14
+ <option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
15
+ <option name="LAST_RESOLUTION" value="IGNORE" />
16
+ </component>
17
+ <component name="FileEditorManager">
18
+ <leaf SIDE_TABS_SIZE_LIMIT_KEY="300">
19
+ <file leaf-file-name="package.json" pinned="false" current-in-tab="true">
20
+ <entry file="file://$PROJECT_DIR$/package.json">
21
+ <provider selected="true" editor-type-id="text-editor">
22
+ <state relative-caret-position="26">
23
+ <caret line="2" column="17" selection-start-line="2" selection-start-column="17" selection-end-line="2" selection-end-column="17" />
24
+ </state>
25
+ </provider>
26
+ </entry>
27
+ </file>
28
+ <file leaf-file-name="validations.js" pinned="false" current-in-tab="false">
29
+ <entry file="file://$PROJECT_DIR$/lib/validations.js">
30
+ <provider selected="true" editor-type-id="text-editor">
31
+ <state relative-caret-position="3198">
32
+ <caret line="246" column="56" selection-start-line="246" selection-start-column="56" selection-end-line="246" selection-end-column="56" />
33
+ </state>
34
+ </provider>
35
+ </entry>
36
+ </file>
37
+ <file leaf-file-name="validations.spec.js" pinned="false" current-in-tab="false">
38
+ <entry file="file://$PROJECT_DIR$/test/validations.spec.js">
39
+ <provider selected="true" editor-type-id="text-editor">
40
+ <state relative-caret-position="731">
41
+ <caret line="282" column="157" selection-start-line="282" selection-start-column="91" selection-end-line="282" selection-end-column="157" />
42
+ </state>
43
+ </provider>
44
+ </entry>
45
+ </file>
46
+ </leaf>
47
+ </component>
48
+ <component name="FindInProjectRecents">
49
+ <findStrings>
50
+ <find>addressVal</find>
51
+ </findStrings>
52
+ </component>
53
+ <component name="Git.Settings">
54
+ <option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
55
+ </component>
56
+ <component name="IdeDocumentHistory">
57
+ <option name="CHANGED_PATHS">
58
+ <list>
59
+ <option value="$PROJECT_DIR$/test/validations.spec.js" />
60
+ <option value="$PROJECT_DIR$/lib/validations.js" />
61
+ <option value="$PROJECT_DIR$/package.json" />
62
+ </list>
63
+ </option>
64
+ </component>
65
+ <component name="JsBuildToolGruntFileManager" detection-done="true" sorting="DEFINITION_ORDER" />
66
+ <component name="JsBuildToolPackageJson" detection-done="true" sorting="DEFINITION_ORDER">
67
+ <package-json value="$PROJECT_DIR$/package.json" />
68
+ </component>
69
+ <component name="JsGulpfileManager">
70
+ <detection-done>true</detection-done>
71
+ <sorting>DEFINITION_ORDER</sorting>
72
+ </component>
73
+ <component name="NodeModulesDirectoryManager">
74
+ <handled-path value="$PROJECT_DIR$/node_modules" />
75
+ </component>
76
+ <component name="NodePackageJsonFileManager">
77
+ <packageJsonPaths>
78
+ <path value="$PROJECT_DIR$/package.json" />
79
+ </packageJsonPaths>
80
+ </component>
81
+ <component name="ProjectFrameBounds" extendedState="6">
82
+ <option name="y" value="23" />
83
+ <option name="width" value="1680" />
84
+ <option name="height" value="1027" />
85
+ </component>
86
+ <component name="ProjectView">
87
+ <navigator proportions="" version="1">
88
+ <foldersAlwaysOnTop value="true" />
89
+ </navigator>
90
+ <panes>
91
+ <pane id="ProjectPane">
92
+ <subPane>
93
+ <expand>
94
+ <path>
95
+ <item name="aml-utils" type="b2602c69:ProjectViewProjectNode" />
96
+ <item name="aml-utils" type="462c0819:PsiDirectoryNode" />
97
+ </path>
98
+ <path>
99
+ <item name="aml-utils" type="b2602c69:ProjectViewProjectNode" />
100
+ <item name="aml-utils" type="462c0819:PsiDirectoryNode" />
101
+ <item name="lib" type="462c0819:PsiDirectoryNode" />
102
+ </path>
103
+ <path>
104
+ <item name="aml-utils" type="b2602c69:ProjectViewProjectNode" />
105
+ <item name="aml-utils" type="462c0819:PsiDirectoryNode" />
106
+ <item name="test" type="462c0819:PsiDirectoryNode" />
107
+ </path>
108
+ </expand>
109
+ <select />
110
+ </subPane>
111
+ </pane>
112
+ <pane id="Scope" />
113
+ </panes>
114
+ </component>
115
+ <component name="PropertiesComponent">
116
+ <property name="WebServerToolWindowFactoryState" value="false" />
117
+ <property name="last_opened_file_path" value="$PROJECT_DIR$" />
118
+ <property name="node.js.detected.package.eslint" value="true" />
119
+ <property name="node.js.path.for.package.eslint" value="project" />
120
+ <property name="node.js.selected.package.eslint" value="$PROJECT_DIR$/node_modules/eslint" />
121
+ <property name="nodejs.mocha.mocha_node_package_dir" value="$PROJECT_DIR$/node_modules/mocha" />
122
+ <property name="nodejs_interpreter_path.stuck_in_default_project" value="undefined stuck path" />
123
+ <property name="nodejs_npm_path_reset_for_default_project" value="true" />
124
+ <property name="nodejs_package_manager_path" value="npm" />
125
+ </component>
126
+ <component name="RunDashboard">
127
+ <option name="ruleStates">
128
+ <list>
129
+ <RuleState>
130
+ <option name="name" value="ConfigurationTypeDashboardGroupingRule" />
131
+ </RuleState>
132
+ <RuleState>
133
+ <option name="name" value="StatusDashboardGroupingRule" />
134
+ </RuleState>
135
+ </list>
136
+ </option>
137
+ </component>
138
+ <component name="SvnConfiguration">
139
+ <configuration />
140
+ </component>
141
+ <component name="TaskManager">
142
+ <task active="true" id="Default" summary="Default task">
143
+ <changelist id="beae4972-1969-4895-bbc9-d79f09bb9811" name="Default" comment="" />
144
+ <created>1563360614655</created>
145
+ <option name="number" value="Default" />
146
+ <option name="presentableId" value="Default" />
147
+ <updated>1563360614655</updated>
148
+ <workItem from="1563360615721" duration="151000" />
149
+ <workItem from="1567667753338" duration="597000" />
150
+ <workItem from="1574357456118" duration="136000" />
151
+ <workItem from="1578386363024" duration="2022000" />
152
+ <workItem from="1578389154778" duration="18000" />
153
+ <workItem from="1578391578799" duration="6000" />
154
+ </task>
155
+ <servers />
156
+ </component>
157
+ <component name="TimeTrackingManager">
158
+ <option name="totallyTimeSpent" value="2930000" />
159
+ </component>
160
+ <component name="ToolWindowManager">
161
+ <frame x="-1" y="23" width="1920" height="1057" extended-state="6" />
162
+ <editor active="true" />
163
+ <layout>
164
+ <window_info active="true" content_ui="combo" id="Project" order="0" visible="true" weight="0.24907847" />
165
+ <window_info anchor="bottom" id="TODO" order="6" />
166
+ <window_info anchor="bottom" id="Docker" order="7" show_stripe_button="false" />
167
+ <window_info anchor="bottom" id="Event Log" order="7" side_tool="true" />
168
+ <window_info anchor="bottom" id="Version Control" order="7" />
169
+ <window_info id="npm" order="2" side_tool="true" />
170
+ <window_info anchor="bottom" id="Run" order="2" />
171
+ <window_info id="Structure" order="1" side_tool="true" weight="0.25" />
172
+ <window_info anchor="bottom" id="Terminal" order="7" />
173
+ <window_info id="Favorites" order="2" side_tool="true" />
174
+ <window_info anchor="bottom" id="Debug" order="3" weight="0.4" />
175
+ <window_info anchor="right" content_ui="combo" id="Hierarchy" order="2" weight="0.25" />
176
+ <window_info anchor="bottom" id="Inspection" order="5" weight="0.4" />
177
+ <window_info anchor="right" id="Commander" internal_type="SLIDING" order="0" type="SLIDING" weight="0.4" />
178
+ <window_info anchor="right" id="Ant Build" order="1" weight="0.25" />
179
+ <window_info anchor="bottom" id="Message" order="0" />
180
+ <window_info anchor="bottom" id="Cvs" order="4" weight="0.25" />
181
+ <window_info anchor="bottom" id="Find" order="1" />
182
+ </layout>
183
+ </component>
184
+ <component name="TypeScriptGeneratedFilesManager">
185
+ <option name="version" value="1" />
186
+ </component>
187
+ <component name="VcsContentAnnotationSettings">
188
+ <option name="myLimit" value="2678400000" />
189
+ </component>
190
+ <component name="editorHistoryManager">
191
+ <entry file="file://$PROJECT_DIR$/package.json">
192
+ <provider selected="true" editor-type-id="text-editor">
193
+ <state relative-caret-position="26">
194
+ <caret line="2" column="17" selection-start-line="2" selection-start-column="17" selection-end-line="2" selection-end-column="17" />
195
+ </state>
196
+ </provider>
197
+ </entry>
198
+ <entry file="file://$PROJECT_DIR$/lib/validations.js">
199
+ <provider selected="true" editor-type-id="text-editor">
200
+ <state relative-caret-position="3198">
201
+ <caret line="246" column="56" selection-start-line="246" selection-start-column="56" selection-end-line="246" selection-end-column="56" />
202
+ </state>
203
+ </provider>
204
+ </entry>
205
+ <entry file="file://$PROJECT_DIR$/test/validations.spec.js">
206
+ <provider selected="true" editor-type-id="text-editor">
207
+ <state relative-caret-position="3666">
208
+ <caret line="282" column="157" selection-start-line="282" selection-start-column="91" selection-end-line="282" selection-end-column="157" />
209
+ </state>
210
+ </provider>
211
+ </entry>
212
+ <entry file="file://$PROJECT_DIR$/package.json">
213
+ <provider selected="true" editor-type-id="text-editor">
214
+ <state relative-caret-position="26">
215
+ <caret line="2" column="17" selection-start-line="2" selection-start-column="17" selection-end-line="2" selection-end-column="17" />
216
+ </state>
217
+ </provider>
218
+ </entry>
219
+ <entry file="file://$PROJECT_DIR$/lib/validations.js">
220
+ <provider selected="true" editor-type-id="text-editor">
221
+ <state relative-caret-position="3198">
222
+ <caret line="246" column="56" selection-start-line="246" selection-start-column="56" selection-end-line="246" selection-end-column="56" />
223
+ </state>
224
+ </provider>
225
+ </entry>
226
+ <entry file="file://$PROJECT_DIR$/test/validations.spec.js">
227
+ <provider selected="true" editor-type-id="text-editor">
228
+ <state relative-caret-position="3666">
229
+ <caret line="282" column="93" lean-forward="true" selection-start-line="282" selection-start-column="93" selection-end-line="282" selection-end-column="93" />
230
+ </state>
231
+ </provider>
232
+ </entry>
233
+ <entry file="file://$PROJECT_DIR$/package.json">
234
+ <provider selected="true" editor-type-id="text-editor">
235
+ <state relative-caret-position="26">
236
+ <caret line="2" column="17" selection-start-line="2" selection-start-column="17" selection-end-line="2" selection-end-column="17" />
237
+ </state>
238
+ </provider>
239
+ </entry>
240
+ <entry file="file://$PROJECT_DIR$/lib/validations.js">
241
+ <provider selected="true" editor-type-id="text-editor">
242
+ <state relative-caret-position="1924">
243
+ <caret line="148" column="7" selection-start-line="148" selection-start-column="7" selection-end-line="148" selection-end-column="7" />
244
+ </state>
245
+ </provider>
246
+ </entry>
247
+ <entry file="file://$PROJECT_DIR$/package.json">
248
+ <provider selected="true" editor-type-id="text-editor">
249
+ <state relative-caret-position="364">
250
+ <caret line="28" column="27" lean-forward="true" selection-start-line="28" selection-start-column="27" selection-end-line="28" selection-end-column="27" />
251
+ </state>
252
+ </provider>
253
+ </entry>
254
+ <entry file="file://$PROJECT_DIR$/lib/validations.js">
255
+ <provider selected="true" editor-type-id="text-editor">
256
+ <state relative-caret-position="1924">
257
+ <caret line="148" column="7" lean-forward="true" selection-start-line="148" selection-start-column="7" selection-end-line="148" selection-end-column="7" />
258
+ </state>
259
+ </provider>
260
+ </entry>
261
+ <entry file="file://$PROJECT_DIR$/package.json">
262
+ <provider selected="true" editor-type-id="text-editor">
263
+ <state relative-caret-position="364">
264
+ <caret line="28" column="24" selection-start-line="28" selection-start-column="24" selection-end-line="28" selection-end-column="24" />
265
+ </state>
266
+ </provider>
267
+ </entry>
268
+ <entry file="file://$PROJECT_DIR$/lib/validations.js">
269
+ <provider selected="true" editor-type-id="text-editor">
270
+ <state relative-caret-position="3198">
271
+ <caret line="246" column="56" selection-start-line="246" selection-start-column="56" selection-end-line="246" selection-end-column="56" />
272
+ </state>
273
+ </provider>
274
+ </entry>
275
+ <entry file="file://$PROJECT_DIR$/test/validations.spec.js">
276
+ <provider selected="true" editor-type-id="text-editor">
277
+ <state relative-caret-position="731">
278
+ <caret line="282" column="157" selection-start-line="282" selection-start-column="91" selection-end-line="282" selection-end-column="157" />
279
+ </state>
280
+ </provider>
281
+ </entry>
282
+ <entry file="file://$PROJECT_DIR$/package.json">
283
+ <provider selected="true" editor-type-id="text-editor">
284
+ <state relative-caret-position="26">
285
+ <caret line="2" column="17" selection-start-line="2" selection-start-column="17" selection-end-line="2" selection-end-column="17" />
286
+ </state>
287
+ </provider>
288
+ </entry>
289
+ </component>
290
+ </project>
package/.nycrc.json ADDED
@@ -0,0 +1,11 @@
1
+ {
2
+ "include": [
3
+ "lib/**/*.js"
4
+ ],
5
+ "exclude": [
6
+ "lib/types.js",
7
+ "lib/middleware.js"
8
+ ],
9
+ "all": true,
10
+ "check-coverage": false
11
+ }
package/codecov.yml ADDED
@@ -0,0 +1,29 @@
1
+ codecov:
2
+ require_ci_to_pass: yes
3
+
4
+ coverage:
5
+ precision: 2
6
+ round: down
7
+ range: "70...100"
8
+
9
+ status:
10
+ project:
11
+ default:
12
+ target: 85%
13
+ patch:
14
+ default:
15
+ target: 85%
16
+ changes: no
17
+
18
+ parsers:
19
+ gcov:
20
+ branch_detection:
21
+ conditional: yes
22
+ loop: yes
23
+ method: no
24
+ macro: no
25
+
26
+ comment:
27
+ layout: "reach,diff,flags,tree"
28
+ behavior: default
29
+ require_changes: no
package/lib/formatting.js CHANGED
@@ -10,7 +10,7 @@ const rethrowError = (fnName, e) => {
10
10
  return `${fnName} - ${e.name}: ${e.statusCode} - ${formattedError}`;
11
11
  };
12
12
 
13
- const sqlEscapeWildcard = str => str.replace(/_|%|\\/g, x => `\\${x}`);
13
+ const sqlEscapeWildcard = (str) => str.replace(/_|%|\\/g, (x) => `\\${x}`);
14
14
 
15
15
  module.exports = {
16
16
  rethrowError,
package/lib/middleware.js CHANGED
@@ -1,6 +1,6 @@
1
1
  const T = require('./types');
2
2
 
3
- const ensureType = type => (req, res, next, id, name) => {
3
+ const ensureType = (type) => (req, res, next, id, name) => {
4
4
  let error;
5
5
  try {
6
6
  T.ensureType(type, id, `Invalid ${name}`);
package/lib/ormHelpers.js CHANGED
@@ -1,18 +1,17 @@
1
1
  const _ = require('lodash');
2
2
 
3
- const includeNested = (orm, models) =>
4
- _.map(_.toPairs(models), (arg) => {
5
- const [modelName, inclusion] = arg;
6
- const include = includeNested(orm, inclusion);
7
- const model = orm[modelName];
8
- if (_.isEmpty(include)) {
9
- return model;
10
- }
11
- return {
12
- model,
13
- include,
14
- };
15
- });
3
+ const includeNested = (orm, models) => _.map(_.toPairs(models), (arg) => {
4
+ const [modelName, inclusion] = arg;
5
+ const include = includeNested(orm, inclusion);
6
+ const model = orm[modelName];
7
+ if (_.isEmpty(include)) {
8
+ return model;
9
+ }
10
+ return {
11
+ model,
12
+ include,
13
+ };
14
+ });
16
15
 
17
16
  module.exports = {
18
17
  includeNested,
package/lib/types.js CHANGED
@@ -1,11 +1,11 @@
1
1
  const TC = require('type-check');
2
2
 
3
+ const _ = require('lodash');
4
+
3
5
  const E = require('./errors');
4
6
 
5
7
  const V = require('./validations');
6
8
 
7
- const _ = require('lodash');
8
-
9
9
  const customTypes = {
10
10
  Integer: {
11
11
  typeOf: 'Number',
@@ -152,8 +152,7 @@ const withNullable = Object.keys(customTypes).reduce((acc, _type) => {
152
152
 
153
153
  // for every type, add Nullable+type. A nullable string can also be empty
154
154
  acc[`Nullable${_type}`] = Object.assign({}, customTypes[_type], {
155
- validate: x =>
156
- x == null || (typeOf === 'String' && x === '') || validate(x),
155
+ validate: (x) => x == null || (typeOf === 'String' && x === '') || validate(x),
157
156
  });
158
157
 
159
158
  return acc;
@@ -176,10 +175,13 @@ module.exports = {
176
175
  return V.ensure(this.typeCheck(type, obj), msg);
177
176
  },
178
177
  checkArg(obj, prop, type, msg) {
178
+ let message;
179
179
  if (msg == null) {
180
- msg = `Invalid ${prop}`;
180
+ message = `Invalid ${prop}`;
181
+ } else {
182
+ message = msg;
181
183
  }
182
- this.ensureType(type, obj[prop], msg);
184
+ this.ensureType(type, obj[prop], message);
183
185
  return obj[prop];
184
186
  },
185
187
  checkArgs(input, types) {
@@ -197,8 +199,8 @@ module.exports = {
197
199
  numKeys = 0;
198
200
 
199
201
  Object.keys(fields).forEach((key) => {
200
- types = fields[key];
201
- V.ensure(this.parsedTypeCheck(types, input[key]), `Invalid ${key}`);
202
+ const objTypes = fields[key];
203
+ V.ensure(this.parsedTypeCheck(objTypes, input[key]), `Invalid ${key}`);
202
204
  if (inputKeys[key]) {
203
205
  numKeys += 1;
204
206
  }
@@ -1,4 +1,3 @@
1
- const E = require('./errors');
2
1
  const V = require('validator');
3
2
  const _ = require('lodash');
4
3
  const {
@@ -10,7 +9,9 @@ const {
10
9
  Transaction,
11
10
  } = require('bitcore-lib');
12
11
  const addressValidator = require('wallet-address-validator');
12
+ const zilUtils = require('@zilliqa-js/util');
13
13
  const web3 = require('web3-utils');
14
+ const E = require('./errors');
14
15
 
15
16
  const validations = {
16
17
  _validate(Err, pred, x, msg) {
@@ -59,8 +60,8 @@ const validations = {
59
60
 
60
61
  check: {
61
62
  matches(required, given, msg) {
62
- given = _.uniq(given);
63
- const crit = _.intersection(given, required).length === given.length;
63
+ const newGiven = _.uniq(given);
64
+ const crit = _.intersection(newGiven, required).length === given.length;
64
65
  if (crit) {
65
66
  return true;
66
67
  }
@@ -100,22 +101,21 @@ const validations = {
100
101
 
101
102
  isCustomerReference(x) {
102
103
  return (
103
- _.isString(x) &&
104
- (x != null ? x.length : undefined) > 0 &&
105
- (x != null ? x.length : undefined) <= 100
104
+ _.isString(x)
105
+ && (x != null ? x.length : undefined) > 0
106
+ && (x != null ? x.length : undefined) <= 100
106
107
  );
107
108
  },
108
109
  isCustomerLabelName(x) {
109
110
  return (
110
- _.isString(x) &&
111
- (x != null ? x.length : undefined) > 0 &&
112
- (x != null ? x.length : undefined) <= 50
111
+ _.isString(x)
112
+ && (x != null ? x.length : undefined) > 0
113
+ && (x != null ? x.length : undefined) <= 50
113
114
  );
114
115
  },
115
116
  bitcoin: {
116
117
  isAddress(str) {
117
- const network =
118
- process.env.BITCOIN_NETWORK === 'testnet' ? 'testnet' : 'prod';
118
+ const network = process.env.BITCOIN_NETWORK === 'testnet' ? 'testnet' : 'prod';
119
119
  return typeof str === 'string' && addressValidator.validate(str.trim(), 'BTC', network);
120
120
  },
121
121
  isBech32Address(str) {
@@ -239,12 +239,20 @@ const validations = {
239
239
  return str.length === 64;
240
240
  },
241
241
  },
242
+ zilliqa: {
243
+ isAddress(str) {
244
+ return zilUtils.validation.isAddress(str);
245
+ },
246
+ isTxHash(str) {
247
+ return str.length === 66 && web3.isHexStrict(str);
248
+ },
249
+ },
242
250
  };
243
251
 
244
252
  Object.keys(V).forEach((k) => {
245
253
  const v = V[k];
246
254
  // don't trigger validation with null values (prevents swagger 500 error)
247
- validations[k] = x => (x === null ? false : v(x));
255
+ validations[k] = (x) => (x === null ? false : v(x));
248
256
  });
249
257
 
250
258
  module.exports = validations;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ellipticltd/aml-utils",
3
- "version": "0.3.0",
3
+ "version": "0.5.0",
4
4
  "description": "Utilities, helpers, validations, type-checking, etc",
5
5
  "engines": {
6
6
  "node": "10.1.0",
@@ -13,14 +13,18 @@
13
13
  "homepage": "https://bitbucket.org/elliptic/aml-utils#readme",
14
14
  "main": "index.js",
15
15
  "scripts": {
16
- "test": "./node_modules/.bin/mocha --reporter spec --compilers coffee:coffee-script/register --require 'test/index.coffee'",
16
+ "test:unit": "./node_modules/.bin/mocha --reporter spec --compilers coffee:coffee-script/register --require 'test/index.coffee'",
17
17
  "compile": "./node_modules/coffee-script/bin/coffee -c index.coffee **/*.coffee",
18
- "preprocess": "npm run compile"
18
+ "preprocess": "npm run compile",
19
+ "lint": "./node_modules/.bin/eslint --color 'lib/**/*.js' 'test/**/*.js' ",
20
+ "test": "nyc npm run test:unit && nyc report --reporter=html",
21
+ "coverage": "nyc npm run test:unit && nyc report --reporter=lcov --reporter=text-lcov | codecov --pipe"
19
22
  },
20
23
  "author": "Adam Joyce <adam@ellipitc.co>",
21
24
  "license": "MIT",
22
25
  "dependencies": {
23
- "bitcore-lib": "5.0.0-beta.1",
26
+ "@zilliqa-js/util": "^0.8.8",
27
+ "bitcore-lib": "^8.10.1",
24
28
  "create-error": "0.3.1",
25
29
  "lodash": "^4.17.15",
26
30
  "type-check": "0.3.2",
@@ -29,12 +33,18 @@
29
33
  "web3-utils": "1.0.0"
30
34
  },
31
35
  "devDependencies": {
32
- "@ellipticltd/eslint-config": "0.0.3",
33
36
  "chai": "4.1.1",
37
+ "codecov": "^3.6.1",
34
38
  "coffee-script": "1.12.7",
35
- "eslint": "5.9.0",
36
- "eslint-config-airbnb-base": "13.1.0",
37
- "eslint-plugin-import": "^2.18.0",
38
- "mocha": "3.5.0"
39
+ "eslint": "^6.6.0",
40
+ "eslint-config-airbnb": "^18.0.1",
41
+ "eslint-config-airbnb-base": "^14.0.0",
42
+ "eslint-plugin-coffeescript": "^1.0.0",
43
+ "eslint-plugin-import": "^2.18.2",
44
+ "eslint-plugin-jsx-a11y": "^6.2.3",
45
+ "eslint-plugin-react": "^7.16.0",
46
+ "mocha": "3.5.0",
47
+ "mocha-lcov-reporter": "^1.3.0",
48
+ "nyc": "^14.1.1"
39
49
  }
40
50
  }