aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJacob Evans <jacob@dekz.net>2017-11-12 02:42:42 +0800
committerJacob Evans <jacob@dekz.net>2017-11-12 02:42:42 +0800
commitd34ea79d939beaf677c6730fe6e84e25a687d59f (patch)
tree7b29b467cb4c1e8151766fc1a9d7248552de0747 /src
parentee73659f16dd70f15fa883e8d512e0da893b1393 (diff)
downloaddexon-0x-contracts-d34ea79d939beaf677c6730fe6e84e25a687d59f.tar.gz
dexon-0x-contracts-d34ea79d939beaf677c6730fe6e84e25a687d59f.tar.zst
dexon-0x-contracts-d34ea79d939beaf677c6730fe6e84e25a687d59f.zip
Push unsubscribe to the base class rather than super
Diffstat (limited to 'src')
-rw-r--r--src/contract_wrappers/contract_wrapper.ts29
-rw-r--r--src/contract_wrappers/exchange_wrapper.ts6
-rw-r--r--src/contract_wrappers/token_wrapper.ts6
3 files changed, 16 insertions, 25 deletions
diff --git a/src/contract_wrappers/contract_wrapper.ts b/src/contract_wrappers/contract_wrapper.ts
index 5bdc66b3b..7997b1647 100644
--- a/src/contract_wrappers/contract_wrapper.ts
+++ b/src/contract_wrappers/contract_wrapper.ts
@@ -38,19 +38,10 @@ export class ContractWrapper {
this._onLogAddedSubscriptionToken = undefined;
this._onLogRemovedSubscriptionToken = undefined;
}
- protected _subscribe<ArgsType extends ContractEventArgs>(
- address: string, eventName: ContractEvents, indexFilterValues: IndexedFilterValues, abi: Web3.ContractAbi,
- callback: EventCallback<ArgsType>): string {
- const filter = filterUtils.getFilter(address, eventName, indexFilterValues, abi);
- if (_.isUndefined(this._blockAndLogStreamer)) {
- this._startBlockAndLogStream();
- }
- const filterToken = filterUtils.generateUUID();
- this._filters[filterToken] = filter;
- this._filterCallbacks[filterToken] = callback;
- return filterToken;
- }
- protected unsubscribeAll(): void {
+ /**
+ * Cancels all existing subscriptions
+ */
+ public unsubscribeAll(): void {
const filterTokens = _.keys(this._filterCallbacks);
_.each(filterTokens, filterToken => {
this._unsubscribe(filterToken);
@@ -70,6 +61,18 @@ export class ContractWrapper {
this._stopBlockAndLogStream();
}
}
+ protected _subscribe<ArgsType extends ContractEventArgs>(
+ address: string, eventName: ContractEvents, indexFilterValues: IndexedFilterValues, abi: Web3.ContractAbi,
+ callback: EventCallback<ArgsType>): string {
+ const filter = filterUtils.getFilter(address, eventName, indexFilterValues, abi);
+ if (_.isUndefined(this._blockAndLogStreamer)) {
+ this._startBlockAndLogStream();
+ }
+ const filterToken = filterUtils.generateUUID();
+ this._filters[filterToken] = filter;
+ this._filterCallbacks[filterToken] = callback;
+ return filterToken;
+ }
protected async _getLogsAsync<ArgsType extends ContractEventArgs>(
address: string, eventName: ContractEvents, subscriptionOpts: SubscriptionOpts,
indexFilterValues: IndexedFilterValues, abi: Web3.ContractAbi): Promise<Array<LogWithDecodedArgs<ArgsType>>> {
diff --git a/src/contract_wrappers/exchange_wrapper.ts b/src/contract_wrappers/exchange_wrapper.ts
index 711d883ef..b608e6931 100644
--- a/src/contract_wrappers/exchange_wrapper.ts
+++ b/src/contract_wrappers/exchange_wrapper.ts
@@ -674,12 +674,6 @@ export class ExchangeWrapper extends ContractWrapper {
this._unsubscribe(subscriptionToken);
}
/**
- * Cancels all existing subscriptions
- */
- public unsubscribeAll(): void {
- super.unsubscribeAll();
- }
- /**
* 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.
diff --git a/src/contract_wrappers/token_wrapper.ts b/src/contract_wrappers/token_wrapper.ts
index fbe7354dc..081113964 100644
--- a/src/contract_wrappers/token_wrapper.ts
+++ b/src/contract_wrappers/token_wrapper.ts
@@ -290,12 +290,6 @@ export class TokenWrapper extends ContractWrapper {
);
return logs;
}
- /**
- * Cancels all existing subscriptions
- */
- public unsubscribeAll(): void {
- super.unsubscribeAll();
- }
private _invalidateContractInstancesAsync(): void {
this.unsubscribeAll();
this._tokenContractsByAddress = {};