From a5d2cbfd6f9d7e86807bf2c4fb3a045722153e58 Mon Sep 17 00:00:00 2001 From: Leonid Logvinov Date: Mon, 18 Dec 2017 16:27:14 +0100 Subject: Install types for yargs --- packages/abi-gen/package.json | 2 +- packages/contracts/deploy/cli.ts | 14 +++++++------- packages/contracts/deploy/src/utils/types.ts | 3 ++- packages/contracts/globals.d.ts | 1 - packages/contracts/package.json | 2 +- yarn.lock | 4 ++++ 6 files changed, 15 insertions(+), 11 deletions(-) diff --git a/packages/abi-gen/package.json b/packages/abi-gen/package.json index a5c27b907..00943f063 100644 --- a/packages/abi-gen/package.json +++ b/packages/abi-gen/package.json @@ -38,7 +38,7 @@ "@types/handlebars": "^4.0.36", "@types/mkdirp": "^0.5.1", "@types/node": "^8.0.53", - "@types/yargs": "^8.0.2", + "@types/yargs": "^10.0.0", "npm-run-all": "^4.1.2", "shx": "^0.2.2", "tslint": "5.8.0", diff --git a/packages/contracts/deploy/cli.ts b/packages/contracts/deploy/cli.ts index 423523e21..6587e46f1 100644 --- a/packages/contracts/deploy/cli.ts +++ b/packages/contracts/deploy/cli.ts @@ -23,12 +23,12 @@ const DEFAULT_GAS_PRICE = ((10 ** 9) * 2).toString(); * Compiles all contracts with options passed in through CLI. * @param argv Instance of process.argv provided by yargs. */ -async function onCompileCommand(args: CliOptions): Promise { +async function onCompileCommand(argv: CliOptions): Promise { const opts: CompilerOptions = { - contractsDir: args.contractsDir, - networkId: args.networkId, - optimizerEnabled: args.shouldOptimize ? 1 : 0, - artifactsDir: args.artifactsDir, + contractsDir: argv.contractsDir, + networkId: argv.networkId, + optimizerEnabled: argv.shouldOptimize ? 1 : 0, + artifactsDir: argv.artifactsDir, }; await commands.compileAsync(opts); } @@ -150,11 +150,11 @@ function deployCommandBuilder(yargsInstance: any) { }) .command('compile', 'compile contracts', - _.noop, + _.identity, onCompileCommand) .command('migrate', 'compile and deploy contracts using migration scripts', - _.noop, + _.identity, onMigrateCommand) .command('deploy', 'deploy a single contract with provided arguments', diff --git a/packages/contracts/deploy/src/utils/types.ts b/packages/contracts/deploy/src/utils/types.ts index f6b9de6e9..6831079e6 100644 --- a/packages/contracts/deploy/src/utils/types.ts +++ b/packages/contracts/deploy/src/utils/types.ts @@ -1,5 +1,6 @@ import {TxData} from '@0xproject/types'; import * as Web3 from 'web3'; +import * as yargs from 'yargs'; export enum AbiType { Function = 'function', @@ -32,7 +33,7 @@ export interface SolcErrors { [key: string]: boolean; } -export interface CliOptions { +export interface CliOptions extends yargs.Arguments { artifactsDir: string; contractsDir: string; jsonrpcPort: number; diff --git a/packages/contracts/globals.d.ts b/packages/contracts/globals.d.ts index df53e9372..a2d5176f8 100644 --- a/packages/contracts/globals.d.ts +++ b/packages/contracts/globals.d.ts @@ -2,7 +2,6 @@ declare module 'bn.js'; declare module 'ethereumjs-abi'; declare module 'chai-bignumber'; declare module 'dirty-chai'; -declare module 'yargs'; // HACK: In order to merge the bignumber declaration added by chai-bignumber to the chai Assertion // interface we must use `namespace` as the Chai definitelyTyped definition does. Since we otherwise diff --git a/packages/contracts/package.json b/packages/contracts/package.json index c8ccd0a3a..0a7b8f5ef 100644 --- a/packages/contracts/package.json +++ b/packages/contracts/package.json @@ -36,7 +36,7 @@ "@types/lodash": "^4.14.86", "@types/node": "^8.0.53", "@types/request-promise-native": "^1.0.2", - "@types/yargs": "^8.0.2", + "@types/yargs": "^10.0.0", "chai": "^4.0.1", "chai-as-promised": "^7.1.0", "chai-as-promised-typescript-typings": "^0.0.3", diff --git a/yarn.lock b/yarn.lock index d97a63282..b61c2f607 100644 --- a/yarn.lock +++ b/yarn.lock @@ -266,6 +266,10 @@ dependencies: "@types/node" "*" +"@types/yargs@^10.0.0": + version "10.0.0" + resolved "https://registry.yarnpkg.com/@types/yargs/-/yargs-10.0.0.tgz#b93aa88155fe5106cddf3f934517411ca2a45939" + "@types/yargs@^8.0.2": version "8.0.2" resolved "https://registry.yarnpkg.com/@types/yargs/-/yargs-8.0.2.tgz#0f9c7b236e2d78cd8f4b6502de15d0728aa29385" -- cgit v1.2.3 From ed6756898f02f192081fa4c89b5bb2cb1ae3c637 Mon Sep 17 00:00:00 2001 From: Leonid Logvinov Date: Mon, 18 Dec 2017 16:28:28 +0100 Subject: Define types for ethereumjs-abi --- packages/contracts/globals.d.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/packages/contracts/globals.d.ts b/packages/contracts/globals.d.ts index a2d5176f8..05c08bd98 100644 --- a/packages/contracts/globals.d.ts +++ b/packages/contracts/globals.d.ts @@ -1,5 +1,4 @@ declare module 'bn.js'; -declare module 'ethereumjs-abi'; declare module 'chai-bignumber'; declare module 'dirty-chai'; @@ -30,6 +29,10 @@ declare module 'web3-eth-abi' { export function encodeParameters(typesArray: string[], parameters: any[]): string; } +declare module 'ethereumjs-abi' { + const soliditySHA3: (argTypes: string[], args: any[]) => Buffer; +} + // Truffle injects the following into the global scope declare var artifacts: any; declare var contract: any; -- cgit v1.2.3 From 786ea527380fe8f2f6461628c9dde90d61e3bc85 Mon Sep 17 00:00:00 2001 From: Leonid Logvinov Date: Mon, 18 Dec 2017 16:35:06 +0100 Subject: Define types for methodID --- packages/contracts/globals.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/contracts/globals.d.ts b/packages/contracts/globals.d.ts index 05c08bd98..2e5827324 100644 --- a/packages/contracts/globals.d.ts +++ b/packages/contracts/globals.d.ts @@ -1,4 +1,3 @@ -declare module 'bn.js'; declare module 'chai-bignumber'; declare module 'dirty-chai'; @@ -31,6 +30,7 @@ declare module 'web3-eth-abi' { declare module 'ethereumjs-abi' { const soliditySHA3: (argTypes: string[], args: any[]) => Buffer; + const methodID: (name: string, types: string[]) => Buffer; } // Truffle injects the following into the global scope -- cgit v1.2.3 From e5b5fc400a4bb18b21ceb5bc6dcd648e3c2a5416 Mon Sep 17 00:00:00 2001 From: Leonid Logvinov Date: Tue, 19 Dec 2017 12:18:50 +0100 Subject: Introduce an identityCommandBuilder --- packages/contracts/deploy/cli.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/packages/contracts/deploy/cli.ts b/packages/contracts/deploy/cli.ts index 6587e46f1..b02849826 100644 --- a/packages/contracts/deploy/cli.ts +++ b/packages/contracts/deploy/cli.ts @@ -113,6 +113,7 @@ function deployCommandBuilder(yargsInstance: any) { } (() => { + const identityCommandBuilder = _.identity; return yargs .option('contracts-dir', { type: 'string', @@ -150,11 +151,11 @@ function deployCommandBuilder(yargsInstance: any) { }) .command('compile', 'compile contracts', - _.identity, + identityCommandBuilder, onCompileCommand) .command('migrate', 'compile and deploy contracts using migration scripts', - _.identity, + identityCommandBuilder, onMigrateCommand) .command('deploy', 'deploy a single contract with provided arguments', -- cgit v1.2.3