From 63abca06ba86e44a1e379e0ee96d83f7d1534cd7 Mon Sep 17 00:00:00 2001 From: Adrian Date: Thu, 9 Nov 2023 16:11:38 +0100 Subject: [PATCH] polkadot: set _connecting to false on disconnect --- sdk/apps/modal-example/package.json | 2 +- sdk/packages/selector-polkadot/package.json | 2 +- sdk/packages/selector-polkadot/src/adapter.ts | 36 ++++++++++--------- sdk/pnpm-lock.yaml | 2 +- 4 files changed, 23 insertions(+), 19 deletions(-) diff --git a/sdk/apps/modal-example/package.json b/sdk/apps/modal-example/package.json index afe0758e..eaa1dd95 100644 --- a/sdk/apps/modal-example/package.json +++ b/sdk/apps/modal-example/package.json @@ -22,7 +22,7 @@ "@nightlylabs/nightly-connect-sui": "0.0.28", "@nightlylabs/wallet-selector-sui": "0.2.6", "@nightlylabs/nightly-connect-polkadot": "0.0.12", - "@nightlylabs/wallet-selector-polkadot": "0.1.11", + "@nightlylabs/wallet-selector-polkadot": "0.1.12", "@polkadot/extension-inject": "^0.46.5", "@polkadot/api": "^10.10.1", "@solana/web3.js": "^1.77.2", diff --git a/sdk/packages/selector-polkadot/package.json b/sdk/packages/selector-polkadot/package.json index af38598f..7b503662 100644 --- a/sdk/packages/selector-polkadot/package.json +++ b/sdk/packages/selector-polkadot/package.json @@ -1,6 +1,6 @@ { "name": "@nightlylabs/wallet-selector-polkadot", - "version": "0.1.11", + "version": "0.1.12", "description": "", "type": "module", "exports": { diff --git a/sdk/packages/selector-polkadot/src/adapter.ts b/sdk/packages/selector-polkadot/src/adapter.ts index ba41f715..3b73a209 100644 --- a/sdk/packages/selector-polkadot/src/adapter.ts +++ b/sdk/packages/selector-polkadot/src/adapter.ts @@ -574,22 +574,26 @@ export class NightlyConnectAdapter implements Injected { }) disconnect = async () => { - // Some apps might use disconnect to reset state / recreate session - clearSessionIdForNetwork(this.network) - this._appSessionActive = false - this._app = await AppPolkadot.build(this._appInitData) - if (this._innerStandardAdapter) { - this._innerStandardAdapter = undefined - persistStandardDisconnectForNetwork(this.network) - } - // Update recent wallet - this.walletsList = getPolkadotWalletsList( - this._metadataWallets, - getRecentStandardWalletForNetwork(this.network) ?? undefined - ) - if (this._modal) { - this._modal.walletsList = this.walletsList + try { + // Some apps might use disconnect to reset state / recreate session + clearSessionIdForNetwork(this.network) + this._appSessionActive = false + this._app = await AppPolkadot.build(this._appInitData) + if (this._innerStandardAdapter) { + this._innerStandardAdapter = undefined + persistStandardDisconnectForNetwork(this.network) + } + // Update recent wallet + this.walletsList = getPolkadotWalletsList( + this._metadataWallets, + getRecentStandardWalletForNetwork(this.network) ?? undefined + ) + if (this._modal) { + this._modal.walletsList = this.walletsList + } + this._connected = false + } finally { + this._connecting = false } - this._connected = false } } diff --git a/sdk/pnpm-lock.yaml b/sdk/pnpm-lock.yaml index 0dfc9498..661d1c1a 100644 --- a/sdk/pnpm-lock.yaml +++ b/sdk/pnpm-lock.yaml @@ -141,7 +141,7 @@ importers: specifier: 0.0.28 version: link:../sui '@nightlylabs/wallet-selector-polkadot': - specifier: 0.1.11 + specifier: 0.1.12 version: link:../../packages/selector-polkadot '@nightlylabs/wallet-selector-solana': specifier: 0.2.6