Skip to content

Conversation

@gregfromstl
Copy link
Contributor

@gregfromstl gregfromstl commented Jun 11, 2024

Problem solved

This PR addresses the need for more flexible configuration options when using the useReadContract hook. By adding refetchInterval and retry parameters, users can customize the frequency of refetching data and the number of retry attempts on failure, respectively. These options improve the robustness and flexibility of the useReadContract hook when interacting with contracts.

Changes made

  • Public API changes: useReadContract now accepts refetchInterval and retry as optional parameters.
  • Internal API changes: The PickedQueryOptions type has been updated to include the new parameters.

How to test

  • Automated tests: Adjust or add unit tests covering the new parameters in the appropriate test file.
  • Manual tests: Configure useReadContract with different values for refetchInterval and retry and verify it behaves as expected.

@vercel
Copy link

vercel bot commented Jun 11, 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 11, 2024 3:44pm

@gregfromstl gregfromstl requested a review from MananTank as a code owner June 11, 2024 15:41
@changeset-bot
Copy link

changeset-bot bot commented Jun 11, 2024

🦋 Changeset detected

Latest commit: e099ef5

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

This PR includes changesets to release 8 packages
Name Type
thirdweb Minor
@thirdweb-dev/sdk Patch
@thirdweb-dev/cli Patch
@thirdweb-dev/react-core Patch
@thirdweb-dev/react Patch
@thirdweb-dev/unity-js-bridge Patch
@thirdweb-dev/wallets Patch
@thirdweb-dev/auth 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
Contributor Author

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

Join @gregfromstl and the rest of your teammates on Graphite Graphite

@gregfromstl gregfromstl requested review from jnsdls and removed request for MananTank June 11, 2024 15:41
@codspeed-hq
Copy link

codspeed-hq bot commented Jun 11, 2024

CodSpeed Performance Report

Merging #3273 will improve performances by 12%

Comparing feat-add-options-to-useReadContract (e099ef5) with main (923a5ec)

Summary

⚡ 1 improvements
✅ 8 untouched benchmarks

Benchmarks breakdown

Benchmark main feat-add-options-to-useReadContract Change
keccakId 1.5 ms 1.3 ms +12%

@github-actions
Copy link
Contributor

size-limit report 📦

Path Size Loading time (3g) Running time (snapdragon) Total time
thirdweb (esm) 40.33 KB (0%) 807 ms (0%) 2.1 s (-12.47% 🔽) 2.9 s
thirdweb (cjs) 90.06 KB (0%) 1.9 s (0%) 6.2 s (+15% 🔺) 8 s
thirdweb (minimal + tree-shaking) 4.75 KB (0%) 95 ms (0%) 335 ms (-26.54% 🔽) 430 ms
thirdweb/chains (tree-shaking) 423 B (0%) 10 ms (0%) 49 ms (-8.13% 🔽) 59 ms
thirdweb/react (minimal + tree-shaking) 15.74 KB (0%) 315 ms (0%) 840 ms (+169.61% 🔺) 1.2 s

@codecov
Copy link

codecov bot commented Jun 11, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 63.26%. Comparing base (d2cbb1e) to head (e099ef5).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #3273   +/-   ##
=======================================
  Coverage   63.26%   63.26%           
=======================================
  Files         833      833           
  Lines       63328    63328           
  Branches     3433     3433           
=======================================
  Hits        40066    40066           
  Misses      22587    22587           
  Partials      675      675           
Flag Coverage Δ *Carryforward flag
legacy_packages 65.61% <ø> (ø) Carriedforward from d2cbb1e
packages 62.77% <ø> (ø)

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

Comment on lines +24 to +27
Pick<UseQueryOptions, "enabled"> & {
refetchInterval?: number;
retry?: number;
}
Copy link
Member

Choose a reason for hiding this comment

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

would it make more sense to just ad these to the Pick ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Initially tried that but react query had some janky types that were causing issues

@gregfromstl gregfromstl added this pull request to the merge queue Jun 11, 2024
Merged via the queue into main with commit 7afd2da Jun 11, 2024
@gregfromstl gregfromstl deleted the feat-add-options-to-useReadContract branch June 11, 2024 17:35
@jnsdls jnsdls mentioned this pull request Jun 11, 2024
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.

3 participants