Merge pull request #1492 from 0xProject/feature/sol-cov-sol-profiler-sol-trace-divorce
Refactor out sol-cov, sol-profiler and sol-trace into their separate packages
This commit is contained in:
@@ -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:
|
||||
@@ -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-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-cov-{{ .Environment.CIRCLE_SHA1 }}
|
||||
key: coverage-sol-tracing-utils-{{ .Environment.CIRCLE_SHA1 }}
|
||||
paths:
|
||||
- ~/repo/packages/sol-cov/coverage/lcov.info
|
||||
- ~/repo/packages/sol-tracing-utils/coverage/lcov.info
|
||||
- save_cache:
|
||||
key: coverage-sol-doc-{{ .Environment.CIRCLE_SHA1 }}
|
||||
paths:
|
||||
@@ -335,7 +335,7 @@ jobs:
|
||||
- coverage-sol-compiler-{{ .Environment.CIRCLE_SHA1 }}
|
||||
- restore_cache:
|
||||
keys:
|
||||
- coverage-sol-cov-{{ .Environment.CIRCLE_SHA1 }}
|
||||
- coverage-sol-tracing-utils-{{ .Environment.CIRCLE_SHA1 }}
|
||||
- restore_cache:
|
||||
keys:
|
||||
- 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: ['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-tracing-utils: ['packages/sol-tracing-utils']
|
||||
utils: ['packages/utils']
|
||||
tslint-config: ['packages/tslint-config']
|
||||
asset-buyer: ['packages/asset-buyer']
|
||||
|
2
.gitignore
vendored
2
.gitignore
vendored
@@ -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-tracing-utils/test/fixtures/artifacts/
|
||||
packages/metacoin/artifacts/
|
||||
|
||||
# generated contract wrappers
|
||||
|
@@ -27,7 +27,7 @@ lib
|
||||
/packages/dev-tools-pages/ts/**/data.json
|
||||
package.json
|
||||
scripts/postpublish_utils.js
|
||||
packages/sol-cov/test/fixtures/artifacts
|
||||
packages/sol-coverage/test/fixtures/artifacts
|
||||
.pytest_cache
|
||||
.mypy_cache
|
||||
.tox
|
||||
|
@@ -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-tracing-utils/ @LogvinovLeon
|
||||
packages/sol-resolver/ @LogvinovLeon
|
||||
packages/subproviders/ @fabioberger @dekz
|
||||
packages/verdaccio/ @albrow
|
||||
|
@@ -57,7 +57,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/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/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 |
|
||||
|
@@ -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
|
||||
|
@@ -37,7 +37,6 @@
|
||||
"@0x/contracts-test-utils": "^1.0.3",
|
||||
"@0x/dev-utils": "^1.0.22",
|
||||
"@0x/sol-compiler": "^2.0.0",
|
||||
"@0x/sol-cov": "^2.1.17",
|
||||
"@0x/subproviders": "^2.1.9",
|
||||
"@0x/tslint-config": "^2.0.0",
|
||||
"@types/bn.js": "^4.11.0",
|
||||
|
@@ -49,7 +49,6 @@
|
||||
"@0x/contracts-test-utils": "^1.0.3",
|
||||
"@0x/dev-utils": "^1.0.22",
|
||||
"@0x/sol-compiler": "^2.0.0",
|
||||
"@0x/sol-cov": "^2.1.17",
|
||||
"@0x/subproviders": "^2.1.9",
|
||||
"@0x/tslint-config": "^2.0.0",
|
||||
"@types/bn.js": "^4.11.0",
|
||||
|
@@ -48,7 +48,6 @@
|
||||
"@0x/contracts-test-utils": "^1.0.3",
|
||||
"@0x/dev-utils": "^1.0.22",
|
||||
"@0x/sol-compiler": "^2.0.0",
|
||||
"@0x/sol-cov": "^2.1.17",
|
||||
"@0x/subproviders": "^2.1.9",
|
||||
"@0x/tslint-config": "^2.0.0",
|
||||
"@types/bn.js": "^4.11.0",
|
||||
|
@@ -48,7 +48,6 @@
|
||||
"@0x/contracts-test-utils": "^1.0.3",
|
||||
"@0x/dev-utils": "^1.0.22",
|
||||
"@0x/sol-compiler": "^2.0.0",
|
||||
"@0x/sol-cov": "^2.1.17",
|
||||
"@0x/subproviders": "^2.1.9",
|
||||
"@0x/tslint-config": "^2.0.0",
|
||||
"@types/bn.js": "^4.11.0",
|
||||
|
@@ -47,7 +47,6 @@
|
||||
"@0x/abi-gen": "^1.0.20",
|
||||
"@0x/dev-utils": "^1.0.22",
|
||||
"@0x/sol-compiler": "^2.0.0",
|
||||
"@0x/sol-cov": "^2.1.17",
|
||||
"@0x/subproviders": "^2.1.9",
|
||||
"@0x/tslint-config": "^2.0.0",
|
||||
"@types/bn.js": "^4.11.0",
|
||||
|
@@ -40,11 +40,13 @@
|
||||
"typescript": "3.0.1"
|
||||
},
|
||||
"dependencies": {
|
||||
"@0x/sol-coverage": "^1.0.0",
|
||||
"@0x/sol-profiler": "^1.0.0",
|
||||
"@0x/sol-trace": "^1.0.0",
|
||||
"@0x/abi-gen": "^1.0.20",
|
||||
"@0x/dev-utils": "^1.0.22",
|
||||
"@0x/order-utils": "^3.1.0",
|
||||
"@0x/sol-compiler": "^2.0.0",
|
||||
"@0x/sol-cov": "^2.1.17",
|
||||
"@0x/subproviders": "^2.1.9",
|
||||
"@0x/tslint-config": "^2.0.0",
|
||||
"@0x/types": "^1.5.0",
|
||||
|
@@ -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;
|
||||
|
@@ -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;
|
||||
|
@@ -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;
|
||||
|
@@ -48,7 +48,6 @@
|
||||
"@0x/contracts-test-utils": "^1.0.3",
|
||||
"@0x/dev-utils": "^1.0.22",
|
||||
"@0x/sol-compiler": "^2.0.0",
|
||||
"@0x/sol-cov": "^2.1.17",
|
||||
"@0x/subproviders": "^2.1.9",
|
||||
"@0x/tslint-config": "^2.0.0",
|
||||
"@types/bn.js": "^4.11.0",
|
||||
|
@@ -48,7 +48,6 @@
|
||||
"@0x/contracts-test-utils": "^1.0.3",
|
||||
"@0x/dev-utils": "^1.0.22",
|
||||
"@0x/sol-compiler": "^2.0.0",
|
||||
"@0x/sol-cov": "^2.1.17",
|
||||
"@0x/subproviders": "^2.1.9",
|
||||
"@0x/tslint-config": "^2.0.0",
|
||||
"@types/bn.js": "^4.11.0",
|
||||
|
@@ -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": [
|
||||
|
@@ -78,7 +78,7 @@ const Cov: React.StatelessComponent<{}> = () => (
|
||||
</ContentBlock>
|
||||
<ContentBlock title="Installation">
|
||||
<Breakout>
|
||||
<Code>npm install @0x/sol-cov --save</Code>
|
||||
<Code>npm install @0x/sol-coverage --save</Code>
|
||||
</Breakout>
|
||||
|
||||
<p>
|
||||
@@ -124,7 +124,7 @@ const artifactAdapter = new YourCustomArtifactsAdapter(...);`}
|
||||
<Breakout>
|
||||
<Code language="javascript">
|
||||
{`import { ProviderEngine, RpcSubprovider } from 'web3-provider-engine';
|
||||
import { RevertTraceSubprovider } from '@0x/sol-cov';
|
||||
import { RevertTraceSubprovider } from '@0x/sol-coverage';
|
||||
|
||||
const defaultFromAddress = "..."; // Some ethereum address with test funds
|
||||
const revertTraceSubprovider = new RevertTraceSubprovider(artifactAdapter, defaultFromAddress);
|
||||
|
@@ -121,7 +121,7 @@ const artifactAdapter = new YourCustomArtifactsAdapter(...);`}
|
||||
<Breakout>
|
||||
<Code language="javascript">
|
||||
{`import { ProviderEngine, RpcSubprovider } from 'web3-provider-engine';
|
||||
import { RevertTraceSubprovider } from '@0x/sol-cov';
|
||||
import { RevertTraceSubprovider } from '@0x/sol-coverage';
|
||||
|
||||
const defaultFromAddress = "..."; // Some ethereum address with test funds
|
||||
const revertTraceSubprovider = new RevertTraceSubprovider(artifactAdapter, defaultFromAddress);
|
||||
|
@@ -91,7 +91,7 @@ const artifactAdapter = new YourCustomArtifactsAdapter(...);`}
|
||||
<Breakout>
|
||||
<Code language="javascript">
|
||||
{`import { ProviderEngine, RpcSubprovider } from 'web3-provider-engine';
|
||||
import { RevertTraceSubprovider } from '@0x/sol-cov';
|
||||
import { RevertTraceSubprovider } from '@0x/sol-coverage';
|
||||
|
||||
const defaultFromAddress = "..."; // Some ethereum address with test funds
|
||||
const revertTraceSubprovider = new RevertTraceSubprovider(artifactAdapter, defaultFromAddress);
|
||||
|
@@ -32,7 +32,9 @@
|
||||
"@0x/abi-gen": "^1.0.20",
|
||||
"@0x/abi-gen-templates": "^1.0.1",
|
||||
"@0x/base-contract": "^3.0.11",
|
||||
"@0x/sol-cov": "^2.1.17",
|
||||
"@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",
|
||||
|
@@ -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';
|
||||
|
@@ -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';
|
||||
|
@@ -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 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.
|
||||
// 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<Promise<void>> = [];
|
||||
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 = 15;
|
||||
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<Promise<void>> = [];
|
||||
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);
|
||||
|
@@ -1,6 +0,0 @@
|
||||
{
|
||||
"extends": ["@0x/tslint-config"],
|
||||
"rules": {
|
||||
"completed-docs": false
|
||||
}
|
||||
}
|
11
packages/sol-coverage/CHANGELOG.json
Normal file
11
packages/sol-coverage/CHANGELOG.json
Normal file
@@ -0,0 +1,11 @@
|
||||
[
|
||||
{
|
||||
"version": "1.0.0",
|
||||
"changes": [
|
||||
{
|
||||
"note": "Initial release as a separate package. For historical entries see @0x/sol-tracing-utils",
|
||||
"pr": 1492
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
@@ -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
|
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-tracing-utils": "^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 {
|
||||
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-tracing-utils';
|
||||
import * as _ from 'lodash';
|
||||
|
||||
/**
|
||||
* 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-tracing-utils';
|
||||
|
||||
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/
|
11
packages/sol-profiler/CHANGELOG.json
Normal file
11
packages/sol-profiler/CHANGELOG.json
Normal file
@@ -0,0 +1,11 @@
|
||||
[
|
||||
{
|
||||
"version": "1.0.0",
|
||||
"changes": [
|
||||
{
|
||||
"note": "Initial release as a separate package. For historical entries see @0x/sol-tracing-utils",
|
||||
"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-tracing-utils": "^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 { 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-tracing-utils';
|
||||
|
||||
// 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,
|
@@ -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-tracing-utils';
|
||||
|
||||
/**
|
||||
* 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/.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/
|
11
packages/sol-trace/CHANGELOG.json
Normal file
11
packages/sol-trace/CHANGELOG.json
Normal file
@@ -0,0 +1,11 @@
|
||||
[
|
||||
{
|
||||
"version": "1.0.0",
|
||||
"changes": [
|
||||
{
|
||||
"note": "Initial release as a separate package. For historical entries see @0x/sol-tracing-utils",
|
||||
"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 a stack trace when a revert is encountered.
|
||||
|
||||
### 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-tracing-utils": "^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-tracing-utils';
|
||||
|
||||
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-tracing-utils';
|
||||
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
|
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/**/*"]
|
||||
}
|
6
packages/sol-tracing-utils/.npmignore
Normal file
6
packages/sol-tracing-utils/.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 shared parts of the codebase",
|
||||
"pr": 1492
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"timestamp": 1547040760,
|
||||
"version": "2.1.17",
|
61
packages/sol-tracing-utils/README.md
Normal file
61
packages/sol-tracing-utils/README.md
Normal file
@@ -0,0 +1,61 @@
|
||||
## @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-tracing-utils
|
||||
```
|
||||
|
||||
## 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-tracing-utils yarn build
|
||||
```
|
||||
|
||||
Or continuously rebuild on change:
|
||||
|
||||
```bash
|
||||
PKG=@0x/sol-tracing-utils 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-tracing-utils",
|
||||
"version": "2.1.17",
|
||||
"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-tracing-utils/README.md",
|
||||
"dependencies": {
|
||||
"@0x/dev-utils": "^1.0.22",
|
||||
"@0x/sol-compiler": "^2.0.0",
|
@@ -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`,
|
||||
);
|
||||
}
|
||||
}
|
@@ -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])) {
|
7
packages/sol-tracing-utils/src/globals.d.ts
vendored
Normal file
7
packages/sol-tracing-utils/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-tracing-utils/src/index.ts
Normal file
39
packages/sol-tracing-utils/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 { 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 {
|
@@ -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 map 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,
|
@@ -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 {
|
@@ -51,7 +51,7 @@ export class TraceCollector {
|
||||
singleFileSubtraceHandler: SingleFileSubtraceHandler,
|
||||
) {
|
||||
this._artifactAdapter = artifactAdapter;
|
||||
this._logger = getLogger('sol-cov');
|
||||
this._logger = getLogger('sol-tracing-utils');
|
||||
this._logger.setLevel(isVerbose ? levels.TRACE : levels.ERROR);
|
||||
this._singleFileSubtraceHandler = singleFileSubtraceHandler;
|
||||
}
|
3
packages/sol-tracing-utils/tslint.json
Normal file
3
packages/sol-tracing-utils/tslint.json
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"extends": ["@0x/tslint-config"]
|
||||
}
|
@@ -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';
|
||||
|
@@ -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;
|
||||
```
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user