diff --git a/packages/embark-utils/src/index.js b/packages/embark-utils/src/index.js index 703717cf6..05d8c3066 100644 --- a/packages/embark-utils/src/index.js +++ b/packages/embark-utils/src/index.js @@ -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, diff --git a/packages/embark-utils/src/web3Utils.ts b/packages/embark-utils/src/web3Utils.ts index 1891a948b..69feed120 100644 --- a/packages/embark-utils/src/web3Utils.ts +++ b/packages/embark-utils/src/web3Utils.ts @@ -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); +} diff --git a/packages/embark/src/lib/modules/console_listener/index.js b/packages/embark/src/lib/modules/console_listener/index.js index e3ffc062d..1da47ad57 100644 --- a/packages/embark/src/lib/modules/console_listener/index.js +++ b/packages/embark/src/lib/modules/console_listener/index.js @@ -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); diff --git a/packages/embark/src/lib/utils/utils.js b/packages/embark/src/lib/utils/utils.js index 7f339db34..f3e7fd9a2 100644 --- a/packages/embark/src/lib/utils/utils.js +++ b/packages/embark/src/lib/utils/utils.js @@ -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,