From 45dec8ac178d62cc1080ef0e222b2c5ce14122a0 Mon Sep 17 00:00:00 2001 From: Sam Vitello Date: Mon, 11 Jun 2018 14:32:37 -0600 Subject: [PATCH] fix(EventListener): only stop watching if listener exists --- src/utils/EventListener.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/utils/EventListener.js b/src/utils/EventListener.js index 875208f..fd72177 100644 --- a/src/utils/EventListener.js +++ b/src/utils/EventListener.js @@ -180,11 +180,13 @@ class EventListener { * @param {string} contractImplementationInstance - Address of the contract to stop watching */ stopWatchingForEvents = contractImplementationInstance => { - if (contractImplementationInstance) - this.watcherInstances[ + if (contractImplementationInstance) { + const watcherInstance = this.watcherInstances[ contractImplementationInstance.getContractAddress() - ].stopWatching() - else + ] + + if (watcherInstance) watcherInstance.stopWatching() + } else this.contractInstances.forEach(instance => { this.watcherInstances[instance.getContractAddress()].stopWatching() })