bug: usePrepareContractWrite cache should clear if another transaction has succeeded #2389
Unanswered
KholdStare
asked this question in
Ideas
Replies: 1 comment 1 reply
-
Converted to feature request. You can try changing the |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Is there an existing issue for this?
Package Version
0.12.8
Current Behavior
Currently if there are two separate transactions, where one can depend on the other,
usePrepareContractWrite
result is cached for both transactions. When one of the transaction completes, the other needs to be refetched manually, otherwise the cached result stays, even if the actual result would now differ.An example of this is if you have an ERC20 approval transaction and a use of it in two different components.
Approval:
Buy something with ERC20:
The problem is, there isn't anything there to trigger
usePrepareContractWrite
to re-evaluate after the approval is done. This has to be somehow manually connected, e.g. only enabling it if the approval has succeeded.My thinking is that the WAGMI context should invalidate the caches of all
usePrepareContractWrite
calls when any other transaction succeeds - otherwise they may be assuming a stale state of the blockchain.Expected Behavior
Caches of all
usePrepareContractWrite
calls should be invalidated when any other transaction succeeds.Steps To Reproduce
No response
Link to Minimal Reproducible Example (StackBlitz, CodeSandbox, GitHub repo etc.)
No response
Anything else?
No response
Beta Was this translation helpful? Give feedback.
All reactions