From efc9ddb2366b01fc9f4a4c2022287ea99340c668 Mon Sep 17 00:00:00 2001 From: enesozturk Date: Wed, 5 Jun 2024 13:49:29 +0300 Subject: [PATCH 1/2] refactor: disable disconnected call for siwe if not connected --- packages/scaffold/src/modal/w3m-modal/index.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/scaffold/src/modal/w3m-modal/index.ts b/packages/scaffold/src/modal/w3m-modal/index.ts index 7f2b349a7a..995f2bb3a2 100644 --- a/packages/scaffold/src/modal/w3m-modal/index.ts +++ b/packages/scaffold/src/modal/w3m-modal/index.ts @@ -35,7 +35,7 @@ export class W3mModal extends LitElement { @state() private isSiweEnabled = OptionsController.state.isSiweEnabled - @state() private connected = AccountController.state.isConnected + @state() private isConnected = AccountController.state.isConnected @state() private loading = ModalController.state.loading @@ -49,7 +49,7 @@ export class W3mModal extends LitElement { this.loading = val this.onNewAddress(AccountController.state.caipAddress) }), - AccountController.subscribeKey('isConnected', val => (this.connected = val)), + AccountController.subscribeKey('isConnected', val => (this.isConnected = val)), AccountController.subscribeKey('caipAddress', val => this.onNewAddress(val)), OptionsController.subscribeKey('isSiweEnabled', val => (this.isSiweEnabled = val)) ) @@ -88,7 +88,7 @@ export class W3mModal extends LitElement { if (this.isSiweEnabled) { const { SIWEController } = await import('@web3modal/siwe') - if (SIWEController.state.status !== 'success') { + if (SIWEController.state.status !== 'success' && this.isConnected) { await ConnectionController.disconnect() } } @@ -165,7 +165,7 @@ export class W3mModal extends LitElement { } private async onNewAddress(caipAddress?: CaipAddress) { - if (!this.connected || this.loading) { + if (!this.isConnected || this.loading) { return } From db3e3ea8beb8bb5e067906540071e944dd8ebe4b Mon Sep 17 00:00:00 2001 From: enesozturk Date: Wed, 5 Jun 2024 14:08:56 +0300 Subject: [PATCH 2/2] fix: change isConnected to connected --- packages/scaffold/src/modal/w3m-modal/index.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/scaffold/src/modal/w3m-modal/index.ts b/packages/scaffold/src/modal/w3m-modal/index.ts index 995f2bb3a2..ae164190fa 100644 --- a/packages/scaffold/src/modal/w3m-modal/index.ts +++ b/packages/scaffold/src/modal/w3m-modal/index.ts @@ -35,7 +35,7 @@ export class W3mModal extends LitElement { @state() private isSiweEnabled = OptionsController.state.isSiweEnabled - @state() private isConnected = AccountController.state.isConnected + @state() private connected = AccountController.state.isConnected @state() private loading = ModalController.state.loading @@ -49,7 +49,7 @@ export class W3mModal extends LitElement { this.loading = val this.onNewAddress(AccountController.state.caipAddress) }), - AccountController.subscribeKey('isConnected', val => (this.isConnected = val)), + AccountController.subscribeKey('isConnected', val => (this.connected = val)), AccountController.subscribeKey('caipAddress', val => this.onNewAddress(val)), OptionsController.subscribeKey('isSiweEnabled', val => (this.isSiweEnabled = val)) ) @@ -88,7 +88,7 @@ export class W3mModal extends LitElement { if (this.isSiweEnabled) { const { SIWEController } = await import('@web3modal/siwe') - if (SIWEController.state.status !== 'success' && this.isConnected) { + if (SIWEController.state.status !== 'success' && this.connected) { await ConnectionController.disconnect() } } @@ -165,7 +165,7 @@ export class W3mModal extends LitElement { } private async onNewAddress(caipAddress?: CaipAddress) { - if (!this.isConnected || this.loading) { + if (!this.connected || this.loading) { return }