refactor(@embark/utils): move hexToNumber into embark-utils package

This commit is contained in:
Michael Bradley, Jr 2019-05-06 14:03:30 -05:00 committed by Michael Bradley
parent b8708f4305
commit 20f1a13ae6
4 changed files with 9 additions and 10 deletions

View File

@ -12,6 +12,7 @@ import * as AddressUtils from './addressUtils';
import {
getWeiBalanceFromString,
getHexBalanceFromString,
hexToNumber,
decodeParams,
sha3,
isHex,
@ -200,6 +201,7 @@ const Utils = {
checkIsAvailable,
findNextPort,
hashTo32ByteHexString,
hexToNumber,
isHex,
last,
soliditySha3,

View File

@ -55,3 +55,7 @@ export function soliditySha3(arg: any) {
export function toChecksumAddress(address: any) {
return web3.utils.toChecksumAddress(address);
}
export function hexToNumber(hex: string) {
return web3.utils.hexToNumber(hex);
}

View File

@ -1,6 +1,5 @@
const async = require('async');
const utils = require('../../utils/utils.js');
import { getAddressToContract, getTransactionParams } from 'embark-utils';
import { getAddressToContract, getTransactionParams, hexToNumber } from 'embark-utils';
class ConsoleListener {
constructor(embark, options) {
@ -108,8 +107,8 @@ class ConsoleListener {
}
let {transactionHash, blockNumber, gasUsed, status} = request;
gasUsed = utils.hexToNumber(gasUsed);
blockNumber = utils.hexToNumber(blockNumber);
gasUsed = hexToNumber(gasUsed);
blockNumber = hexToNumber(blockNumber);
const log = Object.assign({}, request, {name, functionName, paramString, gasUsed, blockNumber});
this.events.emit('contracts:log', log);

View File

@ -261,11 +261,6 @@ function getExternalContractUrl(file,providerUrl) {
};
}
function hexToNumber(hex) {
const Web3 = require('web3');
return Web3.utils.hexToNumber(hex);
}
function isValidDomain(v) {
// from: https://github.com/miguelmota/is-valid-domain
if (typeof v !== 'string') return false;
@ -431,7 +426,6 @@ module.exports = {
httpGetJson,
httpsGetJson,
getJson,
hexToNumber,
isValidDomain,
pingEndpoint,
cd,