aboutsummaryrefslogtreecommitdiffstats
path: root/src/contract_wrappers/contract_wrapper.ts
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/contract_wrappers/contract_wrapper.ts
parentee73659f16dd70f15fa883e8d512e0da893b1393 (diff)
downloaddexon-sol-tools-d34ea79d939beaf677c6730fe6e84e25a687d59f.tar
dexon-sol-tools-d34ea79d939beaf677c6730fe6e84e25a687d59f.tar.gz
dexon-sol-tools-d34ea79d939beaf677c6730fe6e84e25a687d59f.tar.bz2
dexon-sol-tools-d34ea79d939beaf677c6730fe6e84e25a687d59f.tar.lz
dexon-sol-tools-d34ea79d939beaf677c6730fe6e84e25a687d59f.tar.xz
dexon-sol-tools-d34ea79d939beaf677c6730fe6e84e25a687d59f.tar.zst
dexon-sol-tools-d34ea79d939beaf677c6730fe6e84e25a687d59f.zip
Push unsubscribe to the base class rather than super
Diffstat (limited to 'src/contract_wrappers/contract_wrapper.ts')
-rw-r--r--src/contract_wrappers/contract_wrapper.ts29
1 files changed, 16 insertions, 13 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>>> {