aboutsummaryrefslogtreecommitdiffstats
path: root/packages/deployer
diff options
context:
space:
mode:
authorLeonid <logvinov.leon@gmail.com>2018-02-21 02:55:10 +0800
committerGitHub <noreply@github.com>2018-02-21 02:55:10 +0800
commitf60b00d116e525e5b789684e68b1541cedba1665 (patch)
tree9c8f33bafb1fb2eef5bfcaaefed781ccae6ffba9 /packages/deployer
parent76afb6b1163182446a1f3646b4bc89b5dc271738 (diff)
parent3a36e0621f0ad0c77c14a04bdaa85131b57ef0ea (diff)
downloaddexon-0x-contracts-f60b00d116e525e5b789684e68b1541cedba1665.tar
dexon-0x-contracts-f60b00d116e525e5b789684e68b1541cedba1665.tar.gz
dexon-0x-contracts-f60b00d116e525e5b789684e68b1541cedba1665.tar.bz2
dexon-0x-contracts-f60b00d116e525e5b789684e68b1541cedba1665.tar.lz
dexon-0x-contracts-f60b00d116e525e5b789684e68b1541cedba1665.tar.xz
dexon-0x-contracts-f60b00d116e525e5b789684e68b1541cedba1665.tar.zst
dexon-0x-contracts-f60b00d116e525e5b789684e68b1541cedba1665.zip
Merge branch 'development' into feature/web3-abi-v2-types
Diffstat (limited to 'packages/deployer')
-rw-r--r--packages/deployer/CHANGELOG.md4
-rw-r--r--packages/deployer/package.json15
-rw-r--r--packages/deployer/src/cli.ts21
-rw-r--r--packages/deployer/src/compiler.ts14
-rw-r--r--packages/deployer/src/utils/types.ts1
-rw-r--r--packages/deployer/test/deploy_test.ts1
-rw-r--r--packages/deployer/test/util/constants.ts1
7 files changed, 46 insertions, 11 deletions
diff --git a/packages/deployer/CHANGELOG.md b/packages/deployer/CHANGELOG.md
index ad8c64538..1d28cbd41 100644
--- a/packages/deployer/CHANGELOG.md
+++ b/packages/deployer/CHANGELOG.md
@@ -1,5 +1,9 @@
# CHANGELOG
+## v0.1.0 - _February 16, 2018_
+
+ * 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)
diff --git a/packages/deployer/package.json b/packages/deployer/package.json
index af5c33354..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",
@@ -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"
@@ -32,16 +32,17 @@
"chai": "^4.0.1",
"copyfiles": "^1.2.0",
"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",
diff --git a/packages/deployer/src/cli.ts b/packages/deployer/src/cli.ts
index 0fe412bdf..3c6d042c0 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_CONTRACTS_LIST = '*';
/**
* Compiles all contracts with options passed in through CLI.
@@ -25,6 +26,7 @@ async function onCompileCommand(argv: CliOptions): Promise<void> {
networkId: argv.networkId,
optimizerEnabled: argv.shouldOptimize ? 1 : 0,
artifactsDir: argv.artifactsDir,
+ specifiedContracts: getContractsSetFromList(argv.contracts),
};
await commands.compileAsync(opts);
}
@@ -43,6 +45,7 @@ async function onMigrateCommand(argv: CliOptions): Promise<void> {
networkId,
optimizerEnabled: argv.shouldOptimize ? 1 : 0,
artifactsDir: argv.artifactsDir,
+ specifiedContracts: getContractsSetFromList(argv.contracts),
};
await commands.compileAsync(compilerOpts);
@@ -72,6 +75,7 @@ async function onDeployCommand(argv: CliOptions): Promise<void> {
networkId,
optimizerEnabled: argv.shouldOptimize ? 1 : 0,
artifactsDir: argv.artifactsDir,
+ specifiedContracts: getContractsSetFromList(argv.contracts),
};
await commands.compileAsync(compilerOpts);
@@ -90,6 +94,18 @@ async function onDeployCommand(argv: CliOptions): Promise<void> {
await commands.deployAsync(argv.contract, deployerArgs, deployerOpts);
}
/**
+ * Creates a set of contracts to compile.
+ * @param contracts Comma separated list of contracts to compile
+ */
+function getContractsSetFromList(contracts: string): Set<string> {
+ const specifiedContracts = new Set();
+ const contractsArray = contracts.split(',');
+ _.forEach(contractsArray, contractName => {
+ specifiedContracts.add(contractName);
+ });
+ return specifiedContracts;
+}
+/**
* 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_CONTRACTS_LIST,
+ 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..2b0b81c44 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<string>;
+ private _specifiedContracts: Set<string>;
/**
* 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._specifiedContracts = opts.specifiedContracts;
}
/**
* Compiles all Solidity files found in contractsDir and writes JSON artifacts to artifactsDir.
@@ -136,6 +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._specifiedContracts.has(ALL_CONTRACTS_IDENTIFIER) || this._specifiedContracts.has(contractName);
let currentArtifactString: string;
let currentArtifact: ContractArtifact;
@@ -150,11 +155,12 @@ export class Compiler {
oldNetworks = currentArtifact.networks;
const oldNetwork: ContractData = oldNetworks[this._networkId];
shouldCompile =
- _.isUndefined(oldNetwork) ||
- oldNetwork.keccak256 !== sourceHash ||
- oldNetwork.optimizer_enabled !== this._optimizerEnabled;
+ (_.isUndefined(oldNetwork) ||
+ oldNetwork.keccak256 !== sourceHash ||
+ oldNetwork.optimizer_enabled !== this._optimizerEnabled) &&
+ isContractSpecified;
} catch (err) {
- shouldCompile = true;
+ shouldCompile = isContractSpecified;
}
if (!shouldCompile) {
diff --git a/packages/deployer/src/utils/types.ts b/packages/deployer/src/utils/types.ts
index e054b9cc2..46481828e 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;
+ specifiedContracts: Set<string>;
}
export interface DeployerOptions {
diff --git a/packages/deployer/test/deploy_test.ts b/packages/deployer/test/deploy_test.ts
index 5fe2ffbd7..6a8397982 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,
+ 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 d52076607..adb13f330 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',
+ specifiedContracts: '*',
};