-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
5 changed files
with
45 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import { useQueryClient } from "@tanstack/react-query"; | ||
|
||
export const useForceRefetchQuery = () => { | ||
const client = useQueryClient(); | ||
|
||
return client.invalidateQueries.bind(client); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export * from "./types"; | ||
export * from "./queries"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import { TokenListResponse, TokenPriceListResponse } from "@repositories/token"; | ||
import { UseQueryOptions, useQuery } from "@tanstack/react-query"; | ||
import { useGnoswapContext } from "@hooks/common/use-gnoswap-context"; | ||
import { QUERY_KEY } from "./types"; | ||
|
||
export const useGetTokensList = ( | ||
options?: UseQueryOptions<TokenListResponse, Error> | ||
) => { | ||
const { tokenRepository } = useGnoswapContext(); | ||
|
||
return useQuery<TokenListResponse, Error>({ | ||
queryKey: [QUERY_KEY.tokens], | ||
queryFn: () => tokenRepository.getTokens(), | ||
enabled: false, | ||
...options, | ||
}); | ||
}; | ||
|
||
export const useGetTokenPrices = ( | ||
options?: UseQueryOptions<TokenPriceListResponse, Error> | ||
) => { | ||
const { tokenRepository } = useGnoswapContext(); | ||
return useQuery<TokenPriceListResponse, Error>({ | ||
queryKey: [QUERY_KEY.tokenPrices], | ||
queryFn: () => tokenRepository.getTokenPrices(), | ||
...options, | ||
}); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
export interface IExampleTypeRequest {} | ||
export interface IExampleTypeResponse {} | ||
|
||
export enum QUERY_KEY { | ||
tokens = "tokens", | ||
tokenPrices = "token_prices", | ||
} |