From 1e4fdcf615502478cbec8711bf6710e093c0c279 Mon Sep 17 00:00:00 2001 From: Leonid Logvinov Date: Mon, 18 Dec 2017 15:35:23 +0100 Subject: Rename SubscriptionOpts to BlockRange --- packages/0x.js/CHANGELOG.md | 9 +++++---- .../0x.js/src/contract_wrappers/contract_wrapper.ts | 6 +++--- .../0x.js/src/contract_wrappers/exchange_wrapper.ts | 10 +++++----- .../0x.js/src/contract_wrappers/token_wrapper.ts | 10 +++++----- packages/0x.js/src/index.ts | 2 +- packages/0x.js/src/types.ts | 2 +- packages/0x.js/src/utils/filter_utils.ts | 8 ++++---- packages/0x.js/test/exchange_wrapper_test.ts | 10 +++++----- packages/0x.js/test/token_wrapper_test.ts | 10 +++++----- packages/json-schemas/CHANGELOG.md | 4 ++++ packages/json-schemas/schemas/block_range_schema.ts | 20 ++++++++++++++++++++ .../json-schemas/schemas/subscription_opts_schema.ts | 20 -------------------- packages/json-schemas/src/schemas.ts | 6 +++--- packages/json-schemas/test/schema_test.ts | 8 ++++---- packages/website/ts/blockchain.ts | 6 +++--- .../ts/containers/zero_ex_js_documentation.tsx | 1 + 16 files changed, 69 insertions(+), 63 deletions(-) create mode 100644 packages/json-schemas/schemas/block_range_schema.ts delete mode 100644 packages/json-schemas/schemas/subscription_opts_schema.ts (limited to 'packages') diff --git a/packages/0x.js/CHANGELOG.md b/packages/0x.js/CHANGELOG.md index 9874b0ca8..962d312d3 100644 --- a/packages/0x.js/CHANGELOG.md +++ b/packages/0x.js/CHANGELOG.md @@ -1,10 +1,11 @@ # CHANGELOG -v0.28.0 - _TBD_ +v0.x.x - _TBD, 2017_ ------------------------ -* Add `etherTokenAddress` arg to `depositAsync` and `withdrawAsync` methods on `zeroEx.etherToken` (#267) -* Removed accidentally included `unsubscribeAll` method from `zeroEx.proxy`, `zeroEx.etherToken` and `zeroEx.tokenRegistry` (#267) -* Removed `etherTokenContractAddress` from `ZeroEx` constructor arg `ZeroExConfig` (#267) + * Add `etherTokenAddress` arg to `depositAsync` and `withdrawAsync` methods on `zeroEx.etherToken` (#267) + * Removed accidentally included `unsubscribeAll` method from `zeroEx.proxy`, `zeroEx.etherToken` and `zeroEx.tokenRegistry` (#267) + * Removed `etherTokenContractAddress` from `ZeroEx` constructor arg `ZeroExConfig` (#267) + * Rename `SubscriptionOpts` to `BlockRange` (#272) v0.27.1 - _November 28, 2017_ ------------------------ diff --git a/packages/0x.js/src/contract_wrappers/contract_wrapper.ts b/packages/0x.js/src/contract_wrappers/contract_wrapper.ts index 46916ebf4..3f07e4e47 100644 --- a/packages/0x.js/src/contract_wrappers/contract_wrapper.ts +++ b/packages/0x.js/src/contract_wrappers/contract_wrapper.ts @@ -7,6 +7,7 @@ import * as Web3 from 'web3'; import { Artifact, BlockParamLiteral, + BlockRange, ContractEventArgs, ContractEvents, EventCallback, @@ -14,7 +15,6 @@ import { InternalZeroExError, LogWithDecodedArgs, RawLog, - SubscriptionOpts, ZeroExError, } from '../types'; import {AbiDecoder} from '../utils/abi_decoder'; @@ -83,9 +83,9 @@ export class ContractWrapper { return filterToken; } protected async _getLogsAsync( - address: string, eventName: ContractEvents, subscriptionOpts: SubscriptionOpts, + address: string, eventName: ContractEvents, blockRange: BlockRange, indexFilterValues: IndexedFilterValues, abi: Web3.ContractAbi): Promise>> { - const filter = filterUtils.getFilter(address, eventName, indexFilterValues, abi, subscriptionOpts); + const filter = filterUtils.getFilter(address, eventName, indexFilterValues, abi, blockRange); const logs = await this._web3Wrapper.getLogsAsync(filter); const logsWithDecodedArguments = _.map(logs, this._tryToDecodeLogOrNoop.bind(this)); return logsWithDecodedArguments; diff --git a/packages/0x.js/src/contract_wrappers/exchange_wrapper.ts b/packages/0x.js/src/contract_wrappers/exchange_wrapper.ts index 3ca5695c4..7739defc0 100644 --- a/packages/0x.js/src/contract_wrappers/exchange_wrapper.ts +++ b/packages/0x.js/src/contract_wrappers/exchange_wrapper.ts @@ -25,7 +25,7 @@ import { OrderTransactionOpts, OrderValues, SignedOrder, - SubscriptionOpts, + BlockRange, ValidateOrderFillableOpts, } from '../types'; import {AbiDecoder} from '../utils/abi_decoder'; @@ -616,20 +616,20 @@ export class ExchangeWrapper extends ContractWrapper { /** * Gets historical logs without creating a subscription * @param eventName The exchange contract event you would like to subscribe to. - * @param subscriptionOpts Subscriptions options that let you configure the subscription. + * @param blockRange Subscriptions options that let you configure the subscription. * @param indexFilterValues An object where the keys are indexed args returned by the event and * the value is the value you are interested in. E.g `{_from: aUserAddressHex}` * @return Array of logs that match the parameters */ public async getLogsAsync( - eventName: ExchangeEvents, subscriptionOpts: SubscriptionOpts, indexFilterValues: IndexedFilterValues, + eventName: ExchangeEvents, blockRange: BlockRange, indexFilterValues: IndexedFilterValues, ): Promise>> { assert.doesBelongToStringEnum('eventName', eventName, ExchangeEvents); - assert.doesConformToSchema('subscriptionOpts', subscriptionOpts, schemas.subscriptionOptsSchema); + assert.doesConformToSchema('blockRange', blockRange, schemas.blockRangeSchema); assert.doesConformToSchema('indexFilterValues', indexFilterValues, schemas.indexFilterValuesSchema); const exchangeContractAddress = this.getContractAddress(); const logs = await this._getLogsAsync( - exchangeContractAddress, eventName, subscriptionOpts, indexFilterValues, artifacts.ExchangeArtifact.abi, + exchangeContractAddress, eventName, blockRange, indexFilterValues, artifacts.ExchangeArtifact.abi, ); return logs; } diff --git a/packages/0x.js/src/contract_wrappers/token_wrapper.ts b/packages/0x.js/src/contract_wrappers/token_wrapper.ts index eccb74871..419b33285 100644 --- a/packages/0x.js/src/contract_wrappers/token_wrapper.ts +++ b/packages/0x.js/src/contract_wrappers/token_wrapper.ts @@ -5,11 +5,11 @@ import * as _ from 'lodash'; import {artifacts} from '../artifacts'; import { + BlockRange, EventCallback, IndexedFilterValues, LogWithDecodedArgs, MethodOpts, - SubscriptionOpts, TokenContractEventArgs, TokenEvents, TransactionOpts, @@ -291,20 +291,20 @@ export class TokenWrapper extends ContractWrapper { * Gets historical logs without creating a subscription * @param tokenAddress An address of the token that emmited the logs. * @param eventName The token contract event you would like to subscribe to. - * @param subscriptionOpts Subscriptions options that let you configure the subscription. + * @param blockRange Subscriptions options that let you configure the subscription. * @param indexFilterValues An object where the keys are indexed args returned by the event and * the value is the value you are interested in. E.g `{_from: aUserAddressHex}` * @return Array of logs that match the parameters */ public async getLogsAsync( - tokenAddress: string, eventName: TokenEvents, subscriptionOpts: SubscriptionOpts, + tokenAddress: string, eventName: TokenEvents, blockRange: BlockRange, indexFilterValues: IndexedFilterValues): Promise>> { assert.isETHAddressHex('tokenAddress', tokenAddress); assert.doesBelongToStringEnum('eventName', eventName, TokenEvents); - assert.doesConformToSchema('subscriptionOpts', subscriptionOpts, schemas.subscriptionOptsSchema); + assert.doesConformToSchema('blockRange', blockRange, schemas.blockRangeSchema); assert.doesConformToSchema('indexFilterValues', indexFilterValues, schemas.indexFilterValuesSchema); const logs = await this._getLogsAsync( - tokenAddress, eventName, subscriptionOpts, indexFilterValues, artifacts.TokenArtifact.abi, + tokenAddress, eventName, blockRange, indexFilterValues, artifacts.TokenArtifact.abi, ); return logs; } diff --git a/packages/0x.js/src/index.ts b/packages/0x.js/src/index.ts index 2f5296a9f..b75ca4fa3 100644 --- a/packages/0x.js/src/index.ts +++ b/packages/0x.js/src/index.ts @@ -12,7 +12,7 @@ export { ExchangeEvents, TokenEvents, IndexedFilterValues, - SubscriptionOpts, + BlockRange, BlockParam, OrderCancellationRequest, OrderFillRequest, diff --git a/packages/0x.js/src/types.ts b/packages/0x.js/src/types.ts index fb3cfa6df..844ac9ed9 100644 --- a/packages/0x.js/src/types.ts +++ b/packages/0x.js/src/types.ts @@ -217,7 +217,7 @@ export enum BlockParamLiteral { export type BlockParam = BlockParamLiteral|number; -export interface SubscriptionOpts { +export interface BlockRange { fromBlock: BlockParam; toBlock: BlockParam; } diff --git a/packages/0x.js/src/utils/filter_utils.ts b/packages/0x.js/src/utils/filter_utils.ts index 57c3ee71c..65161c33e 100644 --- a/packages/0x.js/src/utils/filter_utils.ts +++ b/packages/0x.js/src/utils/filter_utils.ts @@ -4,7 +4,7 @@ import * as _ from 'lodash'; import * as uuid from 'uuid/v4'; import * as Web3 from 'web3'; -import {ContractEvents, IndexedFilterValues, SubscriptionOpts} from '../types'; +import {BlockRange, ContractEvents, IndexedFilterValues} from '../types'; const TOPIC_LENGTH = 32; @@ -14,7 +14,7 @@ export const filterUtils = { }, getFilter(address: string, eventName: ContractEvents, indexFilterValues: IndexedFilterValues, abi: Web3.ContractAbi, - subscriptionOpts?: SubscriptionOpts): Web3.FilterObject { + blockRange?: BlockRange): Web3.FilterObject { const eventAbi = _.find(abi, {name: eventName}) as Web3.EventAbi; const eventSignature = filterUtils.getEventSignatureFromAbiByName(eventAbi, eventName); const topicForEventSignature = ethUtil.addHexPrefix(jsSHA3.keccak256(eventSignature)); @@ -24,9 +24,9 @@ export const filterUtils = { address, topics, }; - if (!_.isUndefined(subscriptionOpts)) { + if (!_.isUndefined(blockRange)) { filter = { - ...subscriptionOpts, + ...blockRange, ...filter, }; } diff --git a/packages/0x.js/test/exchange_wrapper_test.ts b/packages/0x.js/test/exchange_wrapper_test.ts index 51b511dbf..6605e7e52 100644 --- a/packages/0x.js/test/exchange_wrapper_test.ts +++ b/packages/0x.js/test/exchange_wrapper_test.ts @@ -13,7 +13,7 @@ import { OrderCancellationRequest, OrderFillRequest, SignedOrder, - SubscriptionOpts, + BlockRange, Token, ZeroEx, } from '../src'; @@ -760,7 +760,7 @@ describe('ExchangeWrapper', () => { let takerAddress: string; const fillableAmount = new BigNumber(5); const shouldThrowOnInsufficientBalanceOrAllowance = true; - const subscriptionOpts: SubscriptionOpts = { + const blockRange: BlockRange = { fromBlock: 0, toBlock: BlockParamLiteral.Latest, }; @@ -781,7 +781,7 @@ describe('ExchangeWrapper', () => { await zeroEx.awaitTransactionMinedAsync(txHash); const eventName = ExchangeEvents.LogFill; const indexFilterValues = {}; - const logs = await zeroEx.exchange.getLogsAsync(eventName, subscriptionOpts, indexFilterValues); + const logs = await zeroEx.exchange.getLogsAsync(eventName, blockRange, indexFilterValues); expect(logs).to.have.length(1); expect(logs[0].event).to.be.equal(eventName); }); @@ -795,7 +795,7 @@ describe('ExchangeWrapper', () => { await zeroEx.awaitTransactionMinedAsync(txHash); const differentEventName = ExchangeEvents.LogCancel; const indexFilterValues = {}; - const logs = await zeroEx.exchange.getLogsAsync(differentEventName, subscriptionOpts, indexFilterValues); + const logs = await zeroEx.exchange.getLogsAsync(differentEventName, blockRange, indexFilterValues); expect(logs).to.have.length(0); }); it('should only get the logs with the correct indexed fields', async () => { @@ -821,7 +821,7 @@ describe('ExchangeWrapper', () => { maker: differentMakerAddress, }; const logs = await zeroEx.exchange.getLogsAsync( - eventName, subscriptionOpts, indexFilterValues, + eventName, blockRange, indexFilterValues, ); expect(logs).to.have.length(1); const args = logs[0].args; diff --git a/packages/0x.js/test/token_wrapper_test.ts b/packages/0x.js/test/token_wrapper_test.ts index 70637dbfe..5111a05d2 100644 --- a/packages/0x.js/test/token_wrapper_test.ts +++ b/packages/0x.js/test/token_wrapper_test.ts @@ -8,7 +8,7 @@ import * as Web3 from 'web3'; import { ApprovalContractEventArgs, DecodedLogEvent, - SubscriptionOpts, + BlockRange, Token, TokenEvents, TransferContractEventArgs, @@ -433,7 +433,7 @@ describe('TokenWrapper', () => { describe('#getLogsAsync', () => { let tokenAddress: string; let tokenTransferProxyAddress: string; - const subscriptionOpts: SubscriptionOpts = { + const blockRange: BlockRange = { fromBlock: 0, toBlock: BlockParamLiteral.Latest, }; @@ -449,7 +449,7 @@ describe('TokenWrapper', () => { const eventName = TokenEvents.Approval; const indexFilterValues = {}; const logs = await zeroEx.token.getLogsAsync( - tokenAddress, eventName, subscriptionOpts, indexFilterValues, + tokenAddress, eventName, blockRange, indexFilterValues, ); expect(logs).to.have.length(1); const args = logs[0].args; @@ -464,7 +464,7 @@ describe('TokenWrapper', () => { const differentEventName = TokenEvents.Transfer; const indexFilterValues = {}; const logs = await zeroEx.token.getLogsAsync( - tokenAddress, differentEventName, subscriptionOpts, indexFilterValues, + tokenAddress, differentEventName, blockRange, indexFilterValues, ); expect(logs).to.have.length(0); }); @@ -478,7 +478,7 @@ describe('TokenWrapper', () => { _owner: coinbase, }; const logs = await zeroEx.token.getLogsAsync( - tokenAddress, eventName, subscriptionOpts, indexFilterValues, + tokenAddress, eventName, blockRange, indexFilterValues, ); expect(logs).to.have.length(1); const args = logs[0].args; diff --git a/packages/json-schemas/CHANGELOG.md b/packages/json-schemas/CHANGELOG.md index 9f080adeb..81225e5de 100644 --- a/packages/json-schemas/CHANGELOG.md +++ b/packages/json-schemas/CHANGELOG.md @@ -1,5 +1,9 @@ # CHANGELOG +v0.x.x - _TBD, 2017_ +------------------------ + * Rename `subscriptionOptsSchema` to `blockRangeSchema` (#272) + v0.6.7 - _Nov. 14, 2017_ ------------------------ * Re-publish JSON-schema previously published under NPM package 0x-json-schemas diff --git a/packages/json-schemas/schemas/block_range_schema.ts b/packages/json-schemas/schemas/block_range_schema.ts new file mode 100644 index 000000000..b264cb66e --- /dev/null +++ b/packages/json-schemas/schemas/block_range_schema.ts @@ -0,0 +1,20 @@ +export const blockParamSchema = { + id: '/BlockParam', + oneOf: [ + { + type: 'number', + }, + { + enum: ['latest', 'earliest', 'pending'], + }, + ], +}; + +export const blockRangeSchema = { + id: '/BlockRange', + properties: { + fromBlock: {$ref: '/BlockParam'}, + toBlock: {$ref: '/BlockParam'}, + }, + type: 'object', +}; diff --git a/packages/json-schemas/schemas/subscription_opts_schema.ts b/packages/json-schemas/schemas/subscription_opts_schema.ts deleted file mode 100644 index a476e6963..000000000 --- a/packages/json-schemas/schemas/subscription_opts_schema.ts +++ /dev/null @@ -1,20 +0,0 @@ -export const blockParamSchema = { - id: '/BlockParam', - oneOf: [ - { - type: 'number', - }, - { - enum: ['latest', 'earliest', 'pending'], - }, - ], -}; - -export const subscriptionOptsSchema = { - id: '/SubscriptionOpts', - properties: { - fromBlock: {$ref: '/BlockParam'}, - toBlock: {$ref: '/BlockParam'}, - }, - type: 'object', -}; diff --git a/packages/json-schemas/src/schemas.ts b/packages/json-schemas/src/schemas.ts index 69164cbc7..487f4fa5c 100644 --- a/packages/json-schemas/src/schemas.ts +++ b/packages/json-schemas/src/schemas.ts @@ -57,8 +57,8 @@ import { } from '../schemas/signed_orders_schema'; import { blockParamSchema, - subscriptionOptsSchema, -} from '../schemas/subscription_opts_schema'; + blockRangeSchema, +} from '../schemas/block_range_schema'; import { tokenSchema, } from '../schemas/token_schema'; @@ -81,7 +81,7 @@ export const schemas = { signedOrderSchema, signedOrdersSchema, blockParamSchema, - subscriptionOptsSchema, + blockRangeSchema, tokenSchema, jsNumber, txDataSchema, diff --git a/packages/json-schemas/test/schema_test.ts b/packages/json-schemas/test/schema_test.ts index 067b02827..e729c1925 100644 --- a/packages/json-schemas/test/schema_test.ts +++ b/packages/json-schemas/test/schema_test.ts @@ -23,7 +23,7 @@ const { signedOrderSchema, signedOrdersSchema, blockParamSchema, - subscriptionOptsSchema, + blockRangeSchema, tokenSchema, jsNumber, txDataSchema, @@ -170,21 +170,21 @@ describe('Schema', () => { validateAgainstSchema(testCases, blockParamSchema, shouldFail); }); }); - describe('#subscriptionOptsSchema', () => { + describe('#blockRangeSchema', () => { it('should validate valid subscription opts', () => { const testCases = [ {fromBlock: 42, toBlock: 'latest'}, {fromBlock: 42}, {}, ]; - validateAgainstSchema(testCases, subscriptionOptsSchema); + validateAgainstSchema(testCases, blockRangeSchema); }); it('should fail for invalid subscription opts', () => { const testCases = [ {fromBlock: '42'}, ]; const shouldFail = true; - validateAgainstSchema(testCases, subscriptionOptsSchema, shouldFail); + validateAgainstSchema(testCases, blockRangeSchema, shouldFail); }); }); describe('#tokenSchema', () => { diff --git a/packages/website/ts/blockchain.ts b/packages/website/ts/blockchain.ts index a42b19cff..2a4aabeb2 100644 --- a/packages/website/ts/blockchain.ts +++ b/packages/website/ts/blockchain.ts @@ -1,5 +1,6 @@ import { BlockParam, + BlockRange, DecodedLogEvent, ExchangeContractEventArgs, ExchangeEvents, @@ -9,7 +10,6 @@ import { LogWithDecodedArgs, Order, SignedOrder, - SubscriptionOpts, Token as ZeroExToken, TransactionReceiptWithDecodedLogs, ZeroEx, @@ -524,12 +524,12 @@ export class Blockchain { } private async fetchHistoricalExchangeLogFillEventsAsync(indexFilterValues: IndexedFilterValues) { const fromBlock = tradeHistoryStorage.getFillsLatestBlock(this.userAddress, this.networkId); - const subscriptionOpts: SubscriptionOpts = { + const blockRange: BlockRange = { fromBlock, toBlock: 'latest' as BlockParam, }; const decodedLogs = await this.zeroEx.exchange.getLogsAsync( - ExchangeEvents.LogFill, subscriptionOpts, indexFilterValues, + ExchangeEvents.LogFill, blockRange, indexFilterValues, ); for (const decodedLog of decodedLogs) { if (!this.doesLogEventInvolveUser(decodedLog)) { diff --git a/packages/website/ts/containers/zero_ex_js_documentation.tsx b/packages/website/ts/containers/zero_ex_js_documentation.tsx index 1ce9ba139..ded62d2bc 100644 --- a/packages/website/ts/containers/zero_ex_js_documentation.tsx +++ b/packages/website/ts/containers/zero_ex_js_documentation.tsx @@ -95,6 +95,7 @@ const docsInfoConfig: DocsInfoConfig = { 'ExchangeEvents', 'IndexedFilterValues', 'SubscriptionOpts', + 'BlockRange', 'BlockParam', 'OrderFillOrKillRequest', 'OrderCancellationRequest', -- cgit v1.2.3 From f269ecd95efdd85956f995424474184eea09616f Mon Sep 17 00:00:00 2001 From: Leonid Logvinov Date: Mon, 18 Dec 2017 15:58:52 +0100 Subject: Fix linter error --- packages/json-schemas/src/schemas.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'packages') diff --git a/packages/json-schemas/src/schemas.ts b/packages/json-schemas/src/schemas.ts index 487f4fa5c..854291a71 100644 --- a/packages/json-schemas/src/schemas.ts +++ b/packages/json-schemas/src/schemas.ts @@ -2,6 +2,10 @@ import { addressSchema, numberSchema, } from '../schemas/basic_type_schemas'; +import { + blockParamSchema, + blockRangeSchema, +} from '../schemas/block_range_schema'; import { ecSignatureParameterSchema, ecSignatureSchema, @@ -55,10 +59,6 @@ import { import { signedOrdersSchema, } from '../schemas/signed_orders_schema'; -import { - blockParamSchema, - blockRangeSchema, -} from '../schemas/block_range_schema'; import { tokenSchema, } from '../schemas/token_schema'; -- cgit v1.2.3 From 436d78eb93792e352049c790b10fbeddde199cab Mon Sep 17 00:00:00 2001 From: Leonid Logvinov Date: Mon, 18 Dec 2017 17:06:00 +0100 Subject: Fix linter issues --- packages/0x.js/src/contract_wrappers/exchange_wrapper.ts | 4 ++-- packages/0x.js/test/exchange_wrapper_test.ts | 2 +- packages/0x.js/test/token_wrapper_test.ts | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) (limited to 'packages') diff --git a/packages/0x.js/src/contract_wrappers/exchange_wrapper.ts b/packages/0x.js/src/contract_wrappers/exchange_wrapper.ts index 7739defc0..274f217c6 100644 --- a/packages/0x.js/src/contract_wrappers/exchange_wrapper.ts +++ b/packages/0x.js/src/contract_wrappers/exchange_wrapper.ts @@ -7,6 +7,7 @@ import * as Web3 from 'web3'; import {artifacts} from '../artifacts'; import { BlockParamLiteral, + BlockRange, DecodedLogArgs, ECSignature, EventCallback, @@ -25,7 +26,6 @@ import { OrderTransactionOpts, OrderValues, SignedOrder, - BlockRange, ValidateOrderFillableOpts, } from '../types'; import {AbiDecoder} from '../utils/abi_decoder'; @@ -616,7 +616,7 @@ export class ExchangeWrapper extends ContractWrapper { /** * Gets historical logs without creating a subscription * @param eventName The exchange contract event you would like to subscribe to. - * @param blockRange Subscriptions options that let you configure the subscription. + * @param blockRange Subscriptions options that let you configure the subscription. * @param indexFilterValues An object where the keys are indexed args returned by the event and * the value is the value you are interested in. E.g `{_from: aUserAddressHex}` * @return Array of logs that match the parameters diff --git a/packages/0x.js/test/exchange_wrapper_test.ts b/packages/0x.js/test/exchange_wrapper_test.ts index 6605e7e52..9c55069da 100644 --- a/packages/0x.js/test/exchange_wrapper_test.ts +++ b/packages/0x.js/test/exchange_wrapper_test.ts @@ -5,6 +5,7 @@ import 'mocha'; import * as Web3 from 'web3'; import { + BlockRange, DecodedLogEvent, ExchangeContractErrs, ExchangeEvents, @@ -13,7 +14,6 @@ import { OrderCancellationRequest, OrderFillRequest, SignedOrder, - BlockRange, Token, ZeroEx, } from '../src'; diff --git a/packages/0x.js/test/token_wrapper_test.ts b/packages/0x.js/test/token_wrapper_test.ts index 5111a05d2..48742b663 100644 --- a/packages/0x.js/test/token_wrapper_test.ts +++ b/packages/0x.js/test/token_wrapper_test.ts @@ -7,8 +7,8 @@ import * as Web3 from 'web3'; import { ApprovalContractEventArgs, - DecodedLogEvent, BlockRange, + DecodedLogEvent, Token, TokenEvents, TransferContractEventArgs, -- cgit v1.2.3 From 156dae1d33bd0a19c764262fbf0c9d6743425fc6 Mon Sep 17 00:00:00 2001 From: Leonid Logvinov Date: Tue, 19 Dec 2017 12:03:52 +0100 Subject: Fix comments --- packages/0x.js/src/contract_wrappers/exchange_wrapper.ts | 2 +- packages/0x.js/src/contract_wrappers/token_wrapper.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'packages') diff --git a/packages/0x.js/src/contract_wrappers/exchange_wrapper.ts b/packages/0x.js/src/contract_wrappers/exchange_wrapper.ts index 274f217c6..df793aa06 100644 --- a/packages/0x.js/src/contract_wrappers/exchange_wrapper.ts +++ b/packages/0x.js/src/contract_wrappers/exchange_wrapper.ts @@ -616,7 +616,7 @@ export class ExchangeWrapper extends ContractWrapper { /** * Gets historical logs without creating a subscription * @param eventName The exchange contract event you would like to subscribe to. - * @param blockRange Subscriptions options that let you configure the subscription. + * @param blockRange Block range to get logs from. * @param indexFilterValues An object where the keys are indexed args returned by the event and * the value is the value you are interested in. E.g `{_from: aUserAddressHex}` * @return Array of logs that match the parameters diff --git a/packages/0x.js/src/contract_wrappers/token_wrapper.ts b/packages/0x.js/src/contract_wrappers/token_wrapper.ts index 419b33285..a9eac10e0 100644 --- a/packages/0x.js/src/contract_wrappers/token_wrapper.ts +++ b/packages/0x.js/src/contract_wrappers/token_wrapper.ts @@ -291,7 +291,7 @@ export class TokenWrapper extends ContractWrapper { * Gets historical logs without creating a subscription * @param tokenAddress An address of the token that emmited the logs. * @param eventName The token contract event you would like to subscribe to. - * @param blockRange Subscriptions options that let you configure the subscription. + * @param blockRange Block range to get logs from. * @param indexFilterValues An object where the keys are indexed args returned by the event and * the value is the value you are interested in. E.g `{_from: aUserAddressHex}` * @return Array of logs that match the parameters -- cgit v1.2.3 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 +- 5 files changed, 11 insertions(+), 11 deletions(-) (limited to 'packages') 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", -- 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(-) (limited to 'packages') 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(-) (limited to 'packages') 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(-) (limited to 'packages') 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