refactor building web3 obj

This commit is contained in:
Iuri Matias 2017-12-12 16:10:12 -05:00
parent c160ac616f
commit 3ddd492e83
2 changed files with 9 additions and 8 deletions

View File

@ -23,8 +23,11 @@ class Pipeline {
this.buildContracts(contractsJSON);
self.buildWeb3JS(function() {
// limit:1 due to issues when downloading required files such as web3.js
async.eachOfLimit(this.assetFiles, 1, function (files, targetFile, cb) {
async.eachOfLimit(self.assetFiles, 1, function (files, targetFile, cb) {
// limit:1 due to issues when downloading required files such as web3.js
async.mapLimit(files, 1,
function(file, fileCb) {
@ -34,6 +37,7 @@ class Pipeline {
let importsList = {};
importsList["Embark/EmbarkJS"] = fs.embarkPath("js/embark.js");
importsList["Embark/web3"] = utils.joinPath(fs.dappPath(), ".embark", 'web3_instance.js');
async.waterfall([
function findImports(next) {
@ -55,11 +59,6 @@ class Pipeline {
let filePath = utils.joinPath(fs.dappPath(), ".embark", contractName + '.js');
fs.writeFileSync(filePath, contractCode);
importsList[request] = filePath;
} else if (request === "Embark/web3") {
return self.buildWeb3JS(function() {
importsList[request] = utils.joinPath(fs.dappPath(), ".embark", 'web3_instance.js');
callback(null, "amd " + Math.random());
});
}
callback(null, "amd " + Math.random());
}
@ -164,6 +163,7 @@ class Pipeline {
function (_err, _results) {
callback();
});
});
}
build2(abi, contractsJSON, path, callback) {
@ -455,6 +455,7 @@ class Pipeline {
code += "\nwindow.web3 = web3;\n";
code += "\nexport default web3;\n";
let filePath = utils.joinPath(fs.dappPath(), ".embark", 'web3_instance.js');
fs.mkdirpSync(utils.joinPath(fs.dappPath(), ".embark"));
fs.writeFileSync(filePath, code);
cb();
});

View File

@ -8,12 +8,12 @@ import $ from './_vendor/jquery.min';
//console.log("finished importing web3");
import EmbarkJS from 'Embark/EmbarkJS';
import SimpleStorage from 'Embark/contracts/SimpleStorage';
import web3 from 'Embark/web3';
//import web3 from 'Embark/web3';
console.log("SimpleStorage")
console.log(SimpleStorage);
console.log(EmbarkJS);
//console.log(EmbarkJS);
window.SimpleStorage = SimpleStorage;
import test3 from './foo';