From 1d435cafc5890936df6c191200d383c2fdd19942 Mon Sep 17 00:00:00 2001 From: bluecco Date: Tue, 13 Feb 2024 11:02:22 +0100 Subject: [PATCH 1/3] fix: remove last wallet when user rejects with neverAsk mode --- src/main.ts | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/src/main.ts b/src/main.ts index c7218ae..c7807c4 100644 --- a/src/main.ts +++ b/src/main.ts @@ -48,17 +48,22 @@ export const connect = async ({ const lastWalletId = localStorage.getItem("starknetLastConnectedWallet") if (modalMode === "neverAsk") { - const connector = availableConnectors.find((c) => c.id === lastWalletId) + try { + const connector = availableConnectors.find((c) => c.id === lastWalletId) - if (resultType === "wallet") { - await connector?.connect() - } + if (resultType === "wallet") { + await connector?.connect() + } - selectedConnector = connector ?? null + selectedConnector = connector ?? null - return { - connector, - wallet: connector?.wallet ?? null, + return { + connector, + wallet: connector?.wallet ?? null, + } + } catch (error) { + removeStarknetLastConnectedWallet() + throw new Error(error) } } From 191eea07bfa8403d2f9d0da7caba1fa1277a831d Mon Sep 17 00:00:00 2001 From: bluecco Date: Tue, 13 Feb 2024 11:03:24 +0100 Subject: [PATCH 2/3] fix: show installed wallets before not installed wallets --- src/helpers/mapModalWallets.ts | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/helpers/mapModalWallets.ts b/src/helpers/mapModalWallets.ts index 5b53336..9764b0d 100644 --- a/src/helpers/mapModalWallets.ts +++ b/src/helpers/mapModalWallets.ts @@ -25,7 +25,16 @@ export const mapModalWallets = ({ return [] } - return availableConnectors + const allInstalledWallets = installedWallets.map((w) => + availableConnectors.find((c) => c.id === w.id), + ) + + const orderedByInstall = [ + ...availableConnectors.filter((c) => allInstalledWallets.includes(c)), + ...availableConnectors.filter((c) => !allInstalledWallets.includes(c)), + ] + + const connectors = orderedByInstall .map((c) => { const installed = installedWallets.find((w) => w.id === c.id) if (installed) { @@ -74,4 +83,6 @@ export const mapModalWallets = ({ } }) .filter((c): c is ModalWallet => c !== null) + + return connectors } From b5854c9e2f6d16a03cace45ef67f1f0c7c267526 Mon Sep 17 00:00:00 2001 From: semantic-release-bot Date: Tue, 13 Feb 2024 10:08:48 +0000 Subject: [PATCH 3/3] chore(release): 1.1.4 [skip ci] ## [1.1.4](https://github.com/argentlabs/starknetkit/compare/v1.1.3...v1.1.4) (2024-02-13) ### Bug Fixes * remove last wallet when user rejects with neverAsk mode ([1d435ca](https://github.com/argentlabs/starknetkit/commit/1d435cafc5890936df6c191200d383c2fdd19942)) * show installed wallets before not installed wallets ([191eea0](https://github.com/argentlabs/starknetkit/commit/191eea07bfa8403d2f9d0da7caba1fa1277a831d)) --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 1a0eee3..b8922fa 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "starknetkit", - "version": "1.1.3", + "version": "1.1.4", "repository": "github:argentlabs/starknetkit", "private": false, "browser": {