Skip to content

Commit

Permalink
Update UserAssetsQuery to use new QueryConfigWithSelect type
Browse files Browse the repository at this point in the history
  • Loading branch information
jinchung committed Oct 26, 2023
1 parent 6391e7d commit 2e84de1
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions src/resources/assets/UserAssetsQuery.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { rainbowFetch } from '@/rainbow-fetch';
import {
createQueryKey,
queryClient,
QueryConfig,
QueryConfigWithSelect,
QueryFunctionArgs,
QueryFunctionResult,
} from '@/react-query';
Expand Down Expand Up @@ -227,9 +227,14 @@ function parseUserAssetsByChain(message: AddysAccountAssetsResponse) {
// ///////////////////////////////////////////////
// Query Fetcher (Optional)

export async function fetchUserAssets(
export async function fetchUserAssets<TSelectResult = UserAssetsResult>(
{ address, currency, connectedToHardhat }: UserAssetsArgs,
config: QueryConfig<UserAssetsResult, Error, UserAssetsQueryKey> = {}
config: QueryConfigWithSelect<
UserAssetsResult,
Error,
TSelectResult,
UserAssetsQueryKey
> = {}
) {
return await queryClient.fetchQuery(
userAssetsQueryKey({ address, currency, connectedToHardhat }),
Expand All @@ -241,9 +246,14 @@ export async function fetchUserAssets(
// ///////////////////////////////////////////////
// Query Hook

export function useUserAssets(
export function useUserAssets<TSelectResult = UserAssetsResult>(
{ address, currency, connectedToHardhat }: UserAssetsArgs,
config: QueryConfig<UserAssetsResult, Error, UserAssetsQueryKey> = {}
config: QueryConfigWithSelect<
UserAssetsResult,
Error,
TSelectResult,
UserAssetsQueryKey
> = {}
) {
return useQuery(
userAssetsQueryKey({ address, currency, connectedToHardhat }),
Expand Down

0 comments on commit 2e84de1

Please sign in to comment.