Skip to content

Commit

Permalink
fix: add query options to runes queries
Browse files Browse the repository at this point in the history
  • Loading branch information
fbwoolf committed Apr 26, 2024
1 parent 0830303 commit 5510d47
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/app/query/bitcoin/runes/runes-outputs-by-address.query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import { useCurrentNetwork } from '@app/store/networks/networks.selectors';
import type { RunesOutputsByAddress } from '../bitcoin-client';
import { useRunesEnabled } from './runes.hooks';

const queryOptions = { staleTime: 1 * 60 * 1000 };

export function useGetRunesOutputsByAddressQuery<T extends unknown = RunesOutputsByAddress[]>(
address: string,
options?: AppUseQueryConfig<RunesOutputsByAddress[], T>
Expand All @@ -16,14 +18,14 @@ export function useGetRunesOutputsByAddressQuery<T extends unknown = RunesOutput
const network = useCurrentNetwork();

return useQuery({
enabled: !!address && runesEnabled,
queryKey: ['runes-outputs-by-address', address],
queryFn: () =>
client.BestinslotApi.getRunesOutputsByAddress({
address,
network: network.chain.bitcoin.bitcoinNetwork,
}),
staleTime: 1000 * 60,
enabled: !!address && runesEnabled,
...queryOptions,
...options,
});
}
3 changes: 3 additions & 0 deletions src/app/query/bitcoin/runes/runes-ticker-info.query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import { useCurrentNetwork } from '@app/store/networks/networks.selectors';

import type { RuneTickerInfo } from '../bitcoin-client';

const queryOptions = { staleTime: 1 * 60 * 1000 };

export function useGetRunesTickerInfoQuery(runeNames: string[]): UseQueryResult<RuneTickerInfo>[] {
const client = useBitcoinClient();
const network = useCurrentNetwork();
Expand All @@ -18,6 +20,7 @@ export function useGetRunesTickerInfoQuery(runeNames: string[]): UseQueryResult<
queryKey: ['runes-ticker-info', runeName],
queryFn: () =>
client.BestinslotApi.getRunesTickerInfo(runeName, network.chain.bitcoin.bitcoinNetwork),
...queryOptions,
};
}),
});
Expand Down
3 changes: 3 additions & 0 deletions src/app/query/bitcoin/runes/runes-wallet-balances.query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import { useCurrentNetwork } from '@app/store/networks/networks.selectors';

import type { RuneBalance } from '../bitcoin-client';

const queryOptions = { staleTime: 1 * 60 * 1000 };

export function useGetRunesWalletBalancesByAddressesQuery<T extends unknown = RuneBalance[]>(
addresses: string[],
options?: AppUseQueryConfig<RuneBalance[], T>
Expand All @@ -25,6 +27,7 @@ export function useGetRunesWalletBalancesByAddressesQuery<T extends unknown = Ru
address,
network.chain.bitcoin.bitcoinNetwork
),
...queryOptions,
...options,
};
}),
Expand Down

0 comments on commit 5510d47

Please sign in to comment.