aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorLeonid Logvinov <logvinov.leon@gmail.com>2017-11-10 04:44:03 +0800
committerLeonid Logvinov <logvinov.leon@gmail.com>2017-11-10 05:20:31 +0800
commitc9e0b298781ca1522f69cae66ac966a0e4800469 (patch)
treed53806707cd9e5532c88fc3eed3b085644a8f036 /src
parent3a96fec03b5b258a8a2ec5f1c2771cf2a9742e8b (diff)
downloaddexon-0x-contracts-c9e0b298781ca1522f69cae66ac966a0e4800469.tar.gz
dexon-0x-contracts-c9e0b298781ca1522f69cae66ac966a0e4800469.tar.zst
dexon-0x-contracts-c9e0b298781ca1522f69cae66ac966a0e4800469.zip
Add SubscriptionAlreadyPresent error
Diffstat (limited to 'src')
-rw-r--r--src/mempool/order_state_watcher.ts4
-rw-r--r--src/types.ts1
2 files changed, 5 insertions, 0 deletions
diff --git a/src/mempool/order_state_watcher.ts b/src/mempool/order_state_watcher.ts
index 63e812054..d0bf5d89c 100644
--- a/src/mempool/order_state_watcher.ts
+++ b/src/mempool/order_state_watcher.ts
@@ -17,6 +17,7 @@ import {
OnOrderStateChangeCallback,
ExchangeEvents,
TokenEvents,
+ ZeroExError,
} from '../types';
import {Web3Wrapper} from '../web3_wrapper';
@@ -85,6 +86,9 @@ export class OrderStateWatcher {
*/
public subscribe(callback: OnOrderStateChangeCallback, numConfirmations: number): void {
assert.isFunction('callback', callback);
+ if (!_.isUndefined(this._callbackAsync)) {
+ throw new Error(ZeroExError.SubscriptionAlreadyPresent);
+ }
this._callbackAsync = callback;
this._eventWatcher.subscribe(this._onMempoolEventCallbackAsync.bind(this), numConfirmations);
}
diff --git a/src/types.ts b/src/types.ts
index 969f2e96d..246fd8641 100644
--- a/src/types.ts
+++ b/src/types.ts
@@ -16,6 +16,7 @@ export enum ZeroExError {
OutOfGas = 'OUT_OF_GAS',
NoNetworkId = 'NO_NETWORK_ID',
SubscriptionNotFound = 'SUBSCRIPTION_NOT_FOUND',
+ SubscriptionAlreadyPresent = 'SUBSCRIPTION_ALREADY_PRESENT',
}
export enum InternalZeroExError {