@@ -776,15 +776,19 @@ export class BaseProvider extends Provider {
776
776
777
777
waitForTransaction ( transactionHash : string , confirmations ?: number ) : Promise < TransactionReceipt > {
778
778
if ( confirmations == null ) { confirmations = 1 ; }
779
- return poll ( ( ) => {
780
- return this . getTransactionReceipt ( transactionHash ) . then ( ( receipt ) => {
781
- if ( confirmations === 0 ) { return receipt ; }
782
- if ( receipt == null || receipt . confirmations < confirmations ) {
783
- return undefined ;
784
- }
785
- return receipt ;
786
- } ) ;
787
- } , { onceBlock : this } ) ;
779
+
780
+ if ( confirmations === 0 ) {
781
+ return this . getTransactionReceipt ( transactionHash ) ;
782
+ }
783
+
784
+ return new Promise ( ( resolve ) => {
785
+ let handler = ( receipt : TransactionReceipt ) => {
786
+ if ( receipt . confirmations < confirmations ) { return ; }
787
+ this . removeListener ( transactionHash , handler ) ;
788
+ resolve ( receipt ) ;
789
+ }
790
+ this . on ( transactionHash , handler ) ;
791
+ } ) ;
788
792
}
789
793
790
794
getBlockNumber ( ) : Promise < number > {
@@ -1306,13 +1310,18 @@ export class BaseProvider extends Provider {
1306
1310
} ) ;
1307
1311
}
1308
1312
1309
- removeAllListeners ( eventName : EventType ) : Provider {
1310
- let eventTag = getEventTag ( eventName ) ;
1311
- this . _events = this . _events . filter ( ( event ) => {
1312
- return ( event . tag !== eventTag ) ;
1313
- } ) ;
1313
+ removeAllListeners ( eventName ?: EventType ) : Provider {
1314
+ if ( eventName == null ) {
1315
+ this . _events = [ ] ;
1316
+ this . _stopPending ( ) ;
1317
+ } else {
1318
+ let eventTag = getEventTag ( eventName ) ;
1319
+ this . _events = this . _events . filter ( ( event ) => {
1320
+ return ( event . tag !== eventTag ) ;
1321
+ } ) ;
1322
+ if ( eventName === 'pending' ) { this . _stopPending ( ) ; }
1323
+ }
1314
1324
1315
- if ( eventName === 'pending' ) { this . _stopPending ( ) ; }
1316
1325
if ( this . _events . length === 0 ) { this . polling = false ; }
1317
1326
1318
1327
return this ;
@@ -1323,9 +1332,9 @@ export class BaseProvider extends Provider {
1323
1332
1324
1333
let eventTag = getEventTag ( eventName ) ;
1325
1334
this . _events = this . _events . filter ( ( event ) => {
1326
- if ( event . tag !== eventTag ) { return true ; }
1335
+ if ( event . tag !== eventTag || event . listener != listener ) { return true ; }
1327
1336
if ( found ) { return true ; }
1328
- found = false ;
1337
+ found = true ;
1329
1338
return false ;
1330
1339
} ) ;
1331
1340
0 commit comments