diff options
author | Fabio Berger <me@fabioberger.com> | 2018-05-10 23:08:07 +0800 |
---|---|---|
committer | Fabio Berger <me@fabioberger.com> | 2018-05-10 23:08:07 +0800 |
commit | cd5f00ac4d41221c99eb8ce767e63e09a6de6a11 (patch) | |
tree | 2b1865b5fa6ef86965ea753c032ffaba48403921 /packages/deployer/src/cli.ts | |
parent | 23c4027c83b9f30fad352615386b988084f8b39f (diff) | |
parent | c64ad1af28ef116e210aafb3ea6ad2138361cd7c (diff) | |
download | dexon-sol-tools-cd5f00ac4d41221c99eb8ce767e63e09a6de6a11.tar dexon-sol-tools-cd5f00ac4d41221c99eb8ce767e63e09a6de6a11.tar.gz dexon-sol-tools-cd5f00ac4d41221c99eb8ce767e63e09a6de6a11.tar.bz2 dexon-sol-tools-cd5f00ac4d41221c99eb8ce767e63e09a6de6a11.tar.lz dexon-sol-tools-cd5f00ac4d41221c99eb8ce767e63e09a6de6a11.tar.xz dexon-sol-tools-cd5f00ac4d41221c99eb8ce767e63e09a6de6a11.tar.zst dexon-sol-tools-cd5f00ac4d41221c99eb8ce767e63e09a6de6a11.zip |
Merge branch 'development' into breakUp0xjs
* development: (38 commits)
Add fallback image support to relayer grid tile
Clear relayer grid state when fetching
Configure the compiler to generate artifacts with deployedBytecode
Implement loading and error state for relayer grid
Fallback image for relayer grid tile
Change relayer grid tile to link on header
Display top tokens from backend
Remove overflowZ property from portal
Suggestions and fix bad merge
Fix typo
Only show untracked tokens
Make wallet scrollable
Add token flow
Update The Ocean logo
Fix artifacts paths
Create an artifacts folder
Introduce a var
Add removeHexPrefix util method
CHeck if ABI exists
Improve the readability of the check for should compile
...
# Conflicts:
# .gitignore
# packages/contracts/test/multi_sig_with_time_lock.ts
# packages/contracts/test/multi_sig_with_time_lock_except_remove_auth_addr.ts
# packages/contracts/util/artifacts.ts
Diffstat (limited to 'packages/deployer/src/cli.ts')
-rw-r--r-- | packages/deployer/src/cli.ts | 100 |
1 files changed, 42 insertions, 58 deletions
diff --git a/packages/deployer/src/cli.ts b/packages/deployer/src/cli.ts index 7f1ae708a..8c89cf382 100644 --- a/packages/deployer/src/cli.ts +++ b/packages/deployer/src/cli.ts @@ -13,13 +13,13 @@ import { constants } from './utils/constants'; import { consoleReporter } from './utils/error_reporter'; import { CliOptions, CompilerOptions, DeployerOptions } from './utils/types'; -const DEFAULT_OPTIMIZER_ENABLED = false; const DEFAULT_CONTRACTS_DIR = path.resolve('src/contracts'); const DEFAULT_ARTIFACTS_DIR = path.resolve('src/artifacts'); const DEFAULT_NETWORK_ID = 50; const DEFAULT_JSONRPC_URL = 'http://localhost:8545'; const DEFAULT_GAS_PRICE = (10 ** 9 * 2).toString(); const DEFAULT_CONTRACTS_LIST = '*'; +const SEPARATOR = ','; /** * Compiles all contracts with options passed in through CLI. @@ -28,10 +28,8 @@ const DEFAULT_CONTRACTS_LIST = '*'; async function onCompileCommandAsync(argv: CliOptions): Promise<void> { const opts: CompilerOptions = { contractsDir: argv.contractsDir, - networkId: argv.networkId, - optimizerEnabled: argv.shouldOptimize, artifactsDir: argv.artifactsDir, - specifiedContracts: getContractsSetFromList(argv.contracts), + contracts: argv.contracts === DEFAULT_CONTRACTS_LIST ? DEFAULT_CONTRACTS_LIST : argv.contracts.split(SEPARATOR), }; await commands.compileAsync(opts); } @@ -46,10 +44,8 @@ async function onDeployCommandAsync(argv: CliOptions): Promise<void> { const networkId = await web3Wrapper.getNetworkIdAsync(); const compilerOpts: CompilerOptions = { contractsDir: argv.contractsDir, - networkId, - optimizerEnabled: argv.shouldOptimize, artifactsDir: argv.artifactsDir, - specifiedContracts: getContractsSetFromList(argv.contracts), + contracts: argv.contracts === DEFAULT_CONTRACTS_LIST ? DEFAULT_CONTRACTS_LIST : argv.contracts.split(SEPARATOR), }; await commands.compileAsync(compilerOpts); @@ -58,91 +54,79 @@ async function onDeployCommandAsync(argv: CliOptions): Promise<void> { from: argv.account, }; const deployerOpts: DeployerOptions = { - artifactsDir: argv.artifactsDir, + artifactsDir: argv.artifactsDir || DEFAULT_ARTIFACTS_DIR, jsonrpcUrl: argv.jsonrpcUrl, networkId, defaults, }; - const deployerArgsString = argv.args as string; - const deployerArgs = deployerArgsString.split(','); + const deployerArgsString = argv.constructorArgs as string; + const deployerArgs = deployerArgsString.split(SEPARATOR); await commands.deployAsync(argv.contract as string, 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(); - if (contracts === '*') { - return new Set(['*']); - } - const contractsArray = contracts.split(','); - _.forEach(contractsArray, contractName => { - specifiedContracts.add(contractName); - }); - return specifiedContracts; -} -/** - * Provides extra required options for deploy command. + * Adds additional required options for when the user is calling the deploy command. * @param yargsInstance yargs instance provided in builder function callback. */ function deployCommandBuilder(yargsInstance: any) { return yargsInstance - .option('contract', { - type: 'string', - description: 'name of contract to deploy, exluding .sol extension', - }) - .option('args', { - type: 'string', - description: 'comma separated list of constructor args to deploy contract with', - }) - .demandOption(['contract', 'args']) - .help().argv; -} - -(() => { - const identityCommandBuilder = _.identity; - return yargs - .option('contracts-dir', { - type: 'string', - default: DEFAULT_CONTRACTS_DIR, - description: 'path of contracts directory to compile', - }) .option('network-id', { type: 'number', default: DEFAULT_NETWORK_ID, description: 'mainnet=1, kovan=42, testrpc=50', }) - .option('should-optimize', { - type: 'boolean', - default: DEFAULT_OPTIMIZER_ENABLED, - description: 'enable optimizer', + .option('contract', { + type: 'string', + description: 'name of contract to deploy, excluding .sol extension', }) - .option('artifacts-dir', { + .option('constructor-args', { type: 'string', - default: DEFAULT_ARTIFACTS_DIR, - description: 'path to write contracts artifacts to', + description: 'comma separated list of constructor args to deploy contract with', }) .option('jsonrpc-url', { type: 'string', default: DEFAULT_JSONRPC_URL, description: 'url of JSON RPC', }) + .option('account', { + type: 'string', + description: 'account to use for deploying contracts', + }) .option('gas-price', { type: 'string', default: DEFAULT_GAS_PRICE, description: 'gasPrice to be used for transactions', }) - .option('account', { - type: 'string', - description: 'account to use for deploying contracts', - }) + .demandOption(['contract', 'args', 'account']) + .help().argv; +} + +/** + * Adds additional required options for when the user is calling the compile command. + * @param yargsInstance yargs instance provided in builder function callback. + */ +function compileCommandBuilder(yargsInstance: any) { + return yargsInstance .option('contracts', { type: 'string', default: DEFAULT_CONTRACTS_LIST, description: 'comma separated list of contracts to compile', }) - .command('compile', 'compile contracts', identityCommandBuilder, consoleReporter(onCompileCommandAsync)) + .help().argv; +} + +(() => { + const identityCommandBuilder = _.identity; + return yargs + .option('contracts-dir', { + type: 'string', + description: 'path of contracts directory to compile', + }) + .option('artifacts-dir', { + type: 'string', + description: 'path to write contracts artifacts to', + }) + .demandCommand(1) + .command('compile', 'compile contracts', compileCommandBuilder, consoleReporter(onCompileCommandAsync)) .command( 'deploy', 'deploy a single contract with provided arguments', |