From 4d269980bc74fbaa75e8a71de945b58f650b1df0 Mon Sep 17 00:00:00 2001 From: Vitor Date: Thu, 4 Apr 2024 17:23:39 -0300 Subject: [PATCH 1/6] feat: add bridged collections to event cache --- apps/event-cache/abis/L1ERC721Bridge.ts | 644 +++++++++--------- apps/event-cache/abis/L2ERC721Bridge.ts | 2 +- .../abis/OptimismMintableERC721Factory.ts | 2 +- apps/event-cache/abis/index.ts | 3 + apps/event-cache/clients/index.ts | 21 + apps/event-cache/constants/index.ts | 3 +- apps/event-cache/ponder.config.ts | 74 +- apps/event-cache/ponder.schema.ts | 12 + apps/event-cache/src/L1ERC721Bridge.ts | 109 +++ apps/event-cache/src/L2ERC721Bridge.ts | 78 +++ .../src/OptimismMintableERC721Factory.ts | 25 +- 11 files changed, 618 insertions(+), 355 deletions(-) create mode 100644 apps/event-cache/abis/index.ts create mode 100644 apps/event-cache/clients/index.ts create mode 100644 apps/event-cache/src/L1ERC721Bridge.ts create mode 100644 apps/event-cache/src/L2ERC721Bridge.ts diff --git a/apps/event-cache/abis/L1ERC721Bridge.ts b/apps/event-cache/abis/L1ERC721Bridge.ts index 852f4ce..b78c56b 100644 --- a/apps/event-cache/abis/L1ERC721Bridge.ts +++ b/apps/event-cache/abis/L1ERC721Bridge.ts @@ -1,322 +1,322 @@ -export const L1ERC721Bridge = [ - { - "inputs": [], - "stateMutability": "nonpayable", - "type": "constructor" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "address", - "name": "localToken", - "type": "address" - }, - { - "indexed": true, - "internalType": "address", - "name": "remoteToken", - "type": "address" - }, - { - "indexed": true, - "internalType": "address", - "name": "from", - "type": "address" - }, - { - "indexed": false, - "internalType": "address", - "name": "to", - "type": "address" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "tokenId", - "type": "uint256" - }, - { - "indexed": false, - "internalType": "bytes", - "name": "extraData", - "type": "bytes" - } - ], - "name": "ERC721BridgeFinalized", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "address", - "name": "localToken", - "type": "address" - }, - { - "indexed": true, - "internalType": "address", - "name": "remoteToken", - "type": "address" - }, - { - "indexed": true, - "internalType": "address", - "name": "from", - "type": "address" - }, - { - "indexed": false, - "internalType": "address", - "name": "to", - "type": "address" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "tokenId", - "type": "uint256" - }, - { - "indexed": false, - "internalType": "bytes", - "name": "extraData", - "type": "bytes" - } - ], - "name": "ERC721BridgeInitiated", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "uint8", - "name": "version", - "type": "uint8" - } - ], - "name": "Initialized", - "type": "event" - }, - { - "inputs": [], - "name": "MESSENGER", - "outputs": [ - { - "internalType": "contract CrossDomainMessenger", - "name": "", - "type": "address" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "OTHER_BRIDGE", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "_localToken", - "type": "address" - }, - { - "internalType": "address", - "name": "_remoteToken", - "type": "address" - }, - { - "internalType": "uint256", - "name": "_tokenId", - "type": "uint256" - }, - { - "internalType": "uint32", - "name": "_minGasLimit", - "type": "uint32" - }, - { - "internalType": "bytes", - "name": "_extraData", - "type": "bytes" - } - ], - "name": "bridgeERC721", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "_localToken", - "type": "address" - }, - { - "internalType": "address", - "name": "_remoteToken", - "type": "address" - }, - { - "internalType": "address", - "name": "_to", - "type": "address" - }, - { - "internalType": "uint256", - "name": "_tokenId", - "type": "uint256" - }, - { - "internalType": "uint32", - "name": "_minGasLimit", - "type": "uint32" - }, - { - "internalType": "bytes", - "name": "_extraData", - "type": "bytes" - } - ], - "name": "bridgeERC721To", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - }, - { - "internalType": "address", - "name": "", - "type": "address" - }, - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "name": "deposits", - "outputs": [ - { - "internalType": "bool", - "name": "", - "type": "bool" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "_localToken", - "type": "address" - }, - { - "internalType": "address", - "name": "_remoteToken", - "type": "address" - }, - { - "internalType": "address", - "name": "_from", - "type": "address" - }, - { - "internalType": "address", - "name": "_to", - "type": "address" - }, - { - "internalType": "uint256", - "name": "_tokenId", - "type": "uint256" - }, - { - "internalType": "bytes", - "name": "_extraData", - "type": "bytes" - } - ], - "name": "finalizeBridgeERC721", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "contract CrossDomainMessenger", - "name": "_messenger", - "type": "address" - } - ], - "name": "initialize", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [], - "name": "messenger", - "outputs": [ - { - "internalType": "contract CrossDomainMessenger", - "name": "", - "type": "address" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "otherBridge", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "version", - "outputs": [ - { - "internalType": "string", - "name": "", - "type": "string" - } - ], - "stateMutability": "view", - "type": "function" - } - ] as const; \ No newline at end of file +export const L1ERC721BridgeAbi = [ + { + "inputs": [], + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "localToken", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "remoteToken", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "from", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "to", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "tokenId", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "bytes", + "name": "extraData", + "type": "bytes" + } + ], + "name": "ERC721BridgeFinalized", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "localToken", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "remoteToken", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "from", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "to", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "tokenId", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "bytes", + "name": "extraData", + "type": "bytes" + } + ], + "name": "ERC721BridgeInitiated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint8", + "name": "version", + "type": "uint8" + } + ], + "name": "Initialized", + "type": "event" + }, + { + "inputs": [], + "name": "MESSENGER", + "outputs": [ + { + "internalType": "contract CrossDomainMessenger", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "OTHER_BRIDGE", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_localToken", + "type": "address" + }, + { + "internalType": "address", + "name": "_remoteToken", + "type": "address" + }, + { + "internalType": "uint256", + "name": "_tokenId", + "type": "uint256" + }, + { + "internalType": "uint32", + "name": "_minGasLimit", + "type": "uint32" + }, + { + "internalType": "bytes", + "name": "_extraData", + "type": "bytes" + } + ], + "name": "bridgeERC721", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_localToken", + "type": "address" + }, + { + "internalType": "address", + "name": "_remoteToken", + "type": "address" + }, + { + "internalType": "address", + "name": "_to", + "type": "address" + }, + { + "internalType": "uint256", + "name": "_tokenId", + "type": "uint256" + }, + { + "internalType": "uint32", + "name": "_minGasLimit", + "type": "uint32" + }, + { + "internalType": "bytes", + "name": "_extraData", + "type": "bytes" + } + ], + "name": "bridgeERC721To", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + }, + { + "internalType": "address", + "name": "", + "type": "address" + }, + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "name": "deposits", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_localToken", + "type": "address" + }, + { + "internalType": "address", + "name": "_remoteToken", + "type": "address" + }, + { + "internalType": "address", + "name": "_from", + "type": "address" + }, + { + "internalType": "address", + "name": "_to", + "type": "address" + }, + { + "internalType": "uint256", + "name": "_tokenId", + "type": "uint256" + }, + { + "internalType": "bytes", + "name": "_extraData", + "type": "bytes" + } + ], + "name": "finalizeBridgeERC721", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "contract CrossDomainMessenger", + "name": "_messenger", + "type": "address" + } + ], + "name": "initialize", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "messenger", + "outputs": [ + { + "internalType": "contract CrossDomainMessenger", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "otherBridge", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "version", + "outputs": [ + { + "internalType": "string", + "name": "", + "type": "string" + } + ], + "stateMutability": "view", + "type": "function" + } +] as const; \ No newline at end of file diff --git a/apps/event-cache/abis/L2ERC721Bridge.ts b/apps/event-cache/abis/L2ERC721Bridge.ts index 6db5936..9040776 100644 --- a/apps/event-cache/abis/L2ERC721Bridge.ts +++ b/apps/event-cache/abis/L2ERC721Bridge.ts @@ -1 +1 @@ -export const L1ERC721Bridge = [{"inputs":[{"internalType":"address","name":"_messenger","type":"address"},{"internalType":"address","name":"_otherBridge","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"localToken","type":"address"},{"indexed":true,"internalType":"address","name":"remoteToken","type":"address"},{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":false,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"tokenId","type":"uint256"},{"indexed":false,"internalType":"bytes","name":"extraData","type":"bytes"}],"name":"ERC721BridgeFinalized","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"localToken","type":"address"},{"indexed":true,"internalType":"address","name":"remoteToken","type":"address"},{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":false,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"tokenId","type":"uint256"},{"indexed":false,"internalType":"bytes","name":"extraData","type":"bytes"}],"name":"ERC721BridgeInitiated","type":"event"},{"inputs":[],"name":"MESSENGER","outputs":[{"internalType":"contract CrossDomainMessenger","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"OTHER_BRIDGE","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_localToken","type":"address"},{"internalType":"address","name":"_remoteToken","type":"address"},{"internalType":"uint256","name":"_tokenId","type":"uint256"},{"internalType":"uint32","name":"_minGasLimit","type":"uint32"},{"internalType":"bytes","name":"_extraData","type":"bytes"}],"name":"bridgeERC721","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_localToken","type":"address"},{"internalType":"address","name":"_remoteToken","type":"address"},{"internalType":"address","name":"_to","type":"address"},{"internalType":"uint256","name":"_tokenId","type":"uint256"},{"internalType":"uint32","name":"_minGasLimit","type":"uint32"},{"internalType":"bytes","name":"_extraData","type":"bytes"}],"name":"bridgeERC721To","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_localToken","type":"address"},{"internalType":"address","name":"_remoteToken","type":"address"},{"internalType":"address","name":"_from","type":"address"},{"internalType":"address","name":"_to","type":"address"},{"internalType":"uint256","name":"_tokenId","type":"uint256"},{"internalType":"bytes","name":"_extraData","type":"bytes"}],"name":"finalizeBridgeERC721","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"messenger","outputs":[{"internalType":"contract CrossDomainMessenger","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"otherBridge","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"version","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"}] as const; \ No newline at end of file +export const L2ERC721BridgeAbi = [{ "inputs": [{ "internalType": "address", "name": "_messenger", "type": "address" }, { "internalType": "address", "name": "_otherBridge", "type": "address" }], "stateMutability": "nonpayable", "type": "constructor" }, { "anonymous": false, "inputs": [{ "indexed": true, "internalType": "address", "name": "localToken", "type": "address" }, { "indexed": true, "internalType": "address", "name": "remoteToken", "type": "address" }, { "indexed": true, "internalType": "address", "name": "from", "type": "address" }, { "indexed": false, "internalType": "address", "name": "to", "type": "address" }, { "indexed": false, "internalType": "uint256", "name": "tokenId", "type": "uint256" }, { "indexed": false, "internalType": "bytes", "name": "extraData", "type": "bytes" }], "name": "ERC721BridgeFinalized", "type": "event" }, { "anonymous": false, "inputs": [{ "indexed": true, "internalType": "address", "name": "localToken", "type": "address" }, { "indexed": true, "internalType": "address", "name": "remoteToken", "type": "address" }, { "indexed": true, "internalType": "address", "name": "from", "type": "address" }, { "indexed": false, "internalType": "address", "name": "to", "type": "address" }, { "indexed": false, "internalType": "uint256", "name": "tokenId", "type": "uint256" }, { "indexed": false, "internalType": "bytes", "name": "extraData", "type": "bytes" }], "name": "ERC721BridgeInitiated", "type": "event" }, { "inputs": [], "name": "MESSENGER", "outputs": [{ "internalType": "contract CrossDomainMessenger", "name": "", "type": "address" }], "stateMutability": "view", "type": "function" }, { "inputs": [], "name": "OTHER_BRIDGE", "outputs": [{ "internalType": "address", "name": "", "type": "address" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "address", "name": "_localToken", "type": "address" }, { "internalType": "address", "name": "_remoteToken", "type": "address" }, { "internalType": "uint256", "name": "_tokenId", "type": "uint256" }, { "internalType": "uint32", "name": "_minGasLimit", "type": "uint32" }, { "internalType": "bytes", "name": "_extraData", "type": "bytes" }], "name": "bridgeERC721", "outputs": [], "stateMutability": "nonpayable", "type": "function" }, { "inputs": [{ "internalType": "address", "name": "_localToken", "type": "address" }, { "internalType": "address", "name": "_remoteToken", "type": "address" }, { "internalType": "address", "name": "_to", "type": "address" }, { "internalType": "uint256", "name": "_tokenId", "type": "uint256" }, { "internalType": "uint32", "name": "_minGasLimit", "type": "uint32" }, { "internalType": "bytes", "name": "_extraData", "type": "bytes" }], "name": "bridgeERC721To", "outputs": [], "stateMutability": "nonpayable", "type": "function" }, { "inputs": [{ "internalType": "address", "name": "_localToken", "type": "address" }, { "internalType": "address", "name": "_remoteToken", "type": "address" }, { "internalType": "address", "name": "_from", "type": "address" }, { "internalType": "address", "name": "_to", "type": "address" }, { "internalType": "uint256", "name": "_tokenId", "type": "uint256" }, { "internalType": "bytes", "name": "_extraData", "type": "bytes" }], "name": "finalizeBridgeERC721", "outputs": [], "stateMutability": "nonpayable", "type": "function" }, { "inputs": [], "name": "messenger", "outputs": [{ "internalType": "contract CrossDomainMessenger", "name": "", "type": "address" }], "stateMutability": "view", "type": "function" }, { "inputs": [], "name": "otherBridge", "outputs": [{ "internalType": "address", "name": "", "type": "address" }], "stateMutability": "view", "type": "function" }, { "inputs": [], "name": "version", "outputs": [{ "internalType": "string", "name": "", "type": "string" }], "stateMutability": "view", "type": "function" }] as const; \ No newline at end of file diff --git a/apps/event-cache/abis/OptimismMintableERC721Factory.ts b/apps/event-cache/abis/OptimismMintableERC721Factory.ts index e6cdb47..9d97927 100644 --- a/apps/event-cache/abis/OptimismMintableERC721Factory.ts +++ b/apps/event-cache/abis/OptimismMintableERC721Factory.ts @@ -1,4 +1,4 @@ -export const OptimismMintableERC721Factory = [ +export const OptimismMintableERC721FactoryAbi = [ { inputs: [ { diff --git a/apps/event-cache/abis/index.ts b/apps/event-cache/abis/index.ts new file mode 100644 index 0000000..796e944 --- /dev/null +++ b/apps/event-cache/abis/index.ts @@ -0,0 +1,3 @@ +export * from "./L1ERC721Bridge" +export * from "./L2ERC721Bridge" +export * from "./OptimismMintableERC721Factory" diff --git a/apps/event-cache/clients/index.ts b/apps/event-cache/clients/index.ts new file mode 100644 index 0000000..6afd3f6 --- /dev/null +++ b/apps/event-cache/clients/index.ts @@ -0,0 +1,21 @@ +import { createPublicClient, http } from 'viem'; +import { mainnet, sepolia } from "viem/chains"; + + +const mainnetPublicClient = createPublicClient({ + chain: mainnet, + transport: http(process.env.PONDER_RPC_URL_1) +}) + +const sepoliaPublicClient = createPublicClient({ + chain: sepolia, + transport: http(process.env.PONDER_RPC_URL_11155111) +}) + +export function getL1PublicClient(l2chainId: number) { + if (l2chainId === 11155420 || l2chainId === 84532) { + return sepoliaPublicClient; + } else { + return mainnetPublicClient; + } +} \ No newline at end of file diff --git a/apps/event-cache/constants/index.ts b/apps/event-cache/constants/index.ts index 29e427f..7368c06 100644 --- a/apps/event-cache/constants/index.ts +++ b/apps/event-cache/constants/index.ts @@ -1 +1,2 @@ -export const OPTIMISM_MINTABLE_ERC721_FACTORY_ADDRESS = "0x4200000000000000000000000000000000000017" \ No newline at end of file +export const OPTIMISM_MINTABLE_ERC721_FACTORY_ADDRESS = "0x4200000000000000000000000000000000000017" +export const OPTIMISM_L2_ERC721_BRIDGE_ADDRESS = "0x4200000000000000000000000000000000000014" \ No newline at end of file diff --git a/apps/event-cache/ponder.config.ts b/apps/event-cache/ponder.config.ts index a0a3ada..56850a4 100644 --- a/apps/event-cache/ponder.config.ts +++ b/apps/event-cache/ponder.config.ts @@ -1,10 +1,18 @@ import { createConfig } from "@ponder/core"; import { http } from "viem"; -import { OptimismMintableERC721Factory } from "./abis/OptimismMintableERC721Factory"; -import { OPTIMISM_MINTABLE_ERC721_FACTORY_ADDRESS } from "./constants"; +import { L1ERC721BridgeAbi, L2ERC721BridgeAbi, OptimismMintableERC721FactoryAbi } from "./abis"; +import { OPTIMISM_L2_ERC721_BRIDGE_ADDRESS, OPTIMISM_MINTABLE_ERC721_FACTORY_ADDRESS } from "./constants"; export default createConfig({ networks: { + ethereum: { + chainId: 1, + transport: http(process.env.PONDER_RPC_URL_1), + }, + sepolia: { + chainId: 11155111, + transport: http(process.env.PONDER_RPC_URL_11155111), + }, optimism: { chainId: 10, transport: http(process.env.PONDER_RPC_URL_10), @@ -25,31 +33,81 @@ export default createConfig({ contracts: { OptimismMintableERC721Factory: { + abi: OptimismMintableERC721FactoryAbi, + filter: { event: "OptimismMintableERC721Created" }, + address: OPTIMISM_MINTABLE_ERC721_FACTORY_ADDRESS, network: { // Production optimism: { - address: OPTIMISM_MINTABLE_ERC721_FACTORY_ADDRESS, // Block number of the first transaction startBlock: 116002023 }, base: { - address: OPTIMISM_MINTABLE_ERC721_FACTORY_ADDRESS, // Block number of the first transaction startBlock: 2297164 }, - // // Testnet + // Testnet optimismSepolia: { - address: OPTIMISM_MINTABLE_ERC721_FACTORY_ADDRESS, // Block number of the first transaction startBlock: 7074623 }, baseSepolia: { - address: OPTIMISM_MINTABLE_ERC721_FACTORY_ADDRESS, // Block number of the first transaction startBlock: 6932093 }, }, - abi: OptimismMintableERC721Factory, }, + L1ERC721Bridge: { + abi: L1ERC721BridgeAbi, + filter: { event: ["ERC721BridgeInitiated", "ERC721BridgeFinalized"] }, + network: { + // Production + ethereum: { + address: [ + // Optimism + "0x5a7749f83b81B301cAb5f48EB8516B986DAef23D", + // Base + "0x608d94945A64503E642E6370Ec598e519a2C1E53", + ], + // Block number of the first transaction + startBlock: 15677422, + }, + sepolia: { + address: [ + // Optimism Sepolia Testnet + "0xd83e03D576d23C9AEab8cC44Fa98d058D2176D1f", + // Base Sepolia Testnet + "0x21eFD066e581FA55Ef105170Cc04d74386a09190" + ], + // Block number of the first transaction + startBlock: 5126689 + }, + }, + }, + L2ERC721Bridge: { + abi: L2ERC721BridgeAbi, + filter: { event: ["ERC721BridgeInitiated", "ERC721BridgeFinalized"] }, + address: OPTIMISM_L2_ERC721_BRIDGE_ADDRESS, + network: { + // Production + optimism: { + // Block number of the first transaction + startBlock: 0 + }, + base: { + // Block number of the first transaction + startBlock: 0 + }, + // Testnet + optimismSepolia: { + // Block number of the first transaction + startBlock: 0 + }, + baseSepolia: { + // Block number of the first transaction + startBlock: 0 + }, + }, + } }, }); diff --git a/apps/event-cache/ponder.schema.ts b/apps/event-cache/ponder.schema.ts index 7644def..67bad62 100644 --- a/apps/event-cache/ponder.schema.ts +++ b/apps/event-cache/ponder.schema.ts @@ -1,6 +1,7 @@ import { createSchema } from "@ponder/core"; export default createSchema((p) => ({ + BridgedErcy721State: p.createEnum(["L1", "L2", "PENDING_TO_L1", "PENDING_TO_L2"]), OptimismMintableERC721: p.createTable({ id: p.string(), chainId: p.int(), @@ -13,4 +14,15 @@ export default createSchema((p) => ({ remoteSymbol: p.string().optional(), deployer: p.string(), }), + BridgedErc721: p.createTable({ + id: p.string(), + state: p.enum("BridgedErcy721State"), + l1ChainId: p.int(), + l2ChainId: p.int(), + l1Token: p.string(), + l2Token: p.string(), + tokenId: p.string(), + timestamp: p.bigint(), + owner: p.string(), + }), })); diff --git a/apps/event-cache/src/L1ERC721Bridge.ts b/apps/event-cache/src/L1ERC721Bridge.ts new file mode 100644 index 0000000..3302171 --- /dev/null +++ b/apps/event-cache/src/L1ERC721Bridge.ts @@ -0,0 +1,109 @@ +import { ponder } from "@/generated"; +import { base, baseSepolia, optimism, optimismSepolia } from "viem/chains"; + +function getL2ChainId(l1ContractAddress: string | null) { + if (!l1ContractAddress) { + throw new Error("Invalid l1 contract Address") + } + const l1ContractToChainId: Record = { + "0x5a7749f83b81B301cAb5f48EB8516B986DAef23D": optimism.id, + "0x608d94945A64503E642E6370Ec598e519a2C1E53": base.id, + "0xd83e03D576d23C9AEab8cC44Fa98d058D2176D1f": optimismSepolia.id, + "0x21eFD066e581FA55Ef105170Cc04d74386a09190": baseSepolia.id + + } + const l2ChainId = l1ContractToChainId?.[l1ContractAddress] + if (!l2ChainId) { + throw new Error("Invalid l1 contract Address: " + l1ContractAddress) + } + return l2ChainId +} + + +ponder.on("L1ERC721Bridge:ERC721BridgeInitiated", async ({ event, context }) => { + const { BridgedErc721 } = context.db; + const timestamp = event.block.timestamp + const chainId = context.network.chainId + const { localToken: l1Token, remoteToken: l2Token, tokenId, to } = event.args + const l1ContractAddress = event.log.address + const l1ChainId = chainId + const l2ChainId = getL2ChainId(l1ContractAddress) + const id = `${l1ChainId}:${l1Token}:${tokenId}` + + const existingBridgedToken = await BridgedErc721.findUnique({ + id, + }); + + // Only update the token if it is the most recent event + if (!existingBridgedToken || timestamp > existingBridgedToken.timestamp) { + await BridgedErc721.upsert({ + id, + create: { + state: "PENDING_TO_L2", + l1ChainId, + owner: to, + l1Token, + timestamp, + l2Token, + tokenId: tokenId.toString(), + l2ChainId, + }, + update: { + state: "PENDING_TO_L2", + l1ChainId, + owner: to, + l1Token, + l2Token, + timestamp, + tokenId: tokenId.toString(), + l2ChainId, + } + }); + } + + +}); + +ponder.on("L1ERC721Bridge:ERC721BridgeFinalized", async ({ event, context }) => { + const { BridgedErc721 } = context.db; + const timestamp = event.block.timestamp + const chainId = context.network.chainId + const l1ContractAddress = event.log.address + const { localToken: l1Token, remoteToken: l2Token, tokenId, to } = event.args + const l1ChainId = chainId + const l2ChainId = getL2ChainId(l1ContractAddress) + const id = `${l1ChainId}:${l1Token}:${tokenId}` + + const existingBridgedToken = await BridgedErc721.findUnique({ + id, + }); + + // Only update the token if it is the most recent event + if (!existingBridgedToken || timestamp > existingBridgedToken.timestamp) { + await BridgedErc721.upsert({ + id, + create: { + state: "L1", + l1ChainId, + owner: to, + l1Token, + timestamp, + l2Token, + tokenId: tokenId.toString(), + l2ChainId, + }, + update: { + state: "L1", + l1ChainId, + owner: to, + l1Token, + l2Token, + timestamp, + tokenId: tokenId.toString(), + l2ChainId, + } + }); + } + + +}); \ No newline at end of file diff --git a/apps/event-cache/src/L2ERC721Bridge.ts b/apps/event-cache/src/L2ERC721Bridge.ts new file mode 100644 index 0000000..b54040f --- /dev/null +++ b/apps/event-cache/src/L2ERC721Bridge.ts @@ -0,0 +1,78 @@ +import { ponder } from "@/generated"; +import { base, mainnet, optimism, sepolia } from "viem/chains"; + +function getL1ChainId(l2ChainId: number) { + if (l2ChainId in [base.id, optimism.id]) { + return mainnet.id + } + + return sepolia.id +} + +ponder.on("L2ERC721Bridge:ERC721BridgeInitiated", async ({ event, context }) => { + const { BridgedErc721 } = context.db; + const chainId = context.network.chainId + const timestamp = event.block.timestamp + const { remoteToken: l1Token, localToken: l2Token, tokenId } = event.args + const l1ChainId = getL1ChainId(chainId) + const l2ChainId = chainId + const id = `${l1ChainId}:${l1Token}:${tokenId}` + + const existingToken = await BridgedErc721.findUnique({ + id, + }); + + if (!existingToken || timestamp > existingToken.timestamp) { + await BridgedErc721.upsert({ + id, + update: { + state: "PENDING_TO_L1", + l2ChainId, + }, + create: { + state: "PENDING_TO_L1", + l1ChainId, + l2ChainId, + l2Token, + owner: event.args.to, + l1Token, + timestamp, + tokenId: tokenId.toString(), + } + }); + } +}); + +ponder.on("L2ERC721Bridge:ERC721BridgeFinalized", async ({ event, context }) => { + const { BridgedErc721 } = context.db; + const chainId = context.network.chainId + const timestamp = event.block.timestamp + const { remoteToken: l1Token, localToken: l2Token, tokenId } = event.args + const l1ChainId = getL1ChainId(chainId) + const l2ChainId = chainId + const id = `${l1ChainId}:${l1Token}:${tokenId}` + + const existingToken = await BridgedErc721.findUnique({ + id, + }); + + if (!existingToken || timestamp > existingToken.timestamp) { + await BridgedErc721.upsert({ + id, + update: { + state: "L2", + l2ChainId, + }, + create: { + state: "L2", + l1ChainId, + l2ChainId, + l2Token, + owner: event.args.to, + l1Token, + timestamp, + tokenId: tokenId.toString(), + } + }); + } +}); \ No newline at end of file diff --git a/apps/event-cache/src/OptimismMintableERC721Factory.ts b/apps/event-cache/src/OptimismMintableERC721Factory.ts index 9ab473d..7eddfc5 100644 --- a/apps/event-cache/src/OptimismMintableERC721Factory.ts +++ b/apps/event-cache/src/OptimismMintableERC721Factory.ts @@ -1,25 +1,6 @@ import { ponder } from "@/generated"; -import { createPublicClient, erc721Abi, http } from 'viem'; -import { mainnet, sepolia } from "viem/chains"; - - -const mainnetPublicClient = createPublicClient({ - chain: mainnet, - transport: http(process.env.PONDER_RPC_URL_1) -}) - -const sepoliaPublicClient = createPublicClient({ - chain: sepolia, - transport: http(process.env.PONDER_RPC_URL_11155111) -}) - -function getL1PublicClient(l2chainId: number) { - if (l2chainId === 11155420 || l2chainId === 84532) { - return sepoliaPublicClient; - } else { - return mainnetPublicClient; - } -} +import { erc721Abi } from "viem"; +import { getL1PublicClient } from "../clients"; ponder.on("OptimismMintableERC721Factory:OptimismMintableERC721Created", async ({ event, context }) => { const { OptimismMintableERC721 } = context.db; @@ -90,7 +71,7 @@ ponder.on("OptimismMintableERC721Factory:OptimismMintableERC721Created", async ( const { localName, localSymbol, remoteName, remoteSymbol } = tokenMetadata await OptimismMintableERC721.create({ - id: `${context.network.chainId}:${event.args.localToken}`, + id: `${context.network.chainId}:${event.args.localToken}:${event.args.remoteToken}`, data: { chainId: context.network.chainId, blockNumber: event.block.number, From 83e63599e3ed583fd4d4c118b539439fd39b7bbf Mon Sep 17 00:00:00 2001 From: Vitor Date: Fri, 5 Apr 2024 09:51:22 -0300 Subject: [PATCH 2/6] wip --- apps/event-cache/ponder.schema.ts | 4 +- .../app/(general)/bridged-nfts/page.tsx | 39 + .../erc721/erc721-collection-selector.tsx | 268 +++--- .../components/forms/form-L1-to-L2-bridge.tsx | 24 +- .../forms/form-create-l2-erc721.tsx | 64 +- .../lib/event-cache/gql/fragment-masking.ts | 76 +- apps/website/lib/event-cache/gql/gql.ts | 35 +- apps/website/lib/event-cache/gql/graphql.ts | 876 ++++++------------ apps/website/lib/event-cache/gql/index.ts | 4 +- .../event-cache/hooks/use-bridged-erc721.tsx | 47 + ...timism-mintable-erc721-by-local-token.tsx} | 2 +- ...imism-mintable-erc721-by-remote-token.tsx} | 2 +- 12 files changed, 606 insertions(+), 835 deletions(-) create mode 100644 apps/website/app/(general)/bridged-nfts/page.tsx create mode 100644 apps/website/lib/event-cache/hooks/use-bridged-erc721.tsx rename apps/website/lib/event-cache/hooks/{use-get-optimism-mintable-erc721-by-local-token.tsx => use-optimism-mintable-erc721-by-local-token.tsx} (92%) rename apps/website/lib/event-cache/hooks/{use-get-optimism-mintable-erc721-by-remote-token.tsx => use-optimism-mintable-erc721-by-remote-token.tsx} (92%) diff --git a/apps/event-cache/ponder.schema.ts b/apps/event-cache/ponder.schema.ts index 67bad62..2420f56 100644 --- a/apps/event-cache/ponder.schema.ts +++ b/apps/event-cache/ponder.schema.ts @@ -1,7 +1,7 @@ import { createSchema } from "@ponder/core"; export default createSchema((p) => ({ - BridgedErcy721State: p.createEnum(["L1", "L2", "PENDING_TO_L1", "PENDING_TO_L2"]), + BridgedErc721State: p.createEnum(["L1", "L2", "PENDING_TO_L1", "PENDING_TO_L2"]), OptimismMintableERC721: p.createTable({ id: p.string(), chainId: p.int(), @@ -16,7 +16,7 @@ export default createSchema((p) => ({ }), BridgedErc721: p.createTable({ id: p.string(), - state: p.enum("BridgedErcy721State"), + state: p.enum("BridgedErc721State"), l1ChainId: p.int(), l2ChainId: p.int(), l1Token: p.string(), diff --git a/apps/website/app/(general)/bridged-nfts/page.tsx b/apps/website/app/(general)/bridged-nfts/page.tsx new file mode 100644 index 0000000..8f3e126 --- /dev/null +++ b/apps/website/app/(general)/bridged-nfts/page.tsx @@ -0,0 +1,39 @@ +import { Card } from "@/components/ui/card" +import { FormCreateL2ERC721 } from "@/components/forms/form-create-l2-erc721" +import { LinkComponent } from "@/components/shared/link-component" + +export default function CreatePage() { + return ( +
+
+

+ Create New L2 NFT +

+

+ To start bridging NFT collections from Ethereum to the Superchain, a + new L2 NFT must be created using the Optimism developed bridging and + ERC721 smart contracts. +

+
+ + + +
+

+ + We recommend creating a new L2 NFT with the approval of the + collection creator. + {" "} + This ensures the new L2 NFT can be properly associated with the + original collection and third-party platforms, like OpenSea, can + properly display the provenance. +

+

+ + Learn more about getting a collection listed and verified. + +

+
+
+ ) +} diff --git a/apps/website/components/blockchain/erc721/erc721-collection-selector.tsx b/apps/website/components/blockchain/erc721/erc721-collection-selector.tsx index 31c4e29..ed8dd00 100644 --- a/apps/website/components/blockchain/erc721/erc721-collection-selector.tsx +++ b/apps/website/components/blockchain/erc721/erc721-collection-selector.tsx @@ -1,15 +1,12 @@ "use client" -import { useMemo, useState } from "react" -import Image from "next/image" import { l2NetworksOptions } from "@/data/networks/options" +import Image from "next/image" +import { useMemo, useState } from "react" import { Address, checksumAddress, isAddress } from "viem" -import { useGetOtimismMintableERC721ByLocalTokenQuery } from "@/lib/event-cache/hooks/use-get-optimism-mintable-erc721-by-local-token" -import { useGetOtimismMintableERC721ByRemoteTokenQuery } from "@/lib/event-cache/hooks/use-get-optimism-mintable-erc721-by-remote-token" -import { type Nft } from "@/lib/hooks/web3/use-nfts-for-owner" -import { AppMode } from "@/lib/state/app-mode" -import { cn } from "@/lib/utils" +import { ImageIpfs } from "@/components/blockchain/image-ipfs" +import { LinkComponent } from "@/components/shared/link-component" import { Button } from "@/components/ui/button" import { Command, @@ -19,8 +16,11 @@ import { CommandList, } from "@/components/ui/command" import { Dialog, DialogContent } from "@/components/ui/dialog" -import { ImageIpfs } from "@/components/blockchain/image-ipfs" -import { LinkComponent } from "@/components/shared/link-component" +import { useOtimismMintableERC721ByLocalTokenQuery } from "@/lib/event-cache/hooks/use-optimism-mintable-erc721-by-local-token" +import { useOtimismMintableERC721ByRemoteTokenQuery } from "@/lib/event-cache/hooks/use-optimism-mintable-erc721-by-remote-token" +import { type Nft } from "@/lib/hooks/web3/use-nfts-for-owner" +import { AppMode } from "@/lib/state/app-mode" +import { cn } from "@/lib/utils" import { Token, TokenList } from "./types" @@ -62,7 +62,7 @@ export function Erc721CollectionSelector({ const [searchValue, setSearchValue] = useState("") const getOtimismMintableERC721ByRemoteTokenQuery = - useGetOtimismMintableERC721ByRemoteTokenQuery({ + useOtimismMintableERC721ByRemoteTokenQuery({ remoteToken: isAddress(selectedUnlistedToken ?? searchValue) ? checksumAddress(selectedUnlistedToken ?? (searchValue as Address)) : "0x0", @@ -74,7 +74,7 @@ export function Erc721CollectionSelector({ }) const getOtimismMintableERC721ByLocalTokenQuery = - useGetOtimismMintableERC721ByLocalTokenQuery({ + useOtimismMintableERC721ByLocalTokenQuery({ chainId, localToken: isAddress(selectedUnlistedToken ?? searchValue) ? checksumAddress(selectedUnlistedToken ?? (searchValue as Address)) @@ -252,16 +252,12 @@ export function Erc721CollectionSelector({ value={tokenAddress} className={cn("flex cursor-pointer gap-x-2.5 py-2")} onSelect={() => { - const tokenAddress = ( - chainType === "L1" - ? token.address - : token.extensions?.bridgeInfo?.[chainId] - ?.tokenAddress - ) as Address - handleSelect(tokenAddress) + const l1Token = token.address as Address + const l2Token = token.extensions?.bridgeInfo?.[chainId] + handleSelect((chainType === "L1" ? l1Token : l2Token) as Address) setSelectedUnlistedToken(undefined) setDestinationNetwork?.(undefined) - setRemoteToken?.(token.address as Address) + setRemoteToken?.((chainType === "L1" ? l2Token : l1Token) as Address) setTokenMetadata?.({ logoURI: selectedTokenData?.logoURI, name: selectedTokenData?.name ?? undefined, @@ -320,128 +316,128 @@ export function Erc721CollectionSelector({ })} {chainType === "L1" ? getOtimismMintableERC721ByRemoteTokenQuery.data && ( -
- {getOtimismMintableERC721ByRemoteTokenQuery.data.optimismMintableERC721s.items.map( - (item) => ( - { - handleSelect(item.remoteToken as Address) - setSelectedUnlistedToken( - item.remoteToken as Address - ) - setDestinationNetwork?.(item.chainId.toString()) - setRemoteToken?.(item.localToken as Address) - setTokenMetadata?.({ - logoURI: "/logo.svg", - name: - item.localName ?? - item.remoteName ?? - undefined, - }) - }} - > - -
-
-

- {item.remoteName ?? item.localName} -

-

- L2: {item.localToken} -

-
-
-
- chain logo -
-

- Unlisted -

+
+ {getOtimismMintableERC721ByRemoteTokenQuery.data.optimismMintableERC721s.items.map( + (item) => ( + { + handleSelect(item.remoteToken as Address) + setSelectedUnlistedToken( + item.remoteToken as Address + ) + setDestinationNetwork?.(item.chainId.toString()) + setRemoteToken?.(item.localToken as Address) + setTokenMetadata?.({ + logoURI: "/logo.svg", + name: + item.localName ?? + item.remoteName ?? + undefined, + }) + }} + > + +
+
+

+ {item.remoteName ?? item.localName} +

+

+ L2: {item.localToken} +

+
+
+
+ chain logo
+

+ Unlisted +

- - ) - )} -
- ) +
+ + ) + )} +
+ ) : getOtimismMintableERC721ByLocalTokenQuery.data && ( -
- {getOtimismMintableERC721ByLocalTokenQuery.data.optimismMintableERC721s.items.map( - (item) => ( - { - handleSelect(item.localToken as Address) - setSelectedUnlistedToken( - item.localToken as Address - ) - setRemoteToken?.(item.remoteToken as Address) - setTokenMetadata?.({ - logoURI: "/logo.svg", - name: - item.localName ?? - item.remoteName ?? - undefined, - }) - }} - > - -
-
-

- {item.remoteName ?? item.localName} -

-

- {item.localToken} -

-
-
-
- chain logo -
-

- Unlisted -

+
+ {getOtimismMintableERC721ByLocalTokenQuery.data.optimismMintableERC721s.items.map( + (item) => ( + { + handleSelect(item.localToken as Address) + setSelectedUnlistedToken( + item.localToken as Address + ) + setRemoteToken?.(item.remoteToken as Address) + setTokenMetadata?.({ + logoURI: "/logo.svg", + name: + item.localName ?? + item.remoteName ?? + undefined, + }) + }} + > + +
+
+

+ {item.remoteName ?? item.localName} +

+

+ {item.localToken} +

+
+
+
+ chain logo
+

+ Unlisted +

- - ) - )} -
- )} +
+ + ) + )} +
+ )}
diff --git a/apps/website/components/forms/form-L1-to-L2-bridge.tsx b/apps/website/components/forms/form-L1-to-L2-bridge.tsx index c01c155..3bb0cec 100644 --- a/apps/website/components/forms/form-L1-to-L2-bridge.tsx +++ b/apps/website/components/forms/form-L1-to-L2-bridge.tsx @@ -1,9 +1,9 @@ "use client" -import { useEffect, useMemo, useState, type HTMLAttributes } from "react" -import Image from "next/image" import { l1Erc721BridgeAbi } from "@/data/abis" import { l1NetworkOptions, l2NetworksOptions } from "@/data/networks/options" +import Image from "next/image" +import { useEffect, useMemo, useState, type HTMLAttributes } from "react" import { type Address, type BaseError } from "viem" import { useAccount, @@ -12,6 +12,15 @@ import { useWriteContract, } from "wagmi" +import { BlockExplorerLink } from "@/components/blockchain/block-explorer-link" +import { ConnectButton } from "@/components/blockchain/connect-button" +import { ContractWriteButton } from "@/components/blockchain/contract-write-button" +import { ImageIpfs } from "@/components/blockchain/image-ipfs" +import { SwitchNetworkButton } from "@/components/blockchain/switch-network-button" +import { TransactionStatus } from "@/components/blockchain/transaction-status" +import { Button } from "@/components/ui/button" +import { Label } from "@/components/ui/label" +import { Skeleton } from "@/components/ui/skeleton" import { useReadErc721GetApproved, useSimulateErc721Approve, @@ -20,15 +29,6 @@ import { import { useNftsForOwner } from "@/lib/hooks/web3/use-nfts-for-owner" import { type AppMode } from "@/lib/state/app-mode" import { cn } from "@/lib/utils" -import { Button } from "@/components/ui/button" -import { Label } from "@/components/ui/label" -import { Skeleton } from "@/components/ui/skeleton" -import { BlockExplorerLink } from "@/components/blockchain/block-explorer-link" -import { ConnectButton } from "@/components/blockchain/connect-button" -import { ContractWriteButton } from "@/components/blockchain/contract-write-button" -import { ImageIpfs } from "@/components/blockchain/image-ipfs" -import { SwitchNetworkButton } from "@/components/blockchain/switch-network-button" -import { TransactionStatus } from "@/components/blockchain/transaction-status" import { queryClient } from "../providers/root-provider" @@ -58,7 +58,7 @@ export function FormL1ToL2Bridge({ ...props }: FormL1ToL2BridgeProps) { const [imageLoaded, setImageLoaded] = useState(false) - + console.log("localToken", localToken, remoteToken) const l1Chain = l1NetworkOptions[appMode] const l2Chains = l2NetworksOptions[appMode] diff --git a/apps/website/components/forms/form-create-l2-erc721.tsx b/apps/website/components/forms/form-create-l2-erc721.tsx index c85d1bb..3478734 100644 --- a/apps/website/components/forms/form-create-l2-erc721.tsx +++ b/apps/website/components/forms/form-create-l2-erc721.tsx @@ -1,10 +1,10 @@ "use client" -import { useEffect, useState, type HTMLAttributes } from "react" -import Image from "next/image" import { optimismMintableErc721FactoryAbi } from "@/data/abis" import { l1NetworkOptions, l2NetworksOptions } from "@/data/networks/options" import { zodResolver } from "@hookform/resolvers/zod" +import Image from "next/image" +import { useEffect, useState, type HTMLAttributes } from "react" import { SubmitHandler, useForm } from "react-hook-form" import { useDebounce } from "usehooks-ts" import { @@ -21,15 +21,10 @@ 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, - useSimulateOptimismMintableErc721FactoryCreateOptimismMintableErc721, - useWriteOptimismMintableErc721FactoryCreateOptimismMintableErc721, -} from "@/lib/generated/blockchain" -import { useAppMode } from "@/lib/state/app-mode" -import { cn } from "@/lib/utils" +import { ConnectButton } from "@/components/blockchain/connect-button" +import { ContractWriteButton } from "@/components/blockchain/contract-write-button" +import { SwitchNetworkButton } from "@/components/blockchain/switch-network-button" +import { TransactionStatus } from "@/components/blockchain/transaction-status" import { Form, FormControl, @@ -46,10 +41,15 @@ import { SelectTrigger, SelectValue, } from "@/components/ui/select" -import { ConnectButton } from "@/components/blockchain/connect-button" -import { ContractWriteButton } from "@/components/blockchain/contract-write-button" -import { SwitchNetworkButton } from "@/components/blockchain/switch-network-button" -import { TransactionStatus } from "@/components/blockchain/transaction-status" +import { useOtimismMintableERC721ByRemoteTokenQuery } from "@/lib/event-cache/hooks/use-optimism-mintable-erc721-by-remote-token" +import { + useReadErc721Name, + useReadErc721Symbol, + useSimulateOptimismMintableErc721FactoryCreateOptimismMintableErc721, + useWriteOptimismMintableErc721FactoryCreateOptimismMintableErc721, +} from "@/lib/generated/blockchain" +import { useAppMode } from "@/lib/state/app-mode" +import { cn } from "@/lib/utils" import { BlockExplorerLink } from "../blockchain/block-explorer-link" import { LinkComponent } from "../shared/link-component" @@ -92,25 +92,25 @@ export const FormCreateL2ERC721 = ({ name: keyof FormData type: string }[] = [ - { - label: `L1 NFT Address ${l1Chain.name}`, - name: "remoteToken", - type: "text", - }, - { - label: "Name", - name: "name", - type: "text", - }, - { - label: "Symbol", - name: "symbol", - type: "text", - }, - ] + { + label: `L1 NFT Address ${l1Chain.name}`, + name: "remoteToken", + type: "text", + }, + { + label: "Name", + name: "name", + type: "text", + }, + { + label: "Symbol", + name: "symbol", + type: "text", + }, + ] const getOtimismMintableERC721ByRemoteTokenQuery = - useGetOtimismMintableERC721ByRemoteTokenQuery({ + useOtimismMintableERC721ByRemoteTokenQuery({ chainId: Number(watchL2ChainId), remoteToken: isAddress(watchRemoteToken) ? checksumAddress(watchRemoteToken) diff --git a/apps/website/lib/event-cache/gql/fragment-masking.ts b/apps/website/lib/event-cache/gql/fragment-masking.ts index 36e56ac..2ba06f1 100644 --- a/apps/website/lib/event-cache/gql/fragment-masking.ts +++ b/apps/website/lib/event-cache/gql/fragment-masking.ts @@ -1,86 +1,66 @@ -import { - DocumentTypeDecoration, - ResultOf, - TypedDocumentNode, -} from "@graphql-typed-document-node/core" -import { FragmentDefinitionNode } from "graphql" +import { ResultOf, DocumentTypeDecoration, TypedDocumentNode } from '@graphql-typed-document-node/core'; +import { FragmentDefinitionNode } from 'graphql'; +import { Incremental } from './graphql'; -import { Incremental } from "./graphql" -export type FragmentType< - TDocumentType extends DocumentTypeDecoration -> = TDocumentType extends DocumentTypeDecoration - ? [TType] extends [{ " $fragmentName"?: infer TKey }] +export type FragmentType> = TDocumentType extends DocumentTypeDecoration< + infer TType, + any +> + ? [TType] extends [{ ' $fragmentName'?: infer TKey }] ? TKey extends string - ? { " $fragmentRefs"?: { [key in TKey]: TType } } + ? { ' $fragmentRefs'?: { [key in TKey]: TType } } : never : never - : never + : never; // return non-nullable if `fragmentType` is non-nullable export function useFragment( _documentNode: DocumentTypeDecoration, fragmentType: FragmentType> -): TType +): TType; // return nullable if `fragmentType` is nullable export function useFragment( _documentNode: DocumentTypeDecoration, - fragmentType: - | FragmentType> - | null - | undefined -): TType | null | undefined + fragmentType: FragmentType> | null | undefined +): TType | null | undefined; // return array of non-nullable if `fragmentType` is array of non-nullable export function useFragment( _documentNode: DocumentTypeDecoration, fragmentType: ReadonlyArray>> -): ReadonlyArray +): ReadonlyArray; // return array of nullable if `fragmentType` is array of nullable export function useFragment( _documentNode: DocumentTypeDecoration, - fragmentType: - | ReadonlyArray>> - | null - | undefined -): ReadonlyArray | null | undefined + fragmentType: ReadonlyArray>> | null | undefined +): ReadonlyArray | null | undefined; export function useFragment( _documentNode: DocumentTypeDecoration, - fragmentType: - | FragmentType> - | ReadonlyArray>> - | null - | undefined + fragmentType: FragmentType> | ReadonlyArray>> | null | undefined ): TType | ReadonlyArray | null | undefined { - return fragmentType as any + return fragmentType as any; } + export function makeFragmentData< F extends DocumentTypeDecoration, FT extends ResultOf >(data: FT, _fragment: F): FragmentType { - return data as FragmentType + return data as FragmentType; } export function isFragmentReady( queryNode: DocumentTypeDecoration, fragmentNode: TypedDocumentNode, - data: - | FragmentType, any>> - | null - | undefined + data: FragmentType, any>> | null | undefined ): data is FragmentType { - const deferredFields = ( - queryNode as { - __meta__?: { deferredFields: Record } - } - ).__meta__?.deferredFields + const deferredFields = (queryNode as { __meta__?: { deferredFields: Record } }).__meta__ + ?.deferredFields; - if (!deferredFields) return true + if (!deferredFields) return true; - const fragDef = fragmentNode.definitions[0] as - | FragmentDefinitionNode - | undefined - const fragName = fragDef?.name?.value + 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) + 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 index e43e18e..708802f 100644 --- a/apps/website/lib/event-cache/gql/gql.ts +++ b/apps/website/lib/event-cache/gql/gql.ts @@ -1,7 +1,6 @@ /* eslint-disable */ -import { TypedDocumentNode as DocumentNode } from "@graphql-typed-document-node/core" - -import * as types from "./graphql" +import * as types from './graphql'; +import { TypedDocumentNode as DocumentNode } from '@graphql-typed-document-node/core'; /** * Map of all GraphQL operations in the project. @@ -14,13 +13,10 @@ import * as types from "./graphql" * 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 getOtimismMintableERC721ByLocalTokenQuery(\n $localToken: String!\n $chainId: Int\n ) {\n optimismMintableERC721s(\n where: { localToken: $localToken, 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.GetOtimismMintableErc721ByLocalTokenQueryDocument, - "\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, -} + "\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 getOtimismMintableERC721ByLocalTokenQuery(\n $localToken: String!\n $chainId: Int\n ) {\n optimismMintableERC721s(\n where: { localToken: $localToken, 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.GetOtimismMintableErc721ByLocalTokenQueryDocument, + "\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. @@ -34,30 +30,23 @@ const documents = { * The query argument is unknown! * Please regenerate the types. */ -export function graphql(source: string): unknown +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"] +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 getOtimismMintableERC721ByLocalTokenQuery(\n $localToken: String!\n $chainId: Int\n ) {\n optimismMintableERC721s(\n where: { localToken: $localToken, 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 getOtimismMintableERC721ByLocalTokenQuery(\n $localToken: String!\n $chainId: Int\n ) {\n optimismMintableERC721s(\n where: { localToken: $localToken, 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: "\n query getOtimismMintableERC721ByLocalTokenQuery(\n $localToken: String!\n $chainId: Int\n ) {\n optimismMintableERC721s(\n where: { localToken: $localToken, 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 getOtimismMintableERC721ByLocalTokenQuery(\n $localToken: String!\n $chainId: Int\n ) {\n optimismMintableERC721s(\n where: { localToken: $localToken, 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"]; /** * 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: "\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] ?? {} + return (documents as any)[source] ?? {}; } -export type DocumentType> = - TDocumentNode extends DocumentNode ? TType : never +export type DocumentType> = TDocumentNode extends DocumentNode< infer TType, any> ? TType : never; \ No newline at end of file diff --git a/apps/website/lib/event-cache/gql/graphql.ts b/apps/website/lib/event-cache/gql/graphql.ts index 8037ea0..ad7b2cd 100644 --- a/apps/website/lib/event-cache/gql/graphql.ts +++ b/apps/website/lib/event-cache/gql/graphql.ts @@ -1,606 +1,326 @@ /* 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 - } +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 = { [_ 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 } + 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 BridgedErc721 = { + __typename?: 'BridgedErc721'; + id: Scalars['String']['output']; + l1ChainId: Scalars['Int']['output']; + l1Token: Scalars['String']['output']; + l2ChainId: Scalars['Int']['output']; + l2Token: Scalars['String']['output']; + owner: Scalars['String']['output']; + state: BridgedErc721State; + timestamp: Scalars['BigInt']['output']; + tokenId: Scalars['String']['output']; +}; + +export type BridgedErc721Filter = { + AND?: InputMaybe>>; + OR?: 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; + l1ChainId?: InputMaybe; + l1ChainId_gt?: InputMaybe; + l1ChainId_gte?: InputMaybe; + l1ChainId_in?: InputMaybe>>; + l1ChainId_lt?: InputMaybe; + l1ChainId_lte?: InputMaybe; + l1ChainId_not?: InputMaybe; + l1ChainId_not_in?: InputMaybe>>; + l1Token?: InputMaybe; + l1Token_contains?: InputMaybe; + l1Token_ends_with?: InputMaybe; + l1Token_in?: InputMaybe>>; + l1Token_not?: InputMaybe; + l1Token_not_contains?: InputMaybe; + l1Token_not_ends_with?: InputMaybe; + l1Token_not_in?: InputMaybe>>; + l1Token_not_starts_with?: InputMaybe; + l1Token_starts_with?: InputMaybe; + l2ChainId?: InputMaybe; + l2ChainId_gt?: InputMaybe; + l2ChainId_gte?: InputMaybe; + l2ChainId_in?: InputMaybe>>; + l2ChainId_lt?: InputMaybe; + l2ChainId_lte?: InputMaybe; + l2ChainId_not?: InputMaybe; + l2ChainId_not_in?: InputMaybe>>; + l2Token?: InputMaybe; + l2Token_contains?: InputMaybe; + l2Token_ends_with?: InputMaybe; + l2Token_in?: InputMaybe>>; + l2Token_not?: InputMaybe; + l2Token_not_contains?: InputMaybe; + l2Token_not_ends_with?: InputMaybe; + l2Token_not_in?: InputMaybe>>; + l2Token_not_starts_with?: InputMaybe; + l2Token_starts_with?: InputMaybe; + owner?: InputMaybe; + owner_contains?: InputMaybe; + owner_ends_with?: InputMaybe; + owner_in?: InputMaybe>>; + owner_not?: InputMaybe; + owner_not_contains?: InputMaybe; + owner_not_ends_with?: InputMaybe; + owner_not_in?: InputMaybe>>; + owner_not_starts_with?: InputMaybe; + owner_starts_with?: InputMaybe; + state?: InputMaybe; + state_in?: InputMaybe>>; + state_not?: InputMaybe; + state_not_in?: InputMaybe>>; + timestamp?: InputMaybe; + timestamp_gt?: InputMaybe; + timestamp_gte?: InputMaybe; + timestamp_in?: InputMaybe>>; + timestamp_lt?: InputMaybe; + timestamp_lte?: InputMaybe; + timestamp_not?: InputMaybe; + timestamp_not_in?: InputMaybe>>; + tokenId?: InputMaybe; + tokenId_contains?: InputMaybe; + tokenId_ends_with?: InputMaybe; + tokenId_in?: InputMaybe>>; + tokenId_not?: InputMaybe; + tokenId_not_contains?: InputMaybe; + tokenId_not_ends_with?: InputMaybe; + tokenId_not_in?: InputMaybe>>; + tokenId_not_starts_with?: InputMaybe; + tokenId_starts_with?: InputMaybe; +}; + +export type BridgedErc721Page = { + __typename?: 'BridgedErc721Page'; + items: Array; + pageInfo: PageInfo; +}; + +export enum BridgedErc721State { + L1 = 'L1', + L2 = 'L2', + PendingToL1 = 'PENDING_TO_L1', + PendingToL2 = 'PENDING_TO_L2' } 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"] -} + __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 -} + 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>>; + 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 -} + __typename?: 'OptimismMintableERC721Page'; + items: Array; + pageInfo: PageInfo; +}; export type PageInfo = { - __typename?: "PageInfo" - endCursor?: Maybe - hasNextPage: Scalars["Boolean"]["output"] - hasPreviousPage: Scalars["Boolean"]["output"] - startCursor?: Maybe -} + __typename?: 'PageInfo'; + endCursor?: Maybe; + hasNextPage: Scalars['Boolean']['output']; + hasPreviousPage: Scalars['Boolean']['output']; + startCursor?: Maybe; +}; export type Query = { - __typename?: "Query" - optimismMintableERC721?: Maybe - optimismMintableERC721s: OptimismMintableErc721Page -} + __typename?: 'Query'; + bridgedErc721?: Maybe; + bridgedErc721s: BridgedErc721Page; + optimismMintableERC721?: Maybe; + optimismMintableERC721s: OptimismMintableErc721Page; +}; + + +export type QueryBridgedErc721Args = { + id: Scalars['String']['input']; + timestamp?: InputMaybe; +}; + + +export type QueryBridgedErc721sArgs = { + after?: InputMaybe; + before?: InputMaybe; + limit?: InputMaybe; + orderBy?: InputMaybe; + orderDirection?: InputMaybe; + timestamp?: InputMaybe; + where?: InputMaybe; +}; + export type QueryOptimismMintableErc721Args = { - id: Scalars["String"]["input"] - timestamp?: InputMaybe -} + id: Scalars['String']['input']; + timestamp?: InputMaybe; +}; + export type QueryOptimismMintableErc721sArgs = { - after?: InputMaybe - before?: InputMaybe - limit?: InputMaybe - orderBy?: InputMaybe - orderDirection?: InputMaybe - timestamp?: InputMaybe - where?: InputMaybe -} + after?: InputMaybe; + before?: InputMaybe; + limit?: InputMaybe; + orderBy?: InputMaybe; + orderDirection?: InputMaybe; + timestamp?: InputMaybe; + where?: InputMaybe; +}; export type AllOptimismMintableErc721QueryQueryVariables = Exact<{ - limit?: InputMaybe -}> + 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 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 GetOtimismMintableErc721ByLocalTokenQueryQueryVariables = Exact<{ - localToken: Scalars["String"]["input"] - chainId?: InputMaybe -}> + localToken: Scalars['String']['input']; + chainId?: InputMaybe; +}>; -export type GetOtimismMintableErc721ByLocalTokenQueryQuery = { - __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 GetOtimismMintableErc721ByLocalTokenQueryQuery = { __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?: InputMaybe -}> + remoteToken: Scalars['String']['input']; + chainId?: InputMaybe; +}>; + + +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 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 GetOtimismMintableErc721ByLocalTokenQueryDocument = { - kind: "Document", - definitions: [ - { - kind: "OperationDefinition", - operation: "query", - name: { - kind: "Name", - value: "getOtimismMintableERC721ByLocalTokenQuery", - }, - variableDefinitions: [ - { - kind: "VariableDefinition", - variable: { - kind: "Variable", - name: { kind: "Name", value: "localToken" }, - }, - type: { - kind: "NonNullType", - type: { - kind: "NamedType", - name: { kind: "Name", value: "String" }, - }, - }, - }, - { - kind: "VariableDefinition", - variable: { - kind: "Variable", - name: { kind: "Name", value: "chainId" }, - }, - 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: "localToken" }, - value: { - kind: "Variable", - name: { kind: "Name", value: "localToken" }, - }, - }, - { - 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< - GetOtimismMintableErc721ByLocalTokenQueryQuery, - GetOtimismMintableErc721ByLocalTokenQueryQueryVariables -> -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: "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 -> +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; +export const GetOtimismMintableErc721ByLocalTokenQueryDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"getOtimismMintableERC721ByLocalTokenQuery"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"localToken"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}}},{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"chainId"}},"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":"localToken"},"value":{"kind":"Variable","name":{"kind":"Name","value":"localToken"}}},{"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; +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":"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; \ No newline at end of file diff --git a/apps/website/lib/event-cache/gql/index.ts b/apps/website/lib/event-cache/gql/index.ts index f2b0e1a..f515991 100644 --- a/apps/website/lib/event-cache/gql/index.ts +++ b/apps/website/lib/event-cache/gql/index.ts @@ -1,2 +1,2 @@ -export * from "./fragment-masking" -export * from "./gql" +export * from "./fragment-masking"; +export * from "./gql"; \ No newline at end of file diff --git a/apps/website/lib/event-cache/hooks/use-bridged-erc721.tsx b/apps/website/lib/event-cache/hooks/use-bridged-erc721.tsx new file mode 100644 index 0000000..2c77dad --- /dev/null +++ b/apps/website/lib/event-cache/hooks/use-bridged-erc721.tsx @@ -0,0 +1,47 @@ +import { Address } from "viem" + +import { graphql } from "../gql" +import { useGraphQL } from "../use-graphql" + +const getBridgedERC721ByOwnerQuery = graphql(/* GraphQL */ ` + query getOtimismMintableERC721ByLocalTokenQuery( + $localToken: String! + $chainId: Int + ) { + optimismMintableERC721s( + where: { localToken: $localToken, chainId: $chainId } + ) { + items { + id + chainId + blockNumber + localToken + localName + localSymbol + remoteToken + remoteName + remoteSymbol + deployer + } + } + } +`) + +export function useOtimismMintableERC721ByLocalTokenQuery(params: { + localToken: Address + chainId?: number + query?: { enabled: boolean } +}) { + return useGraphQL( + getBridgedERC721ByOwnerQuery, + { + queryKey: [ + "getOtimismMintableERC721ByLocalToken", + params.chainId, + params.localToken, + ], + enabled: params.query?.enabled, + }, + params + ) +} diff --git a/apps/website/lib/event-cache/hooks/use-get-optimism-mintable-erc721-by-local-token.tsx b/apps/website/lib/event-cache/hooks/use-optimism-mintable-erc721-by-local-token.tsx similarity index 92% rename from apps/website/lib/event-cache/hooks/use-get-optimism-mintable-erc721-by-local-token.tsx rename to apps/website/lib/event-cache/hooks/use-optimism-mintable-erc721-by-local-token.tsx index 42e21f5..5bea8bd 100644 --- a/apps/website/lib/event-cache/hooks/use-get-optimism-mintable-erc721-by-local-token.tsx +++ b/apps/website/lib/event-cache/hooks/use-optimism-mintable-erc721-by-local-token.tsx @@ -27,7 +27,7 @@ const getOtimismMintableERC721ByLocalTokenQuery = graphql(/* GraphQL */ ` } `) -export function useGetOtimismMintableERC721ByLocalTokenQuery(params: { +export function useOtimismMintableERC721ByLocalTokenQuery(params: { localToken: Address chainId?: number query?: { enabled: boolean } 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-optimism-mintable-erc721-by-remote-token.tsx similarity index 92% rename from apps/website/lib/event-cache/hooks/use-get-optimism-mintable-erc721-by-remote-token.tsx rename to apps/website/lib/event-cache/hooks/use-optimism-mintable-erc721-by-remote-token.tsx index e8ceab3..2e5bab7 100644 --- a/apps/website/lib/event-cache/hooks/use-get-optimism-mintable-erc721-by-remote-token.tsx +++ b/apps/website/lib/event-cache/hooks/use-optimism-mintable-erc721-by-remote-token.tsx @@ -27,7 +27,7 @@ const getOtimismMintableERC721ByRemoteTokenQuery = graphql(/* GraphQL */ ` } `) -export function useGetOtimismMintableERC721ByRemoteTokenQuery(params: { +export function useOtimismMintableERC721ByRemoteTokenQuery(params: { remoteToken: Address chainId?: number query?: { enabled: boolean } From fac81f04614fc7dbc13cf2d1f43dab8c4f02345c Mon Sep 17 00:00:00 2001 From: Vitor Date: Fri, 5 Apr 2024 12:19:02 -0300 Subject: [PATCH 3/6] feat: add bridged NFTs page --- apps/event-cache/ponder.schema.ts | 2 + apps/event-cache/src/L1ERC721Bridge.ts | 24 +- apps/event-cache/src/L2ERC721Bridge.ts | 23 +- .../(general)/bridged-nfts/[chainId]/page.tsx | 192 +++ .../app/(general)/bridged-nfts/page.tsx | 55 +- .../blockchain/block-explorer-link.tsx | 35 +- .../erc721/erc721-collection-selector.tsx | 252 ++-- .../components/forms/form-L1-to-L2-bridge.tsx | 23 +- .../forms/form-create-l2-erc721.tsx | 62 +- apps/website/components/layout/footer.tsx | 6 +- .../website/components/ui/navigation-menu.tsx | 12 +- .../lib/event-cache/gql/fragment-masking.ts | 76 +- apps/website/lib/event-cache/gql/gql.ts | 43 +- apps/website/lib/event-cache/gql/graphql.ts | 1177 +++++++++++++---- apps/website/lib/event-cache/gql/index.ts | 4 +- .../event-cache/hooks/use-bridged-erc721.tsx | 55 +- 16 files changed, 1442 insertions(+), 599 deletions(-) create mode 100644 apps/website/app/(general)/bridged-nfts/[chainId]/page.tsx diff --git a/apps/event-cache/ponder.schema.ts b/apps/event-cache/ponder.schema.ts index 2420f56..bc05f47 100644 --- a/apps/event-cache/ponder.schema.ts +++ b/apps/event-cache/ponder.schema.ts @@ -24,5 +24,7 @@ export default createSchema((p) => ({ tokenId: p.string(), timestamp: p.bigint(), owner: p.string(), + txHash: p.string(), + txChainId: p.int(), }), })); diff --git a/apps/event-cache/src/L1ERC721Bridge.ts b/apps/event-cache/src/L1ERC721Bridge.ts index 3302171..1b8287c 100644 --- a/apps/event-cache/src/L1ERC721Bridge.ts +++ b/apps/event-cache/src/L1ERC721Bridge.ts @@ -47,16 +47,13 @@ ponder.on("L1ERC721Bridge:ERC721BridgeInitiated", async ({ event, context }) => l2Token, tokenId: tokenId.toString(), l2ChainId, + txHash: event.log.transactionHash, + txChainId: chainId }, update: { state: "PENDING_TO_L2", - l1ChainId, - owner: to, - l1Token, - l2Token, - timestamp, - tokenId: tokenId.toString(), - l2ChainId, + txHash: event.log.transactionHash, + txChainId: chainId } }); } @@ -91,19 +88,14 @@ ponder.on("L1ERC721Bridge:ERC721BridgeFinalized", async ({ event, context }) => l2Token, tokenId: tokenId.toString(), l2ChainId, + txHash: event.log.transactionHash, + txChainId: chainId }, update: { state: "L1", - l1ChainId, - owner: to, - l1Token, - l2Token, - timestamp, - tokenId: tokenId.toString(), - l2ChainId, + txHash: event.log.transactionHash, + txChainId: chainId } }); } - - }); \ No newline at end of file diff --git a/apps/event-cache/src/L2ERC721Bridge.ts b/apps/event-cache/src/L2ERC721Bridge.ts index b54040f..e22c45e 100644 --- a/apps/event-cache/src/L2ERC721Bridge.ts +++ b/apps/event-cache/src/L2ERC721Bridge.ts @@ -1,12 +1,17 @@ import { ponder } from "@/generated"; -import { base, mainnet, optimism, sepolia } from "viem/chains"; +import { base, baseSepolia, mainnet, optimism, optimismSepolia, sepolia } from "viem/chains"; function getL1ChainId(l2ChainId: number) { - if (l2ChainId in [base.id, optimism.id]) { + const productionChains: number[] = [base.id, optimism.id] + const testnetChains: number[] = [baseSepolia.id, optimismSepolia.id] + + if (productionChains.includes(l2ChainId)) { return mainnet.id } - - return sepolia.id + if (testnetChains.includes(l2ChainId)) { + return sepolia.id + } + throw new Error("Invalid l2 chain id abc: " + l2ChainId) } ponder.on("L2ERC721Bridge:ERC721BridgeInitiated", async ({ event, context }) => { @@ -27,7 +32,8 @@ ponder.on("L2ERC721Bridge:ERC721BridgeInitiated", async ({ event, context }) => id, update: { state: "PENDING_TO_L1", - l2ChainId, + txHash: event.log.transactionHash, + txChainId: chainId }, create: { state: "PENDING_TO_L1", @@ -38,6 +44,8 @@ ponder.on("L2ERC721Bridge:ERC721BridgeInitiated", async ({ event, context }) => l1Token, timestamp, tokenId: tokenId.toString(), + txHash: event.log.transactionHash, + txChainId: chainId } }); } @@ -61,7 +69,8 @@ ponder.on("L2ERC721Bridge:ERC721BridgeFinalized", async ({ event, context }) => id, update: { state: "L2", - l2ChainId, + txHash: event.log.transactionHash, + txChainId: chainId }, create: { state: "L2", @@ -72,6 +81,8 @@ ponder.on("L2ERC721Bridge:ERC721BridgeFinalized", async ({ event, context }) => l1Token, timestamp, tokenId: tokenId.toString(), + txHash: event.log.transactionHash, + txChainId: chainId } }); } diff --git a/apps/website/app/(general)/bridged-nfts/[chainId]/page.tsx b/apps/website/app/(general)/bridged-nfts/[chainId]/page.tsx new file mode 100644 index 0000000..b91c206 --- /dev/null +++ b/apps/website/app/(general)/bridged-nfts/[chainId]/page.tsx @@ -0,0 +1,192 @@ +"use client" + +import { useEffect } from "react" +import Image from "next/image" +import Link from "next/link" +import { useRouter } from "next/navigation" +import { l1NetworkOptions, l2NetworksOptions } from "@/data/networks/options" +import { LuExternalLink } from "react-icons/lu" +import { type Address, type Hex } from "viem" +import { useAccount } from "wagmi" + +import { + BridgedErc721State, + useBridgedERC721ByOwner, +} from "@/lib/event-cache/hooks/use-bridged-erc721" +import { useTokenList } from "@/lib/hooks/use-token-list" +import { useAppMode } from "@/lib/state/app-mode" +import { cn } from "@/lib/utils" +import { Card } from "@/components/ui/card" +import { + NavigationMenu, + NavigationMenuItem, + NavigationMenuLink, + NavigationMenuList, + navigationMenuTriggerStyle, +} from "@/components/ui/navigation-menu" +import { Skeleton } from "@/components/ui/skeleton" +import { BlockExplorerLink } from "@/components/blockchain/block-explorer-link" +import { ConnectButton } from "@/components/blockchain/connect-button" + +export default function BridgedCollectionsByChainIdPage({ + params: { chainId }, +}: { + params: { + chainId: string + } +}) { + const router = useRouter() + const { appMode } = useAppMode() + const { address } = useAccount() + const tokenList = useTokenList() + + const bridgedERC721ByOwnerQuery = useBridgedERC721ByOwner({ + params: { + owner: address, + l2chainId: Number(chainId), + states: [ + BridgedErc721State.L2, + BridgedErc721State.PendingToL1, + BridgedErc721State.PendingToL2, + ], + }, + query: { + enabled: !!address, + }, + }) + const l1Chain = l1NetworkOptions[appMode] || 1 + const l2Chain = l2NetworksOptions[appMode][Number(chainId)] || 10 + + useEffect(() => { + const newChainId = Object.values(l2NetworksOptions[appMode])[0].chainId + + // If AppMode changes, redirect to the first chain in the new mode + if (!l2NetworksOptions[appMode][Number(chainId)]) { + router.push(`/bridged-nfts/${newChainId}`) + } + }, [appMode]) + + return ( +
+ + + {Object.values(l2NetworksOptions[appMode]).map( + ({ name, chainId: optionChainId }) => ( + + + + {name} + + + + ) + )} + + +
+ {!address ? ( +
+ +
+ ) : bridgedERC721ByOwnerQuery.isLoading ? ( + <> + {Array.from({ length: 4 }).map((_, idx) => ( + + ))} + + ) : !bridgedERC721ByOwnerQuery.data || + bridgedERC721ByOwnerQuery.data?.bridgedErc721s.items.length === 0 ? ( +
+ No bridged NFTs found +
+ ) : ( + bridgedERC721ByOwnerQuery.data?.bridgedErc721s.items + .sort( + (a, b) => + Object.keys(BridgedErc721State).indexOf(a.state) - + Object.keys(BridgedErc721State).indexOf(b.state) + ) + .map((bridgedErc721) => { + const tokenMetadata = tokenList?.tokens.find( + (token) => token.address === bridgedErc721.l1Token + ) + return ( + + {`logo`} +
+
+

+ {tokenMetadata?.name || "Unknown"} +

+

+ # {bridgedErc721.tokenId} +

+

+ State:{" "} + {bridgedErc721.state === BridgedErc721State.L2 + ? "L2" + : bridgedErc721.state === + BridgedErc721State.PendingToL1 + ? "Pending bridge to L1" + : "Pending bridge to L2"} +

+
+
+
+ +
+
Transaction Details
+
+ {" "} + +
+
+
+
+
+
{l1Chain.name}
+ +
+
+
{l2Chain?.name}
+ +
+
+
+
+ ) + }) + )} +
+
+ ) +} diff --git a/apps/website/app/(general)/bridged-nfts/page.tsx b/apps/website/app/(general)/bridged-nfts/page.tsx index 8f3e126..a6303ef 100644 --- a/apps/website/app/(general)/bridged-nfts/page.tsx +++ b/apps/website/app/(general)/bridged-nfts/page.tsx @@ -1,39 +1,20 @@ -import { Card } from "@/components/ui/card" -import { FormCreateL2ERC721 } from "@/components/forms/form-create-l2-erc721" -import { LinkComponent } from "@/components/shared/link-component" +"use client" -export default function CreatePage() { - return ( -
-
-

- Create New L2 NFT -

-

- To start bridging NFT collections from Ethereum to the Superchain, a - new L2 NFT must be created using the Optimism developed bridging and - ERC721 smart contracts. -

-
- - - -
-

- - We recommend creating a new L2 NFT with the approval of the - collection creator. - {" "} - This ensures the new L2 NFT can be properly associated with the - original collection and third-party platforms, like OpenSea, can - properly display the provenance. -

-

- - Learn more about getting a collection listed and verified. - -

-
-
- ) +import { useEffect } from "react" +import { useRouter } from "next/navigation" +import { l2NetworksOptions } from "@/data/networks/options" + +import { useAppMode } from "@/lib/state/app-mode" + +export default function BridgedCollectionsPage() { + const { appMode } = useAppMode() + const router = useRouter() + + useEffect(() => { + router.push( + `/bridged-nfts/${Object.values(l2NetworksOptions[appMode])[0].chainId}` + ) + }, []) + + return null } diff --git a/apps/website/components/blockchain/block-explorer-link.tsx b/apps/website/components/blockchain/block-explorer-link.tsx index 5b5b393..f2c40e5 100644 --- a/apps/website/components/blockchain/block-explorer-link.tsx +++ b/apps/website/components/blockchain/block-explorer-link.tsx @@ -1,24 +1,33 @@ import { HTMLAttributes } from "react" -import { type Address } from "viem" +import { Hex, type Address } from "viem" import { useAccount } from "wagmi" import { config } from "@/config/wagmi" import { cn } from "@/lib/utils" -interface BlockExplorerLinkProps extends HTMLAttributes { - address: Address | undefined - showExplorerName?: boolean - chainId?: number - type?: "address" | "tx" -} +type BlockExplorerLinkProps = HTMLAttributes & + ( + | { + address: Address | undefined + tx?: never + showExplorerName?: boolean + chainId?: number + } + | { + address?: never + tx: Hex + showExplorerName?: boolean + chainId?: number + } + ) export const BlockExplorerLink = ({ address, + tx, children, className, chainId, showExplorerName, - type = "address", ...props }: BlockExplorerLinkProps) => { const { chain } = useAccount() @@ -28,7 +37,9 @@ export const BlockExplorerLink = ({ : chain?.blockExplorers?.default chain?.blockExplorers?.default - if (!address) return null + if (!address && !tx) return null + + const type = tx ? "tx" : "address" return ( {blockExplorer && ( - {showExplorerName ? blockExplorer.name : children ?? address} + {showExplorerName + ? blockExplorer.name + : children ?? address ?? tx ?? ""} )} diff --git a/apps/website/components/blockchain/erc721/erc721-collection-selector.tsx b/apps/website/components/blockchain/erc721/erc721-collection-selector.tsx index a745ff7..b054f35 100644 --- a/apps/website/components/blockchain/erc721/erc721-collection-selector.tsx +++ b/apps/website/components/blockchain/erc721/erc721-collection-selector.tsx @@ -1,12 +1,15 @@ "use client" -import { l2NetworksOptions } from "@/data/networks/options" -import Image from "next/image" import { useMemo, useState } from "react" +import Image from "next/image" +import { l2NetworksOptions } from "@/data/networks/options" import { Address, checksumAddress, isAddress } from "viem" -import { ImageIpfs } from "@/components/blockchain/image-ipfs" -import { LinkComponent } from "@/components/shared/link-component" +import { useOtimismMintableERC721ByLocalTokenQuery } from "@/lib/event-cache/hooks/use-optimism-mintable-erc721-by-local-token" +import { useOtimismMintableERC721ByRemoteTokenQuery } from "@/lib/event-cache/hooks/use-optimism-mintable-erc721-by-remote-token" +import { type Nft } from "@/lib/hooks/web3/use-nfts-for-owner" +import { AppMode } from "@/lib/state/app-mode" +import { cn } from "@/lib/utils" import { Button } from "@/components/ui/button" import { Command, @@ -16,11 +19,8 @@ import { CommandList, } from "@/components/ui/command" import { Dialog, DialogContent } from "@/components/ui/dialog" -import { useOtimismMintableERC721ByLocalTokenQuery } from "@/lib/event-cache/hooks/use-optimism-mintable-erc721-by-local-token" -import { useOtimismMintableERC721ByRemoteTokenQuery } from "@/lib/event-cache/hooks/use-optimism-mintable-erc721-by-remote-token" -import { type Nft } from "@/lib/hooks/web3/use-nfts-for-owner" -import { AppMode } from "@/lib/state/app-mode" -import { cn } from "@/lib/utils" +import { ImageIpfs } from "@/components/blockchain/image-ipfs" +import { LinkComponent } from "@/components/shared/link-component" import { Token, TokenList } from "./types" @@ -320,128 +320,128 @@ export function Erc721CollectionSelector({ })} {chainType === "L1" ? getOtimismMintableERC721ByRemoteTokenQuery.data && ( -
- {getOtimismMintableERC721ByRemoteTokenQuery.data.optimismMintableERC721s.items.map( - (item) => ( - { - handleSelect(item.remoteToken as Address) - setSelectedUnlistedToken( - item.remoteToken as Address - ) - setDestinationNetwork?.(item.chainId.toString()) - setRemoteToken?.(item.localToken as Address) - setTokenMetadata?.({ - logoURI: "/logo.svg", - name: - item.localName ?? - item.remoteName ?? - undefined, - }) - }} - > - -
-
-

- {item.remoteName ?? item.localName} -

-

- L2: {item.localToken} -

-
-
-
- chain logo +
+ {getOtimismMintableERC721ByRemoteTokenQuery.data.optimismMintableERC721s.items.map( + (item) => ( + { + handleSelect(item.remoteToken as Address) + setSelectedUnlistedToken( + item.remoteToken as Address + ) + setDestinationNetwork?.(item.chainId.toString()) + setRemoteToken?.(item.localToken as Address) + setTokenMetadata?.({ + logoURI: "/logo.svg", + name: + item.localName ?? + item.remoteName ?? + undefined, + }) + }} + > + +
+
+

+ {item.remoteName ?? item.localName} +

+

+ L2: {item.localToken} +

+
+
+
+ chain logo +
+

+ Unlisted +

-

- Unlisted -

-
- - ) - )} -
- ) + + ) + )} +
+ ) : getOtimismMintableERC721ByLocalTokenQuery.data && ( -
- {getOtimismMintableERC721ByLocalTokenQuery.data.optimismMintableERC721s.items.map( - (item) => ( - { - handleSelect(item.localToken as Address) - setSelectedUnlistedToken( - item.localToken as Address - ) - setRemoteToken?.(item.remoteToken as Address) - setTokenMetadata?.({ - logoURI: "/logo.svg", - name: - item.localName ?? - item.remoteName ?? - undefined, - }) - }} - > - -
-
-

- {item.remoteName ?? item.localName} -

-

- {item.localToken} -

-
-
-
- chain logo +
+ {getOtimismMintableERC721ByLocalTokenQuery.data.optimismMintableERC721s.items.map( + (item) => ( + { + handleSelect(item.localToken as Address) + setSelectedUnlistedToken( + item.localToken as Address + ) + setRemoteToken?.(item.remoteToken as Address) + setTokenMetadata?.({ + logoURI: "/logo.svg", + name: + item.localName ?? + item.remoteName ?? + undefined, + }) + }} + > + +
+
+

+ {item.remoteName ?? item.localName} +

+

+ {item.localToken} +

+
+
+
+ chain logo +
+

+ Unlisted +

-

- Unlisted -

-
- - ) - )} -
- )} + + ) + )} +
+ )}
diff --git a/apps/website/components/forms/form-L1-to-L2-bridge.tsx b/apps/website/components/forms/form-L1-to-L2-bridge.tsx index 3bb0cec..eec87a0 100644 --- a/apps/website/components/forms/form-L1-to-L2-bridge.tsx +++ b/apps/website/components/forms/form-L1-to-L2-bridge.tsx @@ -1,9 +1,9 @@ "use client" +import { useEffect, useMemo, useState, type HTMLAttributes } from "react" +import Image from "next/image" import { l1Erc721BridgeAbi } from "@/data/abis" import { l1NetworkOptions, l2NetworksOptions } from "@/data/networks/options" -import Image from "next/image" -import { useEffect, useMemo, useState, type HTMLAttributes } from "react" import { type Address, type BaseError } from "viem" import { useAccount, @@ -12,15 +12,6 @@ import { useWriteContract, } from "wagmi" -import { BlockExplorerLink } from "@/components/blockchain/block-explorer-link" -import { ConnectButton } from "@/components/blockchain/connect-button" -import { ContractWriteButton } from "@/components/blockchain/contract-write-button" -import { ImageIpfs } from "@/components/blockchain/image-ipfs" -import { SwitchNetworkButton } from "@/components/blockchain/switch-network-button" -import { TransactionStatus } from "@/components/blockchain/transaction-status" -import { Button } from "@/components/ui/button" -import { Label } from "@/components/ui/label" -import { Skeleton } from "@/components/ui/skeleton" import { useReadErc721GetApproved, useSimulateErc721Approve, @@ -29,6 +20,15 @@ import { import { useNftsForOwner } from "@/lib/hooks/web3/use-nfts-for-owner" import { type AppMode } from "@/lib/state/app-mode" import { cn } from "@/lib/utils" +import { Button } from "@/components/ui/button" +import { Label } from "@/components/ui/label" +import { Skeleton } from "@/components/ui/skeleton" +import { BlockExplorerLink } from "@/components/blockchain/block-explorer-link" +import { ConnectButton } from "@/components/blockchain/connect-button" +import { ContractWriteButton } from "@/components/blockchain/contract-write-button" +import { ImageIpfs } from "@/components/blockchain/image-ipfs" +import { SwitchNetworkButton } from "@/components/blockchain/switch-network-button" +import { TransactionStatus } from "@/components/blockchain/transaction-status" import { queryClient } from "../providers/root-provider" @@ -58,7 +58,6 @@ export function FormL1ToL2Bridge({ ...props }: FormL1ToL2BridgeProps) { const [imageLoaded, setImageLoaded] = useState(false) - console.log("localToken", localToken, remoteToken) const l1Chain = l1NetworkOptions[appMode] const l2Chains = l2NetworksOptions[appMode] diff --git a/apps/website/components/forms/form-create-l2-erc721.tsx b/apps/website/components/forms/form-create-l2-erc721.tsx index 3478734..bfd7bba 100644 --- a/apps/website/components/forms/form-create-l2-erc721.tsx +++ b/apps/website/components/forms/form-create-l2-erc721.tsx @@ -1,10 +1,10 @@ "use client" +import { useEffect, useState, type HTMLAttributes } from "react" +import Image from "next/image" import { optimismMintableErc721FactoryAbi } from "@/data/abis" import { l1NetworkOptions, l2NetworksOptions } from "@/data/networks/options" import { zodResolver } from "@hookform/resolvers/zod" -import Image from "next/image" -import { useEffect, useState, type HTMLAttributes } from "react" import { SubmitHandler, useForm } from "react-hook-form" import { useDebounce } from "usehooks-ts" import { @@ -21,10 +21,15 @@ import { } from "wagmi" import { z } from "zod" -import { ConnectButton } from "@/components/blockchain/connect-button" -import { ContractWriteButton } from "@/components/blockchain/contract-write-button" -import { SwitchNetworkButton } from "@/components/blockchain/switch-network-button" -import { TransactionStatus } from "@/components/blockchain/transaction-status" +import { useOtimismMintableERC721ByRemoteTokenQuery } from "@/lib/event-cache/hooks/use-optimism-mintable-erc721-by-remote-token" +import { + useReadErc721Name, + useReadErc721Symbol, + useSimulateOptimismMintableErc721FactoryCreateOptimismMintableErc721, + useWriteOptimismMintableErc721FactoryCreateOptimismMintableErc721, +} from "@/lib/generated/blockchain" +import { useAppMode } from "@/lib/state/app-mode" +import { cn } from "@/lib/utils" import { Form, FormControl, @@ -41,15 +46,10 @@ import { SelectTrigger, SelectValue, } from "@/components/ui/select" -import { useOtimismMintableERC721ByRemoteTokenQuery } from "@/lib/event-cache/hooks/use-optimism-mintable-erc721-by-remote-token" -import { - useReadErc721Name, - useReadErc721Symbol, - useSimulateOptimismMintableErc721FactoryCreateOptimismMintableErc721, - useWriteOptimismMintableErc721FactoryCreateOptimismMintableErc721, -} from "@/lib/generated/blockchain" -import { useAppMode } from "@/lib/state/app-mode" -import { cn } from "@/lib/utils" +import { ConnectButton } from "@/components/blockchain/connect-button" +import { ContractWriteButton } from "@/components/blockchain/contract-write-button" +import { SwitchNetworkButton } from "@/components/blockchain/switch-network-button" +import { TransactionStatus } from "@/components/blockchain/transaction-status" import { BlockExplorerLink } from "../blockchain/block-explorer-link" import { LinkComponent } from "../shared/link-component" @@ -92,22 +92,22 @@ export const FormCreateL2ERC721 = ({ name: keyof FormData type: string }[] = [ - { - label: `L1 NFT Address ${l1Chain.name}`, - name: "remoteToken", - type: "text", - }, - { - label: "Name", - name: "name", - type: "text", - }, - { - label: "Symbol", - name: "symbol", - type: "text", - }, - ] + { + label: `L1 NFT Address ${l1Chain.name}`, + name: "remoteToken", + type: "text", + }, + { + label: "Name", + name: "name", + type: "text", + }, + { + label: "Symbol", + name: "symbol", + type: "text", + }, + ] const getOtimismMintableERC721ByRemoteTokenQuery = useOtimismMintableERC721ByRemoteTokenQuery({ diff --git a/apps/website/components/layout/footer.tsx b/apps/website/components/layout/footer.tsx index 479c706..4609d0a 100644 --- a/apps/website/components/layout/footer.tsx +++ b/apps/website/components/layout/footer.tsx @@ -33,6 +33,10 @@ const menuItems = [ title: "Bridged Collections", href: "/bridged-collections", }, + { + title: "Bridged NFTs", + href: "/bridged-nfts", + }, { title: "Testing Tools", href: "/mint", @@ -74,7 +78,7 @@ export function Footer({ className, ...props }: HTMLAttributes) {
{menuItems.map(({ href, title }) => ( - + {title} ))} diff --git a/apps/website/components/ui/navigation-menu.tsx b/apps/website/components/ui/navigation-menu.tsx index 2f6f52e..7a3d9ac 100644 --- a/apps/website/components/ui/navigation-menu.tsx +++ b/apps/website/components/ui/navigation-menu.tsx @@ -41,7 +41,7 @@ NavigationMenuList.displayName = NavigationMenuPrimitive.List.displayName const NavigationMenuItem = NavigationMenuPrimitive.Item const navigationMenuTriggerStyle = cva( - "group inline-flex h-9 w-max items-center justify-center rounded-md bg-transparent px-4 py-2 text-base font-medium transition-colors hover:bg-accent hover:text-accent-foreground focus:bg-accent focus:text-accent-foreground focus:outline-none disabled:pointer-events-none disabled:opacity-50 data-[active]:bg-background data-[state=open]:bg-backgroud" + "group inline-flex h-9 w-max items-center justify-center rounded-md bg-transparent px-4 py-2 text-base font-medium transition-colors hover:bg-accent hover:text-accent-foreground focus:bg-accent focus:text-accent-foreground focus:outline-none disabled:pointer-events-none disabled:opacity-50 data-[active]:bg-primary data-[state=open]:bg-primary data-[active]:text-secondary data-[state=open]:text-secondary" ) const NavigationMenuTrigger = React.forwardRef< @@ -116,13 +116,13 @@ NavigationMenuIndicator.displayName = NavigationMenuPrimitive.Indicator.displayName export { - navigationMenuTriggerStyle, NavigationMenu, - NavigationMenuList, - NavigationMenuItem, NavigationMenuContent, - NavigationMenuTrigger, - NavigationMenuLink, NavigationMenuIndicator, + NavigationMenuItem, + NavigationMenuLink, + NavigationMenuList, + NavigationMenuTrigger, NavigationMenuViewport, + navigationMenuTriggerStyle, } diff --git a/apps/website/lib/event-cache/gql/fragment-masking.ts b/apps/website/lib/event-cache/gql/fragment-masking.ts index 2ba06f1..36e56ac 100644 --- a/apps/website/lib/event-cache/gql/fragment-masking.ts +++ b/apps/website/lib/event-cache/gql/fragment-masking.ts @@ -1,66 +1,86 @@ -import { ResultOf, DocumentTypeDecoration, TypedDocumentNode } from '@graphql-typed-document-node/core'; -import { FragmentDefinitionNode } from 'graphql'; -import { Incremental } from './graphql'; +import { + DocumentTypeDecoration, + ResultOf, + TypedDocumentNode, +} from "@graphql-typed-document-node/core" +import { FragmentDefinitionNode } from "graphql" +import { Incremental } from "./graphql" -export type FragmentType> = TDocumentType extends DocumentTypeDecoration< - infer TType, - any -> - ? [TType] extends [{ ' $fragmentName'?: infer TKey }] +export type FragmentType< + TDocumentType extends DocumentTypeDecoration +> = TDocumentType extends DocumentTypeDecoration + ? [TType] extends [{ " $fragmentName"?: infer TKey }] ? TKey extends string - ? { ' $fragmentRefs'?: { [key in TKey]: TType } } + ? { " $fragmentRefs"?: { [key in TKey]: TType } } : never : never - : never; + : never // return non-nullable if `fragmentType` is non-nullable export function useFragment( _documentNode: DocumentTypeDecoration, fragmentType: FragmentType> -): TType; +): TType // return nullable if `fragmentType` is nullable export function useFragment( _documentNode: DocumentTypeDecoration, - fragmentType: FragmentType> | null | undefined -): TType | null | undefined; + fragmentType: + | FragmentType> + | null + | undefined +): TType | null | undefined // return array of non-nullable if `fragmentType` is array of non-nullable export function useFragment( _documentNode: DocumentTypeDecoration, fragmentType: ReadonlyArray>> -): ReadonlyArray; +): ReadonlyArray // return array of nullable if `fragmentType` is array of nullable export function useFragment( _documentNode: DocumentTypeDecoration, - fragmentType: ReadonlyArray>> | null | undefined -): ReadonlyArray | null | undefined; + fragmentType: + | ReadonlyArray>> + | null + | undefined +): ReadonlyArray | null | undefined export function useFragment( _documentNode: DocumentTypeDecoration, - fragmentType: FragmentType> | ReadonlyArray>> | null | undefined + fragmentType: + | FragmentType> + | ReadonlyArray>> + | null + | undefined ): TType | ReadonlyArray | null | undefined { - return fragmentType as any; + return fragmentType as any } - export function makeFragmentData< F extends DocumentTypeDecoration, FT extends ResultOf >(data: FT, _fragment: F): FragmentType { - return data as FragmentType; + return data as FragmentType } export function isFragmentReady( queryNode: DocumentTypeDecoration, fragmentNode: TypedDocumentNode, - data: FragmentType, any>> | null | undefined + data: + | FragmentType, any>> + | null + | undefined ): data is FragmentType { - const deferredFields = (queryNode as { __meta__?: { deferredFields: Record } }).__meta__ - ?.deferredFields; + const deferredFields = ( + queryNode as { + __meta__?: { deferredFields: Record } + } + ).__meta__?.deferredFields - if (!deferredFields) return true; + if (!deferredFields) return true - const fragDef = fragmentNode.definitions[0] as FragmentDefinitionNode | undefined; - const fragName = fragDef?.name?.value; + 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); + 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 index 708802f..49fa8b8 100644 --- a/apps/website/lib/event-cache/gql/gql.ts +++ b/apps/website/lib/event-cache/gql/gql.ts @@ -1,6 +1,7 @@ /* eslint-disable */ -import * as types from './graphql'; -import { TypedDocumentNode as DocumentNode } from '@graphql-typed-document-node/core'; +import { TypedDocumentNode as DocumentNode } from "@graphql-typed-document-node/core" + +import * as types from "./graphql" /** * Map of all GraphQL operations in the project. @@ -13,10 +14,15 @@ import { TypedDocumentNode as DocumentNode } from '@graphql-typed-document-node/ * 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 getOtimismMintableERC721ByLocalTokenQuery(\n $localToken: String!\n $chainId: Int\n ) {\n optimismMintableERC721s(\n where: { localToken: $localToken, 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.GetOtimismMintableErc721ByLocalTokenQueryDocument, - "\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, -}; + "\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 getBridgedERC721Query(\n $owner: String\n $l2chainId: Int\n $states: [BridgedErc721State]\n ) {\n bridgedErc721s(\n where: { owner: $owner, l2ChainId: $l2chainId, state_in: $states }\n orderBy: "timestamp"\n orderDirection: "desc"\n ) {\n items {\n id\n state\n l1ChainId\n l2ChainId\n l1Token\n l2Token\n tokenId\n owner\n txHash\n txChainId\n timestamp\n }\n }\n }\n': + types.GetBridgedErc721QueryDocument, + "\n query getOtimismMintableERC721ByLocalTokenQuery(\n $localToken: String!\n $chainId: Int\n ) {\n optimismMintableERC721s(\n where: { localToken: $localToken, 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.GetOtimismMintableErc721ByLocalTokenQueryDocument, + "\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. @@ -30,23 +36,36 @@ const documents = { * The query argument is unknown! * Please regenerate the types. */ -export function graphql(source: string): unknown; +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"]; +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 getBridgedERC721Query(\n $owner: String\n $l2chainId: Int\n $states: [BridgedErc721State]\n ) {\n bridgedErc721s(\n where: { owner: $owner, l2ChainId: $l2chainId, state_in: $states }\n orderBy: "timestamp"\n orderDirection: "desc"\n ) {\n items {\n id\n state\n l1ChainId\n l2ChainId\n l1Token\n l2Token\n tokenId\n owner\n txHash\n txChainId\n timestamp\n }\n }\n }\n' +): (typeof documents)['\n query getBridgedERC721Query(\n $owner: String\n $l2chainId: Int\n $states: [BridgedErc721State]\n ) {\n bridgedErc721s(\n where: { owner: $owner, l2ChainId: $l2chainId, state_in: $states }\n orderBy: "timestamp"\n orderDirection: "desc"\n ) {\n items {\n id\n state\n l1ChainId\n l2ChainId\n l1Token\n l2Token\n tokenId\n owner\n txHash\n txChainId\n timestamp\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 getOtimismMintableERC721ByLocalTokenQuery(\n $localToken: String!\n $chainId: Int\n ) {\n optimismMintableERC721s(\n where: { localToken: $localToken, 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 getOtimismMintableERC721ByLocalTokenQuery(\n $localToken: String!\n $chainId: Int\n ) {\n optimismMintableERC721s(\n where: { localToken: $localToken, 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: "\n query getOtimismMintableERC721ByLocalTokenQuery(\n $localToken: String!\n $chainId: Int\n ) {\n optimismMintableERC721s(\n where: { localToken: $localToken, 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 getOtimismMintableERC721ByLocalTokenQuery(\n $localToken: String!\n $chainId: Int\n ) {\n optimismMintableERC721s(\n where: { localToken: $localToken, 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"] /** * 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: "\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] ?? {}; + return (documents as any)[source] ?? {} } -export type DocumentType> = TDocumentNode extends DocumentNode< infer TType, any> ? TType : never; \ No newline at end of file +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 index ad7b2cd..b9ac395 100644 --- a/apps/website/lib/event-cache/gql/graphql.ts +++ b/apps/website/lib/event-cache/gql/graphql.ts @@ -1,326 +1,933 @@ /* 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 = { [_ in K]?: never }; -export type Incremental = T | { [P in keyof T]?: P extends ' $fragmentName' | '__typename' ? T[P] : never }; +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; } -}; + 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 BridgedErc721 = { - __typename?: 'BridgedErc721'; - id: Scalars['String']['output']; - l1ChainId: Scalars['Int']['output']; - l1Token: Scalars['String']['output']; - l2ChainId: Scalars['Int']['output']; - l2Token: Scalars['String']['output']; - owner: Scalars['String']['output']; - state: BridgedErc721State; - timestamp: Scalars['BigInt']['output']; - tokenId: Scalars['String']['output']; -}; + __typename?: "BridgedErc721" + id: Scalars["String"]["output"] + l1ChainId: Scalars["Int"]["output"] + l1Token: Scalars["String"]["output"] + l2ChainId: Scalars["Int"]["output"] + l2Token: Scalars["String"]["output"] + owner: Scalars["String"]["output"] + state: BridgedErc721State + timestamp: Scalars["BigInt"]["output"] + tokenId: Scalars["String"]["output"] + txChainId: Scalars["Int"]["output"] + txHash: Scalars["String"]["output"] +} export type BridgedErc721Filter = { - AND?: InputMaybe>>; - OR?: 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; - l1ChainId?: InputMaybe; - l1ChainId_gt?: InputMaybe; - l1ChainId_gte?: InputMaybe; - l1ChainId_in?: InputMaybe>>; - l1ChainId_lt?: InputMaybe; - l1ChainId_lte?: InputMaybe; - l1ChainId_not?: InputMaybe; - l1ChainId_not_in?: InputMaybe>>; - l1Token?: InputMaybe; - l1Token_contains?: InputMaybe; - l1Token_ends_with?: InputMaybe; - l1Token_in?: InputMaybe>>; - l1Token_not?: InputMaybe; - l1Token_not_contains?: InputMaybe; - l1Token_not_ends_with?: InputMaybe; - l1Token_not_in?: InputMaybe>>; - l1Token_not_starts_with?: InputMaybe; - l1Token_starts_with?: InputMaybe; - l2ChainId?: InputMaybe; - l2ChainId_gt?: InputMaybe; - l2ChainId_gte?: InputMaybe; - l2ChainId_in?: InputMaybe>>; - l2ChainId_lt?: InputMaybe; - l2ChainId_lte?: InputMaybe; - l2ChainId_not?: InputMaybe; - l2ChainId_not_in?: InputMaybe>>; - l2Token?: InputMaybe; - l2Token_contains?: InputMaybe; - l2Token_ends_with?: InputMaybe; - l2Token_in?: InputMaybe>>; - l2Token_not?: InputMaybe; - l2Token_not_contains?: InputMaybe; - l2Token_not_ends_with?: InputMaybe; - l2Token_not_in?: InputMaybe>>; - l2Token_not_starts_with?: InputMaybe; - l2Token_starts_with?: InputMaybe; - owner?: InputMaybe; - owner_contains?: InputMaybe; - owner_ends_with?: InputMaybe; - owner_in?: InputMaybe>>; - owner_not?: InputMaybe; - owner_not_contains?: InputMaybe; - owner_not_ends_with?: InputMaybe; - owner_not_in?: InputMaybe>>; - owner_not_starts_with?: InputMaybe; - owner_starts_with?: InputMaybe; - state?: InputMaybe; - state_in?: InputMaybe>>; - state_not?: InputMaybe; - state_not_in?: InputMaybe>>; - timestamp?: InputMaybe; - timestamp_gt?: InputMaybe; - timestamp_gte?: InputMaybe; - timestamp_in?: InputMaybe>>; - timestamp_lt?: InputMaybe; - timestamp_lte?: InputMaybe; - timestamp_not?: InputMaybe; - timestamp_not_in?: InputMaybe>>; - tokenId?: InputMaybe; - tokenId_contains?: InputMaybe; - tokenId_ends_with?: InputMaybe; - tokenId_in?: InputMaybe>>; - tokenId_not?: InputMaybe; - tokenId_not_contains?: InputMaybe; - tokenId_not_ends_with?: InputMaybe; - tokenId_not_in?: InputMaybe>>; - tokenId_not_starts_with?: InputMaybe; - tokenId_starts_with?: InputMaybe; -}; + AND?: InputMaybe>> + OR?: 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 + l1ChainId?: InputMaybe + l1ChainId_gt?: InputMaybe + l1ChainId_gte?: InputMaybe + l1ChainId_in?: InputMaybe>> + l1ChainId_lt?: InputMaybe + l1ChainId_lte?: InputMaybe + l1ChainId_not?: InputMaybe + l1ChainId_not_in?: InputMaybe>> + l1Token?: InputMaybe + l1Token_contains?: InputMaybe + l1Token_ends_with?: InputMaybe + l1Token_in?: InputMaybe>> + l1Token_not?: InputMaybe + l1Token_not_contains?: InputMaybe + l1Token_not_ends_with?: InputMaybe + l1Token_not_in?: InputMaybe>> + l1Token_not_starts_with?: InputMaybe + l1Token_starts_with?: InputMaybe + l2ChainId?: InputMaybe + l2ChainId_gt?: InputMaybe + l2ChainId_gte?: InputMaybe + l2ChainId_in?: InputMaybe>> + l2ChainId_lt?: InputMaybe + l2ChainId_lte?: InputMaybe + l2ChainId_not?: InputMaybe + l2ChainId_not_in?: InputMaybe>> + l2Token?: InputMaybe + l2Token_contains?: InputMaybe + l2Token_ends_with?: InputMaybe + l2Token_in?: InputMaybe>> + l2Token_not?: InputMaybe + l2Token_not_contains?: InputMaybe + l2Token_not_ends_with?: InputMaybe + l2Token_not_in?: InputMaybe>> + l2Token_not_starts_with?: InputMaybe + l2Token_starts_with?: InputMaybe + owner?: InputMaybe + owner_contains?: InputMaybe + owner_ends_with?: InputMaybe + owner_in?: InputMaybe>> + owner_not?: InputMaybe + owner_not_contains?: InputMaybe + owner_not_ends_with?: InputMaybe + owner_not_in?: InputMaybe>> + owner_not_starts_with?: InputMaybe + owner_starts_with?: InputMaybe + state?: InputMaybe + state_in?: InputMaybe>> + state_not?: InputMaybe + state_not_in?: InputMaybe>> + timestamp?: InputMaybe + timestamp_gt?: InputMaybe + timestamp_gte?: InputMaybe + timestamp_in?: InputMaybe>> + timestamp_lt?: InputMaybe + timestamp_lte?: InputMaybe + timestamp_not?: InputMaybe + timestamp_not_in?: InputMaybe>> + tokenId?: InputMaybe + tokenId_contains?: InputMaybe + tokenId_ends_with?: InputMaybe + tokenId_in?: InputMaybe>> + tokenId_not?: InputMaybe + tokenId_not_contains?: InputMaybe + tokenId_not_ends_with?: InputMaybe + tokenId_not_in?: InputMaybe>> + tokenId_not_starts_with?: InputMaybe + tokenId_starts_with?: InputMaybe + txChainId?: InputMaybe + txChainId_gt?: InputMaybe + txChainId_gte?: InputMaybe + txChainId_in?: InputMaybe>> + txChainId_lt?: InputMaybe + txChainId_lte?: InputMaybe + txChainId_not?: InputMaybe + txChainId_not_in?: InputMaybe>> + txHash?: InputMaybe + txHash_contains?: InputMaybe + txHash_ends_with?: InputMaybe + txHash_in?: InputMaybe>> + txHash_not?: InputMaybe + txHash_not_contains?: InputMaybe + txHash_not_ends_with?: InputMaybe + txHash_not_in?: InputMaybe>> + txHash_not_starts_with?: InputMaybe + txHash_starts_with?: InputMaybe +} export type BridgedErc721Page = { - __typename?: 'BridgedErc721Page'; - items: Array; - pageInfo: PageInfo; -}; + __typename?: "BridgedErc721Page" + items: Array + pageInfo: PageInfo +} export enum BridgedErc721State { - L1 = 'L1', - L2 = 'L2', - PendingToL1 = 'PENDING_TO_L1', - PendingToL2 = 'PENDING_TO_L2' + L1 = "L1", + L2 = "L2", + PendingToL1 = "PENDING_TO_L1", + PendingToL2 = "PENDING_TO_L2", } 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']; -}; + __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>>; - 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; -}; + 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; -}; + __typename?: "OptimismMintableERC721Page" + items: Array + pageInfo: PageInfo +} export type PageInfo = { - __typename?: 'PageInfo'; - endCursor?: Maybe; - hasNextPage: Scalars['Boolean']['output']; - hasPreviousPage: Scalars['Boolean']['output']; - startCursor?: Maybe; -}; + __typename?: "PageInfo" + endCursor?: Maybe + hasNextPage: Scalars["Boolean"]["output"] + hasPreviousPage: Scalars["Boolean"]["output"] + startCursor?: Maybe +} export type Query = { - __typename?: 'Query'; - bridgedErc721?: Maybe; - bridgedErc721s: BridgedErc721Page; - optimismMintableERC721?: Maybe; - optimismMintableERC721s: OptimismMintableErc721Page; -}; - + __typename?: "Query" + bridgedErc721?: Maybe + bridgedErc721s: BridgedErc721Page + optimismMintableERC721?: Maybe + optimismMintableERC721s: OptimismMintableErc721Page +} export type QueryBridgedErc721Args = { - id: Scalars['String']['input']; - timestamp?: InputMaybe; -}; - + id: Scalars["String"]["input"] + timestamp?: InputMaybe +} export type QueryBridgedErc721sArgs = { - after?: InputMaybe; - before?: InputMaybe; - limit?: InputMaybe; - orderBy?: InputMaybe; - orderDirection?: InputMaybe; - timestamp?: InputMaybe; - where?: InputMaybe; -}; - + after?: InputMaybe + before?: InputMaybe + limit?: InputMaybe + orderBy?: InputMaybe + orderDirection?: InputMaybe + timestamp?: InputMaybe + where?: InputMaybe +} export type QueryOptimismMintableErc721Args = { - id: Scalars['String']['input']; - timestamp?: InputMaybe; -}; - + id: Scalars["String"]["input"] + timestamp?: InputMaybe +} export type QueryOptimismMintableErc721sArgs = { - after?: InputMaybe; - before?: InputMaybe; - limit?: InputMaybe; - orderBy?: InputMaybe; - orderDirection?: InputMaybe; - timestamp?: InputMaybe; - where?: InputMaybe; -}; + after?: InputMaybe + before?: InputMaybe + limit?: InputMaybe + orderBy?: InputMaybe + orderDirection?: InputMaybe + timestamp?: InputMaybe + where?: InputMaybe +} export type AllOptimismMintableErc721QueryQueryVariables = Exact<{ - limit?: InputMaybe; -}>; + 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 GetBridgedErc721QueryQueryVariables = Exact<{ + owner?: InputMaybe + l2chainId?: InputMaybe + states?: InputMaybe< + Array> | 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 GetBridgedErc721QueryQuery = { + __typename?: "Query" + bridgedErc721s: { + __typename?: "BridgedErc721Page" + items: Array<{ + __typename?: "BridgedErc721" + id: string + state: BridgedErc721State + l1ChainId: number + l2ChainId: number + l1Token: string + l2Token: string + tokenId: string + owner: string + txHash: string + txChainId: number + timestamp: any + }> + } +} export type GetOtimismMintableErc721ByLocalTokenQueryQueryVariables = Exact<{ - localToken: Scalars['String']['input']; - chainId?: InputMaybe; -}>; + localToken: Scalars["String"]["input"] + chainId?: InputMaybe +}> - -export type GetOtimismMintableErc721ByLocalTokenQueryQuery = { __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 GetOtimismMintableErc721ByLocalTokenQueryQuery = { + __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?: InputMaybe; -}>; - - -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 }> } }; + remoteToken: Scalars["String"]["input"] + chainId?: InputMaybe +}> +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; -export const GetOtimismMintableErc721ByLocalTokenQueryDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"getOtimismMintableERC721ByLocalTokenQuery"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"localToken"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}}},{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"chainId"}},"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":"localToken"},"value":{"kind":"Variable","name":{"kind":"Name","value":"localToken"}}},{"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; -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":"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; \ No newline at end of file +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 GetBridgedErc721QueryDocument = { + kind: "Document", + definitions: [ + { + kind: "OperationDefinition", + operation: "query", + name: { kind: "Name", value: "getBridgedERC721Query" }, + variableDefinitions: [ + { + kind: "VariableDefinition", + variable: { + kind: "Variable", + name: { kind: "Name", value: "owner" }, + }, + type: { kind: "NamedType", name: { kind: "Name", value: "String" } }, + }, + { + kind: "VariableDefinition", + variable: { + kind: "Variable", + name: { kind: "Name", value: "l2chainId" }, + }, + type: { kind: "NamedType", name: { kind: "Name", value: "Int" } }, + }, + { + kind: "VariableDefinition", + variable: { + kind: "Variable", + name: { kind: "Name", value: "states" }, + }, + type: { + kind: "ListType", + type: { + kind: "NamedType", + name: { kind: "Name", value: "BridgedErc721State" }, + }, + }, + }, + ], + selectionSet: { + kind: "SelectionSet", + selections: [ + { + kind: "Field", + name: { kind: "Name", value: "bridgedErc721s" }, + arguments: [ + { + kind: "Argument", + name: { kind: "Name", value: "where" }, + value: { + kind: "ObjectValue", + fields: [ + { + kind: "ObjectField", + name: { kind: "Name", value: "owner" }, + value: { + kind: "Variable", + name: { kind: "Name", value: "owner" }, + }, + }, + { + kind: "ObjectField", + name: { kind: "Name", value: "l2ChainId" }, + value: { + kind: "Variable", + name: { kind: "Name", value: "l2chainId" }, + }, + }, + { + kind: "ObjectField", + name: { kind: "Name", value: "state_in" }, + value: { + kind: "Variable", + name: { kind: "Name", value: "states" }, + }, + }, + ], + }, + }, + { + kind: "Argument", + name: { kind: "Name", value: "orderBy" }, + value: { + kind: "StringValue", + value: "timestamp", + block: false, + }, + }, + { + kind: "Argument", + name: { kind: "Name", value: "orderDirection" }, + value: { kind: "StringValue", value: "desc", block: false }, + }, + ], + 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: "state" } }, + { + kind: "Field", + name: { kind: "Name", value: "l1ChainId" }, + }, + { + kind: "Field", + name: { kind: "Name", value: "l2ChainId" }, + }, + { + kind: "Field", + name: { kind: "Name", value: "l1Token" }, + }, + { + kind: "Field", + name: { kind: "Name", value: "l2Token" }, + }, + { + kind: "Field", + name: { kind: "Name", value: "tokenId" }, + }, + { kind: "Field", name: { kind: "Name", value: "owner" } }, + { + kind: "Field", + name: { kind: "Name", value: "txHash" }, + }, + { + kind: "Field", + name: { kind: "Name", value: "txChainId" }, + }, + { + kind: "Field", + name: { kind: "Name", value: "timestamp" }, + }, + ], + }, + }, + ], + }, + }, + ], + }, + }, + ], +} as unknown as DocumentNode< + GetBridgedErc721QueryQuery, + GetBridgedErc721QueryQueryVariables +> +export const GetOtimismMintableErc721ByLocalTokenQueryDocument = { + kind: "Document", + definitions: [ + { + kind: "OperationDefinition", + operation: "query", + name: { + kind: "Name", + value: "getOtimismMintableERC721ByLocalTokenQuery", + }, + variableDefinitions: [ + { + kind: "VariableDefinition", + variable: { + kind: "Variable", + name: { kind: "Name", value: "localToken" }, + }, + type: { + kind: "NonNullType", + type: { + kind: "NamedType", + name: { kind: "Name", value: "String" }, + }, + }, + }, + { + kind: "VariableDefinition", + variable: { + kind: "Variable", + name: { kind: "Name", value: "chainId" }, + }, + 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: "localToken" }, + value: { + kind: "Variable", + name: { kind: "Name", value: "localToken" }, + }, + }, + { + 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< + GetOtimismMintableErc721ByLocalTokenQueryQuery, + GetOtimismMintableErc721ByLocalTokenQueryQueryVariables +> +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: "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/lib/event-cache/gql/index.ts b/apps/website/lib/event-cache/gql/index.ts index f515991..f2b0e1a 100644 --- a/apps/website/lib/event-cache/gql/index.ts +++ b/apps/website/lib/event-cache/gql/index.ts @@ -1,2 +1,2 @@ -export * from "./fragment-masking"; -export * from "./gql"; \ No newline at end of file +export * from "./fragment-masking" +export * from "./gql" diff --git a/apps/website/lib/event-cache/hooks/use-bridged-erc721.tsx b/apps/website/lib/event-cache/hooks/use-bridged-erc721.tsx index 2c77dad..71ca45c 100644 --- a/apps/website/lib/event-cache/hooks/use-bridged-erc721.tsx +++ b/apps/website/lib/event-cache/hooks/use-bridged-erc721.tsx @@ -1,46 +1,49 @@ -import { Address } from "viem" - import { graphql } from "../gql" +import { GetBridgedErc721QueryQueryVariables, InputMaybe } from "../gql/graphql" import { useGraphQL } from "../use-graphql" +export { BridgedErc721State } from "../gql/graphql" + const getBridgedERC721ByOwnerQuery = graphql(/* GraphQL */ ` - query getOtimismMintableERC721ByLocalTokenQuery( - $localToken: String! - $chainId: Int + query getBridgedERC721Query( + $owner: String + $l2chainId: Int + $states: [BridgedErc721State] ) { - optimismMintableERC721s( - where: { localToken: $localToken, chainId: $chainId } + bridgedErc721s( + where: { owner: $owner, l2ChainId: $l2chainId, state_in: $states } + orderBy: "timestamp" + orderDirection: "desc" ) { items { id - chainId - blockNumber - localToken - localName - localSymbol - remoteToken - remoteName - remoteSymbol - deployer + state + l1ChainId + l2ChainId + l1Token + l2Token + tokenId + owner + txHash + txChainId + timestamp } } } `) -export function useOtimismMintableERC721ByLocalTokenQuery(params: { - localToken: Address - chainId?: number - query?: { enabled: boolean } +export function useBridgedERC721ByOwner({ + params, + query, +}: { + params: GetBridgedErc721QueryQueryVariables + query?: InputMaybe<{ enabled: boolean }> }) { return useGraphQL( getBridgedERC721ByOwnerQuery, { - queryKey: [ - "getOtimismMintableERC721ByLocalToken", - params.chainId, - params.localToken, - ], - enabled: params.query?.enabled, + queryKey: ["getBridgedERC721ByOwner", params], + enabled: query?.enabled, }, params ) From 0a344962b5672d8856d1b2b8a046e464260faef9 Mon Sep 17 00:00:00 2001 From: Vitor Date: Fri, 5 Apr 2024 12:27:35 -0300 Subject: [PATCH 4/6] fix: build errors --- apps/website/app/(general)/bridged-nfts/[chainId]/page.tsx | 2 +- apps/website/components/blockchain/block-explorer-link.tsx | 2 +- apps/website/components/blockchain/transaction-status.tsx | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/apps/website/app/(general)/bridged-nfts/[chainId]/page.tsx b/apps/website/app/(general)/bridged-nfts/[chainId]/page.tsx index b91c206..8d3ff63 100644 --- a/apps/website/app/(general)/bridged-nfts/[chainId]/page.tsx +++ b/apps/website/app/(general)/bridged-nfts/[chainId]/page.tsx @@ -90,7 +90,7 @@ export default function BridgedCollectionsByChainIdPage({ )} -
+
{!address ? (
diff --git a/apps/website/components/blockchain/block-explorer-link.tsx b/apps/website/components/blockchain/block-explorer-link.tsx index f2c40e5..5355034 100644 --- a/apps/website/components/blockchain/block-explorer-link.tsx +++ b/apps/website/components/blockchain/block-explorer-link.tsx @@ -15,7 +15,7 @@ type BlockExplorerLinkProps = HTMLAttributes & } | { address?: never - tx: Hex + tx: Hex | undefined showExplorerName?: boolean chainId?: number } diff --git a/apps/website/components/blockchain/transaction-status.tsx b/apps/website/components/blockchain/transaction-status.tsx index 734a5bf..f6ac7e0 100644 --- a/apps/website/components/blockchain/transaction-status.tsx +++ b/apps/website/components/blockchain/transaction-status.tsx @@ -30,7 +30,7 @@ export const TransactionStatus = ({ {(isLoadingTx || isSuccess) && ( <> {isLoadingTx ? "Processing..." : "Success!"} - + )}
From 335ce618b6f21b10f7ede6df60ce88230c2ac713 Mon Sep 17 00:00:00 2001 From: Vitor Date: Fri, 5 Apr 2024 14:24:28 -0300 Subject: [PATCH 5/6] feat: add account history to header --- .../[chainId]/page.tsx | 46 ++++++++++++------- .../page.tsx | 2 +- apps/website/components/layout/footer.tsx | 4 -- .../website/components/layout/site-header.tsx | 15 ++++-- .../components/shared/app-mode-selector.tsx | 4 +- 5 files changed, 44 insertions(+), 27 deletions(-) rename apps/website/app/(general)/{bridged-nfts => account-history}/[chainId]/page.tsx (83%) rename apps/website/app/(general)/{bridged-nfts => account-history}/page.tsx (82%) diff --git a/apps/website/app/(general)/bridged-nfts/[chainId]/page.tsx b/apps/website/app/(general)/account-history/[chainId]/page.tsx similarity index 83% rename from apps/website/app/(general)/bridged-nfts/[chainId]/page.tsx rename to apps/website/app/(general)/account-history/[chainId]/page.tsx index 8d3ff63..023b914 100644 --- a/apps/website/app/(general)/bridged-nfts/[chainId]/page.tsx +++ b/apps/website/app/(general)/account-history/[chainId]/page.tsx @@ -62,19 +62,22 @@ export default function BridgedCollectionsByChainIdPage({ // If AppMode changes, redirect to the first chain in the new mode if (!l2NetworksOptions[appMode][Number(chainId)]) { - router.push(`/bridged-nfts/${newChainId}`) + router.push(`/account-history/${newChainId}`) } }, [appMode]) return (
+

+ Your Bridged NFTs +

{Object.values(l2NetworksOptions[appMode]).map( ({ name, chainId: optionChainId }) => ( @@ -122,15 +125,17 @@ export default function BridgedCollectionsByChainIdPage({ className="flex w-full flex-col items-center gap-x-0 gap-y-5 p-6 sm:flex-row sm:gap-x-4" key={bridgedErc721.id} > - {`logo`} -
+
+ {`logo`} +
+

{tokenMetadata?.name || "Unknown"} @@ -139,13 +144,20 @@ export default function BridgedCollectionsByChainIdPage({ # {bridgedErc721.tokenId}

- State:{" "} + Status:{" "} {bridgedErc721.state === BridgedErc721State.L2 - ? "L2" + ? l2NetworksOptions[appMode][bridgedErc721.l2ChainId] + ?.name || "L1" : bridgedErc721.state === BridgedErc721State.PendingToL1 - ? "Pending bridge to L1" - : "Pending bridge to L2"} + ? `Pending bridge to ${ + l1NetworkOptions[appMode]?.name || "L2" + }` + : `Pending bridge to ${ + l2NetworksOptions[appMode][ + bridgedErc721.l2ChainId + ]?.name || "L2" + }`}

@@ -164,7 +176,7 @@ export default function BridgedCollectionsByChainIdPage({
-
+
{l1Chain.name}
-
+
{l2Chain?.name}
{ router.push( - `/bridged-nfts/${Object.values(l2NetworksOptions[appMode])[0].chainId}` + `/account-history/${Object.values(l2NetworksOptions[appMode])[0].chainId}` ) }, []) diff --git a/apps/website/components/layout/footer.tsx b/apps/website/components/layout/footer.tsx index 4609d0a..f453ce0 100644 --- a/apps/website/components/layout/footer.tsx +++ b/apps/website/components/layout/footer.tsx @@ -33,10 +33,6 @@ const menuItems = [ title: "Bridged Collections", href: "/bridged-collections", }, - { - title: "Bridged NFTs", - href: "/bridged-nfts", - }, { title: "Testing Tools", href: "/mint", diff --git a/apps/website/components/layout/site-header.tsx b/apps/website/components/layout/site-header.tsx index dce0967..15f0f78 100644 --- a/apps/website/components/layout/site-header.tsx +++ b/apps/website/components/layout/site-header.tsx @@ -6,12 +6,13 @@ import { ConnectButton } from "@/components/blockchain/connect-button" import { AppModeSelector } from "../shared/app-mode-selector" import { LinkComponent } from "../shared/link-component" +import { buttonVariants } from "../ui/button" export function SiteHeader() { return (
@@ -28,8 +29,16 @@ export function SiteHeader() {
-
- +
+ + Account History + +
+ +
) diff --git a/apps/website/components/shared/app-mode-selector.tsx b/apps/website/components/shared/app-mode-selector.tsx index 66848db..ddc73d6 100644 --- a/apps/website/components/shared/app-mode-selector.tsx +++ b/apps/website/components/shared/app-mode-selector.tsx @@ -20,12 +20,12 @@ export function AppModeSelector() { {appMode === "mainnet" ? ( <> ๐Ÿš€ - Production + Production ) : ( <> ๐Ÿงช - Testing + Testing )}
From d35bdc788ca6d1910ed5713c967d81710a3f133c Mon Sep 17 00:00:00 2001 From: Vitor Date: Fri, 5 Apr 2024 14:46:53 -0300 Subject: [PATCH 6/6] fix: header style --- .../account-history/[chainId]/page.tsx | 42 ++++++++----------- 1 file changed, 17 insertions(+), 25 deletions(-) diff --git a/apps/website/app/(general)/account-history/[chainId]/page.tsx b/apps/website/app/(general)/account-history/[chainId]/page.tsx index 023b914..168cb46 100644 --- a/apps/website/app/(general)/account-history/[chainId]/page.tsx +++ b/apps/website/app/(general)/account-history/[chainId]/page.tsx @@ -15,16 +15,9 @@ import { } from "@/lib/event-cache/hooks/use-bridged-erc721" import { useTokenList } from "@/lib/hooks/use-token-list" import { useAppMode } from "@/lib/state/app-mode" -import { cn } from "@/lib/utils" import { Card } from "@/components/ui/card" -import { - NavigationMenu, - NavigationMenuItem, - NavigationMenuLink, - NavigationMenuList, - navigationMenuTriggerStyle, -} from "@/components/ui/navigation-menu" import { Skeleton } from "@/components/ui/skeleton" +import { Tabs, TabsList, TabsTrigger } from "@/components/ui/tabs" import { BlockExplorerLink } from "@/components/blockchain/block-explorer-link" import { ConnectButton } from "@/components/blockchain/connect-button" @@ -71,28 +64,27 @@ export default function BridgedCollectionsByChainIdPage({

Your Bridged NFTs

- - + + {Object.values(l2NetworksOptions[appMode]).map( ({ name, chainId: optionChainId }) => ( - - + - - {name} - - - + {name} + + ) )} - - + +
{!address ? (