From c7af8895fc4a9176958571aebf6a7584f7c5813a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=B8ren=20Bruus=20Zeppelin?= Date: Thu, 4 Apr 2024 14:19:26 +0200 Subject: [PATCH] Fix modal not triggering cancel function on close --- packages/react-components/package.json | 2 +- packages/wallet-connectors/package.json | 2 +- packages/wallet-connectors/src/WalletConnect.ts | 11 ++++++++--- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/packages/react-components/package.json b/packages/react-components/package.json index 95c80e6..a1e184d 100644 --- a/packages/react-components/package.json +++ b/packages/react-components/package.json @@ -27,7 +27,7 @@ "build": "tsc" }, "dependencies": { - "@concordium/wallet-connectors": "^0.6.0-alpha.4" + "@concordium/wallet-connectors": "^0.6.0-alpha.5" }, "devDependencies": { "@tsconfig/recommended": "^1.0.1", diff --git a/packages/wallet-connectors/package.json b/packages/wallet-connectors/package.json index f2069d9..20b3a77 100644 --- a/packages/wallet-connectors/package.json +++ b/packages/wallet-connectors/package.json @@ -1,6 +1,6 @@ { "name": "@concordium/wallet-connectors", - "version": "0.6.0-alpha.4", + "version": "0.6.0-alpha.5", "description": "Utility interface for dApps to interact with wallets without depending on the underlying protocol and implementations for Concordium Browser Wallet and Wallet Connect v2.", "author": "Concordium Software", "license": "Apache-2.0", diff --git a/packages/wallet-connectors/src/WalletConnect.ts b/packages/wallet-connectors/src/WalletConnect.ts index 7a713f8..126ebfc 100644 --- a/packages/wallet-connectors/src/WalletConnect.ts +++ b/packages/wallet-connectors/src/WalletConnect.ts @@ -138,8 +138,13 @@ async function connect( walletImages, enableExplorer, }); + modal.subscribeModal(({ open }) => { + if (!open) { + return cancel(); + } + }); // Open modal as we're not connecting to an existing pairing. - modal.openModal({ uri }); + await modal.openModal({ uri }); } return await approval(); } catch (e) { @@ -552,8 +557,8 @@ export class WalletConnectConnector implements WalletConnector { this.network === MAINNET ? [cryptoXWalletMainnet, concordiumWalletMainnet] : this.network === TESTNET - ? [cryptoXWalletTestnet, concordiumWalletTestnet] - : undefined + ? [cryptoXWalletTestnet, concordiumWalletTestnet] + : undefined ); }