eslint ./src/utils

pull/86/head
Szymon Lesisz 6 years ago
parent f435b8669c
commit 1ea6d0be4c

@ -12,6 +12,7 @@
"jest": true "jest": true
}, },
"rules": { "rules": {
"import/prefer-default-export": 0,
"no-use-before-define": 0, "no-use-before-define": 0,
"no-plusplus": 0, "no-plusplus": 0,
"class-methods-use-this": 0, "class-methods-use-this": 0,

@ -5,14 +5,11 @@ import EthereumjsUtil from 'ethereumjs-util';
export const decimalToHex = (dec: number): string => new BigNumber(dec).toString(16); export const decimalToHex = (dec: number): string => new BigNumber(dec).toString(16);
export const padLeftEven = (hex: string): string => { export const padLeftEven = (hex: string): string => (hex.length % 2 !== 0 ? `0${hex}` : hex);
hex = hex.length % 2 != 0 ? `0${hex}` : hex;
return hex;
};
export const sanitizeHex = (hex: number | string): ?string => { export const sanitizeHex = ($hex: number | string): ?string => {
if (typeof hex !== 'string') return null; if (typeof $hex !== 'string') return null;
hex = hex.substring(0, 2) === '0x' ? hex.substring(2) : hex; const hex = $hex.substring(0, 2) === '0x' ? $hex.substring(2) : $hex;
if (hex === '') return ''; if (hex === '') return '';
return `0x${padLeftEven(hex)}`; return `0x${padLeftEven(hex)}`;
}; };
@ -35,10 +32,12 @@ export const validateAddress = (address: string): ?string => {
const hasUpperCase = new RegExp('^(.*[A-Z].*)$'); const hasUpperCase = new RegExp('^(.*[A-Z].*)$');
if (address.length < 1) { if (address.length < 1) {
return 'Address is not set'; return 'Address is not set';
} else if (!EthereumjsUtil.isValidAddress(address)) { }
if (!EthereumjsUtil.isValidAddress(address)) {
return 'Address is not valid'; return 'Address is not valid';
} else if (address.match(hasUpperCase) && !EthereumjsUtil.isValidChecksumAddress(address)) { }
if (address.match(hasUpperCase) && !EthereumjsUtil.isValidChecksumAddress(address)) {
return 'Address is not a valid checksum'; return 'Address is not a valid checksum';
} }
return null; return null;
} };

@ -1,12 +1,5 @@
/* @flow */ /* @flow */
export const resolveAfter = (msec: number, value?: any): Promise<any> => new Promise((resolve) => {
// import root from 'window-or-global'; window.setTimeout(resolve, msec, value);
// import Promise from 'es6-promise'; });
export async function resolveAfter(msec: number, value?: any): Promise<any> {
await new Promise((resolve) => {
//root.setTimeout(resolve, msec, value);
window.setTimeout(resolve, msec, value);
});
}

Loading…
Cancel
Save