fix resolving from error

pull/5370/head
yann300 2 years ago committed by GitHub
parent d674407d69
commit c07998ddeb
  1. 14
      apps/remix-ide/src/app/providers/injected-provider.tsx

@ -57,17 +57,21 @@ export class InjectedProvider extends Plugin implements IProvider {
// This will be displayed on UI tooltip as 'cannot get account list: Environment Updated !!'
if (!this.provider) {
this.call('notification', 'toast', 'No injected provider (e.g Metamask) has been found.')
return reject(new Error('no injected provider found.'))
return resolve({ jsonrpc: '2.0', error: 'no injected provider found', id: data.id })
}
try {
if ((window as any) && typeof (window as any).ethereum.request === "function") (window as any).ethereum.request({ method: "eth_requestAccounts" });
let resultData = await this.provider.currentProvider.send(data.method, data.params)
if (resultData && resultData.jsonrpc && resultData.jsonrpc === '2.0') {
resultData = resultData.result
if (resultData) {
if (resultData.jsonrpc && resultData.jsonrpc === '2.0') {
resultData = resultData.result
}
resolve({ jsonrpc: '2.0', result: resultData, id: data.id })
} else {
resolve({ jsonrpc: '2.0', error: 'no return data provided', id: data.id })
}
resolve({ jsonrpc: '2.0', result: resultData, id: data.id })
} catch (error) {
reject(error)
resolve({ jsonrpc: '2.0', error: error.message, id: data.id })
}
}
}

Loading…
Cancel
Save