From 1bac96facc9f4608680e406dcea8bf95dab5f1d5 Mon Sep 17 00:00:00 2001 From: Jan-Felix Date: Tue, 4 Jun 2024 10:46:25 +0200 Subject: [PATCH] prevent other extensions from overriding the injected provider --- extension/src/injection.ts | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/extension/src/injection.ts b/extension/src/injection.ts index 3cf193dc..a8e7e55e 100644 --- a/extension/src/injection.ts +++ b/extension/src/injection.ts @@ -16,7 +16,18 @@ if (window.ethereum) { // inject bridged ethereum provider const injectedProvider = new InjectedProvider() -window.ethereum = injectedProvider +Object.defineProperties(window, { + ethereum: { + get() { + return injectedProvider + }, + set() { + // do nothing + }, + configurable: false, + }, +}) + console.log('injected into', document.title) // establish message bridge for location requests