diff --git a/apps/remix-ide/src/app/providers/injected-provider.tsx b/apps/remix-ide/src/app/providers/injected-provider.tsx index a89eb7b899..adbb614fe5 100644 --- a/apps/remix-ide/src/app/providers/injected-provider.tsx +++ b/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 }) } } }