Skip to content

Commit dd1c10f

Browse files
committed
remove useless waterfall
1 parent ad13680 commit dd1c10f

File tree

1 file changed

+52
-55
lines changed

1 file changed

+52
-55
lines changed

lib/modules/vyper/index.js

Lines changed: 52 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -14,63 +14,60 @@ class Vyper {
1414

1515
compile_vyper(contractFiles, cb) {
1616
let self = this;
17-
async.waterfall([
18-
function compileContracts(callback) {
19-
self.logger.info("compiling vyper contracts...");
20-
const compiled_object = {};
21-
async.each(contractFiles,
22-
function (file, fileCb) {
23-
const className = path.basename(file.filename).split('.')[0];
24-
compiled_object[className] = {};
25-
async.parallel([
26-
function getByteCode(paraCb) {
27-
shelljs.exec(`vyper ${file.filename}`, {silent: true}, (code, stdout, stderr) => {
28-
if (stderr) {
29-
return paraCb(stderr);
30-
}
31-
if (code !== 0) {
32-
return paraCb(`Vyper exited with error code ${code}`);
33-
}
34-
if (!stdout) {
35-
return paraCb('Execution returned no bytecode');
36-
}
37-
const byteCode = stdout.replace(/\n/g, '');
38-
compiled_object[className].runtimeBytecode = byteCode;
39-
compiled_object[className].realRuntimeBytecode = byteCode;
40-
compiled_object[className].code = byteCode;
41-
paraCb();
42-
});
43-
},
44-
function getABI(paraCb) {
45-
shelljs.exec(`vyper -f json ${file.filename}`, {silent: true}, (code, stdout, stderr) => {
46-
if (stderr) {
47-
return paraCb(stderr);
48-
}
49-
if (code !== 0) {
50-
return paraCb(`Vyper exited with error code ${code}`);
51-
}
52-
if (!stdout) {
53-
return paraCb('Execution returned no ABI');
54-
}
55-
let ABI = [];
56-
try {
57-
ABI = JSON.parse(stdout.replace(/\n/g, ''));
58-
} catch (e) {
59-
return paraCb('ABI is not valid JSON');
60-
}
61-
compiled_object[className].abiDefinition = ABI;
62-
paraCb();
63-
});
17+
if (!contractFiles || !contractFiles.length) {
18+
return cb();
19+
}
20+
self.logger.info("compiling Vyper contracts...");
21+
const compiled_object = {};
22+
async.each(contractFiles,
23+
function (file, fileCb) {
24+
const className = path.basename(file.filename).split('.')[0];
25+
compiled_object[className] = {};
26+
async.parallel([
27+
function getByteCode(paraCb) {
28+
shelljs.exec(`vyper ${file.filename}`, {silent: true}, (code, stdout, stderr) => {
29+
if (stderr) {
30+
return paraCb(stderr);
6431
}
65-
], fileCb);
32+
if (code !== 0) {
33+
return paraCb(`Vyper exited with error code ${code}`);
34+
}
35+
if (!stdout) {
36+
return paraCb('Execution returned no bytecode');
37+
}
38+
const byteCode = stdout.replace(/\n/g, '');
39+
compiled_object[className].runtimeBytecode = byteCode;
40+
compiled_object[className].realRuntimeBytecode = byteCode;
41+
compiled_object[className].code = byteCode;
42+
paraCb();
43+
});
6644
},
67-
function (err) {
68-
callback(err, compiled_object);
69-
});
70-
}
71-
], function (err, result) {
72-
cb(err, result);
73-
});
45+
function getABI(paraCb) {
46+
shelljs.exec(`vyper -f json ${file.filename}`, {silent: true}, (code, stdout, stderr) => {
47+
if (stderr) {
48+
return paraCb(stderr);
49+
}
50+
if (code !== 0) {
51+
return paraCb(`Vyper exited with error code ${code}`);
52+
}
53+
if (!stdout) {
54+
return paraCb('Execution returned no ABI');
55+
}
56+
let ABI = [];
57+
try {
58+
ABI = JSON.parse(stdout.replace(/\n/g, ''));
59+
} catch (e) {
60+
return paraCb('ABI is not valid JSON');
61+
}
62+
compiled_object[className].abiDefinition = ABI;
63+
paraCb();
64+
});
65+
}
66+
], fileCb);
67+
},
68+
function (err) {
69+
cb(err, compiled_object);
70+
});
7471
}
7572

7673
}

0 commit comments

Comments
 (0)