@@ -91,7 +91,7 @@ RequestManager.prototype.setProvider = function (provider, net) {
91
91
92
92
93
93
// reset the old one before changing, if still connected
94
- if ( this . provider && this . provider . connected )
94
+ if ( this . provider && this . provider . connected )
95
95
this . clearSubscriptions ( ) ;
96
96
97
97
this . provider = provider || null ;
@@ -123,17 +123,17 @@ RequestManager.prototype.setProvider = function (provider, net) {
123
123
124
124
// notify all subscriptions about bad close conditions
125
125
this . provider . on ( 'close' , function close ( event ) {
126
- if ( ! _this . _isCleanCloseEvent ( event ) || _this . _isIpcCloseError ( event ) ) {
126
+ if ( ! _this . _isCleanCloseEvent ( event ) || _this . _isIpcCloseError ( event ) ) {
127
127
_this . subscriptions . forEach ( function ( subscription ) {
128
128
subscription . callback ( errors . ConnectionCloseError ( event ) ) ;
129
129
_this . subscriptions . delete ( subscription . subscription . id ) ;
130
130
} ) ;
131
131
132
- if ( _this . provider && _this . provider . emit ) {
132
+ if ( _this . provider && _this . provider . emit ) {
133
133
_this . provider . emit ( 'error' , errors . ConnectionCloseError ( event ) ) ;
134
134
}
135
135
}
136
- if ( _this . provider && _this . provider . emit ) {
136
+ if ( _this . provider && _this . provider . emit ) {
137
137
_this . provider . emit ( 'end' , event ) ;
138
138
}
139
139
} ) ;
@@ -151,7 +151,7 @@ RequestManager.prototype.setProvider = function (provider, net) {
151
151
* @param {Function } callback
152
152
*/
153
153
RequestManager . prototype . send = function ( data , callback ) {
154
- callback = callback || function ( ) { } ;
154
+ callback = callback || function ( ) { } ;
155
155
156
156
if ( ! this . provider ) {
157
157
return callback ( errors . InvalidProvider ( ) ) ;
@@ -163,7 +163,7 @@ RequestManager.prototype.send = function (data, callback) {
163
163
const jsonrpcResultCallback = this . _jsonrpcResultCallback ( callback , jsonrpcPayload )
164
164
165
165
if ( this . provider . request ) {
166
- const callbackRequest = callbackify ( this . provider . request )
166
+ const callbackRequest = callbackify ( this . provider . request . bind ( this . provider ) )
167
167
const requestArgs = { method, params }
168
168
callbackRequest ( requestArgs , callback ) ;
169
169
} else if ( this . provider . sendAsync ) {
@@ -220,7 +220,7 @@ RequestManager.prototype.addSubscription = function (subscription, callback) {
220
220
}
221
221
) ;
222
222
} else {
223
- throw new Error ( 'The provider doesn\'t support subscriptions: ' + this . provider . constructor . name ) ;
223
+ throw new Error ( 'The provider doesn\'t support subscriptions: ' + this . provider . constructor . name ) ;
224
224
}
225
225
} ;
226
226
@@ -273,7 +273,7 @@ RequestManager.prototype.clearSubscriptions = function (keepIsSyncing) {
273
273
}
274
274
275
275
// reset notification callbacks etc.
276
- if ( this . provider . reset )
276
+ if ( this . provider . reset )
277
277
this . provider . reset ( ) ;
278
278
279
279
return true
@@ -320,8 +320,8 @@ RequestManager.prototype._isIpcCloseError = function (event) {
320
320
*
321
321
*/
322
322
RequestManager . prototype . _jsonrpcResultCallback = function ( callback , payload ) {
323
- return function ( err , result ) {
324
- if ( result && result . id && payload . id !== result . id ) {
323
+ return function ( err , result ) {
324
+ if ( result && result . id && payload . id !== result . id ) {
325
325
return callback ( new Error ( `Wrong response id ${ result . id } (expected: ${ payload . id } ) in ${ JSON . stringify ( payload ) } ` ) ) ;
326
326
}
327
327
0 commit comments