mirror of https://github.com/embarklabs/embark.git
Merge pull request #441 from embark-framework/ipfs_object
make Ipfs object available in environment
This commit is contained in:
commit
6bcf03adc5
|
@ -131,7 +131,7 @@ class Deploy {
|
|||
// always run contractCode so other functionality like 'afterDeploy' can also work
|
||||
let codeGenerator = new CodeGenerator({contractsManager: self.contractsManager});
|
||||
let contractCode = codeGenerator.generateContractCode(contract, self.gasLimit);
|
||||
RunCode.doEval(contractCode, self.web3);
|
||||
RunCode.doEval(contractCode, {web3: self.web3});
|
||||
|
||||
return callback();
|
||||
}
|
||||
|
@ -151,13 +151,13 @@ class Deploy {
|
|||
// always run contractCode so other functionality like 'afterDeploy' can also work
|
||||
let codeGenerator = new CodeGenerator({contractsManager: self.contractsManager});
|
||||
let contractCode = codeGenerator.generateContractCode(contract, self.gasLimit);
|
||||
RunCode.doEval(contractCode, self.web3);
|
||||
RunCode.doEval(contractCode, {web3: self.web3});
|
||||
|
||||
if (contract.onDeploy !== undefined) {
|
||||
self.logger.info(__('executing onDeploy commands'));
|
||||
|
||||
let contractCode = codeGenerator.generateContractCode(contract, self.gasLimit);
|
||||
RunCode.doEval(contractCode, self.web3);
|
||||
RunCode.doEval(contractCode, {web3: self.web3});
|
||||
|
||||
let withErrors = false;
|
||||
let regex = /\$\w+/g;
|
||||
|
@ -200,7 +200,7 @@ class Deploy {
|
|||
for(let cmd of onDeployCode) {
|
||||
self.logger.info(__("executing: ") + cmd);
|
||||
try {
|
||||
RunCode.doEval(cmd, self.web3);
|
||||
RunCode.doEval(cmd, {web3: self.web3});
|
||||
} catch(e) {
|
||||
if (e.message.indexOf("invalid opcode") >= 0) {
|
||||
self.logger.error(__('the transaction was rejected; this usually happens due to a throw or a require, it can also happen due to an invalid operation'));
|
||||
|
|
|
@ -137,7 +137,7 @@ class DeployManager {
|
|||
for(let cmd of onDeployCode) {
|
||||
self.logger.info(__("executing") + ": " + cmd);
|
||||
try {
|
||||
RunCode.doEval(cmd, web3);
|
||||
RunCode.doEval(cmd, {web3: web3});
|
||||
} catch(e) {
|
||||
if (e.message.indexOf("invalid opcode") >= 0) {
|
||||
self.logger.error(__('the transaction was rejected; this usually happens due to a throw or a require, it can also happen due to an invalid operation'));
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
/*eslint no-unused-vars: off*/
|
||||
let Web3 = require('web3');
|
||||
let web3;
|
||||
let ipfs;
|
||||
let __mainContext;
|
||||
|
||||
// ======================
|
||||
|
@ -8,9 +9,12 @@ let __mainContext;
|
|||
// this should be at least moved to a different process and scope
|
||||
// for now it is defined here
|
||||
// ======================
|
||||
function doEval(code, _web3) {
|
||||
if (_web3) {
|
||||
web3 = _web3;
|
||||
function doEval(code, opts) {
|
||||
if (opts && opts.web3) {
|
||||
web3 = opts.web3;
|
||||
}
|
||||
if (opts && opts.ipfs) {
|
||||
ipfs = opts.ipfs;
|
||||
}
|
||||
|
||||
try {
|
||||
|
|
|
@ -22,6 +22,7 @@ class Console {
|
|||
'versions - ' + __('display versions in use for libraries and tools like web3 and solc'),
|
||||
// TODO: only if the blockchain is actually active!
|
||||
// will need to pass te current embark state here
|
||||
'ipfs - ' + __('instantiated js-ipfs object configured to the current environment (available if ipfs is enabled)'),
|
||||
'web3 - ' + __('instantiated web3.js object configured to the current environment'),
|
||||
'quit - ' + __('to immediatly exit (alias: exit)'),
|
||||
'',
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
let UploadIPFS = require('./upload.js');
|
||||
let utils = require('../../utils/utils.js');
|
||||
let fs = require('../../core/fs.js');
|
||||
let RunCode = require('../../core/runCode.js');
|
||||
let IpfsApi = require('ipfs-api');
|
||||
|
||||
class IPFS {
|
||||
|
||||
|
@ -18,6 +20,7 @@ class IPFS {
|
|||
this.setServiceCheck();
|
||||
this.addIPFSToEmbarkJS();
|
||||
this.addSetProvider();
|
||||
this.addIpfsObjectToConsole();
|
||||
}
|
||||
|
||||
commandlineDeploy() {
|
||||
|
@ -111,6 +114,12 @@ class IPFS {
|
|||
|
||||
this.embark.addProviderInit('storage', code, shouldInit);
|
||||
}
|
||||
|
||||
addIpfsObjectToConsole() {
|
||||
let ipfs = IpfsApi(this.storageConfig.host, this.storageConfig.port);
|
||||
RunCode.doEval("", {ipfs: ipfs});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
module.exports = IPFS;
|
||||
|
|
|
@ -104,7 +104,7 @@ Test.prototype.deployAll = function(contractsConfig, cb) {
|
|||
throw new Error(err);
|
||||
}
|
||||
self.web3.eth.defaultAccount = accounts[0];
|
||||
RunCode.doEval(result, self.web3);
|
||||
RunCode.doEval(result, {web3: self.web3});
|
||||
//cb();
|
||||
cb(accounts);
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue