From 0204eb6d46145f5c37758ea54e22ab1b73f69129 Mon Sep 17 00:00:00 2001 From: Jonathan Rainville Date: Mon, 30 Jul 2018 15:49:58 -0400 Subject: [PATCH] swarm adjustements --- lib/index.js | 11 ++++++++--- lib/modules/blockchain_process/index.js | 1 - lib/modules/ens/index.js | 9 ++++++++- lib/modules/swarm/index.js | 2 +- lib/modules/swarm/process.js | 2 +- lib/utils/utils.js | 6 ++++++ 6 files changed, 24 insertions(+), 7 deletions(-) diff --git a/lib/index.js b/lib/index.js index 4f426b0df..b6ad1a0fc 100644 --- a/lib/index.js +++ b/lib/index.js @@ -394,7 +394,9 @@ class Embark { engine.startService("deployment"); engine.startService("storage"); engine.startService("codeGenerator"); - engine.startService("namingSystem"); + if(options.ensDomain) { + engine.startService("namingSystem"); + } callback(); }, function listLoadedPlugin(callback) { @@ -434,8 +436,11 @@ class Embark { } ], function (err) { if (err) { - engine.logger.error(err.message); - engine.logger.debug(err.stack); + if (err.message) { + engine.logger.error(err.message); + return engine.logger.debug(err.stack); + } + engine.locale.error(err); } else { engine.logger.info((__("finished building DApp and deploying to") + " " + platform).underline); } diff --git a/lib/modules/blockchain_process/index.js b/lib/modules/blockchain_process/index.js index 96c32a940..f2bb352a9 100644 --- a/lib/modules/blockchain_process/index.js +++ b/lib/modules/blockchain_process/index.js @@ -20,7 +20,6 @@ class BlockchainModule { registerBlockchainProcess() { const self = this; this.events.request('processes:register', 'blockchain', (cb) => { - console.dir("gonna check node connection"); self.assertNodeConnection(true, (connected) => { if (connected) return cb(); self.startBlockchainNode(cb); diff --git a/lib/modules/ens/index.js b/lib/modules/ens/index.js index 1b32c4a50..c9835c244 100644 --- a/lib/modules/ens/index.js +++ b/lib/modules/ens/index.js @@ -77,11 +77,18 @@ class ENS { // Convert IPFS multihash to 32 byte hex string let contentHash; + if (utils.isHex(storageHash)) { + contentHash = storageHash; + } else { try { contentHash = ENS.hashTo32ByteHexString(storageHash); } catch(e) { return cb('Invalid IPFS hash'); } + } + if (!contentHash.startsWith('0x')) { + contentHash = '0x' + contentHash; + } // Set content async.waterfall([ @@ -128,7 +135,7 @@ class ENS { function setContent(resolver, defaultAccount, next) { resolver.methods.setContent(hashedName, contentHash).send({from: defaultAccount}).then((transaction) => { if (transaction.status !== "0x1" && transaction.status !== "0x01" && transaction.status !== true) { - return next(new Error('Association failed. Status: ' + transaction.status)); + return next('Association failed. Status: ' + transaction.status); } next(); }).catch(next); diff --git a/lib/modules/swarm/index.js b/lib/modules/swarm/index.js index c479a1008..b5e02b1df 100644 --- a/lib/modules/swarm/index.js +++ b/lib/modules/swarm/index.js @@ -31,7 +31,7 @@ class Swarm { this.setServiceCheck(); this.addProviderToEmbarkJS(); - this.startProcess(() => {}); + //this.startProcess(() => {}); this.registerUploadCommand(); this._checkService((err) => { diff --git a/lib/modules/swarm/process.js b/lib/modules/swarm/process.js index 2ecf29d9c..eeb489b53 100644 --- a/lib/modules/swarm/process.js +++ b/lib/modules/swarm/process.js @@ -24,7 +24,7 @@ class SwarmProcess extends ProcessWrapper { `--password=${fs.dappPath(this.storageConfig.account.password)}`, `--corsdomain=${self.cors.join(',')}` ]; - console.trace('Starting swarm process with arguments: ' + args.join(' ')); + console.error('Starting swarm process with arguments: ' + args.join(' ')); this.child = child_process.spawn(this.command, args); this.child.on('error', (err) => { diff --git a/lib/utils/utils.js b/lib/utils/utils.js index e65601450..fe2daebc6 100644 --- a/lib/utils/utils.js +++ b/lib/utils/utils.js @@ -255,6 +255,11 @@ function hexToNumber(hex){ return Web3.utils.hexToNumber(hex); } +function isHex(hex){ + const Web3 = require('web3'); + return Web3.utils.isHex(hex); +} + function decodeParams(typesArray, hexString){ var Web3EthAbi = require('web3-eth-abi'); return Web3EthAbi.decodeParameters(typesArray, hexString); @@ -421,6 +426,7 @@ module.exports = { httpsGetJson, getJson, hexToNumber, + isHex, pingEndpoint, decodeParams, runCmd,