From 459f434db98dd1bdbaf643aa87d1e460bd0ea625 Mon Sep 17 00:00:00 2001 From: Harman-singh-waraich Date: Tue, 30 Sep 2025 16:49:27 +0530 Subject: [PATCH] chore/envio-query-migration --- packages/site/src/pages/index.tsx | 30 ++--- packages/snap/src/index.ts | 199 ++++++++++++++++++------------ 2 files changed, 138 insertions(+), 91 deletions(-) diff --git a/packages/site/src/pages/index.tsx b/packages/site/src/pages/index.tsx index f397872..7e61014 100644 --- a/packages/site/src/pages/index.tsx +++ b/packages/site/src/pages/index.tsx @@ -95,20 +95,20 @@ const Index = () => { useEffect(() => { const fetchData = async () => { const response = await axios.post( - "https://gateway.thegraph.com/api/b027176e14f0a073a572abe9068dd266/subgraphs/id/9hHo5MpjpC1JqfD3BsgFnojGurXRHTrHWcUcZPPCo6m8", + 'https://indexer.hyperindex.xyz/1a2f51c/v1/graphql', { query: ` - { - litems(first:1000, where:{registry:"0xfdb66ad9576842945431c27fe8cb5ef8ed5cb8bb", status_in:[Registered], disputed:false}) - { - itemID - metadata { - key0 - key1 - key2 - } - } - } + { + litems: LItem( + limit: 1000 + where: {registry_id: {_eq: "0xfdb66ad9576842945431c27fe8cb5ef8ed5cb8bb"}, status: {_in: [Registered]}, disputed: {_eq: false}} + ) { + itemID + key0 + key1 + key2 + } + } `, }, ); @@ -123,7 +123,9 @@ const Index = () => { const filterPackages = async () => { try { const results = await axios.get( - `https://registry.npmjs.org/-/v1/search?text=${encodeURIComponent(search)}`, + `https://registry.npmjs.org/-/v1/search?text=${encodeURIComponent( + search, + )}`, ); setFilteredPackages( results.data.objects.map((obj: { package: any }) => obj.package), @@ -194,7 +196,7 @@ const Index = () => { {filteredPackages.map((pkg) => { - const isVerified = packages.some((item) => item?.metadata?.key0 === pkg.name); + const isVerified = packages.some((item) => item?.key0 === pkg.name); return ( { text( '**Contract Tag:** _What is the function or tag associated with the smart contract?_', ), - text('**Domain:** _Whether this contract is known to be used on this domain?_'), + text( + '**Domain:** _Whether this contract is known to be used on this domain?_', + ), image(InsightsDisplayImage), ]), }, @@ -288,38 +281,83 @@ export const onTransaction: OnTransactionHandler = async ({ if (result.length > 0) { insights.push(...result); } else { - insights.push(`No insights available for this contract. Interact at your own risk.`); + insights.push( + `No insights available for this contract. Interact at your own risk.`, + ); } const excludedDomains = [ - 'etherscan.io', 'bscscan.com', 'gnosisscan.io', 'polygonscan.com', - 'mempool.space', 'explorer.solana.com', 'basescan.org', 'arbiscan.io', - 'moonscan.io', 'lineascan.build', 'optimistic.etherscan.io', 'ftmscan.com', - 'moonriver.moonscan.io', 'snowscan.xyz', 'cronoscan.com', 'bttcscan.com', - 'zkevm.polygonscan.com', 'wemixscan.com', 'scrollscan.com', 'era.zksync.network', - 'celoscan.io', 'avascan.info', 'blastscan.io', 'mantlescan.xyz', 'sepolia.etherscan.io', - 'goerli.etherscan.io', 'holesky.etherscan.io', 'testnet.bscscan.com', 'testnet.ftmscan.com', - 'mumbai.polygonscan.com', 'goerli.arbiscan.io', 'sepolia.arbiscan.io', 'testnet.snowtrace.io', - 'explorer.testnet.mantle.xyz', 'sepolia.basescan.org', 'goerli.basescan.org', 'alfajores.celoscan.io', - 'blockscout.com', 'explorer.zksync.io', 'layerzeroscan.com', 'routescan.io', - 'moonbeam.moonscan.io', 'subscan.io', 'solscan.io', 'explorer.near.org', - 'cardanoscan.io', 'astar.subscan.io', 'polkadot.subscan.io', 'kusama.subscan.io' + 'etherscan.io', + 'bscscan.com', + 'gnosisscan.io', + 'polygonscan.com', + 'mempool.space', + 'explorer.solana.com', + 'basescan.org', + 'arbiscan.io', + 'moonscan.io', + 'lineascan.build', + 'optimistic.etherscan.io', + 'ftmscan.com', + 'moonriver.moonscan.io', + 'snowscan.xyz', + 'cronoscan.com', + 'bttcscan.com', + 'zkevm.polygonscan.com', + 'wemixscan.com', + 'scrollscan.com', + 'era.zksync.network', + 'celoscan.io', + 'avascan.info', + 'blastscan.io', + 'mantlescan.xyz', + 'sepolia.etherscan.io', + 'goerli.etherscan.io', + 'holesky.etherscan.io', + 'testnet.bscscan.com', + 'testnet.ftmscan.com', + 'mumbai.polygonscan.com', + 'goerli.arbiscan.io', + 'sepolia.arbiscan.io', + 'testnet.snowtrace.io', + 'explorer.testnet.mantle.xyz', + 'sepolia.basescan.org', + 'goerli.basescan.org', + 'alfajores.celoscan.io', + 'blockscout.com', + 'explorer.zksync.io', + 'layerzeroscan.com', + 'routescan.io', + 'moonbeam.moonscan.io', + 'subscan.io', + 'solscan.io', + 'explorer.near.org', + 'cardanoscan.io', + 'astar.subscan.io', + 'polkadot.subscan.io', + 'kusama.subscan.io', ]; - if (!excludedDomains.includes(domain) && !insights.some(insight => insight.includes('Domain'))) { + if ( + !excludedDomains.includes(domain) && + !insights.some((insight) => insight.includes('Domain')) + ) { const cdnPathURL = `https://app.klerosscout.eth.limo/#/?registry=CDN&network=1&network=100&network=137&network=56&network=42161&network=10&network=43114&network=534352&network=42220&network=8453&network=250&network=324&status=Registered&status=RegistrationRequested&status=ClearingRequested&status=Absent&disputed=true&disputed=false&page=1&orderDirection=desc&&additem=CDN&caip10Address=${caipAddress}&domain=${domain}`; - insights.push(`Is this contract officially linked to **${domain}**? If so, submit the info at [Scout App](${cdnPathURL}) to verify it for all users!`); + insights.push( + `Is this contract officially linked to **${domain}**? If so, submit the info at [Scout App](${cdnPathURL}) to verify it for all users!`, + ); } return { - content: panel([ - ...insights.map((insight) => text(insight)), - ]), + content: panel([...insights.map((insight) => text(insight))]), }; }; -export const onSignature: OnSignatureHandler = async ({ signature, signatureOrigin }) => { +export const onSignature: OnSignatureHandler = async ({ + signature, + signatureOrigin, +}) => { const { signatureMethod, data } = signature; const insights: string[] = []; @@ -329,15 +367,22 @@ export const onSignature: OnSignatureHandler = async ({ signature, signatureOrig ) { const verifyingContract = data?.domain?.verifyingContract; const numericChainId = data?.domain?.chainId; - const caipAddress = `eip155:${numericChainId}:${verifyingContract as string}`; + const caipAddress = `eip155:${numericChainId}:${ + verifyingContract as string + }`; if (verifyingContract) { - const result = await getInsights(caipAddress, signatureOrigin || 'NO_DOMAIN'); + const result = await getInsights( + caipAddress, + signatureOrigin || 'NO_DOMAIN', + ); if (result.length > 0) { insights.push(...result); } else { - insights.push('No insights available for this contract. Interact at your own risk.'); + insights.push( + 'No insights available for this contract. Interact at your own risk.', + ); } } else { insights.push('No verifying contract found in the signature data.');