From 205e8b00cbb68b9d75b735362abe083eed47e100 Mon Sep 17 00:00:00 2001 From: MK Date: Mon, 7 Oct 2024 13:12:23 +0100 Subject: [PATCH] fix: siwe modal not opening --- .changeset/giant-moons-guess.md | 26 +++++++++++++++++ .../scaffold-ui/src/modal/w3m-modal/index.ts | 28 +++++++++++-------- .../src/views/w3m-connecting-wc-view/index.ts | 4 ++- 3 files changed, 46 insertions(+), 12 deletions(-) create mode 100644 .changeset/giant-moons-guess.md diff --git a/.changeset/giant-moons-guess.md b/.changeset/giant-moons-guess.md new file mode 100644 index 0000000000..40bfaf77cd --- /dev/null +++ b/.changeset/giant-moons-guess.md @@ -0,0 +1,26 @@ +--- +'@reown/appkit-scaffold-ui': patch +'@apps/laboratory': patch +'@apps/demo': patch +'@apps/gallery': patch +'@reown/appkit-adapter-ethers': patch +'@reown/appkit-adapter-ethers5': patch +'@reown/appkit-adapter-polkadot': patch +'@reown/appkit-adapter-solana': patch +'@reown/appkit-adapter-wagmi': patch +'@reown/appkit': patch +'@reown/appkit-utils': patch +'@reown/appkit-cdn': patch +'@reown/appkit-common': patch +'@reown/appkit-core': patch +'@reown/appkit-ethers': patch +'@reown/appkit-ethers5': patch +'@reown/appkit-polyfills': patch +'@reown/appkit-siwe': patch +'@reown/appkit-solana': patch +'@reown/appkit-ui': patch +'@reown/appkit-wagmi': patch +'@reown/appkit-wallet': patch +--- + +Fixed an issue where SIWE modal wasn't showing up for some mobile wallets. diff --git a/packages/scaffold-ui/src/modal/w3m-modal/index.ts b/packages/scaffold-ui/src/modal/w3m-modal/index.ts index eedb32756d..44d733f416 100644 --- a/packages/scaffold-ui/src/modal/w3m-modal/index.ts +++ b/packages/scaffold-ui/src/modal/w3m-modal/index.ts @@ -189,31 +189,37 @@ export class W3mModal extends LitElement { } private async onNewAddress(caipAddress?: CaipAddress) { - const prevConnected = this.caipAddress - ? CoreHelperUtil.getPlainAddress(this.caipAddress) + const prevCaipAddress = this.caipAddress + const prevConnected = prevCaipAddress + ? CoreHelperUtil.getPlainAddress(prevCaipAddress) : undefined const nextConnected = caipAddress ? CoreHelperUtil.getPlainAddress(caipAddress) : undefined const isSameAddress = prevConnected === nextConnected + this.caipAddress = caipAddress + if (nextConnected && !isSameAddress && this.isSiweEnabled) { - const { SIWEController } = await import('@reown/appkit-siwe') - const signed = AccountController.state.siweStatus === 'success' + try { + const { SIWEController } = await import('@reown/appkit-siwe') + const signed = AccountController.state.siweStatus === 'success' - if (!prevConnected && nextConnected) { - this.onSiweNavigation() - } else if (signed && prevConnected && nextConnected && prevConnected !== nextConnected) { - if (SIWEController.state._client?.options.signOutOnAccountChange) { - await SIWEController.signOut() + if (!prevConnected && nextConnected) { this.onSiweNavigation() + } else if (signed && prevConnected && nextConnected && prevConnected !== nextConnected) { + if (SIWEController.state._client?.options.signOutOnAccountChange) { + await SIWEController.signOut() + this.onSiweNavigation() + } } + } catch (err) { + this.caipAddress = prevCaipAddress + throw err } } if (!nextConnected) { ModalController.close() } - - this.caipAddress = caipAddress } private async onNewNetwork(nextCaipNetwork: CaipNetwork | undefined) { diff --git a/packages/scaffold-ui/src/views/w3m-connecting-wc-view/index.ts b/packages/scaffold-ui/src/views/w3m-connecting-wc-view/index.ts index 9434ee9006..c49ead8692 100644 --- a/packages/scaffold-ui/src/views/w3m-connecting-wc-view/index.ts +++ b/packages/scaffold-ui/src/views/w3m-connecting-wc-view/index.ts @@ -28,6 +28,8 @@ export class W3mConnectingWcView extends LitElement { @state() private platforms: Platform[] = [] + @state() private isSiweEnabled = OptionsController.state.isSiweEnabled + public constructor() { super() this.determinePlatforms() @@ -72,7 +74,7 @@ export class W3mConnectingWcView extends LitElement { OptionsController.state.hasMultipleAddresses ) { RouterController.push('SelectAddresses') - } else { + } else if (!this.isSiweEnabled) { ModalController.close() } }