From 0999101c584fabdb435d62e957916cc04775538e Mon Sep 17 00:00:00 2001 From: Gabe Rodriguez Date: Mon, 18 Nov 2024 16:18:09 +0100 Subject: [PATCH] Revert "remove inject request (#213)" This reverts commit 900df64bc10a0729a49a35ccd0cf32fb50f3c145. --- .../src/content-scripts/injected-penumbra-global.ts | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/apps/extension/src/content-scripts/injected-penumbra-global.ts b/apps/extension/src/content-scripts/injected-penumbra-global.ts index 1e3f6639..71c1ac2f 100644 --- a/apps/extension/src/content-scripts/injected-penumbra-global.ts +++ b/apps/extension/src/content-scripts/injected-penumbra-global.ts @@ -57,6 +57,16 @@ class PraxInjection { private stateEvents = new EventTarget(); private injection: Readonly = Object.freeze({ + /** + * Meet the 'request' method of the old page API to mitigate incompatibility + * with pd v0.80.0's bundled minifront. This prevents connection failure. + * @todo Remove when bundled frontends are updated beyond `a31d54a` + * @issue https://github.com/prax-wallet/web/issues/175 + */ + request: async () => { + await Promise.resolve(this.port ?? this.postConnectRequest()); + }, + connect: () => Promise.resolve(this.port ?? this.postConnectRequest()), disconnect: () => this.postDisconnectRequest(), isConnected: () => Boolean(this.port && this.presentState === PenumbraState.Connected),