@@ -5,7 +5,6 @@ import { isValidAddress } from './wallet'
55
66const hexRegExp = /[0-9A-Fa-f]{64}/g
77
8−
98// // Note that this validator also transforms data
109// const validateBase64 = ({ data, pass, error }) => {
1110// if (pass !== true) return { data, pass, error }
@@ -30,10 +29,6 @@ const hexRegExp = /[0-9A-Fa-f]{64}/g
3029// }
3130// };
3231
33−
34−
35−
36−
3732// Validates a bip39 mnemonic
3833const validateMnemonic = m => simpleValidatorWrapper({
3934 prevMessage: m,
@@ -41,7 +36,6 @@ const validateMnemonic = m => simpleValidatorWrapper({
4136 errorMessage: 'This is not a valid mnemonic.'
4237});
4338
44−
4539// Checks an empty field
4640const validateNotEmpty = m => simpleValidatorWrapper({
4741 prevMessage: m,
@@ -49,8 +43,6 @@ const validateNotEmpty = m => simpleValidatorWrapper({
4943 errorMessage: 'This field is required.'
5044});
5145
52−
53−
5446// Checks if a patp is a valid galaxy
5547const validateGalaxy = m => simpleValidatorWrapper({
5648 prevMessage: m,
@@ -66,8 +58,6 @@ const validateGalaxy = m => simpleValidatorWrapper({
6658 errorMessage: 'This is not a valid galaxy'
6759});
6860
69−
70−
7161const validatePoint = m => simpleValidatorWrapper({
7262 prevMessage: m,
7363 validator: d => {
@@ -80,8 +70,6 @@ const validatePoint = m => simpleValidatorWrapper({
8070 errorMessage: 'This is not a valid point'
8171});
8272
83−
84−
8573const validateTicket = m => simpleValidatorWrapper({
8674 prevMessage: m,
8775 validator: d => {
@@ -94,7 +82,6 @@ const validateTicket = m => simpleValidatorWrapper({
9482 errorMessage: 'This is not a valid ticket'
9583});
9684
97−
9885const validateShard = m => simpleValidatorWrapper({
9986 prevMessage: m,
10087 validator: d => {
@@ -107,29 +94,24 @@ const validateShard = m => simpleValidatorWrapper({
10794 errorMessage: 'This is not a valid shard'
10895});
10996
110−
11197const validateLength = (m, l) => simpleValidatorWrapper({
11298 prevMessage: m,
11399 validator: d => d.length === l,
114100 errorMessage: 'This is of an invalid length'
115101});
116102
117−
118103const validateNetworkKey = m => simpleValidatorWrapper({
119104 prevMessage: m,
120105 validator: d => hexRegExp.test(d),
121106 errorMessage: 'This is not a valid network key'
122107});
123108
124−
125109const validateNetworkSeed = m => simpleValidatorWrapper({
126110 prevMessage: m,
127111 validator: d => hexRegExp.test(d),
128112 errorMessage: 'This is not a valid network seed'
129113});
130114
131−
132−
133115// Checks if a string is a valid ethereum address
134116const validateEthereumAddress = m => simpleValidatorWrapper({
135117 prevMessage: m,
@@ -137,10 +119,6 @@ const validateEthereumAddress = m => simpleValidatorWrapper({
137119 errorMessage: 'This is not a valid Ethereum address'
138120});
139121
140−
141−
142−
143−
144122// Wraps single validation functions in a controlled and predictable way.
145123const simpleValidatorWrapper = config => {
146124
@@ -172,11 +150,10 @@ const newMessage = (data, pass, error) => ({
172150 error,
173151})
174152
175−
176−
177153export {
178154 // validateBase64,
179155 // validateJSON,
156+ simpleValidatorWrapper,
180157 validateMnemonic,
181158 validateNotEmpty,
182159 validateGalaxy,