Skip to content

Commit

Permalink
Merge pull request #242 from gnoswap-labs/GSW-624-Use-react-query-com…
Browse files Browse the repository at this point in the history
…monly
  • Loading branch information
akstar82 authored Dec 7, 2023
2 parents e8fb9f1 + 5eccd52 commit f01a492
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 1 deletion.
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>({
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",
}

0 comments on commit f01a492

Please sign in to comment.