mirror of https://github.com/embarklabs/embark.git
define api for profiler
This commit is contained in:
parent
546d7af076
commit
7e96eb661e
|
@ -192,7 +192,10 @@ class Engine {
|
|||
let self = this;
|
||||
|
||||
this.setupCompilerAndContractsManagerService(options);
|
||||
this.registerModule('profiler');
|
||||
this.registerModule('compiler', {plugins: self.plugins, disableOptimizations: options.disableOptimizations});
|
||||
this.registerModule('solidity', {ipc: self.ipc, useDashboard: this.useDashboard});
|
||||
this.registerModule('vyper');
|
||||
this.registerModule('profiler', {plugins: this.plugins});
|
||||
this.registerModule('deploytracker', {trackContracts: options.trackContracts});
|
||||
this.registerModule('specialconfigs');
|
||||
this.registerModule('ens');
|
||||
|
|
|
@ -2,13 +2,15 @@ const asciiTable = require('ascii-table');
|
|||
const GasEstimator = require('./gasEstimator.js');
|
||||
|
||||
class Profiler {
|
||||
constructor(embark) {
|
||||
constructor(embark, options) {
|
||||
this.embark = embark;
|
||||
this.logger = embark.logger;
|
||||
this.events = embark.events;
|
||||
this.plugins = options.plugins;
|
||||
this.gasEstimator = new GasEstimator(embark);
|
||||
|
||||
this.registerConsoleCommand();
|
||||
this.registerApi();
|
||||
}
|
||||
|
||||
profile(contractName, contract, callback) {
|
||||
|
@ -65,6 +67,32 @@ class Profiler {
|
|||
};
|
||||
});
|
||||
}
|
||||
|
||||
registerApi() {
|
||||
const self = this;
|
||||
|
||||
let plugin = this.plugins.createPlugin('profiler', {});
|
||||
plugin.registerAPICall(
|
||||
'get',
|
||||
'/embark-api/profiler/:contractName',
|
||||
(req, res) => {
|
||||
let contractName = req.params.contractName;
|
||||
//self.events.request('contracts:contract', req.params.contractName, res.send.bind(res));
|
||||
self.events.request('contracts:contract', contractName, (contract) => {
|
||||
if (!contract || !contract.deployedAddress) {
|
||||
return res.send("-- couldn't profile " + contractName + " - it's not deployed or could be an interface");
|
||||
}
|
||||
self.profile(contractName, contract, (err, table) => {
|
||||
if (err) {
|
||||
return res.send(err);
|
||||
}
|
||||
res.send(table);
|
||||
});
|
||||
});
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
module.exports = Profiler;
|
||||
|
|
Loading…
Reference in New Issue