Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[GSW-624] feat: use react query commonly #242

Merged
merged 2 commits into from
Dec 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Gnoswap Interface
# Gnoswap Interface
Welcome to the open source interface for Gnoswap, the first decentralized exchange (DEX) powered by Gnoland, designed to simplify concentrated liquidity experience and increase capital efficiency for traders.

_Note: Gnoswap is in active development and not yet in production, and we welcome your contributions! Please check our [contribution guidelines](https://github.com/gnoswap-labs/gnoswap-interface#contributing--support) and the [latest release](https://github.com/gnoswap-labs/gnoswap-interface/releases) to see the current development status._
Expand Down
7 changes: 7 additions & 0 deletions packages/web/src/hooks/common/useForceRefetchQuery.tsx
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);
};
2 changes: 2 additions & 0 deletions packages/web/src/react-query/token/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export * from "./types";
export * from "./queries";
28 changes: 28 additions & 0 deletions packages/web/src/react-query/token/queries.ts
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>({
khiemldk marked this conversation as resolved.
Show resolved Hide resolved
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,
});
};
7 changes: 7 additions & 0 deletions packages/web/src/react-query/token/types.ts
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",
}