remove useless waterfall

This commit is contained in:
Jonathan Rainville 2018-04-16 13:10:55 -04:00
parent ad136802da
commit dd1c10fe85

View File

@ -14,63 +14,60 @@ class Vyper {
compile_vyper(contractFiles, cb) { compile_vyper(contractFiles, cb) {
let self = this; let self = this;
async.waterfall([ if (!contractFiles || !contractFiles.length) {
function compileContracts(callback) { return cb();
self.logger.info("compiling vyper contracts..."); }
const compiled_object = {}; self.logger.info("compiling Vyper contracts...");
async.each(contractFiles, const compiled_object = {};
function (file, fileCb) { async.each(contractFiles,
const className = path.basename(file.filename).split('.')[0]; function (file, fileCb) {
compiled_object[className] = {}; const className = path.basename(file.filename).split('.')[0];
async.parallel([ compiled_object[className] = {};
function getByteCode(paraCb) { async.parallel([
shelljs.exec(`vyper ${file.filename}`, {silent: true}, (code, stdout, stderr) => { function getByteCode(paraCb) {
if (stderr) { shelljs.exec(`vyper ${file.filename}`, {silent: true}, (code, stdout, stderr) => {
return paraCb(stderr); if (stderr) {
} return paraCb(stderr);
if (code !== 0) {
return paraCb(`Vyper exited with error code ${code}`);
}
if (!stdout) {
return paraCb('Execution returned no bytecode');
}
const byteCode = stdout.replace(/\n/g, '');
compiled_object[className].runtimeBytecode = byteCode;
compiled_object[className].realRuntimeBytecode = byteCode;
compiled_object[className].code = byteCode;
paraCb();
});
},
function getABI(paraCb) {
shelljs.exec(`vyper -f json ${file.filename}`, {silent: true}, (code, stdout, stderr) => {
if (stderr) {
return paraCb(stderr);
}
if (code !== 0) {
return paraCb(`Vyper exited with error code ${code}`);
}
if (!stdout) {
return paraCb('Execution returned no ABI');
}
let ABI = [];
try {
ABI = JSON.parse(stdout.replace(/\n/g, ''));
} catch (e) {
return paraCb('ABI is not valid JSON');
}
compiled_object[className].abiDefinition = ABI;
paraCb();
});
} }
], fileCb); if (code !== 0) {
return paraCb(`Vyper exited with error code ${code}`);
}
if (!stdout) {
return paraCb('Execution returned no bytecode');
}
const byteCode = stdout.replace(/\n/g, '');
compiled_object[className].runtimeBytecode = byteCode;
compiled_object[className].realRuntimeBytecode = byteCode;
compiled_object[className].code = byteCode;
paraCb();
});
}, },
function (err) { function getABI(paraCb) {
callback(err, compiled_object); shelljs.exec(`vyper -f json ${file.filename}`, {silent: true}, (code, stdout, stderr) => {
}); if (stderr) {
} return paraCb(stderr);
], function (err, result) { }
cb(err, result); if (code !== 0) {
}); return paraCb(`Vyper exited with error code ${code}`);
}
if (!stdout) {
return paraCb('Execution returned no ABI');
}
let ABI = [];
try {
ABI = JSON.parse(stdout.replace(/\n/g, ''));
} catch (e) {
return paraCb('ABI is not valid JSON');
}
compiled_object[className].abiDefinition = ABI;
paraCb();
});
}
], fileCb);
},
function (err) {
cb(err, compiled_object);
});
} }
} }