mirror of
https://github.com/embarklabs/embark.git
synced 2025-01-22 11:40:09 +00:00
refactor(@embark/plugins/profiler): re-enable embark-profiler plugin
Hook `embark-profiler` into the engine's contracts group. Adjust `request` signatures to match v5 usage. Ensure gas numbers are formatted consistently in the ascii table. Display non-json output in cockpit's console as monospace/pre to preserve profiler table formatting.
This commit is contained in:
parent
7c5d662772
commit
08933dec90
@ -7,6 +7,11 @@
|
|||||||
text-transform: capitalize;
|
text-transform: capitalize;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.console-text {
|
||||||
|
font-family: monospace;
|
||||||
|
white-space: pre;
|
||||||
|
}
|
||||||
|
|
||||||
.text__new-line, .card.warnings-card .list-group-item, .card.errors-card .list-group-item {
|
.text__new-line, .card.warnings-card .list-group-item, .card.errors-card .list-group-item {
|
||||||
white-space: pre-wrap;
|
white-space: pre-wrap;
|
||||||
font-family: monospace;
|
font-family: monospace;
|
||||||
|
@ -77,6 +77,7 @@ class Console extends Component {
|
|||||||
|
|
||||||
logClassName(item) {
|
logClassName(item) {
|
||||||
return classnames('m-0', {
|
return classnames('m-0', {
|
||||||
|
'console-text': true,
|
||||||
'text-success': item.logLevel === 'info',
|
'text-success': item.logLevel === 'info',
|
||||||
'text-info': item.logLevel === 'debug',
|
'text-info': item.logLevel === 'debug',
|
||||||
'text-danger': item.logLevel === 'error',
|
'text-danger': item.logLevel === 'error',
|
||||||
|
@ -286,6 +286,7 @@ export class Engine {
|
|||||||
this.registerModulePackage('embark-specialconfigs', {plugins: this.plugins});
|
this.registerModulePackage('embark-specialconfigs', {plugins: this.plugins});
|
||||||
this.registerModulePackage('embark-transaction-logger');
|
this.registerModulePackage('embark-transaction-logger');
|
||||||
this.registerModulePackage('embark-transaction-tracker');
|
this.registerModulePackage('embark-transaction-tracker');
|
||||||
|
this.registerModulePackage('embark-profiler');
|
||||||
}
|
}
|
||||||
|
|
||||||
storageComponent() {
|
storageComponent() {
|
||||||
|
@ -45,6 +45,7 @@
|
|||||||
"ascii-table": "0.0.9",
|
"ascii-table": "0.0.9",
|
||||||
"async": "2.6.1",
|
"async": "2.6.1",
|
||||||
"core-js": "3.3.5",
|
"core-js": "3.3.5",
|
||||||
|
"web3": "1.2.1",
|
||||||
"web3-utils": "1.2.1"
|
"web3-utils": "1.2.1"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
const async = require('async');
|
const async = require('async');
|
||||||
const ContractFuzzer = require('./fuzzer.js');
|
const ContractFuzzer = require('./fuzzer.js');
|
||||||
|
const Web3 = require('web3');
|
||||||
|
|
||||||
class GasEstimator {
|
class GasEstimator {
|
||||||
constructor(embark) {
|
constructor(embark) {
|
||||||
@ -12,8 +13,10 @@ class GasEstimator {
|
|||||||
estimateGas(contractName, cb) {
|
estimateGas(contractName, cb) {
|
||||||
const self = this;
|
const self = this;
|
||||||
let gasMap = {};
|
let gasMap = {};
|
||||||
self.events.request('blockchain:object', ({ web3 }) => {
|
self.events.request("blockchain:client:provider", "ethereum", (err, provider) => {
|
||||||
self.events.request('contracts:contract', contractName, (contract) => {
|
const web3 = new Web3(provider);
|
||||||
|
self.events.request('contracts:contract', contractName, (err, contract) => {
|
||||||
|
if (err) return cb(err);
|
||||||
let fuzzMap = self.fuzzer.generateFuzz(3, contract);
|
let fuzzMap = self.fuzzer.generateFuzz(3, contract);
|
||||||
let contractObj = new web3.eth.Contract(contract.abiDefinition, contract.deployedAddress);
|
let contractObj = new web3.eth.Contract(contract.abiDefinition, contract.deployedAddress);
|
||||||
async.each(contract.abiDefinition.filter((x) => x.type !== "event"),
|
async.each(contract.abiDefinition.filter((x) => x.type !== "event"),
|
||||||
@ -21,10 +24,10 @@ class GasEstimator {
|
|||||||
let name = abiMethod.name;
|
let name = abiMethod.name;
|
||||||
if (abiMethod.type === "constructor") {
|
if (abiMethod.type === "constructor") {
|
||||||
// already provided for us
|
// already provided for us
|
||||||
gasMap['constructor'] = contract.gasEstimates.creation.totalCost.toString();
|
gasMap['constructor'] = parseFloat(contract.gasEstimates.creation.totalCost.toString());
|
||||||
return gasCb(null, name, abiMethod.type);
|
return gasCb(null, name, abiMethod.type);
|
||||||
} else if (abiMethod.type === "fallback") {
|
} else if (abiMethod.type === "fallback") {
|
||||||
gasMap['fallback'] = contract.gasEstimates.external[""].toString();
|
gasMap['fallback'] = parseFloat(contract.gasEstimates.external[""].toString());
|
||||||
return gasCb(null, name, abiMethod.type);
|
return gasCb(null, name, abiMethod.type);
|
||||||
} else if (
|
} else if (
|
||||||
(abiMethod.inputs === null || abiMethod.inputs === undefined || abiMethod.inputs.length === 0)
|
(abiMethod.inputs === null || abiMethod.inputs === undefined || abiMethod.inputs.length === 0)
|
||||||
|
@ -19,7 +19,8 @@ class Profiler {
|
|||||||
profileObj.name = contractName;
|
profileObj.name = contractName;
|
||||||
profileObj.methods = [];
|
profileObj.methods = [];
|
||||||
|
|
||||||
self.events.request('contracts:contract', contractName, (contract) => {
|
self.events.request('contracts:contract', contractName, (err, contract) => {
|
||||||
|
if (err) return returnCb(err);
|
||||||
if (!contract || !contract.deployedAddress) {
|
if (!contract || !contract.deployedAddress) {
|
||||||
return returnCb("-- couldn't profile " + contractName + " - it's not deployed or could be an interface");
|
return returnCb("-- couldn't profile " + contractName + " - it's not deployed or could be an interface");
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user