refactor building web3 obj
This commit is contained in:
parent
c160ac616f
commit
3ddd492e83
|
@ -23,8 +23,11 @@ class Pipeline {
|
||||||
|
|
||||||
this.buildContracts(contractsJSON);
|
this.buildContracts(contractsJSON);
|
||||||
|
|
||||||
|
|
||||||
|
self.buildWeb3JS(function() {
|
||||||
|
|
||||||
// limit:1 due to issues when downloading required files such as web3.js
|
// 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
|
// limit:1 due to issues when downloading required files such as web3.js
|
||||||
async.mapLimit(files, 1,
|
async.mapLimit(files, 1,
|
||||||
function(file, fileCb) {
|
function(file, fileCb) {
|
||||||
|
@ -34,6 +37,7 @@ class Pipeline {
|
||||||
let importsList = {};
|
let importsList = {};
|
||||||
|
|
||||||
importsList["Embark/EmbarkJS"] = fs.embarkPath("js/embark.js");
|
importsList["Embark/EmbarkJS"] = fs.embarkPath("js/embark.js");
|
||||||
|
importsList["Embark/web3"] = utils.joinPath(fs.dappPath(), ".embark", 'web3_instance.js');
|
||||||
|
|
||||||
async.waterfall([
|
async.waterfall([
|
||||||
function findImports(next) {
|
function findImports(next) {
|
||||||
|
@ -55,11 +59,6 @@ class Pipeline {
|
||||||
let filePath = utils.joinPath(fs.dappPath(), ".embark", contractName + '.js');
|
let filePath = utils.joinPath(fs.dappPath(), ".embark", contractName + '.js');
|
||||||
fs.writeFileSync(filePath, contractCode);
|
fs.writeFileSync(filePath, contractCode);
|
||||||
importsList[request] = filePath;
|
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());
|
callback(null, "amd " + Math.random());
|
||||||
}
|
}
|
||||||
|
@ -164,6 +163,7 @@ class Pipeline {
|
||||||
function (_err, _results) {
|
function (_err, _results) {
|
||||||
callback();
|
callback();
|
||||||
});
|
});
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
build2(abi, contractsJSON, path, callback) {
|
build2(abi, contractsJSON, path, callback) {
|
||||||
|
@ -455,6 +455,7 @@ class Pipeline {
|
||||||
code += "\nwindow.web3 = web3;\n";
|
code += "\nwindow.web3 = web3;\n";
|
||||||
code += "\nexport default web3;\n";
|
code += "\nexport default web3;\n";
|
||||||
let filePath = utils.joinPath(fs.dappPath(), ".embark", 'web3_instance.js');
|
let filePath = utils.joinPath(fs.dappPath(), ".embark", 'web3_instance.js');
|
||||||
|
fs.mkdirpSync(utils.joinPath(fs.dappPath(), ".embark"));
|
||||||
fs.writeFileSync(filePath, code);
|
fs.writeFileSync(filePath, code);
|
||||||
cb();
|
cb();
|
||||||
});
|
});
|
||||||
|
|
|
@ -8,12 +8,12 @@ import $ from './_vendor/jquery.min';
|
||||||
//console.log("finished importing web3");
|
//console.log("finished importing web3");
|
||||||
import EmbarkJS from 'Embark/EmbarkJS';
|
import EmbarkJS from 'Embark/EmbarkJS';
|
||||||
import SimpleStorage from 'Embark/contracts/SimpleStorage';
|
import SimpleStorage from 'Embark/contracts/SimpleStorage';
|
||||||
import web3 from 'Embark/web3';
|
//import web3 from 'Embark/web3';
|
||||||
|
|
||||||
console.log("SimpleStorage")
|
console.log("SimpleStorage")
|
||||||
console.log(SimpleStorage);
|
console.log(SimpleStorage);
|
||||||
|
|
||||||
console.log(EmbarkJS);
|
//console.log(EmbarkJS);
|
||||||
window.SimpleStorage = SimpleStorage;
|
window.SimpleStorage = SimpleStorage;
|
||||||
|
|
||||||
import test3 from './foo';
|
import test3 from './foo';
|
||||||
|
|
Loading…
Reference in New Issue