Skip to content

[TOOL-2917]: fix useReadContract type hinting #5888

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

Merged
merged 1 commit into from
Jan 7, 2025

Conversation

dirtycajunrice
Copy link
Contributor

@dirtycajunrice dirtycajunrice commented Jan 6, 2025

Notes for the reviewer

  • Clarified types for inputs to help LSPs/IDEs
  • fixed "todo"s for biome conditional hooks with type safe key/queryFn definition

PR-Codex overview

This PR focuses on enhancing the useReadContract hook by introducing new type definitions and improving type safety for contract interactions in the thirdweb package.

Detailed summary

  • Added Extension type in types.ts for transaction options.
  • Introduced AbiOfLength and AsyncGetAbiFunctionFromContract types in contract/types.ts.
  • Updated PickedOnceQueryOptions and WithPickedOnceQueryOptions in hooks/types.ts.
  • Refactored useReadContract to utilize new types for better type safety.
  • Consolidated query options handling in useReadContract.

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

Copy link

vercel bot commented Jan 6, 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 Jan 6, 2025 11:57pm
thirdweb_playground ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jan 6, 2025 11:57pm
thirdweb-www ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jan 6, 2025 11:57pm
wallet-ui ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jan 6, 2025 11:57pm

@dirtycajunrice dirtycajunrice requested review from a team as code owners January 6, 2025 03:18
Copy link

changeset-bot bot commented Jan 6, 2025

⚠️ No Changeset found

Latest commit: 6ca7886

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

@github-actions github-actions bot added packages SDK Involves changes to the thirdweb SDK labels Jan 6, 2025
Copy link
Contributor Author

dirtycajunrice commented Jan 6, 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.

Copy link
Contributor

github-actions bot commented Jan 6, 2025

size-limit report 📦

Path Size Loading time (3g) Running time (snapdragon) Total time
thirdweb (esm) 45 KB (0%) 900 ms (0%) 435 ms (-14.32% 🔽) 1.4 s
thirdweb (cjs) 110.81 KB (0%) 2.3 s (0%) 1.1 s (-11.64% 🔽) 3.3 s
thirdweb (minimal + tree-shaking) 5.58 KB (0%) 112 ms (0%) 173 ms (+720.48% 🔺) 284 ms
thirdweb/chains (tree-shaking) 506 B (0%) 10 ms (0%) 39 ms (+472.55% 🔺) 49 ms
thirdweb/react (minimal + tree-shaking) 19.13 KB (0%) 383 ms (0%) 224 ms (+18.08% 🔺) 606 ms

@dirtycajunrice dirtycajunrice force-pushed the 01-05-fix_usereadcontract_type_hinting branch from df05843 to 5970df9 Compare January 6, 2025 03:22
@dirtycajunrice dirtycajunrice changed the title fix useReadContract type hinting [TOOL-2917]: fix useReadContract type hinting Jan 6, 2025
Copy link

linear bot commented Jan 6, 2025

Copy link

codecov bot commented Jan 6, 2025

Codecov Report

Attention: Patch coverage is 60.52632% with 15 lines in your changes missing coverage. Please review.

Project coverage is 55.29%. Comparing base (a0835f7) to head (6ca7886).
Report is 28 commits behind head on main.

Files with missing lines Patch % Lines
...b/src/react/core/hooks/contract/useReadContract.ts 60.52% 15 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #5888      +/-   ##
==========================================
+ Coverage   55.19%   55.29%   +0.10%     
==========================================
  Files        1123     1123              
  Lines       59622    59646      +24     
  Branches     5029     5044      +15     
==========================================
+ Hits        32906    32980      +74     
+ Misses      25996    25945      -51     
- Partials      720      721       +1     
Flag Coverage Δ *Carryforward flag
legacy_packages 65.68% <ø> (ø) Carriedforward from a0835f7
packages 52.97% <60.52%> (+0.12%) ⬆️

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

Files with missing lines Coverage Δ
...b/src/react/core/hooks/contract/useReadContract.ts 57.40% <60.52%> (+14.22%) ⬆️

... and 14 files with indirect coverage changes

@gregfromstl gregfromstl merged commit c06ecda into main Jan 7, 2025
32 of 33 checks passed
@gregfromstl gregfromstl deleted the 01-05-fix_usereadcontract_type_hinting branch January 7, 2025 02:12
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