-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathindex.js
36 lines (29 loc) · 1.23 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
const shelljs = require("shelljs");
function isMythosInstalled() {
return shelljs.test("-f", "node_modules/.bin/mythos");
}
function executeMythos(contractFilePath, contractName, mythxEthAddress, mythxPassword, logger) {
shelljs.exec(`node_modules/.bin/mythos analyze ${contractFilePath} ${contractName} --mythxEthAddress=${mythxEthAddress} --mythxPassword=${mythxPassword}`,
{ silent: true }, function (code, stdout, stderr) {
if (stderr) {
logger.info(stderr);
}
logger.info(stdout);
});
}
async function run(embark, compilationResult) {
if (!isMythosInstalled()) {
embark.logger.warn("Mythos not found! Plugin dependencies were not installed correctly.");
return;
}
Object.keys(compilationResult.contracts).map((contractFilePath) => {
Object.keys(compilationResult.contracts[contractFilePath]).map((contractName) => {
embark.logger.info(`Requesting analysis of ${contractName} from ${contractFilePath}`);
executeMythos(contractFilePath, contractName, embark.pluginConfig.mythxEthAddress, embark.pluginConfig.mythxPassword, embark.logger);
});
});
}
function register(embark) {
embark.events.on("contracts:compiled:solc", run.bind(null, embark));
}
module.exports = register;