Skip to content
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

Merged
merged 1 commit into from
Oct 7, 2024

Conversation

magiziz
Copy link
Contributor

@magiziz magiziz commented Oct 4, 2024

Description

There was an issue where if you used SIWE and connected with your mobile wallet, the SIWE modal never showed up.

Type of change

  • Chore (non-breaking change that addresses non-functional tasks, maintenance, or code quality improvements)
  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)

Associated Issues

For Linear issues: Closes APKT-1254

Checklist

  • Code in this PR is covered by automated tests (Unit tests, E2E tests)
  • My changes generate no new warnings
  • I have reviewed my own code
  • I have filled out all required sections
  • I have tested my changes on the preview link
  • Approver of this PR confirms that the changes are tested on the preview link

Copy link

linear bot commented Oct 4, 2024

Copy link

changeset-bot bot commented Oct 4, 2024

🦋 Changeset detected

Latest commit: 205e8b0

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 22 packages
Name Type
@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

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link

vercel bot commented Oct 4, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated (UTC)
appkit-laboratory ✅ Ready (Inspect) Visit Preview Oct 7, 2024 0:17am
web3modal-gallery ✅ Ready (Inspect) Visit Preview Oct 7, 2024 0:17am

@magiziz magiziz requested a review from tomiir October 4, 2024 10:51
Copy link
Contributor

github-actions bot commented Oct 4, 2024

Coverage Report for Coverage

Status Category Percentage Covered / Total
🔵 Lines 245.16% 4182 / 18780
🔵 Statements 245.16% 4182 / 18780
🔵 Functions 261.34% 326 / 996
🔵 Branches 312.22999999999996% 583 / 1249
File Coverage
File Stmts % Branch % Funcs % Lines Uncovered Lines
Changed Files
packages/scaffold-ui/src/modal/w3m-modal/index.ts 0% 0% 0% 0% 1, 12-16, 22, 25, 27-29, 32, 34, 37, 39, 41, 43, 45, 47-62, 64-67, 70-73, 75, 89-90, 93-97, 99-101, 103-114, 116-120, 122-128, 130-135, 137-140, 150-151, 153-158, 160-178, 180-183, 185-189, 191-197, 199, 201-204, 206-218, 220-223, 225-228, 230-231, 233-234, 236-238, 240-251, 253-255, 257-269
packages/scaffold-ui/src/views/w3m-connecting-wc-view/index.ts 0% 0% 0% 0% 1, 12-15, 17-18, 20, 22, 24, 27, 29, 31, 33-38, 40-42, 45-48, 50-52, 54, 57-58, 63-64, 66-70, 72-94, 96-97, 99-104, 106-114, 116-119, 121-122, 124-126, 128-136, 139-153, 155-156, 158-164, 167-169, 172-174, 177-182, 184-185, 187-189, 191, 193-194, 198, 200-216
Generated in workflow #6622 for commit 205e8b0 by the Vitest Coverage Report Action

Copy link
Contributor

github-actions bot commented Oct 4, 2024

♻️ Vite-Size ♻️

Size Difference

Size (kb) Gzip (kb)
Total Diff. 0 0

Current Size

Name Size (kb) Gzip (kb)
assets/index-CNRRNGkV.js 1888.629 539.686
assets/index.js 9.63 3.161
assets/index2.js 11.589 3.212
assets/w3m-modal.js 7.482 2.653
assets/noble-curves.js 31.941 12.779
assets/2.21.4_bufferutil.js 2.789 1.327
assets/index3.js 102.251 29.116
assets/index4.js 304.393 87.286
assets/hooks.module.js 74.286 25.525
index.html 0.329 0.237
Total Size 2433.319 704.982

Base Size

Name Size (kb) Gzip (kb)
assets/index-CNRRNGkV.js 1888.629 539.686
assets/index.js 9.63 3.161
assets/index2.js 11.589 3.212
assets/w3m-modal.js 7.482 2.653
assets/noble-curves.js 31.941 12.779
assets/2.21.4_bufferutil.js 2.789 1.327
assets/index3.js 102.251 29.116
assets/index4.js 304.393 87.286
assets/hooks.module.js 74.286 25.525
index.html 0.329 0.237
Total Size 2433.319 704.982

view: 'ConnectingSiwe'
})
}
ModalController.open({
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One thing is ModalController.open has await ApiController.state.prefetchPromise logic. This might cause us to refetch many things unnecessarily.

@magiziz magiziz force-pushed the fix/siwe-failure-on-mobile branch from 0a7f89b to 205e8b0 Compare October 7, 2024 12:12
@magiziz magiziz changed the title fix: siwe modal not showing for mobile wallets fix: siwe modal not opening for some wallets Oct 7, 2024
Comment on lines +77 to 79
} else if (!this.isSiweEnabled) {
ModalController.close()
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When we did RouterController.replace('ConnectingSiwe'), right after the modal would be closed. I did a small check just to make sure if siwe is not enabled then we go ahead and close the modal.

Comment on lines +199 to 201
this.caipAddress = caipAddress

if (nextConnected && !isSameAddress && this.isSiweEnabled) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The 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.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It this the one fixing the main issue?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah

@magiziz magiziz requested a review from enesozturk October 7, 2024 14:01
: undefined
const nextConnected = caipAddress ? CoreHelperUtil.getPlainAddress(caipAddress) : undefined
const isSameAddress = prevConnected === nextConnected

this.caipAddress = caipAddress
Copy link
Contributor

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?

Copy link
Contributor

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?

Copy link
Contributor Author

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.

@magiziz magiziz merged commit e1b8720 into main Oct 7, 2024
15 checks passed
@magiziz magiziz deleted the fix/siwe-failure-on-mobile branch October 7, 2024 15:06
@github-actions github-actions bot mentioned this pull request Oct 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants