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

refactor: local storage keys to appkit + network switch fixes #2861

Merged
merged 22 commits into from
Sep 19, 2024

Conversation

enesozturk
Copy link
Contributor

@enesozturk enesozturk commented Sep 17, 2024

Description

Switched to @appkit/* prefix for the local storage keys.

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-xxx
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

changeset-bot bot commented Sep 17, 2024

🦋 Changeset detected

Latest commit: 1eb7feb

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

This PR includes changesets to release 34 packages
Name Type
@reown/appkit-adapter-ethers5 Patch
@reown/appkit-adapter-ethers Patch
@reown/appkit-utils Patch
@reown/appkit Patch
@reown/appkit-common Patch
@reown/appkit-wallet Patch
@reown/appkit-core Patch
@apps/demo Patch
@apps/gallery Patch
@apps/laboratory Patch
@examples/html-ethers Patch
@examples/html-ethers5 Patch
@examples/html-wagmi Patch
@examples/next-ethers Patch
@examples/next-wagmi Patch
@examples/react-ethers Patch
@examples/react-ethers5 Patch
@examples/react-solana Patch
@examples/react-wagmi Patch
@examples/vue-ethers5 Patch
@examples/vue-solana Patch
@examples/vue-wagmi Patch
@reown/appkit-adapter-polkadot Patch
@reown/appkit-adapter-solana Patch
@reown/appkit-adapter-wagmi Patch
@reown/appkit-cdn Patch
@reown/appkit-ethers Patch
@reown/appkit-ethers5 Patch
@reown/appkit-polyfills Patch
@reown/appkit-scaffold-ui Patch
@reown/appkit-siwe Patch
@reown/appkit-solana Patch
@reown/appkit-ui Patch
@reown/appkit-wagmi 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 Sep 17, 2024

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

Name Status Preview Updated (UTC)
web3modal-gallery ✅ Ready (Inspect) Visit Preview Sep 19, 2024 8:29pm
web3modal-laboratory ✅ Ready (Inspect) Visit Preview Sep 19, 2024 8:29pm

Copy link
Contributor

github-actions bot commented Sep 17, 2024

Coverage Report for Coverage

Status Category Percentage Covered / Total
🔵 Lines 243.10999999999999% 4160 / 10409
🔵 Statements 243.10999999999999% 4160 / 10409
🔵 Functions 265.11% 320 / 803
🔵 Branches 309.06% 568 / 1042
File Coverage
File Stmts % Branch % Funcs % Lines Uncovered Lines
Changed Files
packages/appkit/src/universal-adapter/client.ts 55.53% 46.29% 50% 55.53% 101-102, 137-138, 141, 146-147, 149-151, 160-163, 165-167, 169-171, 173-178, 180, 182-191, 193, 195-198, 200-205, 207, 209, 211-214, 228-230, 239-241, 243-245, 247-250, 252-253, 279-280, 298-303, 307-312, 322, 324-327, 333-341, 343, 345-346, 363-364, 366-371, 400, 404-407, 409-410, 446-449, 451-452, 454-456, 459-462, 466-468, 470-490, 528-533, 536-539, 543-544, 546-549, 551-553, 555-557, 559-566, 569-571, 573-588
packages/appkit/src/utils/ConstantsUtil.ts 0% 0% 0% 0% 1-4
packages/appkit-utils/src/ethers/EthersConstantsUtil.ts 0% 0% 0% 0% 1-4
packages/appkit-utils/src/solana/SolanaConstantsUtil.ts 100% 100% 100% 100%
packages/common/src/utils/SafeLocalStorage.ts 92.3% 100% 80% 92.3% 65-68
packages/core/src/controllers/ChainController.ts 67.44% 52.08% 76.47% 67.44% 73-77, 80-84, 86-87, 89-97, 103-104, 132, 134-146, 150-158, 170-171, 194-195, 237-239, 241-243, 245-246, 248-252, 261-263, 265-266, 298-301, 312-314, 316-317, 326-327, 346-348, 350-351, 354-355, 360-361, 364-365, 377-378, 381-382, 387-388, 400-401, 406-407, 413, 415-420, 422-423, 429-430
packages/core/src/controllers/NetworkController.ts 62.05% 67.5% 70% 62.05% 49-50, 56-59, 61-70, 77, 79-82, 96-97, 110-111, 114-115, 128-134, 147-148, 154-155, 169-172, 186, 188-189, 191-198, 201-202, 204-206, 208-209, 211, 213-217, 219-220, 228-229, 241-242, 259-260, 263-264, 277-278, 292, 294-296, 298-299, 303
packages/core/src/utils/StorageUtil.ts 80.21% 74.07% 100% 80.21% 48-49, 58-59, 61, 68-69, 76-77, 79, 86-87, 94-95, 97, 104-105, 107
Generated in workflow #6177

Copy link
Contributor

github-actions bot commented Sep 17, 2024

♻️ Vite-Size ♻️

Size Difference

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

Current Size

Name Size (kb) Gzip (kb)
assets/index-CjJNdljT.js 1869.775 533.737
assets/index.js 9.63 3.16
assets/index2.js 11.572 3.199
assets/w3m-modal.js 7.371 2.601
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.443 25.591
index.html 0.329 0.237
Total Size 2414.494 699.033

Base Size

Name Size (kb) Gzip (kb)
assets/index-CjJNdljT.js 1869.775 533.737
assets/index.js 9.63 3.16
assets/index2.js 11.572 3.199
assets/w3m-modal.js 7.371 2.601
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.443 25.591
index.html 0.329 0.237
Total Size 2414.494 699.033

@enesozturk enesozturk changed the title Refactor/local storage keys to appkit 2 refactor: local storage keys to appkit 2 Sep 17, 2024
@enesozturk enesozturk requested review from svenvoskamp, tomiir and zoruka and removed request for svenvoskamp September 18, 2024 10:19
@@ -24,7 +32,7 @@ export const SafeLocalStorage = {
value: SafeLocalStorageItems[Key]
): void {
if (isSafe()) {
localStorage.setItem(key, JSON.stringify(value))
localStorage.setItem(key, value)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

We shouldn't do the parsing here. An example;

We have @appkit/active_caip_network key, which is expected to store CaipNetwork type.

If we set '@appkit/active_caip_network': string on SafeLocalStorageItems, the getItem's catch will return type error bc, if somehow the parsing fails, it'll return string which is not what that key stores.

So the stringifying and parseing should be abstracted from this SafeLocalStorage utility.

@ignaciosantise
Copy link
Collaborator

ignaciosantise commented Sep 18, 2024

@enesozturk @tomiir @zoruka are you going to add some logic to migrate from old keys to new ones? If not, i think you'll probably mess some connections from dapps migrating from the old sdk to the new one

@zoruka
Copy link
Contributor

zoruka commented Sep 18, 2024

@enesozturk @tomiir @zoruka are you going to add some logic to migrate from old keys to new ones? If not, i think you'll probably mess some connections from dapps migrating from the old sdk to the new one

I think old connections will fail to parse when attempted to read the values in the JSON.parse and then it will result as if the localStorage where empty. I guess this will only happen one time

@tomiir tomiir changed the title refactor: local storage keys to appkit 2 refactor: local storage keys to appkit + network switch fixes Sep 19, 2024
@tomiir tomiir merged commit a181a19 into main Sep 19, 2024
14 checks passed
@tomiir tomiir deleted the refactor/local-storage-keys-to-appkit-2 branch September 19, 2024 20:37
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.

4 participants