Removed Circular Dependencies
This commit is contained in:
@@ -17,7 +17,7 @@
|
||||
import BigNumber from 'bignumber.js';
|
||||
|
||||
import { isArray, isHex, isInstanceOf, isString } from '../util/types';
|
||||
import { padLeft } from '../util/format';
|
||||
import { padLeft, toHex } from '../util/format';
|
||||
|
||||
export function inAddress (address) {
|
||||
// TODO: address validation if we have upper-lower addresses
|
||||
@@ -100,15 +100,7 @@ export function inFilter (options) {
|
||||
}
|
||||
|
||||
export function inHex (str) {
|
||||
if (str && str.toString) {
|
||||
str = str.toString(16);
|
||||
}
|
||||
|
||||
if (str && str.substr(0, 2) === '0x') {
|
||||
return str.toLowerCase();
|
||||
}
|
||||
|
||||
return `0x${(str || '').toLowerCase()}`;
|
||||
return toHex(str);
|
||||
}
|
||||
|
||||
export function inNumber10 (number) {
|
||||
|
||||
@@ -15,7 +15,6 @@
|
||||
// along with Parity. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import { range } from 'lodash';
|
||||
import { inHex } from '../format/input';
|
||||
|
||||
export function bytesToHex (bytes) {
|
||||
return '0x' + bytes.map((b) => ('0' + b.toString(16)).slice(-2)).join('');
|
||||
@@ -38,11 +37,23 @@ export function asciiToHex (string) {
|
||||
}
|
||||
|
||||
export function padRight (input, length) {
|
||||
const value = inHex(input).substr(2, length * 2);
|
||||
const value = toHex(input).substr(2, length * 2);
|
||||
return '0x' + value + range(length * 2 - value.length).map(() => '0').join('');
|
||||
}
|
||||
|
||||
export function padLeft (input, length) {
|
||||
const value = inHex(input).substr(2, length * 2);
|
||||
const value = toHex(input).substr(2, length * 2);
|
||||
return '0x' + range(length * 2 - value.length).map(() => '0').join('') + value;
|
||||
}
|
||||
|
||||
export function toHex (str) {
|
||||
if (str && str.toString) {
|
||||
str = str.toString(16);
|
||||
}
|
||||
|
||||
if (str && str.substr(0, 2) === '0x') {
|
||||
return str.toLowerCase();
|
||||
}
|
||||
|
||||
return `0x${(str || '').toLowerCase()}`;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user