From 6fa7e92fd8c301a8585b4259f5ef8a8c729b92c6 Mon Sep 17 00:00:00 2001 From: emizzle Date: Tue, 5 Jun 2018 17:15:21 +1000 Subject: [PATCH 01/32] Updates console to inform user of an ongoing package download. Console message turns red after 1 second. --- lib/versions/npm.js | 65 +++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 60 insertions(+), 5 deletions(-) diff --git a/lib/versions/npm.js b/lib/versions/npm.js index 1bac4306..f7ca1751 100644 --- a/lib/versions/npm.js +++ b/lib/versions/npm.js @@ -1,6 +1,8 @@ -let fs = require('../core/fs.js'); - -let PluginManager = require('live-plugin-manager').PluginManager; +const fs = require('../core/fs.js'); +const {PerformanceObserver, performance} = require('perf_hooks'); +const PluginManager = require('live-plugin-manager').PluginManager; +require('colors'); +const _ = require('underscore'); class Npm { @@ -17,9 +19,62 @@ class Npm { return callback(null, packageDirectory + packageName); } - this.logger.info("downloading " + packageName + " " + version + "...."); - this.logger.info(__("downloading {{packageName}} {{version}}....", {packageName: packageName, version: version})); + this.logger.info(__("Downloading {{packageName}} {{version}}...", {packageName: packageName, version: version})); + + const obsMeasure = new PerformanceObserver((items) => { + let entry; + let strDuration; + + // find any download ongoing measurements we've made + entry = _.last(_.where(items.getEntries(), {name: downloadOngoing})); + if(entry){ + // ongoing performance mark + strDuration = __('Still downloading {{packageName}} {{version}}... ({{duration}}ms elapsed)', {packageName: packageName, version: version, duration: entry.duration}); + } + else{ + // otherwise, find our download complete measurement + entry = _.last(_.where(items.getEntries(), {name: downloadComplete})); + + if(entry){ + strDuration = __('Finished downloading {{packageName}} {{version}} in {{duration}}ms', {packageName: packageName, version: version, duration: entry.duration}); + performance.clearMarks(); + } + } + + // log our measurement and make it red if it has taken too long + if(entry && strDuration){ + if(entry.duration > 1000){ + strDuration = strDuration.red; + } + this.logger.info(strDuration); + } + + }); + obsMeasure.observe({entryTypes: ['measure']}); + + // define mark and measurement names + let startMark = 'downloadStart' + packageName + version; + let ongoingMark = 'downloadOngoingMark' + packageName + version; + let downloadOngoing = 'downloadOngoing' + packageName + version; + let endMark = 'downloadEnd' + packageName + version; + let downloadComplete = 'downloadComplete' + packageName + version; + + // mark our start time + performance.mark(startMark); + + // function that continually updates the console to show user that we're downloading a library + let intOngoingDownload = setInterval( + function(){ + performance.mark(ongoingMark); + performance.measure(downloadOngoing, startMark, ongoingMark); + }, 750); + + // do the package download/install manager.install(packageName, version).then((result) => { + // stop updating console for ongoing download + clearInterval(intOngoingDownload); + performance.mark(endMark); + performance.measure(downloadComplete, startMark, endMark); callback(null , result.location); }).catch(callback); } From bbaf1676fbb8532ab10d7ff8951009f5c6773b70 Mon Sep 17 00:00:00 2001 From: emizzle Date: Tue, 5 Jun 2018 17:15:21 +1000 Subject: [PATCH 02/32] Updates console to inform user of an ongoing package download. Console message turns red after 1 second. --- lib/versions/npm.js | 65 +++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 60 insertions(+), 5 deletions(-) diff --git a/lib/versions/npm.js b/lib/versions/npm.js index 1bac4306..f7ca1751 100644 --- a/lib/versions/npm.js +++ b/lib/versions/npm.js @@ -1,6 +1,8 @@ -let fs = require('../core/fs.js'); - -let PluginManager = require('live-plugin-manager').PluginManager; +const fs = require('../core/fs.js'); +const {PerformanceObserver, performance} = require('perf_hooks'); +const PluginManager = require('live-plugin-manager').PluginManager; +require('colors'); +const _ = require('underscore'); class Npm { @@ -17,9 +19,62 @@ class Npm { return callback(null, packageDirectory + packageName); } - this.logger.info("downloading " + packageName + " " + version + "...."); - this.logger.info(__("downloading {{packageName}} {{version}}....", {packageName: packageName, version: version})); + this.logger.info(__("Downloading {{packageName}} {{version}}...", {packageName: packageName, version: version})); + + const obsMeasure = new PerformanceObserver((items) => { + let entry; + let strDuration; + + // find any download ongoing measurements we've made + entry = _.last(_.where(items.getEntries(), {name: downloadOngoing})); + if(entry){ + // ongoing performance mark + strDuration = __('Still downloading {{packageName}} {{version}}... ({{duration}}ms elapsed)', {packageName: packageName, version: version, duration: entry.duration}); + } + else{ + // otherwise, find our download complete measurement + entry = _.last(_.where(items.getEntries(), {name: downloadComplete})); + + if(entry){ + strDuration = __('Finished downloading {{packageName}} {{version}} in {{duration}}ms', {packageName: packageName, version: version, duration: entry.duration}); + performance.clearMarks(); + } + } + + // log our measurement and make it red if it has taken too long + if(entry && strDuration){ + if(entry.duration > 1000){ + strDuration = strDuration.red; + } + this.logger.info(strDuration); + } + + }); + obsMeasure.observe({entryTypes: ['measure']}); + + // define mark and measurement names + let startMark = 'downloadStart' + packageName + version; + let ongoingMark = 'downloadOngoingMark' + packageName + version; + let downloadOngoing = 'downloadOngoing' + packageName + version; + let endMark = 'downloadEnd' + packageName + version; + let downloadComplete = 'downloadComplete' + packageName + version; + + // mark our start time + performance.mark(startMark); + + // function that continually updates the console to show user that we're downloading a library + let intOngoingDownload = setInterval( + function(){ + performance.mark(ongoingMark); + performance.measure(downloadOngoing, startMark, ongoingMark); + }, 750); + + // do the package download/install manager.install(packageName, version).then((result) => { + // stop updating console for ongoing download + clearInterval(intOngoingDownload); + performance.mark(endMark); + performance.measure(downloadComplete, startMark, endMark); callback(null , result.location); }).catch(callback); } From 7e2f5624ba79ef83d0ade1186eb8f728bce2d20d Mon Sep 17 00:00:00 2001 From: emizzle Date: Wed, 6 Jun 2018 12:04:30 +1000 Subject: [PATCH 03/32] Increased time before reporting of library download duration goes red to 4 seconds. Incrased travis build version to node 8, as embark only supports 8.10, and also perf_hooks requires 8.5 --- .travis.yml | 2 +- lib/versions/npm.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 1019d91d..b9912bde 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,6 +1,6 @@ language: node_js node_js: - - "7" + - "8" addons: code_climate: repo_token: 7454b1a666015e244c384d19f48c34e35d1ae58c3aa428ec542f10bbcb848358 diff --git a/lib/versions/npm.js b/lib/versions/npm.js index f7ca1751..0f245f78 100644 --- a/lib/versions/npm.js +++ b/lib/versions/npm.js @@ -43,7 +43,7 @@ class Npm { // log our measurement and make it red if it has taken too long if(entry && strDuration){ - if(entry.duration > 1000){ + if(entry.duration > 4000){ strDuration = strDuration.red; } this.logger.info(strDuration); From bfc8663a61efe70f5bd83458a919d26e7c6b5f9c Mon Sep 17 00:00:00 2001 From: Jonathan Rainville Date: Thu, 7 Jun 2018 12:55:07 -0400 Subject: [PATCH 04/32] change account funding order to enable starting a node before --- lib/contracts/blockchain.js | 46 ++++++++++++++++++++++--------------- lib/contracts/provider.js | 23 +++++++++++-------- 2 files changed, 41 insertions(+), 28 deletions(-) diff --git a/lib/contracts/blockchain.js b/lib/contracts/blockchain.js index 1d0f0c95..e2403c0c 100644 --- a/lib/contracts/blockchain.js +++ b/lib/contracts/blockchain.js @@ -54,26 +54,34 @@ class Blockchain { }; provider = new Provider(providerOptions); - provider.startWeb3Provider(() => { - self.assertNodeConnection(true, (err) => { - if (err && self.web3StartedInProcess) { - // Already started blockchain in another node, we really have a node problem - self.logger.error(__('Unable to start the blockchain process. Is Geth installed?').red); - return cb(err); - } - if (!err) { - self.isWeb3Ready = true; - self.events.emit(WEB3_READY); - return cb(); - } - self.web3StartedInProcess = true; - self.startBlockchainNode(() => { - // Need to re-initialize web3 to connect to the new blockchain node - provider.stop(); - self.initWeb3(cb); + async.waterfall([ + function startProvider(next) { + provider.startWeb3Provider(next); + }, + function checkNode(next) { + self.assertNodeConnection(true, (err) => { + if (err && self.web3StartedInProcess) { + // Already started blockchain in another node, we really have a node problem + self.logger.error(__('Unable to start the blockchain process. Is Geth installed?').red); + return next(err); + } + if (!err) { + self.isWeb3Ready = true; + self.events.emit(WEB3_READY); + return next(); + } + self.web3StartedInProcess = true; + self.startBlockchainNode(() => { + // Need to re-initialize web3 to connect to the new blockchain node + provider.stop(); + self.initWeb3(cb); + }); }); - }); - }); + }, + function fundAccountsIfNeeded(next) { + provider.fundAccounts(next); + } + ], cb); } else { throw new Error("contracts config error: unknown deployment type " + this.contractsConfig.deployment.type); } diff --git a/lib/contracts/provider.js b/lib/contracts/provider.js index 2614e384..f9337962 100644 --- a/lib/contracts/provider.js +++ b/lib/contracts/provider.js @@ -35,18 +35,10 @@ class Provider { self.accounts = AccountParser.parseAccountsConfig(self.accountsConfig, self.web3, self.logger); self.addresses = []; async.waterfall([ - function fundAccounts(next) { + function populateWeb3Wallet(next) { if (!self.accounts.length) { return next(NO_ACCOUNTS); } - if (!self.isDev) { - return next(); - } - async.each(self.accounts, (account, eachCb) => { - fundAccount(self.web3, account.address, eachCb); - }, next); - }, - function populateWeb3Wallet(next) { self.accounts.forEach(account => { self.addresses.push(account.address); self.web3.eth.accounts.wallet.add(account); @@ -64,6 +56,19 @@ class Provider { }); } + fundAccounts(callback) { + const self = this; + if (!self.accounts.length) { + return callback(); + } + if (!self.isDev) { + return callback(); + } + async.each(self.accounts, (account, eachCb) => { + fundAccount(self.web3, account.address, eachCb); + }, callback); + } + stop() { this.engine.stop(); } From ac631f90dcd24f0df2dd3ab8c49588d5a87630a0 Mon Sep 17 00:00:00 2001 From: Jonathan Rainville Date: Wed, 6 Jun 2018 15:22:15 -0400 Subject: [PATCH 05/32] fix missing error callback --- lib/contracts/deploy_manager.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/contracts/deploy_manager.js b/lib/contracts/deploy_manager.js index ff87adf4..7f69e9e6 100644 --- a/lib/contracts/deploy_manager.js +++ b/lib/contracts/deploy_manager.js @@ -29,8 +29,8 @@ class DeployManager { async.eachOfSeries(contracts, function (contract, key, callback) { contract._gasLimit = self.gasLimit; - self.events.request('deploy:contract', contract, () => { - callback(); + self.events.request('deploy:contract', contract, (err) => { + callback(err); }); }, function (err, _results) { From 30a82635690db968dcac8e10339c526104b39c9f Mon Sep 17 00:00:00 2001 From: Jonathan Rainville Date: Wed, 6 Jun 2018 15:33:48 -0400 Subject: [PATCH 06/32] enable using accounts and balances --- lib/tests/test.js | 39 +++++++++++++++---- .../test_app/test/another_storage_spec.js | 7 ++++ 2 files changed, 38 insertions(+), 8 deletions(-) diff --git a/lib/tests/test.js b/lib/tests/test.js index 2e81f943..f98c6a32 100644 --- a/lib/tests/test.js +++ b/lib/tests/test.js @@ -6,6 +6,7 @@ const utils = require('../utils/utils'); const constants = require('../constants'); const Events = require('../core/events'); const cloneDeep = require('clone-deep'); +const AccountParser = require('../contracts/accountParser'); function getSimulator() { try { @@ -36,12 +37,7 @@ class Test { this.compiledContracts = {}; this.web3 = new Web3(); - if (this.simOptions.node) { - this.web3.setProvider(new this.web3.providers.HttpProvider(this.simOptions.node)); - } else { - this.sim = getSimulator(); - this.web3.setProvider(this.sim.provider(this.simOptions)); - } + this.initWeb3Provider(); this.engine = new Engine({ env: this.options.env || 'test', @@ -55,11 +51,32 @@ class Test { }); this.versions_default = this.engine.config.contractsConfig.versions; + const deploymentConfig = this.engine.config.contractsConfig.versions; // Reset contract config to nothing to make sure we deploy only what we want - this.engine.config.contractsConfig = {contracts: {}, versions: this.versions_default}; + this.engine.config.contractsConfig = {contracts: {}, versions: this.versions_default, deployment: deploymentConfig}; this.engine.startService("libraryManager"); this.engine.startService("codeRunner"); + this.initDeployServices(); + this.engine.startService("codeGenerator"); + } + + initWeb3Provider() { + if (this.simOptions.node) { + this.web3.setProvider(new this.web3.providers.HttpProvider(this.simOptions.node)); + } else { + if (this.simOptions.accounts) { + this.simOptions.accounts = this.simOptions.accounts.map((account, index) => { + return {balance: this.options.deployment.accounts[index].balance || 0xFFFFFFFFFFFFFFFFFF, + secretKey: account.privateKey}; + }); + } + this.sim = getSimulator(); + this.web3.setProvider(this.sim.provider(this.simOptions)); + } + } + + initDeployServices() { this.engine.startService("web3", { web3: this.web3 }); @@ -67,7 +84,6 @@ class Test { trackContracts: false, ipcRole: 'client' }); - this.engine.startService("codeGenerator"); } init(callback) { @@ -100,6 +116,13 @@ class Test { this.simOptions = this.options.simulatorOptions || {}; this.ready = false; + if (this.options.deployment && this.options.deployment.accounts) { + // Account setup + this.simOptions.accounts = AccountParser.parseAccountsConfig(this.options.deployment.accounts, this.web3); + this.initWeb3Provider(); + this.initDeployServices(); + } + // Reset contracts this.engine.contractsManager.contracts = cloneDeep(this.builtContracts); this.engine.contractsManager.compiledContracts = cloneDeep(this.compiledContracts); diff --git a/test_apps/test_app/test/another_storage_spec.js b/test_apps/test_app/test/another_storage_spec.js index 82ee75fb..cce1aaa6 100644 --- a/test_apps/test_app/test/another_storage_spec.js +++ b/test_apps/test_app/test/another_storage_spec.js @@ -4,6 +4,13 @@ const AnotherStorage = embark.require('Embark/contracts/AnotherStorage'); const SimpleStorage = embark.require('Embark/contracts/SimpleStorage'); config({ + deployment: { + "accounts": [ + { + "mnemonic": "example exile argue silk regular smile grass bomb merge arm assist farm" + } + ] + }, contracts: { "SimpleStorage": { args: [100] From 4ffb5c401fae64e24927fa2838a576fc20e9caf4 Mon Sep 17 00:00:00 2001 From: Jonathan Rainville Date: Wed, 6 Jun 2018 16:43:08 -0400 Subject: [PATCH 07/32] enable setting balance in mutliple formats --- lib/tests/test.js | 52 ++++++++++++++++++- .../test_app/test/another_storage_spec.js | 15 +++++- 2 files changed, 63 insertions(+), 4 deletions(-) diff --git a/lib/tests/test.js b/lib/tests/test.js index f98c6a32..9dbc400e 100644 --- a/lib/tests/test.js +++ b/lib/tests/test.js @@ -61,14 +61,62 @@ class Test { this.engine.startService("codeGenerator"); } + // eslint-disable-next-line complexity + getMutliplicator(keyword) { + switch (keyword.toLowerCase()) { + case 'wei': return 1; + case 'ether': + case 'eth': return 1000000000000000000; + case 'finney': + case 'milli': + case 'milliether': return 1000000000000000; + case 'szabo': + case 'microether,': + case 'micro': return 1000000000000; + case 'gwei': + case 'nanoether': + case 'shannon': + case 'nano': return 1000000000; + case 'mwei': + case 'babbage': + case 'picoether': return 1000000; + case 'kwei': + case 'ada': + case 'femtoether': return 1000; + case 'kether': + case 'grand': + case 'einstein': return 1000000000000000000000; + case 'mether': return 1000000000000000000000000; + case 'gether': return 1000000000000000000000000000; + case 'tether': return 1000000000000000000000000000000; + default: console.warn('\n' + __(`Unrecognised keyword ${keyword} in balance. Will assume Wei`).yellow); + return 1; + } + } + + getBalance(balanceString) { + if (!balanceString) { + return 0xFFFFFFFFFFFFFFFFFF; + } + if (this.web3.utils.isHexStrict(balanceString)) { + return balanceString; + } + const match = balanceString.match(/([0-9]+) ?([a-zA-Z]*)/); + if (!match[2]) { + return this.web3.utils.toHex(parseInt(match[1], 10)); + } + + return this.web3.utils.toHex(parseInt(match[1], 10) * this.getMutliplicator(match[2])); + } + initWeb3Provider() { if (this.simOptions.node) { this.web3.setProvider(new this.web3.providers.HttpProvider(this.simOptions.node)); } else { if (this.simOptions.accounts) { this.simOptions.accounts = this.simOptions.accounts.map((account, index) => { - return {balance: this.options.deployment.accounts[index].balance || 0xFFFFFFFFFFFFFFFFFF, - secretKey: account.privateKey}; + const balance = this.getBalance(this.options.deployment.accounts[index].balance); + return {balance, secretKey: account.privateKey}; }); } this.sim = getSimulator(); diff --git a/test_apps/test_app/test/another_storage_spec.js b/test_apps/test_app/test/another_storage_spec.js index cce1aaa6..10ee0b35 100644 --- a/test_apps/test_app/test/another_storage_spec.js +++ b/test_apps/test_app/test/another_storage_spec.js @@ -1,13 +1,16 @@ -/*global contract, config, it, embark*/ +/*global contract, config, it, embark, web3*/ const assert = require('assert'); const AnotherStorage = embark.require('Embark/contracts/AnotherStorage'); const SimpleStorage = embark.require('Embark/contracts/SimpleStorage'); +let accounts; + config({ deployment: { "accounts": [ { - "mnemonic": "example exile argue silk regular smile grass bomb merge arm assist farm" + "mnemonic": "example exile argue silk regular smile grass bomb merge arm assist farm", + balance: "5ether" } ] }, @@ -19,6 +22,8 @@ config({ args: ["$SimpleStorage"] } } +}, (err, theAccounts) => { + accounts = theAccounts; }); contract("AnotherStorage", function() { @@ -28,4 +33,10 @@ contract("AnotherStorage", function() { let result = await AnotherStorage.methods.simpleStorageAddress().call(); assert.equal(result.toString(), SimpleStorage.options.address); }); + + it('should set the balance correctly', async function () { + const balance = await web3.eth.getBalance(accounts[0]); + assert.ok(balance < 5000000000000000000); + assert.ok(balance > 4000000000000000000); + }); }); From 2a61b2251cbdf69a82f7e4a23f2e2bc39efc2efd Mon Sep 17 00:00:00 2001 From: Jonathan Rainville Date: Wed, 6 Jun 2018 16:53:28 -0400 Subject: [PATCH 08/32] use web3 utils function instead --- lib/tests/test.js | 35 +---------------------------------- 1 file changed, 1 insertion(+), 34 deletions(-) diff --git a/lib/tests/test.js b/lib/tests/test.js index 9dbc400e..fd9e16a6 100644 --- a/lib/tests/test.js +++ b/lib/tests/test.js @@ -61,39 +61,6 @@ class Test { this.engine.startService("codeGenerator"); } - // eslint-disable-next-line complexity - getMutliplicator(keyword) { - switch (keyword.toLowerCase()) { - case 'wei': return 1; - case 'ether': - case 'eth': return 1000000000000000000; - case 'finney': - case 'milli': - case 'milliether': return 1000000000000000; - case 'szabo': - case 'microether,': - case 'micro': return 1000000000000; - case 'gwei': - case 'nanoether': - case 'shannon': - case 'nano': return 1000000000; - case 'mwei': - case 'babbage': - case 'picoether': return 1000000; - case 'kwei': - case 'ada': - case 'femtoether': return 1000; - case 'kether': - case 'grand': - case 'einstein': return 1000000000000000000000; - case 'mether': return 1000000000000000000000000; - case 'gether': return 1000000000000000000000000000; - case 'tether': return 1000000000000000000000000000000; - default: console.warn('\n' + __(`Unrecognised keyword ${keyword} in balance. Will assume Wei`).yellow); - return 1; - } - } - getBalance(balanceString) { if (!balanceString) { return 0xFFFFFFFFFFFFFFFFFF; @@ -106,7 +73,7 @@ class Test { return this.web3.utils.toHex(parseInt(match[1], 10)); } - return this.web3.utils.toHex(parseInt(match[1], 10) * this.getMutliplicator(match[2])); + return this.web3.utils.toHex(this.web3.utils.toWei(match[1], match[2])); } initWeb3Provider() { From 3d70028cc5713d24a2374eb33c87f84aa138375c Mon Sep 17 00:00:00 2001 From: Jonathan Rainville Date: Thu, 7 Jun 2018 10:33:05 -0400 Subject: [PATCH 09/32] fixing small stuff --- lib/core/plugin.js | 1 - lib/modules/solidity/solcP.js | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/core/plugin.js b/lib/core/plugin.js index b0197522..296f52b5 100644 --- a/lib/core/plugin.js +++ b/lib/core/plugin.js @@ -60,7 +60,6 @@ Plugin.prototype.hasContext = function(context) { Plugin.prototype.loadPlugin = function() { if (!this.isContextValid()) { - console.log(this.acceptedContext); this.logger.warn(__('Plugin {{name}} can only be loaded in the context of "{{contextes}}"', {name: this.name, contextes: this.acceptedContext.join(', ')})); return false; } diff --git a/lib/modules/solidity/solcP.js b/lib/modules/solidity/solcP.js index 2d538324..43f9c024 100644 --- a/lib/modules/solidity/solcP.js +++ b/lib/modules/solidity/solcP.js @@ -19,7 +19,7 @@ class SolcProcess extends ProcessWrapper { return {contents: fs.readFileSync(path.join('./node_modules/', filename)).toString()}; } if (fs.existsSync(path.join(constants.httpContractsDirectory, filename))) { - return {contents: fs.readFileSync(path.join('./.embark/contracts', filename)).toString()}; + return {contents: fs.readFileSync(path.join(constants.httpContractsDirectory, filename)).toString()}; } return {error: 'File not found'}; } From bb3e87d85e1e0f15224ca0a91f39f2fb9152d16a Mon Sep 17 00:00:00 2001 From: Jonathan Rainville Date: Thu, 7 Jun 2018 10:53:20 -0400 Subject: [PATCH 10/32] move getBalance in accountParser --- lib/contracts/accountParser.js | 25 ++++++++++++++++++++++--- lib/tests/test.js | 20 ++------------------ 2 files changed, 24 insertions(+), 21 deletions(-) diff --git a/lib/contracts/accountParser.js b/lib/contracts/accountParser.js index e2460bd6..da2ded9c 100644 --- a/lib/contracts/accountParser.js +++ b/lib/contracts/accountParser.js @@ -21,10 +21,29 @@ class AccountParser { return accounts; } + static getHexBalance(balanceString, web3) { + if (!balanceString) { + return 0xFFFFFFFFFFFFFFFFFF; + } + if (web3.utils.isHexStrict(balanceString)) { + return balanceString; + } + const match = balanceString.match(/([0-9]+) ?([a-zA-Z]*)/); + if (!match[2]) { + return web3.utils.toHex(parseInt(match[1], 10)); + } + + return web3.utils.toHex(web3.utils.toWei(match[1], match[2])); + } + static getAccount(accountConfig, web3, logger) { if (!logger) { logger = console; } + let hexBalance = null; + if (accountConfig.balance) { + hexBalance = AccountParser.getHexBalance(accountConfig.balance, web3); + } if (accountConfig.privateKey) { if (!accountConfig.privateKey.startsWith('0x')) { accountConfig.privateKey = '0x' + accountConfig.privateKey; @@ -33,7 +52,7 @@ class AccountParser { logger.warn(`Private key ending with ${accountConfig.privateKey.substr(accountConfig.privateKey.length - 5)} is not a HEX string`); return null; } - return web3.eth.accounts.privateKeyToAccount(accountConfig.privateKey); + return Object.assign(web3.eth.accounts.privateKeyToAccount(accountConfig.privateKey), {hexBalance}); } if (accountConfig.privateKeyFile) { let fileContent = fs.readFileSync(fs.dappPath(accountConfig.privateKeyFile)).toString(); @@ -46,7 +65,7 @@ class AccountParser { logger.warn(`Private key is not a HEX string in file ${accountConfig.privateKeyFile} at index ${index}`); return null; } - return web3.eth.accounts.privateKeyToAccount(key); + return Object.assign(web3.eth.accounts.privateKeyToAccount(key), {hexBalance}); }); } if (accountConfig.mnemonic) { @@ -59,7 +78,7 @@ class AccountParser { const accounts = []; for (let i = addressIndex; i < addressIndex + numAddresses; i++) { const wallet = hdwallet.derivePath(wallet_hdpath + i).getWallet(); - accounts.push(web3.eth.accounts.privateKeyToAccount('0x' + wallet.getPrivateKey().toString('hex'))); + accounts.push(Object.assign(web3.eth.accounts.privateKeyToAccount('0x' + wallet.getPrivateKey().toString('hex')), {hexBalance})); } return accounts; } diff --git a/lib/tests/test.js b/lib/tests/test.js index fd9e16a6..86e52ca0 100644 --- a/lib/tests/test.js +++ b/lib/tests/test.js @@ -61,29 +61,13 @@ class Test { this.engine.startService("codeGenerator"); } - getBalance(balanceString) { - if (!balanceString) { - return 0xFFFFFFFFFFFFFFFFFF; - } - if (this.web3.utils.isHexStrict(balanceString)) { - return balanceString; - } - const match = balanceString.match(/([0-9]+) ?([a-zA-Z]*)/); - if (!match[2]) { - return this.web3.utils.toHex(parseInt(match[1], 10)); - } - - return this.web3.utils.toHex(this.web3.utils.toWei(match[1], match[2])); - } - initWeb3Provider() { if (this.simOptions.node) { this.web3.setProvider(new this.web3.providers.HttpProvider(this.simOptions.node)); } else { if (this.simOptions.accounts) { - this.simOptions.accounts = this.simOptions.accounts.map((account, index) => { - const balance = this.getBalance(this.options.deployment.accounts[index].balance); - return {balance, secretKey: account.privateKey}; + this.simOptions.accounts = this.simOptions.accounts.map((account) => { + return {balance: account.hexBalance, secretKey: account.privateKey}; }); } this.sim = getSimulator(); From a5ecd9f1f4619c57478a203590fa37c42a3b6999 Mon Sep 17 00:00:00 2001 From: Jonathan Rainville Date: Thu, 7 Jun 2018 11:30:33 -0400 Subject: [PATCH 11/32] add tests for getBalance --- lib/contracts/accountParser.js | 3 ++ test/accountParser.js | 55 ++++++++++++++++++++++++++++++---- 2 files changed, 52 insertions(+), 6 deletions(-) diff --git a/lib/contracts/accountParser.js b/lib/contracts/accountParser.js index da2ded9c..f407cf54 100644 --- a/lib/contracts/accountParser.js +++ b/lib/contracts/accountParser.js @@ -29,6 +29,9 @@ class AccountParser { return balanceString; } const match = balanceString.match(/([0-9]+) ?([a-zA-Z]*)/); + if (!match) { + throw new Error(__('Unrecognized balance string "%s"', balanceString)); + } if (!match[2]) { return web3.utils.toHex(parseInt(match[1], 10)); } diff --git a/test/accountParser.js b/test/accountParser.js index d79b002f..28801384 100644 --- a/test/accountParser.js +++ b/test/accountParser.js @@ -3,6 +3,9 @@ const assert = require('assert'); const sinon = require('sinon'); const AccountParser = require('../lib/contracts/accountParser'); let TestLogger = require('../lib/tests/test_logger.js'); +const Web3 = require('web3'); +const i18n = require('../lib/i18n/i18n.js'); +i18n.setOrDetectLocale('en'); describe('embark.AccountParser', function () { describe('#getAccount', function () { @@ -25,7 +28,7 @@ describe('embark.AccountParser', function () { privateKey: 'myKey' }, web3, testLogger); - assert.deepEqual(account, {key: '0xmyKey'}); + assert.deepEqual(account, {key: '0xmyKey', hexBalance: null}); }); it('should return two accounts from the keys in the file', function () { @@ -34,8 +37,8 @@ describe('embark.AccountParser', function () { }, web3, testLogger); assert.deepEqual(account, [ - {key: '0xkey1'}, - {key: '0xkey2'} + {key: '0xkey1', hexBalance: null}, + {key: '0xkey2', hexBalance: null} ]); }); @@ -45,7 +48,7 @@ describe('embark.AccountParser', function () { }, web3, testLogger); assert.deepEqual(account, - [{key: "0xf942d5d524ec07158df4354402bfba8d928c99d0ab34d0799a6158d56156d986"}]); + [{key: "0xf942d5d524ec07158df4354402bfba8d928c99d0ab34d0799a6158d56156d986", hexBalance: null}]); }); it('should return two accounts from the mnemonic using numAddresses', function () { @@ -56,8 +59,8 @@ describe('embark.AccountParser', function () { assert.deepEqual(account, [ - {key: "0xf942d5d524ec07158df4354402bfba8d928c99d0ab34d0799a6158d56156d986"}, - {key: "0x88f37cfbaed8c0c515c62a17a3a1ce2f397d08bbf20dcc788b69f11b5a5c9791"} + {key: "0xf942d5d524ec07158df4354402bfba8d928c99d0ab34d0799a6158d56156d986", hexBalance: null}, + {key: "0x88f37cfbaed8c0c515c62a17a3a1ce2f397d08bbf20dcc788b69f11b5a5c9791", hexBalance: null} ]); }); @@ -68,6 +71,46 @@ describe('embark.AccountParser', function () { assert.strictEqual(account, null); }); + }); + describe('getHexBalance', () => { + it('should return default if no balance', () => { + const hexBalance = AccountParser.getHexBalance(null, Web3); + + assert.strictEqual(hexBalance, 0xFFFFFFFFFFFFFFFFFF); + }); + + it('should return the balance string if already hexadecimal', () => { + const hexBalance = AccountParser.getHexBalance('0xFFF', Web3); + + assert.strictEqual(hexBalance, '0xFFF'); + }); + + it('should convert to hex when decimal', () => { + const hexBalance = AccountParser.getHexBalance('500', Web3); + + assert.strictEqual(hexBalance, '0x1f4'); + }); + + it('should convert to hex with eth string', () => { + const hexBalance = AccountParser.getHexBalance('4ether', Web3); + + assert.strictEqual(hexBalance, '0x3782dace9d900000'); + }); + + it('should convert to hex with eth string with space', () => { + const hexBalance = AccountParser.getHexBalance('673 shannon', Web3); + + assert.strictEqual(hexBalance, '0x9cb1ed0a00'); + }); + + it('should fail when string is not good', () => { + try { + AccountParser.getHexBalance('nogood', Web3); + assert.fail('Should have failed at getHexBalance'); + } catch (e) { + // Ok + } + }); }); }); From 9c9bb761a4b766acb606b1b7250208838bcfade3 Mon Sep 17 00:00:00 2001 From: Jonathan Rainville Date: Thu, 7 Jun 2018 11:38:18 -0400 Subject: [PATCH 12/32] add error when using deployAll --- lib/tests/run_tests.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/tests/run_tests.js b/lib/tests/run_tests.js index 17872ff8..505d8e2c 100644 --- a/lib/tests/run_tests.js +++ b/lib/tests/run_tests.js @@ -37,6 +37,12 @@ module.exports = { global.assert = assert; global.config = test.config.bind(test); + global.deployAll = function () { + console.error(__('%s is not supported anymore', 'deployAll').red); + console.info(__('You can learn about the new revamped tests here: %s', 'https://embark.status.im/docs/testing.html'.underline)); + process.exit(); + }; + // TODO: this global here might not be necessary at all global.web3 = global.embark.web3; From 1b89199f5024366eaa56d46f197eaa8c2e6bc7f3 Mon Sep 17 00:00:00 2001 From: Jonathan Rainville Date: Thu, 7 Jun 2018 13:06:09 -0400 Subject: [PATCH 13/32] fund accounts in wallet using contracts config --- lib/contracts/fundAccount.js | 12 ++++++++---- lib/contracts/provider.js | 2 +- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/lib/contracts/fundAccount.js b/lib/contracts/fundAccount.js index cb9baade..35470b54 100644 --- a/lib/contracts/fundAccount.js +++ b/lib/contracts/fundAccount.js @@ -1,8 +1,12 @@ const async = require('async'); -const TARGET = 15000000000000000000; +const TARGET = 0x7FFFFFFFFFFFFFFF; const ALREADY_FUNDED = 'alreadyFunded'; -function fundAccount(web3, accountAddress, callback) { +function fundAccount(web3, accountAddress, hexBalance, callback) { + if (!hexBalance) { + hexBalance = TARGET; + } + const targetBalance = (typeof hexBalance === 'string') ? parseInt(hexBalance, 16) : hexBalance; let accountBalance; let coinbaseAddress; let lastNonce; @@ -14,7 +18,7 @@ function fundAccount(web3, accountAddress, callback) { if (err) { return next(err); } - if (balance >= TARGET) { + if (balance >= targetBalance) { return next(ALREADY_FUNDED); } accountBalance = balance; @@ -56,7 +60,7 @@ function fundAccount(web3, accountAddress, callback) { web3.eth.sendTransaction({ from: coinbaseAddress, to: accountAddress, - value: TARGET - accountBalance, + value: targetBalance - accountBalance, gasPrice: gasPrice, nonce: lastNonce }, next); diff --git a/lib/contracts/provider.js b/lib/contracts/provider.js index f9337962..0e60ee86 100644 --- a/lib/contracts/provider.js +++ b/lib/contracts/provider.js @@ -65,7 +65,7 @@ class Provider { return callback(); } async.each(self.accounts, (account, eachCb) => { - fundAccount(self.web3, account.address, eachCb); + fundAccount(self.web3, account.address, account.hexBalance, eachCb); }, callback); } From a6a5bac053f24ec27efdee020b0a95fad3eb1f5e Mon Sep 17 00:00:00 2001 From: Jonathan Rainville Date: Thu, 7 Jun 2018 16:07:58 -0400 Subject: [PATCH 14/32] use new provider when using account with a node specified --- lib/contracts/blockchain.js | 2 +- lib/tests/test.js | 170 +++++++++++++++++++++++------------- 2 files changed, 110 insertions(+), 62 deletions(-) diff --git a/lib/contracts/blockchain.js b/lib/contracts/blockchain.js index e2403c0c..1fbf4dde 100644 --- a/lib/contracts/blockchain.js +++ b/lib/contracts/blockchain.js @@ -83,7 +83,7 @@ class Blockchain { } ], cb); } else { - throw new Error("contracts config error: unknown deployment type " + this.contractsConfig.deployment.type); + throw new Error(__("contracts config error: unknown deployment type %s", this.contractsConfig.deployment.type)); } } diff --git a/lib/tests/test.js b/lib/tests/test.js index 86e52ca0..332e4edc 100644 --- a/lib/tests/test.js +++ b/lib/tests/test.js @@ -2,11 +2,11 @@ const async = require('async'); const Engine = require('../core/engine.js'); const TestLogger = require('./test_logger.js'); const Web3 = require('web3'); -const utils = require('../utils/utils'); const constants = require('../constants'); const Events = require('../core/events'); const cloneDeep = require('clone-deep'); const AccountParser = require('../contracts/accountParser'); +const Provider = require('../contracts/provider'); function getSimulator() { try { @@ -29,7 +29,7 @@ function getSimulator() { class Test { constructor(options) { this.options = options || {}; - this.simOptions = this.options.simulatorOptions || {}; + this.simOptions = {}; this.contracts = {}; this.events = new Events(); this.ready = true; @@ -37,42 +37,29 @@ class Test { this.compiledContracts = {}; this.web3 = new Web3(); - this.initWeb3Provider(); - - this.engine = new Engine({ - env: this.options.env || 'test', - // TODO: config will need to detect if this is a obj - embarkConfig: this.options.embarkConfig || 'embark.json', - interceptLogs: false - }); - - this.engine.init({ - logger: new TestLogger({logLevel: 'debug'}) - }); - - this.versions_default = this.engine.config.contractsConfig.versions; - const deploymentConfig = this.engine.config.contractsConfig.versions; - // Reset contract config to nothing to make sure we deploy only what we want - this.engine.config.contractsConfig = {contracts: {}, versions: this.versions_default, deployment: deploymentConfig}; - - this.engine.startService("libraryManager"); - this.engine.startService("codeRunner"); - this.initDeployServices(); - this.engine.startService("codeGenerator"); } - initWeb3Provider() { - if (this.simOptions.node) { - this.web3.setProvider(new this.web3.providers.HttpProvider(this.simOptions.node)); - } else { - if (this.simOptions.accounts) { - this.simOptions.accounts = this.simOptions.accounts.map((account) => { - return {balance: account.hexBalance, secretKey: account.privateKey}; - }); - } - this.sim = getSimulator(); - this.web3.setProvider(this.sim.provider(this.simOptions)); + initWeb3Provider(callback) { + if (this.simOptions.host) { + const providerOptions = { + web3: this.web3, + accountsConfig: this.simOptions.accounts, + logger: this.engine.logger, + isDev: false, + web3Endpoint: 'http://' + this.simOptions.host + ':' + this.simOptions.port + }; + this.provider = new Provider(providerOptions); + return this.provider.startWeb3Provider(callback); } + + if (this.simOptions.accounts) { + this.simOptions.accounts = this.simOptions.accounts.map((account) => { + return {balance: account.hexBalance, secretKey: account.privateKey}; + }); + } + this.sim = getSimulator(); + this.web3.setProvider(this.sim.provider(this.simOptions)); + callback(); } initDeployServices() { @@ -87,10 +74,41 @@ class Test { init(callback) { const self = this; - this.engine.contractsManager.build(() => { - self.builtContracts = cloneDeep(self.engine.contractsManager.contracts); - self.compiledContracts = cloneDeep(self.engine.contractsManager.compiledContracts); - callback(); + + this.initWeb3Provider((err) => { + if (err) { + return callback(err); + } + this.engine = new Engine({ + env: this.options.env || 'test', + // TODO: config will need to detect if this is a obj + embarkConfig: this.options.embarkConfig || 'embark.json', + interceptLogs: false + }); + + this.engine.init({ + logger: new TestLogger({logLevel: 'debug'}) + }); + + this.versions_default = this.engine.config.contractsConfig.versions; + const deploymentConfig = this.engine.config.contractsConfig.versions; + // Reset contract config to nothing to make sure we deploy only what we want + this.engine.config.contractsConfig = { + contracts: {}, + versions: this.versions_default, + deployment: deploymentConfig + }; + + this.engine.startService("libraryManager"); + this.engine.startService("codeRunner"); + this.initDeployServices(); + this.engine.startService("codeGenerator"); + + this.engine.contractsManager.build(() => { + self.builtContracts = cloneDeep(self.engine.contractsManager.contracts); + self.compiledContracts = cloneDeep(self.engine.contractsManager.compiledContracts); + callback(); + }); }); } @@ -104,6 +122,7 @@ class Test { } config(options, callback) { + const self = this; if (!callback) { callback = function () { }; @@ -111,30 +130,59 @@ class Test { if (!options.contracts) { throw new Error(__('No contracts specified in the options')); } - this.options = utils.recursiveMerge(this.options, options); - this.simOptions = this.options.simulatorOptions || {}; - this.ready = false; + self.ready = false; - if (this.options.deployment && this.options.deployment.accounts) { - // Account setup - this.simOptions.accounts = AccountParser.parseAccountsConfig(this.options.deployment.accounts, this.web3); - this.initWeb3Provider(); - this.initDeployServices(); - } - - // Reset contracts - this.engine.contractsManager.contracts = cloneDeep(this.builtContracts); - this.engine.contractsManager.compiledContracts = cloneDeep(this.compiledContracts); - - this._deploy(options, (err, accounts) => { - this.ready = true; - this.events.emit('ready'); - if (err) { - console.error(err.red); - return callback(err); + async.waterfall([ + function checkDeploymentOptions(next) { + if (!options.deployment) { + if (!self.simOptions.host && !self.simOptions.accounts) { + return next(); + } + self.simOptions = {}; + } else { + self.simOptions = {}; + let resetServices = false; + if (options.deployment.accounts) { + // Account setup + self.simOptions.accounts = AccountParser.parseAccountsConfig(options.deployment.accounts, self.web3); + resetServices = true; + } + if (options.deployment.host && options.deployment.port && options.deployment.type) { + if (options.deployment.type !== 'rpc') { + throw new Error(__("contracts config error: unknown deployment type %s", options.deployment.type)); + } + Object.assign(self.simOptions, {host: options.deployment.host, port: options.deployment.port}); + resetServices = true; + } + if (!resetServices) { + return next(); + } + } + self.initWeb3Provider((err) => { + if (err) { + return next(err); + } + self.initDeployServices(); + next(); + }); + }, + function resetContracts(next) { + self.engine.contractsManager.contracts = cloneDeep(self.builtContracts); + self.engine.contractsManager.compiledContracts = cloneDeep(self.compiledContracts); + next(); + }, + function deploy(next) { + self._deploy(options, (err, accounts) => { + self.ready = true; + self.events.emit('ready'); + if (err) { + console.error(err.red); + return next(err); + } + next(null, accounts); + }); } - callback(null, accounts); - }); + ], callback); } _deploy(config, callback) { From cbe456bf1ea89f2c4c95c359af23456a4e126414 Mon Sep 17 00:00:00 2001 From: Jonathan Rainville Date: Thu, 7 Jun 2018 16:09:54 -0400 Subject: [PATCH 15/32] remove useless config --- lib/tests/test.js | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/lib/tests/test.js b/lib/tests/test.js index 332e4edc..b89739d8 100644 --- a/lib/tests/test.js +++ b/lib/tests/test.js @@ -91,12 +91,10 @@ class Test { }); this.versions_default = this.engine.config.contractsConfig.versions; - const deploymentConfig = this.engine.config.contractsConfig.versions; // Reset contract config to nothing to make sure we deploy only what we want this.engine.config.contractsConfig = { contracts: {}, - versions: this.versions_default, - deployment: deploymentConfig + versions: this.versions_default }; this.engine.startService("libraryManager"); From e902c86ed2a5fb594d49d6c855e85f606bd22614 Mon Sep 17 00:00:00 2001 From: Jonathan Rainville Date: Thu, 7 Jun 2018 16:14:42 -0400 Subject: [PATCH 16/32] conflicts in tests --- lib/tests/run_tests.js | 10 ++ package-lock.json | 157 ++++++++++++++++-- .../test/another_storage_spec.js | 6 +- .../test/array_references_spec.js | 8 +- test_apps/contracts_app/test/lib_test_spec.js | 4 +- .../contracts_app/test/simple_storage_spec.js | 4 +- test_apps/contracts_app/test/token_spec.js | 12 +- .../test_app/test/another_storage_spec.js | 6 +- .../test_app/test/array_references_spec.js | 8 +- test_apps/test_app/test/lib_test_spec.js | 4 +- .../test_app/test/plugin_storage_spec.js | 6 +- .../test_app/test/simple_storage_spec.js | 4 +- test_apps/test_app/test/token_spec.js | 12 +- 13 files changed, 192 insertions(+), 49 deletions(-) diff --git a/lib/tests/run_tests.js b/lib/tests/run_tests.js index 505d8e2c..2496c472 100644 --- a/lib/tests/run_tests.js +++ b/lib/tests/run_tests.js @@ -43,6 +43,16 @@ module.exports = { process.exit(); }; + // Override require to enable `require('Embark/contracts/contractName');` + const Module = require('module'); + const originalRequire = require('module').prototype.require; + Module.prototype.require = function(requireName) { + if (requireName.startsWith('Embark')) { + return test.require(...arguments); + } + return originalRequire.apply(this, arguments); + }; + // TODO: this global here might not be necessary at all global.web3 = global.embark.web3; diff --git a/package-lock.json b/package-lock.json index 21d95370..7661c123 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1832,7 +1832,7 @@ "browserify-zlib": { "version": "0.2.0", "resolved": "https://registry.npmjs.org/browserify-zlib/-/browserify-zlib-0.2.0.tgz", - "integrity": "sha1-KGlFnZqjviRf6P4sofRuLn9U1z8=", + "integrity": "sha512-Z942RysHXmJrhqk88FmKBVq/v5tqmSkDz7p54G/MGyjMnCFFnC79XWNbg+Vta8W6Wb2qtSZTSxIGkJrRpCFEiA==", "requires": { "pako": "1.0.6" } @@ -3194,7 +3194,7 @@ "domain-browser": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/domain-browser/-/domain-browser-1.2.0.tgz", - "integrity": "sha1-PTH1AZGmdJ3RN1p/Ui6CPULlTto=" + "integrity": "sha512-jnjyiM6eRyZl2H+W8Q/zLMA481hzi0eszAaBUzIVnmYVDBbnLxVNnfu1HgEBvCbL+71FrxMl3E6lpKH7Ge3OXA==" }, "drbg.js": { "version": "1.0.1", @@ -3219,6 +3219,11 @@ "typechecker": "2.1.0" } }, + "easy-stack": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/easy-stack/-/easy-stack-1.0.0.tgz", + "integrity": "sha1-EskbMIWjfwuqM26UhurEv5Tj54g=" + }, "ecc-jsbn": { "version": "0.1.1", "resolved": "https://registry.npmjs.org/ecc-jsbn/-/ecc-jsbn-0.1.1.tgz", @@ -3312,7 +3317,7 @@ "errno": { "version": "0.1.7", "resolved": "https://registry.npmjs.org/errno/-/errno-0.1.7.tgz", - "integrity": "sha1-RoTXF3mtOa8Xfj8AeZb3xnyFJhg=", + "integrity": "sha512-MfrRBDWzIWifgq6tJj60gkAwtLNb6sQPlcFrSOflcP1aFmmruKQ2wRnze/8V6kgyz7H3FF8Npzv78mZ7XLLflg==", "requires": { "prr": "1.0.1" } @@ -4102,6 +4107,11 @@ "es5-ext": "0.10.42" } }, + "event-pubsub": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/event-pubsub/-/event-pubsub-4.3.0.tgz", + "integrity": "sha512-z7IyloorXvKbFx9Bpie2+vMJKKx1fH1EN5yiTfp8CiLOTptSYy1g8H4yDpGlEdshL1PBiFtBHepF2cNsqeEeFQ==" + }, "eventemitter2": { "version": "0.4.14", "resolved": "https://registry.npmjs.org/eventemitter2/-/eventemitter2-0.4.14.tgz", @@ -6500,6 +6510,19 @@ "resolved": "https://registry.npmjs.org/js-base64/-/js-base64-2.4.3.tgz", "integrity": "sha512-H7ErYLM34CvDMto3GbD6xD0JLUGYXR3QTcH6B/tr4Hi/QpSThnCsIp+Sy5FRTw3B0d6py4HcNkW7nO/wdtGWEw==" }, + "js-message": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/js-message/-/js-message-1.0.5.tgz", + "integrity": "sha1-IwDSSxrwjondCVvBpMnJz8uJLRU=" + }, + "js-queue": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/js-queue/-/js-queue-2.0.0.tgz", + "integrity": "sha1-NiITz4YPRo8BJfxslqvBdCUx+Ug=", + "requires": { + "easy-stack": "1.0.0" + } + }, "js-sha3": { "version": "0.7.0", "resolved": "https://registry.npmjs.org/js-sha3/-/js-sha3-0.7.0.tgz", @@ -6577,7 +6600,7 @@ "json-loader": { "version": "0.5.7", "resolved": "https://registry.npmjs.org/json-loader/-/json-loader-0.5.7.tgz", - "integrity": "sha1-3KFKcCNf+C8KyaOr62DTN6NlGF0=" + "integrity": "sha512-QLPs8Dj7lnf3e3QYS1zkCo+4ZwqOiF9d/nZnYozTISxXWCfNs9yuky5rJw4/W34s7POaNlbZmQGaB5NiXCbP4w==" }, "json-parse-better-errors": { "version": "1.0.1", @@ -8332,10 +8355,20 @@ "resolved": "https://registry.npmjs.org/node-forge/-/node-forge-0.7.4.tgz", "integrity": "sha512-8Df0906+tq/omxuCZD6PqhPaQDYuyJ1d+VITgxoIA8zvQd1ru+nMJcDChHH324MWitIgbVkAkQoGEEVJNpn/PA==" }, + "node-ipc": { + "version": "9.1.1", + "resolved": "https://registry.npmjs.org/node-ipc/-/node-ipc-9.1.1.tgz", + "integrity": "sha512-FAyICv0sIRJxVp3GW5fzgaf9jwwRQxAKDJlmNFUL5hOy+W4X/I5AypyHoq0DXXbo9o/gt79gj++4cMr4jVWE/w==", + "requires": { + "event-pubsub": "4.3.0", + "js-message": "1.0.5", + "js-queue": "2.0.0" + } + }, "node-libs-browser": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/node-libs-browser/-/node-libs-browser-2.1.0.tgz", - "integrity": "sha1-X5QmPUBPbkR2fXJpAf/wVHjWAN8=", + "integrity": "sha512-5AzFzdoIMb89hBGMZglEegffzgRg+ZFoUmisQ8HI4j1KDdpx13J0taNp2y9xPbur6W61gepGDDotGBVQ7mfUCg==", "requires": { "assert": "1.4.1", "browserify-zlib": "0.2.0", @@ -8799,7 +8832,7 @@ "os-locale": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/os-locale/-/os-locale-2.1.0.tgz", - "integrity": "sha1-QrwpAKa1uL0XN2yOiCtlr8zyS/I=", + "integrity": "sha512-3sslG3zJbEYcaC4YVAvDorjGxc7tv6KVATnLPZONiljsUncvihe9BQoVCEs0RZ1kmf4Hk9OBqlZfJZWI4GanKA==", "requires": { "execa": "0.7.0", "lcid": "1.0.0", @@ -8896,7 +8929,7 @@ "pako": { "version": "1.0.6", "resolved": "https://registry.npmjs.org/pako/-/pako-1.0.6.tgz", - "integrity": "sha1-AQEhG6pwxLykoPY/Igbpe3368lg=" + "integrity": "sha512-lQe48YPsMJAig+yngZ87Lus+NF+3mtu7DVOBu6b/gHO1YpKwIj5AWjZ/TOS7i46HD/UixzWb1zeWDZfGZ3iYcg==" }, "parse-asn1": { "version": "5.1.0", @@ -12792,7 +12825,7 @@ "webpack": { "version": "3.11.0", "resolved": "https://registry.npmjs.org/webpack/-/webpack-3.11.0.tgz", - "integrity": "sha512-3kOFejWqj5ISpJk4Qj/V7w98h9Vl52wak3CLiw/cDOfbVTq7FeoZ0SdoHHY9PYlHr50ZS42OfvzE2vB4nncKQg==", + "integrity": "sha1-d9pFGx17SxF62vQaGpO1dC8k2JQ=", "requires": { "acorn": "5.5.3", "acorn-dynamic-import": "2.0.2", @@ -13020,8 +13053,10 @@ "p-each-series": "1.0.0", "p-lazy": "1.0.0", "prettier": "1.13.4", + "supports-color": "5.4.0", "v8-compile-cache": "2.0.0", "webpack-addons": "1.1.5", + "yargs": "11.1.0", "yeoman-environment": "2.2.0", "yeoman-generator": "2.0.5" }, @@ -13050,7 +13085,8 @@ "integrity": "sha512-ObN6h1v2fTJSmUXoS3nMQ92LbDK9be4TV+6G+omQlGJFdcUX5heKi1LZ1YnRMIgwTLEj3E24bT6tYni50rlCfQ==", "requires": { "ansi-styles": "3.2.1", - "escape-string-regexp": "1.0.5" + "escape-string-regexp": "1.0.5", + "supports-color": "5.4.0" } }, "cliui": { @@ -13059,6 +13095,7 @@ "integrity": "sha512-4FG+RSG9DL7uEwRUZXZn3SS34DiDPfzP0VOiEwtUWlE+AR2EIg+hSyvrIgUUfhdgR/UkAeW2QHgeP+hWrXs7jQ==", "requires": { "string-width": "2.1.1", + "strip-ansi": "4.0.0", "wrap-ansi": "2.1.0" } }, @@ -13085,7 +13122,8 @@ "integrity": "sha512-jox/62b2GofV1qTUQTMPEJSDIGycS43evqYzD/KVtEb9OCoki9cnacUPxCrZa7JfPzZSYOCZhu9O9luaMxAX8g==", "requires": { "graceful-fs": "4.1.11", - "memory-fs": "0.4.1" + "memory-fs": "0.4.1", + "tapable": "1.0.0" } }, "got": { @@ -13108,6 +13146,7 @@ "pify": "3.0.0", "safe-buffer": "5.1.1", "timed-out": "4.0.1", + "url-parse-lax": "3.0.0", "url-to-options": "1.0.1" } }, @@ -13132,6 +13171,7 @@ "run-async": "2.3.0", "rxjs": "5.5.11", "string-width": "2.1.1", + "strip-ansi": "4.0.0", "through": "2.3.8" } }, @@ -13153,10 +13193,44 @@ "p-finally": "1.0.0" } }, + "prepend-http": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/prepend-http/-/prepend-http-2.0.0.tgz", + "integrity": "sha1-6SQ0v6XqjBn0HN/UAddBo8gZ2Jc=" + }, + "strip-ansi": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-4.0.0.tgz", + "integrity": "sha1-qEeQIusaw2iocTibY1JixQXuNo8=", + "requires": { + "ansi-regex": "3.0.0" + } + }, + "supports-color": { + "version": "5.4.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.4.0.tgz", + "integrity": "sha512-zjaXglF5nnWpsq470jSv6P9DwPvgLkuapYmfDm3JWOm0vkNTVF2tI4UrN2r6jH1qM/uc/WtxYY1hYoA2dOKj5w==", + "requires": { + "has-flag": "3.0.0" + } + }, + "tapable": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/tapable/-/tapable-1.0.0.tgz", + "integrity": "sha512-dQRhbNQkRnaqauC7WqSJ21EEksgT0fYZX2lqXzGkpo8JNig9zGZTYoMGvyI2nWmXlE2VSVXVDu7wLVGu/mQEsg==" + }, "underscore": { "version": "1.8.3", "resolved": "https://registry.npmjs.org/underscore/-/underscore-1.8.3.tgz", "integrity": "sha1-Tz+1OxBuYJf8+ctBCfKl6b36UCI=" + }, + "url-parse-lax": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/url-parse-lax/-/url-parse-lax-3.0.0.tgz", + "integrity": "sha1-FrXK/Afb42dsGxmZF3gj1lA6yww=", + "requires": { + "prepend-http": "2.0.0" + } } } }, @@ -13187,7 +13261,7 @@ "webpack-sources": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/webpack-sources/-/webpack-sources-1.1.0.tgz", - "integrity": "sha1-oQHrrlnWUHNU1x2AE5UKOot6WlQ=", + "integrity": "sha512-aqYp18kPphgoO5c/+NaUvEeACtZjMESmDChuD3NBciVpah3XpMEU9VAAtIaB1BsfJWWTSdv8Vv1m3T0aRk2dUw==", "requires": { "source-list-map": "2.0.0", "source-map": "0.6.1" @@ -13196,7 +13270,7 @@ "source-map": { "version": "0.6.1", "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", - "integrity": "sha1-dHIq8y6WFOnCh6jQu95IteLxomM=" + "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==" } } }, @@ -13444,6 +13518,65 @@ "resolved": "https://registry.npmjs.org/yallist/-/yallist-2.1.2.tgz", "integrity": "sha1-HBH5IY8HYImkfdUS+TxmmaaoHVI=" }, + "yargs": { + "version": "11.1.0", + "resolved": "https://registry.npmjs.org/yargs/-/yargs-11.1.0.tgz", + "integrity": "sha512-NwW69J42EsCSanF8kyn5upxvjp5ds+t3+udGBeTbFnERA+lF541DDpMawzo4z6W/QrzNM18D+BPMiOBibnFV5A==", + "requires": { + "cliui": "4.1.0", + "decamelize": "1.2.0", + "find-up": "2.1.0", + "get-caller-file": "1.0.2", + "os-locale": "2.1.0", + "require-directory": "2.1.1", + "require-main-filename": "1.0.1", + "set-blocking": "2.0.0", + "string-width": "2.1.1", + "which-module": "2.0.0", + "y18n": "3.2.1", + "yargs-parser": "9.0.2" + }, + "dependencies": { + "ansi-regex": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-3.0.0.tgz", + "integrity": "sha1-7QMXwyIGT3lGbAKWa922Bas32Zg=" + }, + "cliui": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/cliui/-/cliui-4.1.0.tgz", + "integrity": "sha512-4FG+RSG9DL7uEwRUZXZn3SS34DiDPfzP0VOiEwtUWlE+AR2EIg+hSyvrIgUUfhdgR/UkAeW2QHgeP+hWrXs7jQ==", + "requires": { + "string-width": "2.1.1", + "strip-ansi": "4.0.0", + "wrap-ansi": "2.1.0" + } + }, + "strip-ansi": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-4.0.0.tgz", + "integrity": "sha1-qEeQIusaw2iocTibY1JixQXuNo8=", + "requires": { + "ansi-regex": "3.0.0" + } + } + } + }, + "yargs-parser": { + "version": "9.0.2", + "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-9.0.2.tgz", + "integrity": "sha1-nM9qQ0YP5O1Aqbto9I1DuKaMwHc=", + "requires": { + "camelcase": "4.1.0" + }, + "dependencies": { + "camelcase": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-4.1.0.tgz", + "integrity": "sha1-1UVjW+HjPFQmScaRc+Xeas+uNN0=" + } + } + }, "yauzl": { "version": "2.9.1", "resolved": "https://registry.npmjs.org/yauzl/-/yauzl-2.9.1.tgz", diff --git a/test_apps/contracts_app/test/another_storage_spec.js b/test_apps/contracts_app/test/another_storage_spec.js index 82ee75fb..e304e8a1 100644 --- a/test_apps/contracts_app/test/another_storage_spec.js +++ b/test_apps/contracts_app/test/another_storage_spec.js @@ -1,7 +1,7 @@ -/*global contract, config, it, embark*/ +/*global contract, config, it*/ const assert = require('assert'); -const AnotherStorage = embark.require('Embark/contracts/AnotherStorage'); -const SimpleStorage = embark.require('Embark/contracts/SimpleStorage'); +const AnotherStorage = require('Embark/contracts/AnotherStorage'); +const SimpleStorage = require('Embark/contracts/SimpleStorage'); config({ contracts: { diff --git a/test_apps/contracts_app/test/array_references_spec.js b/test_apps/contracts_app/test/array_references_spec.js index 4ca15ab4..ca11c3bb 100644 --- a/test_apps/contracts_app/test/array_references_spec.js +++ b/test_apps/contracts_app/test/array_references_spec.js @@ -1,8 +1,8 @@ -/*global contract, config, it, embark*/ +/*global contract, config, it*/ const assert = require('assert'); -const SomeContract = embark.require('Embark/contracts/SomeContract'); -const SimpleStorage = embark.require('Embark/contracts/SimpleStorage'); -const MyToken2 = embark.require('Embark/contracts/MyToken2'); +const SomeContract = require('Embark/contracts/SomeContract'); +const SimpleStorage = require('Embark/contracts/SimpleStorage'); +const MyToken2 = require('Embark/contracts/MyToken2'); config({ contracts: { diff --git a/test_apps/contracts_app/test/lib_test_spec.js b/test_apps/contracts_app/test/lib_test_spec.js index 7d158b69..fe2a2729 100644 --- a/test_apps/contracts_app/test/lib_test_spec.js +++ b/test_apps/contracts_app/test/lib_test_spec.js @@ -1,6 +1,6 @@ -/*global contract, config, it, embark*/ +/*global contract, config, it*/ const assert = require('assert'); -const Test2 = embark.require('Embark/contracts/Test2'); +const Test2 = require('Embark/contracts/Test2'); config({ contracts: { diff --git a/test_apps/contracts_app/test/simple_storage_spec.js b/test_apps/contracts_app/test/simple_storage_spec.js index 0eba871a..42b5cd2b 100644 --- a/test_apps/contracts_app/test/simple_storage_spec.js +++ b/test_apps/contracts_app/test/simple_storage_spec.js @@ -1,6 +1,6 @@ -/*global contract, config, it, embark*/ +/*global contract, config, it*/ const assert = require('assert'); -const SimpleStorage = embark.require('Embark/contracts/SimpleStorage'); +const SimpleStorage = require('Embark/contracts/SimpleStorage'); config({ contracts: { diff --git a/test_apps/contracts_app/test/token_spec.js b/test_apps/contracts_app/test/token_spec.js index 5390e665..a6e54210 100644 --- a/test_apps/contracts_app/test/token_spec.js +++ b/test_apps/contracts_app/test/token_spec.js @@ -1,10 +1,10 @@ -/*global describe, config, it, embark*/ +/*global describe, config, it*/ const assert = require('assert'); -const Token = embark.require('Embark/contracts/Token'); -const MyToken = embark.require('Embark/contracts/MyToken'); -const MyToken2 = embark.require('Embark/contracts/MyToken2'); -const AlreadyDeployedToken = embark.require('Embark/contracts/AlreadyDeployedToken'); -const Test = embark.require('Embark/contracts/Test'); +const Token = require('Embark/contracts/Token'); +const MyToken = require('Embark/contracts/MyToken'); +const MyToken2 = require('Embark/contracts/MyToken2'); +const AlreadyDeployedToken = require('Embark/contracts/AlreadyDeployedToken'); +const Test = require('Embark/contracts/Test'); config({ contracts: { diff --git a/test_apps/test_app/test/another_storage_spec.js b/test_apps/test_app/test/another_storage_spec.js index 10ee0b35..f0ea1b92 100644 --- a/test_apps/test_app/test/another_storage_spec.js +++ b/test_apps/test_app/test/another_storage_spec.js @@ -1,7 +1,7 @@ -/*global contract, config, it, embark, web3*/ +/*global contract, config, it, web3*/ const assert = require('assert'); -const AnotherStorage = embark.require('Embark/contracts/AnotherStorage'); -const SimpleStorage = embark.require('Embark/contracts/SimpleStorage'); +const AnotherStorage = require('Embark/contracts/AnotherStorage'); +const SimpleStorage = require('Embark/contracts/SimpleStorage'); let accounts; diff --git a/test_apps/test_app/test/array_references_spec.js b/test_apps/test_app/test/array_references_spec.js index 4ca15ab4..ca11c3bb 100644 --- a/test_apps/test_app/test/array_references_spec.js +++ b/test_apps/test_app/test/array_references_spec.js @@ -1,8 +1,8 @@ -/*global contract, config, it, embark*/ +/*global contract, config, it*/ const assert = require('assert'); -const SomeContract = embark.require('Embark/contracts/SomeContract'); -const SimpleStorage = embark.require('Embark/contracts/SimpleStorage'); -const MyToken2 = embark.require('Embark/contracts/MyToken2'); +const SomeContract = require('Embark/contracts/SomeContract'); +const SimpleStorage = require('Embark/contracts/SimpleStorage'); +const MyToken2 = require('Embark/contracts/MyToken2'); config({ contracts: { diff --git a/test_apps/test_app/test/lib_test_spec.js b/test_apps/test_app/test/lib_test_spec.js index 7d158b69..fe2a2729 100644 --- a/test_apps/test_app/test/lib_test_spec.js +++ b/test_apps/test_app/test/lib_test_spec.js @@ -1,6 +1,6 @@ -/*global contract, config, it, embark*/ +/*global contract, config, it*/ const assert = require('assert'); -const Test2 = embark.require('Embark/contracts/Test2'); +const Test2 = require('Embark/contracts/Test2'); config({ contracts: { diff --git a/test_apps/test_app/test/plugin_storage_spec.js b/test_apps/test_app/test/plugin_storage_spec.js index 90346c0e..623ec3cc 100644 --- a/test_apps/test_app/test/plugin_storage_spec.js +++ b/test_apps/test_app/test/plugin_storage_spec.js @@ -1,7 +1,7 @@ -/*global contract, config, it, embark*/ +/*global contract, config, it*/ const assert = require('assert'); -const PluginStorage = embark.require('Embark/contracts/PluginStorage'); -const SimpleStorage = embark.require('Embark/contracts/SimpleStorage'); +const PluginStorage = require('Embark/contracts/PluginStorage'); +const SimpleStorage = require('Embark/contracts/SimpleStorage'); config({ contracts: { diff --git a/test_apps/test_app/test/simple_storage_spec.js b/test_apps/test_app/test/simple_storage_spec.js index 7034bb63..2a503aa3 100644 --- a/test_apps/test_app/test/simple_storage_spec.js +++ b/test_apps/test_app/test/simple_storage_spec.js @@ -1,5 +1,5 @@ -/*global contract, config, it, embark, assert, web3*/ -const SimpleStorage = embark.require('Embark/contracts/SimpleStorage'); +/*global contract, config, it, assert, web3*/ +const SimpleStorage = require('Embark/contracts/SimpleStorage'); let accounts; config({ diff --git a/test_apps/test_app/test/token_spec.js b/test_apps/test_app/test/token_spec.js index 5390e665..a6e54210 100644 --- a/test_apps/test_app/test/token_spec.js +++ b/test_apps/test_app/test/token_spec.js @@ -1,10 +1,10 @@ -/*global describe, config, it, embark*/ +/*global describe, config, it*/ const assert = require('assert'); -const Token = embark.require('Embark/contracts/Token'); -const MyToken = embark.require('Embark/contracts/MyToken'); -const MyToken2 = embark.require('Embark/contracts/MyToken2'); -const AlreadyDeployedToken = embark.require('Embark/contracts/AlreadyDeployedToken'); -const Test = embark.require('Embark/contracts/Test'); +const Token = require('Embark/contracts/Token'); +const MyToken = require('Embark/contracts/MyToken'); +const MyToken2 = require('Embark/contracts/MyToken2'); +const AlreadyDeployedToken = require('Embark/contracts/AlreadyDeployedToken'); +const Test = require('Embark/contracts/Test'); config({ contracts: { From 8fa7357d07aff8b9b2cb7116a9243d443e89260b Mon Sep 17 00:00:00 2001 From: Iuri Matias Date: Thu, 7 Jun 2018 19:08:18 -0400 Subject: [PATCH 17/32] fix default from and data; add single test spec --- lib/tests/test.js | 12 +++++++ .../test/simple_storage_deploy_spec.js | 33 +++++++++++++++++++ 2 files changed, 45 insertions(+) create mode 100644 test_apps/test_app/test/simple_storage_deploy_spec.js diff --git a/lib/tests/test.js b/lib/tests/test.js index b89739d8..1e21442c 100644 --- a/lib/tests/test.js +++ b/lib/tests/test.js @@ -211,12 +211,20 @@ class Test { function createContractObject(accounts, next) { async.each(Object.keys(self.engine.contractsManager.contracts), (contractName, eachCb) => { const contract = self.engine.contractsManager.contracts[contractName]; + let data; if (!self.contracts[contractName]) { self.contracts[contractName] = {}; + data = ""; + } else { + data = self.contracts[contractName].options.data; } Object.assign(self.contracts[contractName], new self.web3.eth.Contract(contract.abiDefinition, contract.deployedAddress, {from: self.web3.eth.defaultAccount, gas: 6000000})); self.contracts[contractName].address = contract.deployedAddress; + if (self.contracts[contractName].options) { + self.contracts[contractName].options.from = self.contracts[contractName].options.from || web3.eth.defaultAccount; + self.contracts[contractName].options.data = data; + } eachCb(); }, (err) => { next(err, accounts); @@ -260,6 +268,10 @@ class Test { this.contracts[contractName] = new this.web3.eth.Contract(contract.abiDefinition, contract.address, {from: this.web3.eth.defaultAccount, gas: 6000000}); this.contracts[contractName].address = contract.address; + this.contracts[contractName].options.data = contract.code; + web3.eth.getAccounts().then((accounts) => { + this.contracts[contractName].options.from = contract.from || accounts[0]; + }); return this.contracts[contractName]; } throw new Error(__('Unknown module %s', module)); diff --git a/test_apps/test_app/test/simple_storage_deploy_spec.js b/test_apps/test_app/test/simple_storage_deploy_spec.js new file mode 100644 index 00000000..b44aa064 --- /dev/null +++ b/test_apps/test_app/test/simple_storage_deploy_spec.js @@ -0,0 +1,33 @@ +/*global contract, config, it, embark, assert, web3*/ +const SimpleStorage = embark.require('Embark/contracts/SimpleStorage'); +let accounts; + +config({ + contracts: { + "SimpleStorage": { + args: [100] + } + } +}, (err, theAccounts) => { + accounts = theAccounts; +}); + +contract("SimpleStorage Deploy", function () { + let SimpleStorageInstance; + + before(async function() { + SimpleStorageInstance = await SimpleStorage.deploy({data: SimpleStorage.options.data, arguments: [150]}).send(); + }); + + it("should set constructor value", async function () { + let result = await SimpleStorageInstance.methods.storedData().call(); + assert.strictEqual(parseInt(result, 10), 150); + }); + + it("set storage value", async function () { + await SimpleStorageInstance.methods.set(150).send(); + let result = await SimpleStorageInstance.methods.get().call(); + assert.strictEqual(parseInt(result, 10), 499650); + }); + +}); From c1590d0b4880ecb977e816944c84049a55caca2c Mon Sep 17 00:00:00 2001 From: Iuri Matias Date: Thu, 7 Jun 2018 19:57:56 -0400 Subject: [PATCH 18/32] change deploy to beforeAll, so it takes priority over the test before --- lib/tests/run_tests.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/tests/run_tests.js b/lib/tests/run_tests.js index 2496c472..baaedd0b 100644 --- a/lib/tests/run_tests.js +++ b/lib/tests/run_tests.js @@ -81,7 +81,9 @@ module.exports = { mocha.addFile(file); mocha.suite.timeout(0); - mocha.suite.beforeEach('Wait for deploy', (done) => { + + mocha.suite.beforeAll('Wait for deploy', (done) => { + console.dir("runnning wait for deploy"); global.embark.onReady(() => { done(); }); From 1c6df9db8d7e8618202c7787ff96885a2c8cfd39 Mon Sep 17 00:00:00 2001 From: Iuri Matias Date: Thu, 7 Jun 2018 20:05:56 -0400 Subject: [PATCH 19/32] remove data parameter --- lib/tests/run_tests.js | 1 - test_apps/test_app/test/simple_storage_deploy_spec.js | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/tests/run_tests.js b/lib/tests/run_tests.js index baaedd0b..eb31209a 100644 --- a/lib/tests/run_tests.js +++ b/lib/tests/run_tests.js @@ -83,7 +83,6 @@ module.exports = { mocha.suite.timeout(0); mocha.suite.beforeAll('Wait for deploy', (done) => { - console.dir("runnning wait for deploy"); global.embark.onReady(() => { done(); }); diff --git a/test_apps/test_app/test/simple_storage_deploy_spec.js b/test_apps/test_app/test/simple_storage_deploy_spec.js index b44aa064..b74acc33 100644 --- a/test_apps/test_app/test/simple_storage_deploy_spec.js +++ b/test_apps/test_app/test/simple_storage_deploy_spec.js @@ -16,7 +16,7 @@ contract("SimpleStorage Deploy", function () { let SimpleStorageInstance; before(async function() { - SimpleStorageInstance = await SimpleStorage.deploy({data: SimpleStorage.options.data, arguments: [150]}).send(); + SimpleStorageInstance = await SimpleStorage.deploy({arguments: [150]}).send(); }); it("should set constructor value", async function () { From 402ee19722fc9da98c84c8b11ec51547f485e140 Mon Sep 17 00:00:00 2001 From: Iuri Matias Date: Thu, 7 Jun 2018 20:09:07 -0400 Subject: [PATCH 20/32] default contracts fields --- lib/tests/test.js | 2 +- test_apps/test_app/test/simple_storage_deploy_spec.js | 8 +------- 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/lib/tests/test.js b/lib/tests/test.js index 1e21442c..aa0ea821 100644 --- a/lib/tests/test.js +++ b/lib/tests/test.js @@ -126,7 +126,7 @@ class Test { }; } if (!options.contracts) { - throw new Error(__('No contracts specified in the options')); + options.contracts = {}; } self.ready = false; diff --git a/test_apps/test_app/test/simple_storage_deploy_spec.js b/test_apps/test_app/test/simple_storage_deploy_spec.js index b74acc33..e4d24241 100644 --- a/test_apps/test_app/test/simple_storage_deploy_spec.js +++ b/test_apps/test_app/test/simple_storage_deploy_spec.js @@ -2,13 +2,7 @@ const SimpleStorage = embark.require('Embark/contracts/SimpleStorage'); let accounts; -config({ - contracts: { - "SimpleStorage": { - args: [100] - } - } -}, (err, theAccounts) => { +config({}, (err, theAccounts) => { accounts = theAccounts; }); From edbbaa160bdfc58e7415d0bc37b18dbf79f07e4b Mon Sep 17 00:00:00 2001 From: Iuri Matias Date: Thu, 7 Jun 2018 20:11:49 -0400 Subject: [PATCH 21/32] make config params optional --- lib/tests/test.js | 4 ++++ test_apps/test_app/test/simple_storage_deploy_spec.js | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/tests/test.js b/lib/tests/test.js index aa0ea821..4f9d1075 100644 --- a/lib/tests/test.js +++ b/lib/tests/test.js @@ -121,6 +121,10 @@ class Test { config(options, callback) { const self = this; + if (typeof(options) === 'function') { + callback = options; + options = {}; + } if (!callback) { callback = function () { }; diff --git a/test_apps/test_app/test/simple_storage_deploy_spec.js b/test_apps/test_app/test/simple_storage_deploy_spec.js index e4d24241..0f814434 100644 --- a/test_apps/test_app/test/simple_storage_deploy_spec.js +++ b/test_apps/test_app/test/simple_storage_deploy_spec.js @@ -2,7 +2,7 @@ const SimpleStorage = embark.require('Embark/contracts/SimpleStorage'); let accounts; -config({}, (err, theAccounts) => { +config((err, theAccounts) => { accounts = theAccounts; }); From 3db8ccd44e9bd73f0d330f203c6f83a1b7fa9b67 Mon Sep 17 00:00:00 2001 From: Iuri Matias Date: Thu, 7 Jun 2018 20:13:50 -0400 Subject: [PATCH 22/32] remove unnecessary config --- test_apps/test_app/test/simple_storage_deploy_spec.js | 4 ---- 1 file changed, 4 deletions(-) diff --git a/test_apps/test_app/test/simple_storage_deploy_spec.js b/test_apps/test_app/test/simple_storage_deploy_spec.js index 0f814434..c194dda6 100644 --- a/test_apps/test_app/test/simple_storage_deploy_spec.js +++ b/test_apps/test_app/test/simple_storage_deploy_spec.js @@ -2,10 +2,6 @@ const SimpleStorage = embark.require('Embark/contracts/SimpleStorage'); let accounts; -config((err, theAccounts) => { - accounts = theAccounts; -}); - contract("SimpleStorage Deploy", function () { let SimpleStorageInstance; From ede4926069918bb66b7a4e1232a62ac01d2ea665 Mon Sep 17 00:00:00 2001 From: Iuri Matias Date: Fri, 8 Jun 2018 06:14:46 -0400 Subject: [PATCH 23/32] don't continue testing file if there was deploy errors; avoids unrelated errors for each 'it' --- lib/tests/run_tests.js | 4 ++-- lib/tests/test.js | 9 ++++++--- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/lib/tests/run_tests.js b/lib/tests/run_tests.js index eb31209a..0ed32c7c 100644 --- a/lib/tests/run_tests.js +++ b/lib/tests/run_tests.js @@ -83,8 +83,8 @@ module.exports = { mocha.suite.timeout(0); mocha.suite.beforeAll('Wait for deploy', (done) => { - global.embark.onReady(() => { - done(); + global.embark.onReady((err) => { + done(err); }); }); diff --git a/lib/tests/test.js b/lib/tests/test.js index 4f9d1075..bc9b5abe 100644 --- a/lib/tests/test.js +++ b/lib/tests/test.js @@ -117,6 +117,9 @@ class Test { this.events.once('ready', () => { callback(); }); + this.events.once('deployError', (err) => { + callback(err); + }); } config(options, callback) { @@ -175,12 +178,12 @@ class Test { }, function deploy(next) { self._deploy(options, (err, accounts) => { - self.ready = true; - self.events.emit('ready'); if (err) { - console.error(err.red); + self.events.emit('deployError', err); return next(err); } + self.ready = true; + self.events.emit('ready'); next(null, accounts); }); } From 2efea55d2b42217960c5c17d9d5755aa1122d20b Mon Sep 17 00:00:00 2001 From: Iuri Matias Date: Fri, 8 Jun 2018 06:17:51 -0400 Subject: [PATCH 24/32] lint is king --- lib/tests/test.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/tests/test.js b/lib/tests/test.js index bc9b5abe..0e883686 100644 --- a/lib/tests/test.js +++ b/lib/tests/test.js @@ -124,7 +124,7 @@ class Test { config(options, callback) { const self = this; - if (typeof(options) === 'function') { + if (typeof (options) === 'function') { callback = options; options = {}; } @@ -229,7 +229,7 @@ class Test { {from: self.web3.eth.defaultAccount, gas: 6000000})); self.contracts[contractName].address = contract.deployedAddress; if (self.contracts[contractName].options) { - self.contracts[contractName].options.from = self.contracts[contractName].options.from || web3.eth.defaultAccount; + self.contracts[contractName].options.from = self.contracts[contractName].options.from || self.web3.eth.defaultAccount; self.contracts[contractName].options.data = data; } eachCb(); @@ -276,7 +276,7 @@ class Test { {from: this.web3.eth.defaultAccount, gas: 6000000}); this.contracts[contractName].address = contract.address; this.contracts[contractName].options.data = contract.code; - web3.eth.getAccounts().then((accounts) => { + this.web3.eth.getAccounts().then((accounts) => { this.contracts[contractName].options.from = contract.from || accounts[0]; }); return this.contracts[contractName]; From c8b52a17466105737dab5a99f087355b03ecf6d1 Mon Sep 17 00:00:00 2001 From: Iuri Matias Date: Fri, 8 Jun 2018 07:07:27 -0400 Subject: [PATCH 25/32] fix errors handling so it doesn't attempt to continue building when there are fatal errors compiling contracts --- lib/contracts/code_generator.js | 8 ++++---- lib/contracts/contract_deployer.js | 2 +- lib/contracts/contracts.js | 11 ++++++++--- lib/contracts/deploy_manager.js | 15 ++++++++++----- lib/index.js | 7 +++++-- lib/pipeline/pipeline.js | 6 +++--- 6 files changed, 31 insertions(+), 18 deletions(-) diff --git a/lib/contracts/code_generator.js b/lib/contracts/code_generator.js index 964a54ff..9a02f519 100644 --- a/lib/contracts/code_generator.js +++ b/lib/contracts/code_generator.js @@ -43,7 +43,7 @@ class CodeGenerator { // new events this.events.setCommandHandler('code-vanila', function(cb) { - self.events.request("contracts:list", (contractsList) => { + self.events.request("contracts:list", (_err, contractsList) => { let vanillaABI = self.generateABI(contractsList, {useEmbarkJS: false}); let contractsJSON = self.generateContractsJSON(contractsList); cb(vanillaABI, contractsJSON); @@ -51,7 +51,7 @@ class CodeGenerator { }); this.events.setCommandHandler('code', function(cb) { - self.events.request("contracts:list", (contractsList) => { + self.events.request("contracts:list", (_err, contractsList) => { let embarkJSABI = self.generateABI(contractsList, {useEmbarkJS: true}); let contractsJSON = self.generateContractsJSON(contractsList); cb(embarkJSABI, contractsJSON); @@ -59,7 +59,7 @@ class CodeGenerator { }); this.events.setCommandHandler('code-contracts-vanila', function(cb) { - self.events.request("contracts:list", (contractsList) => { + self.events.request("contracts:list", (_err, contractsList) => { let vanillaContractsABI = self.generateContracts(contractsList, false, true, false); let contractsJSON = self.generateContractsJSON(contractsList); cb(vanillaContractsABI, contractsJSON); @@ -67,7 +67,7 @@ class CodeGenerator { }); this.events.setCommandHandler('code-vanila-deployment', function(cb) { - self.events.request("contracts:list", (contractsList) => { + self.events.request("contracts:list", (_err, contractsList) => { let vanillaABI = self.generateABI(contractsList, {useEmbarkJS: false, deployment: true}); let contractsJSON = self.generateContractsJSON(contractsList); cb(vanillaABI, contractsJSON); diff --git a/lib/contracts/contract_deployer.js b/lib/contracts/contract_deployer.js index 7ffce6d9..546012c8 100644 --- a/lib/contracts/contract_deployer.js +++ b/lib/contracts/contract_deployer.js @@ -170,7 +170,7 @@ class ContractDeployer { }); }, function doLinking(next) { - self.events.request('contracts:list', (contracts) => { + self.events.request('contracts:list', (_err, contracts) => { for (let contractObj of contracts) { let filename = contractObj.filename; let deployedAddress = contractObj.deployedAddress; diff --git a/lib/contracts/contracts.js b/lib/contracts/contracts.js index 5c389723..b74b7f55 100644 --- a/lib/contracts/contracts.js +++ b/lib/contracts/contracts.js @@ -18,6 +18,7 @@ class ContractsManager { this.gasLimit = options.gasLimit; this.deployOnlyOnConfig = false; this.events = options.events; + this.compileError = false; self.events.on(constants.events.contractFilesChanged, (newContractFiles) => { self.contractFiles = newContractFiles; @@ -27,7 +28,7 @@ class ContractsManager { }); self.events.setCommandHandler('contracts:list', (cb) => { - cb(self.listContracts()); + cb(self.compileError, self.listContracts()); }); self.events.setCommandHandler("contracts:contract", (contractName, cb) => { @@ -36,8 +37,8 @@ class ContractsManager { self.events.setCommandHandler("contracts:build", (configOnly, cb) => { self.deployOnlyOnConfig = configOnly; // temporary, should refactor - self.build(() => { - cb(); + self.build((err) => { + cb(err); }); }); @@ -59,6 +60,7 @@ class ContractsManager { let self = this; async.waterfall([ function compileContracts(callback) { + self.events.emit("status", __("Compiling...")); if (process.env.isTest && self.compiledContracts && Object.keys(self.compiledContracts).length) { // Only compile once for tests return callback(); @@ -69,6 +71,7 @@ class ContractsManager { }); }, function prepareContractsFromConfig(callback) { + self.events.emit("status", __("Building...")); let className, contract; for (className in self.contractsConfig.contracts) { contract = self.contractsConfig.contracts[className]; @@ -247,6 +250,8 @@ class ContractsManager { } ], function (err, _result) { if (err) { + self.compileError = true; + self.events.emit("status", __("Compile/Build error")); self.logger.error(__("Error Compiling/Building contracts: ") + err); } self.logger.trace("finished".underline); diff --git a/lib/contracts/deploy_manager.js b/lib/contracts/deploy_manager.js index 7f69e9e6..7f63a4d4 100644 --- a/lib/contracts/deploy_manager.js +++ b/lib/contracts/deploy_manager.js @@ -22,10 +22,15 @@ class DeployManager { deployAll(done) { let self = this; - this.logger.info(__("deploying contracts")); - this.events.emit("deploy:beforeAll"); - self.events.request('contracts:list', (contracts) => { + self.events.request('contracts:list', (err, contracts) => { + if (err) { + return done(err); + } + + self.logger.info(__("deploying contracts")); + self.events.emit("deploy:beforeAll"); + async.eachOfSeries(contracts, function (contract, key, callback) { contract._gasLimit = self.gasLimit; @@ -61,8 +66,8 @@ class DeployManager { async.waterfall([ function buildContracts(callback) { - self.events.request("contracts:build", self.deployOnlyOnConfig, () => { - callback(); + self.events.request("contracts:build", self.deployOnlyOnConfig, (err) => { + callback(err); }); }, diff --git a/lib/index.js b/lib/index.js index bc5410df..338ee7fc 100644 --- a/lib/index.js +++ b/lib/index.js @@ -121,11 +121,14 @@ class Embark { engine.startService("storage"); engine.startService("codeGenerator"); engine.startService("namingSystem"); - + engine.events.on('check:backOnline:Ethereum', function () { engine.logger.info(__('Ethereum node detected') + '..'); engine.config.reloadConfig(); - engine.events.request('deploy:contracts', function() { + engine.events.request('deploy:contracts', function(err) { + if (err) { + return; + } engine.logger.info(__('Deployment Done')); }); }); diff --git a/lib/pipeline/pipeline.js b/lib/pipeline/pipeline.js index db50770e..544e1d26 100644 --- a/lib/pipeline/pipeline.js +++ b/lib/pipeline/pipeline.js @@ -53,7 +53,7 @@ class Pipeline { next(); }, function writeContracts(next) { - self.events.request('contracts:list', (contracts) => { + self.events.request('contracts:list', (_err, contracts) => { // ensure the .embark/contracts directory exists (create if not exists) fs.mkdirp(fs.dappPath(".embark/contracts", ''), (err) => { if(err) return next(err); @@ -224,8 +224,8 @@ class Pipeline { }); }, function getContracts(next) { - self.events.request('contracts:list', (contracts) => { - next(null, contracts); + self.events.request('contracts:list', (err, contracts) => { + next(err, contracts); }); }, function writeContractsJSON(contracts, next) { From 46e085b01110f7212f50060a2effe49d2bdc543a Mon Sep 17 00:00:00 2001 From: Iuri Matias Date: Fri, 8 Jun 2018 09:40:23 -0400 Subject: [PATCH 26/32] lint is king --- lib/tests/test.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/tests/test.js b/lib/tests/test.js index 4f9d1075..3dcfbf10 100644 --- a/lib/tests/test.js +++ b/lib/tests/test.js @@ -121,7 +121,7 @@ class Test { config(options, callback) { const self = this; - if (typeof(options) === 'function') { + if (typeof (options) === 'function') { callback = options; options = {}; } @@ -226,7 +226,7 @@ class Test { {from: self.web3.eth.defaultAccount, gas: 6000000})); self.contracts[contractName].address = contract.deployedAddress; if (self.contracts[contractName].options) { - self.contracts[contractName].options.from = self.contracts[contractName].options.from || web3.eth.defaultAccount; + self.contracts[contractName].options.from = self.contracts[contractName].options.from || self.web3.eth.defaultAccount; self.contracts[contractName].options.data = data; } eachCb(); @@ -273,7 +273,7 @@ class Test { {from: this.web3.eth.defaultAccount, gas: 6000000}); this.contracts[contractName].address = contract.address; this.contracts[contractName].options.data = contract.code; - web3.eth.getAccounts().then((accounts) => { + this.web3.eth.getAccounts().then((accounts) => { this.contracts[contractName].options.from = contract.from || accounts[0]; }); return this.contracts[contractName]; From eecd71951588650268ee9dbe97a0893b0c1375ff Mon Sep 17 00:00:00 2001 From: Jonathan Rainville Date: Fri, 8 Jun 2018 10:40:01 -0400 Subject: [PATCH 27/32] put message if swarm or ipfs is not installed --- lib/modules/storage/index.js | 1 - lib/processes/storageProcesses/ipfs.js | 16 +- .../storageProcessesLauncher.js | 16 +- .../storageProcesses/storageUtils.js | 25 ++ lib/processes/storageProcesses/swarm.js | 4 +- package-lock.json | 226 +++++++++--------- 6 files changed, 163 insertions(+), 125 deletions(-) create mode 100644 lib/processes/storageProcesses/storageUtils.js diff --git a/lib/modules/storage/index.js b/lib/modules/storage/index.js index 9f8162a9..299538bb 100644 --- a/lib/modules/storage/index.js +++ b/lib/modules/storage/index.js @@ -69,7 +69,6 @@ class Storage { self._logger.trace(`Storage module: Launching ${platform} process...`); return storageProcessesLauncher.launchProcess(platform.toLowerCase(), (err) => { if (err) { - self._logger.error(err); return callback(err); } callback(); diff --git a/lib/processes/storageProcesses/ipfs.js b/lib/processes/storageProcesses/ipfs.js index 83fedc2a..4f511a77 100644 --- a/lib/processes/storageProcesses/ipfs.js +++ b/lib/processes/storageProcesses/ipfs.js @@ -1,21 +1,23 @@ const child_process = require('child_process'); const ProcessWrapper = require('../../process/processWrapper'); const constants = require('../../constants'); +const StorageUtils = require('./storageUtils'); let ipfsProcess; // eslint-disable-line no-unused-vars class IPFSProcess extends ProcessWrapper { - constructor(_options) { + constructor(options) { super(); - this.cors = _options.cors; + this.cors = options.cors; + this.command = StorageUtils.getCommand('ipfs', options); this.checkIPFSVersion(); this.startIPFSDaemon(); } checkIPFSVersion() { - child_process.exec('ipfs --version', {silent: true}, (err, stdout, _stderr) => { + child_process.exec(this.command + ' --version', {silent: true}, (err, stdout, _stderr) => { if (err) { console.error(err); return; @@ -35,7 +37,7 @@ class IPFSProcess extends ProcessWrapper { const self = this; // spawn the daemon (muhaha) - this.child = child_process.spawn('ipfs', ['daemon']); + this.child = child_process.spawn(this.command, ['daemon']); this.child.on('error', (err) => { err = err.toString(); @@ -51,7 +53,7 @@ class IPFSProcess extends ProcessWrapper { self.readyCalled = true; // update IPFS cors before spawning a daemon (muhaha) - let ipfsCorsCmd = `ipfs config --json API.HTTPHeaders.Access-Control-Allow-Origin "[\\"${self.cors.join('\\", \\"')}\\"]"`; + let ipfsCorsCmd = `${self.command} config --json API.HTTPHeaders.Access-Control-Allow-Origin "[\\"${self.cors.join('\\", \\"')}\\"]"`; console.trace(`Updating IPFS CORS using command: ${ipfsCorsCmd}`); child_process.exec(ipfsCorsCmd, {silent: true}, (err, stdout, _stderr) => { if(err){ @@ -62,7 +64,7 @@ class IPFSProcess extends ProcessWrapper { _stderr = _stderr.toString(); console.error(`IPFS CORS update error: ${_stderr}`); } - child_process.exec('ipfs config --json API.HTTPHeaders.Access-Control-Allow-Credentials "[\\"true\\"]"', {silent: true}, (err, stdout, _stderr) => { + child_process.exec(self.command + ' config --json API.HTTPHeaders.Access-Control-Allow-Credentials "[\\"true\\"]"', {silent: true}, (err, stdout, _stderr) => { if(err){ err = err.toString(); console.error('IPFS CORS update error: ', err); @@ -71,7 +73,7 @@ class IPFSProcess extends ProcessWrapper { _stderr = _stderr.toString(); console.error(`IPFS CORS update error: ${_stderr}`); } - child_process.exec('ipfs config --json API.HTTPHeaders.Access-Control-Allow-Methods "[\\"PUT\\", \\"POST\\", \\"GET\\"]"', {silent: true}, (err, stdout, _stderr) => { + child_process.exec(self.command + ' config --json API.HTTPHeaders.Access-Control-Allow-Methods "[\\"PUT\\", \\"POST\\", \\"GET\\"]"', {silent: true}, (err, stdout, _stderr) => { if(err){ err = err.toString(); console.error('IPFS CORS update error: ', err); diff --git a/lib/processes/storageProcesses/storageProcessesLauncher.js b/lib/processes/storageProcesses/storageProcessesLauncher.js index 14e86ee9..2ac624a0 100644 --- a/lib/processes/storageProcesses/storageProcessesLauncher.js +++ b/lib/processes/storageProcesses/storageProcessesLauncher.js @@ -1,7 +1,9 @@ const fs = require('../../core/fs'); +const shellJs = require('shelljs'); const utils = require('../../utils/utils'); const ProcessLauncher = require('../../process/processLauncher'); const constants = require('../../constants'); +const StorageUtils = require('./storageUtils'); class StorageProcessesLauncher { constructor(options) { @@ -69,7 +71,7 @@ class StorageProcessesLauncher { } processExited(storageName, code) { - this.logger.error(__(`Storage process for ${storageName} ended before the end of this process. Code: ${code}`)); + this.logger.error(__(`Storage process for {{storageName}} ended before the end of this process. Code: {{code}}`, {storageName, code})); } launchProcess(storageName, callback) { @@ -80,9 +82,17 @@ class StorageProcessesLauncher { const filePath = utils.joinPath(__dirname, `./${storageName}.js`); fs.access(filePath, (err) => { if (err) { - return callback(__('No process file for this storage type exists. Please start the process locally.')); + return callback(__('No process file for this storage type (%s) exists. Please start the process locally.', storageName)); } - self.logger.info(__(`Starting ${storageName} process`).cyan); + + const program = shellJs.which(StorageUtils.getCommand(storageName, self.storageConfig)); + if (!program) { + self.logger.warn(__('{{storageName}} is not installed or your configuration is not right', {storageName}).yellow); + self.logger.info(__('You can install and get more information here: ').yellow + StorageUtils.getStorageInstallationSite(storageName).underline); + return callback(__('%s not installed', storageName)); + } + + self.logger.info(__(`Starting %s process`, storageName).cyan); self.processes[storageName] = new ProcessLauncher({ modulePath: filePath, logger: self.logger, diff --git a/lib/processes/storageProcesses/storageUtils.js b/lib/processes/storageProcesses/storageUtils.js new file mode 100644 index 00000000..d701d2b7 --- /dev/null +++ b/lib/processes/storageProcesses/storageUtils.js @@ -0,0 +1,25 @@ +const IPFS = 'ipfs'; +const SWARM = 'swarm'; + +class StorageUtils { + static getCommand(storageName, config) { + if (storageName === IPFS) { + return IPFS; + } + if (storageName === SWARM) { + return config.swarmPath || SWARM; + } + return null; + } + + static getStorageInstallationSite(storageName) { + if (storageName === IPFS) { + return 'https://ipfs.io/docs/install/'; + } + if (storageName === SWARM) { + return 'http://swarm-guide.readthedocs.io/en/latest/installation.html'; + } + } +} + +module.exports = StorageUtils; diff --git a/lib/processes/storageProcesses/swarm.js b/lib/processes/storageProcesses/swarm.js index 8bbf37ca..36302c17 100644 --- a/lib/processes/storageProcesses/swarm.js +++ b/lib/processes/storageProcesses/swarm.js @@ -2,6 +2,7 @@ const child_process = require('child_process'); const ProcessWrapper = require('../../process/processWrapper'); const constants = require('../../constants'); const fs = require('../../core/fs'); +const StorageUtils = require('./storageUtils'); let swarmProcess; @@ -10,6 +11,7 @@ class SwarmProcess extends ProcessWrapper { super(); this.storageConfig = options.storageConfig; this.cors = options.cors; + this.command = StorageUtils.getCommand('swarm', this.storageConfig); } startSwarmDaemon() { @@ -24,7 +26,7 @@ class SwarmProcess extends ProcessWrapper { `--corsdomain=${self.cors.join(',')}` ]; console.trace('Starting swarm process with arguments: ' + args.join(' ')); - this.child = child_process.spawn(this.storageConfig.swarmPath || 'swarm', args); + this.child = child_process.spawn(this.command, args); this.child.on('error', (err) => { err = err.toString(); diff --git a/package-lock.json b/package-lock.json index 7661c123..2595336b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -92,7 +92,7 @@ "abbrev": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/abbrev/-/abbrev-1.1.1.tgz", - "integrity": "sha512-nne9/IiQ/hzIhY6pdDnbBtz7DjPTKrY00P/zvPSm5pOFkl6xuGrGnXn/VtTNNfNtAfZ9/1RtehkszU9qcTii0Q==" + "integrity": "sha1-+PLIh60Qv2f2NPAFtph/7TF5qsg=" }, "abstract-leveldown": { "version": "2.6.3", @@ -114,7 +114,7 @@ "acorn": { "version": "5.5.3", "resolved": "https://registry.npmjs.org/acorn/-/acorn-5.5.3.tgz", - "integrity": "sha512-jd5MkIUlbbmb07nXH0DT3y7rDVtkzDi4XZOUVWAer8ajmF/DTSSbl5oNFyDOl/OXA33Bl79+ypHhl2pN20VeOQ==" + "integrity": "sha1-9HPdR+AnegjijpvsWu6wR1HwuMk=" }, "acorn-dynamic-import": { "version": "2.0.2", @@ -484,7 +484,7 @@ "argparse": { "version": "1.0.10", "resolved": "https://registry.npmjs.org/argparse/-/argparse-1.0.10.tgz", - "integrity": "sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg==", + "integrity": "sha1-vNZ5HqWuCXJeF+WtmIE0zUCz2RE=", "requires": { "sprintf-js": "1.0.3" } @@ -500,7 +500,7 @@ "arr-flatten": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/arr-flatten/-/arr-flatten-1.1.0.tgz", - "integrity": "sha512-L3hKV5R/p5o81R7O02IGnwpDmkp6E982XhtbuwSe3O4qOtMMMtodicASA1Cny2U+aCXcNpml+m4dPsvsJ3jatg==" + "integrity": "sha1-NgSLv/TntH4TZkQxbJlmnqWukfE=" }, "arr-union": { "version": "3.1.0", @@ -559,7 +559,7 @@ "asn1.js": { "version": "4.10.1", "resolved": "https://registry.npmjs.org/asn1.js/-/asn1.js-4.10.1.tgz", - "integrity": "sha512-p32cOF5q0Zqs9uBiONKYLm6BClCoBCM5O9JfeUSlnQLBTxYdTK+pW+nXflm8UkKd2UYlEbYz5qEi0JuZR9ckSw==", + "integrity": "sha1-ucK/WAXx5kqt7tbfOiv6+1pz9aA=", "requires": { "bn.js": "4.11.8", "inherits": "2.0.3", @@ -687,7 +687,7 @@ "babel-generator": { "version": "6.26.1", "resolved": "https://registry.npmjs.org/babel-generator/-/babel-generator-6.26.1.tgz", - "integrity": "sha512-HyfwY6ApZj7BYTcJURpM5tznulaBvyio7/0d4zFOeMPUmfxkCjHocCuoLa2SAGzBI8AREcH3eP3758F672DppA==", + "integrity": "sha1-GERAjTuPDTWkBOp6wYDwh6YBvZA=", "requires": { "babel-messages": "6.23.0", "babel-runtime": "6.26.0", @@ -858,7 +858,7 @@ "babel-loader": { "version": "7.1.4", "resolved": "https://registry.npmjs.org/babel-loader/-/babel-loader-7.1.4.tgz", - "integrity": "sha512-/hbyEvPzBJuGpk9o80R0ZyTej6heEOr59GoEUtn8qFKbnx4cJm9FWES6J/iv644sYgrtVw9JJQkjaLW/bqb5gw==", + "integrity": "sha1-40Y5OL1ObVXRwXTFSF1AahiO0BU=", "requires": { "find-cache-dir": "1.0.0", "loader-utils": "1.1.0", @@ -1553,7 +1553,7 @@ "babylon": { "version": "6.18.0", "resolved": "https://registry.npmjs.org/babylon/-/babylon-6.18.0.tgz", - "integrity": "sha512-q/UEjfGJ2Cm3oKV71DJz9d25TPnq5rhBVL2Q4fA5wcC3jcrdn7+SssEybFIxwAvvP+YCsCYNKughoF33GxgycQ==" + "integrity": "sha1-ry87iPpvXB5MY00aD46sT1WzleM=" }, "backoff": { "version": "2.5.0", @@ -1571,7 +1571,7 @@ "base": { "version": "0.11.2", "resolved": "https://registry.npmjs.org/base/-/base-0.11.2.tgz", - "integrity": "sha512-5T6P4xPgpp0YDFvSWwEZ4NoE3aM4QBQXDzmVbraCkFj8zHM+mba8SyqB5DbZWyR7mYHo6Y7BdQo3MoA4m0TeQg==", + "integrity": "sha1-e95c7RRbbVUakNuH+DxVi060io8=", "requires": { "cache-base": "1.0.1", "class-utils": "0.3.6", @@ -1630,7 +1630,7 @@ "big.js": { "version": "3.2.0", "resolved": "https://registry.npmjs.org/big.js/-/big.js-3.2.0.tgz", - "integrity": "sha512-+hN/Zh2D08Mx65pZ/4g5bsmNiZUuChDiQfTUQ7qJr4/kuopCr88xZsAXv6mBoZEsUI4OuGHlX59qE94K2mMW8Q==" + "integrity": "sha1-pfwpi4G54Nyi5FiCR4S2XFK6WI4=" }, "binary-extensions": { "version": "1.11.0", @@ -1645,7 +1645,7 @@ "bindings": { "version": "1.3.0", "resolved": "https://registry.npmjs.org/bindings/-/bindings-1.3.0.tgz", - "integrity": "sha512-DpLh5EzMR2kzvX1KIlVC0VkC3iZtHKTgdtZ0a3pglBZdaQFjt5S9g9xd1lE+YvXyfd6mtCeRnrUfOLYiTMlNSw==" + "integrity": "sha1-s0b27PapX1qBXFg5/HzbIlAvHtc=" }, "bip39": { "version": "2.5.0", @@ -1701,7 +1701,7 @@ "bn.js": { "version": "4.11.8", "resolved": "https://registry.npmjs.org/bn.js/-/bn.js-4.11.8.tgz", - "integrity": "sha512-ItfYfPLkWHUjckQCk8xC+LwxgK8NYcXywGigJgSwOP8Y2iyWT4f2vsZnoOXTTbo+o5yXmIUJ4gn5538SO5S3gA==" + "integrity": "sha1-LN4J617jQfSEdGuwMJsyU7GxRC8=" }, "body-parser": { "version": "1.18.2", @@ -1731,7 +1731,7 @@ "brace-expansion": { "version": "1.1.11", "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", - "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", + "integrity": "sha1-PH/L9SnYcibz0vUrlm/1Jx60Qd0=", "requires": { "balanced-match": "1.0.0", "concat-map": "0.0.1" @@ -1931,7 +1931,7 @@ "cache-base": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/cache-base/-/cache-base-1.0.1.tgz", - "integrity": "sha512-AKcdTnFSWATd5/GCPRxr2ChwIJ85CeyrEyjRHlKxQ56d4XJMGym0uAiKn0xbLOGOl3+yRpOTi484dVCEc5AUzQ==", + "integrity": "sha1-Cn9GQWgxyLZi7jb+TnxZ129marI=", "requires": { "collection-visit": "1.0.0", "component-emitter": "1.2.1", @@ -2223,7 +2223,7 @@ "cids": { "version": "0.5.3", "resolved": "https://registry.npmjs.org/cids/-/cids-0.5.3.tgz", - "integrity": "sha512-ujWbNP8SeLKg5KmGrxYZM4c+ttd+wwvegrdtgmbi2KNFUbQN4pqsGZaGQE3rhjayXTbKFq36bYDbKhsnD0eMsg==", + "integrity": "sha1-miW2l+t2+vgHr87DXEq5Nu370KQ=", "requires": { "multibase": "0.4.0", "multicodec": "0.2.6", @@ -2233,7 +2233,7 @@ "cipher-base": { "version": "1.0.4", "resolved": "https://registry.npmjs.org/cipher-base/-/cipher-base-1.0.4.tgz", - "integrity": "sha512-Kkht5ye6ZGmwv40uUDZztayT2ThLQGfnj/T71N/XzeZeo3nf8foyW7zGTsPYkEya3m5f3cAypH+qe7YOrM1U2Q==", + "integrity": "sha1-h2Dk7MJy9MNjUy+SbYdKriwTl94=", "requires": { "inherits": "2.0.3", "safe-buffer": "5.1.1" @@ -2248,7 +2248,7 @@ "clap": { "version": "1.2.3", "resolved": "https://registry.npmjs.org/clap/-/clap-1.2.3.tgz", - "integrity": "sha512-4CoL/A3hf90V3VIEjeuhSvlGFEHKzOz+Wfc2IVZc+FaUgU0ZQafJTP49fvnULipOPcAfqhyI2duwQyns6xqjYA==", + "integrity": "sha1-TzZ0WzIAhJJVf0ZBLWbVDLmbzlE=", "requires": { "chalk": "1.1.3" } @@ -2256,7 +2256,7 @@ "class-utils": { "version": "0.3.6", "resolved": "https://registry.npmjs.org/class-utils/-/class-utils-0.3.6.tgz", - "integrity": "sha512-qOhPa/Fj7s6TY8H8esGu5QNpMMQxz79h+urzrNYN6mn+9BnxlDGf5QZ+XeCDsxSjPqsSR56XOZOJmpeurnLMeg==", + "integrity": "sha1-+TNprouafOAv1B+q0MqDAzGQxGM=", "requires": { "arr-union": "3.1.0", "define-property": "0.2.5", @@ -2510,7 +2510,7 @@ "color-convert": { "version": "1.9.1", "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.1.tgz", - "integrity": "sha512-mjGanIiwQJskCC18rPR6OmrZ6fm2Lc7PeGFYwCmy5J34wC6F1PzdGL6xeMfmgicfYcNLGuVFA3WzXtIDCQSZxQ==", + "integrity": "sha1-wSYRB66y8pTr/+ye2eytUppgl+0=", "requires": { "color-name": "1.1.3" } @@ -2721,7 +2721,7 @@ "crypto-browserify": { "version": "3.12.0", "resolved": "https://registry.npmjs.org/crypto-browserify/-/crypto-browserify-3.12.0.tgz", - "integrity": "sha512-fz4spIh+znjO2VjL+IdhEpRJ3YN6sMzITSBijk6FK2UvTqruSQW+/cCZTSNsMiZNvUeq0CqurF+dAbyiGOY6Wg==", + "integrity": "sha1-OWz58xN/A+S45TLFj2mCVOAPgOw=", "requires": { "browserify-cipher": "1.0.0", "browserify-sign": "4.0.4", @@ -2895,7 +2895,7 @@ "debug": { "version": "2.6.9", "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", - "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", + "integrity": "sha1-XRKFFd8TT/Mn6QpMk/Tgd6U2NB8=", "requires": { "ms": "2.0.0" } @@ -3047,7 +3047,7 @@ "define-property": { "version": "2.0.2", "resolved": "https://registry.npmjs.org/define-property/-/define-property-2.0.2.tgz", - "integrity": "sha512-jwK2UV4cnPpbcG7+VRARKTZPUWowwXA8bzH5NP6ud0oeAxyYPuGZUAC7hMugpCdz4BeSZl2Dl9k66CHJ/46ZYQ==", + "integrity": "sha1-1Flono1lS6d+AqgX+HENcCyxbp0=", "requires": { "is-descriptor": "1.0.2", "isobject": "3.0.1" @@ -3293,7 +3293,7 @@ "end-of-stream": { "version": "1.4.1", "resolved": "https://registry.npmjs.org/end-of-stream/-/end-of-stream-1.4.1.tgz", - "integrity": "sha512-1MkrZNvWTKCaigbn+W15elq2BB/L22nqrSY5DKlo3X6+vclJm8Bb5djXJBmEX6fS3+zCh/F4VBK5Z2KxJt4s2Q==", + "integrity": "sha1-7SljTRm6ukY7bOa4CjchPqtx7EM=", "requires": { "once": "1.4.0" } @@ -3624,7 +3624,7 @@ "esrecurse": { "version": "4.2.1", "resolved": "https://registry.npmjs.org/esrecurse/-/esrecurse-4.2.1.tgz", - "integrity": "sha512-64RBB++fIOAXPw3P9cy89qfMlvZEXZkqqJkjqqXIvzP5ezRZjW+lPWjw35UX/3EhUPFYbg5ER4JYgDw4007/DQ==", + "integrity": "sha1-AHo7n9vCs7uH5IeeoZyS/b05Qs8=", "requires": { "estraverse": "4.2.0" } @@ -4131,7 +4131,7 @@ "evp_bytestokey": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/evp_bytestokey/-/evp_bytestokey-1.0.3.tgz", - "integrity": "sha512-/f2Go4TognH/KvCISP7OUsHn85hT9nUkxxA9BEWxFn+Oj9o8ZNLm/40hdlgSLyuOimsrTKLUMEorQexp/aPQeA==", + "integrity": "sha1-f8vbGY3HGVlDLv4ThCaE4FJaywI=", "requires": { "md5.js": "1.3.4", "safe-buffer": "5.1.1" @@ -4252,7 +4252,7 @@ "is-extendable": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/is-extendable/-/is-extendable-1.0.1.tgz", - "integrity": "sha512-arnXMxT1hhoKo9k1LZdmlNyJdDDfy2v0fXjFlmok4+i8ul/6WlbVge9bhM74OpNPQPMGUToDtz+KXa1PneJxOA==", + "integrity": "sha1-p0cPnkJnM9gb2B4RVSZOOjUHyrQ=", "requires": { "is-plain-object": "2.0.4" } @@ -4658,7 +4658,7 @@ "file-loader": { "version": "1.1.11", "resolved": "https://registry.npmjs.org/file-loader/-/file-loader-1.1.11.tgz", - "integrity": "sha512-TGR4HU7HUsGg6GCOPJnFk06RhWgEWFLAGWiT6rcD+GRC2keU3s9RGJ+b3Z6/U73jwwNb2gKLJ7YCrp+jvU4ALg==", + "integrity": "sha1-b+iGRJsPKpNuQ8q6rAzb+zaVBvg=", "requires": { "loader-utils": "1.1.0", "schema-utils": "0.4.5" @@ -4927,7 +4927,7 @@ "function-bind": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.1.tgz", - "integrity": "sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A==" + "integrity": "sha1-pWiZ0+o8m6uHS7l3O3xe3pL0iV0=" }, "functional-red-black-tree": { "version": "1.0.1", @@ -5043,7 +5043,7 @@ "glob": { "version": "7.1.2", "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.2.tgz", - "integrity": "sha512-MJTUg1kjuLeQCJ+ccE4Vpa6kKVXkPYJ2mOCQyUuKLcLQsdrMCpBPUi8qVE6+YuaJkozeA9NusTAw3hLr8Xe5EQ==", + "integrity": "sha1-wZyd+aAocC1nhhI4SmVSQExjbRU=", "requires": { "fs.realpath": "1.0.0", "inflight": "1.0.6", @@ -5145,7 +5145,7 @@ "globals": { "version": "9.18.0", "resolved": "https://registry.npmjs.org/globals/-/globals-9.18.0.tgz", - "integrity": "sha512-S0nG3CLEQiY/ILxqtztTWH/3iRRdyBLw6KMDxnKMchrtbj2OFmehVh0WUCfW3DUrIgx/qFrJPICrq4Z4sTR9UQ==" + "integrity": "sha1-qjiWs+abSH8X4x7SFD1pqOMMLYo=" }, "globby": { "version": "5.0.0", @@ -5480,7 +5480,7 @@ "grunt-mocha-test": { "version": "0.13.3", "resolved": "https://registry.npmjs.org/grunt-mocha-test/-/grunt-mocha-test-0.13.3.tgz", - "integrity": "sha512-zQGEsi3d+ViPPi7/4jcj78afKKAKiAA5n61pknQYi25Ugik+aNOuRmiOkmb8mN2CeG8YxT+YdT1H1Q7B/eNkoQ==", + "integrity": "sha1-kChHK2Fb2m3eqnswpaFk6YBd4AU=", "dev": true, "requires": { "hooker": "0.2.3", @@ -5646,7 +5646,7 @@ "hash.js": { "version": "1.1.3", "resolved": "https://registry.npmjs.org/hash.js/-/hash.js-1.1.3.tgz", - "integrity": "sha512-/UETyP0W22QILqS+6HowevwhEFJ3MBJnwTf75Qob9Wz9t0DPuisL8kW8YZMK62dHAKE1c1p+gY1TtOLY+USEHA==", + "integrity": "sha1-NA3tvmKQGHFRweodd3o0SJNd+EY=", "requires": { "inherits": "2.0.3", "minimalistic-assert": "1.0.0" @@ -5710,7 +5710,7 @@ "hosted-git-info": { "version": "2.6.0", "resolved": "https://registry.npmjs.org/hosted-git-info/-/hosted-git-info-2.6.0.tgz", - "integrity": "sha512-lIbgIIQA3lz5XaB6vxakj6sDHADJiZadYEJB+FgA+C4nubM1NwcuvUr9EJPmnH1skZqpqUzWborWo8EIUi0Sdw==" + "integrity": "sha1-IyNbKasjDFdqqw1PE/wEawsDgiI=" }, "html-comment-regex": { "version": "1.1.1", @@ -5799,7 +5799,7 @@ "ansi-styles": { "version": "3.2.1", "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.1.tgz", - "integrity": "sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==", + "integrity": "sha1-QfuyAkPlCxK+DwS43tvwdSDOhB0=", "requires": { "color-convert": "1.9.1" } @@ -5832,7 +5832,7 @@ "source-map": { "version": "0.6.1", "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", - "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==" + "integrity": "sha1-dHIq8y6WFOnCh6jQu95IteLxomM=" }, "supports-color": { "version": "5.3.0", @@ -6039,7 +6039,7 @@ "invariant": { "version": "2.2.4", "resolved": "https://registry.npmjs.org/invariant/-/invariant-2.2.4.tgz", - "integrity": "sha512-phJfQVBuaJM5raOpJjSfkiD6BpbCE4Ns//LaXl6wGYtUBY83nWS6Rf9tXm2e8VaK60JEjYldbPif/A2B1C2gNA==", + "integrity": "sha1-YQ88ksk1nOHbYW5TgAjSP/NRWOY=", "requires": { "loose-envify": "1.3.1" } @@ -6062,7 +6062,7 @@ "ipfs-api": { "version": "17.2.4", "resolved": "https://registry.npmjs.org/ipfs-api/-/ipfs-api-17.2.4.tgz", - "integrity": "sha512-GFNy3Cj7EkzCrdyaQpvctHmtwtghzIDPTtW6XTqj+vybSwk2swyEMKaMHimqi8c8N+5+x5wfLpeUyRUhcZ9lDA==", + "integrity": "sha1-gTCl+pjhWyr49qJ7cUQs66/ImyQ=", "requires": { "async": "2.6.0", "bs58": "4.0.1", @@ -6099,7 +6099,7 @@ "ipfs-block": { "version": "0.6.1", "resolved": "https://registry.npmjs.org/ipfs-block/-/ipfs-block-0.6.1.tgz", - "integrity": "sha512-28dgGsb2YsYnFs+To4cVBX8e/lTCb8eWDzGhN5csj3a/sHMOYrHeK8+Ez0IV67CI3lqKGuG/ZD01Cmd6JUvKrQ==", + "integrity": "sha1-uTBT6eqV917SkHgX/79V2ZKgatE=", "requires": { "cids": "0.5.3" } @@ -6107,7 +6107,7 @@ "ipfs-unixfs": { "version": "0.1.14", "resolved": "https://registry.npmjs.org/ipfs-unixfs/-/ipfs-unixfs-0.1.14.tgz", - "integrity": "sha512-s1tEnwKhdd17MmyC/EUMNVMDYzKhCiHDI11TF8tSBeWkEQp+0WUxkYuqvz0R5TSi2lNDJ/oVnEmwWhki2spUiQ==", + "integrity": "sha1-JWQ3/PZC2KtGtRhVguxPIekI7zc=", "requires": { "protons": "1.0.1" } @@ -6115,7 +6115,7 @@ "ipld-dag-pb": { "version": "0.11.4", "resolved": "https://registry.npmjs.org/ipld-dag-pb/-/ipld-dag-pb-0.11.4.tgz", - "integrity": "sha512-A514Bt4z44bxhPQVzmBFMJsV3res92eBaDX0snzVsLLasBPNh4Z7He8N2mwSeAX9bJNywRBlJbHMQPwC45rqXw==", + "integrity": "sha1-sPrlaB+tVpcTLjJdbC/xe18Mtqg=", "requires": { "async": "2.6.0", "bs58": "4.0.1", @@ -6167,7 +6167,7 @@ "is-buffer": { "version": "1.1.6", "resolved": "https://registry.npmjs.org/is-buffer/-/is-buffer-1.1.6.tgz", - "integrity": "sha512-NcdALwpXkTm5Zvvbk7owOUSvVvBKDgKP5/ewfXEznmQFfs4ZRmanOeKBTjRVjka3QFoN6XJ+9F3USqfHqTaU5w==" + "integrity": "sha1-76ouqdqg16suoTqXsritUf776L4=" }, "is-builtin-module": { "version": "1.0.0", @@ -6284,7 +6284,7 @@ "is-ipfs": { "version": "0.3.2", "resolved": "https://registry.npmjs.org/is-ipfs/-/is-ipfs-0.3.2.tgz", - "integrity": "sha512-82V1j4LMkYy7H4seQQzOWqo7FiW3I64/1/ryo3dhtWKfOvm7ZolLMRQQfGKs4OXWauh5rAkPnamVcRISHwhmpQ==", + "integrity": "sha1-xGULg442/QFR3liWsv8xn+iTYYI=", "requires": { "bs58": "4.0.1", "cids": "0.5.3", @@ -6327,7 +6327,7 @@ "is-odd": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/is-odd/-/is-odd-2.0.0.tgz", - "integrity": "sha512-OTiixgpZAT1M4NHgS5IguFp/Vz2VI3U7Goh4/HA1adtwyLtSBrxYlcSYkhpAE07s4fKEcjrFxyvtQBND4vFQyQ==", + "integrity": "sha1-dkZiRnH9fqVYzNmieVGC8pWPGyQ=", "requires": { "is-number": "4.0.0" }, @@ -6335,7 +6335,7 @@ "is-number": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/is-number/-/is-number-4.0.0.tgz", - "integrity": "sha512-rSklcAIlf1OmFdyAqbnWTLVelsQ58uvZ66S/ZyawjWqIviTWCjg2PzVGw8WUA+nNuPTqb4wgA+NszrJ+08LlgQ==" + "integrity": "sha1-ACbjf1RU1z41bf5lZGmYZ8an8P8=" } } }, @@ -6371,7 +6371,7 @@ "is-plain-object": { "version": "2.0.4", "resolved": "https://registry.npmjs.org/is-plain-object/-/is-plain-object-2.0.4.tgz", - "integrity": "sha512-h5PpgXkWitc38BBMYawTYMWJHFZJVnBquFE57xFpjB8pJFiF6gZ+bU+WyI/yqXiFR5mdLsgYNaPe8uao6Uv9Og==", + "integrity": "sha1-LBY7P6+xtgbZ0Xko8FwqHDjgdnc=", "requires": { "isobject": "3.0.1" }, @@ -6456,7 +6456,7 @@ "is-windows": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/is-windows/-/is-windows-1.0.2.tgz", - "integrity": "sha512-eXK1UInq2bPmjyX6e3VHIzMLobc4J94i4AWn+Hpq3OU5KkrRC96OAcR3PRJ/pGu6m8TRnBHP9dkXQVsT/COVIA==" + "integrity": "sha1-0YUOuXkezRjmGCzhKjDzlmNLsZ0=" }, "isarray": { "version": "1.0.0", @@ -6895,7 +6895,7 @@ "libp2p-crypto": { "version": "0.12.1", "resolved": "https://registry.npmjs.org/libp2p-crypto/-/libp2p-crypto-0.12.1.tgz", - "integrity": "sha512-1/z8rxZ0DcQNreZhEsl7PnLr7DWOioSvYbKBLGkRwNRiNh1JJLgh0PdTySBb44wkrOGT+TxcGRd7iq3/X6Wxwg==", + "integrity": "sha1-SocNJpujFQ3+AU5PmuoeVQdgFcg=", "requires": { "asn1.js": "5.0.0", "async": "2.6.0", @@ -6915,7 +6915,7 @@ "asn1.js": { "version": "5.0.0", "resolved": "https://registry.npmjs.org/asn1.js/-/asn1.js-5.0.0.tgz", - "integrity": "sha512-Y+FKviD0uyIWWo/xE0XkUl0x1allKFhzEVJ+//2Dgqpy+n+B77MlPNqvyk7Vx50M9XyVzjnRhDqJAEAsyivlbA==", + "integrity": "sha1-Kwq7x/pm3Aqt0GpGg8c2CMMrBpY=", "requires": { "bn.js": "4.11.8", "inherits": "2.0.3", @@ -7915,7 +7915,7 @@ "miller-rabin": { "version": "4.0.1", "resolved": "https://registry.npmjs.org/miller-rabin/-/miller-rabin-4.0.1.tgz", - "integrity": "sha512-115fLhvZVqWwHPbClyntxEVfVDfl9DLLTuJvq3g2O/Oxi8AiNouAHvDSzHS0viUJc+V5vm3eq91Xwqn9dp4jRA==", + "integrity": "sha1-8IA1HIZbDcViqEYpZtqlNUPHik0=", "requires": { "bn.js": "4.11.8", "brorand": "1.1.0" @@ -7924,7 +7924,7 @@ "mime": { "version": "1.4.1", "resolved": "https://registry.npmjs.org/mime/-/mime-1.4.1.tgz", - "integrity": "sha512-KI1+qOZu5DcW6wayYHSzR/tXKCDC5Om4s1z2QJjDULzLcmf3DvzS7oluY4HCTrc+9FiKmWUgeNLg7W3uIQvxtQ==" + "integrity": "sha1-Eh+evEnjdm8xGnbh+hyAA8SwOqY=" }, "mime-db": { "version": "1.33.0", @@ -7942,7 +7942,7 @@ "mimic-fn": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/mimic-fn/-/mimic-fn-1.2.0.tgz", - "integrity": "sha512-jf84uxzwiuiIVKiOLpfYk7N46TSy8ubTonmneY9vrpHNAnp0QBt2BxWV9dO3/j+BoVAb+a5G6YDPW3M5HOdMWQ==" + "integrity": "sha1-ggyGo5M0ZA6ZUWkovQP8qIBX0CI=" }, "mimic-response": { "version": "1.0.0", @@ -7970,7 +7970,7 @@ "minimatch": { "version": "3.0.4", "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", - "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", + "integrity": "sha1-UWbihkV/AzBgZL5Ul+jbsMPTIIM=", "requires": { "brace-expansion": "1.1.11" } @@ -7998,7 +7998,7 @@ "minizlib": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/minizlib/-/minizlib-1.1.0.tgz", - "integrity": "sha512-4T6Ur/GctZ27nHfpt9THOdRZNgyJ9FZchYO1ceg5S8Q3DNLCKYy44nCZzgCJgcvx2UM8czmqak5BCxJMrq37lA==", + "integrity": "sha1-EeE2WM5GvDpwomeqxYNZ0eDCnOs=", "requires": { "minipass": "2.2.1" } @@ -8006,7 +8006,7 @@ "mixin-deep": { "version": "1.3.1", "resolved": "https://registry.npmjs.org/mixin-deep/-/mixin-deep-1.3.1.tgz", - "integrity": "sha512-8ZItLHeEgaqEvd5lYBXfm4EZSFCX29Jb9K+lAHhDKzReKBQKj3R+7NOF6tjqYi9t4oI8VUfaWITJQm86wnXGNQ==", + "integrity": "sha1-pJ5yaNzhoNlpjkUybFYm3zVD0P4=", "requires": { "for-in": "1.0.2", "is-extendable": "1.0.1" @@ -8015,7 +8015,7 @@ "is-extendable": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/is-extendable/-/is-extendable-1.0.1.tgz", - "integrity": "sha512-arnXMxT1hhoKo9k1LZdmlNyJdDDfy2v0fXjFlmok4+i8ul/6WlbVge9bhM74OpNPQPMGUToDtz+KXa1PneJxOA==", + "integrity": "sha1-p0cPnkJnM9gb2B4RVSZOOjUHyrQ=", "requires": { "is-plain-object": "2.0.4" } @@ -8138,7 +8138,7 @@ "multibase": { "version": "0.4.0", "resolved": "https://registry.npmjs.org/multibase/-/multibase-0.4.0.tgz", - "integrity": "sha512-fnYvZJWDn3eSJ7EeWvS8zbOpRwuyPHpDggSnqGXkQMvYED5NdO9nyqnZboGvAT+r/60J8KZ09tW8YJHkS22sFw==", + "integrity": "sha1-G9tiyC3gEU+CKh2HUby+6RzS77o=", "requires": { "base-x": "3.0.4" } @@ -8146,7 +8146,7 @@ "multicodec": { "version": "0.2.6", "resolved": "https://registry.npmjs.org/multicodec/-/multicodec-0.2.6.tgz", - "integrity": "sha512-VGyRUDkxdJzWnj9x3C49MzI3+TtKKDYNfIBOaWBCNuPk6CE5CwwkL15gJtsLDfLay0fL4xTh4Af3kBbJSxSppw==", + "integrity": "sha1-nS1lZfvAgVsTnfyQY3H8Od9N/ds=", "requires": { "varint": "5.0.0" } @@ -8154,7 +8154,7 @@ "multihashes": { "version": "0.4.13", "resolved": "https://registry.npmjs.org/multihashes/-/multihashes-0.4.13.tgz", - "integrity": "sha512-HwJGEKPCpLlNlgGQA56CYh/Wsqa+c4JAq8+mheIgw7OK5T4QvNJqgp6TH8gZ4q4l1aiWeNat/H/MrFXmTuoFfQ==", + "integrity": "sha1-0QvXG9UdJKqJTipvFFcUa7e6wSU=", "requires": { "bs58": "4.0.1", "varint": "5.0.0" @@ -8163,7 +8163,7 @@ "multihashing-async": { "version": "0.4.8", "resolved": "https://registry.npmjs.org/multihashing-async/-/multihashing-async-0.4.8.tgz", - "integrity": "sha512-LCc4lfxmTJOHKIjZjFNgvmfB6nXS/ErLInT9uwU8udFrRm2PH+aTPk3mfCREKmCiSHOlCWiv2O8rlnBx+OjlMw==", + "integrity": "sha1-QVcrJaj8aOsxi4ViQJ/dchpyfqE=", "requires": { "async": "2.6.0", "blakejs": "1.1.0", @@ -8222,7 +8222,7 @@ "nanomatch": { "version": "1.2.9", "resolved": "https://registry.npmjs.org/nanomatch/-/nanomatch-1.2.9.tgz", - "integrity": "sha512-n8R9bS8yQ6eSXaV6jHUpKzD8gLsin02w1HSFiegwrs9E098Ylhw5jdyKPaYqvHknHaSCKTPp7C8dGCQ0q9koXA==", + "integrity": "sha1-h59xUMstq3pHElkGbBBO7m4Pp8I=", "requires": { "arr-diff": "4.0.0", "array-unique": "0.3.2", @@ -8521,7 +8521,7 @@ "normalize-package-data": { "version": "2.4.0", "resolved": "https://registry.npmjs.org/normalize-package-data/-/normalize-package-data-2.4.0.tgz", - "integrity": "sha512-9jjUFbTPfEy3R/ad/2oNbKtW9Hgovl5O1FvFWKkKblNXoN/Oou6+9+KKohPK13Yc3/TyunyWhJp6gvRNR/PPAw==", + "integrity": "sha1-EvlaMH1YNSB1oEkHuErIvpisAS8=", "requires": { "hosted-git-info": "2.6.0", "is-builtin-module": "1.0.0", @@ -8890,7 +8890,7 @@ "p-limit": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-1.2.0.tgz", - "integrity": "sha512-Y/OtIaXtUPr4/YpMv1pCL5L5ed0rumAaAeBSj12F+bSlMdys7i8oQF/GUJmfpTS/QoaRrS/k6pma29haJpsMng==", + "integrity": "sha1-DpK2vty1nwIsE9DxlJ3ILRWQnxw=", "requires": { "p-try": "1.0.0" } @@ -9069,7 +9069,7 @@ "peer-info": { "version": "0.11.6", "resolved": "https://registry.npmjs.org/peer-info/-/peer-info-0.11.6.tgz", - "integrity": "sha512-xrVNiAF1IhVJNGEg5P2UQN+subaEkszT8YkC3zdy06MK0vTH3cMHB+HH+ZURkoSLssc3HbK58ecXeKpQ/4zq5w==", + "integrity": "sha1-BICwAw0t+P1PCYebJppxWyvSuhI=", "requires": { "lodash.uniqby": "4.7.0", "multiaddr": "3.0.2", @@ -9152,7 +9152,7 @@ "postcss": { "version": "5.2.18", "resolved": "https://registry.npmjs.org/postcss/-/postcss-5.2.18.tgz", - "integrity": "sha512-zrUjRRe1bpXKsX1qAJNJjqZViErVuyEkMTRrwu4ud4sbTtIBRmtaYDrHmcGgmrbsW3MHfmtIf+vJumgQn+PrXg==", + "integrity": "sha1-ut+hSX1GJE9jkPWLMZgw2RB4U8U=", "requires": { "chalk": "1.1.3", "js-base64": "2.4.3", @@ -9336,7 +9336,7 @@ "ansi-styles": { "version": "3.2.1", "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.1.tgz", - "integrity": "sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==", + "integrity": "sha1-QfuyAkPlCxK+DwS43tvwdSDOhB0=", "requires": { "color-convert": "1.9.1" } @@ -9369,7 +9369,7 @@ "source-map": { "version": "0.6.1", "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", - "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==" + "integrity": "sha1-dHIq8y6WFOnCh6jQu95IteLxomM=" }, "supports-color": { "version": "5.3.0", @@ -9393,7 +9393,7 @@ "ansi-styles": { "version": "3.2.1", "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.1.tgz", - "integrity": "sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==", + "integrity": "sha1-QfuyAkPlCxK+DwS43tvwdSDOhB0=", "requires": { "color-convert": "1.9.1" } @@ -9426,7 +9426,7 @@ "source-map": { "version": "0.6.1", "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", - "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==" + "integrity": "sha1-dHIq8y6WFOnCh6jQu95IteLxomM=" }, "supports-color": { "version": "5.3.0", @@ -9450,7 +9450,7 @@ "ansi-styles": { "version": "3.2.1", "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.1.tgz", - "integrity": "sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==", + "integrity": "sha1-QfuyAkPlCxK+DwS43tvwdSDOhB0=", "requires": { "color-convert": "1.9.1" } @@ -9483,7 +9483,7 @@ "source-map": { "version": "0.6.1", "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", - "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==" + "integrity": "sha1-dHIq8y6WFOnCh6jQu95IteLxomM=" }, "supports-color": { "version": "5.3.0", @@ -9507,7 +9507,7 @@ "ansi-styles": { "version": "3.2.1", "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.1.tgz", - "integrity": "sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==", + "integrity": "sha1-QfuyAkPlCxK+DwS43tvwdSDOhB0=", "requires": { "color-convert": "1.9.1" } @@ -9540,7 +9540,7 @@ "source-map": { "version": "0.6.1", "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", - "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==" + "integrity": "sha1-dHIq8y6WFOnCh6jQu95IteLxomM=" }, "supports-color": { "version": "5.3.0", @@ -9687,7 +9687,7 @@ "private": { "version": "0.1.8", "resolved": "https://registry.npmjs.org/private/-/private-0.1.8.tgz", - "integrity": "sha512-VvivMrbvd2nKkiG38qjULzlc+4Vx4wm/whI9pQD35YrARNnhxeiRktSOhSukRLFNlzg6Br/cJPet5J/u19r/mg==" + "integrity": "sha1-I4Hts2ifelPWUxkAYPz4ItLzaP8=" }, "process": { "version": "0.11.10", @@ -9697,7 +9697,7 @@ "process-nextick-args": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.0.tgz", - "integrity": "sha512-MtEC1TqN0EU5nephaJ4rAtThHtC86dNN9qCuEhtshvpVBkAW5ZO7BASN9REnF9eoXGcRub+pFuKEpOHE+HbEMw==" + "integrity": "sha1-o31zL0JxtKsa0HDTVQjoKQeI/6o=" }, "progress": { "version": "2.0.0", @@ -9725,7 +9725,7 @@ "promisify-es6": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/promisify-es6/-/promisify-es6-1.0.3.tgz", - "integrity": "sha512-N9iVG+CGJsI4b4ZGazjwLnxErD2d9Pe4DPvvXSxYA9tFNu8ymXME4Qs5HIQ0LMJpNM7zj+m0NlNnNeqFpKzqnA==" + "integrity": "sha1-sBJmjE3zyWXOE9qsKzpNFyapY0Y=" }, "promptly": { "version": "2.2.0", @@ -9746,12 +9746,12 @@ "protocol-buffers-schema": { "version": "3.3.2", "resolved": "https://registry.npmjs.org/protocol-buffers-schema/-/protocol-buffers-schema-3.3.2.tgz", - "integrity": "sha512-Xdayp8sB/mU+sUV4G7ws8xtYMGdQnxbeIfLjyO9TZZRJdztBGhlmbI5x1qcY4TG5hBkIKGnc28i7nXxaugu88w==" + "integrity": "sha1-AENPYItOjfVMWeBw7+78N/tLuFk=" }, "protons": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/protons/-/protons-1.0.1.tgz", - "integrity": "sha512-+0ZKnfVs+4c43tbAQ5j0Mck8wPcLnlxUYzKQoB4iDW4ocdXGnN4P+0dDbgX1FTpoY9+7P2Tn2scJyHHqj+S/lQ==", + "integrity": "sha1-HBBxRMB/wtHLi2y3ZFHmqTgjdnY=", "requires": { "protocol-buffers-schema": "3.3.2", "safe-buffer": "5.1.1", @@ -9813,7 +9813,7 @@ "pump": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/pump/-/pump-1.0.3.tgz", - "integrity": "sha512-8k0JupWme55+9tCVE+FS5ULT3K6AbgqrGa58lTT49RpyfwwcGedHqaC5LlQNdEAumn/wFsu6aPwkuPMioy8kqw==", + "integrity": "sha1-Xf6DEcM7v2/BgmH580cCxHwIqVQ=", "requires": { "end-of-stream": "1.4.1", "once": "1.4.0" @@ -9893,7 +9893,7 @@ "randombytes": { "version": "2.0.6", "resolved": "https://registry.npmjs.org/randombytes/-/randombytes-2.0.6.tgz", - "integrity": "sha512-CIQ5OFxf4Jou6uOKe9t1AOgqpeU5fd70A8NPdHSGeYXqXsPe6peOwI0cUl88RWZ6sP1vPMV3avd/R6cZ5/sP1A==", + "integrity": "sha1-0wLFIpSFiISKjTAMkytEwkIx2oA=", "requires": { "safe-buffer": "5.1.1" } @@ -9901,7 +9901,7 @@ "randomfill": { "version": "1.0.4", "resolved": "https://registry.npmjs.org/randomfill/-/randomfill-1.0.4.tgz", - "integrity": "sha512-87lcbR8+MhcWcUiQ+9e+Rwx8MyR2P7qnt15ynUlbm3TU/fjbgz4GsvfSUDTemtCCtVCqb4ZcEFlyPNTh9bBTLw==", + "integrity": "sha1-ySGW/IarQr6YPxvzF3giSTHWFFg=", "requires": { "randombytes": "2.0.6", "safe-buffer": "5.1.1" @@ -10090,12 +10090,12 @@ "regenerator-runtime": { "version": "0.11.1", "resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.11.1.tgz", - "integrity": "sha512-MguG95oij0fC3QV3URf4V2SDYGJhJnJGqvIIgdECeODCT98wSWDAJ94SSuVpYQUoTcGUIL6L4yNB7j1DFFHSBg==" + "integrity": "sha1-vgWtf5v30i4Fb5cmzuUBf78Z4uk=" }, "regenerator-transform": { "version": "0.10.1", "resolved": "https://registry.npmjs.org/regenerator-transform/-/regenerator-transform-0.10.1.tgz", - "integrity": "sha512-PJepbvDbuK1xgIgnau7Y90cwaAmO/LCLMI2mPvaXq2heGMR3aWW5/BQvYrhJ8jgmQjXewXvBjzfqKcVOmhjZ6Q==", + "integrity": "sha1-HkmWg3Ix2ot/PPQRTXG1aRoGgN0=", "requires": { "babel-runtime": "6.26.0", "babel-types": "6.26.0", @@ -10105,7 +10105,7 @@ "regex-cache": { "version": "0.4.4", "resolved": "https://registry.npmjs.org/regex-cache/-/regex-cache-0.4.4.tgz", - "integrity": "sha512-nVIZwtCjkC9YgvWkpM55B5rBhBYRZhAaJbgcFYXXsHnbZ9UZI9nnVWYZpBlCqv9ho2eZryPnWrZGsOdPwVWXWQ==", + "integrity": "sha1-db3FiioUls7EihKDW8VMjVYjNt0=", "requires": { "is-equal-shallow": "0.1.3" } @@ -10113,7 +10113,7 @@ "regex-not": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/regex-not/-/regex-not-1.0.2.tgz", - "integrity": "sha512-J6SDjUgDxQj5NusnOtdFxDwN/+HWykR8GELwctJ7mdqhcyy1xEc4SRFHUXvxTp661YaVKAjfRLZ9cCqS6tn32A==", + "integrity": "sha1-H07OJ+ALC2XgJHpoEOaoXYOldSw=", "requires": { "extend-shallow": "3.0.2", "safe-regex": "1.1.0" @@ -10302,7 +10302,7 @@ "ret": { "version": "0.1.15", "resolved": "https://registry.npmjs.org/ret/-/ret-0.1.15.tgz", - "integrity": "sha512-TTlYpa+OL+vMMNG24xSlQGEJ3B/RzEfUlLct7b5G/ytav+wPrplCpVMFuwzXbkecJrb6IYo1iFb0S9v37754mg==" + "integrity": "sha1-uKSCXVvbH8P29Twrwz+BOIaBx7w=" }, "right-align": { "version": "0.1.3", @@ -10315,7 +10315,7 @@ "rimraf": { "version": "2.6.2", "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.6.2.tgz", - "integrity": "sha512-lreewLK/BlghmxtfH36YYVg1i8IAce4TI7oao75I1g245+6BctqTVQiBP3YUJ9C6DQOXJmkYR9X9fCLtCOJc5w==", + "integrity": "sha1-LtgVDSShbqhlHm1u8PR8QVjOejY=", "requires": { "glob": "7.1.2" } @@ -10431,7 +10431,7 @@ "sax": { "version": "1.2.4", "resolved": "https://registry.npmjs.org/sax/-/sax-1.2.4.tgz", - "integrity": "sha512-NqVDv9TpANUjFm0N8uM5GxL36UgKi9/atZw+x7YFnQ8ckwFGKrl4xX4yWtrey3UJm5nP1kUbnYgLopqWNSRhWw==" + "integrity": "sha1-KBYjTiN4vdxOU1T6tcqold9xANk=" }, "scandirectory": { "version": "2.5.0", @@ -10446,7 +10446,7 @@ "schema-utils": { "version": "0.4.5", "resolved": "https://registry.npmjs.org/schema-utils/-/schema-utils-0.4.5.tgz", - "integrity": "sha512-yYrjb9TX2k/J1Y5UNy3KYdZq10xhYcF8nMpAW6o3hy6Q8WSIEf9lJHG/ePnOBfziPM3fvQwfOwa13U/Fh8qTfA==", + "integrity": "sha1-IYNvBgiqwXt4+ePiTa/xSlyhOj4=", "requires": { "ajv": "6.2.1", "ajv-keywords": "3.1.0" @@ -10485,7 +10485,7 @@ "secp256k1": { "version": "3.5.0", "resolved": "https://registry.npmjs.org/secp256k1/-/secp256k1-3.5.0.tgz", - "integrity": "sha512-e5QIJl8W7Y4tT6LHffVcZAxJjvpgE5Owawv6/XCYPQljE9aP2NFFddQ8OYMKhdLshNu88FfL3qCN3/xYkXGRsA==", + "integrity": "sha1-Z307io4E4aX6OBoa5DfFQge3ONA=", "requires": { "bindings": "1.3.0", "bip66": "1.1.5", @@ -10523,12 +10523,12 @@ "semver": { "version": "5.5.0", "resolved": "https://registry.npmjs.org/semver/-/semver-5.5.0.tgz", - "integrity": "sha512-4SJ3dm0WAwWy/NVeioZh5AntkdJoWKxHxcmyP622fOkgHa4z3R0TdBJICINyaSDE6uNwVc8gZr+ZinwZAH4xIA==" + "integrity": "sha1-3Eu8emyp2Rbe5dQ1FvAJK1j3uKs=" }, "send": { "version": "0.16.2", "resolved": "https://registry.npmjs.org/send/-/send-0.16.2.tgz", - "integrity": "sha512-E64YFPUssFHEFBvpbbjr44NCLtI1AohxQ8ZSiJjQLskAdKuriYEP6VyGEsRDH8ScozGpkaX1BGvhanqCwkcEZw==", + "integrity": "sha1-bsyh4PjBVtFBWXVZhI32RzCmu8E=", "requires": { "debug": "2.6.9", "depd": "1.1.2", @@ -10555,7 +10555,7 @@ "serve-static": { "version": "1.13.2", "resolved": "https://registry.npmjs.org/serve-static/-/serve-static-1.13.2.tgz", - "integrity": "sha512-p/tdJrO4U387R9oMjb1oj7qSMaMfmOyd4j9hOFoxZe2baQszgHcSWjuya/CiT5kgZZKRudHNOA0pYXOl8rQ5nw==", + "integrity": "sha1-CV6Ecv1bRiN9tQzkhqQ/S4bGzsE=", "requires": { "encodeurl": "1.0.2", "escape-html": "1.0.3", @@ -10588,7 +10588,7 @@ "set-value": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/set-value/-/set-value-2.0.0.tgz", - "integrity": "sha512-hw0yxk9GT/Hr5yJEYnHNKYXkIA8mVJgd9ditYZCe16ZczcaELYYcfvaXesNACk2O8O0nTiPQcQhGUQj8JLzeeg==", + "integrity": "sha1-ca5KiPD+77v1LR6mBPP7MV67YnQ=", "requires": { "extend-shallow": "2.0.1", "is-extendable": "0.1.1", @@ -10762,7 +10762,7 @@ "snapdragon": { "version": "0.8.2", "resolved": "https://registry.npmjs.org/snapdragon/-/snapdragon-0.8.2.tgz", - "integrity": "sha512-FtyOnWN/wCHTVXOMwvSv26d+ko5vWlIDD6zoUJ7LW8vh+ZBC8QdljveRP+crNrtBwioEUWy/4dMtbBjA4ioNlg==", + "integrity": "sha1-ZJIufFZbDhQgS6GqfWlkJ40lGC0=", "requires": { "base": "0.11.2", "debug": "2.6.9", @@ -10846,7 +10846,7 @@ "snapdragon-node": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/snapdragon-node/-/snapdragon-node-2.1.1.tgz", - "integrity": "sha512-O27l4xaMYt/RSQ5TR3vpWCAB5Kb/czIcqUFOM/C4fYcLnbZUc1PkjTAMjof2pBWaSTwOUd6qUHcFGVGj7aIwnw==", + "integrity": "sha1-bBdfhv8UvbByRWPo88GwIaKGhTs=", "requires": { "define-property": "1.0.0", "isobject": "3.0.1", @@ -10871,7 +10871,7 @@ "snapdragon-util": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/snapdragon-util/-/snapdragon-util-3.0.1.tgz", - "integrity": "sha512-mbKkMdQKsjX4BAL4bRYTj21edOf8cN7XHdYUJEe+Zn99hVEYcMvKPct1IqNe7+AZPirn8BCDOQBHQZknqmKlZQ==", + "integrity": "sha1-+VZHlIbyrNeXAGk/b3uAXkWrVuI=", "requires": { "kind-of": "3.2.2" } @@ -11073,7 +11073,7 @@ "source-list-map": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/source-list-map/-/source-list-map-2.0.0.tgz", - "integrity": "sha512-I2UmuJSRr/T8jisiROLU3A3ltr+swpniSmNPI4Ml3ZCX6tVnDsuZzK7F2hl5jTqbZBWCEKlj5HRQiPExXLgE8A==" + "integrity": "sha1-qqR0A/eyRakvvJfqCPJQ1gh+0IU=" }, "source-map": { "version": "0.5.7", @@ -11095,7 +11095,7 @@ "source-map-support": { "version": "0.4.18", "resolved": "https://registry.npmjs.org/source-map-support/-/source-map-support-0.4.18.tgz", - "integrity": "sha512-try0/JqxPLF9nOjvSta7tVondkP5dwgyLDjVoyMDlmjugT2lRZ1OfsrYTkCd2hkDnJTKRbO/Rl3orm8vlsUzbA==", + "integrity": "sha1-Aoam3ovkJkEzhZTpfM6nXwosWF8=", "requires": { "source-map": "0.5.7" } @@ -11108,7 +11108,7 @@ "spdx-correct": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/spdx-correct/-/spdx-correct-3.0.0.tgz", - "integrity": "sha512-N19o9z5cEyc8yQQPukRCZ9EUmb4HUpnrmaL/fxS2pBo2jbfcFRVuFZ/oFC+vZz0MNNk0h80iMn5/S6qGZOL5+g==", + "integrity": "sha1-BaW01xU6GVvJLDxCW2nzsqlSTII=", "requires": { "spdx-expression-parse": "3.0.0", "spdx-license-ids": "3.0.0" @@ -11117,12 +11117,12 @@ "spdx-exceptions": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/spdx-exceptions/-/spdx-exceptions-2.1.0.tgz", - "integrity": "sha512-4K1NsmrlCU1JJgUrtgEeTVyfx8VaYea9J9LvARxhbHtVtohPs/gFGG5yy49beySjlIMhhXZ4QqujIZEfS4l6Cg==" + "integrity": "sha1-LHrmEFbHFKW5ubKyr30xHvXHj+k=" }, "spdx-expression-parse": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/spdx-expression-parse/-/spdx-expression-parse-3.0.0.tgz", - "integrity": "sha512-Yg6D3XpRD4kkOmTpdgbUiEJFKghJH03fiC1OPll5h/0sO6neh2jqRDVHOQ4o/LMea0tgCkbMgea5ip/e+MkWyg==", + "integrity": "sha1-meEZt6XaAOBUkcn6M4t5BII7QdA=", "requires": { "spdx-exceptions": "2.1.0", "spdx-license-ids": "3.0.0" @@ -11131,12 +11131,12 @@ "spdx-license-ids": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/spdx-license-ids/-/spdx-license-ids-3.0.0.tgz", - "integrity": "sha512-2+EPwgbnmOIl8HjGBXXMd9NAu02vLjOO1nWw4kmeRDFyHn+M/ETfHxQUK0oXg8ctgVnl9t3rosNVsZ1jG61nDA==" + "integrity": "sha1-enzShHDMbToc/m1miG9rxDDTrIc=" }, "split-string": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/split-string/-/split-string-3.1.0.tgz", - "integrity": "sha512-NzNVhJDYpwceVVii8/Hu6DKfD2G+NrQHlS/V/qgv763EYudVwEcMQNxd2lh+0VrUByXN/oJkl5grOhYWvQUYiw==", + "integrity": "sha1-fLCd2jqGWFcFxks5pkZgOGguj+I=", "requires": { "extend-shallow": "3.0.2" } @@ -11144,7 +11144,7 @@ "split2": { "version": "2.2.0", "resolved": "https://registry.npmjs.org/split2/-/split2-2.2.0.tgz", - "integrity": "sha512-RAb22TG39LhI31MbreBgIuKiIKhVsawfTgEGqKHTK87aG+ul/PB8Sqoi3I7kVdRWiCfrKxK3uo4/YUkpNvhPbw==", + "integrity": "sha1-GGsldbz4PoW30YRldWI47k7kJJM=", "requires": { "through2": "2.0.3" } @@ -11320,7 +11320,7 @@ "string-width": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/string-width/-/string-width-2.1.1.tgz", - "integrity": "sha512-nOqH59deCq9SRHlxq1Aw85Jnt4w6KvLKqWVik6oA9ZklXLNIOlqg4F2yrT1MVaTjAqvVwdfeZ7w7aCvJD7ugkw==", + "integrity": "sha1-q5Pyeo3BPSjKyBXEYhQ6bZASrp4=", "requires": { "is-fullwidth-code-point": "2.0.0", "strip-ansi": "4.0.0" @@ -11439,7 +11439,7 @@ "style-loader": { "version": "0.19.1", "resolved": "https://registry.npmjs.org/style-loader/-/style-loader-0.19.1.tgz", - "integrity": "sha512-IRE+ijgojrygQi3rsqT0U4dd+UcPCqcVvauZpCnQrGAlEe+FUIyrK93bUDScamesjP08JlQNsFJU+KmPedP5Og==", + "integrity": "sha1-WR/8gLzv4mi3fF2evAUF13Jhn4U=", "requires": { "loader-utils": "1.1.0", "schema-utils": "0.3.0" @@ -11651,7 +11651,7 @@ "tar": { "version": "3.2.1", "resolved": "https://registry.npmjs.org/tar/-/tar-3.2.1.tgz", - "integrity": "sha512-ZSzds1E0IqutvMU8HxjMaU8eB7urw2fGwTq88ukDOVuUIh0656l7/P7LiVPxhO5kS4flcRJQk8USG+cghQbTUQ==", + "integrity": "sha1-mqjkHIjwnnbBZgdbxx+T1RZuYbE=", "requires": { "chownr": "1.0.1", "minipass": "2.2.1", @@ -11820,7 +11820,7 @@ "to-regex": { "version": "3.0.2", "resolved": "https://registry.npmjs.org/to-regex/-/to-regex-3.0.2.tgz", - "integrity": "sha512-FWtleNAtZ/Ki2qtqej2CXTOayOH9bHDQF+Q48VpWyDXjbYxA4Yz8iDB31zXOBUlOHHKidDbqGVrTUvQMPmBGBw==", + "integrity": "sha1-E8/dmzNlUvMLUfM6iuG0Knp1mc4=", "requires": { "define-property": "2.0.2", "extend-shallow": "3.0.2", @@ -11941,7 +11941,7 @@ "typedarray-to-buffer": { "version": "3.1.5", "resolved": "https://registry.npmjs.org/typedarray-to-buffer/-/typedarray-to-buffer-3.1.5.tgz", - "integrity": "sha512-zdu8XMNEDepKKR+XYOXAVPtWui0ly0NtohUscw+UmaHiAWT8hrV1rr//H6V+0DvJ3OQ19S979M0laLfX8rm82Q==", + "integrity": "sha1-qX7nqf9CaRufeD/xvFES/j/KkIA=", "requires": { "is-typedarray": "1.0.0" } @@ -12186,7 +12186,7 @@ "url-loader": { "version": "0.6.2", "resolved": "https://registry.npmjs.org/url-loader/-/url-loader-0.6.2.tgz", - "integrity": "sha512-h3qf9TNn53BpuXTTcpC+UehiRrl0Cv45Yr/xWayApjw6G8Bg2dGke7rIwDQ39piciWCWrC+WiqLjOh3SUp9n0Q==", + "integrity": "sha1-oAenEJYg6dmI0UvOZ3od7Lmpk/c=", "requires": { "loader-utils": "1.1.0", "mime": "1.4.1", @@ -12235,7 +12235,7 @@ "use": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/use/-/use-3.1.0.tgz", - "integrity": "sha512-6UJEQM/L+mzC3ZJNM56Q4DFGLX/evKGRg15UJHGB9X5j5Z3AFbgZvjUh2yq/UJUY4U5dh7Fal++XbNg1uzpRAw==", + "integrity": "sha1-FHFr8D/f79AwQK71jYtLhfOnxUQ=", "requires": { "kind-of": "6.0.2" }, @@ -12290,7 +12290,7 @@ "validate-npm-package-license": { "version": "3.0.3", "resolved": "https://registry.npmjs.org/validate-npm-package-license/-/validate-npm-package-license-3.0.3.tgz", - "integrity": "sha512-63ZOUnL4SIXj4L0NixR3L1lcjO38crAbgrTpl28t8jjrfuiOBL5Iygm+60qPs/KsZGzPNg6Smnc/oY16QTjF0g==", + "integrity": "sha1-gWQ7y+8b3+zUYjeT3EZIlIupgzg=", "requires": { "spdx-correct": "3.0.0", "spdx-expression-parse": "3.0.0" @@ -13296,7 +13296,7 @@ "which": { "version": "1.3.0", "resolved": "https://registry.npmjs.org/which/-/which-1.3.0.tgz", - "integrity": "sha512-xcJpopdamTuY5duC/KnTTNBraPK54YwpenP4lzxU8H91GudWpFv38u0CKjclE1Wi2EH2EDz5LRcHcKbCIzqGyg==", + "integrity": "sha1-/wS9/AEO5UfXgL7DjhrBwnd9JTo=", "requires": { "isexe": "2.0.0" } From 0214447476be544e386719cff111e199af2bc10c Mon Sep 17 00:00:00 2001 From: Jonathan Rainville Date: Fri, 8 Jun 2018 11:20:14 -0400 Subject: [PATCH 28/32] tigger build --- lib/pipeline/pipeline.js | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/pipeline/pipeline.js b/lib/pipeline/pipeline.js index 544e1d26..ca61b515 100644 --- a/lib/pipeline/pipeline.js +++ b/lib/pipeline/pipeline.js @@ -252,7 +252,6 @@ class Pipeline { } ], cb); } - } module.exports = Pipeline; From 1b6ac99ea2b558706d0419597f46452378be2184 Mon Sep 17 00:00:00 2001 From: Iuri Matias Date: Fri, 8 Jun 2018 12:30:44 -0400 Subject: [PATCH 29/32] remove listeners to avoid leaks --- lib/tests/test.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/lib/tests/test.js b/lib/tests/test.js index 0e883686..ac1a219f 100644 --- a/lib/tests/test.js +++ b/lib/tests/test.js @@ -33,6 +33,7 @@ class Test { this.contracts = {}; this.events = new Events(); this.ready = true; + this.error = false; this.builtContracts = {}; this.compiledContracts = {}; @@ -111,13 +112,19 @@ class Test { } onReady(callback) { + const self = this; if (this.ready) { return callback(); } + if (this.error) { + return callback(this.error); + } this.events.once('ready', () => { + self.events.removeListener('deployError', () => {}); callback(); }); this.events.once('deployError', (err) => { + self.events.removeListener('ready', () => {}); callback(err); }); } @@ -180,9 +187,11 @@ class Test { self._deploy(options, (err, accounts) => { if (err) { self.events.emit('deployError', err); + self.error = err; return next(err); } self.ready = true; + self.error = false; self.events.emit('ready'); next(null, accounts); }); From cdfa30ebd2edc9e00ca9f9a95bc2a4b10e256737 Mon Sep 17 00:00:00 2001 From: Iuri Matias Date: Fri, 8 Jun 2018 12:51:04 -0400 Subject: [PATCH 30/32] remove listeners correctly --- lib/tests/test.js | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/lib/tests/test.js b/lib/tests/test.js index ac1a219f..a6789da9 100644 --- a/lib/tests/test.js +++ b/lib/tests/test.js @@ -119,14 +119,21 @@ class Test { if (this.error) { return callback(this.error); } - this.events.once('ready', () => { - self.events.removeListener('deployError', () => {}); - callback(); - }); - this.events.once('deployError', (err) => { - self.events.removeListener('ready', () => {}); + + let errorCallback, readyCallback; + + errorCallback = (err) => { + self.events.removeListener('ready', readyCallback); callback(err); - }); + }; + + readyCallback = () => { + self.events.removeListener('deployError', errorCallback); + callback(); + }; + + this.events.once('ready', readyCallback); + this.events.once('deployError', errorCallback); } config(options, callback) { From 9f18c7ff0e9a852d7431f637aeff101caf254416 Mon Sep 17 00:00:00 2001 From: Iuri Matias Date: Fri, 8 Jun 2018 13:10:47 -0400 Subject: [PATCH 31/32] add test for balance and web3 object --- test_apps/test_app/test/another_storage_spec.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/test_apps/test_app/test/another_storage_spec.js b/test_apps/test_app/test/another_storage_spec.js index f0ea1b92..8ebc9e3f 100644 --- a/test_apps/test_app/test/another_storage_spec.js +++ b/test_apps/test_app/test/another_storage_spec.js @@ -29,6 +29,12 @@ config({ contract("AnotherStorage", function() { this.timeout(0); + it("should have account with balance", async function() { + let balance = await web3.eth.getBalance(accounts[0]); + assert.ok(parseInt(balance, 10) > 4900000000000000000); + assert.ok(parseInt(balance, 10) <= 5000000000000000000); + }); + it("set SimpleStorage address", async function() { let result = await AnotherStorage.methods.simpleStorageAddress().call(); assert.equal(result.toString(), SimpleStorage.options.address); From c6e63af12de5cd5ee15afe4ddfd99b23020b90d4 Mon Sep 17 00:00:00 2001 From: Iuri Matias Date: Fri, 8 Jun 2018 13:55:24 -0400 Subject: [PATCH 32/32] remove unneded param --- lib/core/engine.js | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/core/engine.js b/lib/core/engine.js index cfd6fdf2..28640f0d 100644 --- a/lib/core/engine.js +++ b/lib/core/engine.js @@ -252,7 +252,6 @@ class Engine { storageService(_options) { this.registerModule('storage', { - addCheck: this.servicesMonitor.addCheck.bind(this.servicesMonitor), storageConfig: this.config.storageConfig, webServerConfig: this.config.webServerConfig, blockchainConfig: this.config.blockchainConfig,