From 318250de68b97034ce5cf8c5631dd8bef5288082 Mon Sep 17 00:00:00 2001 From: StephenHeaps <5314553+StephenHeaps@users.noreply.github.com> Date: Fri, 5 May 2023 09:20:34 -0400 Subject: [PATCH] Fix #7392: Error formatting for Ethereum DApp responses (#7393) Fix error formatting for Ethereum DApp responses --- .../Scripts/Paged/WalletEthereumProviderScript.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Sources/Brave/Frontend/UserContent/UserScripts/Scripts_Dynamic/Scripts/Paged/WalletEthereumProviderScript.js b/Sources/Brave/Frontend/UserContent/UserScripts/Scripts_Dynamic/Scripts/Paged/WalletEthereumProviderScript.js index 7780f0ba07c..11897334dff 100644 --- a/Sources/Brave/Frontend/UserContent/UserScripts/Scripts_Dynamic/Scripts/Paged/WalletEthereumProviderScript.js +++ b/Sources/Brave/Frontend/UserContent/UserScripts/Scripts_Dynamic/Scripts/Paged/WalletEthereumProviderScript.js @@ -18,8 +18,11 @@ if (window.isSecureContext) { "args": JSON.stringify(payload) }) .then(resolve, (errorJSON) => { + /* remove `Error: ` prefix. errorJSON=`Error: {code: 1, errorMessage: "Internal error"}` */ + const errorJSONString = new String(errorJSON); + const errorJSONStringSliced = errorJSONString.slice(errorJSONString.indexOf('{')); try { - reject(JSON.parse(errorJSON)) + reject(JSON.parse(errorJSONStringSliced)) } catch(e) { reject(errorJSON) }