-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: siwe modal not opening for some wallets #3012
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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. |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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) { | ||
Comment on lines
+199
to
201
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There were some asynchronous tasks happening before setting caipAddress. In here i just made sure to assign caipAddress before asynchronous tasks start to kick in. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It this the one fixing the main issue? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah |
||
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) { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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() | ||
} | ||
Comment on lines
+77
to
79
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. When we did |
||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are we sure we want to set this before doing some logics?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Might it be better to do it at the end?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah it's better to do at the end, but seems like there is some async tasks that's blocking it from having address being assigned earlier. Otherwise in here it's going to close the modal.