Skip to content

Commit

Permalink
Remove web3 shim and related test
Browse files Browse the repository at this point in the history
  • Loading branch information
yrliou committed Oct 25, 2022
1 parent cd2f618 commit a155717
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 62 deletions.
26 changes: 0 additions & 26 deletions browser/brave_wallet/send_transaction_browsertest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -807,30 +807,4 @@ IN_PROC_BROWSER_TEST_F(SendTransactionBrowserTest,
true);
}

IN_PROC_BROWSER_TEST_F(SendTransactionBrowserTest,
EnsurePropertiesCantBeDeleted) {
GURL url =
https_server_for_files()->GetURL("a.com", "/send_transaction.html");
ASSERT_TRUE(ui_test_utils::NavigateToURL(browser(), url));
EXPECT_TRUE(WaitForLoadStop(web_contents()));
ASSERT_EQ(EvalJs(web_contents(), "ensurePropertiesCantBeDeleted()",
content::EXECUTE_SCRIPT_USE_MANUAL_REPLY)
.ExtractBool(),
true);
}

IN_PROC_BROWSER_TEST_F(SendTransactionBrowserTest,
EnsurePropertiesCantBeDeletedNoOverwrite) {
brave_wallet_service_->SetDefaultEthereumWallet(
mojom::DefaultWallet::BraveWallet);
GURL url =
https_server_for_files()->GetURL("a.com", "/send_transaction.html");
ASSERT_TRUE(ui_test_utils::NavigateToURL(browser(), url));
EXPECT_TRUE(WaitForLoadStop(web_contents()));
ASSERT_EQ(EvalJs(web_contents(), "ensurePropertiesCantBeDeleted()",
content::EXECUTE_SCRIPT_USE_MANUAL_REPLY)
.ExtractBool(),
true);
}

} // namespace brave_wallet
28 changes: 0 additions & 28 deletions components/brave_wallet/resources/ethereum_provider.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,32 +27,4 @@
writable: false
}
})

var alreadyLogged = false
var logweb3Warning = () => {
if (!alreadyLogged) {
console.warn('You are accessing the window.web3 shim. This object is deprecated, please use window.ethereum instead.')
alreadyLogged = true
}
}
const web3Shim = {
__isMetaMaskShim__: true,
currentProvider: window.ethereum
}
const web3Proxy = new Proxy(web3Shim, {
get: (...args) => {
logweb3Warning()
return Reflect.get(...args)
},
set: (...args) => {
logweb3Warning()
return Reflect.set(...args)
}
})
$Object.defineProperty(window, 'web3', {
value: web3Proxy,
enumerable: false,
configurable: true,
writable: true,
})
})()
8 changes: 0 additions & 8 deletions test/data/brave-wallet/send_transaction.html
Original file line number Diff line number Diff line change
Expand Up @@ -99,14 +99,6 @@
window.ethereum._metamask.isUnlocked().then(result =>
window.domAutomationController.send(result))
}
function ensurePropertiesCantBeDeleted() {
// window.ethereum properties cannot be deleted AND they return true
// this is for web-compat, for example https://wallet.polygon.technology/
// fails otherwise as it uses a library which tries to delete
// window.ethereum.sendAsync and then uses it. Seriously.
window.domAutomationController.send(delete window.ethereum.sendAsync === true &&
typeof(window.ethereum.sendAsync) === 'function')
}
</script>

<body>
Expand Down

0 comments on commit a155717

Please sign in to comment.