@@ -215,7 +215,6 @@ function checkTransaction(transaction) {
215215 }
216216
217217 if ( ! transaction . raw ) {
218-
219218 // Very loose providers (e.g. TestRPC) don't provide a signature or raw
220219 if ( transaction . v && transaction . r && transaction . s ) {
221220 var raw = [
@@ -718,7 +717,7 @@ utils.defineProperty(Provider.prototype, 'sendTransaction', function(signedTrans
718717
719718utils . defineProperty ( Provider . prototype , 'call' , function ( transaction ) {
720719 var self = this ;
721- return this . _resolveNames ( transaction , [ 'to' , 'from' ] ) . then ( function ( transaction ) {
720+ return this . _resolveNames ( transaction , [ 'to' , 'from' ] ) . then ( function ( transaction ) {
722721 var params = { transaction : checkTransactionRequest ( transaction ) } ;
723722 return self . perform ( 'call' , params ) . then ( function ( result ) {
724723 return utils . hexlify ( result ) ;
@@ -728,7 +727,7 @@ utils.defineProperty(Provider.prototype, 'call', function(transaction) {
728727
729728utils . defineProperty ( Provider . prototype , 'estimateGas' , function ( transaction ) {
730729 var self = this ;
731- return this . _resolveNames ( transaction , [ 'to' , 'from' ] ) . then ( function ( transaction ) {
730+ return this . _resolveNames ( transaction , [ 'to' , 'from' ] ) . then ( function ( transaction ) {
732731 var params = { transaction : checkTransactionRequest ( transaction ) } ;
733732 return self . perform ( 'estimateGas' , params ) . then ( function ( result ) {
734733 return utils . bigNumberify ( result ) ;
@@ -934,6 +933,9 @@ function getEventString(object) {
934933 if ( object === 'block' ) {
935934 return 'block' ;
936935
936+ } else if ( object === 'pending' ) {
937+ return 'pending' ;
938+
937939 } else if ( utils . isHexString ( object ) ) {
938940 if ( object . length === 66 ) {
939941 return 'tx:' + object ;
@@ -961,6 +963,9 @@ function parseEventString(string) {
961963 } else if ( string === 'block' ) {
962964 return { type : 'block' } ;
963965
966+ } else if ( string === 'pending' ) {
967+ return { type : 'pending' } ;
968+
964969 } else if ( string . substring ( 0 , 8 ) === 'address:' ) {
965970 return { type : 'address' , address : string . substring ( 8 ) } ;
966971
@@ -980,17 +985,26 @@ function parseEventString(string) {
980985 throw new Error ( 'invalid event string' ) ;
981986}
982987
988+ utils . defineProperty ( Provider . prototype , '_startPending' , function ( ) {
989+ console . log ( 'WARNING: this provider does not support pending events' ) ;
990+ } ) ;
991+
992+ utils . defineProperty ( Provider . prototype , '_stopPending' , function ( ) {
993+ } ) ;
994+
983995utils . defineProperty ( Provider . prototype , 'on' , function ( eventName , listener ) {
984996 var key = getEventString ( eventName ) ;
985997 if ( ! this . _events [ key ] ) { this . _events [ key ] = [ ] ; }
986998 this . _events [ key ] . push ( { eventName : eventName , listener : listener , type : 'on' } ) ;
999+ if ( key === 'pending' ) { this . _startPending ( ) ; }
9871000 this . polling = true ;
9881001} ) ;
9891002
9901003utils . defineProperty ( Provider . prototype , 'once' , function ( eventName , listener ) {
9911004 var key = getEventString ( eventName ) ;
9921005 if ( ! this . _events [ key ] ) { this . _events [ key ] = [ ] ; }
9931006 this . _events [ key ] . push ( { eventName : eventName , listener : listener , type : 'once' } ) ;
1007+ if ( key === 'pending' ) { this . _startPending ( ) ; }
9941008 this . polling = true ;
9951009} ) ;
9961010
@@ -1015,7 +1029,11 @@ utils.defineProperty(Provider.prototype, 'emit', function(eventName) {
10151029 }
10161030 }
10171031
1018- if ( listeners . length === 0 ) { delete this . _events [ key ] ; }
1032+ if ( listeners . length === 0 ) {
1033+ delete this . _events [ key ] ;
1034+ if ( key === 'pending' ) { this . _stopPending ( ) ; }
1035+ }
1036+
10191037 if ( this . listenerCount ( ) === 0 ) { this . polling = false ; }
10201038} ) ;
10211039
@@ -1060,4 +1078,8 @@ utils.defineProperty(Provider.prototype, 'removeListener', function(eventName, l
10601078 if ( this . listenerCount ( ) === 0 ) { this . polling = false ; }
10611079} ) ;
10621080
1081+ utils . defineProperty ( Provider , '_formatters' , {
1082+ checkTransactionResponse : checkTransaction
1083+ } ) ;
1084+
10631085module . exports = Provider ;
0 commit comments