mirror of
https://github.com/status-im/embark-area-51.git
synced 2025-02-20 02:58:05 +00:00
async buildContractJs
This commit is contained in:
parent
4ec7fbb9db
commit
a03777dc65
@ -75,10 +75,11 @@ class Pipeline {
|
|||||||
},
|
},
|
||||||
function writeContracts(next) {
|
function writeContracts(next) {
|
||||||
async.each(Object.keys(contractsJSON), (contractName, eachCb) => {
|
async.each(Object.keys(contractsJSON), (contractName, eachCb) => {
|
||||||
let contractCode = self.buildContractJS(contractName);
|
self.buildContractJS(contractName, (err, contractCode) => {
|
||||||
let filePath = fs.dappPath(".embark", contractName + '.js');
|
let filePath = fs.dappPath(".embark", contractName + '.js');
|
||||||
importsList["Embark/contracts/" + contractName] = filePath;
|
importsList["Embark/contracts/" + contractName] = filePath;
|
||||||
fs.writeFile(filePath, contractCode, eachCb);
|
fs.writeFile(filePath, contractCode, eachCb);
|
||||||
|
});
|
||||||
}, next);
|
}, next);
|
||||||
},
|
},
|
||||||
function assetFileWrite(next) {
|
function assetFileWrite(next) {
|
||||||
@ -310,8 +311,12 @@ class Pipeline {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
buildContractJS(contractName) {
|
buildContractJS(contractName, callback) {
|
||||||
let contractJSON = fs.readFileSync(fs.dappPath(this.buildDir, 'contracts', contractName + '.json')).toString();
|
fs.readFile(fs.dappPath(this.buildDir, 'contracts', contractName + '.json'), (err, contractJSON) => {
|
||||||
|
if (err) {
|
||||||
|
return callback(err);
|
||||||
|
}
|
||||||
|
contractJSON = contractJSON.toString();
|
||||||
|
|
||||||
let contractCode = "";
|
let contractCode = "";
|
||||||
contractCode += "import web3 from 'Embark/web3';\n";
|
contractCode += "import web3 from 'Embark/web3';\n";
|
||||||
@ -324,8 +329,8 @@ class Pipeline {
|
|||||||
contractCode += "\n});\n";
|
contractCode += "\n});\n";
|
||||||
|
|
||||||
contractCode += "export default " + contractName + ";\n";
|
contractCode += "export default " + contractName + ";\n";
|
||||||
|
callback(null, contractCode);
|
||||||
return contractCode;
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
buildWeb3JS(cb) {
|
buildWeb3JS(cb) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user