Refactor out sol-cov, sol-profiler and sol-trace into their separate packages
This commit is contained in:
parent
0ac36cef28
commit
2c974b5f3f
@ -118,7 +118,7 @@ jobs:
|
|||||||
- run: yarn wsrun test:circleci @0x/order-utils
|
- run: yarn wsrun test:circleci @0x/order-utils
|
||||||
- run: yarn wsrun test:circleci @0x/order-watcher
|
- run: yarn wsrun test:circleci @0x/order-watcher
|
||||||
- run: yarn wsrun test:circleci @0x/sol-compiler
|
- 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/sol-doc
|
||||||
- run: yarn wsrun test:circleci @0x/subproviders
|
- run: yarn wsrun test:circleci @0x/subproviders
|
||||||
- run: yarn wsrun test:circleci @0x/web3-wrapper
|
- run: yarn wsrun test:circleci @0x/web3-wrapper
|
||||||
@ -169,9 +169,9 @@ jobs:
|
|||||||
paths:
|
paths:
|
||||||
- ~/repo/packages/sol-compiler/coverage/lcov.info
|
- ~/repo/packages/sol-compiler/coverage/lcov.info
|
||||||
- save_cache:
|
- save_cache:
|
||||||
key: coverage-sol-cov-{{ .Environment.CIRCLE_SHA1 }}
|
key: coverage-sol-trace-based-tools-common-{{ .Environment.CIRCLE_SHA1 }}
|
||||||
paths:
|
paths:
|
||||||
- ~/repo/packages/sol-cov/coverage/lcov.info
|
- ~/repo/packages/sol-trace-based-tools-common/coverage/lcov.info
|
||||||
- save_cache:
|
- save_cache:
|
||||||
key: coverage-sol-doc-{{ .Environment.CIRCLE_SHA1 }}
|
key: coverage-sol-doc-{{ .Environment.CIRCLE_SHA1 }}
|
||||||
paths:
|
paths:
|
||||||
@ -342,7 +342,7 @@ jobs:
|
|||||||
- coverage-sol-compiler-{{ .Environment.CIRCLE_SHA1 }}
|
- coverage-sol-compiler-{{ .Environment.CIRCLE_SHA1 }}
|
||||||
- restore_cache:
|
- restore_cache:
|
||||||
keys:
|
keys:
|
||||||
- coverage-sol-cov-{{ .Environment.CIRCLE_SHA1 }}
|
- coverage-sol-trace-based-tools-common-{{ .Environment.CIRCLE_SHA1 }}
|
||||||
- restore_cache:
|
- restore_cache:
|
||||||
keys:
|
keys:
|
||||||
- coverage-sol-doc-{{ .Environment.CIRCLE_SHA1 }}
|
- coverage-sol-doc-{{ .Environment.CIRCLE_SHA1 }}
|
||||||
|
5
.github/autolabeler.yml
vendored
5
.github/autolabeler.yml
vendored
@ -13,7 +13,10 @@ instant: ['packages/instant']
|
|||||||
abi-gen-templates: ['packages/abi-gen-templates']
|
abi-gen-templates: ['packages/abi-gen-templates']
|
||||||
abi-gen: ['packages/abi-gen']
|
abi-gen: ['packages/abi-gen']
|
||||||
website: ['packages/website']
|
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']
|
utils: ['packages/utils']
|
||||||
tslint-config: ['packages/tslint-config']
|
tslint-config: ['packages/tslint-config']
|
||||||
asset-buyer: ['packages/asset-buyer']
|
asset-buyer: ['packages/asset-buyer']
|
||||||
|
2
.gitignore
vendored
2
.gitignore
vendored
@ -91,7 +91,7 @@ contracts/interfaces/generated-artifacts/
|
|||||||
contracts/tokens/generated-artifacts/
|
contracts/tokens/generated-artifacts/
|
||||||
contracts/examples/generated-artifacts/
|
contracts/examples/generated-artifacts/
|
||||||
contracts/extensions/generated-artifacts/
|
contracts/extensions/generated-artifacts/
|
||||||
packages/sol-cov/test/fixtures/artifacts/
|
packages/sol-trace-based-tools-common/test/fixtures/artifacts/
|
||||||
packages/metacoin/artifacts/
|
packages/metacoin/artifacts/
|
||||||
|
|
||||||
# generated contract wrappers
|
# generated contract wrappers
|
||||||
|
@ -26,4 +26,4 @@ lib
|
|||||||
/packages/sra-spec/public/
|
/packages/sra-spec/public/
|
||||||
package.json
|
package.json
|
||||||
scripts/postpublish_utils.js
|
scripts/postpublish_utils.js
|
||||||
packages/sol-cov/test/fixtures/artifacts
|
packages/sol-coverage/test/fixtures/artifacts
|
||||||
|
@ -24,7 +24,10 @@ packages/metacoin/ @LogvinovLeon
|
|||||||
packages/monorepo-scripts/ @fabioberger
|
packages/monorepo-scripts/ @fabioberger
|
||||||
packages/order-utils/ @fabioberger @LogvinovLeon
|
packages/order-utils/ @fabioberger @LogvinovLeon
|
||||||
packages/sol-compiler/ @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/sol-resolver/ @LogvinovLeon
|
||||||
packages/subproviders/ @fabioberger @dekz
|
packages/subproviders/ @fabioberger @dekz
|
||||||
packages/verdaccio/ @albrow
|
packages/verdaccio/ @albrow
|
||||||
|
@ -54,7 +54,9 @@ Visit our [developer portal](https://0xproject.com/docs/order-utils) for a compr
|
|||||||
| -------------------------------------------- | ----------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
| -------------------------------------------- | ----------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||||
| [`@0x/web3-wrapper`](/packages/web3-wrapper) | [](https://www.npmjs.com/package/@0x/web3-wrapper) | An Ethereum JSON RPC client |
|
| [`@0x/web3-wrapper`](/packages/web3-wrapper) | [](https://www.npmjs.com/package/@0x/web3-wrapper) | An Ethereum JSON RPC client |
|
||||||
| [`@0x/sol-compiler`](/packages/sol-compiler) | [](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-compiler`](/packages/sol-compiler) | [](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) | [](https://www.npmjs.com/package/@0x/sol-cov) | A solidity test coverage tool |
|
| [`@0x/sol-coverage`](/packages/sol-coverage) | [](https://www.npmjs.com/package/@0x/sol-coverage) | A solidity test coverage tool |
|
||||||
|
| [`@0x/sol-profiler`](/packages/sol-profiler) | [](https://www.npmjs.com/package/@0x/sol-profiler) | A solidity gas cost profiler |
|
||||||
|
| [`@0x/sol-trace`](/packages/sol-trace) | [](https://www.npmjs.com/package/@0x/sol-trace) | A solidity stack trace tool |
|
||||||
| [`@0x/sol-resolver`](/packages/sol-resolver) | [](https://www.npmjs.com/package/@0x/sol-resolver) | Import resolver for smart contracts dependencies |
|
| [`@0x/sol-resolver`](/packages/sol-resolver) | [](https://www.npmjs.com/package/@0x/sol-resolver) | Import resolver for smart contracts dependencies |
|
||||||
| [`@0x/subproviders`](/packages/subproviders) | [](https://www.npmjs.com/package/@0x/subproviders) | Web3 provider middlewares (e.g. LedgerSubprovider) |
|
| [`@0x/subproviders`](/packages/subproviders) | [](https://www.npmjs.com/package/@0x/subproviders) | Web3 provider middlewares (e.g. LedgerSubprovider) |
|
||||||
| [`@0x/sol-doc`](/packages/sol-doc) | [](https://www.npmjs.com/package/@0x/sol-doc) | Solidity documentation generator |
|
| [`@0x/sol-doc`](/packages/sol-doc) | [](https://www.npmjs.com/package/@0x/sol-doc) | Solidity documentation generator |
|
||||||
|
@ -20,7 +20,7 @@ TEST_PROVIDER=geth yarn test
|
|||||||
|
|
||||||
## Code coverage
|
## 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
|
yarn test:coverage
|
||||||
|
@ -37,7 +37,6 @@
|
|||||||
"@0x/contracts-test-utils": "^1.0.2",
|
"@0x/contracts-test-utils": "^1.0.2",
|
||||||
"@0x/dev-utils": "^1.0.21",
|
"@0x/dev-utils": "^1.0.21",
|
||||||
"@0x/sol-compiler": "^1.1.16",
|
"@0x/sol-compiler": "^1.1.16",
|
||||||
"@0x/sol-cov": "^2.1.16",
|
|
||||||
"@0x/subproviders": "^2.1.8",
|
"@0x/subproviders": "^2.1.8",
|
||||||
"@0x/tslint-config": "^2.0.0",
|
"@0x/tslint-config": "^2.0.0",
|
||||||
"@types/bn.js": "^4.11.0",
|
"@types/bn.js": "^4.11.0",
|
||||||
|
@ -49,7 +49,6 @@
|
|||||||
"@0x/contracts-test-utils": "^1.0.2",
|
"@0x/contracts-test-utils": "^1.0.2",
|
||||||
"@0x/dev-utils": "^1.0.21",
|
"@0x/dev-utils": "^1.0.21",
|
||||||
"@0x/sol-compiler": "^1.1.16",
|
"@0x/sol-compiler": "^1.1.16",
|
||||||
"@0x/sol-cov": "^2.1.16",
|
|
||||||
"@0x/subproviders": "^2.1.8",
|
"@0x/subproviders": "^2.1.8",
|
||||||
"@0x/tslint-config": "^2.0.0",
|
"@0x/tslint-config": "^2.0.0",
|
||||||
"@types/bn.js": "^4.11.0",
|
"@types/bn.js": "^4.11.0",
|
||||||
|
@ -48,7 +48,6 @@
|
|||||||
"@0x/contracts-test-utils": "^1.0.2",
|
"@0x/contracts-test-utils": "^1.0.2",
|
||||||
"@0x/dev-utils": "^1.0.21",
|
"@0x/dev-utils": "^1.0.21",
|
||||||
"@0x/sol-compiler": "^1.1.16",
|
"@0x/sol-compiler": "^1.1.16",
|
||||||
"@0x/sol-cov": "^2.1.16",
|
|
||||||
"@0x/subproviders": "^2.1.8",
|
"@0x/subproviders": "^2.1.8",
|
||||||
"@0x/tslint-config": "^2.0.0",
|
"@0x/tslint-config": "^2.0.0",
|
||||||
"@types/bn.js": "^4.11.0",
|
"@types/bn.js": "^4.11.0",
|
||||||
|
@ -48,7 +48,6 @@
|
|||||||
"@0x/contracts-test-utils": "^1.0.2",
|
"@0x/contracts-test-utils": "^1.0.2",
|
||||||
"@0x/dev-utils": "^1.0.21",
|
"@0x/dev-utils": "^1.0.21",
|
||||||
"@0x/sol-compiler": "^1.1.16",
|
"@0x/sol-compiler": "^1.1.16",
|
||||||
"@0x/sol-cov": "^2.1.16",
|
|
||||||
"@0x/subproviders": "^2.1.8",
|
"@0x/subproviders": "^2.1.8",
|
||||||
"@0x/tslint-config": "^2.0.0",
|
"@0x/tslint-config": "^2.0.0",
|
||||||
"@types/bn.js": "^4.11.0",
|
"@types/bn.js": "^4.11.0",
|
||||||
|
@ -47,7 +47,6 @@
|
|||||||
"@0x/abi-gen": "^1.0.19",
|
"@0x/abi-gen": "^1.0.19",
|
||||||
"@0x/dev-utils": "^1.0.21",
|
"@0x/dev-utils": "^1.0.21",
|
||||||
"@0x/sol-compiler": "^1.1.16",
|
"@0x/sol-compiler": "^1.1.16",
|
||||||
"@0x/sol-cov": "^2.1.16",
|
|
||||||
"@0x/subproviders": "^2.1.8",
|
"@0x/subproviders": "^2.1.8",
|
||||||
"@0x/tslint-config": "^2.0.0",
|
"@0x/tslint-config": "^2.0.0",
|
||||||
"@types/bn.js": "^4.11.0",
|
"@types/bn.js": "^4.11.0",
|
||||||
|
@ -44,7 +44,9 @@
|
|||||||
"@0x/dev-utils": "^1.0.21",
|
"@0x/dev-utils": "^1.0.21",
|
||||||
"@0x/order-utils": "^3.0.7",
|
"@0x/order-utils": "^3.0.7",
|
||||||
"@0x/sol-compiler": "^1.1.16",
|
"@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/subproviders": "^2.1.8",
|
||||||
"@0x/tslint-config": "^2.0.0",
|
"@0x/tslint-config": "^2.0.0",
|
||||||
"@0x/types": "^1.4.1",
|
"@0x/types": "^1.4.1",
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import { devConstants } from '@0x/dev-utils';
|
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 * as _ from 'lodash';
|
||||||
|
|
||||||
let coverageSubprovider: CoverageSubprovider;
|
let coverageSubprovider: CoverageSubprovider;
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import { devConstants } from '@0x/dev-utils';
|
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 * as _ from 'lodash';
|
||||||
|
|
||||||
let profilerSubprovider: ProfilerSubprovider;
|
let profilerSubprovider: ProfilerSubprovider;
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import { devConstants } from '@0x/dev-utils';
|
import { devConstants } from '@0x/dev-utils';
|
||||||
import { RevertTraceSubprovider, SolCompilerArtifactAdapter } from '@0x/sol-cov';
|
import { RevertTraceSubprovider, SolCompilerArtifactAdapter } from '@0x/sol-trace';
|
||||||
import * as _ from 'lodash';
|
import * as _ from 'lodash';
|
||||||
|
|
||||||
let revertTraceSubprovider: RevertTraceSubprovider;
|
let revertTraceSubprovider: RevertTraceSubprovider;
|
||||||
|
@ -48,7 +48,6 @@
|
|||||||
"@0x/contracts-test-utils": "^1.0.2",
|
"@0x/contracts-test-utils": "^1.0.2",
|
||||||
"@0x/dev-utils": "^1.0.21",
|
"@0x/dev-utils": "^1.0.21",
|
||||||
"@0x/sol-compiler": "^1.1.16",
|
"@0x/sol-compiler": "^1.1.16",
|
||||||
"@0x/sol-cov": "^2.1.16",
|
|
||||||
"@0x/subproviders": "^2.1.8",
|
"@0x/subproviders": "^2.1.8",
|
||||||
"@0x/tslint-config": "^2.0.0",
|
"@0x/tslint-config": "^2.0.0",
|
||||||
"@types/bn.js": "^4.11.0",
|
"@types/bn.js": "^4.11.0",
|
||||||
|
@ -48,7 +48,6 @@
|
|||||||
"@0x/contracts-test-utils": "^1.0.2",
|
"@0x/contracts-test-utils": "^1.0.2",
|
||||||
"@0x/dev-utils": "^1.0.21",
|
"@0x/dev-utils": "^1.0.21",
|
||||||
"@0x/sol-compiler": "^1.1.16",
|
"@0x/sol-compiler": "^1.1.16",
|
||||||
"@0x/sol-cov": "^2.1.16",
|
|
||||||
"@0x/subproviders": "^2.1.8",
|
"@0x/subproviders": "^2.1.8",
|
||||||
"@0x/tslint-config": "^2.0.0",
|
"@0x/tslint-config": "^2.0.0",
|
||||||
"@types/bn.js": "^4.11.0",
|
"@types/bn.js": "^4.11.0",
|
||||||
|
@ -41,7 +41,7 @@
|
|||||||
},
|
},
|
||||||
"config": {
|
"config": {
|
||||||
"mnemonic": "concert load couple harbor equip island argue ramp clarify fence smart topic",
|
"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": {
|
"bundlewatch": {
|
||||||
"files": [
|
"files": [
|
||||||
@ -62,6 +62,9 @@
|
|||||||
"repoBranchBase": "development"
|
"repoBranchBase": "development"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"resolutions": {
|
||||||
|
"graceful-fs": "4.1.15"
|
||||||
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@0x-lerna-fork/lerna": "3.0.0-beta.26",
|
"@0x-lerna-fork/lerna": "3.0.0-beta.26",
|
||||||
"@0xproject/npm-cli-login": "^0.0.11",
|
"@0xproject/npm-cli-login": "^0.0.11",
|
||||||
|
@ -32,7 +32,8 @@
|
|||||||
"@0x/abi-gen": "^1.0.19",
|
"@0x/abi-gen": "^1.0.19",
|
||||||
"@0x/abi-gen-templates": "^1.0.1",
|
"@0x/abi-gen-templates": "^1.0.1",
|
||||||
"@0x/base-contract": "^3.0.10",
|
"@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/subproviders": "^2.1.8",
|
||||||
"@0x/tslint-config": "^2.0.0",
|
"@0x/tslint-config": "^2.0.0",
|
||||||
"@0x/types": "^1.4.1",
|
"@0x/types": "^1.4.1",
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import { devConstants } from '@0x/dev-utils';
|
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 * as _ from 'lodash';
|
||||||
|
|
||||||
import { config } from './config';
|
import { config } from './config';
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import { devConstants } from '@0x/dev-utils';
|
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 * as _ from 'lodash';
|
||||||
|
|
||||||
import { config } from './config';
|
import { config } from './config';
|
||||||
|
@ -1,6 +0,0 @@
|
|||||||
{
|
|
||||||
"extends": ["@0x/tslint-config"],
|
|
||||||
"rules": {
|
|
||||||
"completed-docs": false
|
|
||||||
}
|
|
||||||
}
|
|
12
packages/sol-coverage/CHANGELOG.json
Normal file
12
packages/sol-coverage/CHANGELOG.json
Normal file
@ -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
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
@ -1,25 +1,25 @@
|
|||||||
## @0x/sol-cov
|
## @0x/sol-coverage
|
||||||
|
|
||||||
A Solidity code coverage tool.
|
A Solidity code coverage tool.
|
||||||
|
|
||||||
### Read the [Documentation](https://0xproject.com/docs/sol-cov).
|
### Read the [Documentation](https://0xproject.com/docs/sol-coverage).
|
||||||
|
|
||||||
## Installation
|
## Installation
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
yarn add @0x/sol-cov
|
yarn add @0x/sol-coverage
|
||||||
```
|
```
|
||||||
|
|
||||||
**Import**
|
**Import**
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
import { CoverageSubprovider } from '@0x/sol-cov';
|
import { CoverageSubprovider } from '@0x/sol-coverage';
|
||||||
```
|
```
|
||||||
|
|
||||||
or
|
or
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
var CoverageSubprovider = require('@0x/sol-cov').CoverageSubprovider;
|
var CoverageSubprovider = require('@0x/sol-coverage').CoverageSubprovider;
|
||||||
```
|
```
|
||||||
|
|
||||||
## Contributing
|
## 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:
|
To build this package and all other monorepo packages that it depends on, run the following from the monorepo root directory:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
PKG=@0x/sol-cov yarn build
|
PKG=@0x/sol-coverage yarn build
|
||||||
```
|
```
|
||||||
|
|
||||||
Or continuously rebuild on change:
|
Or continuously rebuild on change:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
PKG=@0x/sol-cov yarn watch
|
PKG=@0x/sol-coverage yarn watch
|
||||||
```
|
```
|
||||||
|
|
||||||
### Clean
|
### Clean
|
52
packages/sol-coverage/package.json
Normal file
52
packages/sol-coverage/package.json
Normal file
@ -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"
|
||||||
|
}
|
||||||
|
}
|
@ -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 {
|
import {
|
||||||
|
AbstractArtifactAdapter,
|
||||||
BranchCoverage,
|
BranchCoverage,
|
||||||
|
collectCoverageEntries,
|
||||||
ContractData,
|
ContractData,
|
||||||
Coverage,
|
Coverage,
|
||||||
FunctionCoverage,
|
FunctionCoverage,
|
||||||
FunctionDescription,
|
FunctionDescription,
|
||||||
|
SingleFileSubtraceHandler,
|
||||||
SourceRange,
|
SourceRange,
|
||||||
StatementCoverage,
|
StatementCoverage,
|
||||||
StatementDescription,
|
StatementDescription,
|
||||||
Subtrace,
|
Subtrace,
|
||||||
|
TraceCollector,
|
||||||
TraceInfo,
|
TraceInfo,
|
||||||
} from './types';
|
TraceInfoSubprovider,
|
||||||
import { utils } from './utils';
|
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.
|
* This class implements the [web3-provider-engine](https://github.com/MetaMask/provider-engine) subprovider interface.
|
23
packages/sol-coverage/src/index.ts
Normal file
23
packages/sol-coverage/src/index.ts
Normal file
@ -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';
|
8
packages/sol-coverage/tsconfig.json
Normal file
8
packages/sol-coverage/tsconfig.json
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
{
|
||||||
|
"extends": "../../tsconfig",
|
||||||
|
"compilerOptions": {
|
||||||
|
"outDir": "lib",
|
||||||
|
"rootDir": "."
|
||||||
|
},
|
||||||
|
"include": ["./src/**/*"]
|
||||||
|
}
|
3
packages/sol-coverage/tslint.json
Normal file
3
packages/sol-coverage/tslint.json
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
{
|
||||||
|
"extends": ["@0x/tslint-config"]
|
||||||
|
}
|
6
packages/sol-profiler/.npmignore
Normal file
6
packages/sol-profiler/.npmignore
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
.*
|
||||||
|
yarn-error.log
|
||||||
|
/src/
|
||||||
|
/scripts/
|
||||||
|
tsconfig.json
|
||||||
|
/lib/src/monorepo_scripts/
|
12
packages/sol-profiler/CHANGELOG.json
Normal file
12
packages/sol-profiler/CHANGELOG.json
Normal file
@ -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
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
75
packages/sol-profiler/README.md
Normal file
75
packages/sol-profiler/README.md
Normal file
@ -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
|
||||||
|
```
|
50
packages/sol-profiler/package.json
Normal file
50
packages/sol-profiler/package.json
Normal file
@ -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"
|
||||||
|
}
|
||||||
|
}
|
7
packages/sol-profiler/src/globals.d.ts
vendored
Normal file
7
packages/sol-profiler/src/globals.d.ts
vendored
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
// tslint:disable:completed-docs
|
||||||
|
declare module '*.json' {
|
||||||
|
const json: any;
|
||||||
|
/* tslint:disable */
|
||||||
|
export default json;
|
||||||
|
/* tslint:enable */
|
||||||
|
}
|
@ -1,13 +1,13 @@
|
|||||||
export { CoverageSubprovider } from './coverage_subprovider';
|
export {
|
||||||
export { SolCompilerArtifactAdapter } from './artifact_adapters/sol_compiler_artifact_adapter';
|
AbstractArtifactAdapter,
|
||||||
export { TruffleArtifactAdapter } from './artifact_adapters/truffle_artifact_adapter';
|
SolCompilerArtifactAdapter,
|
||||||
export { AbstractArtifactAdapter } from './artifact_adapters/abstract_artifact_adapter';
|
TruffleArtifactAdapter,
|
||||||
|
ContractData,
|
||||||
|
} from '@0x/sol-trace-based-tools-common';
|
||||||
|
|
||||||
// HACK: ProfilerSubprovider is a hacky way to do profiling using coverage tools. Not production ready
|
// HACK: ProfilerSubprovider is a hacky way to do profiling using coverage tools. Not production ready
|
||||||
export { ProfilerSubprovider } from './profiler_subprovider';
|
export { ProfilerSubprovider } from './profiler_subprovider';
|
||||||
export { RevertTraceSubprovider } from './revert_trace_subprovider';
|
|
||||||
|
|
||||||
export { ContractData } from './types';
|
|
||||||
export {
|
export {
|
||||||
JSONRPCRequestPayload,
|
JSONRPCRequestPayload,
|
||||||
Provider,
|
Provider,
|
@ -1,11 +1,18 @@
|
|||||||
import * as _ from 'lodash';
|
import * as _ from 'lodash';
|
||||||
|
|
||||||
import { AbstractArtifactAdapter } from './artifact_adapters/abstract_artifact_adapter';
|
import {
|
||||||
import { collectCoverageEntries } from './collect_coverage_entries';
|
AbstractArtifactAdapter,
|
||||||
import { SingleFileSubtraceHandler, TraceCollector } from './trace_collector';
|
collectCoverageEntries,
|
||||||
import { TraceInfoSubprovider } from './trace_info_subprovider';
|
ContractData,
|
||||||
import { ContractData, Coverage, SourceRange, Subtrace, TraceInfo } from './types';
|
Coverage,
|
||||||
import { utils } from './utils';
|
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.
|
* This class implements the [web3-provider-engine](https://github.com/MetaMask/provider-engine) subprovider interface.
|
8
packages/sol-profiler/tsconfig.json
Normal file
8
packages/sol-profiler/tsconfig.json
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
{
|
||||||
|
"extends": "../../tsconfig",
|
||||||
|
"compilerOptions": {
|
||||||
|
"outDir": "lib",
|
||||||
|
"rootDir": "."
|
||||||
|
},
|
||||||
|
"include": ["./src/**/*"]
|
||||||
|
}
|
3
packages/sol-profiler/tslint.json
Normal file
3
packages/sol-profiler/tslint.json
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
{
|
||||||
|
"extends": ["@0x/tslint-config"]
|
||||||
|
}
|
7
packages/sol-profiler/typedoc-tsconfig.json
Normal file
7
packages/sol-profiler/typedoc-tsconfig.json
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
{
|
||||||
|
"extends": "../../typedoc-tsconfig",
|
||||||
|
"compilerOptions": {
|
||||||
|
"outDir": "lib"
|
||||||
|
},
|
||||||
|
"include": ["./src/**/*"]
|
||||||
|
}
|
6
packages/sol-trace-based-tools-common/.npmignore
Normal file
6
packages/sol-trace-based-tools-common/.npmignore
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
.*
|
||||||
|
yarn-error.log
|
||||||
|
/src/
|
||||||
|
/scripts/
|
||||||
|
tsconfig.json
|
||||||
|
/lib/src/monorepo_scripts/
|
@ -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",
|
"version": "2.1.16",
|
||||||
"changes": [
|
"changes": [
|
61
packages/sol-trace-based-tools-common/README.md
Normal file
61
packages/sol-trace-based-tools-common/README.md
Normal file
@ -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
|
||||||
|
```
|
@ -1,10 +1,10 @@
|
|||||||
{
|
{
|
||||||
"name": "@0x/sol-cov",
|
"name": "@0x/sol-trace-based-tools-common",
|
||||||
"version": "2.1.16",
|
"version": "2.1.16",
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=6.12"
|
"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",
|
"main": "lib/src/index.js",
|
||||||
"types": "lib/src/index.d.ts",
|
"types": "lib/src/index.d.ts",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
@ -34,13 +34,13 @@
|
|||||||
},
|
},
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/0xProject/0x.js.git"
|
"url": "https://github.com/0xProject/0x-monorepo.git"
|
||||||
},
|
},
|
||||||
"license": "Apache-2.0",
|
"license": "Apache-2.0",
|
||||||
"bugs": {
|
"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": {
|
"dependencies": {
|
||||||
"@0x/dev-utils": "^1.0.21",
|
"@0x/dev-utils": "^1.0.21",
|
||||||
"@0x/sol-compiler": "^1.1.16",
|
"@0x/sol-compiler": "^1.1.16",
|
@ -80,7 +80,7 @@ export class TruffleArtifactAdapter extends AbstractArtifactAdapter {
|
|||||||
throw new Error(
|
throw new Error(
|
||||||
`${artifact.contractName} was compiled with solidity ${compilerVersion} but specified version is ${
|
`${artifact.contractName} was compiled with solidity ${compilerVersion} but specified version is ${
|
||||||
this._solcVersion
|
this._solcVersion
|
||||||
} making it impossible for sol-cov to process traces`,
|
} making it impossible to process traces`,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -15,6 +15,11 @@ interface ASTInfo {
|
|||||||
// Parsing source code for each transaction/code is slow and therefore we cache it
|
// Parsing source code for each transaction/code is slow and therefore we cache it
|
||||||
const parsedSourceByHash: { [sourceHash: string]: Parser.ASTNode } = {};
|
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 {
|
export function getSourceRangeSnippet(sourceRange: SourceRange, sourceCode: string): SourceSnippet | null {
|
||||||
const sourceHash = ethUtil.sha3(sourceCode).toString('hex');
|
const sourceHash = ethUtil.sha3(sourceCode).toString('hex');
|
||||||
if (_.isUndefined(parsedSourceByHash[sourceHash])) {
|
if (_.isUndefined(parsedSourceByHash[sourceHash])) {
|
7
packages/sol-trace-based-tools-common/src/globals.d.ts
vendored
Normal file
7
packages/sol-trace-based-tools-common/src/globals.d.ts
vendored
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
// tslint:disable:completed-docs
|
||||||
|
declare module '*.json' {
|
||||||
|
const json: any;
|
||||||
|
/* tslint:disable */
|
||||||
|
export default json;
|
||||||
|
/* tslint:enable */
|
||||||
|
}
|
39
packages/sol-trace-based-tools-common/src/index.ts
Normal file
39
packages/sol-trace-based-tools-common/src/index.ts
Normal file
@ -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';
|
@ -6,6 +6,11 @@ import * as _ from 'lodash';
|
|||||||
import { EvmCallStack } from './types';
|
import { EvmCallStack } from './types';
|
||||||
import { utils } from './utils';
|
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 {
|
export function getRevertTrace(structLogs: StructLog[], startAddress: string): EvmCallStack {
|
||||||
const evmCallStack: EvmCallStack = [];
|
const evmCallStack: EvmCallStack = [];
|
||||||
const addressStack = [startAddress];
|
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
|
// TODO: Refactor this logic to fetch the sub-called contract bytecode before the selfdestruct is called
|
||||||
// in order to handle this edge-case.
|
// in order to handle this edge-case.
|
||||||
logUtils.warn(
|
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) {
|
} else if (structLog.op === OpCode.Revert) {
|
||||||
@ -67,7 +72,7 @@ export function getRevertTrace(structLogs: StructLog[], startAddress: string): E
|
|||||||
} else if (structLog.op === OpCode.Create) {
|
} else if (structLog.op === OpCode.Create) {
|
||||||
// TODO: Extract the new contract address from the stack and handle that scenario
|
// TODO: Extract the new contract address from the stack and handle that scenario
|
||||||
logUtils.warn(
|
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 [];
|
return [];
|
||||||
} else {
|
} else {
|
@ -1,7 +1,7 @@
|
|||||||
import * as _ from 'lodash';
|
import * as _ from 'lodash';
|
||||||
|
|
||||||
import { getPcToInstructionIndexMapping } from './instructions';
|
import { getPcToInstructionIndexMapping } from './instructions';
|
||||||
import { LineColumn, LocationByOffset, SourceRange } from './types';
|
import { LocationByOffset, SourceRange } from './types';
|
||||||
|
|
||||||
const RADIX = 10;
|
const RADIX = 10;
|
||||||
|
|
||||||
@ -11,6 +11,10 @@ export interface SourceLocation {
|
|||||||
fileIndex: number;
|
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 {
|
export function getLocationByOffset(str: string): LocationByOffset {
|
||||||
const locationByOffset: LocationByOffset = { 0: { line: 1, column: 0 } };
|
const locationByOffset: LocationByOffset = { 0: { line: 1, column: 0 } };
|
||||||
let currentOffset = 0;
|
let currentOffset = 0;
|
||||||
@ -26,8 +30,14 @@ export function getLocationByOffset(str: string): LocationByOffset {
|
|||||||
return 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(
|
export function parseSourceMap(
|
||||||
sourceCodes: string[],
|
sourceCodes: string[],
|
||||||
srcMap: string,
|
srcMap: string,
|
@ -8,6 +8,11 @@ export interface TraceByContractAddress {
|
|||||||
[contractAddress: string]: StructLog[];
|
[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 {
|
export function getTracesByContractAddress(structLogs: StructLog[], startAddress: string): TraceByContractAddress {
|
||||||
const traceByContractAddress: TraceByContractAddress = {};
|
const traceByContractAddress: TraceByContractAddress = {};
|
||||||
let currentTraceSegment = [];
|
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
|
// TODO: Refactor this logic to fetch the sub-called contract bytecode before the selfdestruct is called
|
||||||
// in order to handle this edge-case.
|
// in order to handle this edge-case.
|
||||||
logUtils.warn(
|
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) {
|
} else if (structLog.op === OpCode.Create) {
|
||||||
// TODO: Extract the new contract address from the stack and handle that scenario
|
// TODO: Extract the new contract address from the stack and handle that scenario
|
||||||
logUtils.warn(
|
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;
|
return traceByContractAddress;
|
||||||
} else {
|
} else {
|
@ -51,7 +51,7 @@ export class TraceCollector {
|
|||||||
singleFileSubtraceHandler: SingleFileSubtraceHandler,
|
singleFileSubtraceHandler: SingleFileSubtraceHandler,
|
||||||
) {
|
) {
|
||||||
this._artifactAdapter = artifactAdapter;
|
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._logger.setLevel(isVerbose ? levels.TRACE : levels.ERROR);
|
||||||
this._singleFileSubtraceHandler = singleFileSubtraceHandler;
|
this._singleFileSubtraceHandler = singleFileSubtraceHandler;
|
||||||
}
|
}
|
3
packages/sol-trace-based-tools-common/tslint.json
Normal file
3
packages/sol-trace-based-tools-common/tslint.json
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
{
|
||||||
|
"extends": ["@0x/tslint-config"]
|
||||||
|
}
|
6
packages/sol-trace/.npmignore
Normal file
6
packages/sol-trace/.npmignore
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
.*
|
||||||
|
yarn-error.log
|
||||||
|
/src/
|
||||||
|
/scripts/
|
||||||
|
tsconfig.json
|
||||||
|
/lib/src/monorepo_scripts/
|
12
packages/sol-trace/CHANGELOG.json
Normal file
12
packages/sol-trace/CHANGELOG.json
Normal file
@ -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
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
75
packages/sol-trace/README.md
Normal file
75
packages/sol-trace/README.md
Normal file
@ -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
|
||||||
|
```
|
52
packages/sol-trace/package.json
Normal file
52
packages/sol-trace/package.json
Normal file
@ -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"
|
||||||
|
}
|
||||||
|
}
|
7
packages/sol-trace/src/globals.d.ts
vendored
Normal file
7
packages/sol-trace/src/globals.d.ts
vendored
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
// tslint:disable:completed-docs
|
||||||
|
declare module '*.json' {
|
||||||
|
const json: any;
|
||||||
|
/* tslint:disable */
|
||||||
|
export default json;
|
||||||
|
/* tslint:enable */
|
||||||
|
}
|
24
packages/sol-trace/src/index.ts
Normal file
24
packages/sol-trace/src/index.ts
Normal file
@ -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';
|
@ -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 { stripHexPrefix } from 'ethereumjs-util';
|
||||||
import * as _ from 'lodash';
|
import * as _ from 'lodash';
|
||||||
import { getLogger, levels, Logger } from 'loglevel';
|
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.
|
* 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.
|
* It is used to report call stack traces whenever a revert occurs.
|
||||||
@ -35,7 +39,7 @@ export class RevertTraceSubprovider extends TraceCollectionSubprovider {
|
|||||||
};
|
};
|
||||||
super(defaultFromAddress, traceCollectionSubproviderConfig);
|
super(defaultFromAddress, traceCollectionSubproviderConfig);
|
||||||
this._artifactAdapter = artifactAdapter;
|
this._artifactAdapter = artifactAdapter;
|
||||||
this._logger = getLogger('sol-cov');
|
this._logger = getLogger('sol-trace');
|
||||||
this._logger.setLevel(isVerbose ? levels.TRACE : levels.ERROR);
|
this._logger.setLevel(isVerbose ? levels.TRACE : levels.ERROR);
|
||||||
}
|
}
|
||||||
// tslint:disable-next-line:no-unused-variable
|
// tslint:disable-next-line:no-unused-variable
|
8
packages/sol-trace/tsconfig.json
Normal file
8
packages/sol-trace/tsconfig.json
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
{
|
||||||
|
"extends": "../../tsconfig",
|
||||||
|
"compilerOptions": {
|
||||||
|
"outDir": "lib",
|
||||||
|
"rootDir": "."
|
||||||
|
},
|
||||||
|
"include": ["./src/**/*"]
|
||||||
|
}
|
3
packages/sol-trace/tslint.json
Normal file
3
packages/sol-trace/tslint.json
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
{
|
||||||
|
"extends": ["@0x/tslint-config"]
|
||||||
|
}
|
7
packages/sol-trace/typedoc-tsconfig.json
Normal file
7
packages/sol-trace/typedoc-tsconfig.json
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
{
|
||||||
|
"extends": "../../typedoc-tsconfig",
|
||||||
|
"compilerOptions": {
|
||||||
|
"outDir": "lib"
|
||||||
|
},
|
||||||
|
"include": ["./src/**/*"]
|
||||||
|
}
|
@ -1,12 +1,12 @@
|
|||||||
# Schemas
|
# 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
|
```bash
|
||||||
npm install @0xproject/json-schemas --save
|
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
|
```js
|
||||||
import {SchemaValidator, ValidatorResult, schemas} from '@0xproject/json-schemas';
|
import {SchemaValidator, ValidatorResult, schemas} from '@0xproject/json-schemas';
|
||||||
|
@ -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;
|
|
||||||
```
|
|
@ -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.
|
|
@ -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;
|
|
||||||
```
|
|
@ -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.
|
|
17
packages/website/md/docs/sol_coverage/installation.md
Normal file
17
packages/website/md/docs/sol_coverage/installation.md
Normal file
@ -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;
|
||||||
|
```
|
1
packages/website/md/docs/sol_coverage/introduction.md
Normal file
1
packages/website/md/docs/sol_coverage/introduction.md
Normal file
@ -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.
|
@ -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.
|
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.
|
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
|
```typescript
|
||||||
import { SolCompilerArtifactsAdapter } from '@0x/sol-cov';
|
import { SolCompilerArtifactsAdapter } from '@0x/sol-coverage';
|
||||||
const artifactsPath = 'src/artifacts';
|
const artifactsPath = 'src/artifacts';
|
||||||
const contractsPath = 'src/contracts';
|
const contractsPath = 'src/contracts';
|
||||||
const artifactsAdapter = new SolCompilerArtifactsAdapter(artifactsPath, contractsPath);
|
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.
|
If your project is using [Truffle](https://truffleframework.com/), we've written a `TruffleArtifactsAdapter`for you.
|
||||||
|
|
||||||
```typescript
|
```typescript
|
||||||
import { TruffleArtifactAdapter } from '@0x/sol-cov';
|
import { TruffleArtifactAdapter } from '@0x/sol-coverage';
|
||||||
const contractsPath = 'src/contracts';
|
const contractsPath = 'src/contracts';
|
||||||
const artifactAdapter = new TruffleArtifactAdapter(contractsDir);
|
const artifactAdapter = new TruffleArtifactAdapter(contractsDir);
|
||||||
```
|
```
|
||||||
@ -37,7 +37,7 @@ Look at the code of the two adapters above for examples.
|
|||||||
### Usage
|
### Usage
|
||||||
|
|
||||||
```typescript
|
```typescript
|
||||||
import { CoverageSubprovider } from '@0x/sol-cov';
|
import { CoverageSubprovider } from '@0x/sol-coverage';
|
||||||
import ProviderEngine = require('web3-provider-engine');
|
import ProviderEngine = require('web3-provider-engine');
|
||||||
|
|
||||||
const provider = new ProviderEngine();
|
const provider = new ProviderEngine();
|
17
packages/website/md/docs/sol_profiler/installation.md
Normal file
17
packages/website/md/docs/sol_profiler/installation.md
Normal file
@ -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;
|
||||||
|
```
|
1
packages/website/md/docs/sol_profiler/introduction.md
Normal file
1
packages/website/md/docs/sol_profiler/introduction.md
Normal file
@ -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.
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user