From 3d391cdbb83523806e278de7ed0b4589e4737fcc Mon Sep 17 00:00:00 2001 From: Aaron Choo Date: Wed, 4 Oct 2023 16:59:38 +0800 Subject: [PATCH] fix: prevent `GET_ACCOUNTS` from redirecting to app --- CHANGELOG.md | 6 ++++++ package.json | 2 +- src/wallet/walletconnect/WalletConnectV2.ts | 6 +++++- 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e4c311a2..e4eb9211 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ # Changelog +## `v0.0.34` + +### Fixes + +- Prevent redirecting users to the mobile app when querying for the user's account via WalletConnect (on first connect) + ## `v0.0.33` ### Fixes diff --git a/package.json b/package.json index 94e3ac0e..eddb9a87 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "cosmes", - "version": "0.0.33", + "version": "0.0.34", "private": false, "packageManager": "pnpm@8.3.0", "sideEffects": false, diff --git a/src/wallet/walletconnect/WalletConnectV2.ts b/src/wallet/walletconnect/WalletConnectV2.ts index e2d43195..3028c31f 100644 --- a/src/wallet/walletconnect/WalletConnectV2.ts +++ b/src/wallet/walletconnect/WalletConnectV2.ts @@ -243,7 +243,11 @@ export class WalletConnectV2 { throw new Error("Session not found for " + chainId); } const { topic } = JSON.parse(session) as StorageSession; - if (isMobile()) { + if ( + isMobile() && + // GET_ACCOUNTS does not require the user to authorise + method !== Method.GET_ACCOUNTS + ) { window.location.href = isAndroid() ? this.mobileAppDetails.android : this.mobileAppDetails.ios;