From ba57c34adb0348af61210aa0bbee3e734b477f58 Mon Sep 17 00:00:00 2001 From: Leonid Logvinov Date: Fri, 9 Feb 2018 11:49:01 +0100 Subject: Use system-independent rm command --- packages/deployer/package.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'packages/deployer') diff --git a/packages/deployer/package.json b/packages/deployer/package.json index 6564d89eb..c0a4f369b 100644 --- a/packages/deployer/package.json +++ b/packages/deployer/package.json @@ -9,7 +9,7 @@ "build": "yarn clean && copyfiles 'test/fixtures/contracts/**/*' src/solc/solc_bin/* ./lib && tsc", "test": "npm run build; mocha lib/test/*_test.js", "compile": "npm run build; node lib/src/cli.js compile", - "clean": "rm -rf ./lib", + "clean": "shx rm -rf ./lib", "migrate": "npm run build; node lib/src/cli.js migrate", "lint": "tslint --project . 'src/**/*.ts' 'test/**/*.ts'", "test:circleci": "yarn test" @@ -29,6 +29,7 @@ "homepage": "https://github.com/0xProject/0x.js/packages/deployer/README.md", "devDependencies": { "copyfiles": "^1.2.0", + "shx": "^0.2.2", "types-bn": "^0.0.1", "typescript": "2.7.1", "web3-typescript-typings": "^0.9.9" -- cgit v1.2.3 From f62762bd0e5d3be443e412df1829c2d89ef4640e Mon Sep 17 00:00:00 2001 From: Amir Bandeali Date: Wed, 14 Feb 2018 14:03:12 -0800 Subject: Add contracts to compiler options --- packages/deployer/src/cli.ts | 21 +++++++++++++++++++++ packages/deployer/src/compiler.ts | 8 ++++++-- packages/deployer/src/utils/types.ts | 1 + 3 files changed, 28 insertions(+), 2 deletions(-) (limited to 'packages/deployer') diff --git a/packages/deployer/src/cli.ts b/packages/deployer/src/cli.ts index 0fe412bdf..5e0f2145b 100644 --- a/packages/deployer/src/cli.ts +++ b/packages/deployer/src/cli.ts @@ -14,6 +14,7 @@ const DEFAULT_ARTIFACTS_DIR = path.resolve('artifacts'); const DEFAULT_NETWORK_ID = 50; const DEFAULT_JSONRPC_PORT = 8545; const DEFAULT_GAS_PRICE = (10 ** 9 * 2).toString(); +const DEFAULT_COMPILE_CONTRACTS = '*'; /** * Compiles all contracts with options passed in through CLI. @@ -25,6 +26,7 @@ async function onCompileCommand(argv: CliOptions): Promise { networkId: argv.networkId, optimizerEnabled: argv.shouldOptimize ? 1 : 0, artifactsDir: argv.artifactsDir, + contractsToCompile: generateContractsToCompileSet(argv.contracts), }; await commands.compileAsync(opts); } @@ -43,6 +45,7 @@ async function onMigrateCommand(argv: CliOptions): Promise { networkId, optimizerEnabled: argv.shouldOptimize ? 1 : 0, artifactsDir: argv.artifactsDir, + contractsToCompile: generateContractsToCompileSet(argv.contracts), }; await commands.compileAsync(compilerOpts); @@ -72,6 +75,7 @@ async function onDeployCommand(argv: CliOptions): Promise { networkId, optimizerEnabled: argv.shouldOptimize ? 1 : 0, artifactsDir: argv.artifactsDir, + contractsToCompile: generateContractsToCompileSet(argv.contracts), }; await commands.compileAsync(compilerOpts); @@ -89,6 +93,18 @@ async function onDeployCommand(argv: CliOptions): Promise { const deployerArgs = deployerArgsString.split(','); await commands.deployAsync(argv.contract, deployerArgs, deployerOpts); } +/** + * Creates a set of contracts to compile. + * @param contracts Comma separated list of contracts to compile + */ +function generateContractsToCompileSet(contracts: string): Set { + const contractsToCompile = new Set(); + const contractsArray = contracts.split(','); + _.forEach(contracts, contractName => { + contractsToCompile.add(contractName); + }); + return contractsToCompile; +} /** * Provides extra required options for deploy command. * @param yargsInstance yargs instance provided in builder function callback. @@ -144,6 +160,11 @@ function deployCommandBuilder(yargsInstance: any) { type: 'string', description: 'account to use for deploying contracts', }) + .option('contracts', { + type: 'string', + default: DEFAULT_COMPILE_CONTRACTS, + description: 'comma separated list of contracts to compile', + }) .command('compile', 'compile contracts', identityCommandBuilder, onCompileCommand) .command( 'migrate', diff --git a/packages/deployer/src/compiler.ts b/packages/deployer/src/compiler.ts index 63db6c865..4e5518d0e 100644 --- a/packages/deployer/src/compiler.ts +++ b/packages/deployer/src/compiler.ts @@ -17,6 +17,7 @@ import { import { utils } from './utils/utils'; const SOLIDITY_FILE_EXTENSION = '.sol'; +const ALL_CONTRACTS_IDENTIFIER = '*'; export class Compiler { private _contractsDir: string; @@ -25,6 +26,7 @@ export class Compiler { private _artifactsDir: string; private _contractSourcesIfExists?: ContractSources; private _solcErrors: Set; + private _contractsToCompile: Set; /** * Recursively retrieves Solidity source code from directory. * @param dirPath Directory to search. @@ -106,6 +108,7 @@ export class Compiler { this._optimizerEnabled = opts.optimizerEnabled; this._artifactsDir = opts.artifactsDir; this._solcErrors = new Set(); + this._contractsToCompile = opts.contractsToCompile; } /** * Compiles all Solidity files found in contractsDir and writes JSON artifacts to artifactsDir. @@ -150,9 +153,10 @@ export class Compiler { oldNetworks = currentArtifact.networks; const oldNetwork: ContractData = oldNetworks[this._networkId]; shouldCompile = - _.isUndefined(oldNetwork) || + (_.isUndefined(oldNetwork) || oldNetwork.keccak256 !== sourceHash || - oldNetwork.optimizer_enabled !== this._optimizerEnabled; + oldNetwork.optimizer_enabled !== this._optimizerEnabled) && + (this._contractsToCompile.has(ALL_CONTRACTS_IDENTIFIER) || this._contractsToCompile.has(contractName)); } catch (err) { shouldCompile = true; } diff --git a/packages/deployer/src/utils/types.ts b/packages/deployer/src/utils/types.ts index e054b9cc2..c8bb1b9ca 100644 --- a/packages/deployer/src/utils/types.ts +++ b/packages/deployer/src/utils/types.ts @@ -50,6 +50,7 @@ export interface CompilerOptions { networkId: number; optimizerEnabled: number; artifactsDir: string; + contractsToCompile: Set; } export interface DeployerOptions { -- cgit v1.2.3 From af333b1838628fa0f8d393b19818224c15427106 Mon Sep 17 00:00:00 2001 From: Amir Bandeali Date: Wed, 14 Feb 2018 13:54:04 -0800 Subject: Fix checks, add contract list to compile script in package.json --- packages/deployer/src/cli.ts | 2 +- packages/deployer/src/compiler.ts | 5 +++-- packages/deployer/test/deploy_test.ts | 1 + packages/deployer/test/util/constants.ts | 1 + 4 files changed, 6 insertions(+), 3 deletions(-) (limited to 'packages/deployer') diff --git a/packages/deployer/src/cli.ts b/packages/deployer/src/cli.ts index 5e0f2145b..bc1ec8421 100644 --- a/packages/deployer/src/cli.ts +++ b/packages/deployer/src/cli.ts @@ -100,7 +100,7 @@ async function onDeployCommand(argv: CliOptions): Promise { function generateContractsToCompileSet(contracts: string): Set { const contractsToCompile = new Set(); const contractsArray = contracts.split(','); - _.forEach(contracts, contractName => { + _.forEach(contractsArray, contractName => { contractsToCompile.add(contractName); }); return contractsToCompile; diff --git a/packages/deployer/src/compiler.ts b/packages/deployer/src/compiler.ts index 4e5518d0e..beeda1260 100644 --- a/packages/deployer/src/compiler.ts +++ b/packages/deployer/src/compiler.ts @@ -139,6 +139,7 @@ export class Compiler { const contractName = path.basename(contractBaseName, SOLIDITY_FILE_EXTENSION); const currentArtifactPath = `${this._artifactsDir}/${contractName}.json`; const sourceHash = `0x${ethUtil.sha3(source).toString('hex')}`; + const isContractSpecified = this._contractsToCompile.has(ALL_CONTRACTS_IDENTIFIER) || this._contractsToCompile.has(contractName); let currentArtifactString: string; let currentArtifact: ContractArtifact; @@ -156,9 +157,9 @@ export class Compiler { (_.isUndefined(oldNetwork) || oldNetwork.keccak256 !== sourceHash || oldNetwork.optimizer_enabled !== this._optimizerEnabled) && - (this._contractsToCompile.has(ALL_CONTRACTS_IDENTIFIER) || this._contractsToCompile.has(contractName)); + isContractSpecified; } catch (err) { - shouldCompile = true; + shouldCompile = isContractSpecified; } if (!shouldCompile) { diff --git a/packages/deployer/test/deploy_test.ts b/packages/deployer/test/deploy_test.ts index 5fe2ffbd7..775a40cf6 100644 --- a/packages/deployer/test/deploy_test.ts +++ b/packages/deployer/test/deploy_test.ts @@ -18,6 +18,7 @@ const compilerOpts: CompilerOptions = { contractsDir, networkId: constants.networkId, optimizerEnabled: constants.optimizerEnabled, + contractsToCompile: new Set(constants.contractsToCompile), }; const compiler = new Compiler(compilerOpts); const deployerOpts = { diff --git a/packages/deployer/test/util/constants.ts b/packages/deployer/test/util/constants.ts index d52076607..223bfed27 100644 --- a/packages/deployer/test/util/constants.ts +++ b/packages/deployer/test/util/constants.ts @@ -8,4 +8,5 @@ export const constants = { timeoutMs: 20000, zrxTokenAddress: '0xe41d2489571d322189246dafa5ebde1f4699f498', tokenTransferProxyAddress: '0x8da0d80f5007ef1e431dd2127178d224e32c2ef4', + contractsToCompile: '*', }; -- cgit v1.2.3 From db52ed994111dabe13593280c46afc3bd5f7574e Mon Sep 17 00:00:00 2001 From: Amir Bandeali Date: Wed, 14 Feb 2018 14:06:00 -0800 Subject: Run prettier --- packages/deployer/src/compiler.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'packages/deployer') diff --git a/packages/deployer/src/compiler.ts b/packages/deployer/src/compiler.ts index beeda1260..3ff41139e 100644 --- a/packages/deployer/src/compiler.ts +++ b/packages/deployer/src/compiler.ts @@ -139,7 +139,8 @@ export class Compiler { const contractName = path.basename(contractBaseName, SOLIDITY_FILE_EXTENSION); const currentArtifactPath = `${this._artifactsDir}/${contractName}.json`; const sourceHash = `0x${ethUtil.sha3(source).toString('hex')}`; - const isContractSpecified = this._contractsToCompile.has(ALL_CONTRACTS_IDENTIFIER) || this._contractsToCompile.has(contractName); + const isContractSpecified = + this._contractsToCompile.has(ALL_CONTRACTS_IDENTIFIER) || this._contractsToCompile.has(contractName); let currentArtifactString: string; let currentArtifact: ContractArtifact; @@ -155,8 +156,8 @@ export class Compiler { const oldNetwork: ContractData = oldNetworks[this._networkId]; shouldCompile = (_.isUndefined(oldNetwork) || - oldNetwork.keccak256 !== sourceHash || - oldNetwork.optimizer_enabled !== this._optimizerEnabled) && + oldNetwork.keccak256 !== sourceHash || + oldNetwork.optimizer_enabled !== this._optimizerEnabled) && isContractSpecified; } catch (err) { shouldCompile = isContractSpecified; -- cgit v1.2.3 From 003e5da00df49bc192112e7368e4478731fea82f Mon Sep 17 00:00:00 2001 From: Amir Bandeali Date: Wed, 14 Feb 2018 16:04:38 -0800 Subject: Update CHANGELOG --- packages/deployer/CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'packages/deployer') diff --git a/packages/deployer/CHANGELOG.md b/packages/deployer/CHANGELOG.md index ad8c64538..a33158ea0 100644 --- a/packages/deployer/CHANGELOG.md +++ b/packages/deployer/CHANGELOG.md @@ -1,5 +1,9 @@ # CHANGELOG +## v0.0.10 - _??_ + + * Add the ability to pass in specific contracts to compile in CLI (#400) + ## v0.0.8 - _February 9, 2018_ * Fix publishing issue where .npmignore was not properly excluding undesired content (#389) -- cgit v1.2.3 From 060b02eaed2c7e2946286897b79ccfe828efc95d Mon Sep 17 00:00:00 2001 From: Amir Bandeali Date: Thu, 15 Feb 2018 10:20:03 -0800 Subject: Rename variables --- packages/deployer/src/cli.ts | 18 +++++++++--------- packages/deployer/src/compiler.ts | 6 +++--- packages/deployer/src/utils/types.ts | 2 +- packages/deployer/test/deploy_test.ts | 2 +- packages/deployer/test/util/constants.ts | 2 +- 5 files changed, 15 insertions(+), 15 deletions(-) (limited to 'packages/deployer') diff --git a/packages/deployer/src/cli.ts b/packages/deployer/src/cli.ts index bc1ec8421..3c6d042c0 100644 --- a/packages/deployer/src/cli.ts +++ b/packages/deployer/src/cli.ts @@ -14,7 +14,7 @@ const DEFAULT_ARTIFACTS_DIR = path.resolve('artifacts'); const DEFAULT_NETWORK_ID = 50; const DEFAULT_JSONRPC_PORT = 8545; const DEFAULT_GAS_PRICE = (10 ** 9 * 2).toString(); -const DEFAULT_COMPILE_CONTRACTS = '*'; +const DEFAULT_CONTRACTS_LIST = '*'; /** * Compiles all contracts with options passed in through CLI. @@ -26,7 +26,7 @@ async function onCompileCommand(argv: CliOptions): Promise { networkId: argv.networkId, optimizerEnabled: argv.shouldOptimize ? 1 : 0, artifactsDir: argv.artifactsDir, - contractsToCompile: generateContractsToCompileSet(argv.contracts), + specifiedContracts: getContractsSetFromList(argv.contracts), }; await commands.compileAsync(opts); } @@ -45,7 +45,7 @@ async function onMigrateCommand(argv: CliOptions): Promise { networkId, optimizerEnabled: argv.shouldOptimize ? 1 : 0, artifactsDir: argv.artifactsDir, - contractsToCompile: generateContractsToCompileSet(argv.contracts), + specifiedContracts: getContractsSetFromList(argv.contracts), }; await commands.compileAsync(compilerOpts); @@ -75,7 +75,7 @@ async function onDeployCommand(argv: CliOptions): Promise { networkId, optimizerEnabled: argv.shouldOptimize ? 1 : 0, artifactsDir: argv.artifactsDir, - contractsToCompile: generateContractsToCompileSet(argv.contracts), + specifiedContracts: getContractsSetFromList(argv.contracts), }; await commands.compileAsync(compilerOpts); @@ -97,13 +97,13 @@ async function onDeployCommand(argv: CliOptions): Promise { * Creates a set of contracts to compile. * @param contracts Comma separated list of contracts to compile */ -function generateContractsToCompileSet(contracts: string): Set { - const contractsToCompile = new Set(); +function getContractsSetFromList(contracts: string): Set { + const specifiedContracts = new Set(); const contractsArray = contracts.split(','); _.forEach(contractsArray, contractName => { - contractsToCompile.add(contractName); + specifiedContracts.add(contractName); }); - return contractsToCompile; + return specifiedContracts; } /** * Provides extra required options for deploy command. @@ -162,7 +162,7 @@ function deployCommandBuilder(yargsInstance: any) { }) .option('contracts', { type: 'string', - default: DEFAULT_COMPILE_CONTRACTS, + default: DEFAULT_CONTRACTS_LIST, description: 'comma separated list of contracts to compile', }) .command('compile', 'compile contracts', identityCommandBuilder, onCompileCommand) diff --git a/packages/deployer/src/compiler.ts b/packages/deployer/src/compiler.ts index 3ff41139e..2b0b81c44 100644 --- a/packages/deployer/src/compiler.ts +++ b/packages/deployer/src/compiler.ts @@ -26,7 +26,7 @@ export class Compiler { private _artifactsDir: string; private _contractSourcesIfExists?: ContractSources; private _solcErrors: Set; - private _contractsToCompile: Set; + private _specifiedContracts: Set; /** * Recursively retrieves Solidity source code from directory. * @param dirPath Directory to search. @@ -108,7 +108,7 @@ export class Compiler { this._optimizerEnabled = opts.optimizerEnabled; this._artifactsDir = opts.artifactsDir; this._solcErrors = new Set(); - this._contractsToCompile = opts.contractsToCompile; + this._specifiedContracts = opts.specifiedContracts; } /** * Compiles all Solidity files found in contractsDir and writes JSON artifacts to artifactsDir. @@ -140,7 +140,7 @@ export class Compiler { const currentArtifactPath = `${this._artifactsDir}/${contractName}.json`; const sourceHash = `0x${ethUtil.sha3(source).toString('hex')}`; const isContractSpecified = - this._contractsToCompile.has(ALL_CONTRACTS_IDENTIFIER) || this._contractsToCompile.has(contractName); + this._specifiedContracts.has(ALL_CONTRACTS_IDENTIFIER) || this._specifiedContracts.has(contractName); let currentArtifactString: string; let currentArtifact: ContractArtifact; diff --git a/packages/deployer/src/utils/types.ts b/packages/deployer/src/utils/types.ts index c8bb1b9ca..46481828e 100644 --- a/packages/deployer/src/utils/types.ts +++ b/packages/deployer/src/utils/types.ts @@ -50,7 +50,7 @@ export interface CompilerOptions { networkId: number; optimizerEnabled: number; artifactsDir: string; - contractsToCompile: Set; + specifiedContracts: Set; } export interface DeployerOptions { diff --git a/packages/deployer/test/deploy_test.ts b/packages/deployer/test/deploy_test.ts index 775a40cf6..6a8397982 100644 --- a/packages/deployer/test/deploy_test.ts +++ b/packages/deployer/test/deploy_test.ts @@ -18,7 +18,7 @@ const compilerOpts: CompilerOptions = { contractsDir, networkId: constants.networkId, optimizerEnabled: constants.optimizerEnabled, - contractsToCompile: new Set(constants.contractsToCompile), + specifiedContracts: new Set(constants.specifiedContracts), }; const compiler = new Compiler(compilerOpts); const deployerOpts = { diff --git a/packages/deployer/test/util/constants.ts b/packages/deployer/test/util/constants.ts index 223bfed27..adb13f330 100644 --- a/packages/deployer/test/util/constants.ts +++ b/packages/deployer/test/util/constants.ts @@ -8,5 +8,5 @@ export const constants = { timeoutMs: 20000, zrxTokenAddress: '0xe41d2489571d322189246dafa5ebde1f4699f498', tokenTransferProxyAddress: '0x8da0d80f5007ef1e431dd2127178d224e32c2ef4', - contractsToCompile: '*', + specifiedContracts: '*', }; -- cgit v1.2.3 From d12352972e986635e188759abc45f28f31ec54c2 Mon Sep 17 00:00:00 2001 From: Brandon Millman Date: Fri, 16 Feb 2018 09:49:02 -0700 Subject: Updated CHANGELOGs --- packages/deployer/CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'packages/deployer') diff --git a/packages/deployer/CHANGELOG.md b/packages/deployer/CHANGELOG.md index a33158ea0..1d28cbd41 100644 --- a/packages/deployer/CHANGELOG.md +++ b/packages/deployer/CHANGELOG.md @@ -1,6 +1,6 @@ # CHANGELOG -## v0.0.10 - _??_ +## v0.1.0 - _February 16, 2018_ * Add the ability to pass in specific contracts to compile in CLI (#400) -- cgit v1.2.3 From f62d72e54893a07ae549b6579896be9f0ab21259 Mon Sep 17 00:00:00 2001 From: Brandon Millman Date: Fri, 16 Feb 2018 09:53:35 -0700 Subject: Publish - 0x.js@0.32.4 - @0xproject/abi-gen@0.2.3 - @0xproject/assert@0.0.20 - @0xproject/connect@0.6.0 - contracts@2.1.13 - @0xproject/deployer@0.1.0 - @0xproject/dev-utils@0.1.0 - @0xproject/json-schemas@0.7.12 - @0xproject/subproviders@0.5.0 - @0xproject/testnet-faucets@1.0.14 - @0xproject/types@0.2.3 - @0xproject/utils@0.3.4 - web3-typescript-typings@0.9.11 - @0xproject/web3-wrapper@0.1.14 - @0xproject/website@0.0.16 --- packages/deployer/package.json | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'packages/deployer') diff --git a/packages/deployer/package.json b/packages/deployer/package.json index 89dfd3ef1..f969e4eda 100644 --- a/packages/deployer/package.json +++ b/packages/deployer/package.json @@ -1,6 +1,6 @@ { "name": "@0xproject/deployer", - "version": "0.0.9", + "version": "0.1.0", "description": "Smart contract deployer of 0x protocol", "main": "lib/src/index.js", "types": "lib/src/index.d.ts", @@ -31,18 +31,18 @@ "@0xproject/tslint-config": "^0.4.9", "chai": "^4.0.1", "copyfiles": "^1.2.0", - "shx": "^0.2.2", "mocha": "^4.0.1", + "shx": "^0.2.2", "tslint": "5.8.0", "types-bn": "^0.0.1", "typescript": "2.7.1", - "web3-typescript-typings": "^0.9.10" + "web3-typescript-typings": "^0.9.11" }, "dependencies": { - "@0xproject/json-schemas": "^0.7.11", - "@0xproject/types": "^0.2.2", - "@0xproject/utils": "^0.3.3", - "@0xproject/web3-wrapper": "^0.1.13", + "@0xproject/json-schemas": "^0.7.12", + "@0xproject/types": "^0.2.3", + "@0xproject/utils": "^0.3.4", + "@0xproject/web3-wrapper": "^0.1.14", "ethereumjs-util": "^5.1.1", "lodash": "^4.17.4", "solc": "^0.4.18", -- cgit v1.2.3