From 23bd2c91a7457c50935aa34fdba59c668d0046e5 Mon Sep 17 00:00:00 2001 From: Iuri Matias Date: Tue, 17 Apr 2018 15:38:12 -0400 Subject: [PATCH] add event and API end poitn to get the JSON info of a contract --- lib/contracts/deploy.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/lib/contracts/deploy.js b/lib/contracts/deploy.js index 38df563a..fc4eee80 100644 --- a/lib/contracts/deploy.js +++ b/lib/contracts/deploy.js @@ -21,6 +21,19 @@ class Deploy { this.events.setCommandHandler('setDashboardState', () => { self.events.emit('contractsState', self.contractsManager.contractsState()); }); + + self.events.setCommandHandler("contracts:contract", (contractName, cb) => { + cb(self.contractsManager.getContract(contractName)); + }); + + let plugin = this.plugins.createPlugin('deployment', {}); + plugin.registerAPICall( + 'get', + '/embark/contract/:contractName', + (req, res) => { + self.events.request('contracts:contract', req.params.contractName, res.send.bind(res)); + } + ); } initTracker(cb) {