fix provider

pull/3951/head
Oleksii Kosynskyi 1 year ago
parent 8e9f275613
commit 92a08145ed
No known key found for this signature in database
GPG Key ID: B4A8D3CCE22EA65E
  1. 20
      libs/remix-simulator/src/provider.ts

@ -70,7 +70,7 @@ export class Provider {
}
}
sendAsync (payload: JSONRPCRequestPayload, callback: (err: Error, result?: JSONRPCResponsePayload) => void) {
_send(payload: JSONRPCRequestPayload, callback: (err: Error, result?: JSONRPCResponsePayload) => void) {
// log.info('payload method is ', payload.method) // commented because, this floods the IDE console
if (!this.initialized) {
this.pendingRequests.push({ payload, callback })
@ -96,8 +96,24 @@ export class Provider {
callback(new Error('unknown method ' + payload.method))
}
sendAsync (payload: JSONRPCRequestPayload, callback: (err: Error, result?: JSONRPCResponsePayload) => void) {
return new Promise((resolve,reject)=>{
const cb = (err, result) => {
if(typeof callback==='function'){
callback(err,result)
}
if(err){
console.log('err',err)
return reject(err)
}
return resolve(result)
}
this._send(payload, cb)
})
}
send (payload, callback) {
this.sendAsync(payload, callback || function () {})
return this.sendAsync(payload,callback)
}
isConnected () {

Loading…
Cancel
Save