From b5e51cc1b060dbe9af0d0330b6f3cb2c920b996f Mon Sep 17 00:00:00 2001 From: Corantin Date: Fri, 7 Jun 2024 14:48:52 -0400 Subject: [PATCH] Cleanup --- packages/nextjs/components/FileValidation.tsx | 2 +- .../nextjs/components/ValidationPropertyOverview.tsx | 1 + packages/nextjs/contracts/deployedContracts.ts | 7 +++++-- packages/nextjs/contracts/externalContracts.ts | 1 - packages/nextjs/hooks/scaffold-eth/useAutoConnect.ts | 7 ++----- .../hooks/scaffold-eth/useScaffoldEventHistory.ts | 3 ++- packages/nextjs/pages/agent-explorer/index.tsx | 4 ++-- packages/nextjs/pages/playground/ContractEvent.tsx | 4 ++-- packages/nextjs/servers/auth.ts | 2 +- .../utils/scaffold-eth/fetchPriceFromUniswap.ts | 11 ++++++----- packages/nextjs/utils/scaffold-eth/networks.ts | 2 ++ 11 files changed, 24 insertions(+), 20 deletions(-) diff --git a/packages/nextjs/components/FileValidation.tsx b/packages/nextjs/components/FileValidation.tsx index 35809c2b..5d654da1 100644 --- a/packages/nextjs/components/FileValidation.tsx +++ b/packages/nextjs/components/FileValidation.tsx @@ -143,7 +143,7 @@ const FileValidation = ({ }; const openFile = async (file: FileModel) => { - await fileClient.getFile(file.fileId, file.fileName, false); + await fileClient.getFile(file, file.fileName, false); }; const handleStateChanged = (ev: any) => { diff --git a/packages/nextjs/components/ValidationPropertyOverview.tsx b/packages/nextjs/components/ValidationPropertyOverview.tsx index aa2e9dc4..c54581bd 100644 --- a/packages/nextjs/components/ValidationPropertyOverview.tsx +++ b/packages/nextjs/components/ValidationPropertyOverview.tsx @@ -47,6 +47,7 @@ const PropertyOverview = ({ deedData, onRefresh, handleMint, handleValidate }: P <>
f.id === burnerWalletId); - return { connector, chainId: defaultBurnerChainId }; + return { connector, chainId: getTargetNetwork().id }; } } else { // the user was connected to wallet diff --git a/packages/nextjs/hooks/scaffold-eth/useScaffoldEventHistory.ts b/packages/nextjs/hooks/scaffold-eth/useScaffoldEventHistory.ts index 9fecde7a..36bc7019 100644 --- a/packages/nextjs/hooks/scaffold-eth/useScaffoldEventHistory.ts +++ b/packages/nextjs/hooks/scaffold-eth/useScaffoldEventHistory.ts @@ -64,7 +64,8 @@ export const useScaffoldEventHistory = < address: deployedContractData?.address, event, args: filters as any, // TODO: check if it works and fix type - fromBlock: BigInt(deployedContractData.startBlock), + // @ts-ignore + fromBlock: BigInt(deployedContractData.startBlock ?? 0), }); const newEvents = []; for (let i = logs.length - 1; i >= 0; i--) { diff --git a/packages/nextjs/pages/agent-explorer/index.tsx b/packages/nextjs/pages/agent-explorer/index.tsx index 00ccca94..49f53ba6 100644 --- a/packages/nextjs/pages/agent-explorer/index.tsx +++ b/packages/nextjs/pages/agent-explorer/index.tsx @@ -77,8 +77,8 @@ const AgentExplorer: NextPage = () => { cover: `https://picsum.photos/seed/${Math.round(Math.random() * 1000)}/500/300`, email: "random@gmail.com", phone: "1234567890", - latitude: center.lat + (Math.random() - 0.5) * (radius * 2), - longitude: center.lng + (Math.random() - 0.5) * (radius * 2), + lat: center.lat + (Math.random() - 0.5) * (radius * 2), + lng: center.lng + (Math.random() - 0.5) * (radius * 2), icon: agentIcon, type: "fixme", location: "New York", diff --git a/packages/nextjs/pages/playground/ContractEvent.tsx b/packages/nextjs/pages/playground/ContractEvent.tsx index 718eef28..ebfbbcfd 100644 --- a/packages/nextjs/pages/playground/ContractEvent.tsx +++ b/packages/nextjs/pages/playground/ContractEvent.tsx @@ -45,7 +45,7 @@ const ContractEvent = < return ( x.log.blockNumber.toString() === search.trim() || x.log.transactionHash.includes(search) || - x.log.topics.find(topic => topic.includes(search)) || + x.log.topics.find((topic: any) => topic.includes(search)) || (argsString ? argsString.includes(search) : (x.args as any).toString().includes(search)) @@ -69,7 +69,7 @@ const ContractEvent = <
Topics:
    - {x.log.topics.map((topic, i) => ( + {x.log.topics.map((topic: any, i: number) => (
  • - {topic}
  • diff --git a/packages/nextjs/servers/auth.ts b/packages/nextjs/servers/auth.ts index 9d8ea647..6eb9c9c9 100644 --- a/packages/nextjs/servers/auth.ts +++ b/packages/nextjs/servers/auth.ts @@ -40,7 +40,7 @@ export const authentify = async ( const contract = getContract({ address: accessManager.address, abi: accessManager.abi, - publicClient: getClient(req, chainId), + publicClient: getClient(req.headers.host ?? "", chainId), }); if (constraint === "Validator") { diff --git a/packages/nextjs/utils/scaffold-eth/fetchPriceFromUniswap.ts b/packages/nextjs/utils/scaffold-eth/fetchPriceFromUniswap.ts index c15f3140..408aff83 100644 --- a/packages/nextjs/utils/scaffold-eth/fetchPriceFromUniswap.ts +++ b/packages/nextjs/utils/scaffold-eth/fetchPriceFromUniswap.ts @@ -4,6 +4,7 @@ import { createPublicClient, http, parseAbi } from "viem"; import { goerli } from "viem/chains"; import { mainnet } from "wagmi"; import CONFIG from "~~/config"; +import logger from "~~/services/logger.service"; import { getTargetNetwork } from "~~/utils/scaffold-eth"; const publicClient = createPublicClient({ @@ -20,9 +21,9 @@ const ABI = parseAbi([ export const fetchPriceFromUniswap = async (): Promise => { const configuredNetwork = getTargetNetwork(); if ( - configuredNetwork.nativeCurrency.symbol !== "ETH" && - configuredNetwork.nativeCurrency.symbol !== "SEP" && - !configuredNetwork.nativeCurrencyTokenAddress + configuredNetwork.stableCoin.symbol !== "ETH" && + configuredNetwork.stableCoin.symbol !== "SEP" && + !configuredNetwork.stableCoin ) { return 0; } @@ -30,7 +31,7 @@ export const fetchPriceFromUniswap = async (): Promise => { const DAI = new Token(1, "0x6B175474E89094C44Da98b954EedeAC495271d0F", 18); const TOKEN = new Token( 1, - configuredNetwork.nativeCurrencyTokenAddress || "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2", + configuredNetwork.stableCoin.address || "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2", 18, ); const pairAddress = Pair.getAddress(TOKEN, DAI); @@ -64,7 +65,7 @@ export const fetchPriceFromUniswap = async (): Promise => { const price = parseFloat(route.midPrice.toSignificant(6)); return price; } catch (error) { - console.error("useNativeCurrencyPrice - Error fetching ETH price from Uniswap: ", error); + logger.error("useNativeCurrencyPrice - Error fetching ETH price from Uniswap: ", error); return 0; } }; diff --git a/packages/nextjs/utils/scaffold-eth/networks.ts b/packages/nextjs/utils/scaffold-eth/networks.ts index fe7f7cd5..fe2647ef 100644 --- a/packages/nextjs/utils/scaffold-eth/networks.ts +++ b/packages/nextjs/utils/scaffold-eth/networks.ts @@ -50,6 +50,7 @@ export const NETWORKS_EXTRA_DATA: Record = { }, deedSubgraph: "https://api.studio.thegraph.com/query/56229/deed3-sepolia/version/latest", ipfsGateway: "https://ipfs.io/ipfs/", + blockExplorer: "https://blockscout.com/xdai/mainnet", }, [chains.polygon.id]: { color: "#5f4bb6", @@ -62,6 +63,7 @@ export const NETWORKS_EXTRA_DATA: Record = { symbol: "USDC", coinGeckoId: "usd-coin", }, + blockExplorer: "https://polygonscan.com/", }, // [chains.hardhat.id]: { // color: "#b8af0c",