Skip to content

Commit fe13401

Browse files
chore: lint
1 parent 6d49fcd commit fe13401

File tree

6 files changed

+104
-102
lines changed

6 files changed

+104
-102
lines changed

app/page.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
'use client';
22

33
import Triples from 'components/Triples';
4-
import { usePrivy } from '@privy-io/react-auth';
4+
5+
import {usePrivy} from '@privy-io/react-auth';
56

67
export default function Home() {
7-
const { ready } = usePrivy();
8+
const {ready} = usePrivy();
89

910
if (!ready) {
1011
return null;

components/AccountImage.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1+
import {blo} from 'blo';
12
import React from 'react';
2-
import { blo } from 'blo';
3-
import { Address } from 'viem';
3+
import type {Address} from 'viem';
44

55
interface AccountImageProps {
66
id: Address;
77
label?: string | null;
88
image?: string | null;
99
}
1010

11-
export const AccountImage: React.FC<AccountImageProps> = ({ id, label, image }) => {
11+
export const AccountImage: React.FC<AccountImageProps> = ({id, label, image}) => {
1212
return (
1313
<img
1414
src={image || blo(id)}

components/Triples.tsx

Lines changed: 42 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +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 { Address, parseEther } from 'viem';
7-
import { useAccount, useWriteContract, useReadContract } from 'wagmi';
8-
import { usePrivy } from '@privy-io/react-auth';
9-
import { AccountImage } from './AccountImage';
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';
9+
10+
import {usePrivy} from '@privy-io/react-auth';
11+
12+
import {AccountImage} from './AccountImage';
1013

1114
const Triples = () => {
12-
const { login } = usePrivy();
15+
const {login} = usePrivy();
1316
const account = useAccount();
14-
const { writeContractAsync, isPending } = useWriteContract();
17+
const {writeContractAsync, isPending} = useWriteContract();
1518

16-
const { data, error, loading } = useQuery(getTriplesWithMyPosition, {
19+
const {data, error, loading} = useQuery(getTriplesWithMyPosition, {
1720
variables: {
1821
predicateId: 6639,
1922
subjectId: 535,
@@ -47,7 +50,7 @@ const Triples = () => {
4750
functionName: 'redeemTriple',
4851
args: [BigInt(shares), account.address, BigInt(vaultId)],
4952
});
50-
}
53+
};
5154

5255
return (
5356
<div className="border-1 mb-4 flex flex-col items-start gap-2 rounded border border-black bg-slate-100 p-3">
@@ -57,23 +60,28 @@ const Triples = () => {
5760
{data && (
5861
<>
5962
{data.triples.map((triple) => {
60-
const myPositionFor = triple.vault?.myPosition?.length !== 0
61-
const myPositionAgainst = triple.counterVault?.myPosition?.length !== 0
63+
const myPositionFor = triple.vault?.myPosition?.length !== 0;
64+
const myPositionAgainst = triple.counterVault?.myPosition?.length !== 0;
6265

6366
return (
6467
<div key={triple.id} className="mb-4">
6568
<h2 className="text-xl font-bold">{triple.object?.label}</h2>
6669
<p>{triple.object?.value?.thing?.description}</p>
6770

68-
<div className="flex gap-2 mb-2">
71+
<div className="mb-2 flex gap-2">
6972
<button
70-
className={`rounded px-4 py-1 border border-green-800 ${myPositionFor ? 'bg-green-800 text-white' : 'bg-green-200 text-black'} disabled:opacity-50 disabled:cursor-not-allowed`}
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`}
7176
disabled={isPending || myPositionAgainst}
72-
onClick={() => myPositionFor ?
73-
handleRedeemTriple(triple.vault?.id, triple.vault?.myPosition[0].shares)
74-
: handleDepositTriple(triple.vault?.id)
77+
onClick={() =>
78+
myPositionFor
79+
? handleRedeemTriple(triple.vault?.id, triple.vault?.myPosition[0].shares)
80+
: handleDepositTriple(triple.vault?.id)
7581
}
76-
>👍 {triple.vault?.positionCount} </button>
82+
>
83+
👍 {triple.vault?.positionCount}{' '}
84+
</button>
7785
<div className="gap-1">
7886
{triple.vault?.myPosition.map((position) => (
7987
<AccountImage
@@ -97,13 +105,21 @@ const Triples = () => {
97105

98106
<div className="flex gap-2">
99107
<button
100-
className={`rounded px-4 py-1 border border-red-800 ${myPositionAgainst ? 'bg-red-800 text-white' : 'bg-red-100 text-black'} disabled:opacity-50 disabled:cursor-not-allowed `}
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 `}
101111
disabled={isPending || myPositionFor}
102-
onClick={() => myPositionAgainst ?
103-
handleRedeemTriple(triple.counterVault?.id, triple.counterVault?.myPosition[0].shares)
104-
: handleDepositTriple(triple.counterVault?.id)
112+
onClick={() =>
113+
myPositionAgainst
114+
? handleRedeemTriple(
115+
triple.counterVault?.id,
116+
triple.counterVault?.myPosition[0].shares,
117+
)
118+
: handleDepositTriple(triple.counterVault?.id)
105119
}
106-
>👎 {triple.counterVault?.positionCount} </button>
120+
>
121+
👎 {triple.counterVault?.positionCount}{' '}
122+
</button>
107123
<div className="gap-1">
108124
{triple.counterVault?.myPosition.map((position) => (
109125
<AccountImage
@@ -124,9 +140,8 @@ const Triples = () => {
124140
</div>
125141
</div>
126142
</div>
127-
)
128-
}
129-
)}
143+
);
144+
})}
130145
</>
131146
)}
132147
</div>

components/providers.tsx

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
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({
1313
uri: 'https://api.i7n.dev/v1/graphql',
@@ -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

Lines changed: 2 additions & 2 deletions
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-
"\nquery GetTriplesWithMyPosition($predicateId: numeric!, $subjectId: numeric!, $address: String) {\n triples(\n where: { predicateId: { _eq: $predicateId }, subjectId: { _eq: $subjectId } }\n order_by: [\n { vault: { positionCount: desc }, counterVault: { positionCount: desc } }\n ]\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(\n limit: 10\n where: { accountId: { _neq: $address } }\n ) {\n accountId\n account {\n image\n label\n }\n }\n myPosition: positions(\n limit: 1\n where: { accountId: { _eq: $address } }\n ) {\n shares\n accountId\n account {\n image\n label\n }\n }\n }\n counterVault {\n id\n positionCount\n positions(\n limit: 10\n where: { accountId: { _neq: $address } }\n ) {\n accountId\n account {\n image\n label\n }\n }\n myPosition: positions(\n limit: 1\n where: { accountId: { _eq: $address } }\n ) {\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: {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,
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: "\nquery GetTriplesWithMyPosition($predicateId: numeric!, $subjectId: numeric!, $address: String) {\n triples(\n where: { predicateId: { _eq: $predicateId }, subjectId: { _eq: $subjectId } }\n order_by: [\n { vault: { positionCount: desc }, counterVault: { positionCount: desc } }\n ]\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(\n limit: 10\n where: { accountId: { _neq: $address } }\n ) {\n accountId\n account {\n image\n label\n }\n }\n myPosition: positions(\n limit: 1\n where: { accountId: { _eq: $address } }\n ) {\n shares\n accountId\n account {\n image\n label\n }\n }\n }\n counterVault {\n id\n positionCount\n positions(\n limit: 10\n where: { accountId: { _neq: $address } }\n ) {\n accountId\n account {\n image\n label\n }\n }\n myPosition: positions(\n limit: 1\n where: { accountId: { _eq: $address } }\n ) {\n shares\n accountId\n account {\n image\n label\n }\n }\n }\n }\n}\n"): (typeof documents)["\nquery GetTriplesWithMyPosition($predicateId: numeric!, $subjectId: numeric!, $address: String) {\n triples(\n where: { predicateId: { _eq: $predicateId }, subjectId: { _eq: $subjectId } }\n order_by: [\n { vault: { positionCount: desc }, counterVault: { positionCount: desc } }\n ]\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(\n limit: 10\n where: { accountId: { _neq: $address } }\n ) {\n accountId\n account {\n image\n label\n }\n }\n myPosition: positions(\n limit: 1\n where: { accountId: { _eq: $address } }\n ) {\n shares\n accountId\n account {\n image\n label\n }\n }\n }\n counterVault {\n id\n positionCount\n positions(\n limit: 10\n where: { accountId: { _neq: $address } }\n ) {\n accountId\n account {\n image\n label\n }\n }\n myPosition: positions(\n limit: 1\n where: { accountId: { _eq: $address } }\n ) {\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: {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"];
3838

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

lib/queries.ts

Lines changed: 46 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -1,74 +1,60 @@
1-
import { gql } from 'generated/gql';
1+
import {gql} from 'generated/gql';
22

33
export const getTriplesWithMyPosition = gql(/* GraphQL */ `
4-
query GetTriplesWithMyPosition($predicateId: numeric!, $subjectId: numeric!, $address: String) {
5-
triples(
6-
where: { predicateId: { _eq: $predicateId }, subjectId: { _eq: $subjectId } }
7-
order_by: [
8-
{ vault: { positionCount: desc }, counterVault: { positionCount: desc } }
9-
]
10-
) {
11-
id
12-
label
13-
object {
4+
query GetTriplesWithMyPosition($predicateId: numeric!, $subjectId: numeric!, $address: String) {
5+
triples(
6+
where: {predicateId: {_eq: $predicateId}, subjectId: {_eq: $subjectId}}
7+
order_by: [{vault: {positionCount: desc}, counterVault: {positionCount: desc}}]
8+
) {
9+
id
1410
label
15-
value {
16-
thing {
17-
name
18-
description
11+
object {
12+
label
13+
value {
14+
thing {
15+
name
16+
description
17+
}
1918
}
2019
}
21-
}
22-
vault {
23-
id
24-
positionCount
25-
positions(
26-
limit: 10
27-
where: { accountId: { _neq: $address } }
28-
) {
29-
accountId
30-
account {
31-
image
32-
label
20+
vault {
21+
id
22+
positionCount
23+
positions(limit: 10, where: {accountId: {_neq: $address}}) {
24+
accountId
25+
account {
26+
image
27+
label
28+
}
3329
}
34-
}
35-
myPosition: positions(
36-
limit: 1
37-
where: { accountId: { _eq: $address } }
38-
) {
39-
shares
40-
accountId
41-
account {
42-
image
43-
label
30+
myPosition: positions(limit: 1, where: {accountId: {_eq: $address}}) {
31+
shares
32+
accountId
33+
account {
34+
image
35+
label
36+
}
4437
}
4538
}
46-
}
47-
counterVault {
48-
id
49-
positionCount
50-
positions(
51-
limit: 10
52-
where: { accountId: { _neq: $address } }
53-
) {
54-
accountId
55-
account {
56-
image
57-
label
39+
counterVault {
40+
id
41+
positionCount
42+
positions(limit: 10, where: {accountId: {_neq: $address}}) {
43+
accountId
44+
account {
45+
image
46+
label
47+
}
5848
}
59-
}
60-
myPosition: positions(
61-
limit: 1
62-
where: { accountId: { _eq: $address } }
63-
) {
64-
shares
65-
accountId
66-
account {
67-
image
68-
label
49+
myPosition: positions(limit: 1, where: {accountId: {_eq: $address}}) {
50+
shares
51+
accountId
52+
account {
53+
image
54+
label
55+
}
6956
}
7057
}
7158
}
7259
}
73-
}
7460
`);

0 commit comments

Comments
 (0)