diff options
author | Jacob Evans <dekz@dekz.net> | 2017-11-16 08:31:08 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-11-16 08:31:08 +0800 |
commit | 9ee04fb14c510c6633d288b212f4a8b9d1d640de (patch) | |
tree | 2f0be49e2c28bc6d3a4a0c791cff0ebc34c083c7 /packages/0x.js | |
parent | e9a5ae21e0e738082924da24b62bb44a4df84286 (diff) | |
parent | 141f185c72959fb9470532fce5cfad7a06283723 (diff) | |
download | dexon-sol-tools-9ee04fb14c510c6633d288b212f4a8b9d1d640de.tar dexon-sol-tools-9ee04fb14c510c6633d288b212f4a8b9d1d640de.tar.gz dexon-sol-tools-9ee04fb14c510c6633d288b212f4a8b9d1d640de.tar.bz2 dexon-sol-tools-9ee04fb14c510c6633d288b212f4a8b9d1d640de.tar.lz dexon-sol-tools-9ee04fb14c510c6633d288b212f4a8b9d1d640de.tar.xz dexon-sol-tools-9ee04fb14c510c6633d288b212f4a8b9d1d640de.tar.zst dexon-sol-tools-9ee04fb14c510c6633d288b212f4a8b9d1d640de.zip |
Merge branch 'development' into feature/track-zrx-movements
Diffstat (limited to 'packages/0x.js')
-rw-r--r-- | packages/0x.js/CHANGELOG.md | 5 | ||||
-rw-r--r-- | packages/0x.js/src/index.ts | 2 | ||||
-rw-r--r-- | packages/0x.js/src/order_watcher/event_watcher.ts | 2 | ||||
-rw-r--r-- | packages/0x.js/src/order_watcher/order_state_watcher.ts | 14 | ||||
-rw-r--r-- | packages/0x.js/src/types.ts | 13 |
5 files changed, 14 insertions, 22 deletions
diff --git a/packages/0x.js/CHANGELOG.md b/packages/0x.js/CHANGELOG.md index 56a1e1ab0..d8b49abc4 100644 --- a/packages/0x.js/CHANGELOG.md +++ b/packages/0x.js/CHANGELOG.md @@ -1,7 +1,8 @@ # CHANGELOG -Pending +vx.x.x ------------------------ + * Remove support for Async callback types when used in Subscribe functions * In OrderWatcher subscribe to ZRX Token Transfer and Approval events when maker token is different (#225) v0.25.1 - _November 13, 2017_ @@ -12,7 +13,7 @@ v0.25.1 - _November 13, 2017_ v0.23.0 - _November 12, 2017_ ------------------------ * Fixed unhandled promise rejection error in subscribe methods (#209) - * Subscribe callbacks now receive an error object as their first argument + * Subscribe callbacks now receive an error object as their first argument v0.22.6 - _November 10, 2017_ ------------------------ diff --git a/packages/0x.js/src/index.ts b/packages/0x.js/src/index.ts index 1b3e893ba..e529e2858 100644 --- a/packages/0x.js/src/index.ts +++ b/packages/0x.js/src/index.ts @@ -6,8 +6,6 @@ export { ECSignature, ZeroExError, EventCallback, - EventCallbackAsync, - EventCallbackSync, ExchangeContractErrs, ContractEvent, Token, diff --git a/packages/0x.js/src/order_watcher/event_watcher.ts b/packages/0x.js/src/order_watcher/event_watcher.ts index 81529a98c..c39431f6d 100644 --- a/packages/0x.js/src/order_watcher/event_watcher.ts +++ b/packages/0x.js/src/order_watcher/event_watcher.ts @@ -81,7 +81,7 @@ export class EventWatcher { ...log, }; if (!_.isUndefined(this._intervalIdIfExists)) { - await callback(logEvent); + callback(logEvent); } } } diff --git a/packages/0x.js/src/order_watcher/order_state_watcher.ts b/packages/0x.js/src/order_watcher/order_state_watcher.ts index 0051aaf5b..33fa69b1c 100644 --- a/packages/0x.js/src/order_watcher/order_state_watcher.ts +++ b/packages/0x.js/src/order_watcher/order_state_watcher.ts @@ -52,7 +52,7 @@ interface OrderByOrderHash { export class OrderStateWatcher { private _orderByOrderHash: OrderByOrderHash = {}; private _dependentOrderHashes: DependentOrderHashes = {}; - private _callbackIfExistsAsync?: OnOrderStateChangeCallback; + private _callbackIfExists?: OnOrderStateChangeCallback; private _eventWatcher: EventWatcher; private _web3Wrapper: Web3Wrapper; private _abiDecoder: AbiDecoder; @@ -109,22 +109,22 @@ export class OrderStateWatcher { */ public subscribe(callback: OnOrderStateChangeCallback): void { assert.isFunction('callback', callback); - if (!_.isUndefined(this._callbackIfExistsAsync)) { + if (!_.isUndefined(this._callbackIfExists)) { throw new Error(ZeroExError.SubscriptionAlreadyPresent); } - this._callbackIfExistsAsync = callback; + this._callbackIfExists = callback; this._eventWatcher.subscribe(this._onEventWatcherCallbackAsync.bind(this)); } /** * Ends an orderStateWatcher subscription. */ public unsubscribe(): void { - if (_.isUndefined(this._callbackIfExistsAsync)) { + if (_.isUndefined(this._callbackIfExists)) { throw new Error(ZeroExError.SubscriptionNotFound); } this._balanceAndProxyAllowanceLazyStore.deleteAll(); this._orderFilledCancelledLazyStore.deleteAll(); - delete this._callbackIfExistsAsync; + delete this._callbackIfExists; this._eventWatcher.unsubscribe(); } private async _onEventWatcherCallbackAsync(log: LogEvent): Promise<void> { @@ -207,10 +207,10 @@ export class OrderStateWatcher { // Most of these calls will never reach the network because the data is fetched from stores // and only updated when cache is invalidated const orderState = await this._orderStateUtils.getOrderStateAsync(signedOrder); - if (_.isUndefined(this._callbackIfExistsAsync)) { + if (_.isUndefined(this._callbackIfExists)) { break; // Unsubscribe was called } - await this._callbackIfExistsAsync(orderState); + this._callbackIfExists(orderState); } } private async addToDependentOrderHashesAsync(signedOrder: SignedOrder, orderHash: string): Promise<void> { diff --git a/packages/0x.js/src/types.ts b/packages/0x.js/src/types.ts index 71089f9a1..39e5fa9f2 100644 --- a/packages/0x.js/src/types.ts +++ b/packages/0x.js/src/types.ts @@ -42,13 +42,8 @@ export type OrderValues = [BigNumber, BigNumber, BigNumber, export type LogEvent = Web3.LogEntryEvent; export type DecodedLogEvent<ArgsType> = Web3.DecodedLogEntryEvent<ArgsType>; -export type EventCallbackAsync<ArgsType> = (err: null|Error, log?: DecodedLogEvent<ArgsType>) => Promise<void>; -export type EventCallbackSync<ArgsType> = (err: null|Error, log?: DecodedLogEvent<ArgsType>) => void; -export type EventCallback<ArgsType> = EventCallbackSync<ArgsType>|EventCallbackAsync<ArgsType>; - -export type EventWatcherCallbackSync = (log: LogEvent) => void; -export type EventWatcherCallbackAsync = (log: LogEvent) => Promise<void>; -export type EventWatcherCallback = EventWatcherCallbackSync|EventWatcherCallbackAsync; +export type EventCallback<ArgsType> = (err: null|Error, log?: DecodedLogEvent<ArgsType>) => void; +export type EventWatcherCallback = (log: LogEvent) => void; export interface ExchangeContract extends Web3.ContractInstance { isValidSignature: { @@ -507,9 +502,7 @@ export interface OrderStateInvalid { export type OrderState = OrderStateValid|OrderStateInvalid; -export type OnOrderStateChangeCallbackSync = (orderState: OrderState) => void; -export type OnOrderStateChangeCallbackAsync = (orderState: OrderState) => Promise<void>; -export type OnOrderStateChangeCallback = OnOrderStateChangeCallbackAsync|OnOrderStateChangeCallbackSync; +export type OnOrderStateChangeCallback = (orderState: OrderState) => void; export interface TransactionReceipt { blockHash: string; |