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

feat: Refresh cached data when transaction is sent/confirmed #11

Open
wants to merge 10 commits into
base: main
Choose a base branch
from

Conversation

tmjssz
Copy link
Contributor

@tmjssz tmjssz commented Sep 20, 2024

When a transaction is executed or confirmed, the cached data is updated. This is done by invalidating the corresponding queries which makes the data being fetched again and replacing the cache.

  • When multi-sig transaction is confirmed, the pending transactions are refetched
  • When a transaction is executed, the SafeInfo and executed + pending transactions are refetched

Additionally the useSafeInfo hook is refactored, by moving the individual properties (address, threshold, owners, nonce, isDeployed) into separate hooks. That way, we can internally use those individual hooks, instead of fetching all the data.

This is necessary to make sure that transaction lists are updated when a new one is sent. By invalidating the queries, the transactions are refetched and replace the ones in the cache.

Add `useAddress` hook and use it instead of the `useSafeInfo` when only the address is needed.

Move the queryClient and invalidateQueries functions to a new file called queryClient.ts for better organization and separation of concerns.
Create individual hooks for each Safe Info prop
@tmjssz tmjssz linked an issue Sep 20, 2024 that may be closed by this pull request
Yarn link the unpublished types-kit package
Fix the yarn link command
Checkout the safe-core-sdk at the commit hash before types-kit was introduced
@coveralls
Copy link

Pull Request Test Coverage Report for Build 10998049945

Details

  • 193 of 195 (98.97%) changed or added relevant lines in 30 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+1.7%) to 96.975%

Changes Missing Coverage Covered Lines Changed/Added Lines %
src/SafeContext.ts 3 4 75.0%
src/hooks/useWaitForTransaction.ts 37 38 97.37%
Totals Coverage Status
Change from base Build 10848263362: 1.7%
Covered Lines: 455
Relevant Lines: 463

💛 - Coveralls

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.

[React Hooks] Reload caching after sending a transaction
2 participants