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

[SDK] Fix: Undefined chain ID on eip1193 provider input #5871

Conversation

gregfromstl
Copy link
Member

@gregfromstl gregfromstl commented Jan 2, 2025

Problem solved

Short description of the bug fixed or feature added


PR-Codex overview

This PR focuses on improving the handling of wallet connections in the thirdweb SDK by gracefully managing cases where the chain ID is undefined, particularly for certain wallets.

Detailed summary

  • Updated the check for chain.id in fromEip1193Provider to ensure it is defined before comparison.
  • Added a test case to verify connection handling when the chain ID is not provided.

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

@gregfromstl gregfromstl requested review from a team as code owners January 2, 2025 00:51
Copy link

vercel bot commented Jan 2, 2025

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

Name Status Preview Comments Updated (UTC)
docs-v2 🛑 Canceled (Inspect) Jan 4, 2025 0:38am
thirdweb_playground ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jan 4, 2025 0:38am
thirdweb-www ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jan 4, 2025 0:38am
wallet-ui 🛑 Canceled (Inspect) Jan 4, 2025 0:38am

Copy link

linear bot commented Jan 2, 2025

Copy link

changeset-bot bot commented Jan 2, 2025

🦋 Changeset detected

Latest commit: 9abc3cc

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

This PR includes changesets to release 2 packages
Name Type
thirdweb Patch
@thirdweb-dev/wagmi-adapter 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

graphite-app bot commented Jan 2, 2025

How to use the Graphite Merge Queue

Add either label to this PR to merge it via the merge queue:

  • merge-queue - adds this PR to the back of the merge queue
  • hotfix - for urgent hot fixes, skip the queue and merge this PR next

You must have a Graphite account in order to use the merge queue. Sign up using this link.

An organization admin has enabled the Graphite Merge Queue in this repository.

Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue.

Copy link
Contributor

github-actions bot commented Jan 2, 2025

size-limit report 📦

Path Size Loading time (3g) Running time (snapdragon) Total time
thirdweb (esm) 45 KB (0%) 900 ms (0%) 3.2 s (+30.71% 🔺) 4.1 s
thirdweb (cjs) 110.81 KB (0%) 2.3 s (0%) 8 s (+28.69% 🔺) 10.2 s
thirdweb (minimal + tree-shaking) 5.58 KB (0%) 112 ms (0%) 584 ms (+311.95% 🔺) 695 ms
thirdweb/chains (tree-shaking) 506 B (0%) 10 ms (0%) 285 ms (+160.63% 🔺) 295 ms
thirdweb/react (minimal + tree-shaking) 19.13 KB (0%) 383 ms (0%) 560 ms (-31.5% 🔽) 943 ms

Copy link

codecov bot commented Jan 2, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 55.18%. Comparing base (8b1a60d) to head (d57171a).
Report is 6 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #5871   +/-   ##
=======================================
  Coverage   55.18%   55.18%           
=======================================
  Files        1123     1123           
  Lines       59611    59611           
  Branches     5031     5031           
=======================================
+ Hits        32895    32896    +1     
+ Misses      25996    25995    -1     
  Partials      720      720           
Flag Coverage Δ *Carryforward flag
legacy_packages 65.68% <ø> (ø) Carriedforward from 8b1a60d
packages 52.84% <100.00%> (+<0.01%) ⬆️

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

Files with missing lines Coverage Δ
packages/thirdweb/src/wallets/injected/index.ts 36.78% <100.00%> (ø)

... and 1 file with indirect coverage changes

@gregfromstl gregfromstl added the merge-queue Adds the pull request to Graphite's merge queue. label Jan 3, 2025
Copy link
Member Author

gregfromstl commented Jan 3, 2025

Merge activity

  • Jan 3, 5:35 PM EST: The merge label 'merge-queue' was detected. This PR will be added to the Graphite merge queue once it meets the requirements.
  • Jan 3, 5:35 PM EST: A user added this pull request to the Graphite merge queue.
  • Jan 3, 5:47 PM EST: The Graphite merge queue couldn't merge this PR because it was not satisfying all requirements (Failed CI: 'Unit Tests').

gregfromstl added a commit that referenced this pull request Jan 3, 2025
## Problem solved

Short description of the bug fixed or feature added

<!-- start pr-codex -->

---

## PR-Codex overview
This PR focuses on improving the handling of connections in the `thirdweb` SDK by gracefully managing scenarios where a wallet does not provide a chain ID. It adds checks to avoid errors and includes tests for these cases.

### Detailed summary
- Updated `fromEip1193Provider` to check for `undefined` chain ID before switching chains.
- Added a test to handle wallet connection with no chain ID.
- Ensured compatibility with wallets like Abstract that may not send a chain ID on connection.

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

<!-- end pr-codex -->
@gregfromstl gregfromstl force-pushed the greg/tool-2830-connection-failed-error-for-abstract-global-wallet-on-upcade branch from d57171a to c118382 Compare January 3, 2025 22:36
gregfromstl added a commit that referenced this pull request Jan 3, 2025
## Problem solved

Short description of the bug fixed or feature added

<!-- start pr-codex -->

---

## PR-Codex overview
This PR focuses on enhancing the `thirdweb` SDK by gracefully handling cases where a wallet does not provide a chain ID during connection, ensuring better compatibility with certain wallets.

### Detailed summary
- Updated the logic in `fromEip1193Provider` to check for `undefined` chain IDs.
- Added a test to verify connection handling when no chain ID is provided.

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

<!-- end pr-codex -->
@gregfromstl gregfromstl force-pushed the greg/tool-2830-connection-failed-error-for-abstract-global-wallet-on-upcade branch from c118382 to 9abc3cc Compare January 3, 2025 22:37
gregfromstl added a commit that referenced this pull request Jan 3, 2025
## Problem solved

Short description of the bug fixed or feature added

<!-- start pr-codex -->

---

## PR-Codex overview
This PR focuses on improving the handling of wallet connections in the `thirdweb` SDK, specifically addressing cases where the chain ID may be undefined. It ensures that the SDK can gracefully manage connections without a specified chain ID.

### Detailed summary
- Modified the check for `chain.id` in `fromEip1193Provider` to allow for undefined chain IDs.
- Added a test case to handle wallet connection when no chain ID is provided, ensuring the SDK behaves correctly in this scenario.

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

<!-- end pr-codex -->
@gregfromstl gregfromstl force-pushed the greg/tool-2830-connection-failed-error-for-abstract-global-wallet-on-upcade branch from 9abc3cc to 6976cb4 Compare January 3, 2025 22:39
## Problem solved

Short description of the bug fixed or feature added

<!-- start pr-codex -->

---

## PR-Codex overview
This PR focuses on enhancing the `thirdweb` SDK by improving the handling of connections to wallets that may not provide a chain ID, ensuring the SDK can gracefully manage these scenarios.

### Detailed summary
- Updated `fromEip1193Provider` to check for undefined `chain.id` before switching chains.
- Added a test case to handle wallet connections that do not provide a chain ID, ensuring robustness in the connection process.

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

<!-- end pr-codex -->
@gregfromstl gregfromstl force-pushed the greg/tool-2830-connection-failed-error-for-abstract-global-wallet-on-upcade branch from 6976cb4 to 79a135a Compare January 3, 2025 22:44
@graphite-app graphite-app bot removed the merge-queue Adds the pull request to Graphite's merge queue. label Jan 3, 2025
@gregfromstl gregfromstl merged commit 1e8ddcb into main Jan 5, 2025
28 of 29 checks passed
@gregfromstl gregfromstl deleted the greg/tool-2830-connection-failed-error-for-abstract-global-wallet-on-upcade branch January 5, 2025 07:33
@jnsdls jnsdls mentioned this pull request Jan 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
packages SDK Involves changes to the thirdweb SDK
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants