From f473d23e8121f488b6234df59b4daead4addccfa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Sim=C3=A3o?= Date: Wed, 9 Oct 2024 14:48:03 +0100 Subject: [PATCH] fix: faulty window access mm-snap (#101) --- .changeset/pretty-phones-worry.md | 5 +++++ packages/sats-wagmi/src/connectors/mm-snap.ts | 8 +++----- 2 files changed, 8 insertions(+), 5 deletions(-) create mode 100644 .changeset/pretty-phones-worry.md diff --git a/.changeset/pretty-phones-worry.md b/.changeset/pretty-phones-worry.md new file mode 100644 index 0000000..bd57977 --- /dev/null +++ b/.changeset/pretty-phones-worry.md @@ -0,0 +1,5 @@ +--- +"@gobob/sats-wagmi": patch +--- + +fix: faulty window access mm-snap diff --git a/packages/sats-wagmi/src/connectors/mm-snap.ts b/packages/sats-wagmi/src/connectors/mm-snap.ts index 857c782..ef6835e 100644 --- a/packages/sats-wagmi/src/connectors/mm-snap.ts +++ b/packages/sats-wagmi/src/connectors/mm-snap.ts @@ -82,8 +82,6 @@ declare global { } } -const { ethereum } = window; - const snapId = 'npm:@gobob/bob-snap'; // TODO: distinguish between payment and ordinals address @@ -101,7 +99,7 @@ class MMSnapConnector extends SatsConnector { async connect(): Promise { try { - const result: any = await ethereum.request({ + const result: any = await window.ethereum.request({ method: 'wallet_requestSnaps', params: { [snapId]: { @@ -132,7 +130,7 @@ class MMSnapConnector extends SatsConnector { } async isReady(): Promise { - const snaps = await ethereum.request({ + const snaps = await window.ethereum.request({ method: 'wallet_getSnaps' }); @@ -269,7 +267,7 @@ class MMSnapConnector extends SatsConnector { errMsg: string; }): Promise { try { - return (await ethereum.request({ + return (await window.ethereum.request({ method: 'wallet_invokeSnap', params: { snapId,