diff --git a/packages/embark-profiler/package.json b/packages/embark-profiler/package.json new file mode 100644 index 000000000..eb1a96058 --- /dev/null +++ b/packages/embark-profiler/package.json @@ -0,0 +1,69 @@ +{ + "name": "embark-profiler", + "version": "4.0.0", + "author": "Iuri Matias ", + "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" + } +} diff --git a/packages/embark/src/lib/modules/profiler/fuzzer.js b/packages/embark-profiler/src/fuzzer.js similarity index 96% rename from packages/embark/src/lib/modules/profiler/fuzzer.js rename to packages/embark-profiler/src/fuzzer.js index cf9c28b7f..6ce1f7054 100644 --- a/packages/embark/src/lib/modules/profiler/fuzzer.js +++ b/packages/embark-profiler/src/fuzzer.js @@ -1,5 +1,8 @@ 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 class ContractFuzzer { @@ -64,7 +67,7 @@ class ContractFuzzer { } generateRandomBool() { - return u.sample([true, false]); + return sample([true, false]); } generateArrayOfType(length, type) { diff --git a/packages/embark/src/lib/modules/profiler/gasEstimator.js b/packages/embark-profiler/src/gasEstimator.js similarity index 100% rename from packages/embark/src/lib/modules/profiler/gasEstimator.js rename to packages/embark-profiler/src/gasEstimator.js diff --git a/packages/embark/src/lib/modules/profiler/index.js b/packages/embark-profiler/src/index.js similarity index 97% rename from packages/embark/src/lib/modules/profiler/index.js rename to packages/embark-profiler/src/index.js index a0387455b..89a3dc6ea 100644 --- a/packages/embark/src/lib/modules/profiler/index.js +++ b/packages/embark-profiler/src/index.js @@ -2,11 +2,10 @@ const asciiTable = require('ascii-table'); const GasEstimator = require('./gasEstimator.js'); class Profiler { - constructor(embark, options) { + 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(); diff --git a/packages/embark-profiler/tsconfig.json b/packages/embark-profiler/tsconfig.json new file mode 100644 index 000000000..52d43eaaa --- /dev/null +++ b/packages/embark-profiler/tsconfig.json @@ -0,0 +1,4 @@ +{ + "extends": "../../tsconfig.json", + "include": ["src/**/*"] +} diff --git a/packages/embark-profiler/tslint.json b/packages/embark-profiler/tslint.json new file mode 100644 index 000000000..0946f2096 --- /dev/null +++ b/packages/embark-profiler/tslint.json @@ -0,0 +1,3 @@ +{ + "extends": "../../tslint.json" +} diff --git a/packages/embark/package.json b/packages/embark/package.json index 8878471f1..1ce5012ac 100644 --- a/packages/embark/package.json +++ b/packages/embark/package.json @@ -90,6 +90,7 @@ "embark-reset": "^4.0.0", "embark-ui": "^4.0.0", "embark-vyper": "^4.0.0", + "embark-profiler": "^4.0.0", "embarkjs": "^4.0.0", "eth-ens-namehash": "2.0.8", "ethereumjs-tx": "1.3.7", diff --git a/packages/embark/src/lib/core/engine.js b/packages/embark/src/lib/core/engine.js index 15fafd5d4..b33849540 100644 --- a/packages/embark/src/lib/core/engine.js +++ b/packages/embark/src/lib/core/engine.js @@ -225,7 +225,7 @@ class Engine { this.setupCompilerAndContractsManagerService(options); this.registerModule('solidity', {ipc: self.ipc, useDashboard: this.useDashboard}); this.registerModulePackage('embark-vyper'); - this.registerModule('profiler', {plugins: this.plugins}); + this.registerModulePackage('embark-profiler'); this.registerModule('deploytracker', {trackContracts: options.trackContracts}); this.registerModule('specialconfigs'); this.registerModule('ens'); diff --git a/packages/embark/src/lib/utils/utils.js b/packages/embark/src/lib/utils/utils.js index 0ad94287c..9aa85500b 100644 --- a/packages/embark/src/lib/utils/utils.js +++ b/packages/embark/src/lib/utils/utils.js @@ -528,10 +528,6 @@ function groupBy(array, key) { }, {}); } -function sample(array) { - return array[Math.floor(Math.random() * array.length)]; -} - function last(array) { return array[array.length - 1]; } @@ -686,7 +682,6 @@ module.exports = { getHexBalanceFromString, compact, groupBy, - sample, last, interceptLogs, errorMessage,