generated from auditless/cairo-template
-
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.
- Loading branch information
1 parent
18c41f1
commit f0cbc8a
Showing
6 changed files
with
77 additions
and
4 deletions.
There are no files selected for viewing
Binary file not shown.
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 |
---|---|---|
@@ -1,5 +1,10 @@ | ||
{ | ||
"name": "instaswap", | ||
"version": "0.1.0", | ||
"workspaces": ["packages/*"] | ||
"workspaces": ["packages/*"], | ||
"dependencies": { | ||
"@apollo/client": "^3.8.8", | ||
"graphql": "^16.8.1", | ||
"react-query": "^3.39.3" | ||
} | ||
} |
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,17 @@ | ||
// src/apollo-client.ts | ||
import { ApolloClient, InMemoryCache, HttpLink } from '@apollo/client'; | ||
|
||
// Define your GraphQL server URL here | ||
const GRAPHQL_URL = 'https://instaswap-api.metaforo.io/query'; | ||
|
||
const httpLink = new HttpLink({ | ||
uri: GRAPHQL_URL, | ||
}); | ||
|
||
// Create the Apollo Client instance | ||
const client = new ApolloClient({ | ||
link: httpLink, | ||
cache: new InMemoryCache(), | ||
}); | ||
|
||
export default 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
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,43 @@ | ||
import React from 'react'; | ||
import { useQuery, gql } from '@apollo/client'; | ||
|
||
// Define the TypeScript types for the GraphQL response | ||
type ListLiquidityResponse = { | ||
list_liquidity: { | ||
token_id: number; | ||
}[]; | ||
}; | ||
|
||
// Define the query with the appropriate GraphQL syntax | ||
const GET_LIST_LIQUIDITY = gql` | ||
query getListLiquidity($account: String!) { | ||
list_liquidity(account: $account) { | ||
token_id | ||
} | ||
} | ||
`; | ||
|
||
// Define the TypeScript type for the component props | ||
type LiquidityListProps = { | ||
account: string; | ||
}; | ||
|
||
const LiquidityList: React.FC<LiquidityListProps> = ({ account }) => { | ||
// Use the useQuery hook with the response type | ||
const { loading, error, data } = useQuery<ListLiquidityResponse>(GET_LIST_LIQUIDITY, { | ||
variables: { account }, | ||
}); | ||
|
||
if (loading) return <p>Loading...</p>; | ||
if (error) return <p>An error occurred: {error.message}</p>; | ||
|
||
return ( | ||
<ul> | ||
{data && data.list_liquidity.map((liquidity, index) => ( | ||
<li key={index}>Token ID: {liquidity.token_id}</li> | ||
))} | ||
</ul> | ||
); | ||
}; | ||
|
||
export default LiquidityList; |
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