From 3dafadf494119a0f7e1f05af2df66e6df92f5226 Mon Sep 17 00:00:00 2001 From: Vitor Date: Mon, 1 Apr 2024 19:20:38 -0300 Subject: [PATCH] feat: add list of already bridged nfts to create form --- apps/website/.eslintignore | 3 +- apps/website/codegen.ts | 20 + .../components/form-create-l2-erc721.tsx | 45 +- .../event-cache}/gql/fragment-masking.ts | 30 +- apps/website/lib/event-cache/gql/gql.ts | 55 + apps/website/lib/event-cache/gql/graphql.ts | 457 ++++++ .../{queries => lib/event-cache}/gql/index.ts | 0 .../use-all-optimism-mintable-erc721.tsx | 33 + ...timism-mintable-erc721-by-remote-token.tsx | 47 + apps/website/lib/event-cache/use-graphql.ts | 25 + apps/website/package.json | 5 +- apps/website/queries/gql/gql.ts | 36 - apps/website/queries/gql/graphql.ts | 1362 ----------------- .../website/queries/useGetAllERC721Tokens.tsx | 32 - .../queries/useGetTargetERC721Token.tsx | 41 - 15 files changed, 705 insertions(+), 1486 deletions(-) create mode 100644 apps/website/codegen.ts rename apps/website/{queries => lib/event-cache}/gql/fragment-masking.ts (77%) create mode 100644 apps/website/lib/event-cache/gql/gql.ts create mode 100644 apps/website/lib/event-cache/gql/graphql.ts rename apps/website/{queries => lib/event-cache}/gql/index.ts (100%) create mode 100644 apps/website/lib/event-cache/hooks/use-all-optimism-mintable-erc721.tsx create mode 100644 apps/website/lib/event-cache/hooks/use-get-optimism-mintable-erc721-by-remote-token.tsx create mode 100644 apps/website/lib/event-cache/use-graphql.ts delete mode 100644 apps/website/queries/gql/gql.ts delete mode 100644 apps/website/queries/gql/graphql.ts delete mode 100644 apps/website/queries/useGetAllERC721Tokens.tsx delete mode 100644 apps/website/queries/useGetTargetERC721Token.tsx diff --git a/apps/website/.eslintignore b/apps/website/.eslintignore index 0f2eff1..751fa4d 100644 --- a/apps/website/.eslintignore +++ b/apps/website/.eslintignore @@ -3,4 +3,5 @@ **/components/shared/table/** **/generated .next/** -tailwind.config.js \ No newline at end of file +tailwind.config.js +lib/event-cache/gql/fragment-masking.ts \ No newline at end of file diff --git a/apps/website/codegen.ts b/apps/website/codegen.ts new file mode 100644 index 0000000..67829f6 --- /dev/null +++ b/apps/website/codegen.ts @@ -0,0 +1,20 @@ +import { CodegenConfig } from "@graphql-codegen/cli" +import * as dotenv from "dotenv" + +dotenv.config() + +if (!process.env.NEXT_PUBLIC_API_EVENT_CACHE) + throw new Error("NEXT_PUBLIC_API_EVENT_CACHE is not set") + +const config: CodegenConfig = { + schema: process.env.NEXT_PUBLIC_API_EVENT_CACHE, + documents: ["lib/event-cache/hooks/*.tsx"], + ignoreNoDocuments: true, // for better experience with the watcher + generates: { + "./lib/event-cache/gql/": { + preset: "client", + }, + }, +} + +export default config diff --git a/apps/website/components/form-create-l2-erc721.tsx b/apps/website/components/form-create-l2-erc721.tsx index 06cca37..f571103 100644 --- a/apps/website/components/form-create-l2-erc721.tsx +++ b/apps/website/components/form-create-l2-erc721.tsx @@ -7,7 +7,13 @@ import { l1NetworkOptions, l2NetworksOptions } from "@/data/networks/options" import { zodResolver } from "@hookform/resolvers/zod" import { SubmitHandler, useForm } from "react-hook-form" import { useDebounce } from "usehooks-ts" -import { decodeEventLog, type Address, type BaseError } from "viem" +import { + checksumAddress, + decodeEventLog, + isAddress, + type Address, + type BaseError, +} from "viem" import { useAccount, useTransactionReceipt, @@ -15,6 +21,7 @@ import { } from "wagmi" import { z } from "zod" +import { useGetOtimismMintableERC721ByRemoteTokenQuery } from "@/lib/event-cache/hooks/use-get-optimism-mintable-erc721-by-remote-token" import { useReadErc721Name, useReadErc721Symbol, @@ -102,6 +109,19 @@ export const FormCreateL2ERC721 = ({ }, ] + const getOtimismMintableERC721ByRemoteTokenQuery = + useGetOtimismMintableERC721ByRemoteTokenQuery({ + chainId: Number(watchL2ChainId), + remoteToken: isAddress(watchRemoteToken) + ? checksumAddress(watchRemoteToken) + : "0x0", + query: { + enabled: isAddress(watchRemoteToken) && Boolean(Number(watchL2ChainId)), + }, + }) + + getOtimismMintableERC721ByRemoteTokenQuery.data + const { address, chainId: currentChainId } = useAccount() const erc721NameRead = useReadErc721Name({ chainId: l1Chain.chainId, @@ -216,6 +236,29 @@ export const FormCreateL2ERC721 = ({ )} /> + {getOtimismMintableERC721ByRemoteTokenQuery.data && + getOtimismMintableERC721ByRemoteTokenQuery.data + ?.optimismMintableERC721s?.items?.length > 0 && ( +
+

+ This NFT has already been bridged to the L2 network. +

+ + {getOtimismMintableERC721ByRemoteTokenQuery.data?.optimismMintableERC721s?.items?.map( + (item) => ( + + {item.localToken} + + ) + )} + +
+ )} {!address ? ( ) : l2Chain?.chainId === undefined || diff --git a/apps/website/queries/gql/fragment-masking.ts b/apps/website/lib/event-cache/gql/fragment-masking.ts similarity index 77% rename from apps/website/queries/gql/fragment-masking.ts rename to apps/website/lib/event-cache/gql/fragment-masking.ts index 05bf005..36e56ac 100644 --- a/apps/website/queries/gql/fragment-masking.ts +++ b/apps/website/lib/event-cache/gql/fragment-masking.ts @@ -1,10 +1,11 @@ -/* eslint-disable */ import { DocumentTypeDecoration, ResultOf, + TypedDocumentNode, } from "@graphql-typed-document-node/core" +import { FragmentDefinitionNode } from "graphql" -import { Incremental, TypedDocumentString } from "./graphql" +import { Incremental } from "./graphql" export type FragmentType< TDocumentType extends DocumentTypeDecoration @@ -60,21 +61,26 @@ export function makeFragmentData< return data as FragmentType } export function isFragmentReady( - queryNode: TypedDocumentString, - fragmentNode: TypedDocumentString, + queryNode: DocumentTypeDecoration, + fragmentNode: TypedDocumentNode, data: - | FragmentType, any>> + | FragmentType, any>> | null | undefined ): data is FragmentType { - const deferredFields = queryNode.__meta__?.deferredFields as Record< - string, - (keyof TFrag)[] - > - const fragName = fragmentNode.__meta__?.fragmentName as string | undefined + const deferredFields = ( + queryNode as { + __meta__?: { deferredFields: Record } + } + ).__meta__?.deferredFields - if (!deferredFields || !fragName) return true + if (!deferredFields) return true - const fields = deferredFields[fragName] ?? [] + const fragDef = fragmentNode.definitions[0] as + | FragmentDefinitionNode + | undefined + const fragName = fragDef?.name?.value + + const fields = (fragName && deferredFields[fragName]) || [] return fields.length > 0 && fields.every((field) => data && field in data) } diff --git a/apps/website/lib/event-cache/gql/gql.ts b/apps/website/lib/event-cache/gql/gql.ts new file mode 100644 index 0000000..38b7969 --- /dev/null +++ b/apps/website/lib/event-cache/gql/gql.ts @@ -0,0 +1,55 @@ +/* eslint-disable */ +import { TypedDocumentNode as DocumentNode } from "@graphql-typed-document-node/core" + +import * as types from "./graphql" + +/** + * Map of all GraphQL operations in the project. + * + * This map has several performance disadvantages: + * 1. It is not tree-shakeable, so it will include all operations in the project. + * 2. It is not minifiable, so the string of a GraphQL query will be multiple times inside the bundle. + * 3. It does not support dead code elimination, so it will add unused operations. + * + * Therefore it is highly recommended to use the babel or swc plugin for production. + */ +const documents = { + "\n query allOptimismMintableERC721Query($limit: Int) {\n optimismMintableERC721s(limit: $limit) {\n items {\n id\n chainId\n blockNumber\n localToken\n localName\n localSymbol\n remoteToken\n remoteName\n remoteSymbol\n deployer\n }\n }\n }\n": + types.AllOptimismMintableErc721QueryDocument, + "\n query getOtimismMintableERC721ByRemoteTokenQuery(\n $remoteToken: String!\n $chainId: Int!\n ) {\n optimismMintableERC721s(\n where: { remoteToken: $remoteToken, chainId: $chainId }\n ) {\n items {\n id\n chainId\n blockNumber\n localToken\n localName\n localSymbol\n remoteToken\n remoteName\n remoteSymbol\n deployer\n }\n }\n }\n": + types.GetOtimismMintableErc721ByRemoteTokenQueryDocument, +} + +/** + * The graphql function is used to parse GraphQL queries into a document that can be used by GraphQL clients. + * + * + * @example + * ```ts + * const query = graphql(`query GetUser($id: ID!) { user(id: $id) { name } }`); + * ``` + * + * The query argument is unknown! + * Please regenerate the types. + */ +export function graphql(source: string): unknown + +/** + * The graphql function is used to parse GraphQL queries into a document that can be used by GraphQL clients. + */ +export function graphql( + source: "\n query allOptimismMintableERC721Query($limit: Int) {\n optimismMintableERC721s(limit: $limit) {\n items {\n id\n chainId\n blockNumber\n localToken\n localName\n localSymbol\n remoteToken\n remoteName\n remoteSymbol\n deployer\n }\n }\n }\n" +): (typeof documents)["\n query allOptimismMintableERC721Query($limit: Int) {\n optimismMintableERC721s(limit: $limit) {\n items {\n id\n chainId\n blockNumber\n localToken\n localName\n localSymbol\n remoteToken\n remoteName\n remoteSymbol\n deployer\n }\n }\n }\n"] +/** + * The graphql function is used to parse GraphQL queries into a document that can be used by GraphQL clients. + */ +export function graphql( + source: "\n query getOtimismMintableERC721ByRemoteTokenQuery(\n $remoteToken: String!\n $chainId: Int!\n ) {\n optimismMintableERC721s(\n where: { remoteToken: $remoteToken, chainId: $chainId }\n ) {\n items {\n id\n chainId\n blockNumber\n localToken\n localName\n localSymbol\n remoteToken\n remoteName\n remoteSymbol\n deployer\n }\n }\n }\n" +): (typeof documents)["\n query getOtimismMintableERC721ByRemoteTokenQuery(\n $remoteToken: String!\n $chainId: Int!\n ) {\n optimismMintableERC721s(\n where: { remoteToken: $remoteToken, chainId: $chainId }\n ) {\n items {\n id\n chainId\n blockNumber\n localToken\n localName\n localSymbol\n remoteToken\n remoteName\n remoteSymbol\n deployer\n }\n }\n }\n"] + +export function graphql(source: string) { + return (documents as any)[source] ?? {} +} + +export type DocumentType> = + TDocumentNode extends DocumentNode ? TType : never diff --git a/apps/website/lib/event-cache/gql/graphql.ts b/apps/website/lib/event-cache/gql/graphql.ts new file mode 100644 index 0000000..7d6e363 --- /dev/null +++ b/apps/website/lib/event-cache/gql/graphql.ts @@ -0,0 +1,457 @@ +/* eslint-disable */ +import { TypedDocumentNode as DocumentNode } from "@graphql-typed-document-node/core" + +export type Maybe = T | null +export type InputMaybe = Maybe +export type Exact = { + [K in keyof T]: T[K] +} +export type MakeOptional = Omit & { + [SubKey in K]?: Maybe +} +export type MakeMaybe = Omit & { + [SubKey in K]: Maybe +} +export type MakeEmpty< + T extends { [key: string]: unknown }, + K extends keyof T +> = { [_ in K]?: never } +export type Incremental = + | T + | { + [P in keyof T]?: P extends " $fragmentName" | "__typename" ? T[P] : never + } +/** All built-in and custom scalars, mapped to their actual values */ +export type Scalars = { + ID: { input: string; output: string } + String: { input: string; output: string } + Boolean: { input: boolean; output: boolean } + Int: { input: number; output: number } + Float: { input: number; output: number } + BigInt: { input: any; output: any } +} + +export type OptimismMintableErc721 = { + __typename?: "OptimismMintableERC721" + blockNumber: Scalars["BigInt"]["output"] + chainId: Scalars["Int"]["output"] + deployer: Scalars["String"]["output"] + id: Scalars["String"]["output"] + localName?: Maybe + localSymbol?: Maybe + localToken: Scalars["String"]["output"] + remoteName?: Maybe + remoteSymbol?: Maybe + remoteToken: Scalars["String"]["output"] +} + +export type OptimismMintableErc721Filter = { + AND?: InputMaybe>> + OR?: InputMaybe>> + blockNumber?: InputMaybe + blockNumber_gt?: InputMaybe + blockNumber_gte?: InputMaybe + blockNumber_in?: InputMaybe>> + blockNumber_lt?: InputMaybe + blockNumber_lte?: InputMaybe + blockNumber_not?: InputMaybe + blockNumber_not_in?: InputMaybe>> + chainId?: InputMaybe + chainId_gt?: InputMaybe + chainId_gte?: InputMaybe + chainId_in?: InputMaybe>> + chainId_lt?: InputMaybe + chainId_lte?: InputMaybe + chainId_not?: InputMaybe + chainId_not_in?: InputMaybe>> + deployer?: InputMaybe + deployer_contains?: InputMaybe + deployer_ends_with?: InputMaybe + deployer_in?: InputMaybe>> + deployer_not?: InputMaybe + deployer_not_contains?: InputMaybe + deployer_not_ends_with?: InputMaybe + deployer_not_in?: InputMaybe>> + deployer_not_starts_with?: InputMaybe + deployer_starts_with?: InputMaybe + id?: InputMaybe + id_contains?: InputMaybe + id_ends_with?: InputMaybe + id_in?: InputMaybe>> + id_not?: InputMaybe + id_not_contains?: InputMaybe + id_not_ends_with?: InputMaybe + id_not_in?: InputMaybe>> + id_not_starts_with?: InputMaybe + id_starts_with?: InputMaybe + localName?: InputMaybe + localName_contains?: InputMaybe + localName_ends_with?: InputMaybe + localName_in?: InputMaybe>> + localName_not?: InputMaybe + localName_not_contains?: InputMaybe + localName_not_ends_with?: InputMaybe + localName_not_in?: InputMaybe>> + localName_not_starts_with?: InputMaybe + localName_starts_with?: InputMaybe + localSymbol?: InputMaybe + localSymbol_contains?: InputMaybe + localSymbol_ends_with?: InputMaybe + localSymbol_in?: InputMaybe>> + localSymbol_not?: InputMaybe + localSymbol_not_contains?: InputMaybe + localSymbol_not_ends_with?: InputMaybe + localSymbol_not_in?: InputMaybe>> + localSymbol_not_starts_with?: InputMaybe + localSymbol_starts_with?: InputMaybe + localToken?: InputMaybe + localToken_contains?: InputMaybe + localToken_ends_with?: InputMaybe + localToken_in?: InputMaybe>> + localToken_not?: InputMaybe + localToken_not_contains?: InputMaybe + localToken_not_ends_with?: InputMaybe + localToken_not_in?: InputMaybe>> + localToken_not_starts_with?: InputMaybe + localToken_starts_with?: InputMaybe + remoteName?: InputMaybe + remoteName_contains?: InputMaybe + remoteName_ends_with?: InputMaybe + remoteName_in?: InputMaybe>> + remoteName_not?: InputMaybe + remoteName_not_contains?: InputMaybe + remoteName_not_ends_with?: InputMaybe + remoteName_not_in?: InputMaybe>> + remoteName_not_starts_with?: InputMaybe + remoteName_starts_with?: InputMaybe + remoteSymbol?: InputMaybe + remoteSymbol_contains?: InputMaybe + remoteSymbol_ends_with?: InputMaybe + remoteSymbol_in?: InputMaybe>> + remoteSymbol_not?: InputMaybe + remoteSymbol_not_contains?: InputMaybe + remoteSymbol_not_ends_with?: InputMaybe + remoteSymbol_not_in?: InputMaybe< + Array> + > + remoteSymbol_not_starts_with?: InputMaybe + remoteSymbol_starts_with?: InputMaybe + remoteToken?: InputMaybe + remoteToken_contains?: InputMaybe + remoteToken_ends_with?: InputMaybe + remoteToken_in?: InputMaybe>> + remoteToken_not?: InputMaybe + remoteToken_not_contains?: InputMaybe + remoteToken_not_ends_with?: InputMaybe + remoteToken_not_in?: InputMaybe>> + remoteToken_not_starts_with?: InputMaybe + remoteToken_starts_with?: InputMaybe +} + +export type OptimismMintableErc721Page = { + __typename?: "OptimismMintableERC721Page" + items: Array + pageInfo: PageInfo +} + +export type PageInfo = { + __typename?: "PageInfo" + endCursor?: Maybe + hasNextPage: Scalars["Boolean"]["output"] + hasPreviousPage: Scalars["Boolean"]["output"] + startCursor?: Maybe +} + +export type Query = { + __typename?: "Query" + optimismMintableERC721?: Maybe + optimismMintableERC721s: OptimismMintableErc721Page +} + +export type QueryOptimismMintableErc721Args = { + id: Scalars["String"]["input"] + timestamp?: InputMaybe +} + +export type QueryOptimismMintableErc721sArgs = { + after?: InputMaybe + before?: InputMaybe + limit?: InputMaybe + orderBy?: InputMaybe + orderDirection?: InputMaybe + timestamp?: InputMaybe + where?: InputMaybe +} + +export type AllOptimismMintableErc721QueryQueryVariables = Exact<{ + limit?: InputMaybe +}> + +export type AllOptimismMintableErc721QueryQuery = { + __typename?: "Query" + optimismMintableERC721s: { + __typename?: "OptimismMintableERC721Page" + items: Array<{ + __typename?: "OptimismMintableERC721" + id: string + chainId: number + blockNumber: any + localToken: string + localName?: string | null + localSymbol?: string | null + remoteToken: string + remoteName?: string | null + remoteSymbol?: string | null + deployer: string + }> + } +} + +export type GetOtimismMintableErc721ByRemoteTokenQueryQueryVariables = Exact<{ + remoteToken: Scalars["String"]["input"] + chainId: Scalars["Int"]["input"] +}> + +export type GetOtimismMintableErc721ByRemoteTokenQueryQuery = { + __typename?: "Query" + optimismMintableERC721s: { + __typename?: "OptimismMintableERC721Page" + items: Array<{ + __typename?: "OptimismMintableERC721" + id: string + chainId: number + blockNumber: any + localToken: string + localName?: string | null + localSymbol?: string | null + remoteToken: string + remoteName?: string | null + remoteSymbol?: string | null + deployer: string + }> + } +} + +export const AllOptimismMintableErc721QueryDocument = { + kind: "Document", + definitions: [ + { + kind: "OperationDefinition", + operation: "query", + name: { kind: "Name", value: "allOptimismMintableERC721Query" }, + variableDefinitions: [ + { + kind: "VariableDefinition", + variable: { + kind: "Variable", + name: { kind: "Name", value: "limit" }, + }, + type: { kind: "NamedType", name: { kind: "Name", value: "Int" } }, + }, + ], + selectionSet: { + kind: "SelectionSet", + selections: [ + { + kind: "Field", + name: { kind: "Name", value: "optimismMintableERC721s" }, + arguments: [ + { + kind: "Argument", + name: { kind: "Name", value: "limit" }, + value: { + kind: "Variable", + name: { kind: "Name", value: "limit" }, + }, + }, + ], + selectionSet: { + kind: "SelectionSet", + selections: [ + { + kind: "Field", + name: { kind: "Name", value: "items" }, + selectionSet: { + kind: "SelectionSet", + selections: [ + { kind: "Field", name: { kind: "Name", value: "id" } }, + { + kind: "Field", + name: { kind: "Name", value: "chainId" }, + }, + { + kind: "Field", + name: { kind: "Name", value: "blockNumber" }, + }, + { + kind: "Field", + name: { kind: "Name", value: "localToken" }, + }, + { + kind: "Field", + name: { kind: "Name", value: "localName" }, + }, + { + kind: "Field", + name: { kind: "Name", value: "localSymbol" }, + }, + { + kind: "Field", + name: { kind: "Name", value: "remoteToken" }, + }, + { + kind: "Field", + name: { kind: "Name", value: "remoteName" }, + }, + { + kind: "Field", + name: { kind: "Name", value: "remoteSymbol" }, + }, + { + kind: "Field", + name: { kind: "Name", value: "deployer" }, + }, + ], + }, + }, + ], + }, + }, + ], + }, + }, + ], +} as unknown as DocumentNode< + AllOptimismMintableErc721QueryQuery, + AllOptimismMintableErc721QueryQueryVariables +> +export const GetOtimismMintableErc721ByRemoteTokenQueryDocument = { + kind: "Document", + definitions: [ + { + kind: "OperationDefinition", + operation: "query", + name: { + kind: "Name", + value: "getOtimismMintableERC721ByRemoteTokenQuery", + }, + variableDefinitions: [ + { + kind: "VariableDefinition", + variable: { + kind: "Variable", + name: { kind: "Name", value: "remoteToken" }, + }, + type: { + kind: "NonNullType", + type: { + kind: "NamedType", + name: { kind: "Name", value: "String" }, + }, + }, + }, + { + kind: "VariableDefinition", + variable: { + kind: "Variable", + name: { kind: "Name", value: "chainId" }, + }, + type: { + kind: "NonNullType", + type: { kind: "NamedType", name: { kind: "Name", value: "Int" } }, + }, + }, + ], + selectionSet: { + kind: "SelectionSet", + selections: [ + { + kind: "Field", + name: { kind: "Name", value: "optimismMintableERC721s" }, + arguments: [ + { + kind: "Argument", + name: { kind: "Name", value: "where" }, + value: { + kind: "ObjectValue", + fields: [ + { + kind: "ObjectField", + name: { kind: "Name", value: "remoteToken" }, + value: { + kind: "Variable", + name: { kind: "Name", value: "remoteToken" }, + }, + }, + { + kind: "ObjectField", + name: { kind: "Name", value: "chainId" }, + value: { + kind: "Variable", + name: { kind: "Name", value: "chainId" }, + }, + }, + ], + }, + }, + ], + selectionSet: { + kind: "SelectionSet", + selections: [ + { + kind: "Field", + name: { kind: "Name", value: "items" }, + selectionSet: { + kind: "SelectionSet", + selections: [ + { kind: "Field", name: { kind: "Name", value: "id" } }, + { + kind: "Field", + name: { kind: "Name", value: "chainId" }, + }, + { + kind: "Field", + name: { kind: "Name", value: "blockNumber" }, + }, + { + kind: "Field", + name: { kind: "Name", value: "localToken" }, + }, + { + kind: "Field", + name: { kind: "Name", value: "localName" }, + }, + { + kind: "Field", + name: { kind: "Name", value: "localSymbol" }, + }, + { + kind: "Field", + name: { kind: "Name", value: "remoteToken" }, + }, + { + kind: "Field", + name: { kind: "Name", value: "remoteName" }, + }, + { + kind: "Field", + name: { kind: "Name", value: "remoteSymbol" }, + }, + { + kind: "Field", + name: { kind: "Name", value: "deployer" }, + }, + ], + }, + }, + ], + }, + }, + ], + }, + }, + ], +} as unknown as DocumentNode< + GetOtimismMintableErc721ByRemoteTokenQueryQuery, + GetOtimismMintableErc721ByRemoteTokenQueryQueryVariables +> diff --git a/apps/website/queries/gql/index.ts b/apps/website/lib/event-cache/gql/index.ts similarity index 100% rename from apps/website/queries/gql/index.ts rename to apps/website/lib/event-cache/gql/index.ts diff --git a/apps/website/lib/event-cache/hooks/use-all-optimism-mintable-erc721.tsx b/apps/website/lib/event-cache/hooks/use-all-optimism-mintable-erc721.tsx new file mode 100644 index 0000000..52a5d4f --- /dev/null +++ b/apps/website/lib/event-cache/hooks/use-all-optimism-mintable-erc721.tsx @@ -0,0 +1,33 @@ +import { graphql } from "../gql" +import { useGraphQL } from "../use-graphql" + +const allOptimismMintableErc721Query = graphql(/* GraphQL */ ` + query allOptimismMintableERC721Query($limit: Int) { + optimismMintableERC721s(limit: $limit) { + items { + id + chainId + blockNumber + localToken + localName + localSymbol + remoteToken + remoteName + remoteSymbol + deployer + } + } + } +`) + +export function useAllOptimismMintableERC721( + params: { limit: number | undefined } = { limit: undefined } +) { + return useGraphQL( + allOptimismMintableErc721Query, + { + queryKey: ["allOptimismMintableERC721", params], + }, + params + ) +} diff --git a/apps/website/lib/event-cache/hooks/use-get-optimism-mintable-erc721-by-remote-token.tsx b/apps/website/lib/event-cache/hooks/use-get-optimism-mintable-erc721-by-remote-token.tsx new file mode 100644 index 0000000..c1ea95f --- /dev/null +++ b/apps/website/lib/event-cache/hooks/use-get-optimism-mintable-erc721-by-remote-token.tsx @@ -0,0 +1,47 @@ +import { Address } from "viem" + +import { graphql } from "../gql" +import { useGraphQL } from "../use-graphql" + +const getOtimismMintableERC721ByRemoteTokenQuery = graphql(/* GraphQL */ ` + query getOtimismMintableERC721ByRemoteTokenQuery( + $remoteToken: String! + $chainId: Int! + ) { + optimismMintableERC721s( + where: { remoteToken: $remoteToken, chainId: $chainId } + ) { + items { + id + chainId + blockNumber + localToken + localName + localSymbol + remoteToken + remoteName + remoteSymbol + deployer + } + } + } +`) + +export function useGetOtimismMintableERC721ByRemoteTokenQuery(params: { + remoteToken: Address + chainId: number + query?: { enabled: boolean } +}) { + return useGraphQL( + getOtimismMintableERC721ByRemoteTokenQuery, + { + queryKey: [ + "getOtimismMintableERC721ByRemoteToken", + params.chainId, + params.remoteToken, + ], + enabled: params.query?.enabled, + }, + params + ) +} diff --git a/apps/website/lib/event-cache/use-graphql.ts b/apps/website/lib/event-cache/use-graphql.ts new file mode 100644 index 0000000..44139f4 --- /dev/null +++ b/apps/website/lib/event-cache/use-graphql.ts @@ -0,0 +1,25 @@ +import { env } from "@/env.mjs" +import { type TypedDocumentNode } from "@graphql-typed-document-node/core" +import { + useQuery, + type UndefinedInitialDataOptions, + type UseQueryResult, +} from "@tanstack/react-query" +import request from "graphql-request" + +export function useGraphQL( + document: TypedDocumentNode, + options: UndefinedInitialDataOptions, + ...[variables]: TVariables extends Record ? [] : [TVariables] +): UseQueryResult { + return useQuery({ + ...options, + queryKey: [(document.definitions[0] as any).name.value, variables], + queryFn: async ({ queryKey }) => + request( + env.NEXT_PUBLIC_API_EVENT_CACHE, + document, + queryKey[1] ? queryKey[1] : undefined + ), + }) +} diff --git a/apps/website/package.json b/apps/website/package.json index 4bcb581..fcf49ed 100644 --- a/apps/website/package.json +++ b/apps/website/package.json @@ -49,7 +49,8 @@ "class-variance-authority": "^0.4.0", "clsx": "^1.2.1", "cmdk": "^0.2.0", - "graphql-request": "^6.1.0", + "graphql": "^16.8.1", + "graphql-request": "^5.2.0", "jotai": "^1.13.0", "next": "14.0.3", "next-themes": "^0.2.1", @@ -70,6 +71,7 @@ "@graphql-codegen/cli": "^5.0.0", "@graphql-codegen/client-preset": "^4.1.0", "@ianvs/prettier-plugin-sort-imports": "^4.1.0", + "@parcel/watcher": "^2.4.1", "@svgr/webpack": "^6.5.1", "@tsconfig/next": "^1.0.4", "@types/luxon": "^3.2.0", @@ -81,6 +83,7 @@ "@wagmi/cli": "^2.1.2", "autoprefixer": "^10.4.13", "concurrently": "^8.2.0", + "dotenv": "^16.4.5", "eslint": "8.30.0", "eslint-config-next": "14.0.3", "eslint-config-prettier": "^8.5.0", diff --git a/apps/website/queries/gql/gql.ts b/apps/website/queries/gql/gql.ts deleted file mode 100644 index 8fb8495..0000000 --- a/apps/website/queries/gql/gql.ts +++ /dev/null @@ -1,36 +0,0 @@ -/* eslint-disable */ -import * as types from "./graphql" - -/** - * Map of all GraphQL operations in the project. - * - * This map has several performance disadvantages: - * 1. It is not tree-shakeable, so it will include all operations in the project. - * 2. It is not minifiable, so the string of a GraphQL query will be multiple times inside the bundle. - * 3. It does not support dead code elimination, so it will add unused operations. - * - * Therefore it is highly recommended to use the babel or swc plugin for production. - */ -const documents = { - "\n query allFilmsWithVariablesQuery($first: Int!) {\n allFilms(first: $first) {\n edges {\n node {\n ...FilmItem\n }\n }\n }\n }\n": - types.AllFilmsWithVariablesQueryDocument, - "\n fragment FilmItem on Film {\n id\n title\n releaseDate\n producers\n }\n": - types.FilmItemFragmentDoc, -} - -/** - * The graphql function is used to parse GraphQL queries into a document that can be used by GraphQL clients. - */ -export function graphql( - source: "\n query allFilmsWithVariablesQuery($first: Int!) {\n allFilms(first: $first) {\n edges {\n node {\n ...FilmItem\n }\n }\n }\n }\n" -): typeof import("./graphql").AllFilmsWithVariablesQueryDocument -/** - * The graphql function is used to parse GraphQL queries into a document that can be used by GraphQL clients. - */ -export function graphql( - source: "\n fragment FilmItem on Film {\n id\n title\n releaseDate\n producers\n }\n" -): typeof import("./graphql").FilmItemFragmentDoc - -export function graphql(source: string) { - return (documents as any)[source] ?? {} -} diff --git a/apps/website/queries/gql/graphql.ts b/apps/website/queries/gql/graphql.ts deleted file mode 100644 index 4665c04..0000000 --- a/apps/website/queries/gql/graphql.ts +++ /dev/null @@ -1,1362 +0,0 @@ -/* eslint-disable */ -import { DocumentTypeDecoration } from "@graphql-typed-document-node/core" - -export type Maybe = T | null -export type InputMaybe = Maybe -export type Exact = { - [K in keyof T]: T[K] -} -export type MakeOptional = Omit & { - [SubKey in K]?: Maybe -} -export type MakeMaybe = Omit & { - [SubKey in K]: Maybe -} -export type MakeEmpty< - T extends { [key: string]: unknown }, - K extends keyof T -> = { [_ in K]?: never } -export type Incremental = - | T - | { - [P in keyof T]?: P extends " $fragmentName" | "__typename" ? T[P] : never - } -/** All built-in and custom scalars, mapped to their actual values */ -export type Scalars = { - ID: { input: string; output: string } - String: { input: string; output: string } - Boolean: { input: boolean; output: boolean } - Int: { input: number; output: number } - Float: { input: number; output: number } -} - -/** A single film. */ -export type Film = Node & { - __typename?: "Film" - characterConnection?: Maybe - /** The ISO 8601 date format of the time that this resource was created. */ - created?: Maybe - /** The name of the director of this film. */ - director?: Maybe - /** The ISO 8601 date format of the time that this resource was edited. */ - edited?: Maybe - /** The episode number of this film. */ - episodeID?: Maybe - /** The ID of an object */ - id: Scalars["ID"]["output"] - /** The opening paragraphs at the beginning of this film. */ - openingCrawl?: Maybe - planetConnection?: Maybe - /** The name(s) of the producer(s) of this film. */ - producers?: Maybe>> - /** The ISO 8601 date format of film release at original creator country. */ - releaseDate?: Maybe - speciesConnection?: Maybe - starshipConnection?: Maybe - /** The title of this film. */ - title?: Maybe - vehicleConnection?: Maybe -} - -/** A single film. */ -export type FilmCharacterConnectionArgs = { - after?: InputMaybe - before?: InputMaybe - first?: InputMaybe - last?: InputMaybe -} - -/** A single film. */ -export type FilmPlanetConnectionArgs = { - after?: InputMaybe - before?: InputMaybe - first?: InputMaybe - last?: InputMaybe -} - -/** A single film. */ -export type FilmSpeciesConnectionArgs = { - after?: InputMaybe - before?: InputMaybe - first?: InputMaybe - last?: InputMaybe -} - -/** A single film. */ -export type FilmStarshipConnectionArgs = { - after?: InputMaybe - before?: InputMaybe - first?: InputMaybe - last?: InputMaybe -} - -/** A single film. */ -export type FilmVehicleConnectionArgs = { - after?: InputMaybe - before?: InputMaybe - first?: InputMaybe - last?: InputMaybe -} - -/** A connection to a list of items. */ -export type FilmCharactersConnection = { - __typename?: "FilmCharactersConnection" - /** - * A list of all of the objects returned in the connection. This is a convenience - * field provided for quickly exploring the API; rather than querying for - * "{ edges { node } }" when no edge data is needed, this field can be be used - * instead. Note that when clients like Relay need to fetch the "cursor" field on - * the edge to enable efficient pagination, this shortcut cannot be used, and the - * full "{ edges { node } }" version should be used instead. - */ - characters?: Maybe>> - /** A list of edges. */ - edges?: Maybe>> - /** Information to aid in pagination. */ - pageInfo: PageInfo - /** - * A count of the total number of objects in this connection, ignoring pagination. - * This allows a client to fetch the first five objects by passing "5" as the - * argument to "first", then fetch the total count so it could display "5 of 83", - * for example. - */ - totalCount?: Maybe -} - -/** An edge in a connection. */ -export type FilmCharactersEdge = { - __typename?: "FilmCharactersEdge" - /** A cursor for use in pagination */ - cursor: Scalars["String"]["output"] - /** The item at the end of the edge */ - node?: Maybe -} - -/** A connection to a list of items. */ -export type FilmPlanetsConnection = { - __typename?: "FilmPlanetsConnection" - /** A list of edges. */ - edges?: Maybe>> - /** Information to aid in pagination. */ - pageInfo: PageInfo - /** - * A list of all of the objects returned in the connection. This is a convenience - * field provided for quickly exploring the API; rather than querying for - * "{ edges { node } }" when no edge data is needed, this field can be be used - * instead. Note that when clients like Relay need to fetch the "cursor" field on - * the edge to enable efficient pagination, this shortcut cannot be used, and the - * full "{ edges { node } }" version should be used instead. - */ - planets?: Maybe>> - /** - * A count of the total number of objects in this connection, ignoring pagination. - * This allows a client to fetch the first five objects by passing "5" as the - * argument to "first", then fetch the total count so it could display "5 of 83", - * for example. - */ - totalCount?: Maybe -} - -/** An edge in a connection. */ -export type FilmPlanetsEdge = { - __typename?: "FilmPlanetsEdge" - /** A cursor for use in pagination */ - cursor: Scalars["String"]["output"] - /** The item at the end of the edge */ - node?: Maybe -} - -/** A connection to a list of items. */ -export type FilmSpeciesConnection = { - __typename?: "FilmSpeciesConnection" - /** A list of edges. */ - edges?: Maybe>> - /** Information to aid in pagination. */ - pageInfo: PageInfo - /** - * A list of all of the objects returned in the connection. This is a convenience - * field provided for quickly exploring the API; rather than querying for - * "{ edges { node } }" when no edge data is needed, this field can be be used - * instead. Note that when clients like Relay need to fetch the "cursor" field on - * the edge to enable efficient pagination, this shortcut cannot be used, and the - * full "{ edges { node } }" version should be used instead. - */ - species?: Maybe>> - /** - * A count of the total number of objects in this connection, ignoring pagination. - * This allows a client to fetch the first five objects by passing "5" as the - * argument to "first", then fetch the total count so it could display "5 of 83", - * for example. - */ - totalCount?: Maybe -} - -/** An edge in a connection. */ -export type FilmSpeciesEdge = { - __typename?: "FilmSpeciesEdge" - /** A cursor for use in pagination */ - cursor: Scalars["String"]["output"] - /** The item at the end of the edge */ - node?: Maybe -} - -/** A connection to a list of items. */ -export type FilmStarshipsConnection = { - __typename?: "FilmStarshipsConnection" - /** A list of edges. */ - edges?: Maybe>> - /** Information to aid in pagination. */ - pageInfo: PageInfo - /** - * A list of all of the objects returned in the connection. This is a convenience - * field provided for quickly exploring the API; rather than querying for - * "{ edges { node } }" when no edge data is needed, this field can be be used - * instead. Note that when clients like Relay need to fetch the "cursor" field on - * the edge to enable efficient pagination, this shortcut cannot be used, and the - * full "{ edges { node } }" version should be used instead. - */ - starships?: Maybe>> - /** - * A count of the total number of objects in this connection, ignoring pagination. - * This allows a client to fetch the first five objects by passing "5" as the - * argument to "first", then fetch the total count so it could display "5 of 83", - * for example. - */ - totalCount?: Maybe -} - -/** An edge in a connection. */ -export type FilmStarshipsEdge = { - __typename?: "FilmStarshipsEdge" - /** A cursor for use in pagination */ - cursor: Scalars["String"]["output"] - /** The item at the end of the edge */ - node?: Maybe -} - -/** A connection to a list of items. */ -export type FilmVehiclesConnection = { - __typename?: "FilmVehiclesConnection" - /** A list of edges. */ - edges?: Maybe>> - /** Information to aid in pagination. */ - pageInfo: PageInfo - /** - * A count of the total number of objects in this connection, ignoring pagination. - * This allows a client to fetch the first five objects by passing "5" as the - * argument to "first", then fetch the total count so it could display "5 of 83", - * for example. - */ - totalCount?: Maybe - /** - * A list of all of the objects returned in the connection. This is a convenience - * field provided for quickly exploring the API; rather than querying for - * "{ edges { node } }" when no edge data is needed, this field can be be used - * instead. Note that when clients like Relay need to fetch the "cursor" field on - * the edge to enable efficient pagination, this shortcut cannot be used, and the - * full "{ edges { node } }" version should be used instead. - */ - vehicles?: Maybe>> -} - -/** An edge in a connection. */ -export type FilmVehiclesEdge = { - __typename?: "FilmVehiclesEdge" - /** A cursor for use in pagination */ - cursor: Scalars["String"]["output"] - /** The item at the end of the edge */ - node?: Maybe -} - -/** A connection to a list of items. */ -export type FilmsConnection = { - __typename?: "FilmsConnection" - /** A list of edges. */ - edges?: Maybe>> - /** - * A list of all of the objects returned in the connection. This is a convenience - * field provided for quickly exploring the API; rather than querying for - * "{ edges { node } }" when no edge data is needed, this field can be be used - * instead. Note that when clients like Relay need to fetch the "cursor" field on - * the edge to enable efficient pagination, this shortcut cannot be used, and the - * full "{ edges { node } }" version should be used instead. - */ - films?: Maybe>> - /** Information to aid in pagination. */ - pageInfo: PageInfo - /** - * A count of the total number of objects in this connection, ignoring pagination. - * This allows a client to fetch the first five objects by passing "5" as the - * argument to "first", then fetch the total count so it could display "5 of 83", - * for example. - */ - totalCount?: Maybe -} - -/** An edge in a connection. */ -export type FilmsEdge = { - __typename?: "FilmsEdge" - /** A cursor for use in pagination */ - cursor: Scalars["String"]["output"] - /** The item at the end of the edge */ - node?: Maybe -} - -/** An object with an ID */ -export type Node = { - /** The id of the object. */ - id: Scalars["ID"]["output"] -} - -/** Information about pagination in a connection. */ -export type PageInfo = { - __typename?: "PageInfo" - /** When paginating forwards, the cursor to continue. */ - endCursor?: Maybe - /** When paginating forwards, are there more items? */ - hasNextPage: Scalars["Boolean"]["output"] - /** When paginating backwards, are there more items? */ - hasPreviousPage: Scalars["Boolean"]["output"] - /** When paginating backwards, the cursor to continue. */ - startCursor?: Maybe -} - -/** A connection to a list of items. */ -export type PeopleConnection = { - __typename?: "PeopleConnection" - /** A list of edges. */ - edges?: Maybe>> - /** Information to aid in pagination. */ - pageInfo: PageInfo - /** - * A list of all of the objects returned in the connection. This is a convenience - * field provided for quickly exploring the API; rather than querying for - * "{ edges { node } }" when no edge data is needed, this field can be be used - * instead. Note that when clients like Relay need to fetch the "cursor" field on - * the edge to enable efficient pagination, this shortcut cannot be used, and the - * full "{ edges { node } }" version should be used instead. - */ - people?: Maybe>> - /** - * A count of the total number of objects in this connection, ignoring pagination. - * This allows a client to fetch the first five objects by passing "5" as the - * argument to "first", then fetch the total count so it could display "5 of 83", - * for example. - */ - totalCount?: Maybe -} - -/** An edge in a connection. */ -export type PeopleEdge = { - __typename?: "PeopleEdge" - /** A cursor for use in pagination */ - cursor: Scalars["String"]["output"] - /** The item at the end of the edge */ - node?: Maybe -} - -/** An individual person or character within the Star Wars universe. */ -export type Person = Node & { - __typename?: "Person" - /** - * The birth year of the person, using the in-universe standard of BBY or ABY - - * Before the Battle of Yavin or After the Battle of Yavin. The Battle of Yavin is - * a battle that occurs at the end of Star Wars episode IV: A New Hope. - */ - birthYear?: Maybe - /** The ISO 8601 date format of the time that this resource was created. */ - created?: Maybe - /** The ISO 8601 date format of the time that this resource was edited. */ - edited?: Maybe - /** - * The eye color of this person. Will be "unknown" if not known or "n/a" if the - * person does not have an eye. - */ - eyeColor?: Maybe - filmConnection?: Maybe - /** - * The gender of this person. Either "Male", "Female" or "unknown", - * "n/a" if the person does not have a gender. - */ - gender?: Maybe - /** - * The hair color of this person. Will be "unknown" if not known or "n/a" if the - * person does not have hair. - */ - hairColor?: Maybe - /** The height of the person in centimeters. */ - height?: Maybe - /** A planet that this person was born on or inhabits. */ - homeworld?: Maybe - /** The ID of an object */ - id: Scalars["ID"]["output"] - /** The mass of the person in kilograms. */ - mass?: Maybe - /** The name of this person. */ - name?: Maybe - /** The skin color of this person. */ - skinColor?: Maybe - /** The species that this person belongs to, or null if unknown. */ - species?: Maybe - starshipConnection?: Maybe - vehicleConnection?: Maybe -} - -/** An individual person or character within the Star Wars universe. */ -export type PersonFilmConnectionArgs = { - after?: InputMaybe - before?: InputMaybe - first?: InputMaybe - last?: InputMaybe -} - -/** An individual person or character within the Star Wars universe. */ -export type PersonStarshipConnectionArgs = { - after?: InputMaybe - before?: InputMaybe - first?: InputMaybe - last?: InputMaybe -} - -/** An individual person or character within the Star Wars universe. */ -export type PersonVehicleConnectionArgs = { - after?: InputMaybe - before?: InputMaybe - first?: InputMaybe - last?: InputMaybe -} - -/** A connection to a list of items. */ -export type PersonFilmsConnection = { - __typename?: "PersonFilmsConnection" - /** A list of edges. */ - edges?: Maybe>> - /** - * A list of all of the objects returned in the connection. This is a convenience - * field provided for quickly exploring the API; rather than querying for - * "{ edges { node } }" when no edge data is needed, this field can be be used - * instead. Note that when clients like Relay need to fetch the "cursor" field on - * the edge to enable efficient pagination, this shortcut cannot be used, and the - * full "{ edges { node } }" version should be used instead. - */ - films?: Maybe>> - /** Information to aid in pagination. */ - pageInfo: PageInfo - /** - * A count of the total number of objects in this connection, ignoring pagination. - * This allows a client to fetch the first five objects by passing "5" as the - * argument to "first", then fetch the total count so it could display "5 of 83", - * for example. - */ - totalCount?: Maybe -} - -/** An edge in a connection. */ -export type PersonFilmsEdge = { - __typename?: "PersonFilmsEdge" - /** A cursor for use in pagination */ - cursor: Scalars["String"]["output"] - /** The item at the end of the edge */ - node?: Maybe -} - -/** A connection to a list of items. */ -export type PersonStarshipsConnection = { - __typename?: "PersonStarshipsConnection" - /** A list of edges. */ - edges?: Maybe>> - /** Information to aid in pagination. */ - pageInfo: PageInfo - /** - * A list of all of the objects returned in the connection. This is a convenience - * field provided for quickly exploring the API; rather than querying for - * "{ edges { node } }" when no edge data is needed, this field can be be used - * instead. Note that when clients like Relay need to fetch the "cursor" field on - * the edge to enable efficient pagination, this shortcut cannot be used, and the - * full "{ edges { node } }" version should be used instead. - */ - starships?: Maybe>> - /** - * A count of the total number of objects in this connection, ignoring pagination. - * This allows a client to fetch the first five objects by passing "5" as the - * argument to "first", then fetch the total count so it could display "5 of 83", - * for example. - */ - totalCount?: Maybe -} - -/** An edge in a connection. */ -export type PersonStarshipsEdge = { - __typename?: "PersonStarshipsEdge" - /** A cursor for use in pagination */ - cursor: Scalars["String"]["output"] - /** The item at the end of the edge */ - node?: Maybe -} - -/** A connection to a list of items. */ -export type PersonVehiclesConnection = { - __typename?: "PersonVehiclesConnection" - /** A list of edges. */ - edges?: Maybe>> - /** Information to aid in pagination. */ - pageInfo: PageInfo - /** - * A count of the total number of objects in this connection, ignoring pagination. - * This allows a client to fetch the first five objects by passing "5" as the - * argument to "first", then fetch the total count so it could display "5 of 83", - * for example. - */ - totalCount?: Maybe - /** - * A list of all of the objects returned in the connection. This is a convenience - * field provided for quickly exploring the API; rather than querying for - * "{ edges { node } }" when no edge data is needed, this field can be be used - * instead. Note that when clients like Relay need to fetch the "cursor" field on - * the edge to enable efficient pagination, this shortcut cannot be used, and the - * full "{ edges { node } }" version should be used instead. - */ - vehicles?: Maybe>> -} - -/** An edge in a connection. */ -export type PersonVehiclesEdge = { - __typename?: "PersonVehiclesEdge" - /** A cursor for use in pagination */ - cursor: Scalars["String"]["output"] - /** The item at the end of the edge */ - node?: Maybe -} - -/** - * A large mass, planet or planetoid in the Star Wars Universe, at the time of - * 0 ABY. - */ -export type Planet = Node & { - __typename?: "Planet" - /** The climates of this planet. */ - climates?: Maybe>> - /** The ISO 8601 date format of the time that this resource was created. */ - created?: Maybe - /** The diameter of this planet in kilometers. */ - diameter?: Maybe - /** The ISO 8601 date format of the time that this resource was edited. */ - edited?: Maybe - filmConnection?: Maybe - /** - * A number denoting the gravity of this planet, where "1" is normal or 1 standard - * G. "2" is twice or 2 standard Gs. "0.5" is half or 0.5 standard Gs. - */ - gravity?: Maybe - /** The ID of an object */ - id: Scalars["ID"]["output"] - /** The name of this planet. */ - name?: Maybe - /** - * The number of standard days it takes for this planet to complete a single orbit - * of its local star. - */ - orbitalPeriod?: Maybe - /** The average population of sentient beings inhabiting this planet. */ - population?: Maybe - residentConnection?: Maybe - /** - * The number of standard hours it takes for this planet to complete a single - * rotation on its axis. - */ - rotationPeriod?: Maybe - /** - * The percentage of the planet surface that is naturally occurring water or bodies - * of water. - */ - surfaceWater?: Maybe - /** The terrains of this planet. */ - terrains?: Maybe>> -} - -/** - * A large mass, planet or planetoid in the Star Wars Universe, at the time of - * 0 ABY. - */ -export type PlanetFilmConnectionArgs = { - after?: InputMaybe - before?: InputMaybe - first?: InputMaybe - last?: InputMaybe -} - -/** - * A large mass, planet or planetoid in the Star Wars Universe, at the time of - * 0 ABY. - */ -export type PlanetResidentConnectionArgs = { - after?: InputMaybe - before?: InputMaybe - first?: InputMaybe - last?: InputMaybe -} - -/** A connection to a list of items. */ -export type PlanetFilmsConnection = { - __typename?: "PlanetFilmsConnection" - /** A list of edges. */ - edges?: Maybe>> - /** - * A list of all of the objects returned in the connection. This is a convenience - * field provided for quickly exploring the API; rather than querying for - * "{ edges { node } }" when no edge data is needed, this field can be be used - * instead. Note that when clients like Relay need to fetch the "cursor" field on - * the edge to enable efficient pagination, this shortcut cannot be used, and the - * full "{ edges { node } }" version should be used instead. - */ - films?: Maybe>> - /** Information to aid in pagination. */ - pageInfo: PageInfo - /** - * A count of the total number of objects in this connection, ignoring pagination. - * This allows a client to fetch the first five objects by passing "5" as the - * argument to "first", then fetch the total count so it could display "5 of 83", - * for example. - */ - totalCount?: Maybe -} - -/** An edge in a connection. */ -export type PlanetFilmsEdge = { - __typename?: "PlanetFilmsEdge" - /** A cursor for use in pagination */ - cursor: Scalars["String"]["output"] - /** The item at the end of the edge */ - node?: Maybe -} - -/** A connection to a list of items. */ -export type PlanetResidentsConnection = { - __typename?: "PlanetResidentsConnection" - /** A list of edges. */ - edges?: Maybe>> - /** Information to aid in pagination. */ - pageInfo: PageInfo - /** - * A list of all of the objects returned in the connection. This is a convenience - * field provided for quickly exploring the API; rather than querying for - * "{ edges { node } }" when no edge data is needed, this field can be be used - * instead. Note that when clients like Relay need to fetch the "cursor" field on - * the edge to enable efficient pagination, this shortcut cannot be used, and the - * full "{ edges { node } }" version should be used instead. - */ - residents?: Maybe>> - /** - * A count of the total number of objects in this connection, ignoring pagination. - * This allows a client to fetch the first five objects by passing "5" as the - * argument to "first", then fetch the total count so it could display "5 of 83", - * for example. - */ - totalCount?: Maybe -} - -/** An edge in a connection. */ -export type PlanetResidentsEdge = { - __typename?: "PlanetResidentsEdge" - /** A cursor for use in pagination */ - cursor: Scalars["String"]["output"] - /** The item at the end of the edge */ - node?: Maybe -} - -/** A connection to a list of items. */ -export type PlanetsConnection = { - __typename?: "PlanetsConnection" - /** A list of edges. */ - edges?: Maybe>> - /** Information to aid in pagination. */ - pageInfo: PageInfo - /** - * A list of all of the objects returned in the connection. This is a convenience - * field provided for quickly exploring the API; rather than querying for - * "{ edges { node } }" when no edge data is needed, this field can be be used - * instead. Note that when clients like Relay need to fetch the "cursor" field on - * the edge to enable efficient pagination, this shortcut cannot be used, and the - * full "{ edges { node } }" version should be used instead. - */ - planets?: Maybe>> - /** - * A count of the total number of objects in this connection, ignoring pagination. - * This allows a client to fetch the first five objects by passing "5" as the - * argument to "first", then fetch the total count so it could display "5 of 83", - * for example. - */ - totalCount?: Maybe -} - -/** An edge in a connection. */ -export type PlanetsEdge = { - __typename?: "PlanetsEdge" - /** A cursor for use in pagination */ - cursor: Scalars["String"]["output"] - /** The item at the end of the edge */ - node?: Maybe -} - -export type Root = { - __typename?: "Root" - allFilms?: Maybe - allPeople?: Maybe - allPlanets?: Maybe - allSpecies?: Maybe - allStarships?: Maybe - allVehicles?: Maybe - film?: Maybe - /** Fetches an object given its ID */ - node?: Maybe - person?: Maybe - planet?: Maybe - species?: Maybe - starship?: Maybe - vehicle?: Maybe -} - -export type RootAllFilmsArgs = { - after?: InputMaybe - before?: InputMaybe - first?: InputMaybe - last?: InputMaybe -} - -export type RootAllPeopleArgs = { - after?: InputMaybe - before?: InputMaybe - first?: InputMaybe - last?: InputMaybe -} - -export type RootAllPlanetsArgs = { - after?: InputMaybe - before?: InputMaybe - first?: InputMaybe - last?: InputMaybe -} - -export type RootAllSpeciesArgs = { - after?: InputMaybe - before?: InputMaybe - first?: InputMaybe - last?: InputMaybe -} - -export type RootAllStarshipsArgs = { - after?: InputMaybe - before?: InputMaybe - first?: InputMaybe - last?: InputMaybe -} - -export type RootAllVehiclesArgs = { - after?: InputMaybe - before?: InputMaybe - first?: InputMaybe - last?: InputMaybe -} - -export type RootFilmArgs = { - filmID?: InputMaybe - id?: InputMaybe -} - -export type RootNodeArgs = { - id: Scalars["ID"]["input"] -} - -export type RootPersonArgs = { - id?: InputMaybe - personID?: InputMaybe -} - -export type RootPlanetArgs = { - id?: InputMaybe - planetID?: InputMaybe -} - -export type RootSpeciesArgs = { - id?: InputMaybe - speciesID?: InputMaybe -} - -export type RootStarshipArgs = { - id?: InputMaybe - starshipID?: InputMaybe -} - -export type RootVehicleArgs = { - id?: InputMaybe - vehicleID?: InputMaybe -} - -/** A type of person or character within the Star Wars Universe. */ -export type Species = Node & { - __typename?: "Species" - /** The average height of this species in centimeters. */ - averageHeight?: Maybe - /** The average lifespan of this species in years, null if unknown. */ - averageLifespan?: Maybe - /** The classification of this species, such as "mammal" or "reptile". */ - classification?: Maybe - /** The ISO 8601 date format of the time that this resource was created. */ - created?: Maybe - /** The designation of this species, such as "sentient". */ - designation?: Maybe - /** The ISO 8601 date format of the time that this resource was edited. */ - edited?: Maybe - /** - * Common eye colors for this species, null if this species does not typically - * have eyes. - */ - eyeColors?: Maybe>> - filmConnection?: Maybe - /** - * Common hair colors for this species, null if this species does not typically - * have hair. - */ - hairColors?: Maybe>> - /** A planet that this species originates from. */ - homeworld?: Maybe - /** The ID of an object */ - id: Scalars["ID"]["output"] - /** The language commonly spoken by this species. */ - language?: Maybe - /** The name of this species. */ - name?: Maybe - personConnection?: Maybe - /** - * Common skin colors for this species, null if this species does not typically - * have skin. - */ - skinColors?: Maybe>> -} - -/** A type of person or character within the Star Wars Universe. */ -export type SpeciesFilmConnectionArgs = { - after?: InputMaybe - before?: InputMaybe - first?: InputMaybe - last?: InputMaybe -} - -/** A type of person or character within the Star Wars Universe. */ -export type SpeciesPersonConnectionArgs = { - after?: InputMaybe - before?: InputMaybe - first?: InputMaybe - last?: InputMaybe -} - -/** A connection to a list of items. */ -export type SpeciesConnection = { - __typename?: "SpeciesConnection" - /** A list of edges. */ - edges?: Maybe>> - /** Information to aid in pagination. */ - pageInfo: PageInfo - /** - * A list of all of the objects returned in the connection. This is a convenience - * field provided for quickly exploring the API; rather than querying for - * "{ edges { node } }" when no edge data is needed, this field can be be used - * instead. Note that when clients like Relay need to fetch the "cursor" field on - * the edge to enable efficient pagination, this shortcut cannot be used, and the - * full "{ edges { node } }" version should be used instead. - */ - species?: Maybe>> - /** - * A count of the total number of objects in this connection, ignoring pagination. - * This allows a client to fetch the first five objects by passing "5" as the - * argument to "first", then fetch the total count so it could display "5 of 83", - * for example. - */ - totalCount?: Maybe -} - -/** An edge in a connection. */ -export type SpeciesEdge = { - __typename?: "SpeciesEdge" - /** A cursor for use in pagination */ - cursor: Scalars["String"]["output"] - /** The item at the end of the edge */ - node?: Maybe -} - -/** A connection to a list of items. */ -export type SpeciesFilmsConnection = { - __typename?: "SpeciesFilmsConnection" - /** A list of edges. */ - edges?: Maybe>> - /** - * A list of all of the objects returned in the connection. This is a convenience - * field provided for quickly exploring the API; rather than querying for - * "{ edges { node } }" when no edge data is needed, this field can be be used - * instead. Note that when clients like Relay need to fetch the "cursor" field on - * the edge to enable efficient pagination, this shortcut cannot be used, and the - * full "{ edges { node } }" version should be used instead. - */ - films?: Maybe>> - /** Information to aid in pagination. */ - pageInfo: PageInfo - /** - * A count of the total number of objects in this connection, ignoring pagination. - * This allows a client to fetch the first five objects by passing "5" as the - * argument to "first", then fetch the total count so it could display "5 of 83", - * for example. - */ - totalCount?: Maybe -} - -/** An edge in a connection. */ -export type SpeciesFilmsEdge = { - __typename?: "SpeciesFilmsEdge" - /** A cursor for use in pagination */ - cursor: Scalars["String"]["output"] - /** The item at the end of the edge */ - node?: Maybe -} - -/** A connection to a list of items. */ -export type SpeciesPeopleConnection = { - __typename?: "SpeciesPeopleConnection" - /** A list of edges. */ - edges?: Maybe>> - /** Information to aid in pagination. */ - pageInfo: PageInfo - /** - * A list of all of the objects returned in the connection. This is a convenience - * field provided for quickly exploring the API; rather than querying for - * "{ edges { node } }" when no edge data is needed, this field can be be used - * instead. Note that when clients like Relay need to fetch the "cursor" field on - * the edge to enable efficient pagination, this shortcut cannot be used, and the - * full "{ edges { node } }" version should be used instead. - */ - people?: Maybe>> - /** - * A count of the total number of objects in this connection, ignoring pagination. - * This allows a client to fetch the first five objects by passing "5" as the - * argument to "first", then fetch the total count so it could display "5 of 83", - * for example. - */ - totalCount?: Maybe -} - -/** An edge in a connection. */ -export type SpeciesPeopleEdge = { - __typename?: "SpeciesPeopleEdge" - /** A cursor for use in pagination */ - cursor: Scalars["String"]["output"] - /** The item at the end of the edge */ - node?: Maybe -} - -/** A single transport craft that has hyperdrive capability. */ -export type Starship = Node & { - __typename?: "Starship" - /** - * The Maximum number of Megalights this starship can travel in a standard hour. - * A "Megalight" is a standard unit of distance and has never been defined before - * within the Star Wars universe. This figure is only really useful for measuring - * the difference in speed of starships. We can assume it is similar to AU, the - * distance between our Sun (Sol) and Earth. - */ - MGLT?: Maybe - /** The maximum number of kilograms that this starship can transport. */ - cargoCapacity?: Maybe - /** - * The maximum length of time that this starship can provide consumables for its - * entire crew without having to resupply. - */ - consumables?: Maybe - /** The cost of this starship new, in galactic credits. */ - costInCredits?: Maybe - /** The ISO 8601 date format of the time that this resource was created. */ - created?: Maybe - /** The number of personnel needed to run or pilot this starship. */ - crew?: Maybe - /** The ISO 8601 date format of the time that this resource was edited. */ - edited?: Maybe - filmConnection?: Maybe - /** The class of this starships hyperdrive. */ - hyperdriveRating?: Maybe - /** The ID of an object */ - id: Scalars["ID"]["output"] - /** The length of this starship in meters. */ - length?: Maybe - /** The manufacturers of this starship. */ - manufacturers?: Maybe>> - /** - * The maximum speed of this starship in atmosphere. null if this starship is - * incapable of atmosphering flight. - */ - maxAtmospheringSpeed?: Maybe - /** - * The model or official name of this starship. Such as "T-65 X-wing" or "DS-1 - * Orbital Battle Station". - */ - model?: Maybe - /** The name of this starship. The common name, such as "Death Star". */ - name?: Maybe - /** The number of non-essential people this starship can transport. */ - passengers?: Maybe - pilotConnection?: Maybe - /** - * The class of this starship, such as "Starfighter" or "Deep Space Mobile - * Battlestation" - */ - starshipClass?: Maybe -} - -/** A single transport craft that has hyperdrive capability. */ -export type StarshipFilmConnectionArgs = { - after?: InputMaybe - before?: InputMaybe - first?: InputMaybe - last?: InputMaybe -} - -/** A single transport craft that has hyperdrive capability. */ -export type StarshipPilotConnectionArgs = { - after?: InputMaybe - before?: InputMaybe - first?: InputMaybe - last?: InputMaybe -} - -/** A connection to a list of items. */ -export type StarshipFilmsConnection = { - __typename?: "StarshipFilmsConnection" - /** A list of edges. */ - edges?: Maybe>> - /** - * A list of all of the objects returned in the connection. This is a convenience - * field provided for quickly exploring the API; rather than querying for - * "{ edges { node } }" when no edge data is needed, this field can be be used - * instead. Note that when clients like Relay need to fetch the "cursor" field on - * the edge to enable efficient pagination, this shortcut cannot be used, and the - * full "{ edges { node } }" version should be used instead. - */ - films?: Maybe>> - /** Information to aid in pagination. */ - pageInfo: PageInfo - /** - * A count of the total number of objects in this connection, ignoring pagination. - * This allows a client to fetch the first five objects by passing "5" as the - * argument to "first", then fetch the total count so it could display "5 of 83", - * for example. - */ - totalCount?: Maybe -} - -/** An edge in a connection. */ -export type StarshipFilmsEdge = { - __typename?: "StarshipFilmsEdge" - /** A cursor for use in pagination */ - cursor: Scalars["String"]["output"] - /** The item at the end of the edge */ - node?: Maybe -} - -/** A connection to a list of items. */ -export type StarshipPilotsConnection = { - __typename?: "StarshipPilotsConnection" - /** A list of edges. */ - edges?: Maybe>> - /** Information to aid in pagination. */ - pageInfo: PageInfo - /** - * A list of all of the objects returned in the connection. This is a convenience - * field provided for quickly exploring the API; rather than querying for - * "{ edges { node } }" when no edge data is needed, this field can be be used - * instead. Note that when clients like Relay need to fetch the "cursor" field on - * the edge to enable efficient pagination, this shortcut cannot be used, and the - * full "{ edges { node } }" version should be used instead. - */ - pilots?: Maybe>> - /** - * A count of the total number of objects in this connection, ignoring pagination. - * This allows a client to fetch the first five objects by passing "5" as the - * argument to "first", then fetch the total count so it could display "5 of 83", - * for example. - */ - totalCount?: Maybe -} - -/** An edge in a connection. */ -export type StarshipPilotsEdge = { - __typename?: "StarshipPilotsEdge" - /** A cursor for use in pagination */ - cursor: Scalars["String"]["output"] - /** The item at the end of the edge */ - node?: Maybe -} - -/** A connection to a list of items. */ -export type StarshipsConnection = { - __typename?: "StarshipsConnection" - /** A list of edges. */ - edges?: Maybe>> - /** Information to aid in pagination. */ - pageInfo: PageInfo - /** - * A list of all of the objects returned in the connection. This is a convenience - * field provided for quickly exploring the API; rather than querying for - * "{ edges { node } }" when no edge data is needed, this field can be be used - * instead. Note that when clients like Relay need to fetch the "cursor" field on - * the edge to enable efficient pagination, this shortcut cannot be used, and the - * full "{ edges { node } }" version should be used instead. - */ - starships?: Maybe>> - /** - * A count of the total number of objects in this connection, ignoring pagination. - * This allows a client to fetch the first five objects by passing "5" as the - * argument to "first", then fetch the total count so it could display "5 of 83", - * for example. - */ - totalCount?: Maybe -} - -/** An edge in a connection. */ -export type StarshipsEdge = { - __typename?: "StarshipsEdge" - /** A cursor for use in pagination */ - cursor: Scalars["String"]["output"] - /** The item at the end of the edge */ - node?: Maybe -} - -/** A single transport craft that does not have hyperdrive capability */ -export type Vehicle = Node & { - __typename?: "Vehicle" - /** The maximum number of kilograms that this vehicle can transport. */ - cargoCapacity?: Maybe - /** - * The maximum length of time that this vehicle can provide consumables for its - * entire crew without having to resupply. - */ - consumables?: Maybe - /** The cost of this vehicle new, in Galactic Credits. */ - costInCredits?: Maybe - /** The ISO 8601 date format of the time that this resource was created. */ - created?: Maybe - /** The number of personnel needed to run or pilot this vehicle. */ - crew?: Maybe - /** The ISO 8601 date format of the time that this resource was edited. */ - edited?: Maybe - filmConnection?: Maybe - /** The ID of an object */ - id: Scalars["ID"]["output"] - /** The length of this vehicle in meters. */ - length?: Maybe - /** The manufacturers of this vehicle. */ - manufacturers?: Maybe>> - /** The maximum speed of this vehicle in atmosphere. */ - maxAtmospheringSpeed?: Maybe - /** - * The model or official name of this vehicle. Such as "All-Terrain Attack - * Transport". - */ - model?: Maybe - /** - * The name of this vehicle. The common name, such as "Sand Crawler" or "Speeder - * bike". - */ - name?: Maybe - /** The number of non-essential people this vehicle can transport. */ - passengers?: Maybe - pilotConnection?: Maybe - /** The class of this vehicle, such as "Wheeled" or "Repulsorcraft". */ - vehicleClass?: Maybe -} - -/** A single transport craft that does not have hyperdrive capability */ -export type VehicleFilmConnectionArgs = { - after?: InputMaybe - before?: InputMaybe - first?: InputMaybe - last?: InputMaybe -} - -/** A single transport craft that does not have hyperdrive capability */ -export type VehiclePilotConnectionArgs = { - after?: InputMaybe - before?: InputMaybe - first?: InputMaybe - last?: InputMaybe -} - -/** A connection to a list of items. */ -export type VehicleFilmsConnection = { - __typename?: "VehicleFilmsConnection" - /** A list of edges. */ - edges?: Maybe>> - /** - * A list of all of the objects returned in the connection. This is a convenience - * field provided for quickly exploring the API; rather than querying for - * "{ edges { node } }" when no edge data is needed, this field can be be used - * instead. Note that when clients like Relay need to fetch the "cursor" field on - * the edge to enable efficient pagination, this shortcut cannot be used, and the - * full "{ edges { node } }" version should be used instead. - */ - films?: Maybe>> - /** Information to aid in pagination. */ - pageInfo: PageInfo - /** - * A count of the total number of objects in this connection, ignoring pagination. - * This allows a client to fetch the first five objects by passing "5" as the - * argument to "first", then fetch the total count so it could display "5 of 83", - * for example. - */ - totalCount?: Maybe -} - -/** An edge in a connection. */ -export type VehicleFilmsEdge = { - __typename?: "VehicleFilmsEdge" - /** A cursor for use in pagination */ - cursor: Scalars["String"]["output"] - /** The item at the end of the edge */ - node?: Maybe -} - -/** A connection to a list of items. */ -export type VehiclePilotsConnection = { - __typename?: "VehiclePilotsConnection" - /** A list of edges. */ - edges?: Maybe>> - /** Information to aid in pagination. */ - pageInfo: PageInfo - /** - * A list of all of the objects returned in the connection. This is a convenience - * field provided for quickly exploring the API; rather than querying for - * "{ edges { node } }" when no edge data is needed, this field can be be used - * instead. Note that when clients like Relay need to fetch the "cursor" field on - * the edge to enable efficient pagination, this shortcut cannot be used, and the - * full "{ edges { node } }" version should be used instead. - */ - pilots?: Maybe>> - /** - * A count of the total number of objects in this connection, ignoring pagination. - * This allows a client to fetch the first five objects by passing "5" as the - * argument to "first", then fetch the total count so it could display "5 of 83", - * for example. - */ - totalCount?: Maybe -} - -/** An edge in a connection. */ -export type VehiclePilotsEdge = { - __typename?: "VehiclePilotsEdge" - /** A cursor for use in pagination */ - cursor: Scalars["String"]["output"] - /** The item at the end of the edge */ - node?: Maybe -} - -/** A connection to a list of items. */ -export type VehiclesConnection = { - __typename?: "VehiclesConnection" - /** A list of edges. */ - edges?: Maybe>> - /** Information to aid in pagination. */ - pageInfo: PageInfo - /** - * A count of the total number of objects in this connection, ignoring pagination. - * This allows a client to fetch the first five objects by passing "5" as the - * argument to "first", then fetch the total count so it could display "5 of 83", - * for example. - */ - totalCount?: Maybe - /** - * A list of all of the objects returned in the connection. This is a convenience - * field provided for quickly exploring the API; rather than querying for - * "{ edges { node } }" when no edge data is needed, this field can be be used - * instead. Note that when clients like Relay need to fetch the "cursor" field on - * the edge to enable efficient pagination, this shortcut cannot be used, and the - * full "{ edges { node } }" version should be used instead. - */ - vehicles?: Maybe>> -} - -/** An edge in a connection. */ -export type VehiclesEdge = { - __typename?: "VehiclesEdge" - /** A cursor for use in pagination */ - cursor: Scalars["String"]["output"] - /** The item at the end of the edge */ - node?: Maybe -} - -export type AllFilmsWithVariablesQueryQueryVariables = Exact<{ - first: Scalars["Int"]["input"] -}> - -export type AllFilmsWithVariablesQueryQuery = { - __typename?: "Root" - allFilms?: { - __typename?: "FilmsConnection" - edges?: Array<{ - __typename?: "FilmsEdge" - node?: - | ({ __typename?: "Film" } & { - " $fragmentRefs"?: { FilmItemFragment: FilmItemFragment } - }) - | null - } | null> | null - } | null -} - -export type FilmItemFragment = { - __typename?: "Film" - id: string - title?: string | null - releaseDate?: string | null - producers?: Array | null -} & { " $fragmentName"?: "FilmItemFragment" } - -export class TypedDocumentString - extends String - implements DocumentTypeDecoration -{ - __apiType?: DocumentTypeDecoration["__apiType"] - - constructor(private value: string, public __meta__?: Record) { - super(value) - } - - toString(): string & DocumentTypeDecoration { - return this.value - } -} -export const FilmItemFragmentDoc = new TypedDocumentString( - ` - fragment FilmItem on Film { - id - title - releaseDate - producers -} - `, - { fragmentName: "FilmItem" } -) as unknown as TypedDocumentString -export const AllFilmsWithVariablesQueryDocument = new TypedDocumentString(` - query allFilmsWithVariablesQuery($first: Int!) { - allFilms(first: $first) { - edges { - node { - ...FilmItem - } - } - } -} - fragment FilmItem on Film { - id - title - releaseDate - producers -}`) as unknown as TypedDocumentString< - AllFilmsWithVariablesQueryQuery, - AllFilmsWithVariablesQueryQueryVariables -> diff --git a/apps/website/queries/useGetAllERC721Tokens.tsx b/apps/website/queries/useGetAllERC721Tokens.tsx deleted file mode 100644 index 6352cc8..0000000 --- a/apps/website/queries/useGetAllERC721Tokens.tsx +++ /dev/null @@ -1,32 +0,0 @@ -"use client" - -import { env } from "@/env.mjs" -import { useQuery } from "@tanstack/react-query" -import requestQL, { gql } from "graphql-request" - -const query = gql` - query AllClonedERC721Tokens { - optimismMintableERC20s { - items { - id - chainId - deployer - blockNumber - localToken - localName - localSymbol - remoteToken - remoteName - remoteSymbol - } - } - } -` - -export function useGetAllERC721Tokens() { - return useQuery({ - queryKey: ["allClonedERC721Tokens"], - queryFn: () => - requestQL(env.NEXT_PUBLIC_API_EVENT_CACHE, query, { first: 10 }), - }) -} diff --git a/apps/website/queries/useGetTargetERC721Token.tsx b/apps/website/queries/useGetTargetERC721Token.tsx deleted file mode 100644 index 5b62521..0000000 --- a/apps/website/queries/useGetTargetERC721Token.tsx +++ /dev/null @@ -1,41 +0,0 @@ -"use client" - -import { env } from "@/env.mjs" -import { useQuery } from "@tanstack/react-query" -import requestQL, { gql } from "graphql-request" - -const query = (chainId: string | number, token: string) => gql` -query TargetClonedERC721Token { - optimismMintableERC20s(where: { - remoteToken: "${token}" - chainId: ${chainId} - }) { - items { - id - chainId - deployer - blockNumber - localToken - localName - localSymbol - remoteToken - remoteName - remoteSymbol - } - } -} -` - -export function useGetTargetERC721Token( - chainId: number | string, - token: string -) { - return useQuery({ - queryKey: ["targetClonedERC721Token", chainId, token], - queryFn: () => - requestQL(env.NEXT_PUBLIC_API_EVENT_CACHE, query(chainId, token), { - first: 10, - }), - enabled: !!chainId && !!token, - }) -}