Skip to content

Commit

Permalink
fix: queryKey to consider 0 as a value for changing cache (#348)
Browse files Browse the repository at this point in the history
  • Loading branch information
luizstacio authored Oct 7, 2024
1 parent 326d0b9 commit 1ffb4b5
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
5 changes: 5 additions & 0 deletions .changeset/wise-kings-lie.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@fuels/react": patch
---

Fix queryKey to consider 0 as a value for changing cache
12 changes: 8 additions & 4 deletions packages/react/src/utils/queryKeys.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,15 @@ export const QUERY_KEYS = {
const queryKey = QUERY_KEYS.base.concat('balance');
if (address) queryKey.push(address);
if (assetId) queryKey.push(assetId);
if (provider?.getChainId?.()) queryKey.push(provider.getChainId());
if (provider?.getChainId?.() !== undefined)
queryKey.push(provider.getChainId());
return queryKey;
},
wallet: (address?: string | null, provider?: Provider | null): QueryKey => {
const queryKey = QUERY_KEYS.base.concat('wallet');
if (address) queryKey.push(address);
if (provider?.getChainId?.()) queryKey.push(provider.getChainId());
if (provider?.getChainId?.() !== undefined)
queryKey.push(provider.getChainId());
return queryKey;
},
transaction: (id?: string): QueryKey => {
Expand All @@ -64,12 +66,14 @@ export const QUERY_KEYS = {
},
transactionReceipts: (id?: string, provider?: Provider | null): QueryKey => {
const queryKey = QUERY_KEYS.transaction(id).concat('receipts');
if (provider?.getChainId?.()) queryKey.push(provider.getChainId());
if (provider?.getChainId?.() !== undefined)
queryKey.push(provider.getChainId());
return queryKey;
},
transactionResult: (id?: string, provider?: Provider | null): QueryKey => {
const queryKey = QUERY_KEYS.transaction(id).concat('result');
if (provider?.getChainId?.()) queryKey.push(provider.getChainId());
if (provider?.getChainId?.() !== undefined)
queryKey.push(provider.getChainId());
return queryKey;
},
nodeInfo: (url?: string): QueryKey => {
Expand Down

0 comments on commit 1ffb4b5

Please sign in to comment.