From 850677838401e7e8effe0a01256aa0b7485fc381 Mon Sep 17 00:00:00 2001 From: Jonathan Rainville Date: Fri, 26 Apr 2019 15:37:58 -0400 Subject: [PATCH] refactor(@embark/utils): move addressUtils to embark-utils --- .../src/lib/utils => embark-utils/src}/addressUtils.ts | 0 packages/embark-utils/src/index.js | 3 ++- packages/embark/src/lib/core/config.js | 4 ++-- .../src/lib/modules/deployment/contract_deployer.js | 3 ++- packages/embark/src/lib/modules/ens/index.js | 9 ++++----- packages/embark/src/lib/utils/contractsConfig.ts | 3 ++- 6 files changed, 12 insertions(+), 10 deletions(-) rename packages/{embark/src/lib/utils => embark-utils/src}/addressUtils.ts (100%) diff --git a/packages/embark/src/lib/utils/addressUtils.ts b/packages/embark-utils/src/addressUtils.ts similarity index 100% rename from packages/embark/src/lib/utils/addressUtils.ts rename to packages/embark-utils/src/addressUtils.ts diff --git a/packages/embark-utils/src/index.js b/packages/embark-utils/src/index.js index 0565606b5..e0c437683 100644 --- a/packages/embark-utils/src/index.js +++ b/packages/embark-utils/src/index.js @@ -112,7 +112,8 @@ const Utils = { runCmd, escapeHtml: logUtils.escapeHtml, normalizeInput: logUtils.normalizeInput, - LogHandler: require('./logHandler') + LogHandler: require('./logHandler'), + AddressUtils: require('./addressUtils') }; module.exports = Utils; diff --git a/packages/embark/src/lib/core/config.js b/packages/embark/src/lib/core/config.js index 3e8573761..1cee0cab7 100644 --- a/packages/embark/src/lib/core/config.js +++ b/packages/embark/src/lib/core/config.js @@ -5,9 +5,9 @@ const path = require('path'); const deepEqual = require('deep-equal'); const web3 = require('web3'); const constants = require('../constants'); -import {canonicalHost, defaultHost, recursiveMerge} from 'embark-utils'; +import {canonicalHost, defaultHost, recursiveMerge, AddressUtils} from 'embark-utils'; const cloneDeep = require('lodash.clonedeep'); -import { replaceZeroAddressShorthand } from '../utils/addressUtils'; +const { replaceZeroAddressShorthand } = AddressUtils; import { unitRegex } from "../utils/regexConstants"; import * as utilsContractsConfig from "../utils/contractsConfig"; import { File, Types } from "./file"; diff --git a/packages/embark/src/lib/modules/deployment/contract_deployer.js b/packages/embark/src/lib/modules/deployment/contract_deployer.js index 861b0f225..c31141475 100644 --- a/packages/embark/src/lib/modules/deployment/contract_deployer.js +++ b/packages/embark/src/lib/modules/deployment/contract_deployer.js @@ -1,7 +1,8 @@ let async = require('async'); //require("../utils/debug_util.js")(__filename, async); let utils = require('../../utils/utils.js'); -import { ZERO_ADDRESS } from '../../utils/addressUtils'; +import {AddressUtils} from 'embark-utils'; +const {ZERO_ADDRESS} = AddressUtils; // Check out definition 97 of the yellow paper: https://ethereum.github.io/yellowpaper/paper.pdf const MAX_CONTRACT_BYTECODE_LENGTH = 24576; diff --git a/packages/embark/src/lib/modules/ens/index.js b/packages/embark/src/lib/modules/ens/index.js index 346b5dff1..9bdb97d12 100644 --- a/packages/embark/src/lib/modules/ens/index.js +++ b/packages/embark/src/lib/modules/ens/index.js @@ -1,14 +1,13 @@ -import {joinPath, hashTo32ByteHexString, soliditySha3, recursiveMerge} from 'embark-utils'; +import {joinPath, hashTo32ByteHexString, soliditySha3, recursiveMerge, AddressUtils} from 'embark-utils'; const namehash = require('eth-ens-namehash'); const async = require('async'); -const embarkJsUtils = require('embarkjs').Utils; const reverseAddrSuffix = '.addr.reverse'; const ENSFunctions = require('./ENSFunctions'); -const secureSend = embarkJsUtils.secureSend; -import {ZERO_ADDRESS} from '../../utils/addressUtils'; import {ens} from '../../constants'; -import EmbarkJS from 'embarkjs'; +import EmbarkJS, {Utils as embarkJsUtils} from 'embarkjs'; +const secureSend = embarkJsUtils.secureSend; +const {ZERO_ADDRESS} = AddressUtils; const ENS_WHITELIST = ens.whitelist; const NOT_REGISTERED_ERROR = 'Name not yet registered'; diff --git a/packages/embark/src/lib/utils/contractsConfig.ts b/packages/embark/src/lib/utils/contractsConfig.ts index 9108e0f92..244ccbfef 100644 --- a/packages/embark/src/lib/utils/contractsConfig.ts +++ b/packages/embark/src/lib/utils/contractsConfig.ts @@ -1,6 +1,7 @@ -import { extendZeroAddressShorthand, replaceZeroAddressShorthand } from "./addressUtils"; +import AddressUtils from 'embark-utils'; import { unitRegex } from "./regexConstants"; +const { extendZeroAddressShorthand, replaceZeroAddressShorthand } = AddressUtils; const web3 = require("web3"); const utils = require("./utils.js");