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(wallets): cache walletConnectClient #3310

Merged
merged 1 commit into from
Jun 19, 2024

Conversation

gregfromstl
Copy link
Member

@gregfromstl gregfromstl commented Jun 14, 2024

TL;DR

Implemented a caching mechanism for WalletConnect clients to improve performance and added error messaging for failed connections.

What changed?

  • Introduced a caching mechanism for WalletConnect clients using a WeakMap to store instances.
  • Removed redundant console.log error message in WalletConnectReceiverScreen.tsx.
  • Updated disconnect message to "Disconnected".

How to test?

  1. Trigger multiple WalletConnect sessions and ensure that the client is retrieved from the cache after the initial creation.
  2. Test error handling by forcing a connection failure and verifying that the error message is set correctly.
  3. Disconnect a WalletConnect session and ensure the disconnect message is accurate.

Why make this change?

This change enhances the performance by reducing redundant WalletConnect client creations and improves the clarity of error and disconnect messages.


PR-Codex overview

The focus of this PR is to optimize the WalletConnect client caching mechanism and improve error handling in the WalletConnect receiver module.

Detailed summary

  • Added a caching mechanism for WalletConnect clients to improve performance.
  • Updated error message handling in WalletConnect receiver.
  • Improved testing setup by clearing the WalletConnect client cache before each test.

✨ Ask PR-Codex anything about this PR by commenting with /codex {your question}

Copy link

vercel bot commented Jun 14, 2024

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

Name Status Preview Comments Updated (UTC)
thirdweb_playground ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jun 19, 2024 2:45am

Copy link

changeset-bot bot commented Jun 14, 2024

⚠️ No Changeset found

Latest commit: 9266254

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

@gregfromstl gregfromstl marked this pull request as ready for review June 14, 2024 03:01
@gregfromstl gregfromstl requested a review from MananTank as a code owner June 14, 2024 03:01
Copy link

codspeed-hq bot commented Jun 14, 2024

CodSpeed Performance Report

Merging #3310 will not alter performance

Comparing 06-13-fix_wallets_cache_walletconnectclient (9266254) with refactor/icon-usage-connectwallet (ac5bb56)

Summary

✅ 9 untouched benchmarks

Copy link
Contributor

github-actions bot commented Jun 14, 2024

size-limit report 📦

Path Size Loading time (3g) Running time (snapdragon) Total time
thirdweb (esm) 40.65 KB (0%) 814 ms (0%) 2 s (-40.54% 🔽) 2.9 s
thirdweb (cjs) 91.92 KB (0%) 1.9 s (0%) 7 s (-7.04% 🔽) 8.9 s
thirdweb (minimal + tree-shaking) 4.74 KB (0%) 95 ms (0%) 253 ms (+135.6% 🔺) 348 ms
thirdweb/chains (tree-shaking) 423 B (0%) 10 ms (0%) 79 ms (-67.3% 🔽) 89 ms
thirdweb/react (minimal + tree-shaking) 13.46 KB (0%) 270 ms (0%) 373 ms (-25.48% 🔽) 642 ms

@gregfromstl gregfromstl force-pushed the refactor/icon-usage-connectwallet branch from a5f1e16 to b2913ca Compare June 14, 2024 15:59
@gregfromstl gregfromstl force-pushed the 06-13-fix_wallets_cache_walletconnectclient branch from e9ae3d1 to c760d52 Compare June 14, 2024 15:59
@gregfromstl gregfromstl force-pushed the refactor/icon-usage-connectwallet branch from b2913ca to 9d73e12 Compare June 14, 2024 16:52
@gregfromstl gregfromstl force-pushed the 06-13-fix_wallets_cache_walletconnectclient branch from c760d52 to 4204c67 Compare June 14, 2024 16:52
@gregfromstl gregfromstl force-pushed the 06-13-fix_wallets_cache_walletconnectclient branch from 4204c67 to 7f71d45 Compare June 14, 2024 17:06
Copy link

codecov bot commented Jun 14, 2024

Codecov Report

Attention: Patch coverage is 84.21053% with 3 lines in your changes missing coverage. Please review.

Project coverage is 62.55%. Comparing base (ac5bb56) to head (9266254).

Additional details and impacted files
@@                        Coverage Diff                         @@
##           refactor/icon-usage-connectwallet    #3310   +/-   ##
==================================================================
  Coverage                              62.54%   62.55%           
==================================================================
  Files                                    870      870           
  Lines                                  64578    64595   +17     
  Branches                                3479     3479           
==================================================================
+ Hits                                   40390    40405   +15     
- Misses                                 23508    23510    +2     
  Partials                                 680      680           
Flag Coverage Δ *Carryforward flag
legacy_packages 65.60% <ø> (ø) Carriedforward from ac5bb56
packages 61.93% <84.21%> (+<0.01%) ⬆️

*This pull request uses carry forward flags. Click here to find out more.

Files Coverage Δ
...nectWallet/screens/WalletConnectReceiverScreen.tsx 14.10% <ø> (+0.08%) ⬆️
...rdweb/src/wallets/wallet-connect/receiver/index.ts 96.68% <84.21%> (-0.85%) ⬇️

@gregfromstl gregfromstl force-pushed the refactor/icon-usage-connectwallet branch from 9d73e12 to 9088174 Compare June 14, 2024 22:43
@gregfromstl gregfromstl force-pushed the 06-13-fix_wallets_cache_walletconnectclient branch from 7f71d45 to 8e2d234 Compare June 14, 2024 22:43
@gregfromstl gregfromstl force-pushed the refactor/icon-usage-connectwallet branch from 9088174 to 6b67cb6 Compare June 16, 2024 02:24
@gregfromstl gregfromstl force-pushed the 06-13-fix_wallets_cache_walletconnectclient branch from 8e2d234 to 48c5a18 Compare June 16, 2024 02:24
@gregfromstl gregfromstl force-pushed the refactor/icon-usage-connectwallet branch from 6b67cb6 to de2eb1c Compare June 17, 2024 21:07
@gregfromstl gregfromstl force-pushed the 06-13-fix_wallets_cache_walletconnectclient branch from 48c5a18 to a9edd7d Compare June 17, 2024 21:07
Copy link

graphite-app bot commented Jun 19, 2024

Merge activity

@gregfromstl gregfromstl force-pushed the refactor/icon-usage-connectwallet branch from e061008 to 715a597 Compare June 19, 2024 01:08
@gregfromstl gregfromstl force-pushed the 06-13-fix_wallets_cache_walletconnectclient branch from 142ab64 to 1652bbc Compare June 19, 2024 01:08
@gregfromstl gregfromstl force-pushed the refactor/icon-usage-connectwallet branch from 715a597 to 966211e Compare June 19, 2024 01:13
@gregfromstl gregfromstl force-pushed the 06-13-fix_wallets_cache_walletconnectclient branch from 1652bbc to 167819f Compare June 19, 2024 01:13
### TL;DR

Implemented a caching mechanism for WalletConnect clients to improve performance and added error messaging for failed connections.

### What changed?

- Introduced a caching mechanism for WalletConnect clients using a WeakMap to store instances.
- Removed redundant console.log error message in WalletConnectReceiverScreen.tsx.
- Updated disconnect message to "Disconnected".

### How to test?

1. Trigger multiple WalletConnect sessions and ensure that the client is retrieved from the cache after the initial creation.
2. Test error handling by forcing a connection failure and verifying that the error message is set correctly.
3. Disconnect a WalletConnect session and ensure the disconnect message is accurate.

### Why make this change?

This change enhances the performance by reducing redundant WalletConnect client creations and improves the clarity of error and disconnect messages.

<!-- start pr-codex -->

---

## PR-Codex overview
This PR optimizes WalletConnect client caching and error handling.

### Detailed summary
- Added caching mechanism for WalletConnect clients
- Improved error message handling during connection establishment
- Updated disconnect message to "Disconnected"

> ✨ Ask PR-Codex anything about this PR by commenting with `/codex {your question}`

<!-- end pr-codex -->
@gregfromstl gregfromstl force-pushed the refactor/icon-usage-connectwallet branch from 966211e to ac5bb56 Compare June 19, 2024 02:40
@gregfromstl gregfromstl force-pushed the 06-13-fix_wallets_cache_walletconnectclient branch from 167819f to 9266254 Compare June 19, 2024 02:41
@gregfromstl gregfromstl changed the base branch from refactor/icon-usage-connectwallet to main June 19, 2024 02:44
@graphite-app graphite-app bot merged commit 9266254 into main Jun 19, 2024
26 of 27 checks passed
@graphite-app graphite-app bot deleted the 06-13-fix_wallets_cache_walletconnectclient branch June 19, 2024 02:45
@vercel vercel bot temporarily deployed to Production June 19, 2024 02:47 Inactive
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