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

chore: siwe to siwx migration #3194

Open
wants to merge 40 commits into
base: main
Choose a base branch
from
Open

Conversation

zoruka
Copy link
Contributor

@zoruka zoruka commented Nov 4, 2024

Description

  • Replace the whole SIWE logic inside AppKit package with SIWX;
  • Let all SIWX code present in AppKit inside SIWXUtil object centralizing the logic spread around the code;
  • Correction into default implementation of SIWX LocalStorage to validate getting sessions.

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-1408
For GH issues: closes #...

Showcase (Optional)

If there is a UI change include the screenshots with before and after state.
If new feature is being introduced, include the link to demo recording.

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 Nov 4, 2024

Copy link

changeset-bot bot commented Nov 4, 2024

⚠️ No Changeset found

Latest commit: 54c5552

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

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

Copy link

vercel bot commented Nov 4, 2024

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

Name Status Preview Comments Updated (UTC)
appkit-gallery ✅ Ready (Inspect) Visit Preview Nov 15, 2024 9:16pm
appkit-laboratory ✅ Ready (Inspect) Visit Preview 💬 Add feedback Nov 15, 2024 9:16pm
appkit-vue-solana ✅ Ready (Inspect) Visit Preview 💬 Add feedback Nov 15, 2024 9:16pm
appkit-wagmi-cdn-example ✅ Ready (Inspect) Visit Preview 💬 Add feedback Nov 15, 2024 9:16pm
vue-wagmi-example ✅ Ready (Inspect) Visit Preview 💬 Add feedback Nov 15, 2024 9:16pm
web3modal-gallery ✅ Ready (Inspect) Visit Preview 💬 Add feedback Nov 15, 2024 9:16pm

Copy link
Contributor

github-actions bot commented Nov 4, 2024

Coverage Report for Coverage

Status Category Percentage Covered / Total
🔵 Lines 323.72% 4406 / 19678
🔵 Statements 323.72% 4406 / 19678
🔵 Functions 362.44000000000005% 371 / 1138
🔵 Branches 461.6499999999999% 693 / 1402
File Coverage
File Stmts Branches Functions Lines Uncovered Lines
Changed Files
packages/appkit/src/client.ts 44.6% 66.44% 69.42% 44.6% 189-190, 233-234, 237-238, 253-256, 259-262, 265-266, 295-306, 309-318, 413, 417, 424, 462-465, 471-478, 481, 569-581, 596-599, 606-607, 615-616, 631-632, 635-636, 639-640, 643-644, 652-664, 669-676, 693-696, 705-734, 736-769, 771-775, 777-795, 797-802, 804-812, 814-823, 825-845, 847-854, 856-867, 869-882, 884-887, 889-892, 894-897, 899-902, 904-911, 916-976, 979-992, 1000-1001, 1009-1120, 1125-1165, 1172-1187, 1191-1193, 1197-1212, 1217-1227, 1230-1302, 1305-1319, 1322-1334, 1346, 1363, 1378-1379, 1392-1398, 1400-1411, 1413-1420, 1442-1458, 1463-1465, 1473-1477, 1492, 1506, 1508-1509, 1514-1526, 1537, 1539-1540, 1546-1557, 1564-1565, 1575, 1577, 1598-1612, 1619-1620, 1658, 1669-1681
packages/appkit/src/universal-adapter/client.ts 34.05% 100% 15.78% 34.05% 29-38, 47-48, 51-56, 59-92, 101-104, 107-111, 114-117, 120-123, 126-129, 132-133, 136-137, 140-141, 144-145, 148-149, 152-159, 174-179
packages/core/exports/index.ts 100% 100% 100% 100%
packages/core/src/controllers/AccountController.ts 44.02% 83.33% 40% 44.02% 61-62, 68-75, 78-99, 102-103, 106-107, 110-113, 158-159, 170-171, 174-175, 178-181, 184-187, 190-194, 204-210, 213-219, 222-228, 231-260
packages/core/src/controllers/ConnectionController.ts 43.82% 66.66% 28% 43.82% 86-90, 104-134, 152-154, 157-173, 176-177, 180-181, 184-185, 188-189, 192-193, 196-197, 200-201, 204-205, 208-209, 212-213, 230-231, 234-236, 239-240, 243-244, 247-248, 256-262, 267-268
packages/core/src/utils/SIWXUtil.ts 5.55% 100% 0% 5.55% 17-18, 20-52, 54-118, 120-132, 134-143, 145-157, 159-246, 248-254
packages/core/src/utils/TypeUtil.ts 100% 100% 100% 100%
packages/scaffold-ui/src/modal/w3m-modal/index.ts 0% 0% 0% 0% 1-195
packages/scaffold-ui/src/partials/w3m-header/index.ts 0% 0% 0% 0% 1-315
packages/scaffold-ui/src/views/w3m-connecting-wc-view/index.ts 0% 0% 0% 0% 1-212
packages/scaffold-ui/src/views/w3m-email-verify-otp-view/index.ts 0% 0% 0% 0% 1-51
packages/scaffold-ui/src/views/w3m-siwx-sign-message-view/index.ts 0% 0% 0% 0% 1-77
packages/siwx/src/core/SIWXConfig.ts 23.68% 100% 0% 23.68% 17-20, 23-24, 27-33, 36-44, 47-48, 51-52, 55-61
packages/siwx/src/core/SIWXStorage.ts 100% 100% 100% 100%
packages/siwx/src/storages/LocalStorage.ts 77.55% 62.5% 85.71% 77.55% 13-18, 35-36, 40-41, 60-61
Generated in workflow #7377 for commit 54c5552 by the Vitest Coverage Report Action

Copy link
Contributor Author

@zoruka zoruka left a comment

Choose a reason for hiding this comment

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

I've let some comments why changing the tests as this concerns me and we might check if these changes makes sense

cc @tomiir

@@ -59,7 +59,7 @@ test('it should switch to different namespace', async () => {
const chainName = 'Solana'

await page.switchNetwork(chainName)
await page.openNetworks()
await validator.expectUnauthenticated()
Copy link
Contributor Author

Choose a reason for hiding this comment

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

In this case the expected behavior of after network switch is to keep the switch network view opened, right? I've changed to expectUnauthenticated because when switching to non evm with siwe, the current behavior is no validation of signature so unauthenticated.

Comment on lines +31 to +33
await modalPage.promptSiwe()
await walletPage.handleRequest({ accept: true })
await modalValidator.expectAuthenticated()
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This won't expect to prompt siwe because before we were filtering out the solana chain ids when trying to authenticate, as we are not doing it anymore and the OneClickAuth feature won't accept multiple namespaces, the sign message step is now needed for multichain auth.

https://github.com/reown-com/appkit/blob/main/packages/appkit/src/client.ts#L722-L724

@@ -53,5 +56,5 @@ test('it should switch networks and sign siwe', async () => {
test('it should switch to Solana and validate chain title', async () => {
const chainName = 'Solana'
await modalPage.switchNetwork(chainName)
await modalValidator.expectSwitchChainView(chainName.toLocaleLowerCase())
await modalValidator.expectSwitchedNetworkOnNetworksView(chainName)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Again, if the expected behavior is to keep switch chain view open after the chain is switched, this test was wrong.

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