From 90030f2dc5d07bacb897001a91916f722da5271f Mon Sep 17 00:00:00 2001 From: Isacco Date: Tue, 24 Oct 2023 09:01:38 +0200 Subject: [PATCH] fix: WC check --- .../beacon-dapp/src/dapp-client/DAppClient.ts | 26 +++++++++++++------ 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/packages/beacon-dapp/src/dapp-client/DAppClient.ts b/packages/beacon-dapp/src/dapp-client/DAppClient.ts index e01fe8f4b..f1ecca557 100644 --- a/packages/beacon-dapp/src/dapp-client/DAppClient.ts +++ b/packages/beacon-dapp/src/dapp-client/DAppClient.ts @@ -1648,10 +1648,15 @@ export class DAppClient extends Client { let pairingMissing, sessionMissing = false - if (isLocalStorageAvailable()) { - const storage = new LocalStorage() - pairingMissing = ((await storage.get(StorageKey.WC_2_CORE_PAIRING)) ?? '[]') === '[]' - sessionMissing = ((await storage.get(StorageKey.WC_2_CLIENT_SESSION)) ?? '[]') === '[]' + if (transport instanceof WalletConnectTransport) { + if (isLocalStorageAvailable()) { + const storage = new LocalStorage() + pairingMissing = ((await storage.get(StorageKey.WC_2_CORE_PAIRING)) ?? '[]') === '[]' + sessionMissing = ((await storage.get(StorageKey.WC_2_CLIENT_SESSION)) ?? '[]') === '[]' + } else { + pairingMissing = !transport.pairings?.length + sessionMissing = !transport.sessions?.length + } } if ( @@ -1786,10 +1791,15 @@ export class DAppClient extends Client { let pairingMissing, sessionMissing = false - if (isLocalStorageAvailable()) { - const storage = new LocalStorage() - pairingMissing = ((await storage.get(StorageKey.WC_2_CORE_PAIRING)) ?? '[]') === '[]' - sessionMissing = ((await storage.get(StorageKey.WC_2_CLIENT_SESSION)) ?? '[]') === '[]' + if (transport instanceof WalletConnectTransport) { + if (isLocalStorageAvailable()) { + const storage = new LocalStorage() + pairingMissing = ((await storage.get(StorageKey.WC_2_CORE_PAIRING)) ?? '[]') === '[]' + sessionMissing = ((await storage.get(StorageKey.WC_2_CLIENT_SESSION)) ?? '[]') === '[]' + } else { + pairingMissing = !transport.pairings?.length + sessionMissing = !transport.sessions?.length + } } if (