Skip to content

Conversation

@jnsdls
Copy link
Member

@jnsdls jnsdls commented Feb 7, 2025

TOOL-0000

TL;DR

Prioritize explicitly passed clientId over computed values when creating a Thirdweb client.

What changed?

Modified the client initialization logic to prefer explicitly passed clientId parameters over computing them from secretKey. Only falls back to computing the clientId from secretKey when no explicit clientId is provided.

How to test?

  1. Create a Thirdweb client with both clientId and secretKey parameters
  2. Verify that the provided clientId is used instead of computing one from the secretKey
  3. Create a client with only secretKey and verify the clientId is computed correctly

Why make this change?

To give developers more control over client configuration by respecting explicitly provided parameters rather than always computing values from the secret key. This allows for more flexible client setup scenarios where the computed clientId might not be desired.


PR-Codex overview

This PR updates the behavior of the createThirdwebClient() function to prioritize the explicit clientId over a computed clientId derived from the secretKey. It also adjusts the related test cases to reflect this new behavior.

Detailed summary

  • Updated client.ts to prefer the provided clientId over computing it from secretKey.
  • Modified the test case description in client.test.ts to clarify that clientId will not be ignored if secretKey is provided.
  • Adjusted the expectation in the test to check for the explicitly passed clientId instead of the computed value.

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

@changeset-bot
Copy link

changeset-bot bot commented Feb 7, 2025

🦋 Changeset detected

Latest commit: 64d7bf3

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

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

@vercel
Copy link

vercel bot commented Feb 7, 2025

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

Name Status Preview Comments Updated (UTC)
docs-v2 ✅ Ready (Inspect) Visit Preview 💬 Add feedback Feb 7, 2025 8:35am
login ✅ Ready (Inspect) Visit Preview 💬 Add feedback Feb 7, 2025 8:35am
thirdweb_playground ✅ Ready (Inspect) Visit Preview 💬 Add feedback Feb 7, 2025 8:35am
thirdweb-www ✅ Ready (Inspect) Visit Preview 💬 Add feedback Feb 7, 2025 8:35am
wallet-ui ✅ Ready (Inspect) Visit Preview 💬 Add feedback Feb 7, 2025 8:35am

@github-actions github-actions bot added packages SDK Involves changes to the thirdweb SDK labels Feb 7, 2025
@jnsdls jnsdls marked this pull request as ready for review February 7, 2025 07:10
@jnsdls jnsdls requested review from a team as code owners February 7, 2025 07:10
Copy link
Member Author

jnsdls commented Feb 7, 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.

This stack of pull requests is managed by Graphite. Learn more about stacking.

@github-actions
Copy link
Contributor

github-actions bot commented Feb 7, 2025

size-limit report 📦

Path Size Loading time (3g) Running time (snapdragon) Total time
thirdweb (esm) 46.21 KB (-0.04% 🔽) 925 ms (-0.04% 🔽) 172 ms (+63.74% 🔺) 1.1 s
thirdweb (cjs) 121.82 KB (-0.09% 🔽) 2.5 s (-0.09% 🔽) 256 ms (-1.9% 🔽) 2.7 s
thirdweb (minimal + tree-shaking) 5.6 KB (+0.2% 🔺) 112 ms (+0.2% 🔺) 70 ms (+340.22% 🔺) 182 ms
thirdweb/chains (tree-shaking) 506 B (0%) 10 ms (0%) 12 ms (+701.43% 🔺) 22 ms
thirdweb/react (minimal + tree-shaking) 19.29 KB (0%) 386 ms (0%) 203 ms (+750.97% 🔺) 589 ms

@codecov
Copy link

codecov bot commented Feb 7, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 56.88%. Comparing base (a6e9c97) to head (64d7bf3).
Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #6188   +/-   ##
=======================================
  Coverage   56.87%   56.88%           
=======================================
  Files        1155     1155           
  Lines       63988    63988           
  Branches     5200     5193    -7     
=======================================
+ Hits        36395    36399    +4     
+ Misses      26865    26862    -3     
+ Partials      728      727    -1     
Flag Coverage Δ *Carryforward flag
legacy_packages 65.68% <ø> (ø) Carriedforward from a6e9c97
packages 55.08% <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/client/client.ts 100.00% <100.00%> (ø)

... and 5 files with indirect coverage changes

@graphite-app
Copy link
Contributor

graphite-app bot commented Feb 7, 2025

Merge activity

TOOL-0000

### TL;DR

Prioritize explicitly passed `clientId` over computed values when creating a Thirdweb client.

### What changed?

Modified the client initialization logic to prefer explicitly passed `clientId` parameters over computing them from `secretKey`. Only falls back to computing the `clientId` from `secretKey` when no explicit `clientId` is provided.

### How to test?

1. Create a Thirdweb client with both `clientId` and `secretKey` parameters
2. Verify that the provided `clientId` is used instead of computing one from the `secretKey`
3. Create a client with only `secretKey` and verify the `clientId` is computed correctly

### Why make this change?

To give developers more control over client configuration by respecting explicitly provided parameters rather than always computing values from the secret key. This allows for more flexible client setup scenarios where the computed `clientId` might not be desired.

<!-- start pr-codex -->

---

## PR-Codex overview
This PR updates the behavior of the `createThirdwebClient()` function to prioritize the explicitly provided `clientId` over deriving it from the `secretKey`. It also modifies the corresponding test to reflect this new behavior.

### Detailed summary
- Updated `createThirdwebClient()` to prefer `clientId` over computed value from `secretKey`.
- Changed test description to indicate `clientId` is not ignored when `secretKey` is provided.
- Updated test expectation to check that `clientId` is equal to the explicitly provided value instead of the computed one.

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

<!-- end pr-codex -->
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.

3 participants