From 96037aed5231aa9344e5037aa6cff3d01f4abdae Mon Sep 17 00:00:00 2001 From: Leonid Logvinov Date: Tue, 8 May 2018 15:13:24 +0200 Subject: Remove deployer --- packages/deployer/src/cli.ts | 126 ++++++------------------------------------- 1 file changed, 15 insertions(+), 111 deletions(-) (limited to 'packages/deployer/src/cli.ts') diff --git a/packages/deployer/src/cli.ts b/packages/deployer/src/cli.ts index 8c89cf382..2412b8d34 100644 --- a/packages/deployer/src/cli.ts +++ b/packages/deployer/src/cli.ts @@ -8,130 +8,34 @@ import * as path from 'path'; import * as Web3 from 'web3'; import * as yargs from 'yargs'; -import { commands } from './commands'; +import { Compiler } from './compiler'; import { constants } from './utils/constants'; -import { consoleReporter } from './utils/error_reporter'; -import { CliOptions, CompilerOptions, DeployerOptions } from './utils/types'; +import { CompilerOptions } from './utils/types'; -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. - * @param argv Instance of process.argv provided by yargs. - */ -async function onCompileCommandAsync(argv: CliOptions): Promise { - const opts: CompilerOptions = { - contractsDir: argv.contractsDir, - artifactsDir: argv.artifactsDir, - contracts: argv.contracts === DEFAULT_CONTRACTS_LIST ? DEFAULT_CONTRACTS_LIST : argv.contracts.split(SEPARATOR), - }; - await commands.compileAsync(opts); -} -/** - * Deploys a single contract with provided name and args. - * @param argv Instance of process.argv provided by yargs. - */ -async function onDeployCommandAsync(argv: CliOptions): Promise { - const url = argv.jsonrpcUrl; - const provider = new Web3.providers.HttpProvider(url); - const web3Wrapper = new Web3Wrapper(provider); - const networkId = await web3Wrapper.getNetworkIdAsync(); - const compilerOpts: CompilerOptions = { - contractsDir: argv.contractsDir, - artifactsDir: argv.artifactsDir, - contracts: argv.contracts === DEFAULT_CONTRACTS_LIST ? DEFAULT_CONTRACTS_LIST : argv.contracts.split(SEPARATOR), - }; - await commands.compileAsync(compilerOpts); - - const defaults = { - gasPrice: new BigNumber(argv.gasPrice), - from: argv.account, - }; - const deployerOpts: DeployerOptions = { - artifactsDir: argv.artifactsDir || DEFAULT_ARTIFACTS_DIR, - jsonrpcUrl: argv.jsonrpcUrl, - networkId, - defaults, - }; - const deployerArgsString = argv.constructorArgs as string; - const deployerArgs = deployerArgsString.split(SEPARATOR); - await commands.deployAsync(argv.contract as string, deployerArgs, deployerOpts); -} -/** - * 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('network-id', { - type: 'number', - default: DEFAULT_NETWORK_ID, - description: 'mainnet=1, kovan=42, testrpc=50', - }) - .option('contract', { - type: 'string', - description: 'name of contract to deploy, excluding .sol extension', - }) - .option('constructor-args', { - type: 'string', - 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', { +(async () => { + const argv = yargs + .option('contracts-dir', { type: 'string', - description: 'account to use for deploying contracts', + description: 'path of contracts directory to compile', }) - .option('gas-price', { + .option('artifacts-dir', { type: 'string', - default: DEFAULT_GAS_PRICE, - description: 'gasPrice to be used for transactions', + description: 'path to write contracts artifacts to', }) - .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', }) .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', - deployCommandBuilder, - consoleReporter(onDeployCommandAsync), - ) - .help().argv; + const opts: CompilerOptions = { + contractsDir: argv.contractsDir, + artifactsDir: argv.artifactsDir, + contracts: argv.contracts === DEFAULT_CONTRACTS_LIST ? DEFAULT_CONTRACTS_LIST : argv.contracts.split(SEPARATOR), + }; + const compiler = new Compiler(opts); + await compiler.compileAsync(); })(); -- cgit v1.2.3 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/deployer/src/cli.ts | 41 ----------------------------------------- 1 file changed, 41 deletions(-) delete mode 100644 packages/deployer/src/cli.ts (limited to 'packages/deployer/src/cli.ts') diff --git a/packages/deployer/src/cli.ts b/packages/deployer/src/cli.ts deleted file mode 100644 index 2412b8d34..000000000 --- a/packages/deployer/src/cli.ts +++ /dev/null @@ -1,41 +0,0 @@ -#!/usr/bin/env node -// We need the above pragma since this script will be run as a command-line tool. - -import { BigNumber } from '@0xproject/utils'; -import { Web3Wrapper } from '@0xproject/web3-wrapper'; -import * as _ from 'lodash'; -import * as path from 'path'; -import * as Web3 from 'web3'; -import * as yargs from 'yargs'; - -import { Compiler } from './compiler'; -import { constants } from './utils/constants'; -import { CompilerOptions } from './utils/types'; - -const DEFAULT_CONTRACTS_LIST = '*'; -const SEPARATOR = ','; - -(async () => { - const argv = 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', - }) - .option('contracts', { - type: 'string', - default: DEFAULT_CONTRACTS_LIST, - description: 'comma separated list of contracts to compile', - }) - .help().argv; - const opts: CompilerOptions = { - contractsDir: argv.contractsDir, - artifactsDir: argv.artifactsDir, - contracts: argv.contracts === DEFAULT_CONTRACTS_LIST ? DEFAULT_CONTRACTS_LIST : argv.contracts.split(SEPARATOR), - }; - const compiler = new Compiler(opts); - await compiler.compileAsync(); -})(); -- cgit v1.2.3