swarm adjustements

This commit is contained in:
Jonathan Rainville 2018-07-30 15:49:58 -04:00 committed by Iuri Matias
parent 52462dbd3c
commit 0204eb6d46
6 changed files with 24 additions and 7 deletions

View File

@ -394,7 +394,9 @@ class Embark {
engine.startService("deployment"); engine.startService("deployment");
engine.startService("storage"); engine.startService("storage");
engine.startService("codeGenerator"); engine.startService("codeGenerator");
engine.startService("namingSystem"); if(options.ensDomain) {
engine.startService("namingSystem");
}
callback(); callback();
}, },
function listLoadedPlugin(callback) { function listLoadedPlugin(callback) {
@ -434,8 +436,11 @@ class Embark {
} }
], function (err) { ], function (err) {
if (err) { if (err) {
engine.logger.error(err.message); if (err.message) {
engine.logger.debug(err.stack); engine.logger.error(err.message);
return engine.logger.debug(err.stack);
}
engine.locale.error(err);
} else { } else {
engine.logger.info((__("finished building DApp and deploying to") + " " + platform).underline); engine.logger.info((__("finished building DApp and deploying to") + " " + platform).underline);
} }

View File

@ -20,7 +20,6 @@ class BlockchainModule {
registerBlockchainProcess() { registerBlockchainProcess() {
const self = this; const self = this;
this.events.request('processes:register', 'blockchain', (cb) => { this.events.request('processes:register', 'blockchain', (cb) => {
console.dir("gonna check node connection");
self.assertNodeConnection(true, (connected) => { self.assertNodeConnection(true, (connected) => {
if (connected) return cb(); if (connected) return cb();
self.startBlockchainNode(cb); self.startBlockchainNode(cb);

View File

@ -77,11 +77,18 @@ class ENS {
// Convert IPFS multihash to 32 byte hex string // Convert IPFS multihash to 32 byte hex string
let contentHash; let contentHash;
if (utils.isHex(storageHash)) {
contentHash = storageHash;
} else {
try { try {
contentHash = ENS.hashTo32ByteHexString(storageHash); contentHash = ENS.hashTo32ByteHexString(storageHash);
} catch(e) { } catch(e) {
return cb('Invalid IPFS hash'); return cb('Invalid IPFS hash');
} }
}
if (!contentHash.startsWith('0x')) {
contentHash = '0x' + contentHash;
}
// Set content // Set content
async.waterfall([ async.waterfall([
@ -128,7 +135,7 @@ class ENS {
function setContent(resolver, defaultAccount, next) { function setContent(resolver, defaultAccount, next) {
resolver.methods.setContent(hashedName, contentHash).send({from: defaultAccount}).then((transaction) => { resolver.methods.setContent(hashedName, contentHash).send({from: defaultAccount}).then((transaction) => {
if (transaction.status !== "0x1" && transaction.status !== "0x01" && transaction.status !== true) { 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(); next();
}).catch(next); }).catch(next);

View File

@ -31,7 +31,7 @@ class Swarm {
this.setServiceCheck(); this.setServiceCheck();
this.addProviderToEmbarkJS(); this.addProviderToEmbarkJS();
this.startProcess(() => {}); //this.startProcess(() => {});
this.registerUploadCommand(); this.registerUploadCommand();
this._checkService((err) => { this._checkService((err) => {

View File

@ -24,7 +24,7 @@ class SwarmProcess extends ProcessWrapper {
`--password=${fs.dappPath(this.storageConfig.account.password)}`, `--password=${fs.dappPath(this.storageConfig.account.password)}`,
`--corsdomain=${self.cors.join(',')}` `--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 = child_process.spawn(this.command, args);
this.child.on('error', (err) => { this.child.on('error', (err) => {

View File

@ -255,6 +255,11 @@ function hexToNumber(hex){
return Web3.utils.hexToNumber(hex); return Web3.utils.hexToNumber(hex);
} }
function isHex(hex){
const Web3 = require('web3');
return Web3.utils.isHex(hex);
}
function decodeParams(typesArray, hexString){ function decodeParams(typesArray, hexString){
var Web3EthAbi = require('web3-eth-abi'); var Web3EthAbi = require('web3-eth-abi');
return Web3EthAbi.decodeParameters(typesArray, hexString); return Web3EthAbi.decodeParameters(typesArray, hexString);
@ -421,6 +426,7 @@ module.exports = {
httpsGetJson, httpsGetJson,
getJson, getJson,
hexToNumber, hexToNumber,
isHex,
pingEndpoint, pingEndpoint,
decodeParams, decodeParams,
runCmd, runCmd,