add event and API endpoint to get the contract sourcecode

This commit is contained in:
Iuri Matias 2018-04-17 17:35:00 -04:00
parent b324061e2b
commit 1b32122557
1 changed files with 18 additions and 0 deletions

View File

@ -19,6 +19,24 @@ class Pipeline {
this.logger = options.logger;
this.plugins = options.plugins;
this.pipelinePlugins = this.plugins.getPluginsFor('pipeline');
const self = this;
self.events.setCommandHandler("files:contract", (filename, cb) => {
let file = self.contractsFiles.find((file) => file.filename === filename);
if (!file) {
return cb({error: filename + " not found"});
}
file.content(cb);
});
let plugin = this.plugins.createPlugin('deployment', {});
plugin.registerAPICall(
'get',
'/embark/files/contracts/',
(req, res) => {
self.events.request('files:contract', req.query.filename, res.send.bind(res));
}
);
}
build(abi, contractsJSON, path, callback) {