refactor profile caller

This commit is contained in:
Iuri Matias 2018-08-01 15:09:16 -04:00 committed by Pascal Precht
parent 1b96fbf451
commit f7d5bd0e70
No known key found for this signature in database
GPG Key ID: 0EE28D8D6FD85D7D

View File

@ -16,7 +16,7 @@ class Profiler {
profile(contractName, contract, callback) { profile(contractName, contract, callback) {
const self = this; const self = this;
this.profileJSON(contractName, contract, (err, profileObj) => { this.profileJSON(contractName, (err, profileObj) => {
if (err) { if (err) {
return callback(null, "error found in method: " + name + " error: " + JSON.stringify(err)); return callback(null, "error found in method: " + name + " error: " + JSON.stringify(err));
} }
@ -70,17 +70,13 @@ class Profiler {
'/embark-api/profiler/:contractName', '/embark-api/profiler/:contractName',
(req, res) => { (req, res) => {
let contractName = req.params.contractName; let contractName = req.params.contractName;
self.events.request('contracts:contract', contractName, (contract) => {
if (!contract || !contract.deployedAddress) { self.profileJSON(contractName, (err, table) => {
return res.send({error: "-- couldn't profile " + contractName + " - it's not deployed or could be an interface"});
}
self.profile(contractName, contract, (err, table) => {
if (err) { if (err) {
return res.send({error: err}); return res.send({error: err});
} }
res.send(table); res.send(table);
}); });
});
} }
); );
} }