From 2c974b5f3ffa0e9736000273e39cdeee4a251b94 Mon Sep 17 00:00:00 2001 From: Leonid Logvinov Date: Tue, 8 Jan 2019 12:23:33 +0100 Subject: [PATCH 01/15] Refactor out sol-cov, sol-profiler and sol-trace into their separate packages --- .circleci/config.yml | 8 +- .github/autolabeler.yml | 5 +- .gitignore | 2 +- .prettierignore | 2 +- CODEOWNERS | 5 +- README.md | 4 +- contracts/TESTING.md | 2 +- contracts/examples/package.json | 1 - contracts/extensions/package.json | 1 - contracts/libs/package.json | 1 - contracts/multisig/package.json | 1 - contracts/protocol/package.json | 1 - contracts/test-utils/package.json | 4 +- contracts/test-utils/src/coverage.ts | 2 +- contracts/test-utils/src/profiler.ts | 2 +- contracts/test-utils/src/revert_trace.ts | 2 +- contracts/tokens/package.json | 1 - contracts/utils/package.json | 1 - package.json | 5 +- packages/metacoin/package.json | 3 +- packages/metacoin/test/utils/coverage.ts | 2 +- packages/metacoin/test/utils/profiler.ts | 2 +- packages/sol-cov/tslint.json | 6 -- packages/{sol-cov => sol-coverage}/.npmignore | 0 packages/sol-coverage/CHANGELOG.json | 12 +++ packages/{sol-cov => sol-coverage}/README.md | 14 ++-- packages/sol-coverage/package.json | 52 +++++++++++++ .../src/coverage_subprovider.ts | 16 ++-- .../src/globals.d.ts | 0 packages/sol-coverage/src/index.ts | 23 ++++++ packages/sol-coverage/tsconfig.json | 8 ++ packages/sol-coverage/tslint.json | 3 + .../typedoc-tsconfig.json | 0 packages/sol-profiler/.npmignore | 6 ++ packages/sol-profiler/CHANGELOG.json | 12 +++ packages/sol-profiler/README.md | 75 ++++++++++++++++++ packages/sol-profiler/package.json | 50 ++++++++++++ packages/sol-profiler/src/globals.d.ts | 7 ++ .../{sol-cov => sol-profiler}/src/index.ts | 12 +-- .../src/profiler_subprovider.ts | 19 +++-- packages/sol-profiler/tsconfig.json | 8 ++ packages/sol-profiler/tslint.json | 3 + packages/sol-profiler/typedoc-tsconfig.json | 7 ++ .../sol-trace-based-tools-common/.npmignore | 6 ++ .../CHANGELOG.json | 9 +++ .../CHANGELOG.md | 0 .../sol-trace-based-tools-common/README.md | 61 +++++++++++++++ .../compiler.json | 0 .../coverage/.gitkeep | 0 .../package.json | 10 +-- .../abstract_artifact_adapter.ts | 0 .../sol_compiler_artifact_adapter.ts | 0 .../truffle_artifact_adapter.ts | 2 +- .../src/ast_visitor.ts | 0 .../src/collect_coverage_entries.ts | 0 .../src/constants.ts | 0 .../src/get_source_range_snippet.ts | 5 ++ .../src/globals.d.ts | 7 ++ .../sol-trace-based-tools-common/src/index.ts | 39 ++++++++++ .../src/instructions.ts | 0 .../src/revert_trace.ts | 9 ++- .../src/source_maps.ts | 16 +++- .../src/trace.ts | 9 ++- .../src/trace_collection_subprovider.ts | 0 .../src/trace_collector.ts | 2 +- .../src/trace_info_subprovider.ts | 0 .../src/types.ts | 0 .../src/utils.ts | 0 .../test/collect_coverage_entries_test.ts | 0 .../contracts/AllSolidityFeatures.sol | 0 .../test/fixtures/contracts/SimpleStorage.sol | 0 .../test/fixtures/contracts/Simplest.sol | 0 .../test/fixtures/contracts/SolcovIgnore.sol | 0 .../test/instructions_test.ts | 0 .../sol_compiler_artifact_adapter_test.ts | 0 .../test/source_maps_test.ts | 0 .../test/trace_test.ts | 0 .../test/utils_test.ts | 0 .../tsconfig.json | 0 .../sol-trace-based-tools-common/tslint.json | 3 + packages/sol-trace/.npmignore | 6 ++ packages/sol-trace/CHANGELOG.json | 12 +++ packages/sol-trace/README.md | 75 ++++++++++++++++++ packages/sol-trace/package.json | 52 +++++++++++++ packages/sol-trace/src/globals.d.ts | 7 ++ packages/sol-trace/src/index.ts | 24 ++++++ .../src/revert_trace_subprovider.ts | 24 +++--- packages/sol-trace/tsconfig.json | 8 ++ packages/sol-trace/tslint.json | 3 + packages/sol-trace/typedoc-tsconfig.json | 7 ++ packages/sra-spec/src/md/introduction.md | 4 +- .../website/md/docs/sol_cov/1/installation.md | 17 ---- .../website/md/docs/sol_cov/1/introduction.md | 1 - .../website/md/docs/sol_cov/2/installation.md | 17 ---- .../website/md/docs/sol_cov/2/introduction.md | 1 - .../md/docs/sol_coverage/installation.md | 17 ++++ .../md/docs/sol_coverage/introduction.md | 1 + .../docs/{sol_cov/2 => sol_coverage}/usage.md | 8 +- .../md/docs/sol_profiler/installation.md | 17 ++++ .../md/docs/sol_profiler/introduction.md | 1 + .../docs/{sol_cov/1 => sol_profiler}/usage.md | 24 +++--- .../website/md/docs/sol_trace/installation.md | 17 ++++ .../website/md/docs/sol_trace/introduction.md | 1 + packages/website/md/docs/sol_trace/usage.md | 62 +++++++++++++++ .../containers/asset_buyer_documentation.ts | 38 ++------- .../ts/containers/connect_documentation.ts | 38 ++------- .../contract_wrappers_documentation.ts | 38 ++------- .../ethereum_types_documentation.ts | 36 ++------- .../containers/json_schemas_documentation.ts | 38 ++------- .../ts/containers/migrations_documentation.ts | 2 +- .../containers/order_utils_documentation.ts | 38 ++------- .../containers/order_watcher_documentation.ts | 38 ++------- .../smart_contracts_documentation.ts | 36 ++------- .../containers/sol_compiler_documentation.ts | 38 ++------- .../ts/containers/sol_cov_documentation.ts | 77 ------------------- .../containers/sol_coverage_documentation.ts | 43 +++++++++++ .../containers/sol_profiler_documentation.ts | 43 +++++++++++ .../ts/containers/sol_trace_documentation.ts | 43 +++++++++++ .../containers/subproviders_documentation.ts | 38 ++------- .../containers/web3_wrapper_documentation.ts | 38 ++------- .../ts/containers/zero_ex_js_documentation.ts | 38 ++------- packages/website/ts/index.tsx | 23 +++++- .../ts/pages/documentation/doc_page.tsx | 4 +- .../ts/pages/documentation/docs_home.tsx | 22 +++++- packages/website/ts/types.ts | 8 +- .../ts/utils/documentation_container.ts | 35 +++++++++ python-packages/sra_client/README.md | 2 +- tsconfig.json | 5 +- yarn.lock | 21 +---- 129 files changed, 1130 insertions(+), 624 deletions(-) delete mode 100644 packages/sol-cov/tslint.json rename packages/{sol-cov => sol-coverage}/.npmignore (100%) create mode 100644 packages/sol-coverage/CHANGELOG.json rename packages/{sol-cov => sol-coverage}/README.md (73%) create mode 100644 packages/sol-coverage/package.json rename packages/{sol-cov => sol-coverage}/src/coverage_subprovider.ts (94%) rename packages/{sol-cov => sol-coverage}/src/globals.d.ts (100%) create mode 100644 packages/sol-coverage/src/index.ts create mode 100644 packages/sol-coverage/tsconfig.json create mode 100644 packages/sol-coverage/tslint.json rename packages/{sol-cov => sol-coverage}/typedoc-tsconfig.json (100%) create mode 100644 packages/sol-profiler/.npmignore create mode 100644 packages/sol-profiler/CHANGELOG.json create mode 100644 packages/sol-profiler/README.md create mode 100644 packages/sol-profiler/package.json create mode 100644 packages/sol-profiler/src/globals.d.ts rename packages/{sol-cov => sol-profiler}/src/index.ts (51%) rename packages/{sol-cov => sol-profiler}/src/profiler_subprovider.ts (89%) create mode 100644 packages/sol-profiler/tsconfig.json create mode 100644 packages/sol-profiler/tslint.json create mode 100644 packages/sol-profiler/typedoc-tsconfig.json create mode 100644 packages/sol-trace-based-tools-common/.npmignore rename packages/{sol-cov => sol-trace-based-tools-common}/CHANGELOG.json (97%) rename packages/{sol-cov => sol-trace-based-tools-common}/CHANGELOG.md (100%) create mode 100644 packages/sol-trace-based-tools-common/README.md rename packages/{sol-cov => sol-trace-based-tools-common}/compiler.json (100%) rename packages/{sol-cov => sol-trace-based-tools-common}/coverage/.gitkeep (100%) rename packages/{sol-cov => sol-trace-based-tools-common}/package.json (87%) rename packages/{sol-cov => sol-trace-based-tools-common}/src/artifact_adapters/abstract_artifact_adapter.ts (100%) rename packages/{sol-cov => sol-trace-based-tools-common}/src/artifact_adapters/sol_compiler_artifact_adapter.ts (100%) rename packages/{sol-cov => sol-trace-based-tools-common}/src/artifact_adapters/truffle_artifact_adapter.ts (98%) rename packages/{sol-cov => sol-trace-based-tools-common}/src/ast_visitor.ts (100%) rename packages/{sol-cov => sol-trace-based-tools-common}/src/collect_coverage_entries.ts (100%) rename packages/{sol-cov => sol-trace-based-tools-common}/src/constants.ts (100%) rename packages/{sol-cov => sol-trace-based-tools-common}/src/get_source_range_snippet.ts (97%) create mode 100644 packages/sol-trace-based-tools-common/src/globals.d.ts create mode 100644 packages/sol-trace-based-tools-common/src/index.ts rename packages/{sol-cov => sol-trace-based-tools-common}/src/instructions.ts (100%) rename packages/{sol-cov => sol-trace-based-tools-common}/src/revert_trace.ts (91%) rename packages/{sol-cov => sol-trace-based-tools-common}/src/source_maps.ts (89%) rename packages/{sol-cov => sol-trace-based-tools-common}/src/trace.ts (92%) rename packages/{sol-cov => sol-trace-based-tools-common}/src/trace_collection_subprovider.ts (100%) rename packages/{sol-cov => sol-trace-based-tools-common}/src/trace_collector.ts (98%) rename packages/{sol-cov => sol-trace-based-tools-common}/src/trace_info_subprovider.ts (100%) rename packages/{sol-cov => sol-trace-based-tools-common}/src/types.ts (100%) rename packages/{sol-cov => sol-trace-based-tools-common}/src/utils.ts (100%) rename packages/{sol-cov => sol-trace-based-tools-common}/test/collect_coverage_entries_test.ts (100%) rename packages/{sol-cov => sol-trace-based-tools-common}/test/fixtures/contracts/AllSolidityFeatures.sol (100%) rename packages/{sol-cov => sol-trace-based-tools-common}/test/fixtures/contracts/SimpleStorage.sol (100%) rename packages/{sol-cov => sol-trace-based-tools-common}/test/fixtures/contracts/Simplest.sol (100%) rename packages/{sol-cov => sol-trace-based-tools-common}/test/fixtures/contracts/SolcovIgnore.sol (100%) rename packages/{sol-cov => sol-trace-based-tools-common}/test/instructions_test.ts (100%) rename packages/{sol-cov => sol-trace-based-tools-common}/test/sol_compiler_artifact_adapter_test.ts (100%) rename packages/{sol-cov => sol-trace-based-tools-common}/test/source_maps_test.ts (100%) rename packages/{sol-cov => sol-trace-based-tools-common}/test/trace_test.ts (100%) rename packages/{sol-cov => sol-trace-based-tools-common}/test/utils_test.ts (100%) rename packages/{sol-cov => sol-trace-based-tools-common}/tsconfig.json (100%) create mode 100644 packages/sol-trace-based-tools-common/tslint.json create mode 100644 packages/sol-trace/.npmignore create mode 100644 packages/sol-trace/CHANGELOG.json create mode 100644 packages/sol-trace/README.md create mode 100644 packages/sol-trace/package.json create mode 100644 packages/sol-trace/src/globals.d.ts create mode 100644 packages/sol-trace/src/index.ts rename packages/{sol-cov => sol-trace}/src/revert_trace_subprovider.ts (92%) create mode 100644 packages/sol-trace/tsconfig.json create mode 100644 packages/sol-trace/tslint.json create mode 100644 packages/sol-trace/typedoc-tsconfig.json delete mode 100644 packages/website/md/docs/sol_cov/1/installation.md delete mode 100644 packages/website/md/docs/sol_cov/1/introduction.md delete mode 100644 packages/website/md/docs/sol_cov/2/installation.md delete mode 100644 packages/website/md/docs/sol_cov/2/introduction.md create mode 100644 packages/website/md/docs/sol_coverage/installation.md create mode 100644 packages/website/md/docs/sol_coverage/introduction.md rename packages/website/md/docs/{sol_cov/2 => sol_coverage}/usage.md (80%) create mode 100644 packages/website/md/docs/sol_profiler/installation.md create mode 100644 packages/website/md/docs/sol_profiler/introduction.md rename packages/website/md/docs/{sol_cov/1 => sol_profiler}/usage.md (61%) create mode 100644 packages/website/md/docs/sol_trace/installation.md create mode 100644 packages/website/md/docs/sol_trace/introduction.md create mode 100644 packages/website/md/docs/sol_trace/usage.md delete mode 100644 packages/website/ts/containers/sol_cov_documentation.ts create mode 100644 packages/website/ts/containers/sol_coverage_documentation.ts create mode 100644 packages/website/ts/containers/sol_profiler_documentation.ts create mode 100644 packages/website/ts/containers/sol_trace_documentation.ts create mode 100644 packages/website/ts/utils/documentation_container.ts diff --git a/.circleci/config.yml b/.circleci/config.yml index 68d8041a2d..3e5a2809c6 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -118,7 +118,7 @@ jobs: - run: yarn wsrun test:circleci @0x/order-utils - run: yarn wsrun test:circleci @0x/order-watcher - run: yarn wsrun test:circleci @0x/sol-compiler - - run: yarn wsrun test:circleci @0x/sol-cov + - run: yarn wsrun test:circleci @0x/sol-trace-based-tools-common - run: yarn wsrun test:circleci @0x/sol-doc - run: yarn wsrun test:circleci @0x/subproviders - run: yarn wsrun test:circleci @0x/web3-wrapper @@ -169,9 +169,9 @@ jobs: paths: - ~/repo/packages/sol-compiler/coverage/lcov.info - save_cache: - key: coverage-sol-cov-{{ .Environment.CIRCLE_SHA1 }} + key: coverage-sol-trace-based-tools-common-{{ .Environment.CIRCLE_SHA1 }} paths: - - ~/repo/packages/sol-cov/coverage/lcov.info + - ~/repo/packages/sol-trace-based-tools-common/coverage/lcov.info - save_cache: key: coverage-sol-doc-{{ .Environment.CIRCLE_SHA1 }} paths: @@ -342,7 +342,7 @@ jobs: - coverage-sol-compiler-{{ .Environment.CIRCLE_SHA1 }} - restore_cache: keys: - - coverage-sol-cov-{{ .Environment.CIRCLE_SHA1 }} + - coverage-sol-trace-based-tools-common-{{ .Environment.CIRCLE_SHA1 }} - restore_cache: keys: - coverage-sol-doc-{{ .Environment.CIRCLE_SHA1 }} diff --git a/.github/autolabeler.yml b/.github/autolabeler.yml index 8284293d50..ecdc0e89b6 100644 --- a/.github/autolabeler.yml +++ b/.github/autolabeler.yml @@ -13,7 +13,10 @@ instant: ['packages/instant'] abi-gen-templates: ['packages/abi-gen-templates'] abi-gen: ['packages/abi-gen'] website: ['packages/website'] -sol-cov: ['packages/sol-cov'] +sol-coverage: ['packages/sol-coverage'] +sol-profiler: ['packages/sol-profiler'] +sol-trace: ['packages/sol-trace'] +sol-trace-based-tools-common: ['packages/sol-trace-based-tools-common'] utils: ['packages/utils'] tslint-config: ['packages/tslint-config'] asset-buyer: ['packages/asset-buyer'] diff --git a/.gitignore b/.gitignore index 1d4410e255..c2100ea621 100644 --- a/.gitignore +++ b/.gitignore @@ -91,7 +91,7 @@ contracts/interfaces/generated-artifacts/ contracts/tokens/generated-artifacts/ contracts/examples/generated-artifacts/ contracts/extensions/generated-artifacts/ -packages/sol-cov/test/fixtures/artifacts/ +packages/sol-trace-based-tools-common/test/fixtures/artifacts/ packages/metacoin/artifacts/ # generated contract wrappers diff --git a/.prettierignore b/.prettierignore index 7f8662b0a2..2467f8711e 100644 --- a/.prettierignore +++ b/.prettierignore @@ -26,4 +26,4 @@ lib /packages/sra-spec/public/ package.json scripts/postpublish_utils.js -packages/sol-cov/test/fixtures/artifacts +packages/sol-coverage/test/fixtures/artifacts diff --git a/CODEOWNERS b/CODEOWNERS index ca98ec19bc..f57da320f3 100644 --- a/CODEOWNERS +++ b/CODEOWNERS @@ -24,7 +24,10 @@ packages/metacoin/ @LogvinovLeon packages/monorepo-scripts/ @fabioberger packages/order-utils/ @fabioberger @LogvinovLeon packages/sol-compiler/ @LogvinovLeon -packages/sol-cov/ @LogvinovLeon +packages/sol-coverage/ @LogvinovLeon +packages/sol-profiler/ @LogvinovLeon +packages/sol-trace/ @LogvinovLeon +packages/sol-trace-based-tools-common/ @LogvinovLeon packages/sol-resolver/ @LogvinovLeon packages/subproviders/ @fabioberger @dekz packages/verdaccio/ @albrow diff --git a/README.md b/README.md index fd96c2b86b..386673a28d 100644 --- a/README.md +++ b/README.md @@ -54,7 +54,9 @@ Visit our [developer portal](https://0xproject.com/docs/order-utils) for a compr | -------------------------------------------- | ----------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | [`@0x/web3-wrapper`](/packages/web3-wrapper) | [![npm](https://img.shields.io/npm/v/@0x/web3-wrapper.svg)](https://www.npmjs.com/package/@0x/web3-wrapper) | An Ethereum JSON RPC client | | [`@0x/sol-compiler`](/packages/sol-compiler) | [![npm](https://img.shields.io/npm/v/@0x/sol-compiler.svg)](https://www.npmjs.com/package/@0x/sol-compiler) | A wrapper around solc-js that adds smart re-compilation, ability to compile an entire project, Solidity version specific compilation, standard input description support and much more. | -| [`@0x/sol-cov`](/packages/sol-cov) | [![npm](https://img.shields.io/npm/v/@0x/sol-cov.svg)](https://www.npmjs.com/package/@0x/sol-cov) | A solidity test coverage tool | +| [`@0x/sol-coverage`](/packages/sol-coverage) | [![npm](https://img.shields.io/npm/v/@0x/sol-coverage.svg)](https://www.npmjs.com/package/@0x/sol-coverage) | A solidity test coverage tool | +| [`@0x/sol-profiler`](/packages/sol-profiler) | [![npm](https://img.shields.io/npm/v/@0x/sol-profiler.svg)](https://www.npmjs.com/package/@0x/sol-profiler) | A solidity gas cost profiler | +| [`@0x/sol-trace`](/packages/sol-trace) | [![npm](https://img.shields.io/npm/v/@0x/sol-trace.svg)](https://www.npmjs.com/package/@0x/sol-trace) | A solidity stack trace tool | | [`@0x/sol-resolver`](/packages/sol-resolver) | [![npm](https://img.shields.io/npm/v/@0x/sol-resolver.svg)](https://www.npmjs.com/package/@0x/sol-resolver) | Import resolver for smart contracts dependencies | | [`@0x/subproviders`](/packages/subproviders) | [![npm](https://img.shields.io/npm/v/@0x/subproviders.svg)](https://www.npmjs.com/package/@0x/subproviders) | Web3 provider middlewares (e.g. LedgerSubprovider) | | [`@0x/sol-doc`](/packages/sol-doc) | [![npm](https://img.shields.io/npm/v/@0x/sol-doc.svg)](https://www.npmjs.com/package/@0x/sol-doc) | Solidity documentation generator | diff --git a/contracts/TESTING.md b/contracts/TESTING.md index 750b3c62cf..3e6888c04b 100644 --- a/contracts/TESTING.md +++ b/contracts/TESTING.md @@ -20,7 +20,7 @@ TEST_PROVIDER=geth yarn test ## Code coverage -In order to see the Solidity code coverage output generated by `@0x/sol-cov`, run: +In order to see the Solidity code coverage output generated by `@0x/sol-coverage`, run: ``` yarn test:coverage diff --git a/contracts/examples/package.json b/contracts/examples/package.json index 37b73f98c0..68286ec4fa 100644 --- a/contracts/examples/package.json +++ b/contracts/examples/package.json @@ -37,7 +37,6 @@ "@0x/contracts-test-utils": "^1.0.2", "@0x/dev-utils": "^1.0.21", "@0x/sol-compiler": "^1.1.16", - "@0x/sol-cov": "^2.1.16", "@0x/subproviders": "^2.1.8", "@0x/tslint-config": "^2.0.0", "@types/bn.js": "^4.11.0", diff --git a/contracts/extensions/package.json b/contracts/extensions/package.json index aee995645c..6dda2ccf32 100644 --- a/contracts/extensions/package.json +++ b/contracts/extensions/package.json @@ -49,7 +49,6 @@ "@0x/contracts-test-utils": "^1.0.2", "@0x/dev-utils": "^1.0.21", "@0x/sol-compiler": "^1.1.16", - "@0x/sol-cov": "^2.1.16", "@0x/subproviders": "^2.1.8", "@0x/tslint-config": "^2.0.0", "@types/bn.js": "^4.11.0", diff --git a/contracts/libs/package.json b/contracts/libs/package.json index ce7b975028..71955e74d4 100644 --- a/contracts/libs/package.json +++ b/contracts/libs/package.json @@ -48,7 +48,6 @@ "@0x/contracts-test-utils": "^1.0.2", "@0x/dev-utils": "^1.0.21", "@0x/sol-compiler": "^1.1.16", - "@0x/sol-cov": "^2.1.16", "@0x/subproviders": "^2.1.8", "@0x/tslint-config": "^2.0.0", "@types/bn.js": "^4.11.0", diff --git a/contracts/multisig/package.json b/contracts/multisig/package.json index 2d7b4aa05d..6ad04c8380 100644 --- a/contracts/multisig/package.json +++ b/contracts/multisig/package.json @@ -48,7 +48,6 @@ "@0x/contracts-test-utils": "^1.0.2", "@0x/dev-utils": "^1.0.21", "@0x/sol-compiler": "^1.1.16", - "@0x/sol-cov": "^2.1.16", "@0x/subproviders": "^2.1.8", "@0x/tslint-config": "^2.0.0", "@types/bn.js": "^4.11.0", diff --git a/contracts/protocol/package.json b/contracts/protocol/package.json index 891838e54c..987a1e5896 100644 --- a/contracts/protocol/package.json +++ b/contracts/protocol/package.json @@ -47,7 +47,6 @@ "@0x/abi-gen": "^1.0.19", "@0x/dev-utils": "^1.0.21", "@0x/sol-compiler": "^1.1.16", - "@0x/sol-cov": "^2.1.16", "@0x/subproviders": "^2.1.8", "@0x/tslint-config": "^2.0.0", "@types/bn.js": "^4.11.0", diff --git a/contracts/test-utils/package.json b/contracts/test-utils/package.json index 18ec8f6a82..acfcc3d108 100644 --- a/contracts/test-utils/package.json +++ b/contracts/test-utils/package.json @@ -44,7 +44,9 @@ "@0x/dev-utils": "^1.0.21", "@0x/order-utils": "^3.0.7", "@0x/sol-compiler": "^1.1.16", - "@0x/sol-cov": "^2.1.16", + "@0x/sol-coverage": "^1.0.0", + "@0x/sol-profiler": "^1.0.0", + "@0x/sol-trace": "^1.0.0", "@0x/subproviders": "^2.1.8", "@0x/tslint-config": "^2.0.0", "@0x/types": "^1.4.1", diff --git a/contracts/test-utils/src/coverage.ts b/contracts/test-utils/src/coverage.ts index 5becfa1b65..f82288eec9 100644 --- a/contracts/test-utils/src/coverage.ts +++ b/contracts/test-utils/src/coverage.ts @@ -1,5 +1,5 @@ import { devConstants } from '@0x/dev-utils'; -import { CoverageSubprovider, SolCompilerArtifactAdapter } from '@0x/sol-cov'; +import { CoverageSubprovider, SolCompilerArtifactAdapter } from '@0x/sol-coverage'; import * as _ from 'lodash'; let coverageSubprovider: CoverageSubprovider; diff --git a/contracts/test-utils/src/profiler.ts b/contracts/test-utils/src/profiler.ts index 2c7c1d66c0..7f51c384f6 100644 --- a/contracts/test-utils/src/profiler.ts +++ b/contracts/test-utils/src/profiler.ts @@ -1,5 +1,5 @@ import { devConstants } from '@0x/dev-utils'; -import { ProfilerSubprovider, SolCompilerArtifactAdapter } from '@0x/sol-cov'; +import { ProfilerSubprovider, SolCompilerArtifactAdapter } from '@0x/sol-profiler'; import * as _ from 'lodash'; let profilerSubprovider: ProfilerSubprovider; diff --git a/contracts/test-utils/src/revert_trace.ts b/contracts/test-utils/src/revert_trace.ts index 3f74fd28b8..3a57788591 100644 --- a/contracts/test-utils/src/revert_trace.ts +++ b/contracts/test-utils/src/revert_trace.ts @@ -1,5 +1,5 @@ import { devConstants } from '@0x/dev-utils'; -import { RevertTraceSubprovider, SolCompilerArtifactAdapter } from '@0x/sol-cov'; +import { RevertTraceSubprovider, SolCompilerArtifactAdapter } from '@0x/sol-trace'; import * as _ from 'lodash'; let revertTraceSubprovider: RevertTraceSubprovider; diff --git a/contracts/tokens/package.json b/contracts/tokens/package.json index 79afc4820a..8b8329cf3c 100644 --- a/contracts/tokens/package.json +++ b/contracts/tokens/package.json @@ -48,7 +48,6 @@ "@0x/contracts-test-utils": "^1.0.2", "@0x/dev-utils": "^1.0.21", "@0x/sol-compiler": "^1.1.16", - "@0x/sol-cov": "^2.1.16", "@0x/subproviders": "^2.1.8", "@0x/tslint-config": "^2.0.0", "@types/bn.js": "^4.11.0", diff --git a/contracts/utils/package.json b/contracts/utils/package.json index cf94af0f66..4dcf8f826a 100644 --- a/contracts/utils/package.json +++ b/contracts/utils/package.json @@ -48,7 +48,6 @@ "@0x/contracts-test-utils": "^1.0.2", "@0x/dev-utils": "^1.0.21", "@0x/sol-compiler": "^1.1.16", - "@0x/sol-cov": "^2.1.16", "@0x/subproviders": "^2.1.8", "@0x/tslint-config": "^2.0.0", "@types/bn.js": "^4.11.0", diff --git a/package.json b/package.json index 04fbb5e248..9395dbaa29 100644 --- a/package.json +++ b/package.json @@ -41,7 +41,7 @@ }, "config": { "mnemonic": "concert load couple harbor equip island argue ramp clarify fence smart topic", - "packagesWithDocPages": "0x.js connect json-schemas subproviders web3-wrapper contract-wrappers order-utils order-watcher sol-compiler sol-cov ethereum-types asset-buyer migrations" + "packagesWithDocPages": "0x.js connect json-schemas subproviders web3-wrapper contract-wrappers order-utils order-watcher sol-compiler sol-coverage sol-profiler sol-trace ethereum-types asset-buyer migrations" }, "bundlewatch": { "files": [ @@ -62,6 +62,9 @@ "repoBranchBase": "development" } }, + "resolutions": { + "graceful-fs": "4.1.15" + }, "devDependencies": { "@0x-lerna-fork/lerna": "3.0.0-beta.26", "@0xproject/npm-cli-login": "^0.0.11", diff --git a/packages/metacoin/package.json b/packages/metacoin/package.json index 0e9fa4920b..33fc16a3e4 100644 --- a/packages/metacoin/package.json +++ b/packages/metacoin/package.json @@ -32,7 +32,8 @@ "@0x/abi-gen": "^1.0.19", "@0x/abi-gen-templates": "^1.0.1", "@0x/base-contract": "^3.0.10", - "@0x/sol-cov": "^2.1.16", + "@0x/sol-coverage": "^1.0.0", + "@0x/sol-profiler": "^1.0.0", "@0x/subproviders": "^2.1.8", "@0x/tslint-config": "^2.0.0", "@0x/types": "^1.4.1", diff --git a/packages/metacoin/test/utils/coverage.ts b/packages/metacoin/test/utils/coverage.ts index 31275a1632..1a06d8c3cf 100644 --- a/packages/metacoin/test/utils/coverage.ts +++ b/packages/metacoin/test/utils/coverage.ts @@ -1,5 +1,5 @@ import { devConstants } from '@0x/dev-utils'; -import { CoverageSubprovider, SolCompilerArtifactAdapter } from '@0x/sol-cov'; +import { CoverageSubprovider, SolCompilerArtifactAdapter } from '@0x/sol-coverage'; import * as _ from 'lodash'; import { config } from './config'; diff --git a/packages/metacoin/test/utils/profiler.ts b/packages/metacoin/test/utils/profiler.ts index e7c373d200..6e6fc309f4 100644 --- a/packages/metacoin/test/utils/profiler.ts +++ b/packages/metacoin/test/utils/profiler.ts @@ -1,5 +1,5 @@ import { devConstants } from '@0x/dev-utils'; -import { ProfilerSubprovider, SolCompilerArtifactAdapter } from '@0x/sol-cov'; +import { ProfilerSubprovider, SolCompilerArtifactAdapter } from '@0x/sol-profiler'; import * as _ from 'lodash'; import { config } from './config'; diff --git a/packages/sol-cov/tslint.json b/packages/sol-cov/tslint.json deleted file mode 100644 index 631f46bcaa..0000000000 --- a/packages/sol-cov/tslint.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "extends": ["@0x/tslint-config"], - "rules": { - "completed-docs": false - } -} diff --git a/packages/sol-cov/.npmignore b/packages/sol-coverage/.npmignore similarity index 100% rename from packages/sol-cov/.npmignore rename to packages/sol-coverage/.npmignore diff --git a/packages/sol-coverage/CHANGELOG.json b/packages/sol-coverage/CHANGELOG.json new file mode 100644 index 0000000000..ca6048d99a --- /dev/null +++ b/packages/sol-coverage/CHANGELOG.json @@ -0,0 +1,12 @@ +[ + { + "version": "1.0.0", + "changes": [ + { + "note": + "Initial release as a separate package. For historic entries check @0x/sol-trace-based-tools-common", + "pr": 1492 + } + ] + } +] diff --git a/packages/sol-cov/README.md b/packages/sol-coverage/README.md similarity index 73% rename from packages/sol-cov/README.md rename to packages/sol-coverage/README.md index 31d73dc634..f8cc62eb86 100644 --- a/packages/sol-cov/README.md +++ b/packages/sol-coverage/README.md @@ -1,25 +1,25 @@ -## @0x/sol-cov +## @0x/sol-coverage A Solidity code coverage tool. -### Read the [Documentation](https://0xproject.com/docs/sol-cov). +### Read the [Documentation](https://0xproject.com/docs/sol-coverage). ## Installation ```bash -yarn add @0x/sol-cov +yarn add @0x/sol-coverage ``` **Import** ```javascript -import { CoverageSubprovider } from '@0x/sol-cov'; +import { CoverageSubprovider } from '@0x/sol-coverage'; ``` or ```javascript -var CoverageSubprovider = require('@0x/sol-cov').CoverageSubprovider; +var CoverageSubprovider = require('@0x/sol-coverage').CoverageSubprovider; ``` ## Contributing @@ -47,13 +47,13 @@ yarn install To build this package and all other monorepo packages that it depends on, run the following from the monorepo root directory: ```bash -PKG=@0x/sol-cov yarn build +PKG=@0x/sol-coverage yarn build ``` Or continuously rebuild on change: ```bash -PKG=@0x/sol-cov yarn watch +PKG=@0x/sol-coverage yarn watch ``` ### Clean diff --git a/packages/sol-coverage/package.json b/packages/sol-coverage/package.json new file mode 100644 index 0000000000..b95fa55026 --- /dev/null +++ b/packages/sol-coverage/package.json @@ -0,0 +1,52 @@ +{ + "name": "@0x/sol-coverage", + "version": "1.0.0", + "engines": { + "node": ">=6.12" + }, + "description": "Generate coverage reports for Solidity code", + "main": "lib/src/index.js", + "types": "lib/src/index.d.ts", + "scripts": { + "build": "tsc -b", + "build:ci": "yarn build", + "lint": "tslint --format stylish --project .", + "clean": "shx rm -rf lib src/artifacts generated_docs", + "docs:json": "typedoc --excludePrivate --excludeExternals --target ES5 --tsconfig typedoc-tsconfig.json --json $JSON_FILE_PATH $PROJECT_FILES" + }, + "config": { + "postpublish": { + "assets": [] + } + }, + "repository": { + "type": "git", + "url": "https://github.com/0xProject/0x-monorepo.git" + }, + "license": "Apache-2.0", + "bugs": { + "url": "https://github.com/0xProject/0x-monorepo/issues" + }, + "homepage": "https://github.com/0xProject/0x-monorepo/packages/sol-coverage/README.md", + "dependencies": { + "@0x/subproviders": "^2.1.8", + "@0x/sol-trace-based-tools-common": "^2.1.16", + "@0x/typescript-typings": "^3.0.6", + "ethereum-types": "^1.1.4", + "lodash": "^4.17.5" + }, + "devDependencies": { + "@0x/tslint-config": "^2.0.0", + "@types/node": "*", + "npm-run-all": "^4.1.2", + "nyc": "^11.0.1", + "shx": "^0.2.2", + "sinon": "^4.0.0", + "tslint": "5.11.0", + "typedoc": "0.13.0", + "typescript": "3.0.1" + }, + "publishConfig": { + "access": "public" + } +} diff --git a/packages/sol-cov/src/coverage_subprovider.ts b/packages/sol-coverage/src/coverage_subprovider.ts similarity index 94% rename from packages/sol-cov/src/coverage_subprovider.ts rename to packages/sol-coverage/src/coverage_subprovider.ts index 9667e891cd..255fa94819 100644 --- a/packages/sol-cov/src/coverage_subprovider.ts +++ b/packages/sol-coverage/src/coverage_subprovider.ts @@ -1,22 +1,22 @@ -import * as _ from 'lodash'; - -import { AbstractArtifactAdapter } from './artifact_adapters/abstract_artifact_adapter'; -import { collectCoverageEntries } from './collect_coverage_entries'; -import { SingleFileSubtraceHandler, TraceCollector } from './trace_collector'; -import { TraceInfoSubprovider } from './trace_info_subprovider'; import { + AbstractArtifactAdapter, BranchCoverage, + collectCoverageEntries, ContractData, Coverage, FunctionCoverage, FunctionDescription, + SingleFileSubtraceHandler, SourceRange, StatementCoverage, StatementDescription, Subtrace, + TraceCollector, TraceInfo, -} from './types'; -import { utils } from './utils'; + TraceInfoSubprovider, + utils, +} from '@0x/sol-trace-based-tools-common'; +import * as _ from 'lodash'; /** * This class implements the [web3-provider-engine](https://github.com/MetaMask/provider-engine) subprovider interface. diff --git a/packages/sol-cov/src/globals.d.ts b/packages/sol-coverage/src/globals.d.ts similarity index 100% rename from packages/sol-cov/src/globals.d.ts rename to packages/sol-coverage/src/globals.d.ts diff --git a/packages/sol-coverage/src/index.ts b/packages/sol-coverage/src/index.ts new file mode 100644 index 0000000000..dcf97b72ef --- /dev/null +++ b/packages/sol-coverage/src/index.ts @@ -0,0 +1,23 @@ +export { CoverageSubprovider } from './coverage_subprovider'; +export { + SolCompilerArtifactAdapter, + TruffleArtifactAdapter, + AbstractArtifactAdapter, + ContractData, +} from '@0x/sol-trace-based-tools-common'; + +export { + JSONRPCRequestPayload, + Provider, + JSONRPCErrorCallback, + JSONRPCResponsePayload, + JSONRPCResponseError, +} from 'ethereum-types'; + +export { + JSONRPCRequestPayloadWithMethod, + NextCallback, + ErrorCallback, + OnNextCompleted, + Callback, +} from '@0x/subproviders'; diff --git a/packages/sol-coverage/tsconfig.json b/packages/sol-coverage/tsconfig.json new file mode 100644 index 0000000000..233008d61c --- /dev/null +++ b/packages/sol-coverage/tsconfig.json @@ -0,0 +1,8 @@ +{ + "extends": "../../tsconfig", + "compilerOptions": { + "outDir": "lib", + "rootDir": "." + }, + "include": ["./src/**/*"] +} diff --git a/packages/sol-coverage/tslint.json b/packages/sol-coverage/tslint.json new file mode 100644 index 0000000000..dd9053357e --- /dev/null +++ b/packages/sol-coverage/tslint.json @@ -0,0 +1,3 @@ +{ + "extends": ["@0x/tslint-config"] +} diff --git a/packages/sol-cov/typedoc-tsconfig.json b/packages/sol-coverage/typedoc-tsconfig.json similarity index 100% rename from packages/sol-cov/typedoc-tsconfig.json rename to packages/sol-coverage/typedoc-tsconfig.json diff --git a/packages/sol-profiler/.npmignore b/packages/sol-profiler/.npmignore new file mode 100644 index 0000000000..037786e46b --- /dev/null +++ b/packages/sol-profiler/.npmignore @@ -0,0 +1,6 @@ +.* +yarn-error.log +/src/ +/scripts/ +tsconfig.json +/lib/src/monorepo_scripts/ diff --git a/packages/sol-profiler/CHANGELOG.json b/packages/sol-profiler/CHANGELOG.json new file mode 100644 index 0000000000..ca6048d99a --- /dev/null +++ b/packages/sol-profiler/CHANGELOG.json @@ -0,0 +1,12 @@ +[ + { + "version": "1.0.0", + "changes": [ + { + "note": + "Initial release as a separate package. For historic entries check @0x/sol-trace-based-tools-common", + "pr": 1492 + } + ] + } +] diff --git a/packages/sol-profiler/README.md b/packages/sol-profiler/README.md new file mode 100644 index 0000000000..44fa29e3f8 --- /dev/null +++ b/packages/sol-profiler/README.md @@ -0,0 +1,75 @@ +## @0x/sol-profiler + +Solidity line-by-line gas profiler. + +### Read the [Documentation](https://0xproject.com/docs/sol-profiler). + +## Installation + +```bash +yarn add @0x/sol-profiler +``` + +**Import** + +```javascript +import { ProfilerSubprovider } from '@0x/sol-profiler'; +``` + +or + +```javascript +var ProfilerSubprovider = require('@0x/sol-profiler').ProfilerSubprovider; +``` + +## Contributing + +We welcome improvements and fixes from the wider community! To report bugs within this package, please create an issue in this repository. + +Please read our [contribution guidelines](../../CONTRIBUTING.md) before getting started. + +### Install dependencies + +If you don't have yarn workspaces enabled (Yarn < v1.0) - enable them: + +```bash +yarn config set workspaces-experimental true +``` + +Then install dependencies + +```bash +yarn install +``` + +### Build + +To build this package and all other monorepo packages that it depends on, run the following from the monorepo root directory: + +```bash +PKG=@0x/sol-profiler yarn build +``` + +Or continuously rebuild on change: + +```bash +PKG=@0x/sol-profiler yarn watch +``` + +### Clean + +```bash +yarn clean +``` + +### Lint + +```bash +yarn lint +``` + +### Run Tests + +```bash +yarn test +``` diff --git a/packages/sol-profiler/package.json b/packages/sol-profiler/package.json new file mode 100644 index 0000000000..03b421b0eb --- /dev/null +++ b/packages/sol-profiler/package.json @@ -0,0 +1,50 @@ +{ + "name": "@0x/sol-profiler", + "version": "1.0.0", + "engines": { + "node": ">=6.12" + }, + "description": "Generate profiler reports for Solidity code", + "main": "lib/src/index.js", + "types": "lib/src/index.d.ts", + "scripts": { + "build": "tsc -b", + "build:ci": "yarn build", + "lint": "tslint --format stylish --project .", + "clean": "shx rm -rf lib src/artifacts generated_docs", + "docs:json": "typedoc --excludePrivate --excludeExternals --target ES5 --tsconfig typedoc-tsconfig.json --json $JSON_FILE_PATH $PROJECT_FILES" + }, + "config": { + "postpublish": { + "assets": [] + } + }, + "repository": { + "type": "git", + "url": "https://github.com/0xProject/0x-monorepo.git" + }, + "license": "Apache-2.0", + "bugs": { + "url": "https://github.com/0xProject/0x-monorepo/issues" + }, + "homepage": "https://github.com/0xProject/0x-monorepo/packages/sol-profiler/README.md", + "dependencies": { + "@0x/subproviders": "^2.1.8", + "@0x/typescript-typings": "^3.0.6", + "@0x/sol-trace-based-tools-common": "^2.1.16", + "ethereum-types": "^1.1.4", + "lodash": "^4.17.5" + }, + "devDependencies": { + "@0x/tslint-config": "^2.0.0", + "@types/node": "*", + "npm-run-all": "^4.1.2", + "shx": "^0.2.2", + "tslint": "5.11.0", + "typedoc": "0.13.0", + "typescript": "3.0.1" + }, + "publishConfig": { + "access": "public" + } +} diff --git a/packages/sol-profiler/src/globals.d.ts b/packages/sol-profiler/src/globals.d.ts new file mode 100644 index 0000000000..e799b35298 --- /dev/null +++ b/packages/sol-profiler/src/globals.d.ts @@ -0,0 +1,7 @@ +// tslint:disable:completed-docs +declare module '*.json' { + const json: any; + /* tslint:disable */ + export default json; + /* tslint:enable */ +} diff --git a/packages/sol-cov/src/index.ts b/packages/sol-profiler/src/index.ts similarity index 51% rename from packages/sol-cov/src/index.ts rename to packages/sol-profiler/src/index.ts index 348e0fc9bc..b36ed5baa8 100644 --- a/packages/sol-cov/src/index.ts +++ b/packages/sol-profiler/src/index.ts @@ -1,13 +1,13 @@ -export { CoverageSubprovider } from './coverage_subprovider'; -export { SolCompilerArtifactAdapter } from './artifact_adapters/sol_compiler_artifact_adapter'; -export { TruffleArtifactAdapter } from './artifact_adapters/truffle_artifact_adapter'; -export { AbstractArtifactAdapter } from './artifact_adapters/abstract_artifact_adapter'; +export { + AbstractArtifactAdapter, + SolCompilerArtifactAdapter, + TruffleArtifactAdapter, + ContractData, +} from '@0x/sol-trace-based-tools-common'; // HACK: ProfilerSubprovider is a hacky way to do profiling using coverage tools. Not production ready export { ProfilerSubprovider } from './profiler_subprovider'; -export { RevertTraceSubprovider } from './revert_trace_subprovider'; -export { ContractData } from './types'; export { JSONRPCRequestPayload, Provider, diff --git a/packages/sol-cov/src/profiler_subprovider.ts b/packages/sol-profiler/src/profiler_subprovider.ts similarity index 89% rename from packages/sol-cov/src/profiler_subprovider.ts rename to packages/sol-profiler/src/profiler_subprovider.ts index ae9351f176..61dc25b6b2 100644 --- a/packages/sol-cov/src/profiler_subprovider.ts +++ b/packages/sol-profiler/src/profiler_subprovider.ts @@ -1,11 +1,18 @@ import * as _ from 'lodash'; -import { AbstractArtifactAdapter } from './artifact_adapters/abstract_artifact_adapter'; -import { collectCoverageEntries } from './collect_coverage_entries'; -import { SingleFileSubtraceHandler, TraceCollector } from './trace_collector'; -import { TraceInfoSubprovider } from './trace_info_subprovider'; -import { ContractData, Coverage, SourceRange, Subtrace, TraceInfo } from './types'; -import { utils } from './utils'; +import { + AbstractArtifactAdapter, + collectCoverageEntries, + ContractData, + Coverage, + SingleFileSubtraceHandler, + SourceRange, + Subtrace, + TraceCollector, + TraceInfo, + TraceInfoSubprovider, + utils, +} from '@0x/sol-trace-based-tools-common'; /** * This class implements the [web3-provider-engine](https://github.com/MetaMask/provider-engine) subprovider interface. diff --git a/packages/sol-profiler/tsconfig.json b/packages/sol-profiler/tsconfig.json new file mode 100644 index 0000000000..233008d61c --- /dev/null +++ b/packages/sol-profiler/tsconfig.json @@ -0,0 +1,8 @@ +{ + "extends": "../../tsconfig", + "compilerOptions": { + "outDir": "lib", + "rootDir": "." + }, + "include": ["./src/**/*"] +} diff --git a/packages/sol-profiler/tslint.json b/packages/sol-profiler/tslint.json new file mode 100644 index 0000000000..dd9053357e --- /dev/null +++ b/packages/sol-profiler/tslint.json @@ -0,0 +1,3 @@ +{ + "extends": ["@0x/tslint-config"] +} diff --git a/packages/sol-profiler/typedoc-tsconfig.json b/packages/sol-profiler/typedoc-tsconfig.json new file mode 100644 index 0000000000..a4c669cb6d --- /dev/null +++ b/packages/sol-profiler/typedoc-tsconfig.json @@ -0,0 +1,7 @@ +{ + "extends": "../../typedoc-tsconfig", + "compilerOptions": { + "outDir": "lib" + }, + "include": ["./src/**/*"] +} diff --git a/packages/sol-trace-based-tools-common/.npmignore b/packages/sol-trace-based-tools-common/.npmignore new file mode 100644 index 0000000000..037786e46b --- /dev/null +++ b/packages/sol-trace-based-tools-common/.npmignore @@ -0,0 +1,6 @@ +.* +yarn-error.log +/src/ +/scripts/ +tsconfig.json +/lib/src/monorepo_scripts/ diff --git a/packages/sol-cov/CHANGELOG.json b/packages/sol-trace-based-tools-common/CHANGELOG.json similarity index 97% rename from packages/sol-cov/CHANGELOG.json rename to packages/sol-trace-based-tools-common/CHANGELOG.json index b7973c135e..4c56d547d1 100644 --- a/packages/sol-cov/CHANGELOG.json +++ b/packages/sol-trace-based-tools-common/CHANGELOG.json @@ -1,4 +1,13 @@ [ + { + "version": "3.0.0", + "changes": [ + { + "note": "Move out specific tools and leave just the common part", + "pr": 1492 + } + ] + }, { "version": "2.1.16", "changes": [ diff --git a/packages/sol-cov/CHANGELOG.md b/packages/sol-trace-based-tools-common/CHANGELOG.md similarity index 100% rename from packages/sol-cov/CHANGELOG.md rename to packages/sol-trace-based-tools-common/CHANGELOG.md diff --git a/packages/sol-trace-based-tools-common/README.md b/packages/sol-trace-based-tools-common/README.md new file mode 100644 index 0000000000..b6d75dd598 --- /dev/null +++ b/packages/sol-trace-based-tools-common/README.md @@ -0,0 +1,61 @@ +## @0x/sol-trace-based-tools-common + +Common code for all solidity trace-based tools (sol-coverage, sol-profiler, sol-trace). + +## Installation + +```bash +yarn add @0x/sol-sol-trace-based-tools-common +``` + +## Contributing + +We welcome improvements and fixes from the wider community! To report bugs within this package, please create an issue in this repository. + +Please read our [contribution guidelines](../../CONTRIBUTING.md) before getting started. + +### Install dependencies + +If you don't have yarn workspaces enabled (Yarn < v1.0) - enable them: + +```bash +yarn config set workspaces-experimental true +``` + +Then install dependencies + +```bash +yarn install +``` + +### Build + +To build this package and all other monorepo packages that it depends on, run the following from the monorepo root directory: + +```bash +PKG=@0x/sol-trace-based-tools-common yarn build +``` + +Or continuously rebuild on change: + +```bash +PKG=@0x/sol-trace-based-tools-common yarn watch +``` + +### Clean + +```bash +yarn clean +``` + +### Lint + +```bash +yarn lint +``` + +### Run Tests + +```bash +yarn test +``` diff --git a/packages/sol-cov/compiler.json b/packages/sol-trace-based-tools-common/compiler.json similarity index 100% rename from packages/sol-cov/compiler.json rename to packages/sol-trace-based-tools-common/compiler.json diff --git a/packages/sol-cov/coverage/.gitkeep b/packages/sol-trace-based-tools-common/coverage/.gitkeep similarity index 100% rename from packages/sol-cov/coverage/.gitkeep rename to packages/sol-trace-based-tools-common/coverage/.gitkeep diff --git a/packages/sol-cov/package.json b/packages/sol-trace-based-tools-common/package.json similarity index 87% rename from packages/sol-cov/package.json rename to packages/sol-trace-based-tools-common/package.json index 3ade51c80b..6cfabe6d9e 100644 --- a/packages/sol-cov/package.json +++ b/packages/sol-trace-based-tools-common/package.json @@ -1,10 +1,10 @@ { - "name": "@0x/sol-cov", + "name": "@0x/sol-trace-based-tools-common", "version": "2.1.16", "engines": { "node": ">=6.12" }, - "description": "Generate coverage reports for Solidity code", + "description": "Common part of trace based solidity tools (sol-coverage, sol-trace, sol-profiler)", "main": "lib/src/index.js", "types": "lib/src/index.d.ts", "scripts": { @@ -34,13 +34,13 @@ }, "repository": { "type": "git", - "url": "https://github.com/0xProject/0x.js.git" + "url": "https://github.com/0xProject/0x-monorepo.git" }, "license": "Apache-2.0", "bugs": { - "url": "https://github.com/0xProject/0x.js/issues" + "url": "https://github.com/0xProject/0x-monorepo/issues" }, - "homepage": "https://github.com/0xProject/0x.js/packages/sol-cov/README.md", + "homepage": "https://github.com/0xProject/0x-monorepo/packages/sol-trace-based-tools-common/README.md", "dependencies": { "@0x/dev-utils": "^1.0.21", "@0x/sol-compiler": "^1.1.16", diff --git a/packages/sol-cov/src/artifact_adapters/abstract_artifact_adapter.ts b/packages/sol-trace-based-tools-common/src/artifact_adapters/abstract_artifact_adapter.ts similarity index 100% rename from packages/sol-cov/src/artifact_adapters/abstract_artifact_adapter.ts rename to packages/sol-trace-based-tools-common/src/artifact_adapters/abstract_artifact_adapter.ts diff --git a/packages/sol-cov/src/artifact_adapters/sol_compiler_artifact_adapter.ts b/packages/sol-trace-based-tools-common/src/artifact_adapters/sol_compiler_artifact_adapter.ts similarity index 100% rename from packages/sol-cov/src/artifact_adapters/sol_compiler_artifact_adapter.ts rename to packages/sol-trace-based-tools-common/src/artifact_adapters/sol_compiler_artifact_adapter.ts diff --git a/packages/sol-cov/src/artifact_adapters/truffle_artifact_adapter.ts b/packages/sol-trace-based-tools-common/src/artifact_adapters/truffle_artifact_adapter.ts similarity index 98% rename from packages/sol-cov/src/artifact_adapters/truffle_artifact_adapter.ts rename to packages/sol-trace-based-tools-common/src/artifact_adapters/truffle_artifact_adapter.ts index f064911d32..bb2b151530 100644 --- a/packages/sol-cov/src/artifact_adapters/truffle_artifact_adapter.ts +++ b/packages/sol-trace-based-tools-common/src/artifact_adapters/truffle_artifact_adapter.ts @@ -80,7 +80,7 @@ export class TruffleArtifactAdapter extends AbstractArtifactAdapter { throw new Error( `${artifact.contractName} was compiled with solidity ${compilerVersion} but specified version is ${ this._solcVersion - } making it impossible for sol-cov to process traces`, + } making it impossible to process traces`, ); } } diff --git a/packages/sol-cov/src/ast_visitor.ts b/packages/sol-trace-based-tools-common/src/ast_visitor.ts similarity index 100% rename from packages/sol-cov/src/ast_visitor.ts rename to packages/sol-trace-based-tools-common/src/ast_visitor.ts diff --git a/packages/sol-cov/src/collect_coverage_entries.ts b/packages/sol-trace-based-tools-common/src/collect_coverage_entries.ts similarity index 100% rename from packages/sol-cov/src/collect_coverage_entries.ts rename to packages/sol-trace-based-tools-common/src/collect_coverage_entries.ts diff --git a/packages/sol-cov/src/constants.ts b/packages/sol-trace-based-tools-common/src/constants.ts similarity index 100% rename from packages/sol-cov/src/constants.ts rename to packages/sol-trace-based-tools-common/src/constants.ts diff --git a/packages/sol-cov/src/get_source_range_snippet.ts b/packages/sol-trace-based-tools-common/src/get_source_range_snippet.ts similarity index 97% rename from packages/sol-cov/src/get_source_range_snippet.ts rename to packages/sol-trace-based-tools-common/src/get_source_range_snippet.ts index bea17beae9..f578675d31 100644 --- a/packages/sol-cov/src/get_source_range_snippet.ts +++ b/packages/sol-trace-based-tools-common/src/get_source_range_snippet.ts @@ -15,6 +15,11 @@ interface ASTInfo { // Parsing source code for each transaction/code is slow and therefore we cache it const parsedSourceByHash: { [sourceHash: string]: Parser.ASTNode } = {}; +/** + * Gets the source range snippet by source range to be used by revert trace. + * @param sourceRange source range + * @param sourceCode source code + */ export function getSourceRangeSnippet(sourceRange: SourceRange, sourceCode: string): SourceSnippet | null { const sourceHash = ethUtil.sha3(sourceCode).toString('hex'); if (_.isUndefined(parsedSourceByHash[sourceHash])) { diff --git a/packages/sol-trace-based-tools-common/src/globals.d.ts b/packages/sol-trace-based-tools-common/src/globals.d.ts new file mode 100644 index 0000000000..e799b35298 --- /dev/null +++ b/packages/sol-trace-based-tools-common/src/globals.d.ts @@ -0,0 +1,7 @@ +// tslint:disable:completed-docs +declare module '*.json' { + const json: any; + /* tslint:disable */ + export default json; + /* tslint:enable */ +} diff --git a/packages/sol-trace-based-tools-common/src/index.ts b/packages/sol-trace-based-tools-common/src/index.ts new file mode 100644 index 0000000000..413e5305ec --- /dev/null +++ b/packages/sol-trace-based-tools-common/src/index.ts @@ -0,0 +1,39 @@ +export { SolCompilerArtifactAdapter } from './artifact_adapters/sol_compiler_artifact_adapter'; +export { TruffleArtifactAdapter } from './artifact_adapters/truffle_artifact_adapter'; +export { AbstractArtifactAdapter } from './artifact_adapters/abstract_artifact_adapter'; + +export { + ContractData, + EvmCallStack, + SourceRange, + SourceSnippet, + StatementCoverage, + StatementDescription, + BranchCoverage, + BranchDescription, + Subtrace, + TraceInfo, + Coverage, + LineColumn, + LineCoverage, + FunctionCoverage, + FunctionDescription, + SingleFileSourceRange, + BranchMap, + EvmCallStackEntry, + FnMap, + LocationByOffset, + StatementMap, + TraceInfoBase, + TraceInfoExistingContract, + TraceInfoNewContract, +} from './types'; +export { collectCoverageEntries } from './collect_coverage_entries'; +export { TraceCollector, SingleFileSubtraceHandler } from './trace_collector'; +export { TraceInfoSubprovider } from './trace_info_subprovider'; +export { utils } from './utils'; +export { constants } from './constants'; +export { parseSourceMap } from './source_maps'; +export { getSourceRangeSnippet } from './get_source_range_snippet'; +export { getRevertTrace } from './revert_trace'; +export { TraceCollectionSubprovider } from './trace_collection_subprovider'; diff --git a/packages/sol-cov/src/instructions.ts b/packages/sol-trace-based-tools-common/src/instructions.ts similarity index 100% rename from packages/sol-cov/src/instructions.ts rename to packages/sol-trace-based-tools-common/src/instructions.ts diff --git a/packages/sol-cov/src/revert_trace.ts b/packages/sol-trace-based-tools-common/src/revert_trace.ts similarity index 91% rename from packages/sol-cov/src/revert_trace.ts rename to packages/sol-trace-based-tools-common/src/revert_trace.ts index d60c6e7d9b..4d474120ca 100644 --- a/packages/sol-cov/src/revert_trace.ts +++ b/packages/sol-trace-based-tools-common/src/revert_trace.ts @@ -6,6 +6,11 @@ import * as _ from 'lodash'; import { EvmCallStack } from './types'; import { utils } from './utils'; +/** + * Converts linear trace to a call stack by following calls and returns + * @param structLogs Linear trace + * @param startAddress The address of initial context + */ export function getRevertTrace(structLogs: StructLog[], startAddress: string): EvmCallStack { const evmCallStack: EvmCallStack = []; const addressStack = [startAddress]; @@ -55,7 +60,7 @@ export function getRevertTrace(structLogs: StructLog[], startAddress: string): E // TODO: Refactor this logic to fetch the sub-called contract bytecode before the selfdestruct is called // in order to handle this edge-case. logUtils.warn( - "Detected a selfdestruct. Sol-cov currently doesn't support that scenario. We'll just skip the trace part for a destructed contract", + "Detected a selfdestruct. We currently do not support that scenario. We'll just skip the trace part for a destructed contract", ); } } else if (structLog.op === OpCode.Revert) { @@ -67,7 +72,7 @@ export function getRevertTrace(structLogs: StructLog[], startAddress: string): E } else if (structLog.op === OpCode.Create) { // TODO: Extract the new contract address from the stack and handle that scenario logUtils.warn( - "Detected a contract created from within another contract. Sol-cov currently doesn't support that scenario. We'll just skip that trace", + "Detected a contract created from within another contract. We currently do not support that scenario. We'll just skip that trace", ); return []; } else { diff --git a/packages/sol-cov/src/source_maps.ts b/packages/sol-trace-based-tools-common/src/source_maps.ts similarity index 89% rename from packages/sol-cov/src/source_maps.ts rename to packages/sol-trace-based-tools-common/src/source_maps.ts index 90b21dda18..7191fb7127 100644 --- a/packages/sol-cov/src/source_maps.ts +++ b/packages/sol-trace-based-tools-common/src/source_maps.ts @@ -1,7 +1,7 @@ import * as _ from 'lodash'; import { getPcToInstructionIndexMapping } from './instructions'; -import { LineColumn, LocationByOffset, SourceRange } from './types'; +import { LocationByOffset, SourceRange } from './types'; const RADIX = 10; @@ -11,6 +11,10 @@ export interface SourceLocation { fileIndex: number; } +/** + * Receives a string with newlines and returns a hash of byte offset to LineColumn + * @param str A string to process + */ export function getLocationByOffset(str: string): LocationByOffset { const locationByOffset: LocationByOffset = { 0: { line: 1, column: 0 } }; let currentOffset = 0; @@ -26,8 +30,14 @@ export function getLocationByOffset(str: string): LocationByOffset { return locationByOffset; } -// Parses a sourcemap string -// The solidity sourcemap format is documented here: https://github.com/ethereum/solidity/blob/develop/docs/miscellaneous.rst#source-mappings +/** + * Parses a sourcemap string. + * The solidity sourcemap format is documented here: https://github.com/ethereum/solidity/blob/develop/docs/miscellaneous.rst#source-mappings + * @param sourceCodes sources contents + * @param srcMap source map string + * @param bytecodeHex contract bytecode + * @param sources sources file names + */ export function parseSourceMap( sourceCodes: string[], srcMap: string, diff --git a/packages/sol-cov/src/trace.ts b/packages/sol-trace-based-tools-common/src/trace.ts similarity index 92% rename from packages/sol-cov/src/trace.ts rename to packages/sol-trace-based-tools-common/src/trace.ts index b38dbdce0a..770080af37 100644 --- a/packages/sol-cov/src/trace.ts +++ b/packages/sol-trace-based-tools-common/src/trace.ts @@ -8,6 +8,11 @@ export interface TraceByContractAddress { [contractAddress: string]: StructLog[]; } +/** + * Converts linear stack trace to `TraceByContractAddress`. + * @param structLogs stack trace + * @param startAddress initial context address + */ export function getTracesByContractAddress(structLogs: StructLog[], startAddress: string): TraceByContractAddress { const traceByContractAddress: TraceByContractAddress = {}; let currentTraceSegment = []; @@ -58,13 +63,13 @@ export function getTracesByContractAddress(structLogs: StructLog[], startAddress // TODO: Refactor this logic to fetch the sub-called contract bytecode before the selfdestruct is called // in order to handle this edge-case. logUtils.warn( - "Detected a selfdestruct. Sol-cov currently doesn't support that scenario. We'll just skip the trace part for a destructed contract", + "Detected a selfdestruct. We currently do not support that scenario. We'll just skip the trace part for a destructed contract", ); } } else if (structLog.op === OpCode.Create) { // TODO: Extract the new contract address from the stack and handle that scenario logUtils.warn( - "Detected a contract created from within another contract. Sol-cov currently doesn't support that scenario. We'll just skip that trace", + "Detected a contract created from within another contract. We currently do not support that scenario. We'll just skip that trace", ); return traceByContractAddress; } else { diff --git a/packages/sol-cov/src/trace_collection_subprovider.ts b/packages/sol-trace-based-tools-common/src/trace_collection_subprovider.ts similarity index 100% rename from packages/sol-cov/src/trace_collection_subprovider.ts rename to packages/sol-trace-based-tools-common/src/trace_collection_subprovider.ts diff --git a/packages/sol-cov/src/trace_collector.ts b/packages/sol-trace-based-tools-common/src/trace_collector.ts similarity index 98% rename from packages/sol-cov/src/trace_collector.ts rename to packages/sol-trace-based-tools-common/src/trace_collector.ts index 44cffc2385..8ba71f4df9 100644 --- a/packages/sol-cov/src/trace_collector.ts +++ b/packages/sol-trace-based-tools-common/src/trace_collector.ts @@ -51,7 +51,7 @@ export class TraceCollector { singleFileSubtraceHandler: SingleFileSubtraceHandler, ) { this._artifactAdapter = artifactAdapter; - this._logger = getLogger('sol-cov'); + this._logger = getLogger('sol-trace-based-tools-common'); this._logger.setLevel(isVerbose ? levels.TRACE : levels.ERROR); this._singleFileSubtraceHandler = singleFileSubtraceHandler; } diff --git a/packages/sol-cov/src/trace_info_subprovider.ts b/packages/sol-trace-based-tools-common/src/trace_info_subprovider.ts similarity index 100% rename from packages/sol-cov/src/trace_info_subprovider.ts rename to packages/sol-trace-based-tools-common/src/trace_info_subprovider.ts diff --git a/packages/sol-cov/src/types.ts b/packages/sol-trace-based-tools-common/src/types.ts similarity index 100% rename from packages/sol-cov/src/types.ts rename to packages/sol-trace-based-tools-common/src/types.ts diff --git a/packages/sol-cov/src/utils.ts b/packages/sol-trace-based-tools-common/src/utils.ts similarity index 100% rename from packages/sol-cov/src/utils.ts rename to packages/sol-trace-based-tools-common/src/utils.ts diff --git a/packages/sol-cov/test/collect_coverage_entries_test.ts b/packages/sol-trace-based-tools-common/test/collect_coverage_entries_test.ts similarity index 100% rename from packages/sol-cov/test/collect_coverage_entries_test.ts rename to packages/sol-trace-based-tools-common/test/collect_coverage_entries_test.ts diff --git a/packages/sol-cov/test/fixtures/contracts/AllSolidityFeatures.sol b/packages/sol-trace-based-tools-common/test/fixtures/contracts/AllSolidityFeatures.sol similarity index 100% rename from packages/sol-cov/test/fixtures/contracts/AllSolidityFeatures.sol rename to packages/sol-trace-based-tools-common/test/fixtures/contracts/AllSolidityFeatures.sol diff --git a/packages/sol-cov/test/fixtures/contracts/SimpleStorage.sol b/packages/sol-trace-based-tools-common/test/fixtures/contracts/SimpleStorage.sol similarity index 100% rename from packages/sol-cov/test/fixtures/contracts/SimpleStorage.sol rename to packages/sol-trace-based-tools-common/test/fixtures/contracts/SimpleStorage.sol diff --git a/packages/sol-cov/test/fixtures/contracts/Simplest.sol b/packages/sol-trace-based-tools-common/test/fixtures/contracts/Simplest.sol similarity index 100% rename from packages/sol-cov/test/fixtures/contracts/Simplest.sol rename to packages/sol-trace-based-tools-common/test/fixtures/contracts/Simplest.sol diff --git a/packages/sol-cov/test/fixtures/contracts/SolcovIgnore.sol b/packages/sol-trace-based-tools-common/test/fixtures/contracts/SolcovIgnore.sol similarity index 100% rename from packages/sol-cov/test/fixtures/contracts/SolcovIgnore.sol rename to packages/sol-trace-based-tools-common/test/fixtures/contracts/SolcovIgnore.sol diff --git a/packages/sol-cov/test/instructions_test.ts b/packages/sol-trace-based-tools-common/test/instructions_test.ts similarity index 100% rename from packages/sol-cov/test/instructions_test.ts rename to packages/sol-trace-based-tools-common/test/instructions_test.ts diff --git a/packages/sol-cov/test/sol_compiler_artifact_adapter_test.ts b/packages/sol-trace-based-tools-common/test/sol_compiler_artifact_adapter_test.ts similarity index 100% rename from packages/sol-cov/test/sol_compiler_artifact_adapter_test.ts rename to packages/sol-trace-based-tools-common/test/sol_compiler_artifact_adapter_test.ts diff --git a/packages/sol-cov/test/source_maps_test.ts b/packages/sol-trace-based-tools-common/test/source_maps_test.ts similarity index 100% rename from packages/sol-cov/test/source_maps_test.ts rename to packages/sol-trace-based-tools-common/test/source_maps_test.ts diff --git a/packages/sol-cov/test/trace_test.ts b/packages/sol-trace-based-tools-common/test/trace_test.ts similarity index 100% rename from packages/sol-cov/test/trace_test.ts rename to packages/sol-trace-based-tools-common/test/trace_test.ts diff --git a/packages/sol-cov/test/utils_test.ts b/packages/sol-trace-based-tools-common/test/utils_test.ts similarity index 100% rename from packages/sol-cov/test/utils_test.ts rename to packages/sol-trace-based-tools-common/test/utils_test.ts diff --git a/packages/sol-cov/tsconfig.json b/packages/sol-trace-based-tools-common/tsconfig.json similarity index 100% rename from packages/sol-cov/tsconfig.json rename to packages/sol-trace-based-tools-common/tsconfig.json diff --git a/packages/sol-trace-based-tools-common/tslint.json b/packages/sol-trace-based-tools-common/tslint.json new file mode 100644 index 0000000000..dd9053357e --- /dev/null +++ b/packages/sol-trace-based-tools-common/tslint.json @@ -0,0 +1,3 @@ +{ + "extends": ["@0x/tslint-config"] +} diff --git a/packages/sol-trace/.npmignore b/packages/sol-trace/.npmignore new file mode 100644 index 0000000000..037786e46b --- /dev/null +++ b/packages/sol-trace/.npmignore @@ -0,0 +1,6 @@ +.* +yarn-error.log +/src/ +/scripts/ +tsconfig.json +/lib/src/monorepo_scripts/ diff --git a/packages/sol-trace/CHANGELOG.json b/packages/sol-trace/CHANGELOG.json new file mode 100644 index 0000000000..ca6048d99a --- /dev/null +++ b/packages/sol-trace/CHANGELOG.json @@ -0,0 +1,12 @@ +[ + { + "version": "1.0.0", + "changes": [ + { + "note": + "Initial release as a separate package. For historic entries check @0x/sol-trace-based-tools-common", + "pr": 1492 + } + ] + } +] diff --git a/packages/sol-trace/README.md b/packages/sol-trace/README.md new file mode 100644 index 0000000000..dba1934265 --- /dev/null +++ b/packages/sol-trace/README.md @@ -0,0 +1,75 @@ +## @0x/sol-trace + +Prints code traces when revert happens. + +### Read the [Documentation](https://0xproject.com/docs/sol-trace). + +## Installation + +```bash +yarn add @0x/sol-trace +``` + +**Import** + +```javascript +import { RevertTraceSubprovider } from '@0x/sol-trace'; +``` + +or + +```javascript +var RevertTraceSubprovider = require('@0x/sol-trace').RevertTraceSubprovider; +``` + +## Contributing + +We welcome improvements and fixes from the wider community! To report bugs within this package, please create an issue in this repository. + +Please read our [contribution guidelines](../../CONTRIBUTING.md) before getting started. + +### Install dependencies + +If you don't have yarn workspaces enabled (Yarn < v1.0) - enable them: + +```bash +yarn config set workspaces-experimental true +``` + +Then install dependencies + +```bash +yarn install +``` + +### Build + +To build this package and all other monorepo packages that it depends on, run the following from the monorepo root directory: + +```bash +PKG=@0x/sol-trace yarn build +``` + +Or continuously rebuild on change: + +```bash +PKG=@0x/sol-trace yarn watch +``` + +### Clean + +```bash +yarn clean +``` + +### Lint + +```bash +yarn lint +``` + +### Run Tests + +```bash +yarn test +``` diff --git a/packages/sol-trace/package.json b/packages/sol-trace/package.json new file mode 100644 index 0000000000..fd80c541eb --- /dev/null +++ b/packages/sol-trace/package.json @@ -0,0 +1,52 @@ +{ + "name": "@0x/sol-trace", + "version": "1.0.0", + "engines": { + "node": ">=6.12" + }, + "description": "Prints stack trace on Solidity revert", + "main": "lib/src/index.js", + "types": "lib/src/index.d.ts", + "scripts": { + "build": "tsc -b", + "build:ci": "yarn build", + "lint": "tslint --format stylish --project .", + "clean": "shx rm -rf lib src/artifacts generated_docs", + "docs:json": "typedoc --excludePrivate --excludeExternals --target ES5 --tsconfig typedoc-tsconfig.json --json $JSON_FILE_PATH $PROJECT_FILES" + }, + "config": { + "postpublish": { + "assets": [] + } + }, + "repository": { + "type": "git", + "url": "https://github.com/0xProject/0x-monorepo.git" + }, + "license": "Apache-2.0", + "bugs": { + "url": "https://github.com/0xProject/0x-monorepo/issues" + }, + "homepage": "https://github.com/0xProject/0x-monorepo/packages/sol-trace/README.md", + "dependencies": { + "@0x/subproviders": "^2.1.8", + "@0x/typescript-typings": "^3.0.6", + "@0x/sol-trace-based-tools-common": "^2.1.16", + "ethereum-types": "^1.1.4", + "ethereumjs-util": "^5.1.1", + "lodash": "^4.17.5", + "loglevel": "^1.6.1" + }, + "devDependencies": { + "@0x/tslint-config": "^2.0.0", + "@types/loglevel": "^1.5.3", + "@types/node": "*", + "npm-run-all": "^4.1.2", + "shx": "^0.2.2", + "tslint": "5.11.0", + "typescript": "3.0.1" + }, + "publishConfig": { + "access": "public" + } +} diff --git a/packages/sol-trace/src/globals.d.ts b/packages/sol-trace/src/globals.d.ts new file mode 100644 index 0000000000..e799b35298 --- /dev/null +++ b/packages/sol-trace/src/globals.d.ts @@ -0,0 +1,7 @@ +// tslint:disable:completed-docs +declare module '*.json' { + const json: any; + /* tslint:disable */ + export default json; + /* tslint:enable */ +} diff --git a/packages/sol-trace/src/index.ts b/packages/sol-trace/src/index.ts new file mode 100644 index 0000000000..1f3ca3a991 --- /dev/null +++ b/packages/sol-trace/src/index.ts @@ -0,0 +1,24 @@ +export { + AbstractArtifactAdapter, + TruffleArtifactAdapter, + SolCompilerArtifactAdapter, + ContractData, +} from '@0x/sol-trace-based-tools-common'; + +export { RevertTraceSubprovider } from './revert_trace_subprovider'; + +export { + JSONRPCRequestPayload, + Provider, + JSONRPCErrorCallback, + JSONRPCResponsePayload, + JSONRPCResponseError, +} from 'ethereum-types'; + +export { + JSONRPCRequestPayloadWithMethod, + NextCallback, + ErrorCallback, + OnNextCompleted, + Callback, +} from '@0x/subproviders'; diff --git a/packages/sol-cov/src/revert_trace_subprovider.ts b/packages/sol-trace/src/revert_trace_subprovider.ts similarity index 92% rename from packages/sol-cov/src/revert_trace_subprovider.ts rename to packages/sol-trace/src/revert_trace_subprovider.ts index 6ccf59653a..37e62b3f8c 100644 --- a/packages/sol-cov/src/revert_trace_subprovider.ts +++ b/packages/sol-trace/src/revert_trace_subprovider.ts @@ -1,16 +1,20 @@ +import { + AbstractArtifactAdapter, + constants, + ContractData, + EvmCallStack, + getRevertTrace, + getSourceRangeSnippet, + parseSourceMap, + SourceRange, + SourceSnippet, + TraceCollectionSubprovider, + utils, +} from '@0x/sol-trace-based-tools-common'; import { stripHexPrefix } from 'ethereumjs-util'; import * as _ from 'lodash'; import { getLogger, levels, Logger } from 'loglevel'; -import { AbstractArtifactAdapter } from './artifact_adapters/abstract_artifact_adapter'; -import { constants } from './constants'; -import { getSourceRangeSnippet } from './get_source_range_snippet'; -import { getRevertTrace } from './revert_trace'; -import { parseSourceMap } from './source_maps'; -import { TraceCollectionSubprovider } from './trace_collection_subprovider'; -import { ContractData, EvmCallStack, SourceRange, SourceSnippet } from './types'; -import { utils } from './utils'; - /** * This class implements the [web3-provider-engine](https://github.com/MetaMask/provider-engine) subprovider interface. * It is used to report call stack traces whenever a revert occurs. @@ -35,7 +39,7 @@ export class RevertTraceSubprovider extends TraceCollectionSubprovider { }; super(defaultFromAddress, traceCollectionSubproviderConfig); this._artifactAdapter = artifactAdapter; - this._logger = getLogger('sol-cov'); + this._logger = getLogger('sol-trace'); this._logger.setLevel(isVerbose ? levels.TRACE : levels.ERROR); } // tslint:disable-next-line:no-unused-variable diff --git a/packages/sol-trace/tsconfig.json b/packages/sol-trace/tsconfig.json new file mode 100644 index 0000000000..233008d61c --- /dev/null +++ b/packages/sol-trace/tsconfig.json @@ -0,0 +1,8 @@ +{ + "extends": "../../tsconfig", + "compilerOptions": { + "outDir": "lib", + "rootDir": "." + }, + "include": ["./src/**/*"] +} diff --git a/packages/sol-trace/tslint.json b/packages/sol-trace/tslint.json new file mode 100644 index 0000000000..dd9053357e --- /dev/null +++ b/packages/sol-trace/tslint.json @@ -0,0 +1,3 @@ +{ + "extends": ["@0x/tslint-config"] +} diff --git a/packages/sol-trace/typedoc-tsconfig.json b/packages/sol-trace/typedoc-tsconfig.json new file mode 100644 index 0000000000..a4c669cb6d --- /dev/null +++ b/packages/sol-trace/typedoc-tsconfig.json @@ -0,0 +1,7 @@ +{ + "extends": "../../typedoc-tsconfig", + "compilerOptions": { + "outDir": "lib" + }, + "include": ["./src/**/*"] +} diff --git a/packages/sra-spec/src/md/introduction.md b/packages/sra-spec/src/md/introduction.md index 824df89984..ce61abff64 100644 --- a/packages/sra-spec/src/md/introduction.md +++ b/packages/sra-spec/src/md/introduction.md @@ -1,12 +1,12 @@ # Schemas -The [JSON schemas](http://json-schema.org/) for the API payloads and responses can be found in [@0xproject/json-schemas](https://github.com/0xProject/0x.js/tree/development/packages/json-schemas). Examples of each payload and response can be found in the library's [test suite](https://github.com/0xProject/0x.js/blob/development/packages/json-schemas/test/schema_test.ts#L1). +The [JSON schemas](http://json-schema.org/) for the API payloads and responses can be found in [@0xproject/json-schemas](https://github.com/0xProject/0x-monorepo/tree/development/packages/json-schemas). Examples of each payload and response can be found in the library's [test suite](https://github.com/0xProject/0x-monorepo/blob/development/packages/json-schemas/test/schema_test.ts#L1). ```bash npm install @0xproject/json-schemas --save ``` -You can easily validate your API's payloads and responses using the [@0xproject/json-schemas](https://github.com/0xProject/0x.js/tree/development/packages/json-schemas) package: +You can easily validate your API's payloads and responses using the [@0xproject/json-schemas](https://github.com/0xProject/0x-monorepo/tree/development/packages/json-schemas) package: ```js import {SchemaValidator, ValidatorResult, schemas} from '@0xproject/json-schemas'; diff --git a/packages/website/md/docs/sol_cov/1/installation.md b/packages/website/md/docs/sol_cov/1/installation.md deleted file mode 100644 index b9ce25a5fd..0000000000 --- a/packages/website/md/docs/sol_cov/1/installation.md +++ /dev/null @@ -1,17 +0,0 @@ -**Install** - -```bash -yarn add @0xproject/sol-cov -``` - -**Import** - -```javascript -import { CoverageSubprovider } from '@0xproject/sol-cov'; -``` - -or - -```javascript -var CoverageSubprovider = require('@0xproject/sol-cov').CoverageSubprovider; -``` diff --git a/packages/website/md/docs/sol_cov/1/introduction.md b/packages/website/md/docs/sol_cov/1/introduction.md deleted file mode 100644 index 7064a35546..0000000000 --- a/packages/website/md/docs/sol_cov/1/introduction.md +++ /dev/null @@ -1 +0,0 @@ -Welcome to the [@0xproject/sol-cov](https://github.com/0xProject/0x-monorepo/tree/development/packages/sol-cov) documentation! Sol-cov is a Solidity coverage tool for your smart contract tests. diff --git a/packages/website/md/docs/sol_cov/2/installation.md b/packages/website/md/docs/sol_cov/2/installation.md deleted file mode 100644 index 1d4557cf55..0000000000 --- a/packages/website/md/docs/sol_cov/2/installation.md +++ /dev/null @@ -1,17 +0,0 @@ -**Install** - -```bash -yarn add @0x/sol-cov -``` - -**Import** - -```javascript -import { CoverageSubprovider } from '@0x/sol-cov'; -``` - -or - -```javascript -var CoverageSubprovider = require('@0x/sol-cov').CoverageSubprovider; -``` diff --git a/packages/website/md/docs/sol_cov/2/introduction.md b/packages/website/md/docs/sol_cov/2/introduction.md deleted file mode 100644 index ac3256845a..0000000000 --- a/packages/website/md/docs/sol_cov/2/introduction.md +++ /dev/null @@ -1 +0,0 @@ -Welcome to the [sol-cov](https://github.com/0xProject/0x-monorepo/tree/development/packages/sol-cov) documentation! Sol-cov is a Solidity coverage tool for your smart contract tests. diff --git a/packages/website/md/docs/sol_coverage/installation.md b/packages/website/md/docs/sol_coverage/installation.md new file mode 100644 index 0000000000..c7aaf07e91 --- /dev/null +++ b/packages/website/md/docs/sol_coverage/installation.md @@ -0,0 +1,17 @@ +**Install** + +```bash +yarn add @0x/sol-coverage +``` + +**Import** + +```javascript +import { CoverageSubprovider } from '@0x/sol-coverage'; +``` + +or + +```javascript +var CoverageSubprovider = require('@0x/sol-coverage').CoverageSubprovider; +``` diff --git a/packages/website/md/docs/sol_coverage/introduction.md b/packages/website/md/docs/sol_coverage/introduction.md new file mode 100644 index 0000000000..3214e93a97 --- /dev/null +++ b/packages/website/md/docs/sol_coverage/introduction.md @@ -0,0 +1 @@ +Welcome to the [sol-coverage](https://github.com/0xProject/0x-monorepo/tree/development/packages/sol-coverage) documentation! Sol-coverage is a Solidity coverage tool for your smart contract tests. diff --git a/packages/website/md/docs/sol_cov/2/usage.md b/packages/website/md/docs/sol_coverage/usage.md similarity index 80% rename from packages/website/md/docs/sol_cov/2/usage.md rename to packages/website/md/docs/sol_coverage/usage.md index 8e33f3bf50..dd3cdf5978 100644 --- a/packages/website/md/docs/sol_cov/2/usage.md +++ b/packages/website/md/docs/sol_coverage/usage.md @@ -1,4 +1,4 @@ -Sol-cov uses transaction traces in order to figure out which lines of Solidity source code have been covered by your tests. In order for it to gather these traces, you must add the `CoverageSubprovider` to the [ProviderEngine](https://github.com/MetaMask/provider-engine) instance you use when running your Solidity tests. If you're unfamiliar with ProviderEngine, please read the [Web3 Provider explained](https://0x.org/wiki#Web3-Provider-Explained) wiki article. +Sol-coverage uses transaction traces in order to figure out which lines of Solidity source code have been covered by your tests. In order for it to gather these traces, you must add the `CoverageSubprovider` to the [ProviderEngine](https://github.com/MetaMask/provider-engine) instance you use when running your Solidity tests. If you're unfamiliar with ProviderEngine, please read the [Web3 Provider explained](https://0x.org/wiki#Web3-Provider-Explained) wiki article. The CoverageSubprovider eavesdrops on the `eth_sendTransaction` and `eth_call` RPC calls and collects traces after each call using `debug_traceTransaction`. `eth_call`'s' don't generate traces - so we take a snapshot, re-submit it as a transaction, get the trace and then revert the snapshot. @@ -11,7 +11,7 @@ In order to use `CoverageSubprovider` with your favorite framework you need to p If you are generating your artifacts with [@0x/sol-compiler](https://0x.org/docs/sol-compiler) you can use the `SolCompilerArtifactsAdapter` we've implemented for you. ```typescript -import { SolCompilerArtifactsAdapter } from '@0x/sol-cov'; +import { SolCompilerArtifactsAdapter } from '@0x/sol-coverage'; const artifactsPath = 'src/artifacts'; const contractsPath = 'src/contracts'; const artifactsAdapter = new SolCompilerArtifactsAdapter(artifactsPath, contractsPath); @@ -22,7 +22,7 @@ const artifactsAdapter = new SolCompilerArtifactsAdapter(artifactsPath, contract If your project is using [Truffle](https://truffleframework.com/), we've written a `TruffleArtifactsAdapter`for you. ```typescript -import { TruffleArtifactAdapter } from '@0x/sol-cov'; +import { TruffleArtifactAdapter } from '@0x/sol-coverage'; const contractsPath = 'src/contracts'; const artifactAdapter = new TruffleArtifactAdapter(contractsDir); ``` @@ -37,7 +37,7 @@ Look at the code of the two adapters above for examples. ### Usage ```typescript -import { CoverageSubprovider } from '@0x/sol-cov'; +import { CoverageSubprovider } from '@0x/sol-coverage'; import ProviderEngine = require('web3-provider-engine'); const provider = new ProviderEngine(); diff --git a/packages/website/md/docs/sol_profiler/installation.md b/packages/website/md/docs/sol_profiler/installation.md new file mode 100644 index 0000000000..be9a365f5e --- /dev/null +++ b/packages/website/md/docs/sol_profiler/installation.md @@ -0,0 +1,17 @@ +**Install** + +```bash +yarn add @0x/sol-profiler +``` + +**Import** + +```javascript +import { ProfilerSubprovider } from '@0x/sol-profiler'; +``` + +or + +```javascript +var ProfilerSubprovider = require('@0x/sol-profiler').ProfilerSubprovider; +``` diff --git a/packages/website/md/docs/sol_profiler/introduction.md b/packages/website/md/docs/sol_profiler/introduction.md new file mode 100644 index 0000000000..bd53fb0fe7 --- /dev/null +++ b/packages/website/md/docs/sol_profiler/introduction.md @@ -0,0 +1 @@ +Welcome to the [sol-profiler](https://github.com/0xProject/0x-monorepo/tree/development/packages/sol-profiler) documentation! Sol-profiler is a Solidity profiler tool. diff --git a/packages/website/md/docs/sol_cov/1/usage.md b/packages/website/md/docs/sol_profiler/usage.md similarity index 61% rename from packages/website/md/docs/sol_cov/1/usage.md rename to packages/website/md/docs/sol_profiler/usage.md index c2b8404afc..35ea140dae 100644 --- a/packages/website/md/docs/sol_cov/1/usage.md +++ b/packages/website/md/docs/sol_profiler/usage.md @@ -1,17 +1,17 @@ -Sol-cov uses transaction traces in order to figure out which lines of Solidity source code have been covered by your tests. In order for it to gather these traces, you must add the `CoverageSubprovider` to the [ProviderEngine](https://github.com/MetaMask/provider-engine) instance you use when running your Solidity tests. If you're unfamiliar with ProviderEngine, please read the [Web3 Provider explained](https://0x.org/wiki#Web3-Provider-Explained) wiki article. +Sol-profiler uses transaction traces in order to figure out which lines of Solidity source code have been covered by your tests. In order for it to gather these traces, you must add the `ProfilerSubprovider` to the [ProviderEngine](https://github.com/MetaMask/provider-engine) instance you use when running your Solidity tests. If you're unfamiliar with ProviderEngine, please read the [Web3 Provider explained](https://0x.org/wiki#Web3-Provider-Explained) wiki article. -The CoverageSubprovider eavesdrops on the `eth_sendTransaction` and `eth_call` RPC calls and collects traces after each call using `debug_traceTransaction`. `eth_call`'s' don't generate traces - so we take a snapshot, re-submit it as a transaction, get the trace and then revert the snapshot. +The ProfilerSubprovider eavesdrops on the `eth_sendTransaction` and `eth_call` RPC calls and collects traces after each call using `debug_traceTransaction`. `eth_call`'s' don't generate traces - so we take a snapshot, re-submit it as a transaction, get the trace and then revert the snapshot. -Coverage subprovider needs some info about your contracts (`srcMap`, `bytecode`). It gets that info from your project's artifacts. Some frameworks have their own artifact format. Some artifact formats don't actually contain all the neccessary data. +Profiler subprovider needs some info about your contracts (`srcMap`, `bytecode`). It gets that info from your project's artifacts. Some frameworks have their own artifact format. Some artifact formats don't actually contain all the neccessary data. -In order to use `CoverageSubprovider` with your favorite framework you need to pass an `artifactsAdapter` to it. +In order to use `ProfilerSubprovider` with your favorite framework you need to pass an `artifactsAdapter` to it. ### Sol-compiler -If you are generating your artifacts with [@0xproject/sol-compiler](https://0x.org/docs/sol-compiler) you can use the `SolCompilerArtifactsAdapter` we've implemented for you. +If you are generating your artifacts with [@0x/sol-compiler](https://0x.org/docs/sol-compiler) you can use the `SolCompilerArtifactsAdapter` we've implemented for you. ```typescript -import { SolCompilerArtifactsAdapter } from '@0xproject/sol-cov'; +import { SolCompilerArtifactsAdapter } from '@0x/sol-profiler'; const artifactsPath = 'src/artifacts'; const contractsPath = 'src/contracts'; const artifactsAdapter = new SolCompilerArtifactsAdapter(artifactsPath, contractsPath); @@ -22,7 +22,7 @@ const artifactsAdapter = new SolCompilerArtifactsAdapter(artifactsPath, contract If your project is using [Truffle](https://truffleframework.com/), we've written a `TruffleArtifactsAdapter`for you. ```typescript -import { TruffleArtifactAdapter } from '@0xproject/sol-cov'; +import { TruffleArtifactAdapter } from '@0x/sol-profiler'; const contractsPath = 'src/contracts'; const artifactAdapter = new TruffleArtifactAdapter(contractsDir); ``` @@ -37,7 +37,7 @@ Look at the code of the two adapters above for examples. ### Usage ```typescript -import { CoverageSubprovider } from '@0xproject/sol-cov'; +import { ProfilerSubprovider } from '@0x/sol-profiler'; import ProviderEngine = require('web3-provider-engine'); const provider = new ProviderEngine(); @@ -48,15 +48,15 @@ const networkId = 50; // Some calls might not have `from` address specified. Nevertheless - transactions need to be submitted from an address with at least some funds. defaultFromAddress is the address that will be used to submit those calls as transactions from. const defaultFromAddress = '0x5409ed021d9299bf6814279a6a1411a7e866a631'; const isVerbose = true; -const coverageSubprovider = new CoverageSubprovider(artifactsAdapter, defaultFromAddress, isVerbose); +const profilerSubprovider = new ProfilerSubprovider(artifactsAdapter, defaultFromAddress, isVerbose); -provider.addProvider(coverageSubprovider); +provider.addProvider(profilerSubprovider); ``` After your test suite is complete (e.g in the Mocha global `after` hook), you'll need to call: ```typescript -await coverageSubprovider.writeCoverageAsync(); +await profilerSubprovider.writeProfilerAsync(); ``` -This will create a `coverage.json` file in a `coverage` directory. This file has an [Istanbul format](https://github.com/gotwarlost/istanbul/blob/master/coverage.json.md) - so you can use it with any of the existing Istanbul reporters. +This will create a `profiler.json` file in a `profiler` directory. This file has an [Istanbul format](https://github.com/gotwarlost/istanbul/blob/master/profiler.json.md) - so you can use it with any of the existing Istanbul reporters. diff --git a/packages/website/md/docs/sol_trace/installation.md b/packages/website/md/docs/sol_trace/installation.md new file mode 100644 index 0000000000..2f794b2f8f --- /dev/null +++ b/packages/website/md/docs/sol_trace/installation.md @@ -0,0 +1,17 @@ +**Install** + +```bash +yarn add @0x/sol-trace +``` + +**Import** + +```javascript +import { TraceSubprovider } from '@0x/sol-trace'; +``` + +or + +```javascript +var TraceSubprovider = require('@0x/sol-trace').TraceSubprovider; +``` diff --git a/packages/website/md/docs/sol_trace/introduction.md b/packages/website/md/docs/sol_trace/introduction.md new file mode 100644 index 0000000000..21fea764e4 --- /dev/null +++ b/packages/website/md/docs/sol_trace/introduction.md @@ -0,0 +1 @@ +Welcome to the [sol-trace](https://github.com/0xProject/0x-monorepo/tree/development/packages/sol-trace) documentation! Sol-trace is a Solidity trace tool for your smart contract tests. diff --git a/packages/website/md/docs/sol_trace/usage.md b/packages/website/md/docs/sol_trace/usage.md new file mode 100644 index 0000000000..f3aa6fc35a --- /dev/null +++ b/packages/website/md/docs/sol_trace/usage.md @@ -0,0 +1,62 @@ +Sol-trace uses transaction traces in order to figure out which lines of Solidity source code have been covered by your tests. In order for it to gather these traces, you must add the `TraceSubprovider` to the [ProviderEngine](https://github.com/MetaMask/provider-engine) instance you use when running your Solidity tests. If you're unfamiliar with ProviderEngine, please read the [Web3 Provider explained](https://0x.org/wiki#Web3-Provider-Explained) wiki article. + +The TraceSubprovider eavesdrops on the `eth_sendTransaction` and `eth_call` RPC calls and collects traces after each call using `debug_traceTransaction`. `eth_call`'s' don't generate traces - so we take a snapshot, re-submit it as a transaction, get the trace and then revert the snapshot. + +Trace subprovider needs some info about your contracts (`srcMap`, `bytecode`). It gets that info from your project's artifacts. Some frameworks have their own artifact format. Some artifact formats don't actually contain all the neccessary data. + +In order to use `TraceSubprovider` with your favorite framework you need to pass an `artifactsAdapter` to it. + +### Sol-compiler + +If you are generating your artifacts with [@0x/sol-compiler](https://0x.org/docs/sol-compiler) you can use the `SolCompilerArtifactsAdapter` we've implemented for you. + +```typescript +import { SolCompilerArtifactsAdapter } from '@0x/sol-trace'; +const artifactsPath = 'src/artifacts'; +const contractsPath = 'src/contracts'; +const artifactsAdapter = new SolCompilerArtifactsAdapter(artifactsPath, contractsPath); +``` + +### Truffle + +If your project is using [Truffle](https://truffleframework.com/), we've written a `TruffleArtifactsAdapter`for you. + +```typescript +import { TruffleArtifactAdapter } from '@0x/sol-trace'; +const contractsPath = 'src/contracts'; +const artifactAdapter = new TruffleArtifactAdapter(contractsDir); +``` + +Because truffle artifacts don't have all the data we need - we actually will recompile your contracts under the hood. That's why you don't need to pass an `artifactsPath`. + +### Other framework/toolset + +You'll need to write your own artifacts adapter. It should extend `AbstractArtifactsAdapter`. +Look at the code of the two adapters above for examples. + +### Usage + +```typescript +import { TraceSubprovider } from '@0x/sol-trace'; +import ProviderEngine = require('web3-provider-engine'); + +const provider = new ProviderEngine(); + +const artifactsPath = 'src/artifacts'; +const contractsPath = 'src/contracts'; +const networkId = 50; +// Some calls might not have `from` address specified. Nevertheless - transactions need to be submitted from an address with at least some funds. defaultFromAddress is the address that will be used to submit those calls as transactions from. +const defaultFromAddress = '0x5409ed021d9299bf6814279a6a1411a7e866a631'; +const isVerbose = true; +const traceSubprovider = new TraceSubprovider(artifactsAdapter, defaultFromAddress, isVerbose); + +provider.addProvider(traceSubprovider); +``` + +After your test suite is complete (e.g in the Mocha global `after` hook), you'll need to call: + +```typescript +await traceSubprovider.writeTraceAsync(); +``` + +This will create a `trace.json` file in a `trace` directory. This file has an [Istanbul format](https://github.com/gotwarlost/istanbul/blob/master/trace.json.md) - so you can use it with any of the existing Istanbul reporters. diff --git a/packages/website/ts/containers/asset_buyer_documentation.ts b/packages/website/ts/containers/asset_buyer_documentation.ts index c93b9332d2..815176e47e 100644 --- a/packages/website/ts/containers/asset_buyer_documentation.ts +++ b/packages/website/ts/containers/asset_buyer_documentation.ts @@ -1,12 +1,10 @@ -import { DocsInfo, DocsInfoConfig, SupportedDocJson } from '@0x/react-docs'; +import { DocsInfoConfig, SupportedDocJson } from '@0x/react-docs'; import * as React from 'react'; import { connect } from 'react-redux'; -import { Dispatch } from 'redux'; import { DocPage as DocPageComponent, DocPageProps } from 'ts/pages/documentation/doc_page'; -import { Dispatcher } from 'ts/redux/dispatcher'; -import { State } from 'ts/redux/reducer'; -import { DocPackages, ScreenWidths } from 'ts/types'; -import { Translate } from 'ts/utils/translate'; +import { DocPackages } from 'ts/types'; + +import { getMapStateToProps, mapDispatchToProps } from '../utils/documentation_container'; /* tslint:disable:no-var-requires */ const IntroMarkdown = require('md/docs/asset_buyer/introduction'); @@ -25,7 +23,7 @@ const docsInfoConfig: DocsInfoConfig = { packageName: '@0x/asset-buyer', type: SupportedDocJson.TypeDoc, displayName: 'AssetBuyer', - packageUrl: 'https://github.com/0xProject/0x-monorepo', + packageUrl: 'https://github.com/0xProject/0x-monorepo/packages/asset-buyer', markdownMenu: { introduction: [markdownSections.introduction], install: [markdownSections.installation], @@ -40,31 +38,7 @@ const docsInfoConfig: DocsInfoConfig = { }, markdownSections, }; -const docsInfo = new DocsInfo(docsInfoConfig); - -interface ConnectedState { - docsVersion: string; - availableDocVersions: string[]; - docsInfo: DocsInfo; - translate: Translate; - screenWidth: ScreenWidths; -} - -interface ConnectedDispatch { - dispatcher: Dispatcher; -} - -const mapStateToProps = (state: State, _ownProps: DocPageProps): ConnectedState => ({ - docsVersion: state.docsVersion, - availableDocVersions: state.availableDocVersions, - translate: state.translate, - docsInfo, - screenWidth: state.screenWidth, -}); - -const mapDispatchToProps = (dispatch: Dispatch): ConnectedDispatch => ({ - dispatcher: new Dispatcher(dispatch), -}); +const mapStateToProps = getMapStateToProps(docsInfoConfig); export const Documentation: React.ComponentClass = connect(mapStateToProps, mapDispatchToProps)( DocPageComponent, diff --git a/packages/website/ts/containers/connect_documentation.ts b/packages/website/ts/containers/connect_documentation.ts index 0f11e0809f..19fd0ee560 100644 --- a/packages/website/ts/containers/connect_documentation.ts +++ b/packages/website/ts/containers/connect_documentation.ts @@ -1,12 +1,10 @@ -import { DocsInfo, DocsInfoConfig, SupportedDocJson } from '@0x/react-docs'; +import { DocsInfoConfig, SupportedDocJson } from '@0x/react-docs'; import * as React from 'react'; import { connect } from 'react-redux'; -import { Dispatch } from 'redux'; import { DocPage as DocPageComponent, DocPageProps } from 'ts/pages/documentation/doc_page'; -import { Dispatcher } from 'ts/redux/dispatcher'; -import { State } from 'ts/redux/reducer'; -import { DocPackages, ScreenWidths } from 'ts/types'; -import { Translate } from 'ts/utils/translate'; +import { DocPackages } from 'ts/types'; + +import { getMapStateToProps, mapDispatchToProps } from '../utils/documentation_container'; /* tslint:disable:no-var-requires */ const IntroMarkdown1 = require('md/docs/connect/1/introduction'); @@ -25,7 +23,7 @@ const docsInfoConfig: DocsInfoConfig = { packageName: '@0x/connect', type: SupportedDocJson.TypeDoc, displayName: '0x Connect', - packageUrl: 'https://github.com/0xProject/0x-monorepo', + packageUrl: 'https://github.com/0xProject/0x-monorepo/packages/connect', markdownMenu: { 'getting-started': [markdownSections.introduction, markdownSections.installation], }, @@ -45,31 +43,7 @@ const docsInfoConfig: DocsInfoConfig = { }, markdownSections, }; -const docsInfo = new DocsInfo(docsInfoConfig); - -interface ConnectedState { - docsVersion: string; - availableDocVersions: string[]; - docsInfo: DocsInfo; - translate: Translate; - screenWidth: ScreenWidths; -} - -interface ConnectedDispatch { - dispatcher: Dispatcher; -} - -const mapStateToProps = (state: State, _ownProps: DocPageProps): ConnectedState => ({ - docsVersion: state.docsVersion, - availableDocVersions: state.availableDocVersions, - translate: state.translate, - docsInfo, - screenWidth: state.screenWidth, -}); - -const mapDispatchToProps = (dispatch: Dispatch): ConnectedDispatch => ({ - dispatcher: new Dispatcher(dispatch), -}); +const mapStateToProps = getMapStateToProps(docsInfoConfig); export const Documentation: React.ComponentClass = connect(mapStateToProps, mapDispatchToProps)( DocPageComponent, diff --git a/packages/website/ts/containers/contract_wrappers_documentation.ts b/packages/website/ts/containers/contract_wrappers_documentation.ts index 4c05605e36..dec95ae621 100644 --- a/packages/website/ts/containers/contract_wrappers_documentation.ts +++ b/packages/website/ts/containers/contract_wrappers_documentation.ts @@ -1,12 +1,10 @@ -import { DocsInfo, DocsInfoConfig, SupportedDocJson } from '@0x/react-docs'; +import { DocsInfoConfig, SupportedDocJson } from '@0x/react-docs'; import * as React from 'react'; import { connect } from 'react-redux'; -import { Dispatch } from 'redux'; import { DocPage as DocPageComponent, DocPageProps } from 'ts/pages/documentation/doc_page'; -import { Dispatcher } from 'ts/redux/dispatcher'; -import { State } from 'ts/redux/reducer'; -import { DocPackages, ScreenWidths } from 'ts/types'; -import { Translate } from 'ts/utils/translate'; +import { DocPackages } from 'ts/types'; + +import { getMapStateToProps, mapDispatchToProps } from '../utils/documentation_container'; /* tslint:disable:no-var-requires */ const IntroMarkdown1 = require('md/docs/contract_wrappers/1/introduction'); @@ -24,7 +22,7 @@ const docsInfoConfig: DocsInfoConfig = { packageName: '@0x/contract-wrappers', type: SupportedDocJson.TypeDoc, displayName: 'Contract Wrappers', - packageUrl: 'https://github.com/0xProject/0x-monorepo', + packageUrl: 'https://github.com/0xProject/0x-monorepo/packages/contract-wrappers', markdownMenu: { 'getting-started': [markdownSections.introduction, markdownSections.installation], }, @@ -40,31 +38,7 @@ const docsInfoConfig: DocsInfoConfig = { }, markdownSections, }; -const docsInfo = new DocsInfo(docsInfoConfig); - -interface ConnectedState { - docsVersion: string; - availableDocVersions: string[]; - docsInfo: DocsInfo; - translate: Translate; - screenWidth: ScreenWidths; -} - -interface ConnectedDispatch { - dispatcher: Dispatcher; -} - -const mapStateToProps = (state: State, _ownProps: DocPageProps): ConnectedState => ({ - docsVersion: state.docsVersion, - availableDocVersions: state.availableDocVersions, - docsInfo, - translate: state.translate, - screenWidth: state.screenWidth, -}); - -const mapDispatchToProps = (dispatch: Dispatch): ConnectedDispatch => ({ - dispatcher: new Dispatcher(dispatch), -}); +const mapStateToProps = getMapStateToProps(docsInfoConfig); export const Documentation: React.ComponentClass = connect(mapStateToProps, mapDispatchToProps)( DocPageComponent, diff --git a/packages/website/ts/containers/ethereum_types_documentation.ts b/packages/website/ts/containers/ethereum_types_documentation.ts index 9d1df1d1f7..9b668d5151 100644 --- a/packages/website/ts/containers/ethereum_types_documentation.ts +++ b/packages/website/ts/containers/ethereum_types_documentation.ts @@ -1,12 +1,10 @@ -import { constants as docConstants, DocsInfo, DocsInfoConfig, SupportedDocJson } from '@0x/react-docs'; +import { constants as docConstants, DocsInfoConfig, SupportedDocJson } from '@0x/react-docs'; import * as React from 'react'; import { connect } from 'react-redux'; -import { Dispatch } from 'redux'; import { DocPage as DocPageComponent, DocPageProps } from 'ts/pages/documentation/doc_page'; -import { Dispatcher } from 'ts/redux/dispatcher'; -import { State } from 'ts/redux/reducer'; -import { DocPackages, ScreenWidths } from 'ts/types'; -import { Translate } from 'ts/utils/translate'; +import { DocPackages } from 'ts/types'; + +import { getMapStateToProps, mapDispatchToProps } from '../utils/documentation_container'; /* tslint:disable:no-var-requires */ const IntroMarkdown = require('md/docs/ethereum_types/introduction'); @@ -36,31 +34,7 @@ const docsInfoConfig: DocsInfoConfig = { }, markdownSections, }; -const docsInfo = new DocsInfo(docsInfoConfig); - -interface ConnectedState { - docsVersion: string; - availableDocVersions: string[]; - docsInfo: DocsInfo; - translate: Translate; - screenWidth: ScreenWidths; -} - -interface ConnectedDispatch { - dispatcher: Dispatcher; -} - -const mapStateToProps = (state: State, _ownProps: DocPageProps): ConnectedState => ({ - docsVersion: state.docsVersion, - availableDocVersions: state.availableDocVersions, - translate: state.translate, - docsInfo, - screenWidth: state.screenWidth, -}); - -const mapDispatchToProps = (dispatch: Dispatch): ConnectedDispatch => ({ - dispatcher: new Dispatcher(dispatch), -}); +const mapStateToProps = getMapStateToProps(docsInfoConfig); export const Documentation: React.ComponentClass = connect(mapStateToProps, mapDispatchToProps)( DocPageComponent, diff --git a/packages/website/ts/containers/json_schemas_documentation.ts b/packages/website/ts/containers/json_schemas_documentation.ts index 9c4bb8e267..3862ba878e 100644 --- a/packages/website/ts/containers/json_schemas_documentation.ts +++ b/packages/website/ts/containers/json_schemas_documentation.ts @@ -1,12 +1,10 @@ -import { DocsInfo, DocsInfoConfig, SupportedDocJson } from '@0x/react-docs'; +import { DocsInfoConfig, SupportedDocJson } from '@0x/react-docs'; import * as React from 'react'; import { connect } from 'react-redux'; -import { Dispatch } from 'redux'; import { DocPage as DocPageComponent, DocPageProps } from 'ts/pages/documentation/doc_page'; -import { Dispatcher } from 'ts/redux/dispatcher'; -import { State } from 'ts/redux/reducer'; -import { DocPackages, ScreenWidths } from 'ts/types'; -import { Translate } from 'ts/utils/translate'; +import { DocPackages } from 'ts/types'; + +import { getMapStateToProps, mapDispatchToProps } from '../utils/documentation_container'; /* tslint:disable:no-var-requires */ const IntroMarkdown1 = require('md/docs/json_schemas/1/introduction'); @@ -32,7 +30,7 @@ const docsInfoConfig: DocsInfoConfig = { packageName: '@0x/json-schemas', type: SupportedDocJson.TypeDoc, displayName: 'JSON Schemas', - packageUrl: 'https://github.com/0xProject/0x-monorepo', + packageUrl: 'https://github.com/0xProject/0x-monorepo/packages/json-schemas', markdownMenu: { 'getting-started': [markdownSections.introduction, markdownSections.installation, markdownSections.usage], schemas: [markdownSections.schemas], @@ -65,31 +63,7 @@ const docsInfoConfig: DocsInfoConfig = { }, markdownSections, }; -const docsInfo = new DocsInfo(docsInfoConfig); - -interface ConnectedState { - docsVersion: string; - availableDocVersions: string[]; - docsInfo: DocsInfo; - translate: Translate; - screenWidth: ScreenWidths; -} - -interface ConnectedDispatch { - dispatcher: Dispatcher; -} - -const mapStateToProps = (state: State, _ownProps: DocPageProps): ConnectedState => ({ - docsVersion: state.docsVersion, - availableDocVersions: state.availableDocVersions, - translate: state.translate, - docsInfo, - screenWidth: state.screenWidth, -}); - -const mapDispatchToProps = (dispatch: Dispatch): ConnectedDispatch => ({ - dispatcher: new Dispatcher(dispatch), -}); +const mapStateToProps = getMapStateToProps(docsInfoConfig); export const Documentation: React.ComponentClass = connect(mapStateToProps, mapDispatchToProps)( DocPageComponent, diff --git a/packages/website/ts/containers/migrations_documentation.ts b/packages/website/ts/containers/migrations_documentation.ts index 02919e06e2..dd5db3ac6a 100644 --- a/packages/website/ts/containers/migrations_documentation.ts +++ b/packages/website/ts/containers/migrations_documentation.ts @@ -23,7 +23,7 @@ const docsInfoConfig: DocsInfoConfig = { packageName: '@0x/migrations', type: SupportedDocJson.TypeDoc, displayName: 'Migrations', - packageUrl: 'https://github.com/0xProject/0x-monorepo', + packageUrl: 'https://github.com/0xProject/0x-monorepo/packages/migrations', markdownMenu: { 'getting-started': [markdownSections.introduction, markdownSections.installation], }, diff --git a/packages/website/ts/containers/order_utils_documentation.ts b/packages/website/ts/containers/order_utils_documentation.ts index f1d7949885..4996c329a1 100644 --- a/packages/website/ts/containers/order_utils_documentation.ts +++ b/packages/website/ts/containers/order_utils_documentation.ts @@ -1,12 +1,10 @@ -import { DocsInfo, DocsInfoConfig, SupportedDocJson } from '@0x/react-docs'; +import { DocsInfoConfig, SupportedDocJson } from '@0x/react-docs'; import * as React from 'react'; import { connect } from 'react-redux'; -import { Dispatch } from 'redux'; import { DocPage as DocPageComponent, DocPageProps } from 'ts/pages/documentation/doc_page'; -import { Dispatcher } from 'ts/redux/dispatcher'; -import { State } from 'ts/redux/reducer'; -import { DocPackages, ScreenWidths } from 'ts/types'; -import { Translate } from 'ts/utils/translate'; +import { DocPackages } from 'ts/types'; + +import { getMapStateToProps, mapDispatchToProps } from '../utils/documentation_container'; /* tslint:disable:no-var-requires */ const IntroMarkdown1 = require('md/docs/order_utils/1/introduction'); @@ -25,7 +23,7 @@ const docsInfoConfig: DocsInfoConfig = { packageName: '@0x/order-utils', type: SupportedDocJson.TypeDoc, displayName: 'Order utils', - packageUrl: 'https://github.com/0xProject/0x-monorepo', + packageUrl: 'https://github.com/0xProject/0x-monorepo/packages/order-utils', markdownMenu: { 'getting-started': [markdownSections.introduction, markdownSections.installation], }, @@ -41,31 +39,7 @@ const docsInfoConfig: DocsInfoConfig = { }, markdownSections, }; -const docsInfo = new DocsInfo(docsInfoConfig); - -interface ConnectedState { - docsVersion: string; - availableDocVersions: string[]; - docsInfo: DocsInfo; - translate: Translate; - screenWidth: ScreenWidths; -} - -interface ConnectedDispatch { - dispatcher: Dispatcher; -} - -const mapStateToProps = (state: State, _ownProps: DocPageProps): ConnectedState => ({ - docsVersion: state.docsVersion, - availableDocVersions: state.availableDocVersions, - translate: state.translate, - docsInfo, - screenWidth: state.screenWidth, -}); - -const mapDispatchToProps = (dispatch: Dispatch): ConnectedDispatch => ({ - dispatcher: new Dispatcher(dispatch), -}); +const mapStateToProps = getMapStateToProps(docsInfoConfig); export const Documentation: React.ComponentClass = connect(mapStateToProps, mapDispatchToProps)( DocPageComponent, diff --git a/packages/website/ts/containers/order_watcher_documentation.ts b/packages/website/ts/containers/order_watcher_documentation.ts index 683e1fe9fa..f3d3bada89 100644 --- a/packages/website/ts/containers/order_watcher_documentation.ts +++ b/packages/website/ts/containers/order_watcher_documentation.ts @@ -1,12 +1,10 @@ -import { DocsInfo, DocsInfoConfig, SupportedDocJson } from '@0x/react-docs'; +import { DocsInfoConfig, SupportedDocJson } from '@0x/react-docs'; import * as React from 'react'; import { connect } from 'react-redux'; -import { Dispatch } from 'redux'; import { DocPage as DocPageComponent, DocPageProps } from 'ts/pages/documentation/doc_page'; -import { Dispatcher } from 'ts/redux/dispatcher'; -import { State } from 'ts/redux/reducer'; -import { DocPackages, ScreenWidths } from 'ts/types'; -import { Translate } from 'ts/utils/translate'; +import { DocPackages } from 'ts/types'; + +import { getMapStateToProps, mapDispatchToProps } from '../utils/documentation_container'; /* tslint:disable:no-var-requires */ const IntroMarkdown1 = require('md/docs/order_watcher/1/introduction'); @@ -25,7 +23,7 @@ const docsInfoConfig: DocsInfoConfig = { packageName: '@0x/order-watcher', type: SupportedDocJson.TypeDoc, displayName: 'Order Watcher', - packageUrl: 'https://github.com/0xProject/0x-monorepo', + packageUrl: 'https://github.com/0xProject/0x-monorepo/packages/order-watcher', markdownMenu: { 'getting-started': [markdownSections.introduction, markdownSections.installation], }, @@ -41,31 +39,7 @@ const docsInfoConfig: DocsInfoConfig = { }, markdownSections, }; -const docsInfo = new DocsInfo(docsInfoConfig); - -interface ConnectedState { - docsVersion: string; - availableDocVersions: string[]; - docsInfo: DocsInfo; - translate: Translate; - screenWidth: ScreenWidths; -} - -interface ConnectedDispatch { - dispatcher: Dispatcher; -} - -const mapStateToProps = (state: State, _ownProps: DocPageProps): ConnectedState => ({ - docsVersion: state.docsVersion, - availableDocVersions: state.availableDocVersions, - translate: state.translate, - docsInfo, - screenWidth: state.screenWidth, -}); - -const mapDispatchToProps = (dispatch: Dispatch): ConnectedDispatch => ({ - dispatcher: new Dispatcher(dispatch), -}); +const mapStateToProps = getMapStateToProps(docsInfoConfig); export const Documentation: React.ComponentClass = connect(mapStateToProps, mapDispatchToProps)( DocPageComponent, diff --git a/packages/website/ts/containers/smart_contracts_documentation.ts b/packages/website/ts/containers/smart_contracts_documentation.ts index 57c98fa3b9..7c0de55153 100644 --- a/packages/website/ts/containers/smart_contracts_documentation.ts +++ b/packages/website/ts/containers/smart_contracts_documentation.ts @@ -1,13 +1,11 @@ -import { DocsInfo, DocsInfoConfig, SupportedDocJson } from '@0x/react-docs'; +import { DocsInfoConfig, SupportedDocJson } from '@0x/react-docs'; import { Networks } from '@0x/react-shared'; import * as React from 'react'; import { connect } from 'react-redux'; -import { Dispatch } from 'redux'; import { DocPage as DocPageComponent, DocPageProps } from 'ts/pages/documentation/doc_page'; -import { Dispatcher } from 'ts/redux/dispatcher'; -import { State } from 'ts/redux/reducer'; -import { DocPackages, ScreenWidths, SmartContractDocSections as Sections } from 'ts/types'; -import { Translate } from 'ts/utils/translate'; +import { DocPackages, SmartContractDocSections as Sections } from 'ts/types'; + +import { getMapStateToProps, mapDispatchToProps } from '../utils/documentation_container'; /* tslint:disable:no-var-requires */ const IntroMarkdown1 = require('md/docs/smart_contracts/1/introduction'); @@ -91,31 +89,7 @@ const docsInfoConfig: DocsInfoConfig = { }, }, }; -const docsInfo = new DocsInfo(docsInfoConfig); - -interface ConnectedState { - docsVersion: string; - availableDocVersions: string[]; - translate: Translate; - screenWidth: ScreenWidths; -} - -interface ConnectedDispatch { - dispatcher: Dispatcher; - docsInfo: DocsInfo; -} - -const mapStateToProps = (state: State, _ownProps: DocPageProps): ConnectedState => ({ - docsVersion: state.docsVersion, - availableDocVersions: state.availableDocVersions, - translate: state.translate, - screenWidth: state.screenWidth, -}); - -const mapDispatchToProps = (dispatch: Dispatch): ConnectedDispatch => ({ - dispatcher: new Dispatcher(dispatch), - docsInfo, -}); +const mapStateToProps = getMapStateToProps(docsInfoConfig); export const Documentation: React.ComponentClass = connect(mapStateToProps, mapDispatchToProps)( DocPageComponent, diff --git a/packages/website/ts/containers/sol_compiler_documentation.ts b/packages/website/ts/containers/sol_compiler_documentation.ts index f3a793e801..e899e96272 100644 --- a/packages/website/ts/containers/sol_compiler_documentation.ts +++ b/packages/website/ts/containers/sol_compiler_documentation.ts @@ -1,12 +1,10 @@ -import { DocsInfo, DocsInfoConfig, SupportedDocJson } from '@0x/react-docs'; +import { DocsInfoConfig, SupportedDocJson } from '@0x/react-docs'; import * as React from 'react'; import { connect } from 'react-redux'; -import { Dispatch } from 'redux'; import { DocPage as DocPageComponent, DocPageProps } from 'ts/pages/documentation/doc_page'; -import { Dispatcher } from 'ts/redux/dispatcher'; -import { State } from 'ts/redux/reducer'; -import { DocPackages, ScreenWidths } from 'ts/types'; -import { Translate } from 'ts/utils/translate'; +import { DocPackages } from 'ts/types'; + +import { getMapStateToProps, mapDispatchToProps } from '../utils/documentation_container'; /* tslint:disable:no-var-requires */ const IntroMarkdown1 = require('md/docs/sol-compiler/1/introduction'); @@ -27,7 +25,7 @@ const docsInfoConfig: DocsInfoConfig = { packageName: '@0x/sol-compiler', type: SupportedDocJson.TypeDoc, displayName: 'Solidity Compiler', - packageUrl: 'https://github.com/0xProject/0x-monorepo', + packageUrl: 'https://github.com/0xProject/0x-monorepo/packages/sol-compiler', markdownMenu: { 'getting-started': [markdownSections.introduction, markdownSections.installation, markdownSections.usage], }, @@ -45,31 +43,7 @@ const docsInfoConfig: DocsInfoConfig = { }, markdownSections, }; -const docsInfo = new DocsInfo(docsInfoConfig); - -interface ConnectedState { - docsVersion: string; - availableDocVersions: string[]; - docsInfo: DocsInfo; - translate: Translate; - screenWidth: ScreenWidths; -} - -interface ConnectedDispatch { - dispatcher: Dispatcher; -} - -const mapStateToProps = (state: State, _ownProps: DocPageProps): ConnectedState => ({ - docsVersion: state.docsVersion, - availableDocVersions: state.availableDocVersions, - translate: state.translate, - docsInfo, - screenWidth: state.screenWidth, -}); - -const mapDispatchToProps = (dispatch: Dispatch): ConnectedDispatch => ({ - dispatcher: new Dispatcher(dispatch), -}); +const mapStateToProps = getMapStateToProps(docsInfoConfig); export const Documentation: React.ComponentClass = connect(mapStateToProps, mapDispatchToProps)( DocPageComponent, diff --git a/packages/website/ts/containers/sol_cov_documentation.ts b/packages/website/ts/containers/sol_cov_documentation.ts deleted file mode 100644 index 8944ec70ae..0000000000 --- a/packages/website/ts/containers/sol_cov_documentation.ts +++ /dev/null @@ -1,77 +0,0 @@ -import { DocsInfo, DocsInfoConfig, SupportedDocJson } from '@0x/react-docs'; -import * as React from 'react'; -import { connect } from 'react-redux'; -import { Dispatch } from 'redux'; -import { DocPage as DocPageComponent, DocPageProps } from 'ts/pages/documentation/doc_page'; -import { Dispatcher } from 'ts/redux/dispatcher'; -import { State } from 'ts/redux/reducer'; -import { DocPackages, ScreenWidths } from 'ts/types'; -import { Translate } from 'ts/utils/translate'; - -/* tslint:disable:no-var-requires */ -const IntroMarkdown1 = require('md/docs/sol_cov/1/introduction'); -const InstallationMarkdown1 = require('md/docs/sol_cov/1/installation'); -const UsageMarkdown1 = require('md/docs/sol_cov/1/usage'); -const IntroMarkdown2 = require('md/docs/sol_cov/2/introduction'); -const InstallationMarkdown2 = require('md/docs/sol_cov/2/installation'); -const UsageMarkdown2 = require('md/docs/sol_cov/2/usage'); -/* tslint:enable:no-var-requires */ - -const markdownSections = { - introduction: 'introduction', - installation: 'installation', - usage: 'usage', -}; - -const docsInfoConfig: DocsInfoConfig = { - id: DocPackages.SolCov, - packageName: '@0x/sol-cov', - type: SupportedDocJson.TypeDoc, - displayName: 'Sol-cov', - packageUrl: 'https://github.com/0xProject/0x-monorepo', - markdownMenu: { - 'getting-started': [markdownSections.introduction, markdownSections.installation, markdownSections.usage], - }, - sectionNameToMarkdownByVersion: { - '0.0.1': { - [markdownSections.introduction]: IntroMarkdown1, - [markdownSections.installation]: InstallationMarkdown1, - [markdownSections.usage]: UsageMarkdown1, - }, - '2.1.8': { - [markdownSections.introduction]: IntroMarkdown2, - [markdownSections.installation]: InstallationMarkdown2, - [markdownSections.usage]: UsageMarkdown2, - }, - }, - markdownSections, -}; -const docsInfo = new DocsInfo(docsInfoConfig); - -interface ConnectedState { - docsVersion: string; - availableDocVersions: string[]; - docsInfo: DocsInfo; - translate: Translate; - screenWidth: ScreenWidths; -} - -interface ConnectedDispatch { - dispatcher: Dispatcher; -} - -const mapStateToProps = (state: State, _ownProps: DocPageProps): ConnectedState => ({ - docsVersion: state.docsVersion, - availableDocVersions: state.availableDocVersions, - translate: state.translate, - docsInfo, - screenWidth: state.screenWidth, -}); - -const mapDispatchToProps = (dispatch: Dispatch): ConnectedDispatch => ({ - dispatcher: new Dispatcher(dispatch), -}); - -export const Documentation: React.ComponentClass = connect(mapStateToProps, mapDispatchToProps)( - DocPageComponent, -); diff --git a/packages/website/ts/containers/sol_coverage_documentation.ts b/packages/website/ts/containers/sol_coverage_documentation.ts new file mode 100644 index 0000000000..25d67e2d08 --- /dev/null +++ b/packages/website/ts/containers/sol_coverage_documentation.ts @@ -0,0 +1,43 @@ +import { DocsInfoConfig, SupportedDocJson } from '@0x/react-docs'; +import * as React from 'react'; +import { connect } from 'react-redux'; +import { DocPage as DocPageComponent, DocPageProps } from 'ts/pages/documentation/doc_page'; +import { DocPackages } from 'ts/types'; + +import { getMapStateToProps, mapDispatchToProps } from '../utils/documentation_container'; + +/* tslint:disable:no-var-requires */ +const IntroMarkdown = require('md/docs/sol_coverage/introduction'); +const InstallationMarkdown = require('md/docs/sol_coverage/installation'); +const UsageMarkdown = require('md/docs/sol_coverage/usage'); +/* tslint:enable:no-var-requires */ + +const markdownSections = { + introduction: 'introduction', + installation: 'installation', + usage: 'usage', +}; + +const docsInfoConfig: DocsInfoConfig = { + id: DocPackages.SolCoverage, + packageName: '@0x/sol-coverage', + type: SupportedDocJson.TypeDoc, + displayName: 'Sol-coverage', + packageUrl: 'https://github.com/0xProject/0x-monorepo/packages/sol-coverage', + markdownMenu: { + 'getting-started': [markdownSections.introduction, markdownSections.installation, markdownSections.usage], + }, + sectionNameToMarkdownByVersion: { + '1.0.0': { + [markdownSections.introduction]: IntroMarkdown, + [markdownSections.installation]: InstallationMarkdown, + [markdownSections.usage]: UsageMarkdown, + }, + }, + markdownSections, +}; +const mapStateToProps = getMapStateToProps(docsInfoConfig); + +export const Documentation: React.ComponentClass = connect(mapStateToProps, mapDispatchToProps)( + DocPageComponent, +); diff --git a/packages/website/ts/containers/sol_profiler_documentation.ts b/packages/website/ts/containers/sol_profiler_documentation.ts new file mode 100644 index 0000000000..14839831e9 --- /dev/null +++ b/packages/website/ts/containers/sol_profiler_documentation.ts @@ -0,0 +1,43 @@ +import { DocsInfoConfig, SupportedDocJson } from '@0x/react-docs'; +import * as React from 'react'; +import { connect } from 'react-redux'; +import { DocPage as DocPageComponent, DocPageProps } from 'ts/pages/documentation/doc_page'; +import { DocPackages } from 'ts/types'; + +import { getMapStateToProps, mapDispatchToProps } from '../utils/documentation_container'; + +/* tslint:disable:no-var-requires */ +const IntroMarkdown = require('md/docs/sol_profiler/introduction'); +const InstallationMarkdown = require('md/docs/sol_profiler/installation'); +const UsageMarkdown = require('md/docs/sol_profiler/usage'); +/* tslint:enable:no-var-requires */ + +const markdownSections = { + introduction: 'introduction', + installation: 'installation', + usage: 'usage', +}; + +const docsInfoConfig: DocsInfoConfig = { + id: DocPackages.SolProfiler, + packageName: '@0x/sol-profiler', + type: SupportedDocJson.TypeDoc, + displayName: 'Sol-profiler', + packageUrl: 'https://github.com/0xProject/0x-monorepo/packages/sol-profiler', + markdownMenu: { + 'getting-started': [markdownSections.introduction, markdownSections.installation, markdownSections.usage], + }, + sectionNameToMarkdownByVersion: { + '1.0.0': { + [markdownSections.introduction]: IntroMarkdown, + [markdownSections.installation]: InstallationMarkdown, + [markdownSections.usage]: UsageMarkdown, + }, + }, + markdownSections, +}; +const mapStateToProps = getMapStateToProps(docsInfoConfig); + +export const Documentation: React.ComponentClass = connect(mapStateToProps, mapDispatchToProps)( + DocPageComponent, +); diff --git a/packages/website/ts/containers/sol_trace_documentation.ts b/packages/website/ts/containers/sol_trace_documentation.ts new file mode 100644 index 0000000000..c5286f1ff5 --- /dev/null +++ b/packages/website/ts/containers/sol_trace_documentation.ts @@ -0,0 +1,43 @@ +import { DocsInfoConfig, SupportedDocJson } from '@0x/react-docs'; +import * as React from 'react'; +import { connect } from 'react-redux'; +import { DocPage as DocPageComponent, DocPageProps } from 'ts/pages/documentation/doc_page'; +import { DocPackages } from 'ts/types'; + +import { getMapStateToProps, mapDispatchToProps } from '../utils/documentation_container'; + +/* tslint:disable:no-var-requires */ +const IntroMarkdown = require('md/docs/sol_trace/introduction'); +const InstallationMarkdown = require('md/docs/sol_trace/installation'); +const UsageMarkdown = require('md/docs/sol_trace/usage'); +/* tslint:enable:no-var-requires */ + +const markdownSections = { + introduction: 'introduction', + installation: 'installation', + usage: 'usage', +}; + +const docsInfoConfig: DocsInfoConfig = { + id: DocPackages.SolTrace, + packageName: '@0x/sol-trace', + type: SupportedDocJson.TypeDoc, + displayName: 'Sol-trace', + packageUrl: 'https://github.com/0xProject/0x-monorepo/packages/sol-trace', + markdownMenu: { + 'getting-started': [markdownSections.introduction, markdownSections.installation, markdownSections.usage], + }, + sectionNameToMarkdownByVersion: { + '1.0.0': { + [markdownSections.introduction]: IntroMarkdown, + [markdownSections.installation]: InstallationMarkdown, + [markdownSections.usage]: UsageMarkdown, + }, + }, + markdownSections, +}; +const mapStateToProps = getMapStateToProps(docsInfoConfig); + +export const Documentation: React.ComponentClass = connect(mapStateToProps, mapDispatchToProps)( + DocPageComponent, +); diff --git a/packages/website/ts/containers/subproviders_documentation.ts b/packages/website/ts/containers/subproviders_documentation.ts index 0e421777b7..c7fb807a6f 100644 --- a/packages/website/ts/containers/subproviders_documentation.ts +++ b/packages/website/ts/containers/subproviders_documentation.ts @@ -1,12 +1,10 @@ -import { DocsInfo, DocsInfoConfig, SupportedDocJson } from '@0x/react-docs'; +import { DocsInfoConfig, SupportedDocJson } from '@0x/react-docs'; import * as React from 'react'; import { connect } from 'react-redux'; -import { Dispatch } from 'redux'; import { DocPage as DocPageComponent, DocPageProps } from 'ts/pages/documentation/doc_page'; -import { Dispatcher } from 'ts/redux/dispatcher'; -import { State } from 'ts/redux/reducer'; -import { DocPackages, ScreenWidths } from 'ts/types'; -import { Translate } from 'ts/utils/translate'; +import { DocPackages } from 'ts/types'; + +import { getMapStateToProps, mapDispatchToProps } from '../utils/documentation_container'; /* tslint:disable:no-var-requires */ const IntroMarkdown1 = require('md/docs/subproviders/1/introduction'); @@ -26,7 +24,7 @@ const docsInfoConfig: DocsInfoConfig = { packageName: '@0x/subproviders', type: SupportedDocJson.TypeDoc, displayName: 'Subproviders', - packageUrl: 'https://github.com/0xProject/0x-monorepo', + packageUrl: 'https://github.com/0xProject/0x-monorepo/packages/subproviders', markdownMenu: { 'getting-started': [docSections.introduction, docSections.installation, docSections.ledgerNodeHid], }, @@ -44,31 +42,7 @@ const docsInfoConfig: DocsInfoConfig = { }, markdownSections: docSections, }; -const docsInfo = new DocsInfo(docsInfoConfig); - -interface ConnectedState { - docsVersion: string; - availableDocVersions: string[]; - docsInfo: DocsInfo; - translate: Translate; - screenWidth: ScreenWidths; -} - -interface ConnectedDispatch { - dispatcher: Dispatcher; -} - -const mapStateToProps = (state: State, _ownProps: DocPageProps): ConnectedState => ({ - docsVersion: state.docsVersion, - availableDocVersions: state.availableDocVersions, - translate: state.translate, - docsInfo, - screenWidth: state.screenWidth, -}); - -const mapDispatchToProps = (dispatch: Dispatch): ConnectedDispatch => ({ - dispatcher: new Dispatcher(dispatch), -}); +const mapStateToProps = getMapStateToProps(docsInfoConfig); export const Documentation: React.ComponentClass = connect(mapStateToProps, mapDispatchToProps)( DocPageComponent, diff --git a/packages/website/ts/containers/web3_wrapper_documentation.ts b/packages/website/ts/containers/web3_wrapper_documentation.ts index 9c8c346211..ad286da1a5 100644 --- a/packages/website/ts/containers/web3_wrapper_documentation.ts +++ b/packages/website/ts/containers/web3_wrapper_documentation.ts @@ -1,12 +1,10 @@ -import { DocsInfo, DocsInfoConfig, SupportedDocJson } from '@0x/react-docs'; +import { DocsInfoConfig, SupportedDocJson } from '@0x/react-docs'; import * as React from 'react'; import { connect } from 'react-redux'; -import { Dispatch } from 'redux'; import { DocPage as DocPageComponent, DocPageProps } from 'ts/pages/documentation/doc_page'; -import { Dispatcher } from 'ts/redux/dispatcher'; -import { State } from 'ts/redux/reducer'; -import { DocPackages, ScreenWidths } from 'ts/types'; -import { Translate } from 'ts/utils/translate'; +import { DocPackages } from 'ts/types'; + +import { getMapStateToProps, mapDispatchToProps } from '../utils/documentation_container'; /* tslint:disable:no-var-requires */ const IntroMarkdown1 = require('md/docs/web3_wrapper/1/introduction'); @@ -24,7 +22,7 @@ const docsInfoConfig: DocsInfoConfig = { packageName: '@0x/web3-wrapper', type: SupportedDocJson.TypeDoc, displayName: 'Web3Wrapper', - packageUrl: 'https://github.com/0xProject/0x-monorepo', + packageUrl: 'https://github.com/0xProject/0x-monorepo/packages/web3-wrapper', markdownMenu: { 'getting-started': [markdownSections.introduction, markdownSections.installation], }, @@ -40,31 +38,7 @@ const docsInfoConfig: DocsInfoConfig = { }, markdownSections, }; -const docsInfo = new DocsInfo(docsInfoConfig); - -interface ConnectedState { - docsVersion: string; - availableDocVersions: string[]; - docsInfo: DocsInfo; - translate: Translate; - screenWidth: ScreenWidths; -} - -interface ConnectedDispatch { - dispatcher: Dispatcher; -} - -const mapStateToProps = (state: State, _ownProps: DocPageProps): ConnectedState => ({ - docsVersion: state.docsVersion, - availableDocVersions: state.availableDocVersions, - translate: state.translate, - docsInfo, - screenWidth: state.screenWidth, -}); - -const mapDispatchToProps = (dispatch: Dispatch): ConnectedDispatch => ({ - dispatcher: new Dispatcher(dispatch), -}); +const mapStateToProps = getMapStateToProps(docsInfoConfig); export const Documentation: React.ComponentClass = connect(mapStateToProps, mapDispatchToProps)( DocPageComponent, diff --git a/packages/website/ts/containers/zero_ex_js_documentation.ts b/packages/website/ts/containers/zero_ex_js_documentation.ts index e0ea6e2757..5da8d5e529 100644 --- a/packages/website/ts/containers/zero_ex_js_documentation.ts +++ b/packages/website/ts/containers/zero_ex_js_documentation.ts @@ -1,12 +1,10 @@ -import { DocsInfo, DocsInfoConfig, SupportedDocJson } from '@0x/react-docs'; +import { DocsInfoConfig, SupportedDocJson } from '@0x/react-docs'; import * as React from 'react'; import { connect } from 'react-redux'; -import { Dispatch } from 'redux'; import { DocPage as DocPageComponent, DocPageProps } from 'ts/pages/documentation/doc_page'; -import { Dispatcher } from 'ts/redux/dispatcher'; -import { State } from 'ts/redux/reducer'; -import { DocPackages, ScreenWidths } from 'ts/types'; -import { Translate } from 'ts/utils/translate'; +import { DocPackages } from 'ts/types'; + +import { getMapStateToProps, mapDispatchToProps } from '../utils/documentation_container'; /* tslint:disable:no-var-requires */ const IntroMarkdownV0 = require('md/docs/0xjs/0.0.1/introduction'); @@ -37,7 +35,7 @@ const docsInfoConfig: DocsInfoConfig = { packageName: '0x.js', type: SupportedDocJson.TypeDoc, displayName: '0x.js', - packageUrl: 'https://github.com/0xProject/0x-monorepo', + packageUrl: 'https://github.com/0xProject/0x-monorepo/packages/0x.js', markdownMenu: { 'getting-started': [ markdownSections.introduction, @@ -72,31 +70,7 @@ const docsInfoConfig: DocsInfoConfig = { }, markdownSections, }; -const docsInfo = new DocsInfo(docsInfoConfig); - -interface ConnectedState { - docsVersion: string; - availableDocVersions: string[]; - docsInfo: DocsInfo; - translate: Translate; - screenWidth: ScreenWidths; -} - -interface ConnectedDispatch { - dispatcher: Dispatcher; -} - -const mapStateToProps = (state: State, _ownProps: DocPageProps): ConnectedState => ({ - docsVersion: state.docsVersion, - availableDocVersions: state.availableDocVersions, - docsInfo, - translate: state.translate, - screenWidth: state.screenWidth, -}); - -const mapDispatchToProps = (dispatch: Dispatch): ConnectedDispatch => ({ - dispatcher: new Dispatcher(dispatch), -}); +const mapStateToProps = getMapStateToProps(docsInfoConfig); export const Documentation: React.ComponentClass = connect(mapStateToProps, mapDispatchToProps)( DocPageComponent, diff --git a/packages/website/ts/index.tsx b/packages/website/ts/index.tsx index 45054772c1..4ed66c5721 100644 --- a/packages/website/ts/index.tsx +++ b/packages/website/ts/index.tsx @@ -69,8 +69,14 @@ const LazySolCompilerDocumentation = createLazyComponent('Documentation', async const LazyJSONSchemasDocumentation = createLazyComponent('Documentation', async () => import(/* webpackChunkName: "jsonSchemasDocs" */ 'ts/containers/json_schemas_documentation'), ); -const LazySolCovDocumentation = createLazyComponent('Documentation', async () => - import(/* webpackChunkName: "solCovDocs" */ 'ts/containers/sol_cov_documentation'), +const LazySolCoverageDocumentation = createLazyComponent('Documentation', async () => + import(/* webpackChunkName: "solCoverageDocs" */ 'ts/containers/sol_coverage_documentation'), +); +const LazySolTraceDocumentation = createLazyComponent('Documentation', async () => + import(/* webpackChunkName: "solTraceDocs" */ 'ts/containers/sol_trace_documentation'), +); +const LazySolProfilerDocumentation = createLazyComponent('Documentation', async () => + import(/* webpackChunkName: "solProfilerDocs" */ 'ts/containers/sol_profiler_documentation'), ); const LazySubprovidersDocumentation = createLazyComponent('Documentation', async () => import(/* webpackChunkName: "subproviderDocs" */ 'ts/containers/subproviders_documentation'), @@ -149,7 +155,18 @@ render( path={`${WebsitePaths.SolCompiler}/:version?`} component={LazySolCompilerDocumentation} /> - + + + = { }, { description: - 'A Solidity code coverage tool. Sol-cov uses transaction traces to figure out which lines of your code has been covered by your tests.', + 'A Solidity code coverage tool. Sol-coverage uses transaction traces to figure out which lines of your code has been covered by your tests.', link: { - title: '@0x/sol-cov', - to: WebsitePaths.SolCov, + title: '@0x/sol-coverage', + to: WebsitePaths.SolCoverage, + }, + }, + { + description: + 'A Solidity profiler. Sol-profiler uses transaction traces to figure out line-by-line gas consumption.', + link: { + title: '@0x/sol-profiler', + to: WebsitePaths.SolProfiler, + }, + }, + { + description: + 'A Solidity revert trace tool. Sol-trace prints human-readable revert trace whenever the revert happens.', + link: { + title: '@0x/sol-trace', + to: WebsitePaths.SolTrace, }, }, { diff --git a/packages/website/ts/types.ts b/packages/website/ts/types.ts index 37bd730634..50114e2d64 100644 --- a/packages/website/ts/types.ts +++ b/packages/website/ts/types.ts @@ -370,7 +370,9 @@ export enum WebsitePaths { OrderWatcher = '/docs/order-watcher', SolCompiler = '/docs/sol-compiler', JSONSchemas = '/docs/json-schemas', - SolCov = '/docs/sol-cov', + SolCoverage = '/docs/sol-coverage', + SolProfiler = '/docs/sol-profiler', + SolTrace = '/docs/sol-trace', Subproviders = '/docs/subproviders', OrderUtils = '/docs/order-utils', EthereumTypes = '/docs/ethereum-types', @@ -386,7 +388,9 @@ export enum DocPackages { Web3Wrapper = 'WEB3_WRAPPER', SolCompiler = 'SOL_COMPILER', JSONSchemas = 'JSON_SCHEMAS', - SolCov = 'SOL_COV', + SolCoverage = 'SOL_COVERAGE', + SolTrace = 'SOL_TRACE', + SolProfiler = 'SOL_PROFILER', Subproviders = 'SUBPROVIDERS', OrderUtils = 'ORDER_UTILS', EthereumTypes = 'ETHEREUM_TYPES', diff --git a/packages/website/ts/utils/documentation_container.ts b/packages/website/ts/utils/documentation_container.ts new file mode 100644 index 0000000000..54e8a2c1ab --- /dev/null +++ b/packages/website/ts/utils/documentation_container.ts @@ -0,0 +1,35 @@ +import { DocsInfo, DocsInfoConfig } from '@0x/react-docs'; +import { Dispatch } from 'redux'; +import { DocPageProps } from 'ts/pages/documentation/doc_page'; +import { Dispatcher } from 'ts/redux/dispatcher'; +import { State } from 'ts/redux/reducer'; +import { ScreenWidths } from 'ts/types'; +import { Translate } from 'ts/utils/translate'; + +export interface ConnectedState { + docsVersion: string; + availableDocVersions: string[]; + docsInfo: DocsInfo; + translate: Translate; + screenWidth: ScreenWidths; +} + +export interface ConnectedDispatch { + dispatcher: Dispatcher; +} + +export const mapDispatchToProps = (dispatch: Dispatch): ConnectedDispatch => ({ + dispatcher: new Dispatcher(dispatch), +}); + +export const getMapStateToProps = (docsInfoConfig: DocsInfoConfig) => { + const docsInfo = new DocsInfo(docsInfoConfig); + const mapStateToProps = (state: State, _ownProps: DocPageProps): ConnectedState => ({ + docsVersion: state.docsVersion, + availableDocVersions: state.availableDocVersions, + translate: state.translate, + docsInfo, + screenWidth: state.screenWidth, + }); + return mapStateToProps; +}; diff --git a/python-packages/sra_client/README.md b/python-packages/sra_client/README.md index ab3939b419..abf0dee427 100644 --- a/python-packages/sra_client/README.md +++ b/python-packages/sra_client/README.md @@ -4,7 +4,7 @@ A Python client for interacting with servers conforming to [the Standard Relayer # Schemas -The [JSON schemas](http://json-schema.org/) for the API payloads and responses can be found in [@0xproject/json-schemas](https://github.com/0xProject/0x.js/tree/development/packages/json-schemas). Examples of each payload and response can be found in the 0x.js library's [test suite](https://github.com/0xProject/0x.js/blob/development/packages/json-schemas/test/schema_test.ts#L1). +The [JSON schemas](http://json-schema.org/) for the API payloads and responses can be found in [@0xproject/json-schemas](https://github.com/0xProject/0x-monorepo/tree/development/packages/json-schemas). Examples of each payload and response can be found in the 0x.js library's [test suite](https://github.com/0xProject/0x-monorepo/blob/development/packages/json-schemas/test/schema_test.ts#L1). # Pagination diff --git a/tsconfig.json b/tsconfig.json index 7511155544..1f5da33dc1 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -52,7 +52,10 @@ { "path": "./packages/react-docs" }, { "path": "./packages/react-shared" }, { "path": "./packages/sol-compiler" }, - { "path": "./packages/sol-cov" }, + { "path": "./packages/sol-coverage" }, + { "path": "./packages/sol-profiler" }, + { "path": "./packages/sol-trace" }, + { "path": "./packages/sol-trace-based-tools-common" }, { "path": "./packages/sol-resolver" }, { "path": "./packages/sra-spec" }, { "path": "./packages/subproviders" }, diff --git a/yarn.lock b/yarn.lock index b86969e3b1..0a85e8f5a5 100644 --- a/yarn.lock +++ b/yarn.lock @@ -7771,19 +7771,10 @@ got@^6.7.1: unzip-response "^2.0.1" url-parse-lax "^1.0.0" -graceful-fs@^3.0.0: - version "3.0.11" - resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-3.0.11.tgz#7613c778a1afea62f25c630a086d7f3acbbdd818" - dependencies: - natives "^1.1.0" - -graceful-fs@^4.0.0, graceful-fs@^4.1.10, graceful-fs@^4.1.11, graceful-fs@^4.1.2, graceful-fs@^4.1.6, graceful-fs@^4.1.9: - version "4.1.11" - resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-4.1.11.tgz#0e8bdfe4d1ddb8854d64e04ea7c00e2a026e5658" - -graceful-fs@~1.2.0: - version "1.2.3" - resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-1.2.3.tgz#15a4806a57547cb2d2dbf27f42e89a8c3451b364" +graceful-fs@4.1.15, graceful-fs@^3.0.0, graceful-fs@^4.0.0, graceful-fs@^4.1.10, graceful-fs@^4.1.11, graceful-fs@^4.1.2, graceful-fs@^4.1.6, graceful-fs@^4.1.9, graceful-fs@~1.2.0: + version "4.1.15" + resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-4.1.15.tgz#ffb703e1066e8a0eeaa4c8b80ba9253eeefbfb00" + integrity sha512-6uHUhOPEBgQ24HM+r6b/QwWfZq+yiFcipKFrOFiBEnWdy5sdzYoi+pJeQaPI5qOLRFqWmAXUPQNsielzdLoecA== "graceful-readlink@>= 1.0.0": version "1.0.1" @@ -11124,10 +11115,6 @@ nanomatch@^1.2.9: snapdragon "^0.8.1" to-regex "^3.0.1" -natives@^1.1.0: - version "1.1.3" - resolved "https://registry.yarnpkg.com/natives/-/natives-1.1.3.tgz#44a579be64507ea2d6ed1ca04a9415915cf75558" - natural-compare@^1.4.0: version "1.4.0" resolved "https://registry.yarnpkg.com/natural-compare/-/natural-compare-1.4.0.tgz#4abebfeed7541f2c27acfb29bdbbd15c8d5ba4f7" From f05d2906e8d99bd12a07208903450d62ccbb7c80 Mon Sep 17 00:00:00 2001 From: Leonid Logvinov Date: Tue, 8 Jan 2019 16:00:05 +0100 Subject: [PATCH 02/15] Split installation tests in chunks of 10 to not run out of memory --- .../monorepo-scripts/src/test_installation.ts | 73 ++++++++++--------- 1 file changed, 39 insertions(+), 34 deletions(-) diff --git a/packages/monorepo-scripts/src/test_installation.ts b/packages/monorepo-scripts/src/test_installation.ts index 5ae13b198c..ed9b274e23 100644 --- a/packages/monorepo-scripts/src/test_installation.ts +++ b/packages/monorepo-scripts/src/test_installation.ts @@ -45,45 +45,50 @@ function logIfDefined(x: any): void { const IS_LOCAL_PUBLISH = process.env.IS_LOCAL_PUBLISH === 'true'; const registry = IS_LOCAL_PUBLISH ? 'http://localhost:4873/' : 'https://registry.npmjs.org/'; const monorepoRootPath = path.join(__dirname, '../../..'); - const packages = utils.getPackages(monorepoRootPath); + // We sort error messages according to package topology so that we can + // them in a more intuitive order. E.g. if package A has an error and + // package B imports it, the tests for both package A and package B will + // fail. But package B only fails because of an error in package A. + // Since the error in package A is the root cause, we log it first. + const packages = utils.getTopologicallySortedPackages(monorepoRootPath); const installablePackages = _.filter( packages, pkg => !pkg.packageJson.private && !_.isUndefined(pkg.packageJson.main) && pkg.packageJson.main.endsWith('.js'), ); - utils.log('Testing packages:'); - _.map(installablePackages, pkg => utils.log(`* ${pkg.packageJson.name}`)); - // Run all package tests asynchronously and push promises into an array so - // we can wait for all of them to resolve. - const promises: Array> = []; - const errors: PackageErr[] = []; - for (const installablePackage of installablePackages) { - const packagePromise = testInstallPackageAsync(monorepoRootPath, registry, installablePackage).catch(error => { - errors.push({ packageName: installablePackage.packageJson.name, error }); - }); - promises.push(packagePromise); - } - await Promise.all(promises); - if (errors.length > 0) { - // We sort error messages according to package topology so that we can - // them in a more intuitive order. E.g. if package A has an error and - // package B imports it, the tests for both package A and package B will - // fail. But package B only fails because of an error in package A. - // Since the error in package A is the root cause, we log it first. - const topologicallySortedPackages = utils.getTopologicallySortedPackages(monorepoRootPath); - const topologicallySortedErrors = _.sortBy(errors, packageErr => - findPackageIndex(topologicallySortedPackages, packageErr.packageName), - ); - _.forEach(topologicallySortedErrors, packageError => { - utils.log(`ERROR in package ${packageError.packageName}:`); - logIfDefined(packageError.error.message); - logIfDefined(packageError.error.stderr); - logIfDefined(packageError.error.stdout); - logIfDefined(packageError.error.stack); - }); - process.exit(1); - } else { - process.exit(0); + const CHUNK_SIZE = 10; + const chunkedInstallablePackages = _.chunk(installablePackages, CHUNK_SIZE); + utils.log(`Testing all packages in ${chunkedInstallablePackages.length} chunks`); + for (const installablePackagesChunk of chunkedInstallablePackages) { + utils.log('Testing packages:'); + _.map(installablePackagesChunk, pkg => utils.log(`* ${pkg.packageJson.name}`)); + // Run all package tests within that chunk asynchronously and push promises into an array so + // we can wait for all of them to resolve. + const promises: Array> = []; + const errors: PackageErr[] = []; + for (const installablePackage of installablePackagesChunk) { + const packagePromise = testInstallPackageAsync(monorepoRootPath, registry, installablePackage).catch( + error => { + errors.push({ packageName: installablePackage.packageJson.name, error }); + }, + ); + promises.push(packagePromise); + } + await Promise.all(promises); + if (errors.length > 0) { + const topologicallySortedErrors = _.sortBy(errors, packageErr => + findPackageIndex(packages, packageErr.packageName), + ); + _.forEach(topologicallySortedErrors, packageError => { + utils.log(`ERROR in package ${packageError.packageName}:`); + logIfDefined(packageError.error.message); + logIfDefined(packageError.error.stderr); + logIfDefined(packageError.error.stdout); + logIfDefined(packageError.error.stack); + }); + process.exit(1); + } } + process.exit(0); })().catch(err => { utils.log(`Unexpected error: ${err.message}`); process.exit(1); From 03248244ff8a7d8f276a86262f1b53e8dc9d5675 Mon Sep 17 00:00:00 2001 From: Leonid Logvinov Date: Tue, 8 Jan 2019 16:16:02 +0100 Subject: [PATCH 03/15] Bump up the chunk size --- packages/monorepo-scripts/src/test_installation.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/monorepo-scripts/src/test_installation.ts b/packages/monorepo-scripts/src/test_installation.ts index ed9b274e23..59647b836d 100644 --- a/packages/monorepo-scripts/src/test_installation.ts +++ b/packages/monorepo-scripts/src/test_installation.ts @@ -55,7 +55,7 @@ function logIfDefined(x: any): void { packages, pkg => !pkg.packageJson.private && !_.isUndefined(pkg.packageJson.main) && pkg.packageJson.main.endsWith('.js'), ); - const CHUNK_SIZE = 10; + const CHUNK_SIZE = 15; const chunkedInstallablePackages = _.chunk(installablePackages, CHUNK_SIZE); utils.log(`Testing all packages in ${chunkedInstallablePackages.length} chunks`); for (const installablePackagesChunk of chunkedInstallablePackages) { From 420333e3c35252639bca7a987029d65ad8322290 Mon Sep 17 00:00:00 2001 From: Fabio B Date: Thu, 10 Jan 2019 11:11:23 +0100 Subject: [PATCH 04/15] Update packages/monorepo-scripts/src/test_installation.ts Co-Authored-By: LogvinovLeon --- packages/monorepo-scripts/src/test_installation.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/monorepo-scripts/src/test_installation.ts b/packages/monorepo-scripts/src/test_installation.ts index 59647b836d..822f489673 100644 --- a/packages/monorepo-scripts/src/test_installation.ts +++ b/packages/monorepo-scripts/src/test_installation.ts @@ -45,7 +45,7 @@ function logIfDefined(x: any): void { const IS_LOCAL_PUBLISH = process.env.IS_LOCAL_PUBLISH === 'true'; const registry = IS_LOCAL_PUBLISH ? 'http://localhost:4873/' : 'https://registry.npmjs.org/'; const monorepoRootPath = path.join(__dirname, '../../..'); - // We sort error messages according to package topology so that we can + // We sort error messages according to package topology so that we can see // them in a more intuitive order. E.g. if package A has an error and // package B imports it, the tests for both package A and package B will // fail. But package B only fails because of an error in package A. From 60cdbbccae1f33555edf0b68e8f7af9c8048c513 Mon Sep 17 00:00:00 2001 From: Fabio B Date: Thu, 10 Jan 2019 11:11:43 +0100 Subject: [PATCH 05/15] Update packages/sol-coverage/CHANGELOG.json Co-Authored-By: LogvinovLeon --- packages/sol-coverage/CHANGELOG.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/sol-coverage/CHANGELOG.json b/packages/sol-coverage/CHANGELOG.json index ca6048d99a..938fa97a07 100644 --- a/packages/sol-coverage/CHANGELOG.json +++ b/packages/sol-coverage/CHANGELOG.json @@ -4,7 +4,7 @@ "changes": [ { "note": - "Initial release as a separate package. For historic entries check @0x/sol-trace-based-tools-common", + "Initial release as a separate package. For historical entries see @0x/sol-trace-based-tools-common", "pr": 1492 } ] From 36504646f93882b43da8918b59dfe40d09bbbfd4 Mon Sep 17 00:00:00 2001 From: Fabio B Date: Thu, 10 Jan 2019 11:11:52 +0100 Subject: [PATCH 06/15] Update packages/sol-profiler/CHANGELOG.json Co-Authored-By: LogvinovLeon --- packages/sol-profiler/CHANGELOG.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/sol-profiler/CHANGELOG.json b/packages/sol-profiler/CHANGELOG.json index ca6048d99a..938fa97a07 100644 --- a/packages/sol-profiler/CHANGELOG.json +++ b/packages/sol-profiler/CHANGELOG.json @@ -4,7 +4,7 @@ "changes": [ { "note": - "Initial release as a separate package. For historic entries check @0x/sol-trace-based-tools-common", + "Initial release as a separate package. For historical entries see @0x/sol-trace-based-tools-common", "pr": 1492 } ] From 052ed21e9ccc909d981ea61ff29fc845bd976dc0 Mon Sep 17 00:00:00 2001 From: Fabio B Date: Thu, 10 Jan 2019 11:12:08 +0100 Subject: [PATCH 07/15] Update packages/sol-trace-based-tools-common/CHANGELOG.json Co-Authored-By: LogvinovLeon --- packages/sol-trace-based-tools-common/CHANGELOG.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/sol-trace-based-tools-common/CHANGELOG.json b/packages/sol-trace-based-tools-common/CHANGELOG.json index 4c56d547d1..caccb3fffc 100644 --- a/packages/sol-trace-based-tools-common/CHANGELOG.json +++ b/packages/sol-trace-based-tools-common/CHANGELOG.json @@ -3,7 +3,7 @@ "version": "3.0.0", "changes": [ { - "note": "Move out specific tools and leave just the common part", + "note": "Move out specific tools and leave just the shared parts of the codebase", "pr": 1492 } ] From d7df402c42f7964bd31a765f5ec92a40179b69d7 Mon Sep 17 00:00:00 2001 From: Fabio B Date: Thu, 10 Jan 2019 11:15:19 +0100 Subject: [PATCH 08/15] Update packages/sol-trace-based-tools-common/src/source_maps.ts Co-Authored-By: LogvinovLeon --- packages/sol-trace-based-tools-common/src/source_maps.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/sol-trace-based-tools-common/src/source_maps.ts b/packages/sol-trace-based-tools-common/src/source_maps.ts index 7191fb7127..af0fb40351 100644 --- a/packages/sol-trace-based-tools-common/src/source_maps.ts +++ b/packages/sol-trace-based-tools-common/src/source_maps.ts @@ -12,7 +12,7 @@ export interface SourceLocation { } /** - * Receives a string with newlines and returns a hash of byte offset to LineColumn + * Receives a string with newlines and returns a map of byte offset to LineColumn * @param str A string to process */ export function getLocationByOffset(str: string): LocationByOffset { From 03dea585b4e0af9b3272d017e4832d4dd03dbbfe Mon Sep 17 00:00:00 2001 From: Fabio B Date: Thu, 10 Jan 2019 11:15:26 +0100 Subject: [PATCH 09/15] Update packages/sol-trace/CHANGELOG.json Co-Authored-By: LogvinovLeon --- packages/sol-trace/CHANGELOG.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/sol-trace/CHANGELOG.json b/packages/sol-trace/CHANGELOG.json index ca6048d99a..938fa97a07 100644 --- a/packages/sol-trace/CHANGELOG.json +++ b/packages/sol-trace/CHANGELOG.json @@ -4,7 +4,7 @@ "changes": [ { "note": - "Initial release as a separate package. For historic entries check @0x/sol-trace-based-tools-common", + "Initial release as a separate package. For historical entries see @0x/sol-trace-based-tools-common", "pr": 1492 } ] From 15c9479ebeca57e7c275cd2e73ca3daad03a412f Mon Sep 17 00:00:00 2001 From: Fabio B Date: Thu, 10 Jan 2019 11:15:34 +0100 Subject: [PATCH 10/15] Update packages/sol-trace/README.md Co-Authored-By: LogvinovLeon --- packages/sol-trace/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/sol-trace/README.md b/packages/sol-trace/README.md index dba1934265..86ca2cbd67 100644 --- a/packages/sol-trace/README.md +++ b/packages/sol-trace/README.md @@ -1,6 +1,6 @@ ## @0x/sol-trace -Prints code traces when revert happens. +Prints a stack trace when a revert is encountered. ### Read the [Documentation](https://0xproject.com/docs/sol-trace). From 7ae9e79235ed3b7eb110b0a1e88338b3965f44da Mon Sep 17 00:00:00 2001 From: Leonid Logvinov Date: Thu, 10 Jan 2019 11:21:05 +0100 Subject: [PATCH 11/15] Rename sol-trace-based-tools-common to sol-tracing-utils --- .circleci/config.yml | 8 ++++---- .github/autolabeler.yml | 2 +- .gitignore | 2 +- CODEOWNERS | 2 +- packages/sol-coverage/CHANGELOG.json | 2 +- packages/sol-coverage/package.json | 2 +- packages/sol-coverage/src/coverage_subprovider.ts | 2 +- packages/sol-coverage/src/index.ts | 2 +- packages/sol-profiler/CHANGELOG.json | 2 +- packages/sol-profiler/package.json | 2 +- packages/sol-profiler/src/index.ts | 2 +- packages/sol-profiler/src/profiler_subprovider.ts | 2 +- packages/sol-trace-based-tools-common/coverage/.gitkeep | 0 packages/sol-trace/CHANGELOG.json | 2 +- packages/sol-trace/package.json | 2 +- packages/sol-trace/src/index.ts | 2 +- packages/sol-trace/src/revert_trace_subprovider.ts | 2 +- .../.npmignore | 0 .../CHANGELOG.json | 0 .../CHANGELOG.md | 0 .../README.md | 8 ++++---- .../compiler.json | 0 .../package.json | 4 ++-- .../src/artifact_adapters/abstract_artifact_adapter.ts | 0 .../artifact_adapters/sol_compiler_artifact_adapter.ts | 0 .../src/artifact_adapters/truffle_artifact_adapter.ts | 0 .../src/ast_visitor.ts | 0 .../src/collect_coverage_entries.ts | 0 .../src/constants.ts | 0 .../src/get_source_range_snippet.ts | 0 .../src/globals.d.ts | 0 .../src/index.ts | 0 .../src/instructions.ts | 0 .../src/revert_trace.ts | 0 .../src/source_maps.ts | 0 .../src/trace.ts | 0 .../src/trace_collection_subprovider.ts | 0 .../src/trace_collector.ts | 2 +- .../src/trace_info_subprovider.ts | 0 .../src/types.ts | 0 .../src/utils.ts | 0 .../test/collect_coverage_entries_test.ts | 0 .../test/fixtures/contracts/AllSolidityFeatures.sol | 0 .../test/fixtures/contracts/SimpleStorage.sol | 0 .../test/fixtures/contracts/Simplest.sol | 0 .../test/fixtures/contracts/SolcovIgnore.sol | 0 .../test/instructions_test.ts | 0 .../test/sol_compiler_artifact_adapter_test.ts | 0 .../test/source_maps_test.ts | 0 .../test/trace_test.ts | 0 .../test/utils_test.ts | 0 .../tsconfig.json | 0 .../tslint.json | 0 tsconfig.json | 2 +- 54 files changed, 27 insertions(+), 27 deletions(-) delete mode 100644 packages/sol-trace-based-tools-common/coverage/.gitkeep rename packages/{sol-trace-based-tools-common => sol-tracing-utils}/.npmignore (100%) rename packages/{sol-trace-based-tools-common => sol-tracing-utils}/CHANGELOG.json (100%) rename packages/{sol-trace-based-tools-common => sol-tracing-utils}/CHANGELOG.md (100%) rename packages/{sol-trace-based-tools-common => sol-tracing-utils}/README.md (83%) rename packages/{sol-trace-based-tools-common => sol-tracing-utils}/compiler.json (100%) rename packages/{sol-trace-based-tools-common => sol-tracing-utils}/package.json (97%) rename packages/{sol-trace-based-tools-common => sol-tracing-utils}/src/artifact_adapters/abstract_artifact_adapter.ts (100%) rename packages/{sol-trace-based-tools-common => sol-tracing-utils}/src/artifact_adapters/sol_compiler_artifact_adapter.ts (100%) rename packages/{sol-trace-based-tools-common => sol-tracing-utils}/src/artifact_adapters/truffle_artifact_adapter.ts (100%) rename packages/{sol-trace-based-tools-common => sol-tracing-utils}/src/ast_visitor.ts (100%) rename packages/{sol-trace-based-tools-common => sol-tracing-utils}/src/collect_coverage_entries.ts (100%) rename packages/{sol-trace-based-tools-common => sol-tracing-utils}/src/constants.ts (100%) rename packages/{sol-trace-based-tools-common => sol-tracing-utils}/src/get_source_range_snippet.ts (100%) rename packages/{sol-trace-based-tools-common => sol-tracing-utils}/src/globals.d.ts (100%) rename packages/{sol-trace-based-tools-common => sol-tracing-utils}/src/index.ts (100%) rename packages/{sol-trace-based-tools-common => sol-tracing-utils}/src/instructions.ts (100%) rename packages/{sol-trace-based-tools-common => sol-tracing-utils}/src/revert_trace.ts (100%) rename packages/{sol-trace-based-tools-common => sol-tracing-utils}/src/source_maps.ts (100%) rename packages/{sol-trace-based-tools-common => sol-tracing-utils}/src/trace.ts (100%) rename packages/{sol-trace-based-tools-common => sol-tracing-utils}/src/trace_collection_subprovider.ts (100%) rename packages/{sol-trace-based-tools-common => sol-tracing-utils}/src/trace_collector.ts (98%) rename packages/{sol-trace-based-tools-common => sol-tracing-utils}/src/trace_info_subprovider.ts (100%) rename packages/{sol-trace-based-tools-common => sol-tracing-utils}/src/types.ts (100%) rename packages/{sol-trace-based-tools-common => sol-tracing-utils}/src/utils.ts (100%) rename packages/{sol-trace-based-tools-common => sol-tracing-utils}/test/collect_coverage_entries_test.ts (100%) rename packages/{sol-trace-based-tools-common => sol-tracing-utils}/test/fixtures/contracts/AllSolidityFeatures.sol (100%) rename packages/{sol-trace-based-tools-common => sol-tracing-utils}/test/fixtures/contracts/SimpleStorage.sol (100%) rename packages/{sol-trace-based-tools-common => sol-tracing-utils}/test/fixtures/contracts/Simplest.sol (100%) rename packages/{sol-trace-based-tools-common => sol-tracing-utils}/test/fixtures/contracts/SolcovIgnore.sol (100%) rename packages/{sol-trace-based-tools-common => sol-tracing-utils}/test/instructions_test.ts (100%) rename packages/{sol-trace-based-tools-common => sol-tracing-utils}/test/sol_compiler_artifact_adapter_test.ts (100%) rename packages/{sol-trace-based-tools-common => sol-tracing-utils}/test/source_maps_test.ts (100%) rename packages/{sol-trace-based-tools-common => sol-tracing-utils}/test/trace_test.ts (100%) rename packages/{sol-trace-based-tools-common => sol-tracing-utils}/test/utils_test.ts (100%) rename packages/{sol-trace-based-tools-common => sol-tracing-utils}/tsconfig.json (100%) rename packages/{sol-trace-based-tools-common => sol-tracing-utils}/tslint.json (100%) diff --git a/.circleci/config.yml b/.circleci/config.yml index 3e5a2809c6..fb1aacdd92 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -118,7 +118,7 @@ jobs: - run: yarn wsrun test:circleci @0x/order-utils - run: yarn wsrun test:circleci @0x/order-watcher - run: yarn wsrun test:circleci @0x/sol-compiler - - run: yarn wsrun test:circleci @0x/sol-trace-based-tools-common + - run: yarn wsrun test:circleci @0x/sol-tracing-utils - run: yarn wsrun test:circleci @0x/sol-doc - run: yarn wsrun test:circleci @0x/subproviders - run: yarn wsrun test:circleci @0x/web3-wrapper @@ -169,9 +169,9 @@ jobs: paths: - ~/repo/packages/sol-compiler/coverage/lcov.info - save_cache: - key: coverage-sol-trace-based-tools-common-{{ .Environment.CIRCLE_SHA1 }} + key: coverage-sol-tracing-utils-{{ .Environment.CIRCLE_SHA1 }} paths: - - ~/repo/packages/sol-trace-based-tools-common/coverage/lcov.info + - ~/repo/packages/sol-tracing-utils/coverage/lcov.info - save_cache: key: coverage-sol-doc-{{ .Environment.CIRCLE_SHA1 }} paths: @@ -342,7 +342,7 @@ jobs: - coverage-sol-compiler-{{ .Environment.CIRCLE_SHA1 }} - restore_cache: keys: - - coverage-sol-trace-based-tools-common-{{ .Environment.CIRCLE_SHA1 }} + - coverage-sol-tracing-utils-{{ .Environment.CIRCLE_SHA1 }} - restore_cache: keys: - coverage-sol-doc-{{ .Environment.CIRCLE_SHA1 }} diff --git a/.github/autolabeler.yml b/.github/autolabeler.yml index ecdc0e89b6..321ec18a4a 100644 --- a/.github/autolabeler.yml +++ b/.github/autolabeler.yml @@ -16,7 +16,7 @@ website: ['packages/website'] sol-coverage: ['packages/sol-coverage'] sol-profiler: ['packages/sol-profiler'] sol-trace: ['packages/sol-trace'] -sol-trace-based-tools-common: ['packages/sol-trace-based-tools-common'] +sol-tracing-utils: ['packages/sol-tracing-utils'] utils: ['packages/utils'] tslint-config: ['packages/tslint-config'] asset-buyer: ['packages/asset-buyer'] diff --git a/.gitignore b/.gitignore index c2100ea621..0210edc4f9 100644 --- a/.gitignore +++ b/.gitignore @@ -91,7 +91,7 @@ contracts/interfaces/generated-artifacts/ contracts/tokens/generated-artifacts/ contracts/examples/generated-artifacts/ contracts/extensions/generated-artifacts/ -packages/sol-trace-based-tools-common/test/fixtures/artifacts/ +packages/sol-tracing-utils/test/fixtures/artifacts/ packages/metacoin/artifacts/ # generated contract wrappers diff --git a/CODEOWNERS b/CODEOWNERS index f57da320f3..c73a206df9 100644 --- a/CODEOWNERS +++ b/CODEOWNERS @@ -27,7 +27,7 @@ packages/sol-compiler/ @LogvinovLeon packages/sol-coverage/ @LogvinovLeon packages/sol-profiler/ @LogvinovLeon packages/sol-trace/ @LogvinovLeon -packages/sol-trace-based-tools-common/ @LogvinovLeon +packages/sol-tracing-utils/ @LogvinovLeon packages/sol-resolver/ @LogvinovLeon packages/subproviders/ @fabioberger @dekz packages/verdaccio/ @albrow diff --git a/packages/sol-coverage/CHANGELOG.json b/packages/sol-coverage/CHANGELOG.json index 938fa97a07..c650a4a4bf 100644 --- a/packages/sol-coverage/CHANGELOG.json +++ b/packages/sol-coverage/CHANGELOG.json @@ -4,7 +4,7 @@ "changes": [ { "note": - "Initial release as a separate package. For historical entries see @0x/sol-trace-based-tools-common", + "Initial release as a separate package. For historical entries see @0x/sol-tracing-utils", "pr": 1492 } ] diff --git a/packages/sol-coverage/package.json b/packages/sol-coverage/package.json index b95fa55026..7dc764efd4 100644 --- a/packages/sol-coverage/package.json +++ b/packages/sol-coverage/package.json @@ -30,7 +30,7 @@ "homepage": "https://github.com/0xProject/0x-monorepo/packages/sol-coverage/README.md", "dependencies": { "@0x/subproviders": "^2.1.8", - "@0x/sol-trace-based-tools-common": "^2.1.16", + "@0x/sol-tracing-utils": "^2.1.16", "@0x/typescript-typings": "^3.0.6", "ethereum-types": "^1.1.4", "lodash": "^4.17.5" diff --git a/packages/sol-coverage/src/coverage_subprovider.ts b/packages/sol-coverage/src/coverage_subprovider.ts index 255fa94819..e6b546c4ae 100644 --- a/packages/sol-coverage/src/coverage_subprovider.ts +++ b/packages/sol-coverage/src/coverage_subprovider.ts @@ -15,7 +15,7 @@ import { TraceInfo, TraceInfoSubprovider, utils, -} from '@0x/sol-trace-based-tools-common'; +} from '@0x/sol-tracing-utils'; import * as _ from 'lodash'; /** diff --git a/packages/sol-coverage/src/index.ts b/packages/sol-coverage/src/index.ts index dcf97b72ef..97b4ecee61 100644 --- a/packages/sol-coverage/src/index.ts +++ b/packages/sol-coverage/src/index.ts @@ -4,7 +4,7 @@ export { TruffleArtifactAdapter, AbstractArtifactAdapter, ContractData, -} from '@0x/sol-trace-based-tools-common'; +} from '@0x/sol-tracing-utils'; export { JSONRPCRequestPayload, diff --git a/packages/sol-profiler/CHANGELOG.json b/packages/sol-profiler/CHANGELOG.json index 938fa97a07..c650a4a4bf 100644 --- a/packages/sol-profiler/CHANGELOG.json +++ b/packages/sol-profiler/CHANGELOG.json @@ -4,7 +4,7 @@ "changes": [ { "note": - "Initial release as a separate package. For historical entries see @0x/sol-trace-based-tools-common", + "Initial release as a separate package. For historical entries see @0x/sol-tracing-utils", "pr": 1492 } ] diff --git a/packages/sol-profiler/package.json b/packages/sol-profiler/package.json index 03b421b0eb..b85c82ed27 100644 --- a/packages/sol-profiler/package.json +++ b/packages/sol-profiler/package.json @@ -31,7 +31,7 @@ "dependencies": { "@0x/subproviders": "^2.1.8", "@0x/typescript-typings": "^3.0.6", - "@0x/sol-trace-based-tools-common": "^2.1.16", + "@0x/sol-tracing-utils": "^2.1.16", "ethereum-types": "^1.1.4", "lodash": "^4.17.5" }, diff --git a/packages/sol-profiler/src/index.ts b/packages/sol-profiler/src/index.ts index b36ed5baa8..5d4806be48 100644 --- a/packages/sol-profiler/src/index.ts +++ b/packages/sol-profiler/src/index.ts @@ -3,7 +3,7 @@ export { SolCompilerArtifactAdapter, TruffleArtifactAdapter, ContractData, -} from '@0x/sol-trace-based-tools-common'; +} from '@0x/sol-tracing-utils'; // HACK: ProfilerSubprovider is a hacky way to do profiling using coverage tools. Not production ready export { ProfilerSubprovider } from './profiler_subprovider'; diff --git a/packages/sol-profiler/src/profiler_subprovider.ts b/packages/sol-profiler/src/profiler_subprovider.ts index 61dc25b6b2..c3ed13ea5e 100644 --- a/packages/sol-profiler/src/profiler_subprovider.ts +++ b/packages/sol-profiler/src/profiler_subprovider.ts @@ -12,7 +12,7 @@ import { TraceInfo, TraceInfoSubprovider, utils, -} from '@0x/sol-trace-based-tools-common'; +} from '@0x/sol-tracing-utils'; /** * This class implements the [web3-provider-engine](https://github.com/MetaMask/provider-engine) subprovider interface. diff --git a/packages/sol-trace-based-tools-common/coverage/.gitkeep b/packages/sol-trace-based-tools-common/coverage/.gitkeep deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/packages/sol-trace/CHANGELOG.json b/packages/sol-trace/CHANGELOG.json index 938fa97a07..c650a4a4bf 100644 --- a/packages/sol-trace/CHANGELOG.json +++ b/packages/sol-trace/CHANGELOG.json @@ -4,7 +4,7 @@ "changes": [ { "note": - "Initial release as a separate package. For historical entries see @0x/sol-trace-based-tools-common", + "Initial release as a separate package. For historical entries see @0x/sol-tracing-utils", "pr": 1492 } ] diff --git a/packages/sol-trace/package.json b/packages/sol-trace/package.json index fd80c541eb..3013be6f99 100644 --- a/packages/sol-trace/package.json +++ b/packages/sol-trace/package.json @@ -31,7 +31,7 @@ "dependencies": { "@0x/subproviders": "^2.1.8", "@0x/typescript-typings": "^3.0.6", - "@0x/sol-trace-based-tools-common": "^2.1.16", + "@0x/sol-tracing-utils": "^2.1.16", "ethereum-types": "^1.1.4", "ethereumjs-util": "^5.1.1", "lodash": "^4.17.5", diff --git a/packages/sol-trace/src/index.ts b/packages/sol-trace/src/index.ts index 1f3ca3a991..120c0d0a9b 100644 --- a/packages/sol-trace/src/index.ts +++ b/packages/sol-trace/src/index.ts @@ -3,7 +3,7 @@ export { TruffleArtifactAdapter, SolCompilerArtifactAdapter, ContractData, -} from '@0x/sol-trace-based-tools-common'; +} from '@0x/sol-tracing-utils'; export { RevertTraceSubprovider } from './revert_trace_subprovider'; diff --git a/packages/sol-trace/src/revert_trace_subprovider.ts b/packages/sol-trace/src/revert_trace_subprovider.ts index 37e62b3f8c..31067a402e 100644 --- a/packages/sol-trace/src/revert_trace_subprovider.ts +++ b/packages/sol-trace/src/revert_trace_subprovider.ts @@ -10,7 +10,7 @@ import { SourceSnippet, TraceCollectionSubprovider, utils, -} from '@0x/sol-trace-based-tools-common'; +} from '@0x/sol-tracing-utils'; import { stripHexPrefix } from 'ethereumjs-util'; import * as _ from 'lodash'; import { getLogger, levels, Logger } from 'loglevel'; diff --git a/packages/sol-trace-based-tools-common/.npmignore b/packages/sol-tracing-utils/.npmignore similarity index 100% rename from packages/sol-trace-based-tools-common/.npmignore rename to packages/sol-tracing-utils/.npmignore diff --git a/packages/sol-trace-based-tools-common/CHANGELOG.json b/packages/sol-tracing-utils/CHANGELOG.json similarity index 100% rename from packages/sol-trace-based-tools-common/CHANGELOG.json rename to packages/sol-tracing-utils/CHANGELOG.json diff --git a/packages/sol-trace-based-tools-common/CHANGELOG.md b/packages/sol-tracing-utils/CHANGELOG.md similarity index 100% rename from packages/sol-trace-based-tools-common/CHANGELOG.md rename to packages/sol-tracing-utils/CHANGELOG.md diff --git a/packages/sol-trace-based-tools-common/README.md b/packages/sol-tracing-utils/README.md similarity index 83% rename from packages/sol-trace-based-tools-common/README.md rename to packages/sol-tracing-utils/README.md index b6d75dd598..0a4749b8e5 100644 --- a/packages/sol-trace-based-tools-common/README.md +++ b/packages/sol-tracing-utils/README.md @@ -1,11 +1,11 @@ -## @0x/sol-trace-based-tools-common +## @0x/sol-tracing-utils Common code for all solidity trace-based tools (sol-coverage, sol-profiler, sol-trace). ## Installation ```bash -yarn add @0x/sol-sol-trace-based-tools-common +yarn add @0x/sol-sol-tracing-utils ``` ## Contributing @@ -33,13 +33,13 @@ yarn install To build this package and all other monorepo packages that it depends on, run the following from the monorepo root directory: ```bash -PKG=@0x/sol-trace-based-tools-common yarn build +PKG=@0x/sol-tracing-utils yarn build ``` Or continuously rebuild on change: ```bash -PKG=@0x/sol-trace-based-tools-common yarn watch +PKG=@0x/sol-tracing-utils yarn watch ``` ### Clean diff --git a/packages/sol-trace-based-tools-common/compiler.json b/packages/sol-tracing-utils/compiler.json similarity index 100% rename from packages/sol-trace-based-tools-common/compiler.json rename to packages/sol-tracing-utils/compiler.json diff --git a/packages/sol-trace-based-tools-common/package.json b/packages/sol-tracing-utils/package.json similarity index 97% rename from packages/sol-trace-based-tools-common/package.json rename to packages/sol-tracing-utils/package.json index 6cfabe6d9e..f351ccc08f 100644 --- a/packages/sol-trace-based-tools-common/package.json +++ b/packages/sol-tracing-utils/package.json @@ -1,5 +1,5 @@ { - "name": "@0x/sol-trace-based-tools-common", + "name": "@0x/sol-tracing-utils", "version": "2.1.16", "engines": { "node": ">=6.12" @@ -40,7 +40,7 @@ "bugs": { "url": "https://github.com/0xProject/0x-monorepo/issues" }, - "homepage": "https://github.com/0xProject/0x-monorepo/packages/sol-trace-based-tools-common/README.md", + "homepage": "https://github.com/0xProject/0x-monorepo/packages/sol-tracing-utils/README.md", "dependencies": { "@0x/dev-utils": "^1.0.21", "@0x/sol-compiler": "^1.1.16", diff --git a/packages/sol-trace-based-tools-common/src/artifact_adapters/abstract_artifact_adapter.ts b/packages/sol-tracing-utils/src/artifact_adapters/abstract_artifact_adapter.ts similarity index 100% rename from packages/sol-trace-based-tools-common/src/artifact_adapters/abstract_artifact_adapter.ts rename to packages/sol-tracing-utils/src/artifact_adapters/abstract_artifact_adapter.ts diff --git a/packages/sol-trace-based-tools-common/src/artifact_adapters/sol_compiler_artifact_adapter.ts b/packages/sol-tracing-utils/src/artifact_adapters/sol_compiler_artifact_adapter.ts similarity index 100% rename from packages/sol-trace-based-tools-common/src/artifact_adapters/sol_compiler_artifact_adapter.ts rename to packages/sol-tracing-utils/src/artifact_adapters/sol_compiler_artifact_adapter.ts diff --git a/packages/sol-trace-based-tools-common/src/artifact_adapters/truffle_artifact_adapter.ts b/packages/sol-tracing-utils/src/artifact_adapters/truffle_artifact_adapter.ts similarity index 100% rename from packages/sol-trace-based-tools-common/src/artifact_adapters/truffle_artifact_adapter.ts rename to packages/sol-tracing-utils/src/artifact_adapters/truffle_artifact_adapter.ts diff --git a/packages/sol-trace-based-tools-common/src/ast_visitor.ts b/packages/sol-tracing-utils/src/ast_visitor.ts similarity index 100% rename from packages/sol-trace-based-tools-common/src/ast_visitor.ts rename to packages/sol-tracing-utils/src/ast_visitor.ts diff --git a/packages/sol-trace-based-tools-common/src/collect_coverage_entries.ts b/packages/sol-tracing-utils/src/collect_coverage_entries.ts similarity index 100% rename from packages/sol-trace-based-tools-common/src/collect_coverage_entries.ts rename to packages/sol-tracing-utils/src/collect_coverage_entries.ts diff --git a/packages/sol-trace-based-tools-common/src/constants.ts b/packages/sol-tracing-utils/src/constants.ts similarity index 100% rename from packages/sol-trace-based-tools-common/src/constants.ts rename to packages/sol-tracing-utils/src/constants.ts diff --git a/packages/sol-trace-based-tools-common/src/get_source_range_snippet.ts b/packages/sol-tracing-utils/src/get_source_range_snippet.ts similarity index 100% rename from packages/sol-trace-based-tools-common/src/get_source_range_snippet.ts rename to packages/sol-tracing-utils/src/get_source_range_snippet.ts diff --git a/packages/sol-trace-based-tools-common/src/globals.d.ts b/packages/sol-tracing-utils/src/globals.d.ts similarity index 100% rename from packages/sol-trace-based-tools-common/src/globals.d.ts rename to packages/sol-tracing-utils/src/globals.d.ts diff --git a/packages/sol-trace-based-tools-common/src/index.ts b/packages/sol-tracing-utils/src/index.ts similarity index 100% rename from packages/sol-trace-based-tools-common/src/index.ts rename to packages/sol-tracing-utils/src/index.ts diff --git a/packages/sol-trace-based-tools-common/src/instructions.ts b/packages/sol-tracing-utils/src/instructions.ts similarity index 100% rename from packages/sol-trace-based-tools-common/src/instructions.ts rename to packages/sol-tracing-utils/src/instructions.ts diff --git a/packages/sol-trace-based-tools-common/src/revert_trace.ts b/packages/sol-tracing-utils/src/revert_trace.ts similarity index 100% rename from packages/sol-trace-based-tools-common/src/revert_trace.ts rename to packages/sol-tracing-utils/src/revert_trace.ts diff --git a/packages/sol-trace-based-tools-common/src/source_maps.ts b/packages/sol-tracing-utils/src/source_maps.ts similarity index 100% rename from packages/sol-trace-based-tools-common/src/source_maps.ts rename to packages/sol-tracing-utils/src/source_maps.ts diff --git a/packages/sol-trace-based-tools-common/src/trace.ts b/packages/sol-tracing-utils/src/trace.ts similarity index 100% rename from packages/sol-trace-based-tools-common/src/trace.ts rename to packages/sol-tracing-utils/src/trace.ts diff --git a/packages/sol-trace-based-tools-common/src/trace_collection_subprovider.ts b/packages/sol-tracing-utils/src/trace_collection_subprovider.ts similarity index 100% rename from packages/sol-trace-based-tools-common/src/trace_collection_subprovider.ts rename to packages/sol-tracing-utils/src/trace_collection_subprovider.ts diff --git a/packages/sol-trace-based-tools-common/src/trace_collector.ts b/packages/sol-tracing-utils/src/trace_collector.ts similarity index 98% rename from packages/sol-trace-based-tools-common/src/trace_collector.ts rename to packages/sol-tracing-utils/src/trace_collector.ts index 8ba71f4df9..943e208cf9 100644 --- a/packages/sol-trace-based-tools-common/src/trace_collector.ts +++ b/packages/sol-tracing-utils/src/trace_collector.ts @@ -51,7 +51,7 @@ export class TraceCollector { singleFileSubtraceHandler: SingleFileSubtraceHandler, ) { this._artifactAdapter = artifactAdapter; - this._logger = getLogger('sol-trace-based-tools-common'); + this._logger = getLogger('sol-tracing-utils'); this._logger.setLevel(isVerbose ? levels.TRACE : levels.ERROR); this._singleFileSubtraceHandler = singleFileSubtraceHandler; } diff --git a/packages/sol-trace-based-tools-common/src/trace_info_subprovider.ts b/packages/sol-tracing-utils/src/trace_info_subprovider.ts similarity index 100% rename from packages/sol-trace-based-tools-common/src/trace_info_subprovider.ts rename to packages/sol-tracing-utils/src/trace_info_subprovider.ts diff --git a/packages/sol-trace-based-tools-common/src/types.ts b/packages/sol-tracing-utils/src/types.ts similarity index 100% rename from packages/sol-trace-based-tools-common/src/types.ts rename to packages/sol-tracing-utils/src/types.ts diff --git a/packages/sol-trace-based-tools-common/src/utils.ts b/packages/sol-tracing-utils/src/utils.ts similarity index 100% rename from packages/sol-trace-based-tools-common/src/utils.ts rename to packages/sol-tracing-utils/src/utils.ts diff --git a/packages/sol-trace-based-tools-common/test/collect_coverage_entries_test.ts b/packages/sol-tracing-utils/test/collect_coverage_entries_test.ts similarity index 100% rename from packages/sol-trace-based-tools-common/test/collect_coverage_entries_test.ts rename to packages/sol-tracing-utils/test/collect_coverage_entries_test.ts diff --git a/packages/sol-trace-based-tools-common/test/fixtures/contracts/AllSolidityFeatures.sol b/packages/sol-tracing-utils/test/fixtures/contracts/AllSolidityFeatures.sol similarity index 100% rename from packages/sol-trace-based-tools-common/test/fixtures/contracts/AllSolidityFeatures.sol rename to packages/sol-tracing-utils/test/fixtures/contracts/AllSolidityFeatures.sol diff --git a/packages/sol-trace-based-tools-common/test/fixtures/contracts/SimpleStorage.sol b/packages/sol-tracing-utils/test/fixtures/contracts/SimpleStorage.sol similarity index 100% rename from packages/sol-trace-based-tools-common/test/fixtures/contracts/SimpleStorage.sol rename to packages/sol-tracing-utils/test/fixtures/contracts/SimpleStorage.sol diff --git a/packages/sol-trace-based-tools-common/test/fixtures/contracts/Simplest.sol b/packages/sol-tracing-utils/test/fixtures/contracts/Simplest.sol similarity index 100% rename from packages/sol-trace-based-tools-common/test/fixtures/contracts/Simplest.sol rename to packages/sol-tracing-utils/test/fixtures/contracts/Simplest.sol diff --git a/packages/sol-trace-based-tools-common/test/fixtures/contracts/SolcovIgnore.sol b/packages/sol-tracing-utils/test/fixtures/contracts/SolcovIgnore.sol similarity index 100% rename from packages/sol-trace-based-tools-common/test/fixtures/contracts/SolcovIgnore.sol rename to packages/sol-tracing-utils/test/fixtures/contracts/SolcovIgnore.sol diff --git a/packages/sol-trace-based-tools-common/test/instructions_test.ts b/packages/sol-tracing-utils/test/instructions_test.ts similarity index 100% rename from packages/sol-trace-based-tools-common/test/instructions_test.ts rename to packages/sol-tracing-utils/test/instructions_test.ts diff --git a/packages/sol-trace-based-tools-common/test/sol_compiler_artifact_adapter_test.ts b/packages/sol-tracing-utils/test/sol_compiler_artifact_adapter_test.ts similarity index 100% rename from packages/sol-trace-based-tools-common/test/sol_compiler_artifact_adapter_test.ts rename to packages/sol-tracing-utils/test/sol_compiler_artifact_adapter_test.ts diff --git a/packages/sol-trace-based-tools-common/test/source_maps_test.ts b/packages/sol-tracing-utils/test/source_maps_test.ts similarity index 100% rename from packages/sol-trace-based-tools-common/test/source_maps_test.ts rename to packages/sol-tracing-utils/test/source_maps_test.ts diff --git a/packages/sol-trace-based-tools-common/test/trace_test.ts b/packages/sol-tracing-utils/test/trace_test.ts similarity index 100% rename from packages/sol-trace-based-tools-common/test/trace_test.ts rename to packages/sol-tracing-utils/test/trace_test.ts diff --git a/packages/sol-trace-based-tools-common/test/utils_test.ts b/packages/sol-tracing-utils/test/utils_test.ts similarity index 100% rename from packages/sol-trace-based-tools-common/test/utils_test.ts rename to packages/sol-tracing-utils/test/utils_test.ts diff --git a/packages/sol-trace-based-tools-common/tsconfig.json b/packages/sol-tracing-utils/tsconfig.json similarity index 100% rename from packages/sol-trace-based-tools-common/tsconfig.json rename to packages/sol-tracing-utils/tsconfig.json diff --git a/packages/sol-trace-based-tools-common/tslint.json b/packages/sol-tracing-utils/tslint.json similarity index 100% rename from packages/sol-trace-based-tools-common/tslint.json rename to packages/sol-tracing-utils/tslint.json diff --git a/tsconfig.json b/tsconfig.json index 1f5da33dc1..a494839722 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -55,7 +55,7 @@ { "path": "./packages/sol-coverage" }, { "path": "./packages/sol-profiler" }, { "path": "./packages/sol-trace" }, - { "path": "./packages/sol-trace-based-tools-common" }, + { "path": "./packages/sol-tracing-utils" }, { "path": "./packages/sol-resolver" }, { "path": "./packages/sra-spec" }, { "path": "./packages/subproviders" }, From a8d9263062e586b90ee4c303d3d3aca72e428edc Mon Sep 17 00:00:00 2001 From: Leonid Logvinov Date: Thu, 10 Jan 2019 11:42:50 +0100 Subject: [PATCH 12/15] Add .gitkeep --- packages/sol-tracing-utils/coverage/.gitkeep | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 packages/sol-tracing-utils/coverage/.gitkeep diff --git a/packages/sol-tracing-utils/coverage/.gitkeep b/packages/sol-tracing-utils/coverage/.gitkeep new file mode 100644 index 0000000000..e69de29bb2 From 4c60d591234af87f296884a9ee438960d928e010 Mon Sep 17 00:00:00 2001 From: Leonid Logvinov Date: Thu, 10 Jan 2019 11:57:18 +0100 Subject: [PATCH 13/15] Remove second yarn call --- .circleci/config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 25c008c209..f64017b564 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -16,7 +16,7 @@ jobs: command: sudo npm install --global yarn@1.9.4 - run: name: yarn - command: yarn --frozen-lockfile --ignore-engines install || yarn --frozen-lockfile --ignore-engines install + command: yarn --frozen-lockfile --ignore-engines install - run: yarn build:ci:no_website - run: yarn build:ts - save_cache: From c317a69e7e599e79e6b2e841211cc9ceaffa3c6f Mon Sep 17 00:00:00 2001 From: Leonid Logvinov Date: Thu, 10 Jan 2019 13:33:56 +0100 Subject: [PATCH 14/15] Add missing dependencies --- packages/metacoin/package.json | 3 +++ 1 file changed, 3 insertions(+) diff --git a/packages/metacoin/package.json b/packages/metacoin/package.json index 0081e8be18..6812ff823b 100644 --- a/packages/metacoin/package.json +++ b/packages/metacoin/package.json @@ -32,6 +32,9 @@ "@0x/abi-gen": "^1.0.20", "@0x/abi-gen-templates": "^1.0.1", "@0x/base-contract": "^3.0.11", + "@0x/sol-coverage": "^1.0.0", + "@0x/sol-profiler": "^1.0.0", + "@0x/sol-trace": "^1.0.0", "@0x/subproviders": "^2.1.9", "@0x/tslint-config": "^2.0.0", "@0x/types": "^1.5.0", From b8e3829fdbd1f516686618562172cb45fbb63bde Mon Sep 17 00:00:00 2001 From: Leonid Logvinov Date: Thu, 10 Jan 2019 14:05:29 +0100 Subject: [PATCH 15/15] Fix prettier --- packages/sol-coverage/CHANGELOG.json | 3 +-- packages/sol-profiler/CHANGELOG.json | 3 +-- packages/sol-trace/CHANGELOG.json | 3 +-- yarn.lock | 2 +- 4 files changed, 4 insertions(+), 7 deletions(-) diff --git a/packages/sol-coverage/CHANGELOG.json b/packages/sol-coverage/CHANGELOG.json index c650a4a4bf..223400eae1 100644 --- a/packages/sol-coverage/CHANGELOG.json +++ b/packages/sol-coverage/CHANGELOG.json @@ -3,8 +3,7 @@ "version": "1.0.0", "changes": [ { - "note": - "Initial release as a separate package. For historical entries see @0x/sol-tracing-utils", + "note": "Initial release as a separate package. For historical entries see @0x/sol-tracing-utils", "pr": 1492 } ] diff --git a/packages/sol-profiler/CHANGELOG.json b/packages/sol-profiler/CHANGELOG.json index c650a4a4bf..223400eae1 100644 --- a/packages/sol-profiler/CHANGELOG.json +++ b/packages/sol-profiler/CHANGELOG.json @@ -3,8 +3,7 @@ "version": "1.0.0", "changes": [ { - "note": - "Initial release as a separate package. For historical entries see @0x/sol-tracing-utils", + "note": "Initial release as a separate package. For historical entries see @0x/sol-tracing-utils", "pr": 1492 } ] diff --git a/packages/sol-trace/CHANGELOG.json b/packages/sol-trace/CHANGELOG.json index c650a4a4bf..223400eae1 100644 --- a/packages/sol-trace/CHANGELOG.json +++ b/packages/sol-trace/CHANGELOG.json @@ -3,8 +3,7 @@ "version": "1.0.0", "changes": [ { - "note": - "Initial release as a separate package. For historical entries see @0x/sol-tracing-utils", + "note": "Initial release as a separate package. For historical entries see @0x/sol-tracing-utils", "pr": 1492 } ] diff --git a/yarn.lock b/yarn.lock index 4dd15df4de..19d3c0213b 100644 --- a/yarn.lock +++ b/yarn.lock @@ -17366,7 +17366,7 @@ socks@~2.2.0: ip "^1.1.5" smart-buffer "^4.0.1" -solc@0.4.24, solc@^0.4.24: +solc@0.4.24: version "0.4.24" resolved "https://registry.yarnpkg.com/solc/-/solc-0.4.24.tgz#354f14b269b38cbaa82a47d1ff151723502b954e" integrity sha512-2xd7Cf1HeVwrIb6Bu1cwY2/TaLRodrppCq3l7rhLimFQgmxptXhTC3+/wesVLpB09F1A2kZgvbMOgH7wvhFnBQ==