From a6f72de09d7b2c9738b78d2097baa9906838fbe9 Mon Sep 17 00:00:00 2001 From: Leonid Logvinov Date: Tue, 8 May 2018 15:42:07 +0200 Subject: Rename deployer to sol-compiler --- packages/sol-cov/package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'packages/sol-cov') diff --git a/packages/sol-cov/package.json b/packages/sol-cov/package.json index 425b561a6..68937f507 100644 --- a/packages/sol-cov/package.json +++ b/packages/sol-cov/package.json @@ -14,7 +14,7 @@ "run_mocha": "mocha lib/test/**/*_test.js --exit", "clean": "shx rm -rf lib scripts", "build": "copyfiles 'test/fixtures/**/*' ./lib && tsc && copyfiles -u 3 './lib/src/monorepo_scripts/**/*' ./scripts", - "compile_test": "node ../deployer/lib/src/cli.js compile", + "compile_test": "node ../sol-compiler/lib/src/cli.js compile", "manual:postpublish": "yarn build; node ./scripts/postpublish.js", "docs:stage": "yarn build && node ./scripts/stage_docs.js", "docs:json": "typedoc --excludePrivate --excludeExternals --target ES5 --json $JSON_FILE_PATH $PROJECT_FILES", @@ -54,7 +54,7 @@ "solidity-parser-antlr": "^0.2.8" }, "devDependencies": { - "@0xproject/deployer": "^0.3.5", + "@0xproject/sol-compiler": "^0.3.5", "@0xproject/monorepo-scripts": "^0.1.19", "@0xproject/tslint-config": "^0.4.17", "@types/istanbul": "^0.4.29", -- cgit v1.2.3 From 75d24dea0e10d098d3833488a420498410c22991 Mon Sep 17 00:00:00 2001 From: Leonid Logvinov Date: Tue, 8 May 2018 16:02:04 +0200 Subject: Fix linter issues --- packages/sol-cov/package.json | 5 ++--- packages/sol-cov/src/collect_contract_data.ts | 2 +- packages/sol-cov/src/coverage_manager.ts | 11 +++++------ packages/sol-cov/src/coverage_subprovider.ts | 10 ++-------- packages/sol-cov/test/collect_contracts_data_test.ts | 3 +-- 5 files changed, 11 insertions(+), 20 deletions(-) (limited to 'packages/sol-cov') diff --git a/packages/sol-cov/package.json b/packages/sol-cov/package.json index 68937f507..f57a317de 100644 --- a/packages/sol-cov/package.json +++ b/packages/sol-cov/package.json @@ -6,7 +6,7 @@ "types": "lib/src/index.d.ts", "scripts": { "build:watch": "tsc -w", - "lint": "tslint --project . 'src/**/*.ts'", + "lint": "tslint --project .", "test": "run-s clean build compile_test run_mocha", "test:coverage": "nyc npm run test --all && yarn coverage:report:lcov", "coverage:report:lcov": "nyc report --reporter=text-lcov > coverage/lcov.info", @@ -54,10 +54,9 @@ "solidity-parser-antlr": "^0.2.8" }, "devDependencies": { - "@0xproject/sol-compiler": "^0.3.5", "@0xproject/monorepo-scripts": "^0.1.19", "@0xproject/tslint-config": "^0.4.17", - "@types/istanbul": "^0.4.29", + "@types/istanbul": "^0.4.30", "@types/mocha": "^2.2.42", "@types/node": "^8.0.53", "chai": "^4.0.1", diff --git a/packages/sol-cov/src/collect_contract_data.ts b/packages/sol-cov/src/collect_contract_data.ts index bb20e98be..2c2a12835 100644 --- a/packages/sol-cov/src/collect_contract_data.ts +++ b/packages/sol-cov/src/collect_contract_data.ts @@ -5,7 +5,7 @@ import * as path from 'path'; import { ContractData } from './types'; -export const collectContractsData = (artifactsPath: string, sourcesPath: string, networkId: number) => { +export const collectContractsData = (artifactsPath: string, sourcesPath: string) => { const artifactsGlob = `${artifactsPath}/**/*.json`; const artifactFileNames = glob.sync(artifactsGlob, { absolute: true }); const contractsData: ContractData[] = []; diff --git a/packages/sol-cov/src/coverage_manager.ts b/packages/sol-cov/src/coverage_manager.ts index 6a57d07c9..bf580025b 100644 --- a/packages/sol-cov/src/coverage_manager.ts +++ b/packages/sol-cov/src/coverage_manager.ts @@ -1,3 +1,4 @@ +import { addHexPrefix } from 'ethereumjs-util'; import * as fs from 'fs'; import { Collector } from 'istanbul'; import * as _ from 'lodash'; @@ -36,12 +37,11 @@ export class CoverageManager { constructor( artifactsPath: string, sourcesPath: string, - networkId: number, getContractCodeAsync: (address: string) => Promise, ) { this._getContractCodeAsync = getContractCodeAsync; this._sourcesPath = sourcesPath; - this._contractsData = collectContractsData(artifactsPath, this._sourcesPath, networkId); + this._contractsData = collectContractsData(artifactsPath, this._sourcesPath); } public appendTraceInfo(traceInfo: TraceInfo): void { this._traceInfos.push(traceInfo); @@ -134,7 +134,7 @@ export class CoverageManager { if (traceInfo.address !== constants.NEW_CONTRACT) { // Runtime transaction let runtimeBytecode = (traceInfo as TraceInfoExistingContract).runtimeBytecode; - runtimeBytecode = utils.removeHexPrefix(runtimeBytecode); + runtimeBytecode = addHexPrefix(runtimeBytecode); const contractData = _.find(this._contractsData, { runtimeBytecode }) as ContractData; if (_.isUndefined(contractData)) { throw new Error(`Transaction to an unknown address: ${traceInfo.address}`); @@ -159,7 +159,7 @@ export class CoverageManager { } else { // Contract creation transaction let bytecode = (traceInfo as TraceInfoNewContract).bytecode; - bytecode = utils.removeHexPrefix(bytecode); + bytecode = addHexPrefix(bytecode); const contractData = _.find(this._contractsData, contractDataCandidate => bytecode.startsWith(contractDataCandidate.bytecode), ) as ContractData; @@ -185,7 +185,6 @@ export class CoverageManager { } } } - // TODO: Remove any cast as soon as https://github.com/DefinitelyTyped/DefinitelyTyped/pull/24233 gets merged - return (collector as any).getFinalCoverage(); + return collector.getFinalCoverage(); } } diff --git a/packages/sol-cov/src/coverage_subprovider.ts b/packages/sol-cov/src/coverage_subprovider.ts index 6504d5a46..b08291afb 100644 --- a/packages/sol-cov/src/coverage_subprovider.ts +++ b/packages/sol-cov/src/coverage_subprovider.ts @@ -28,19 +28,13 @@ export class CoverageSubprovider extends Subprovider { * Instantiates a CoverageSubprovider instance * @param artifactsPath Path to the smart contract artifacts * @param sourcesPath Path to the smart contract source files - * @param networkId network id * @param defaultFromAddress default from address to use when sending transactions */ - constructor(artifactsPath: string, sourcesPath: string, networkId: number, defaultFromAddress: string) { + constructor(artifactsPath: string, sourcesPath: string, defaultFromAddress: string) { super(); this._lock = new Lock(); this._defaultFromAddress = defaultFromAddress; - this._coverageManager = new CoverageManager( - artifactsPath, - sourcesPath, - networkId, - this._getContractCodeAsync.bind(this), - ); + this._coverageManager = new CoverageManager(artifactsPath, sourcesPath, this._getContractCodeAsync.bind(this)); } /** * Write the test coverage results to a file in Istanbul format. diff --git a/packages/sol-cov/test/collect_contracts_data_test.ts b/packages/sol-cov/test/collect_contracts_data_test.ts index 943a4a878..c7c1dfe32 100644 --- a/packages/sol-cov/test/collect_contracts_data_test.ts +++ b/packages/sol-cov/test/collect_contracts_data_test.ts @@ -12,8 +12,7 @@ describe('Collect contracts data', () => { it('correctly collects contracts data', () => { const artifactsPath = path.resolve(__dirname, 'fixtures/artifacts'); const sourcesPath = path.resolve(__dirname, 'fixtures/contracts'); - const networkId = 50; - const contractsData = collectContractsData(artifactsPath, sourcesPath, networkId); + const contractsData = collectContractsData(artifactsPath, sourcesPath); _.forEach(contractsData, contractData => { expect(contractData).to.have.keys([ 'sourceCodes', -- cgit v1.2.3 From f854f3ee2bd74bbb61ed465099168b4d391f92c8 Mon Sep 17 00:00:00 2001 From: Leonid Logvinov Date: Thu, 10 May 2018 15:20:00 +0200 Subject: Remove unused deployer docs configs --- packages/sol-cov/src/coverage_manager.ts | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'packages/sol-cov') diff --git a/packages/sol-cov/src/coverage_manager.ts b/packages/sol-cov/src/coverage_manager.ts index bf580025b..f50f010b9 100644 --- a/packages/sol-cov/src/coverage_manager.ts +++ b/packages/sol-cov/src/coverage_manager.ts @@ -48,9 +48,7 @@ export class CoverageManager { } public async writeCoverageAsync(): Promise { const finalCoverage = await this._computeCoverageAsync(); - const jsonReplacer: null = null; - const numberOfJsonSpaces = 4; - const stringifiedCoverage = JSON.stringify(finalCoverage, jsonReplacer, numberOfJsonSpaces); + const stringifiedCoverage = JSON.stringify(finalCoverage, null, '\t'); fs.writeFileSync('coverage/coverage.json', stringifiedCoverage); } private _getSingleFileCoverageForTrace( -- cgit v1.2.3