refactor(@embark/embark-profiler): move profiler module

This commit is contained in:
Iuri Matias 2019-03-26 14:41:51 -04:00
parent 573237dc81
commit 6cb14d90f6
9 changed files with 84 additions and 10 deletions

View File

@ -0,0 +1,69 @@
{
"name": "embark-profiler",
"version": "4.0.0",
"author": "Iuri Matias <iuri.matias@gmail.com>",
"contributors": [],
"description": "Smart contract profiler for Embark DApps",
"homepage": "https://github.com/embark-framework/embark/tree/master/packages/embark-profiler#readme",
"bugs": "https://github.com/embark-framework/embark/issues",
"keywords": [
"blockchain",
"dapps",
"ethereum",
"ipfs",
"serverless",
"solc",
"solidity"
],
"files": [
"dist"
],
"license": "MIT",
"repository": {
"directory": "packages/embark-profiler",
"type": "git",
"url": "https://github.com/embark-framework/embark.git"
},
"main": "./dist/index.js",
"scripts": {
"build": "cross-env BABEL_ENV=node babel src --extensions \".js,.ts\" --out-dir dist --root-mode upward --source-maps",
"ci": "npm run qa",
"clean": "npm run reset",
"lint": "npm-run-all lint:*",
"lint:js": "eslint src/",
"// lint:ts": "tslint -c tslint.json \"src/**/*.ts\"",
"package": "npm pack",
"// qa": "npm-run-all lint typecheck build package",
"qa": "npm-run-all lint build package",
"reset": "npx rimraf dist embark-*.tgz package",
"start": "npm run watch",
"// typecheck": "tsc",
"watch": "run-p watch:*",
"watch:build": "npm run build -- --verbose --watch",
"// watch:typecheck": "npm run typecheck -- --preserveWatchOutput --watch"
},
"eslintConfig": {
"extends": "../../.eslintrc.json"
},
"dependencies": {
"@babel/runtime-corejs2": "7.3.1",
"ascii-table": "0.0.9",
"async": "2.6.1",
"web3-utils": "1.0.0-beta.37"
},
"devDependencies": {
"@babel/cli": "7.2.3",
"@babel/core": "7.2.2",
"cross-env": "5.2.0",
"eslint": "5.7.0",
"npm-run-all": "4.1.5",
"rimraf": "2.6.3",
"tslint": "5.11.0",
"typescript": "3.3.1"
},
"engines": {
"node": ">=8.12.0",
"npm": ">=6.4.1",
"yarn": ">=1.12.3"
}
}

View File

@ -1,5 +1,8 @@
const utils = require('web3-utils'); const utils = require('web3-utils');
const u = require('../../utils/utils.js');
function sample(array) {
return array[Math.floor(Math.random() * array.length)];
}
// generates random inputs based on the inputs of an ABI // generates random inputs based on the inputs of an ABI
class ContractFuzzer { class ContractFuzzer {
@ -64,7 +67,7 @@ class ContractFuzzer {
} }
generateRandomBool() { generateRandomBool() {
return u.sample([true, false]); return sample([true, false]);
} }
generateArrayOfType(length, type) { generateArrayOfType(length, type) {

View File

@ -2,11 +2,10 @@ const asciiTable = require('ascii-table');
const GasEstimator = require('./gasEstimator.js'); const GasEstimator = require('./gasEstimator.js');
class Profiler { class Profiler {
constructor(embark, options) { constructor(embark, _options) {
this.embark = embark; this.embark = embark;
this.logger = embark.logger; this.logger = embark.logger;
this.events = embark.events; this.events = embark.events;
this.plugins = options.plugins;
this.gasEstimator = new GasEstimator(embark); this.gasEstimator = new GasEstimator(embark);
this.registerConsoleCommand(); this.registerConsoleCommand();

View File

@ -0,0 +1,4 @@
{
"extends": "../../tsconfig.json",
"include": ["src/**/*"]
}

View File

@ -0,0 +1,3 @@
{
"extends": "../../tslint.json"
}

View File

@ -90,6 +90,7 @@
"embark-reset": "^4.0.0", "embark-reset": "^4.0.0",
"embark-ui": "^4.0.0", "embark-ui": "^4.0.0",
"embark-vyper": "^4.0.0", "embark-vyper": "^4.0.0",
"embark-profiler": "^4.0.0",
"embarkjs": "^4.0.0", "embarkjs": "^4.0.0",
"eth-ens-namehash": "2.0.8", "eth-ens-namehash": "2.0.8",
"ethereumjs-tx": "1.3.7", "ethereumjs-tx": "1.3.7",

View File

@ -225,7 +225,7 @@ class Engine {
this.setupCompilerAndContractsManagerService(options); this.setupCompilerAndContractsManagerService(options);
this.registerModule('solidity', {ipc: self.ipc, useDashboard: this.useDashboard}); this.registerModule('solidity', {ipc: self.ipc, useDashboard: this.useDashboard});
this.registerModulePackage('embark-vyper'); this.registerModulePackage('embark-vyper');
this.registerModule('profiler', {plugins: this.plugins}); this.registerModulePackage('embark-profiler');
this.registerModule('deploytracker', {trackContracts: options.trackContracts}); this.registerModule('deploytracker', {trackContracts: options.trackContracts});
this.registerModule('specialconfigs'); this.registerModule('specialconfigs');
this.registerModule('ens'); this.registerModule('ens');

View File

@ -528,10 +528,6 @@ function groupBy(array, key) {
}, {}); }, {});
} }
function sample(array) {
return array[Math.floor(Math.random() * array.length)];
}
function last(array) { function last(array) {
return array[array.length - 1]; return array[array.length - 1];
} }
@ -686,7 +682,6 @@ module.exports = {
getHexBalanceFromString, getHexBalanceFromString,
compact, compact,
groupBy, groupBy,
sample,
last, last,
interceptLogs, interceptLogs,
errorMessage, errorMessage,