Skip to content

Commit ebc802a

Browse files
feat: use new be
1 parent 5f0cf47 commit ebc802a

File tree

10 files changed

+21146
-1263
lines changed

10 files changed

+21146
-1263
lines changed

app/page.tsx

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
'use client';
22

33
import Triples from 'components/Triples';
4+
import SwitchNetwork from 'components/SwitchNetwork';
45

5-
import {usePrivy} from '@privy-io/react-auth';
6-
6+
import { usePrivy } from '@privy-io/react-auth';
77
export default function Home() {
8-
const {ready} = usePrivy();
9-
8+
const { ready } = usePrivy();
109
if (!ready) {
1110
return null;
1211
}
1312

1413
return (
1514
<main className="min-h-screen bg-slate-200 p-4 text-slate-800">
15+
<SwitchNetwork />
1616
<Triples />
1717
</main>
1818
);

codegen.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { CodegenConfig } from '@graphql-codegen/cli';
22

33
const config: CodegenConfig = {
4-
schema: 'https://api.i7n.app/v1/graphql',
4+
schema: 'https://dev.base-sepolia.intuition-api.com/v1/graphql',
55
documents: ['./**/*.{ts,tsx}'],
66
generates: {
77
'./generated/': {

components/SwitchNetwork.tsx

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
'use client';
2+
3+
import Button from 'components/Button';
4+
import { useAccount } from 'wagmi';
5+
import { useSwitchChain } from 'wagmi';
6+
7+
const SwitchNetwork = () => {
8+
const { chain } = useAccount();
9+
10+
const { chains, error: switchNetworkError, switchChain } = useSwitchChain();
11+
12+
return (
13+
<>
14+
{chain && (
15+
<p>
16+
Connected to {chain.name}
17+
</p>
18+
)}
19+
<div className="flex flex-row items-center gap-2">
20+
<p>Switch chains: </p>
21+
{chains.map((x) => (
22+
<Button
23+
disabled={!switchChain || x.id === chain?.id}
24+
key={x.id}
25+
onClick_={() => switchChain?.({ chainId: x.id })}
26+
cta={x.name}
27+
/>
28+
))}
29+
{switchNetworkError && (
30+
<div>Network switch error: {JSON.stringify(switchNetworkError, null, 2)}</div>
31+
)}
32+
</div>
33+
</>
34+
);
35+
};
36+
37+
export default SwitchNetwork;

components/Triples.tsx

+32-34
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
11
'use client';
22

3-
import {useQuery} from '@apollo/client';
4-
import {abi} from 'lib/abi';
5-
import {getTriplesWithMyPosition} from 'lib/queries';
6-
import {parseEther} from 'viem';
7-
import type {Address} from 'viem';
8-
import {useAccount, useWriteContract} from 'wagmi';
3+
import { useQuery } from '@apollo/client';
4+
import { abi } from 'lib/abi';
5+
import { getTriplesWithMyPosition } from 'lib/queries';
6+
import { parseEther } from 'viem';
7+
import type { Address } from 'viem';
8+
import { useAccount, useWriteContract } from 'wagmi';
99

10-
import {usePrivy} from '@privy-io/react-auth';
10+
import { usePrivy } from '@privy-io/react-auth';
1111

12-
import {AccountImage} from './AccountImage';
12+
import { AccountImage } from './AccountImage';
1313

1414
const Triples = () => {
15-
const {login} = usePrivy();
15+
const { login } = usePrivy();
1616
const account = useAccount();
17-
const {writeContractAsync, isPending} = useWriteContract();
17+
const { writeContractAsync, isPending } = useWriteContract();
1818

19-
const {data, error, loading} = useQuery(getTriplesWithMyPosition, {
19+
const { data, error, loading } = useQuery(getTriplesWithMyPosition, {
2020
variables: {
2121
predicateId: 6639,
2222
subjectId: 535,
@@ -61,7 +61,7 @@ const Triples = () => {
6161
<>
6262
{data.triples.map((triple) => {
6363
const myPositionFor = triple.vault?.myPosition?.length !== 0;
64-
const myPositionAgainst = triple.counterVault?.myPosition?.length !== 0;
64+
const myPositionAgainst = triple.counter_vault?.myPosition?.length !== 0;
6565

6666
return (
6767
<div key={triple.id} className="mb-4">
@@ -70,32 +70,31 @@ const Triples = () => {
7070

7171
<div className="mb-2 flex gap-2">
7272
<button
73-
className={`rounded border border-green-800 px-4 py-1 ${
74-
myPositionFor ? 'bg-green-800 text-white' : 'bg-green-200 text-black'
75-
} disabled:cursor-not-allowed disabled:opacity-50`}
73+
className={`rounded border border-green-800 px-4 py-1 ${myPositionFor ? 'bg-green-800 text-white' : 'bg-green-200 text-black'
74+
} disabled:cursor-not-allowed disabled:opacity-50`}
7675
disabled={isPending || myPositionAgainst}
7776
onClick={() =>
7877
myPositionFor
7978
? handleRedeemTriple(triple.vault?.id, triple.vault?.myPosition[0].shares)
8079
: handleDepositTriple(triple.vault?.id)
8180
}
8281
>
83-
👍 {triple.vault?.positionCount}{' '}
82+
👍 {triple.vault?.position_count}{' '}
8483
</button>
8584
<div className="flex flex-row">
8685
{triple.vault?.myPosition.map((position) => (
8786
<AccountImage
88-
key={position.accountId}
89-
id={position.accountId as Address}
87+
key={position.account_id}
88+
id={position.account_id as Address}
9089
image={position.account?.image}
9190
label={position.account?.label}
9291
/>
9392
))}
9493

9594
{triple.vault?.positions.map((position) => (
9695
<AccountImage
97-
key={position.accountId}
98-
id={position.accountId as Address}
96+
key={position.account_id}
97+
id={position.account_id as Address}
9998
image={position.account?.image}
10099
label={position.account?.label}
101100
/>
@@ -105,34 +104,33 @@ const Triples = () => {
105104

106105
<div className="flex gap-2">
107106
<button
108-
className={`rounded border border-red-800 px-4 py-1 ${
109-
myPositionAgainst ? 'bg-red-800 text-white' : 'bg-red-100 text-black'
110-
} disabled:cursor-not-allowed disabled:opacity-50 `}
107+
className={`rounded border border-red-800 px-4 py-1 ${myPositionAgainst ? 'bg-red-800 text-white' : 'bg-red-100 text-black'
108+
} disabled:cursor-not-allowed disabled:opacity-50 `}
111109
disabled={isPending || myPositionFor}
112110
onClick={() =>
113111
myPositionAgainst
114112
? handleRedeemTriple(
115-
triple.counterVault?.id,
116-
triple.counterVault?.myPosition[0].shares,
117-
)
118-
: handleDepositTriple(triple.counterVault?.id)
113+
triple.counter_vault?.id,
114+
triple.counter_vault?.myPosition[0].shares,
115+
)
116+
: handleDepositTriple(triple.counter_vault?.id)
119117
}
120118
>
121-
👎 {triple.counterVault?.positionCount}{' '}
119+
👎 {triple.counter_vault?.position_count}{' '}
122120
</button>
123121
<div className="flex flex-row">
124-
{triple.counterVault?.myPosition.map((position) => (
122+
{triple.counter_vault?.myPosition.map((position) => (
125123
<AccountImage
126-
key={position.accountId}
127-
id={position.accountId as Address}
124+
key={position.account_id}
125+
id={position.account_id as Address}
128126
image={position.account?.image}
129127
label={position.account?.label}
130128
/>
131129
))}
132-
{triple.counterVault?.positions.map((position) => (
130+
{triple.counter_vault?.positions.map((position) => (
133131
<AccountImage
134-
key={position.accountId}
135-
id={position.accountId as Address}
132+
key={position.account_id}
133+
id={position.account_id as Address}
136134
image={position.account?.image}
137135
label={position.account?.label}
138136
/>

components/providers.tsx

+9-9
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
'use client';
22

3-
import {ApolloClient, InMemoryCache, ApolloProvider} from '@apollo/client';
4-
import {QueryClient, QueryClientProvider} from '@tanstack/react-query';
5-
import {http} from 'viem';
6-
import {baseSepolia} from 'viem/chains';
3+
import { ApolloClient, InMemoryCache, ApolloProvider } from '@apollo/client';
4+
import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
5+
import { http } from 'viem';
6+
import { baseSepolia } from 'viem/chains';
77

8-
import type {PrivyClientConfig} from '@privy-io/react-auth';
9-
import {PrivyProvider} from '@privy-io/react-auth';
10-
import {WagmiProvider, createConfig} from '@privy-io/wagmi';
8+
import type { PrivyClientConfig } from '@privy-io/react-auth';
9+
import { PrivyProvider } from '@privy-io/react-auth';
10+
import { WagmiProvider, createConfig } from '@privy-io/wagmi';
1111

1212
const client = new ApolloClient({
13-
uri: 'https://api.i7n.dev/v1/graphql',
13+
uri: 'https://dev.base-sepolia.intuition-api.com/v1/graphql',
1414
cache: new InMemoryCache(),
1515
});
1616

@@ -35,7 +35,7 @@ const privyConfig: PrivyClientConfig = {
3535
},
3636
};
3737

38-
export default function Providers({children}: {children: React.ReactNode}) {
38+
export default function Providers({ children }: { children: React.ReactNode }) {
3939
return (
4040
<PrivyProvider
4141
// eslint-disable-next-line @typescript-eslint/ban-ts-comment

generated/gql.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import { TypedDocumentNode as DocumentNode } from '@graphql-typed-document-node/
1414
* Learn more about it here: https://the-guild.dev/graphql/codegen/plugins/presets/preset-client#reducing-bundle-size
1515
*/
1616
const documents = {
17-
"\n query GetTriplesWithMyPosition($predicateId: numeric!, $subjectId: numeric!, $address: String) {\n triples(\n where: {predicateId: {_eq: $predicateId}, subjectId: {_eq: $subjectId}}\n order_by: [{vault: {positionCount: desc}, counterVault: {positionCount: desc}}]\n ) {\n id\n label\n object {\n label\n value {\n thing {\n name\n description\n }\n }\n }\n vault {\n id\n positionCount\n positions(limit: 10, where: {accountId: {_neq: $address}}) {\n accountId\n account {\n image\n label\n }\n }\n myPosition: positions(limit: 1, where: {accountId: {_eq: $address}}) {\n shares\n accountId\n account {\n image\n label\n }\n }\n }\n counterVault {\n id\n positionCount\n positions(limit: 10, where: {accountId: {_neq: $address}}) {\n accountId\n account {\n image\n label\n }\n }\n myPosition: positions(limit: 1, where: {accountId: {_eq: $address}}) {\n shares\n accountId\n account {\n image\n label\n }\n }\n }\n }\n }\n": types.GetTriplesWithMyPositionDocument,
17+
"\n query GetTriplesWithMyPosition($predicateId: numeric!, $subjectId: numeric!, $address: String) {\n triples(\n where: {predicate_id: {_eq: $predicateId}, subject_id: {_eq: $subjectId}}\n order_by: [{vault: {position_count: desc}, counter_vault: {position_count: desc}}]\n ) {\n id\n object {\n label\n value {\n thing {\n name\n description\n }\n }\n }\n vault {\n id\n position_count\n positions(limit: 10, where: {account_id: {_neq: $address}}) {\n account_id\n account {\n image\n label\n }\n }\n myPosition: positions(limit: 1, where: {account_id: {_eq: $address}}) {\n shares\n account_id\n account {\n image\n label\n }\n }\n }\n counter_vault {\n id\n position_count\n positions(limit: 10, where: {account_id: {_neq: $address}}) {\n account_id\n account {\n image\n label\n }\n }\n myPosition: positions(limit: 1, where: {account_id: {_eq: $address}}) {\n shares\n account_id\n account {\n image\n label\n }\n }\n }\n }\n }\n": types.GetTriplesWithMyPositionDocument,
1818
};
1919

2020
/**
@@ -34,7 +34,7 @@ export function gql(source: string): unknown;
3434
/**
3535
* The gql function is used to parse GraphQL queries into a document that can be used by GraphQL clients.
3636
*/
37-
export function gql(source: "\n query GetTriplesWithMyPosition($predicateId: numeric!, $subjectId: numeric!, $address: String) {\n triples(\n where: {predicateId: {_eq: $predicateId}, subjectId: {_eq: $subjectId}}\n order_by: [{vault: {positionCount: desc}, counterVault: {positionCount: desc}}]\n ) {\n id\n label\n object {\n label\n value {\n thing {\n name\n description\n }\n }\n }\n vault {\n id\n positionCount\n positions(limit: 10, where: {accountId: {_neq: $address}}) {\n accountId\n account {\n image\n label\n }\n }\n myPosition: positions(limit: 1, where: {accountId: {_eq: $address}}) {\n shares\n accountId\n account {\n image\n label\n }\n }\n }\n counterVault {\n id\n positionCount\n positions(limit: 10, where: {accountId: {_neq: $address}}) {\n accountId\n account {\n image\n label\n }\n }\n myPosition: positions(limit: 1, where: {accountId: {_eq: $address}}) {\n shares\n accountId\n account {\n image\n label\n }\n }\n }\n }\n }\n"): (typeof documents)["\n query GetTriplesWithMyPosition($predicateId: numeric!, $subjectId: numeric!, $address: String) {\n triples(\n where: {predicateId: {_eq: $predicateId}, subjectId: {_eq: $subjectId}}\n order_by: [{vault: {positionCount: desc}, counterVault: {positionCount: desc}}]\n ) {\n id\n label\n object {\n label\n value {\n thing {\n name\n description\n }\n }\n }\n vault {\n id\n positionCount\n positions(limit: 10, where: {accountId: {_neq: $address}}) {\n accountId\n account {\n image\n label\n }\n }\n myPosition: positions(limit: 1, where: {accountId: {_eq: $address}}) {\n shares\n accountId\n account {\n image\n label\n }\n }\n }\n counterVault {\n id\n positionCount\n positions(limit: 10, where: {accountId: {_neq: $address}}) {\n accountId\n account {\n image\n label\n }\n }\n myPosition: positions(limit: 1, where: {accountId: {_eq: $address}}) {\n shares\n accountId\n account {\n image\n label\n }\n }\n }\n }\n }\n"];
37+
export function gql(source: "\n query GetTriplesWithMyPosition($predicateId: numeric!, $subjectId: numeric!, $address: String) {\n triples(\n where: {predicate_id: {_eq: $predicateId}, subject_id: {_eq: $subjectId}}\n order_by: [{vault: {position_count: desc}, counter_vault: {position_count: desc}}]\n ) {\n id\n object {\n label\n value {\n thing {\n name\n description\n }\n }\n }\n vault {\n id\n position_count\n positions(limit: 10, where: {account_id: {_neq: $address}}) {\n account_id\n account {\n image\n label\n }\n }\n myPosition: positions(limit: 1, where: {account_id: {_eq: $address}}) {\n shares\n account_id\n account {\n image\n label\n }\n }\n }\n counter_vault {\n id\n position_count\n positions(limit: 10, where: {account_id: {_neq: $address}}) {\n account_id\n account {\n image\n label\n }\n }\n myPosition: positions(limit: 1, where: {account_id: {_eq: $address}}) {\n shares\n account_id\n account {\n image\n label\n }\n }\n }\n }\n }\n"): (typeof documents)["\n query GetTriplesWithMyPosition($predicateId: numeric!, $subjectId: numeric!, $address: String) {\n triples(\n where: {predicate_id: {_eq: $predicateId}, subject_id: {_eq: $subjectId}}\n order_by: [{vault: {position_count: desc}, counter_vault: {position_count: desc}}]\n ) {\n id\n object {\n label\n value {\n thing {\n name\n description\n }\n }\n }\n vault {\n id\n position_count\n positions(limit: 10, where: {account_id: {_neq: $address}}) {\n account_id\n account {\n image\n label\n }\n }\n myPosition: positions(limit: 1, where: {account_id: {_eq: $address}}) {\n shares\n account_id\n account {\n image\n label\n }\n }\n }\n counter_vault {\n id\n position_count\n positions(limit: 10, where: {account_id: {_neq: $address}}) {\n account_id\n account {\n image\n label\n }\n }\n myPosition: positions(limit: 1, where: {account_id: {_eq: $address}}) {\n shares\n account_id\n account {\n image\n label\n }\n }\n }\n }\n }\n"];
3838

3939
export function gql(source: string) {
4040
return (documents as any)[source] ?? {};

0 commit comments

Comments
 (0)