From a69f619cf732f770c2dbe50a9e2b4e2f170a46ea Mon Sep 17 00:00:00 2001 From: Pascal Precht Date: Thu, 2 May 2019 11:10:10 +0200 Subject: [PATCH] refactor(@embark/utils): move toChecksumAddress to embark-utils --- packages/embark-utils/src/index.js | 4 +++- packages/embark-utils/src/web3Utils.ts | 4 ++++ packages/embark/src/lib/utils/utils.js | 6 ------ 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/packages/embark-utils/src/index.js b/packages/embark-utils/src/index.js index d6f575ac7..703717cf6 100644 --- a/packages/embark-utils/src/index.js +++ b/packages/embark-utils/src/index.js @@ -15,7 +15,8 @@ import { decodeParams, sha3, isHex, - soliditySha3 + soliditySha3, + toChecksumAddress } from './web3Utils'; import { getAddressToContract, getTransactionParams } from './transactionUtils'; import LongRunningProcessTimer from './longRunningProcessTimer'; @@ -216,6 +217,7 @@ const Utils = { LogHandler: require('./logHandler'), LongRunningProcessTimer, proposeAlternative, + toChecksumAddress, toposort, AddressUtils, AccountParser diff --git a/packages/embark-utils/src/web3Utils.ts b/packages/embark-utils/src/web3Utils.ts index 97f6272da..1891a948b 100644 --- a/packages/embark-utils/src/web3Utils.ts +++ b/packages/embark-utils/src/web3Utils.ts @@ -51,3 +51,7 @@ export function isHex(hex: string) { export function soliditySha3(arg: any) { return web3.utils.soliditySha3(arg); } + +export function toChecksumAddress(address: any) { + return web3.utils.toChecksumAddress(address); +} diff --git a/packages/embark/src/lib/utils/utils.js b/packages/embark/src/lib/utils/utils.js index 46d8b2141..7f339db34 100644 --- a/packages/embark/src/lib/utils/utils.js +++ b/packages/embark/src/lib/utils/utils.js @@ -287,11 +287,6 @@ function isValidDomain(v) { return isValid; } -function toChecksumAddress(address) { - const Web3 = require('web3'); - return Web3.utils.toChecksumAddress(address); -} - /** * Builds a URL * @@ -445,7 +440,6 @@ module.exports = { extractTar, extractZip, getExternalContractUrl, - toChecksumAddress, normalizeInput, buildUrl, buildUrlFromConfig,