@ellipticltd/aml-utils 0.2.2 → 0.3.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/.circleci/config.yml +47 -0
- package/lib/validations.js +40 -29
- package/package.json +2 -2
- package/.idea/aml-utils.iml +0 -12
- package/.idea/inspectionProfiles/Project_Default.xml +0 -6
- package/.idea/misc.xml +0 -6
- package/.idea/modules.xml +0 -8
- package/.idea/vcs.xml +0 -6
- package/.idea/workspace.xml +0 -191
- package/.npmignore +0 -4
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
version: 2.1
|
|
2
|
+
|
|
3
|
+
executors:
|
|
4
|
+
node-8_4:
|
|
5
|
+
docker:
|
|
6
|
+
- image: circleci/node:8.4.0
|
|
7
|
+
working_directory: /tmp/workspace
|
|
8
|
+
|
|
9
|
+
jobs:
|
|
10
|
+
install:
|
|
11
|
+
executor: node-8_4
|
|
12
|
+
steps:
|
|
13
|
+
- checkout
|
|
14
|
+
- restore_cache:
|
|
15
|
+
keys:
|
|
16
|
+
- npm-cache-{{ checksum "package-lock.json" }}
|
|
17
|
+
- run:
|
|
18
|
+
name: install node modules
|
|
19
|
+
command: |
|
|
20
|
+
npm i
|
|
21
|
+
- save_cache:
|
|
22
|
+
key: npm-cache-{{ checksum "package-lock.json" }}
|
|
23
|
+
paths:
|
|
24
|
+
- node_modules
|
|
25
|
+
- persist_to_workspace:
|
|
26
|
+
root: /tmp
|
|
27
|
+
paths:
|
|
28
|
+
- workspace
|
|
29
|
+
|
|
30
|
+
unit_test:
|
|
31
|
+
executor: node-8_4
|
|
32
|
+
steps:
|
|
33
|
+
- attach_workspace:
|
|
34
|
+
at: /tmp
|
|
35
|
+
- run:
|
|
36
|
+
name: unit_test
|
|
37
|
+
command: npm run test
|
|
38
|
+
|
|
39
|
+
workflows:
|
|
40
|
+
version: 2.1
|
|
41
|
+
build-test-deploy:
|
|
42
|
+
jobs:
|
|
43
|
+
- install
|
|
44
|
+
|
|
45
|
+
- unit_test:
|
|
46
|
+
requires:
|
|
47
|
+
- install
|
package/lib/validations.js
CHANGED
|
@@ -112,28 +112,6 @@ const validations = {
|
|
|
112
112
|
(x != null ? x.length : undefined) <= 50
|
|
113
113
|
);
|
|
114
114
|
},
|
|
115
|
-
ethereum: {
|
|
116
|
-
isAddress(str) {
|
|
117
|
-
return web3.isAddress(str);
|
|
118
|
-
},
|
|
119
|
-
isBlockHash(str) {
|
|
120
|
-
return str.length === 66 && web3.isHexStrict(str);
|
|
121
|
-
},
|
|
122
|
-
isTxHash(str) {
|
|
123
|
-
return str.length === 66 && web3.isHexStrict(str);
|
|
124
|
-
},
|
|
125
|
-
isAddressCode(str) {
|
|
126
|
-
return web3.isHexStrict(str);
|
|
127
|
-
},
|
|
128
|
-
isValidWeiAmount(str) {
|
|
129
|
-
try {
|
|
130
|
-
web3.fromWei(str);
|
|
131
|
-
return true;
|
|
132
|
-
} catch (e) {
|
|
133
|
-
return false;
|
|
134
|
-
}
|
|
135
|
-
},
|
|
136
|
-
},
|
|
137
115
|
bitcoin: {
|
|
138
116
|
isAddress(str) {
|
|
139
117
|
const network =
|
|
@@ -160,13 +138,13 @@ const validations = {
|
|
|
160
138
|
}
|
|
161
139
|
},
|
|
162
140
|
isTxHash(str) {
|
|
163
|
-
if (!V.isHexadecimal(
|
|
141
|
+
if (!V.isHexadecimal(str)) {
|
|
164
142
|
return false;
|
|
165
143
|
}
|
|
166
144
|
return str.length === 64;
|
|
167
145
|
},
|
|
168
146
|
isTxHex(str) {
|
|
169
|
-
if (!V.isHexadecimal(
|
|
147
|
+
if (!V.isHexadecimal(str)) {
|
|
170
148
|
return false;
|
|
171
149
|
}
|
|
172
150
|
try {
|
|
@@ -180,7 +158,7 @@ const validations = {
|
|
|
180
158
|
return HDPrivateKey.isValidPath(str);
|
|
181
159
|
},
|
|
182
160
|
isScriptHex(str) {
|
|
183
|
-
if (!V.isHexadecimal(
|
|
161
|
+
if (!V.isHexadecimal(str)) {
|
|
184
162
|
return false;
|
|
185
163
|
}
|
|
186
164
|
try {
|
|
@@ -191,7 +169,7 @@ const validations = {
|
|
|
191
169
|
}
|
|
192
170
|
},
|
|
193
171
|
isTxSignature(str) {
|
|
194
|
-
if (!V.isHexadecimal(
|
|
172
|
+
if (!V.isHexadecimal(str)) {
|
|
195
173
|
return false;
|
|
196
174
|
}
|
|
197
175
|
try {
|
|
@@ -211,23 +189,56 @@ const validations = {
|
|
|
211
189
|
return /^[13][a-km-zA-HJ-NP-Z1-9]{25,34}$|^(bitcoincash:)?[q|p][a-z0-9]{41}$|^(BITCOINCASH:)?[Q|P][A-Z0-9]{41}$/.test(str);
|
|
212
190
|
},
|
|
213
191
|
isTxHash(str) {
|
|
214
|
-
if (!V.isHexadecimal(
|
|
192
|
+
if (!V.isHexadecimal(str)) {
|
|
215
193
|
return false;
|
|
216
194
|
}
|
|
217
195
|
return str.length === 64;
|
|
218
196
|
},
|
|
219
197
|
},
|
|
198
|
+
ethereum: {
|
|
199
|
+
isAddress(str) {
|
|
200
|
+
return web3.isAddress(str);
|
|
201
|
+
},
|
|
202
|
+
isBlockHash(str) {
|
|
203
|
+
return str.length === 66 && web3.isHexStrict(str);
|
|
204
|
+
},
|
|
205
|
+
isTxHash(str) {
|
|
206
|
+
return str.length === 66 && web3.isHexStrict(str);
|
|
207
|
+
},
|
|
208
|
+
isAddressCode(str) {
|
|
209
|
+
return web3.isHexStrict(str);
|
|
210
|
+
},
|
|
211
|
+
isValidWeiAmount(str) {
|
|
212
|
+
try {
|
|
213
|
+
web3.fromWei(str);
|
|
214
|
+
return true;
|
|
215
|
+
} catch (e) {
|
|
216
|
+
return false;
|
|
217
|
+
}
|
|
218
|
+
},
|
|
219
|
+
},
|
|
220
220
|
litecoin: {
|
|
221
221
|
isAddress(str) {
|
|
222
222
|
return /^[3LM][a-km-zA-HJ-NP-Z1-9]{24,33}$|^ltc1[ac-hj-np-z02-9]{6,86}$|^LTC1[AC-HJ-NP-Z02-9]{6,86}$/.test(str);
|
|
223
223
|
},
|
|
224
224
|
isTxHash(str) {
|
|
225
|
-
if (!V.isHexadecimal(
|
|
225
|
+
if (!V.isHexadecimal(str)) {
|
|
226
226
|
return false;
|
|
227
227
|
}
|
|
228
228
|
return str.length === 64;
|
|
229
229
|
},
|
|
230
|
-
}
|
|
230
|
+
},
|
|
231
|
+
ripple: {
|
|
232
|
+
isAddress(str) {
|
|
233
|
+
return addressValidator.validate(str, 'XRP');
|
|
234
|
+
},
|
|
235
|
+
isTxHash(str) {
|
|
236
|
+
if (!V.isHexadecimal(str)) {
|
|
237
|
+
return false;
|
|
238
|
+
}
|
|
239
|
+
return str.length === 64;
|
|
240
|
+
},
|
|
241
|
+
},
|
|
231
242
|
};
|
|
232
243
|
|
|
233
244
|
Object.keys(V).forEach((k) => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ellipticltd/aml-utils",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "Utilities, helpers, validations, type-checking, etc",
|
|
5
5
|
"engines": {
|
|
6
6
|
"node": "10.1.0",
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
"dependencies": {
|
|
23
23
|
"bitcore-lib": "5.0.0-beta.1",
|
|
24
24
|
"create-error": "0.3.1",
|
|
25
|
-
"lodash": "^4.17.
|
|
25
|
+
"lodash": "^4.17.15",
|
|
26
26
|
"type-check": "0.3.2",
|
|
27
27
|
"validator": "10.10.0",
|
|
28
28
|
"wallet-address-validator": "0.2.4",
|
package/.idea/aml-utils.iml
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
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>
|
package/.idea/misc.xml
DELETED
package/.idea/modules.xml
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
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
DELETED
package/.idea/workspace.xml
DELETED
|
@@ -1,191 +0,0 @@
|
|
|
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
|
-
<ignored path="$PROJECT_DIR$/.tmp/" />
|
|
6
|
-
<ignored path="$PROJECT_DIR$/temp/" />
|
|
7
|
-
<ignored path="$PROJECT_DIR$/tmp/" />
|
|
8
|
-
<option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" />
|
|
9
|
-
<option name="TRACKING_ENABLED" value="true" />
|
|
10
|
-
<option name="SHOW_DIALOG" value="false" />
|
|
11
|
-
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
|
12
|
-
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
|
|
13
|
-
<option name="LAST_RESOLUTION" value="IGNORE" />
|
|
14
|
-
</component>
|
|
15
|
-
<component name="FileEditorManager">
|
|
16
|
-
<leaf SIDE_TABS_SIZE_LIMIT_KEY="300">
|
|
17
|
-
<file leaf-file-name="package.json" pinned="false" current-in-tab="false">
|
|
18
|
-
<entry file="file://$PROJECT_DIR$/package.json">
|
|
19
|
-
<provider selected="true" editor-type-id="text-editor">
|
|
20
|
-
<state relative-caret-position="364">
|
|
21
|
-
<caret line="28" column="32" selection-start-line="28" selection-start-column="32" selection-end-line="28" selection-end-column="32" />
|
|
22
|
-
</state>
|
|
23
|
-
</provider>
|
|
24
|
-
</entry>
|
|
25
|
-
</file>
|
|
26
|
-
<file leaf-file-name="validations.js" pinned="false" current-in-tab="true">
|
|
27
|
-
<entry file="file://$PROJECT_DIR$/lib/validations.js">
|
|
28
|
-
<provider selected="true" editor-type-id="text-editor">
|
|
29
|
-
<state relative-caret-position="399">
|
|
30
|
-
<caret line="148" column="7" lean-forward="true" selection-start-line="148" selection-start-column="7" selection-end-line="148" selection-end-column="7" />
|
|
31
|
-
</state>
|
|
32
|
-
</provider>
|
|
33
|
-
</entry>
|
|
34
|
-
</file>
|
|
35
|
-
</leaf>
|
|
36
|
-
</component>
|
|
37
|
-
<component name="FindInProjectRecents">
|
|
38
|
-
<findStrings>
|
|
39
|
-
<find>addressVal</find>
|
|
40
|
-
</findStrings>
|
|
41
|
-
</component>
|
|
42
|
-
<component name="Git.Settings">
|
|
43
|
-
<option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
|
|
44
|
-
</component>
|
|
45
|
-
<component name="IdeDocumentHistory">
|
|
46
|
-
<option name="CHANGED_PATHS">
|
|
47
|
-
<list>
|
|
48
|
-
<option value="$PROJECT_DIR$/package.json" />
|
|
49
|
-
<option value="$PROJECT_DIR$/lib/validations.js" />
|
|
50
|
-
</list>
|
|
51
|
-
</option>
|
|
52
|
-
</component>
|
|
53
|
-
<component name="JsBuildToolGruntFileManager" detection-done="true" sorting="DEFINITION_ORDER" />
|
|
54
|
-
<component name="JsBuildToolPackageJson" detection-done="true" sorting="DEFINITION_ORDER">
|
|
55
|
-
<package-json value="$PROJECT_DIR$/package.json" />
|
|
56
|
-
</component>
|
|
57
|
-
<component name="JsGulpfileManager">
|
|
58
|
-
<detection-done>true</detection-done>
|
|
59
|
-
<sorting>DEFINITION_ORDER</sorting>
|
|
60
|
-
</component>
|
|
61
|
-
<component name="NodeModulesDirectoryManager">
|
|
62
|
-
<handled-path value="$PROJECT_DIR$/node_modules" />
|
|
63
|
-
</component>
|
|
64
|
-
<component name="NodePackageJsonFileManager">
|
|
65
|
-
<packageJsonPaths>
|
|
66
|
-
<path value="$PROJECT_DIR$/package.json" />
|
|
67
|
-
</packageJsonPaths>
|
|
68
|
-
</component>
|
|
69
|
-
<component name="ProjectFrameBounds" extendedState="6">
|
|
70
|
-
<option name="y" value="23" />
|
|
71
|
-
<option name="width" value="1680" />
|
|
72
|
-
<option name="height" value="1027" />
|
|
73
|
-
</component>
|
|
74
|
-
<component name="ProjectView">
|
|
75
|
-
<navigator proportions="" version="1">
|
|
76
|
-
<foldersAlwaysOnTop value="true" />
|
|
77
|
-
</navigator>
|
|
78
|
-
<panes>
|
|
79
|
-
<pane id="Scope" />
|
|
80
|
-
<pane id="ProjectPane">
|
|
81
|
-
<subPane>
|
|
82
|
-
<expand>
|
|
83
|
-
<path>
|
|
84
|
-
<item name="aml-utils" type="b2602c69:ProjectViewProjectNode" />
|
|
85
|
-
<item name="aml-utils" type="462c0819:PsiDirectoryNode" />
|
|
86
|
-
</path>
|
|
87
|
-
<path>
|
|
88
|
-
<item name="aml-utils" type="b2602c69:ProjectViewProjectNode" />
|
|
89
|
-
<item name="aml-utils" type="462c0819:PsiDirectoryNode" />
|
|
90
|
-
<item name="lib" type="462c0819:PsiDirectoryNode" />
|
|
91
|
-
</path>
|
|
92
|
-
</expand>
|
|
93
|
-
<select />
|
|
94
|
-
</subPane>
|
|
95
|
-
</pane>
|
|
96
|
-
</panes>
|
|
97
|
-
</component>
|
|
98
|
-
<component name="PropertiesComponent">
|
|
99
|
-
<property name="WebServerToolWindowFactoryState" value="false" />
|
|
100
|
-
<property name="last_opened_file_path" value="$PROJECT_DIR$" />
|
|
101
|
-
<property name="node.js.detected.package.eslint" value="true" />
|
|
102
|
-
<property name="node.js.path.for.package.eslint" value="project" />
|
|
103
|
-
<property name="node.js.selected.package.eslint" value="$PROJECT_DIR$/node_modules/eslint" />
|
|
104
|
-
<property name="nodejs_interpreter_path.stuck_in_default_project" value="undefined stuck path" />
|
|
105
|
-
<property name="nodejs_npm_path_reset_for_default_project" value="true" />
|
|
106
|
-
<property name="nodejs_package_manager_path" value="npm" />
|
|
107
|
-
</component>
|
|
108
|
-
<component name="RunDashboard">
|
|
109
|
-
<option name="ruleStates">
|
|
110
|
-
<list>
|
|
111
|
-
<RuleState>
|
|
112
|
-
<option name="name" value="ConfigurationTypeDashboardGroupingRule" />
|
|
113
|
-
</RuleState>
|
|
114
|
-
<RuleState>
|
|
115
|
-
<option name="name" value="StatusDashboardGroupingRule" />
|
|
116
|
-
</RuleState>
|
|
117
|
-
</list>
|
|
118
|
-
</option>
|
|
119
|
-
</component>
|
|
120
|
-
<component name="SvnConfiguration">
|
|
121
|
-
<configuration />
|
|
122
|
-
</component>
|
|
123
|
-
<component name="TaskManager">
|
|
124
|
-
<task active="true" id="Default" summary="Default task">
|
|
125
|
-
<changelist id="beae4972-1969-4895-bbc9-d79f09bb9811" name="Default" comment="" />
|
|
126
|
-
<created>1563360614655</created>
|
|
127
|
-
<option name="number" value="Default" />
|
|
128
|
-
<option name="presentableId" value="Default" />
|
|
129
|
-
<updated>1563360614655</updated>
|
|
130
|
-
<workItem from="1563360615721" duration="151000" />
|
|
131
|
-
<workItem from="1567667753338" duration="597000" />
|
|
132
|
-
</task>
|
|
133
|
-
<servers />
|
|
134
|
-
</component>
|
|
135
|
-
<component name="TimeTrackingManager">
|
|
136
|
-
<option name="totallyTimeSpent" value="748000" />
|
|
137
|
-
</component>
|
|
138
|
-
<component name="ToolWindowManager">
|
|
139
|
-
<frame x="0" y="23" width="1920" height="1057" extended-state="6" />
|
|
140
|
-
<editor active="true" />
|
|
141
|
-
<layout>
|
|
142
|
-
<window_info active="true" content_ui="combo" id="Project" order="0" visible="true" weight="0.24907847" />
|
|
143
|
-
<window_info anchor="bottom" id="TODO" order="6" />
|
|
144
|
-
<window_info anchor="bottom" id="Docker" order="7" show_stripe_button="false" />
|
|
145
|
-
<window_info anchor="bottom" id="Event Log" order="7" side_tool="true" />
|
|
146
|
-
<window_info id="npm" order="2" side_tool="true" />
|
|
147
|
-
<window_info anchor="bottom" id="Version Control" order="7" />
|
|
148
|
-
<window_info anchor="bottom" id="Run" order="2" />
|
|
149
|
-
<window_info id="Structure" order="1" side_tool="true" weight="0.25" />
|
|
150
|
-
<window_info anchor="bottom" id="Terminal" order="7" />
|
|
151
|
-
<window_info id="Favorites" order="2" side_tool="true" />
|
|
152
|
-
<window_info anchor="bottom" id="Debug" order="3" weight="0.4" />
|
|
153
|
-
<window_info anchor="right" content_ui="combo" id="Hierarchy" order="2" weight="0.25" />
|
|
154
|
-
<window_info anchor="bottom" id="Inspection" order="5" weight="0.4" />
|
|
155
|
-
<window_info anchor="right" id="Commander" internal_type="SLIDING" order="0" type="SLIDING" weight="0.4" />
|
|
156
|
-
<window_info anchor="right" id="Ant Build" order="1" weight="0.25" />
|
|
157
|
-
<window_info anchor="bottom" id="Message" order="0" />
|
|
158
|
-
<window_info anchor="bottom" id="Cvs" order="4" weight="0.25" />
|
|
159
|
-
<window_info anchor="bottom" id="Find" order="1" />
|
|
160
|
-
</layout>
|
|
161
|
-
</component>
|
|
162
|
-
<component name="TypeScriptGeneratedFilesManager">
|
|
163
|
-
<option name="version" value="1" />
|
|
164
|
-
</component>
|
|
165
|
-
<component name="VcsContentAnnotationSettings">
|
|
166
|
-
<option name="myLimit" value="2678400000" />
|
|
167
|
-
</component>
|
|
168
|
-
<component name="editorHistoryManager">
|
|
169
|
-
<entry file="file://$PROJECT_DIR$/package.json">
|
|
170
|
-
<provider selected="true" editor-type-id="text-editor">
|
|
171
|
-
<state relative-caret-position="364">
|
|
172
|
-
<caret line="28" column="24" selection-start-line="28" selection-start-column="24" selection-end-line="28" selection-end-column="24" />
|
|
173
|
-
</state>
|
|
174
|
-
</provider>
|
|
175
|
-
</entry>
|
|
176
|
-
<entry file="file://$PROJECT_DIR$/package.json">
|
|
177
|
-
<provider selected="true" editor-type-id="text-editor">
|
|
178
|
-
<state relative-caret-position="364">
|
|
179
|
-
<caret line="28" column="32" selection-start-line="28" selection-start-column="32" selection-end-line="28" selection-end-column="32" />
|
|
180
|
-
</state>
|
|
181
|
-
</provider>
|
|
182
|
-
</entry>
|
|
183
|
-
<entry file="file://$PROJECT_DIR$/lib/validations.js">
|
|
184
|
-
<provider selected="true" editor-type-id="text-editor">
|
|
185
|
-
<state relative-caret-position="399">
|
|
186
|
-
<caret line="148" column="7" lean-forward="true" selection-start-line="148" selection-start-column="7" selection-end-line="148" selection-end-column="7" />
|
|
187
|
-
</state>
|
|
188
|
-
</provider>
|
|
189
|
-
</entry>
|
|
190
|
-
</component>
|
|
191
|
-
</project>
|
package/.npmignore
DELETED