diff --git a/packages/common-scripts/src/omnilock-ethereum-displaying.ts b/packages/common-scripts/src/omnilock-ethereum-displaying.ts index 42a5a0b39..510c6608f 100644 --- a/packages/common-scripts/src/omnilock-ethereum-displaying.ts +++ b/packages/common-scripts/src/omnilock-ethereum-displaying.ts @@ -17,23 +17,14 @@ export async function signMessage( digest: BytesLike, provider?: Provider ): Promise { - const internal: Provider = (() => { - if (provider) return provider; - - /* c8 ignore start */ - if ( - typeof window !== "undefined" && - "ethereum" in window && - window.ethereum - ) { - return window.ethereum as Provider; - } + const internal: Provider | undefined = + provider ?? (globalThis as { ethereum?: Provider }).ethereum; + if (!internal) { throw new Error( "No provider found, make sure you have installed MetaMask or the other EIP1193 compatible wallet" ); - /* c8 ignore stop */ - })(); + } const sig = await internal.request({ method: "personal_sign",