From b74957acdfc8d67d154bcb4698acd7575db7cc47 Mon Sep 17 00:00:00 2001 From: Leonid Logvinov Date: Fri, 11 May 2018 17:38:51 +0200 Subject: Add missing type definitions --- packages/contracts/test/utils/chai_setup.ts | 2 +- packages/contracts/util/crypto.ts | 2 +- packages/contracts/util/formatters.ts | 6 +++--- packages/contracts/util/multi_sig_wrapper.ts | 4 ++-- packages/contracts/util/signed_order_utils.ts | 13 +++++++++++-- packages/contracts/util/token_registry_wrapper.ts | 8 ++++---- 6 files changed, 22 insertions(+), 13 deletions(-) (limited to 'packages/contracts') diff --git a/packages/contracts/test/utils/chai_setup.ts b/packages/contracts/test/utils/chai_setup.ts index 078edd309..1a8733093 100644 --- a/packages/contracts/test/utils/chai_setup.ts +++ b/packages/contracts/test/utils/chai_setup.ts @@ -4,7 +4,7 @@ import ChaiBigNumber = require('chai-bignumber'); import * as dirtyChai from 'dirty-chai'; export const chaiSetup = { - configure() { + configure(): void { chai.config.includeStack = true; chai.use(ChaiBigNumber()); chai.use(dirtyChai); diff --git a/packages/contracts/util/crypto.ts b/packages/contracts/util/crypto.ts index 810072d2f..3661b3afd 100644 --- a/packages/contracts/util/crypto.ts +++ b/packages/contracts/util/crypto.ts @@ -18,7 +18,7 @@ export const crypto = { solSHA256(args: any[]): Buffer { return crypto._solHash(args, ABI.soliditySHA256); }, - _solHash(args: any[], hashFunction: (types: string[], values: any[]) => Buffer) { + _solHash(args: any[], hashFunction: (types: string[], values: any[]) => Buffer): Buffer { const argTypes: string[] = []; _.each(args, (arg, i) => { const isNumber = _.isFinite(arg); diff --git a/packages/contracts/util/formatters.ts b/packages/contracts/util/formatters.ts index 8e0dfb09e..3e3b67495 100644 --- a/packages/contracts/util/formatters.ts +++ b/packages/contracts/util/formatters.ts @@ -9,7 +9,7 @@ export const formatters = { signedOrders: SignedOrder[], shouldThrowOnInsufficientBalanceOrAllowance: boolean, fillTakerTokenAmounts: BigNumber[] = [], - ) { + ): BatchFillOrders { const batchFill: BatchFillOrders = { orderAddresses: [], orderValues: [], @@ -48,7 +48,7 @@ export const formatters = { signedOrders: SignedOrder[], shouldThrowOnInsufficientBalanceOrAllowance: boolean, fillTakerTokenAmount: BigNumber, - ) { + ): FillOrdersUpTo { const fillUpTo: FillOrdersUpTo = { orderAddresses: [], orderValues: [], @@ -80,7 +80,7 @@ export const formatters = { }); return fillUpTo; }, - createBatchCancel(signedOrders: SignedOrder[], cancelTakerTokenAmounts: BigNumber[] = []) { + createBatchCancel(signedOrders: SignedOrder[], cancelTakerTokenAmounts: BigNumber[] = []): BatchCancelOrders { const batchCancel: BatchCancelOrders = { orderAddresses: [], orderValues: [], diff --git a/packages/contracts/util/multi_sig_wrapper.ts b/packages/contracts/util/multi_sig_wrapper.ts index 9f6dcec52..c66106b9a 100644 --- a/packages/contracts/util/multi_sig_wrapper.ts +++ b/packages/contracts/util/multi_sig_wrapper.ts @@ -11,7 +11,7 @@ import { TransactionDataParams } from './types'; export class MultiSigWrapper { private _multiSig: MultiSigWalletContract; - public static encodeFnArgs(name: string, abi: AbiDefinition[], args: any[]) { + public static encodeFnArgs(name: string, abi: AbiDefinition[], args: any[]): string { const abiEntity = _.find(abi, { name }) as MethodAbi; if (_.isUndefined(abiEntity)) { throw new Error(`Did not find abi entry for name: ${name}`); @@ -33,7 +33,7 @@ export class MultiSigWrapper { from: string, dataParams: TransactionDataParams, value: BigNumber = new BigNumber(0), - ) { + ): Promise { const { name, abi, args = [] } = dataParams; const encoded = MultiSigWrapper.encodeFnArgs(name, abi, args); return this._multiSig.submitTransaction.sendTransactionAsync(destination, value, encoded, { diff --git a/packages/contracts/util/signed_order_utils.ts b/packages/contracts/util/signed_order_utils.ts index fc2f800cd..30a2814e7 100644 --- a/packages/contracts/util/signed_order_utils.ts +++ b/packages/contracts/util/signed_order_utils.ts @@ -6,6 +6,15 @@ import * as _ from 'lodash'; import { crypto } from './crypto'; +interface OrderAddressesAndValues { + orderAddresses: string[]; + orderValues: BigNumber[]; +} + +interface OrderCancel extends OrderAddressesAndValues { + cancelTakerTokenAmount: BigNumber; +} + export const signedOrderUtils = { createFill: ( signedOrder: SignedOrder, @@ -20,14 +29,14 @@ export const signedOrderUtils = { }; return fill; }, - createCancel(signedOrder: SignedOrder, cancelTakerTokenAmount?: BigNumber) { + createCancel(signedOrder: SignedOrder, cancelTakerTokenAmount?: BigNumber): OrderCancel { const cancel = { ...signedOrderUtils.getOrderAddressesAndValues(signedOrder), cancelTakerTokenAmount: cancelTakerTokenAmount || signedOrder.takerTokenAmount, }; return cancel; }, - getOrderAddressesAndValues(signedOrder: SignedOrder) { + getOrderAddressesAndValues(signedOrder: SignedOrder): OrderAddressesAndValues { return { orderAddresses: [ signedOrder.maker, diff --git a/packages/contracts/util/token_registry_wrapper.ts b/packages/contracts/util/token_registry_wrapper.ts index d78c8a64e..bed62fa53 100644 --- a/packages/contracts/util/token_registry_wrapper.ts +++ b/packages/contracts/util/token_registry_wrapper.ts @@ -9,7 +9,7 @@ export class TokenRegWrapper { constructor(tokenRegContract: TokenRegistryContract) { this._tokenReg = tokenRegContract; } - public async addTokenAsync(token: Token, from: string) { + public async addTokenAsync(token: Token, from: string): Promise { const tx = this._tokenReg.addToken.sendTransactionAsync( token.address as string, token.name, @@ -21,7 +21,7 @@ export class TokenRegWrapper { ); return tx; } - public async getTokenMetaDataAsync(tokenAddress: string) { + public async getTokenMetaDataAsync(tokenAddress: string): Promise { const data = await this._tokenReg.getTokenMetaData.callAsync(tokenAddress); const token: Token = { address: data[0], @@ -33,7 +33,7 @@ export class TokenRegWrapper { }; return token; } - public async getTokenByNameAsync(tokenName: string) { + public async getTokenByNameAsync(tokenName: string): Promise { const data = await this._tokenReg.getTokenByName.callAsync(tokenName); const token: Token = { address: data[0], @@ -45,7 +45,7 @@ export class TokenRegWrapper { }; return token; } - public async getTokenBySymbolAsync(tokenSymbol: string) { + public async getTokenBySymbolAsync(tokenSymbol: string): Promise { const data = await this._tokenReg.getTokenBySymbol.callAsync(tokenSymbol); const token: Token = { address: data[0], -- cgit v1.2.3 From 478f6ed011185b66ac87323c6d9ad1f598060760 Mon Sep 17 00:00:00 2001 From: Fabio Berger Date: Mon, 14 May 2018 19:23:50 +0200 Subject: Move from using lerna multi-package commands to wsrun, update README's accordingly --- packages/contracts/README.md | 18 +++--------------- packages/contracts/package.json | 2 +- 2 files changed, 4 insertions(+), 16 deletions(-) (limited to 'packages/contracts') diff --git a/packages/contracts/README.md b/packages/contracts/README.md index 16e253549..23551b69d 100644 --- a/packages/contracts/README.md +++ b/packages/contracts/README.md @@ -34,28 +34,16 @@ yarn install ### Build -If this is your **first** time building this package, you must first build **all** packages within the monorepo. This is because packages that depend on other packages located inside this monorepo are symlinked when run from **within** the monorepo. This allows you to make changes across multiple packages without first publishing dependent packages to NPM. To build all packages, run the following from the monorepo root directory: +To build this package and all other monorepo packages that it depends on, run the following from the monorepo root directory: ```bash -yarn lerna:rebuild +PKG=contracts yarn build ``` Or continuously rebuild on change: ```bash -yarn dev -``` - -You can also build this specific package by running the following from within its directory: - -```bash -yarn build -``` - -or continuously rebuild on change: - -```bash -yarn build:watch +PKG=contracts yarn watch ``` ### Clean diff --git a/packages/contracts/package.json b/packages/contracts/package.json index 557effca2..14f6e53f0 100644 --- a/packages/contracts/package.json +++ b/packages/contracts/package.json @@ -8,7 +8,7 @@ "test": "test" }, "scripts": { - "build:watch": "tsc -w", + "watch": "tsc -w", "prebuild": "run-s clean copy_artifacts generate_contract_wrappers", "copy_artifacts": "copyfiles -u 4 '../migrations/artifacts/1.0.0/**/*' ./lib/src/artifacts;", "build": "tsc", -- cgit v1.2.3 From 5f678acf46ac024ccd6a0a6ea002e0ddf7ff3ba5 Mon Sep 17 00:00:00 2001 From: Fabio Berger Date: Mon, 14 May 2018 19:31:56 +0200 Subject: Fix abi-gen binary so it can be called directly from packages --- packages/contracts/package.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'packages/contracts') diff --git a/packages/contracts/package.json b/packages/contracts/package.json index 14f6e53f0..ec41f951b 100644 --- a/packages/contracts/package.json +++ b/packages/contracts/package.json @@ -18,7 +18,7 @@ "compile:comment": "Yarn workspaces do not link binaries correctly so we need to reference them directly https://github.com/yarnpkg/yarn/issues/3846", "compile": "node ../sol-compiler/lib/src/cli.js", "clean": "shx rm -rf lib src/contract_wrappers/generated", - "generate_contract_wrappers": "node ../abi-gen/lib/index.js --abis ${npm_package_config_abis} --template ../contract_templates/contract.handlebars --partials '../contract_templates/partials/**/*.handlebars' --output src/contract_wrappers/generated --backend ethers && prettier --write 'src/contract_wrappers/generated/**.ts'", + "generate_contract_wrappers": "abi-gen --abis ${npm_package_config_abis} --template ../contract_templates/contract.handlebars --partials '../contract_templates/partials/**/*.handlebars' --output src/contract_wrappers/generated --backend ethers && prettier --write 'src/contract_wrappers/generated/**.ts'", "lint": "tslint --project .", "coverage:report:text": "istanbul report text", "coverage:report:html": "istanbul report html && open coverage/index.html", @@ -39,6 +39,7 @@ }, "homepage": "https://github.com/0xProject/0x-monorepo/packages/contracts/README.md", "devDependencies": { + "@0xproject/abi-gen": "^0.2.13", "@0xproject/dev-utils": "^0.4.1", "@0xproject/tslint-config": "^0.4.17", "@types/lodash": "4.14.104", -- cgit v1.2.3 From a6773b85d2a518c5bc636d889a20ee31bd809cc7 Mon Sep 17 00:00:00 2001 From: Fabio Berger Date: Mon, 14 May 2018 19:32:32 +0200 Subject: Fix sol-compiler binary so it can be called directly from packages --- packages/contracts/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'packages/contracts') diff --git a/packages/contracts/package.json b/packages/contracts/package.json index ec41f951b..cdd5417c4 100644 --- a/packages/contracts/package.json +++ b/packages/contracts/package.json @@ -16,7 +16,7 @@ "test:coverage": "SOLIDITY_COVERAGE=true run-s build run_mocha coverage:report:text coverage:report:lcov", "run_mocha": "mocha 'lib/test/**/*.js' --timeout 100000 --bail --exit", "compile:comment": "Yarn workspaces do not link binaries correctly so we need to reference them directly https://github.com/yarnpkg/yarn/issues/3846", - "compile": "node ../sol-compiler/lib/src/cli.js", + "compile": "sol-compiler", "clean": "shx rm -rf lib src/contract_wrappers/generated", "generate_contract_wrappers": "abi-gen --abis ${npm_package_config_abis} --template ../contract_templates/contract.handlebars --partials '../contract_templates/partials/**/*.handlebars' --output src/contract_wrappers/generated --backend ethers && prettier --write 'src/contract_wrappers/generated/**.ts'", "lint": "tslint --project .", -- cgit v1.2.3 From f86cc0dc7a5d75792b8ef7a38cbf9bba04cb6ab4 Mon Sep 17 00:00:00 2001 From: Alex Browne Date: Wed, 9 May 2018 13:29:43 -0700 Subject: Document Node.js version requirement and add it to package.json --- packages/contracts/package.json | 3 +++ 1 file changed, 3 insertions(+) (limited to 'packages/contracts') diff --git a/packages/contracts/package.json b/packages/contracts/package.json index 557effca2..6cc07d0dc 100644 --- a/packages/contracts/package.json +++ b/packages/contracts/package.json @@ -2,6 +2,9 @@ "private": true, "name": "contracts", "version": "2.1.28", + "engines": { + "node" : ">=8.0.0" + }, "description": "Smart contract components of 0x protocol", "main": "index.js", "directories": { -- cgit v1.2.3 From fdeab0475c956c48ab79bb5238ae60e732b14e11 Mon Sep 17 00:00:00 2001 From: Alex Browne Date: Thu, 10 May 2018 11:46:02 -0700 Subject: Change minimum Node version to 6.12 --- packages/contracts/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'packages/contracts') diff --git a/packages/contracts/package.json b/packages/contracts/package.json index 6cc07d0dc..7efcb6862 100644 --- a/packages/contracts/package.json +++ b/packages/contracts/package.json @@ -3,7 +3,7 @@ "name": "contracts", "version": "2.1.28", "engines": { - "node" : ">=8.0.0" + "node" : ">=6.12" }, "description": "Smart contract components of 0x protocol", "main": "index.js", -- cgit v1.2.3