From c388d83b7bc83f0a214a553cffb1f8991f55c855 Mon Sep 17 00:00:00 2001 From: port dev <108868128+portdeveloper@users.noreply.github.com> Date: Sat, 30 Nov 2024 13:37:02 +0300 Subject: [PATCH 1/4] Merge stores into one, fix chain being different in store --- packages/nextjs/components/Footer.tsx | 4 +- .../NetworksDropdown/AddCustomChainModal.tsx | 5 +- .../NetworksDropdown/NetworksDropdown.tsx | 11 +++- .../blockexplorer/TransactionsTable.tsx | 4 +- .../components/scaffold-eth/Address.tsx | 4 +- .../components/scaffold-eth/Balance.tsx | 4 +- .../scaffold-eth/Contract/ContractUI.tsx | 10 ++-- .../scaffold-eth/Contract/DisplayVariable.tsx | 4 +- .../Contract/ReadOnlyFunctionForm.tsx | 4 +- .../Contract/WriteOnlyFunctionForm.tsx | 4 +- .../NetworkOptions.tsx | 11 ++-- .../RainbowKitCustomConnectButton/index.tsx | 9 ++-- packages/nextjs/hooks/scaffold-eth/index.ts | 1 - .../hooks/scaffold-eth/useAccountBalance.ts | 7 +-- .../hooks/scaffold-eth/useBurnerWallet.ts | 4 +- .../hooks/scaffold-eth/useContractLogs.ts | 4 +- .../scaffold-eth/useDeployedContractInfo.ts | 4 +- .../scaffold-eth/useNativeCurrencyPrice.ts | 4 +- .../hooks/scaffold-eth/useNetworkColor.ts | 4 +- .../hooks/scaffold-eth/useScaffoldContract.ts | 4 +- .../scaffold-eth/useScaffoldEventHistory.ts | 4 +- .../scaffold-eth/useScaffoldReadContract.ts | 4 +- .../useScaffoldWatchContractEvent.ts | 4 +- .../scaffold-eth/useScaffoldWriteContract.ts | 4 +- .../hooks/scaffold-eth/useTargetNetwork.ts | 33 ------------ .../hooks/scaffold-eth/useWatchBalance.ts | 4 +- .../pages/[contractAddress]/[network].tsx | 51 +++++++------------ packages/nextjs/pages/blockexplorer/index.tsx | 4 +- .../blockexplorer/transaction/[txHash].tsx | 4 +- packages/nextjs/pages/index.tsx | 4 +- packages/nextjs/scaffold.config.ts | 1 - packages/nextjs/services/store/store.ts | 14 +---- packages/nextjs/utils/abi.ts | 7 ++- .../scaffold-eth/fetchPriceFromUniswap.ts | 3 ++ 34 files changed, 106 insertions(+), 141 deletions(-) delete mode 100644 packages/nextjs/hooks/scaffold-eth/useTargetNetwork.ts diff --git a/packages/nextjs/components/Footer.tsx b/packages/nextjs/components/Footer.tsx index 207ee393..f0921ab7 100644 --- a/packages/nextjs/components/Footer.tsx +++ b/packages/nextjs/components/Footer.tsx @@ -3,13 +3,13 @@ import Link from "next/link"; import { hardhat } from "viem/chains"; import { MagnifyingGlassIcon } from "@heroicons/react/24/outline"; import { Faucet } from "~~/components/scaffold-eth"; -import { useTargetNetwork } from "~~/hooks/scaffold-eth/useTargetNetwork"; +import { useGlobalState } from "~~/services/store/store"; /** * Site footer */ export const Footer = () => { - const { targetNetwork } = useTargetNetwork(); + const targetNetwork = useGlobalState(state => state.targetNetwork); const isLocalNetwork = targetNetwork.id === hardhat.id; return ( diff --git a/packages/nextjs/components/NetworksDropdown/AddCustomChainModal.tsx b/packages/nextjs/components/NetworksDropdown/AddCustomChainModal.tsx index 3699d4f6..89bb311c 100644 --- a/packages/nextjs/components/NetworksDropdown/AddCustomChainModal.tsx +++ b/packages/nextjs/components/NetworksDropdown/AddCustomChainModal.tsx @@ -20,8 +20,9 @@ type AddCustomChainModalProps = { export const AddCustomChainModal = forwardRef( ({ groupedOptionsState, setGroupedOptionsState, setSelectedOption, onChange }, ref) => { - const { addCustomChain } = useGlobalState(state => ({ + const { addCustomChain, setTargetNetwork } = useGlobalState(state => ({ addCustomChain: state.addChain, + setTargetNetwork: state.setTargetNetwork, })); const handleSubmitCustomChain = (e: React.FormEvent) => { @@ -51,6 +52,8 @@ export const AddCustomChainModal = forwardRef any const [groupedOptionsState, setGroupedOptionsState] = useState(initialGroupedOptions); const [selectedOption, setSelectedOption] = useState>(initialGroupedOptions.mainnet.options[0]); - const { addCustomChain, removeChain, resetTargetNetwork } = useGlobalState(state => ({ + const { addCustomChain, removeChain, resetTargetNetwork, setTargetNetwork, chains } = useGlobalState(state => ({ addCustomChain: state.addChain, removeChain: state.removeChain, resetTargetNetwork: () => state.setTargetNetwork(mainnet), + setTargetNetwork: state.setTargetNetwork, + chains: state.chains, })); + useEffect(() => { + if (selectedOption) { + const chain = Object.values(chains).find(chain => chain.id === selectedOption.value); + setTargetNetwork(chain as Chain); + } + }, [selectedOption, setTargetNetwork, chains]); + const seeOtherChainsModalRef = useRef(null); const customChainModalRef = useRef(null); diff --git a/packages/nextjs/components/blockexplorer/TransactionsTable.tsx b/packages/nextjs/components/blockexplorer/TransactionsTable.tsx index 08ede19e..8fd6e4ba 100644 --- a/packages/nextjs/components/blockexplorer/TransactionsTable.tsx +++ b/packages/nextjs/components/blockexplorer/TransactionsTable.tsx @@ -1,12 +1,12 @@ import { formatEther } from "viem"; import { TransactionHash } from "~~/components/blockexplorer/TransactionHash"; import { Address } from "~~/components/scaffold-eth"; -import { useTargetNetwork } from "~~/hooks/scaffold-eth/useTargetNetwork"; +import { useGlobalState } from "~~/services/store/store"; import { TransactionWithFunction } from "~~/utils/scaffold-eth"; import { TransactionsTableProps } from "~~/utils/scaffold-eth/"; export const TransactionsTable = ({ blocks, transactionReceipts }: TransactionsTableProps) => { - const { targetNetwork } = useTargetNetwork(); + const targetNetwork = useGlobalState(state => state.targetNetwork); return (
diff --git a/packages/nextjs/components/scaffold-eth/Address.tsx b/packages/nextjs/components/scaffold-eth/Address.tsx index ee992493..665d7c60 100644 --- a/packages/nextjs/components/scaffold-eth/Address.tsx +++ b/packages/nextjs/components/scaffold-eth/Address.tsx @@ -6,7 +6,7 @@ import { normalize } from "viem/ens"; import { useEnsAvatar, useEnsName } from "wagmi"; import { CheckCircleIcon, DocumentDuplicateIcon } from "@heroicons/react/24/outline"; import { BlockieAvatar } from "~~/components/scaffold-eth"; -import { useTargetNetwork } from "~~/hooks/scaffold-eth/useTargetNetwork"; +import { useGlobalState } from "~~/services/store/store"; import { getBlockExplorerAddressLink } from "~~/utils/scaffold-eth"; type AddressProps = { @@ -34,7 +34,7 @@ export const Address = ({ address, disableAddressLink, format, size = "base" }: const [ensAvatar, setEnsAvatar] = useState(); const [addressCopied, setAddressCopied] = useState(false); - const { targetNetwork } = useTargetNetwork(); + const targetNetwork = useGlobalState(state => state.targetNetwork); const { data: fetchedEns } = useEnsName({ address: address, diff --git a/packages/nextjs/components/scaffold-eth/Balance.tsx b/packages/nextjs/components/scaffold-eth/Balance.tsx index 53882f66..65a80f21 100644 --- a/packages/nextjs/components/scaffold-eth/Balance.tsx +++ b/packages/nextjs/components/scaffold-eth/Balance.tsx @@ -1,6 +1,6 @@ import { Address } from "viem"; import { useAccountBalance } from "~~/hooks/scaffold-eth"; -import { useTargetNetwork } from "~~/hooks/scaffold-eth/useTargetNetwork"; +import { useGlobalState } from "~~/services/store/store"; type BalanceProps = { address?: Address; @@ -11,7 +11,7 @@ type BalanceProps = { * Display (ETH & USD) balance of an ETH address. */ export const Balance = ({ address, className = "" }: BalanceProps) => { - const { targetNetwork } = useTargetNetwork(); + const targetNetwork = useGlobalState(state => state.targetNetwork); const { balance, price, isError, isLoading, onToggleBalance, isEthBalance } = useAccountBalance(address); if (!address || isLoading || balance === null) { diff --git a/packages/nextjs/components/scaffold-eth/Contract/ContractUI.tsx b/packages/nextjs/components/scaffold-eth/Contract/ContractUI.tsx index 07d767e5..406e99c4 100644 --- a/packages/nextjs/components/scaffold-eth/Contract/ContractUI.tsx +++ b/packages/nextjs/components/scaffold-eth/Contract/ContractUI.tsx @@ -4,17 +4,17 @@ import { ContractReadMethods } from "./ContractReadMethods"; import { ContractVariables } from "./ContractVariables"; import { ContractWriteMethods } from "./ContractWriteMethods"; import { AbiFunction } from "abitype"; -import { Abi } from "viem"; +import { Abi, Address as AddressType } from "viem"; import { useContractRead } from "wagmi"; import { MiniFooter } from "~~/components/MiniFooter"; import { Address, Balance, MethodSelector } from "~~/components/scaffold-eth"; import { useNetworkColor } from "~~/hooks/scaffold-eth"; -import { useAbiNinjaState } from "~~/services/store/store"; +import { useGlobalState } from "~~/services/store/store"; import { getTargetNetworks } from "~~/utils/scaffold-eth"; type ContractUIProps = { className?: string; - initialContractData: { address: string; abi: Abi }; + initialContractData: { address: AddressType; abi: Abi }; }; export interface AugmentedAbiFunction extends AbiFunction { @@ -61,8 +61,8 @@ const mainNetworks = getTargetNetworks(); **/ export const ContractUI = ({ className = "", initialContractData }: ContractUIProps) => { const [refreshDisplayVariables, triggerRefreshDisplayVariables] = useReducer(value => !value, false); - const { implementationAddress, chainId } = useAbiNinjaState(state => ({ - chainId: state.mainChainId, + const { implementationAddress, chainId } = useGlobalState(state => ({ + chainId: state.targetNetwork.id, implementationAddress: state.implementationAddress, })); const mainNetwork = mainNetworks.find(network => network.id === chainId); diff --git a/packages/nextjs/components/scaffold-eth/Contract/DisplayVariable.tsx b/packages/nextjs/components/scaffold-eth/Contract/DisplayVariable.tsx index 9e3df5c1..03ffdd3b 100644 --- a/packages/nextjs/components/scaffold-eth/Contract/DisplayVariable.tsx +++ b/packages/nextjs/components/scaffold-eth/Contract/DisplayVariable.tsx @@ -6,7 +6,7 @@ import { useReadContract } from "wagmi"; import { ArrowPathIcon } from "@heroicons/react/24/outline"; import { displayTxResult } from "~~/components/scaffold-eth"; import { useAnimationConfig } from "~~/hooks/scaffold-eth"; -import { useAbiNinjaState } from "~~/services/store/store"; +import { useGlobalState } from "~~/services/store/store"; import { getParsedError, notification } from "~~/utils/scaffold-eth"; type DisplayVariableProps = { @@ -24,7 +24,7 @@ export const DisplayVariable = ({ abi, inheritedFrom, }: DisplayVariableProps) => { - const mainChainId = useAbiNinjaState(state => state.mainChainId); + const mainChainId = useGlobalState(state => state.targetNetwork.id); const { data: result, isFetching, diff --git a/packages/nextjs/components/scaffold-eth/Contract/ReadOnlyFunctionForm.tsx b/packages/nextjs/components/scaffold-eth/Contract/ReadOnlyFunctionForm.tsx index e785a010..b38a2adf 100644 --- a/packages/nextjs/components/scaffold-eth/Contract/ReadOnlyFunctionForm.tsx +++ b/packages/nextjs/components/scaffold-eth/Contract/ReadOnlyFunctionForm.tsx @@ -13,7 +13,7 @@ import { getParsedContractFunctionArgs, transformAbiFunction, } from "~~/components/scaffold-eth"; -import { useAbiNinjaState } from "~~/services/store/store"; +import { useGlobalState } from "~~/services/store/store"; import { getParsedError, notification } from "~~/utils/scaffold-eth"; type ReadOnlyFunctionFormProps = { @@ -29,7 +29,7 @@ export const ReadOnlyFunctionForm = ({ inheritedFrom, abi, }: ReadOnlyFunctionFormProps) => { - const mainChainId = useAbiNinjaState(state => state.mainChainId); + const mainChainId = useGlobalState(state => state.targetNetwork.id); const [form, setForm] = useState>(() => getInitialFormState(abiFunction)); const [result, setResult] = useState(); diff --git a/packages/nextjs/components/scaffold-eth/Contract/WriteOnlyFunctionForm.tsx b/packages/nextjs/components/scaffold-eth/Contract/WriteOnlyFunctionForm.tsx index 1e45bc25..a0714b3a 100644 --- a/packages/nextjs/components/scaffold-eth/Contract/WriteOnlyFunctionForm.tsx +++ b/packages/nextjs/components/scaffold-eth/Contract/WriteOnlyFunctionForm.tsx @@ -14,7 +14,7 @@ import { transformAbiFunction, } from "~~/components/scaffold-eth"; import { useTransactor } from "~~/hooks/scaffold-eth"; -import { useAbiNinjaState } from "~~/services/store/store"; +import { useGlobalState } from "~~/services/store/store"; type WriteOnlyFunctionFormProps = { abi: Abi; @@ -31,7 +31,7 @@ export const WriteOnlyFunctionForm = ({ contractAddress, inheritedFrom, }: WriteOnlyFunctionFormProps) => { - const mainChainId = useAbiNinjaState(state => state.mainChainId); + const mainChainId = useGlobalState(state => state.targetNetwork.id); const [form, setForm] = useState>(() => getInitialFormState(abiFunction)); const [txValue, setTxValue] = useState(""); const { chain } = useAccount(); diff --git a/packages/nextjs/components/scaffold-eth/RainbowKitCustomConnectButton/NetworkOptions.tsx b/packages/nextjs/components/scaffold-eth/RainbowKitCustomConnectButton/NetworkOptions.tsx index e5a01f9d..cd035d24 100644 --- a/packages/nextjs/components/scaffold-eth/RainbowKitCustomConnectButton/NetworkOptions.tsx +++ b/packages/nextjs/components/scaffold-eth/RainbowKitCustomConnectButton/NetworkOptions.tsx @@ -2,7 +2,7 @@ import { useTheme } from "next-themes"; import { useSwitchChain } from "wagmi"; import { ArrowsRightLeftIcon } from "@heroicons/react/24/solid"; import { getNetworkColor } from "~~/hooks/scaffold-eth"; -import { useAbiNinjaState, useGlobalState } from "~~/services/store/store"; +import { useGlobalState } from "~~/services/store/store"; type NetworkOptionsProps = { hidden?: boolean; @@ -12,8 +12,13 @@ export const NetworkOptions = ({ hidden = false }: NetworkOptionsProps) => { const { resolvedTheme } = useTheme(); const isDarkMode = resolvedTheme === "dark"; const { switchChain } = useSwitchChain(); - const mainChainId = useAbiNinjaState(state => state.mainChainId); - const chains = useGlobalState(state => state.chains); + const { + chains, + targetNetwork: { id: mainChainId }, + } = useGlobalState(state => ({ + chains: state.chains, + targetNetwork: state.targetNetwork, + })); const filteredChains = chains.filter(allowedNetwork => allowedNetwork.id === mainChainId); // if chainId is 31337 we render one element, since viem chains have 3 chains with same chainId. diff --git a/packages/nextjs/components/scaffold-eth/RainbowKitCustomConnectButton/index.tsx b/packages/nextjs/components/scaffold-eth/RainbowKitCustomConnectButton/index.tsx index d9ccc68f..5ba9c079 100644 --- a/packages/nextjs/components/scaffold-eth/RainbowKitCustomConnectButton/index.tsx +++ b/packages/nextjs/components/scaffold-eth/RainbowKitCustomConnectButton/index.tsx @@ -5,17 +5,18 @@ import { WrongNetworkDropdown } from "./WrongNetworkDropdown"; import { ConnectButton } from "@rainbow-me/rainbowkit"; import { Address } from "viem"; import { useNetworkColor } from "~~/hooks/scaffold-eth"; -import { useTargetNetwork } from "~~/hooks/scaffold-eth/useTargetNetwork"; -import { useAbiNinjaState } from "~~/services/store/store"; +import { useGlobalState } from "~~/services/store/store"; import { getBlockExplorerAddressLink } from "~~/utils/scaffold-eth"; /** * Custom Wagmi Connect Button (watch balance + custom design) */ export const RainbowKitCustomConnectButton = () => { - const mainChainId = useAbiNinjaState(state => state.mainChainId); + const { mainChainId, targetNetwork } = useGlobalState(state => ({ + mainChainId: state.targetNetwork.id, + targetNetwork: state.targetNetwork, + })); const networkColor = useNetworkColor(); - const { targetNetwork } = useTargetNetwork(); return ( diff --git a/packages/nextjs/hooks/scaffold-eth/index.ts b/packages/nextjs/hooks/scaffold-eth/index.ts index f6cc34e3..1220ea9c 100644 --- a/packages/nextjs/hooks/scaffold-eth/index.ts +++ b/packages/nextjs/hooks/scaffold-eth/index.ts @@ -10,7 +10,6 @@ export * from "./useScaffoldEventHistory"; export * from "./useScaffoldReadContract"; export * from "./useScaffoldWatchContractEvent"; export * from "./useScaffoldWriteContract"; -export * from "./useTargetNetwork"; export * from "./useTransactor"; export * from "./useWatchBalance"; export * from "./useNativeCurrencyPrice"; diff --git a/packages/nextjs/hooks/scaffold-eth/useAccountBalance.ts b/packages/nextjs/hooks/scaffold-eth/useAccountBalance.ts index 94459e36..5cab5de2 100644 --- a/packages/nextjs/hooks/scaffold-eth/useAccountBalance.ts +++ b/packages/nextjs/hooks/scaffold-eth/useAccountBalance.ts @@ -1,5 +1,4 @@ import { useCallback, useEffect, useState } from "react"; -import { useTargetNetwork } from "./useTargetNetwork"; import { useQueryClient } from "@tanstack/react-query"; import { Address } from "viem"; import { useBalance, useBlockNumber } from "wagmi"; @@ -8,8 +7,10 @@ import { useGlobalState } from "~~/services/store/store"; export function useAccountBalance(address?: Address) { const [isEthBalance, setIsEthBalance] = useState(true); const [balance, setBalance] = useState(null); - const price = useGlobalState(state => state.nativeCurrencyPrice); - const { targetNetwork } = useTargetNetwork(); + const { price, targetNetwork } = useGlobalState(state => ({ + price: state.nativeCurrencyPrice, + targetNetwork: state.targetNetwork, + })); const queryClient = useQueryClient(); const { data: blockNumber } = useBlockNumber({ watch: true, chainId: targetNetwork.id }); diff --git a/packages/nextjs/hooks/scaffold-eth/useBurnerWallet.ts b/packages/nextjs/hooks/scaffold-eth/useBurnerWallet.ts index 019ae783..89aa7420 100644 --- a/packages/nextjs/hooks/scaffold-eth/useBurnerWallet.ts +++ b/packages/nextjs/hooks/scaffold-eth/useBurnerWallet.ts @@ -1,10 +1,10 @@ import { useCallback, useEffect, useRef, useState } from "react"; -import { useTargetNetwork } from "./useTargetNetwork"; import { useLocalStorage } from "usehooks-ts"; import { Chain, Hex, HttpTransport, PrivateKeyAccount, createWalletClient, http } from "viem"; import { WalletClient } from "viem"; import { generatePrivateKey, privateKeyToAccount } from "viem/accounts"; import { usePublicClient } from "wagmi"; +import { useGlobalState } from "~~/services/store/store"; const burnerStorageKey = "scaffoldEth2.burnerWallet.sk"; @@ -61,7 +61,7 @@ type BurnerAccount = { export const useBurnerWallet = (): BurnerAccount => { const [burnerSk, setBurnerSk] = useLocalStorage(burnerStorageKey, newDefaultPrivateKey); - const { targetNetwork } = useTargetNetwork(); + const targetNetwork = useGlobalState(state => state.targetNetwork); const publicClient = usePublicClient({ chainId: targetNetwork.id }); const [walletClient, setWalletClient] = useState>(); const [generatedPrivateKey, setGeneratedPrivateKey] = useState("0x"); diff --git a/packages/nextjs/hooks/scaffold-eth/useContractLogs.ts b/packages/nextjs/hooks/scaffold-eth/useContractLogs.ts index 27775d5b..dcf2128f 100644 --- a/packages/nextjs/hooks/scaffold-eth/useContractLogs.ts +++ b/packages/nextjs/hooks/scaffold-eth/useContractLogs.ts @@ -1,11 +1,11 @@ import { useEffect, useState } from "react"; -import { useTargetNetwork } from "./useTargetNetwork"; import { Address, Log } from "viem"; import { usePublicClient } from "wagmi"; +import { useGlobalState } from "~~/services/store/store"; export const useContractLogs = (address: Address) => { const [logs, setLogs] = useState([]); - const { targetNetwork } = useTargetNetwork(); + const targetNetwork = useGlobalState(state => state.targetNetwork); const client = usePublicClient({ chainId: targetNetwork.id }); useEffect(() => { diff --git a/packages/nextjs/hooks/scaffold-eth/useDeployedContractInfo.ts b/packages/nextjs/hooks/scaffold-eth/useDeployedContractInfo.ts index 8f649c38..61a3c3f9 100644 --- a/packages/nextjs/hooks/scaffold-eth/useDeployedContractInfo.ts +++ b/packages/nextjs/hooks/scaffold-eth/useDeployedContractInfo.ts @@ -1,7 +1,7 @@ import { useEffect, useState } from "react"; -import { useTargetNetwork } from "./useTargetNetwork"; import { useIsMounted } from "usehooks-ts"; import { usePublicClient } from "wagmi"; +import { useGlobalState } from "~~/services/store/store"; import { Contract, ContractCodeStatus, ContractName, contracts } from "~~/utils/scaffold-eth/contract"; /** @@ -10,7 +10,7 @@ import { Contract, ContractCodeStatus, ContractName, contracts } from "~~/utils/ */ export const useDeployedContractInfo = (contractName: TContractName) => { const isMounted = useIsMounted(); - const { targetNetwork } = useTargetNetwork(); + const targetNetwork = useGlobalState(state => state.targetNetwork); const deployedContract = contracts?.[targetNetwork.id]?.[contractName as ContractName] as Contract; const [status, setStatus] = useState(ContractCodeStatus.LOADING); const publicClient = usePublicClient({ chainId: targetNetwork.id }); diff --git a/packages/nextjs/hooks/scaffold-eth/useNativeCurrencyPrice.ts b/packages/nextjs/hooks/scaffold-eth/useNativeCurrencyPrice.ts index b81e781e..c2fcd78a 100644 --- a/packages/nextjs/hooks/scaffold-eth/useNativeCurrencyPrice.ts +++ b/packages/nextjs/hooks/scaffold-eth/useNativeCurrencyPrice.ts @@ -1,7 +1,7 @@ import { useEffect, useState } from "react"; -import { useTargetNetwork } from "./useTargetNetwork"; import { useInterval } from "usehooks-ts"; import scaffoldConfig from "~~/scaffold.config"; +import { useGlobalState } from "~~/services/store/store"; import { fetchPriceFromUniswap } from "~~/utils/scaffold-eth"; const enablePolling = false; @@ -11,7 +11,7 @@ const enablePolling = false; * @returns nativeCurrencyPrice: number */ export const useNativeCurrencyPrice = () => { - const { targetNetwork } = useTargetNetwork(); + const targetNetwork = useGlobalState(state => state.targetNetwork); const [nativeCurrencyPrice, setNativeCurrencyPrice] = useState(0); // Get the price of ETH from Uniswap on mount diff --git a/packages/nextjs/hooks/scaffold-eth/useNetworkColor.ts b/packages/nextjs/hooks/scaffold-eth/useNetworkColor.ts index b2e0f777..6d8573f2 100644 --- a/packages/nextjs/hooks/scaffold-eth/useNetworkColor.ts +++ b/packages/nextjs/hooks/scaffold-eth/useNetworkColor.ts @@ -1,5 +1,5 @@ -import { useTargetNetwork } from "./useTargetNetwork"; import { useTheme } from "next-themes"; +import { useGlobalState } from "~~/services/store/store"; import { ChainWithAttributes } from "~~/utils/scaffold-eth"; export const DEFAULT_NETWORK_COLOR: [string, string] = ["#666666", "#bbbbbb"]; @@ -15,7 +15,7 @@ export function getNetworkColor(network: ChainWithAttributes, isDarkMode: boolea export const useNetworkColor = (network?: ChainWithAttributes) => { const { resolvedTheme } = useTheme(); const isDarkMode = resolvedTheme === "dark"; - const { targetNetwork } = useTargetNetwork(); + const targetNetwork = useGlobalState(state => state.targetNetwork); return getNetworkColor(network || targetNetwork, isDarkMode); }; diff --git a/packages/nextjs/hooks/scaffold-eth/useScaffoldContract.ts b/packages/nextjs/hooks/scaffold-eth/useScaffoldContract.ts index 1add8cba..b08ecaa3 100644 --- a/packages/nextjs/hooks/scaffold-eth/useScaffoldContract.ts +++ b/packages/nextjs/hooks/scaffold-eth/useScaffoldContract.ts @@ -1,8 +1,8 @@ -import { useTargetNetwork } from "./useTargetNetwork"; import { Account, Address, Chain, Client, Transport, getContract } from "viem"; import { usePublicClient } from "wagmi"; import { GetWalletClientReturnType } from "wagmi/actions"; import { useDeployedContractInfo } from "~~/hooks/scaffold-eth"; +import { useGlobalState } from "~~/services/store/store"; import { Contract, ContractName } from "~~/utils/scaffold-eth/contract"; /** @@ -23,7 +23,7 @@ export const useScaffoldContract = < walletClient?: TWalletClient | null; }) => { const { data: deployedContractData, isLoading: deployedContractLoading } = useDeployedContractInfo(contractName); - const { targetNetwork } = useTargetNetwork(); + const targetNetwork = useGlobalState(state => state.targetNetwork); const publicClient = usePublicClient({ chainId: targetNetwork.id }); let contract = undefined; diff --git a/packages/nextjs/hooks/scaffold-eth/useScaffoldEventHistory.ts b/packages/nextjs/hooks/scaffold-eth/useScaffoldEventHistory.ts index 869bb5c1..d11d34bf 100644 --- a/packages/nextjs/hooks/scaffold-eth/useScaffoldEventHistory.ts +++ b/packages/nextjs/hooks/scaffold-eth/useScaffoldEventHistory.ts @@ -1,5 +1,4 @@ import { useCallback, useEffect, useMemo, useState } from "react"; -import { useTargetNetwork } from "./useTargetNetwork"; import { Abi, AbiEvent, ExtractAbiEventNames } from "abitype"; import { useInterval } from "usehooks-ts"; import { Hash } from "viem"; @@ -7,6 +6,7 @@ import * as chains from "viem/chains"; import { usePublicClient } from "wagmi"; import { useDeployedContractInfo } from "~~/hooks/scaffold-eth"; import scaffoldConfig from "~~/scaffold.config"; +import { useGlobalState } from "~~/services/store/store"; import { replacer } from "~~/utils/scaffold-eth/common"; import { ContractAbi, @@ -51,7 +51,7 @@ export const useScaffoldEventHistory = < const [fromBlockUpdated, setFromBlockUpdated] = useState(fromBlock); const { data: deployedContractData, isLoading: deployedContractLoading } = useDeployedContractInfo(contractName); - const { targetNetwork } = useTargetNetwork(); + const targetNetwork = useGlobalState(state => state.targetNetwork); const publicClient = usePublicClient({ chainId: targetNetwork.id, }); diff --git a/packages/nextjs/hooks/scaffold-eth/useScaffoldReadContract.ts b/packages/nextjs/hooks/scaffold-eth/useScaffoldReadContract.ts index 9d9e8f03..de3985f0 100644 --- a/packages/nextjs/hooks/scaffold-eth/useScaffoldReadContract.ts +++ b/packages/nextjs/hooks/scaffold-eth/useScaffoldReadContract.ts @@ -1,10 +1,10 @@ import { useEffect } from "react"; -import { useTargetNetwork } from "./useTargetNetwork"; import { QueryObserverResult, RefetchOptions, useQueryClient } from "@tanstack/react-query"; import type { ExtractAbiFunctionNames } from "abitype"; import { ReadContractErrorType } from "viem"; import { useBlockNumber, useReadContract } from "wagmi"; import { useDeployedContractInfo } from "~~/hooks/scaffold-eth"; +import { useGlobalState } from "~~/services/store/store"; import { AbiFunctionReturnType, ContractAbi, @@ -30,7 +30,7 @@ export const useScaffoldReadContract = < ...readConfig }: UseScaffoldReadConfig) => { const { data: deployedContract } = useDeployedContractInfo(contractName); - const { targetNetwork } = useTargetNetwork(); + const targetNetwork = useGlobalState(state => state.targetNetwork); const { query: queryOptions, watch, ...readContractConfig } = readConfig; // set watch to true by default const defaultWatch = watch ?? true; diff --git a/packages/nextjs/hooks/scaffold-eth/useScaffoldWatchContractEvent.ts b/packages/nextjs/hooks/scaffold-eth/useScaffoldWatchContractEvent.ts index 844b4a08..f5efdc77 100644 --- a/packages/nextjs/hooks/scaffold-eth/useScaffoldWatchContractEvent.ts +++ b/packages/nextjs/hooks/scaffold-eth/useScaffoldWatchContractEvent.ts @@ -1,8 +1,8 @@ -import { useTargetNetwork } from "./useTargetNetwork"; import { Abi, ExtractAbiEventNames } from "abitype"; import { Log } from "viem"; import { useWatchContractEvent } from "wagmi"; import { addIndexedArgsToEvent, useDeployedContractInfo } from "~~/hooks/scaffold-eth"; +import { useGlobalState } from "~~/services/store/store"; import { ContractAbi, ContractName, UseScaffoldEventConfig } from "~~/utils/scaffold-eth/contract"; /** @@ -22,7 +22,7 @@ export const useScaffoldWatchContractEvent = < onLogs, }: UseScaffoldEventConfig) => { const { data: deployedContractData } = useDeployedContractInfo(contractName); - const { targetNetwork } = useTargetNetwork(); + const targetNetwork = useGlobalState(state => state.targetNetwork); const addIndexedArgsToLogs = (logs: Log[]) => logs.map(addIndexedArgsToEvent); const listenerWithIndexedArgs = (logs: Log[]) => onLogs(addIndexedArgsToLogs(logs) as Parameters[0]); diff --git a/packages/nextjs/hooks/scaffold-eth/useScaffoldWriteContract.ts b/packages/nextjs/hooks/scaffold-eth/useScaffoldWriteContract.ts index 4bd903f7..544b64c8 100644 --- a/packages/nextjs/hooks/scaffold-eth/useScaffoldWriteContract.ts +++ b/packages/nextjs/hooks/scaffold-eth/useScaffoldWriteContract.ts @@ -1,11 +1,11 @@ import { useState } from "react"; -import { useTargetNetwork } from "./useTargetNetwork"; import { MutateOptions } from "@tanstack/react-query"; import { Abi, ExtractAbiFunctionNames } from "abitype"; import { Config, UseWriteContractParameters, useAccount, useWriteContract } from "wagmi"; import { WriteContractErrorType, WriteContractReturnType } from "wagmi/actions"; import { WriteContractVariables } from "wagmi/query"; import { useDeployedContractInfo, useTransactor } from "~~/hooks/scaffold-eth"; +import { useGlobalState } from "~~/services/store/store"; import { notification } from "~~/utils/scaffold-eth"; import { ContractAbi, @@ -27,7 +27,7 @@ export const useScaffoldWriteContract = ( const { chain } = useAccount(); const writeTx = useTransactor(); const [isMining, setIsMining] = useState(false); - const { targetNetwork } = useTargetNetwork(); + const targetNetwork = useGlobalState(state => state.targetNetwork); const wagmiContractWrite = useWriteContract(writeContractParams); diff --git a/packages/nextjs/hooks/scaffold-eth/useTargetNetwork.ts b/packages/nextjs/hooks/scaffold-eth/useTargetNetwork.ts deleted file mode 100644 index 9ff726bf..00000000 --- a/packages/nextjs/hooks/scaffold-eth/useTargetNetwork.ts +++ /dev/null @@ -1,33 +0,0 @@ -import { useEffect, useMemo } from "react"; -import { useAccount } from "wagmi"; -import { useAbiNinjaState, useGlobalState } from "~~/services/store/store"; -import { ChainWithAttributes } from "~~/utils/scaffold-eth"; -import { NETWORKS_EXTRA_DATA } from "~~/utils/scaffold-eth"; - -/** - * Retrieves the connected wallet's network from scaffold.config or defaults to the 0th network in the list if the wallet is not connected. - */ -export function useTargetNetwork(): { targetNetwork: ChainWithAttributes } { - const { chain } = useAccount(); - const targetNetwork = useGlobalState(state => state.targetNetwork); - const setTargetNetwork = useGlobalState(state => state.setTargetNetwork); - const chains = useGlobalState(state => state.chains); - const mainChainId = useAbiNinjaState(state => state.mainChainId); - - useEffect(() => { - const newSelectedNetwork = chains.find(network => network.id === chain?.id || network.id === mainChainId); - if (newSelectedNetwork && newSelectedNetwork.id !== targetNetwork.id) { - setTargetNetwork(newSelectedNetwork); - } - }, [chain?.id, setTargetNetwork, targetNetwork.id, chains, mainChainId]); - - return useMemo( - () => ({ - targetNetwork: { - ...targetNetwork, - ...NETWORKS_EXTRA_DATA[targetNetwork.id], - }, - }), - [targetNetwork], - ); -} diff --git a/packages/nextjs/hooks/scaffold-eth/useWatchBalance.ts b/packages/nextjs/hooks/scaffold-eth/useWatchBalance.ts index 26acda9b..b59612c6 100644 --- a/packages/nextjs/hooks/scaffold-eth/useWatchBalance.ts +++ b/packages/nextjs/hooks/scaffold-eth/useWatchBalance.ts @@ -1,13 +1,13 @@ import { useEffect } from "react"; -import { useTargetNetwork } from "./useTargetNetwork"; import { useQueryClient } from "@tanstack/react-query"; import { UseBalanceParameters, useBalance, useBlockNumber } from "wagmi"; +import { useGlobalState } from "~~/services/store/store"; /** * Wrapper around wagmi's useBalance hook. Updates data on every block change. */ export const useWatchBalance = (useBalanceParameters: UseBalanceParameters) => { - const { targetNetwork } = useTargetNetwork(); + const targetNetwork = useGlobalState(state => state.targetNetwork); const queryClient = useQueryClient(); const { data: blockNumber } = useBlockNumber({ watch: true, chainId: targetNetwork.id }); const { queryKey, ...restUseBalanceReturn } = useBalance(useBalanceParameters); diff --git a/packages/nextjs/pages/[contractAddress]/[network].tsx b/packages/nextjs/pages/[contractAddress]/[network].tsx index 8802e0e4..adbf25dd 100644 --- a/packages/nextjs/pages/[contractAddress]/[network].tsx +++ b/packages/nextjs/pages/[contractAddress]/[network].tsx @@ -11,8 +11,8 @@ import { formDataToChain, storeChainInLocalStorage } from "~~/components/Network import { SwitchTheme } from "~~/components/SwitchTheme"; import { ContractUI } from "~~/components/scaffold-eth"; import useFetchContractAbi from "~~/hooks/useFetchContractAbi"; -import { useAbiNinjaState, useGlobalState } from "~~/services/store/store"; -import { parseAndCorrectJSON } from "~~/utils/abi"; +import { useGlobalState } from "~~/services/store/store"; +import { getNetworkName, parseAndCorrectJSON } from "~~/utils/abi"; import { notification } from "~~/utils/scaffold-eth"; interface ParsedQueryContractDetailsPage extends ParsedUrlQuery { @@ -45,36 +45,23 @@ export const getServerSideProps: GetServerSideProps = async context => { }; }; -const toCamelCase = (str: string) => { - return str - .replace(/(?:^\w|[A-Z]|\b\w)/g, (word, index) => { - return index === 0 ? word.toLowerCase() : word.toUpperCase(); - }) - .replace(/\s+/g, ""); -}; - const ContractDetailPage = ({ addressFromUrl, chainIdFromUrl }: ServerSideProps) => { const router = useRouter(); const { contractAddress, network } = router.query as ParsedQueryContractDetailsPage; const [localContractAbi, setLocalContractAbi] = useState(""); const [isUseLocalAbi, setIsUseLocalAbi] = useState(false); const [localContractData, setLocalContractData] = useState(null); - const { setMainChainId, chainId, setImplementationAddress, contractAbi } = useAbiNinjaState(state => ({ - setMainChainId: state.setMainChainId, - chainId: state.mainChainId, - setImplementationAddress: state.setImplementationAddress, - contractAbi: state.contractAbi, - })); - - const { addChain, chains } = useGlobalState(state => ({ - addChain: state.addChain, - chains: state.chains, - })); - const getNetworkName = (chainId: number) => { - const chain = Object.values(chains).find(chain => chain.id === chainId); - return chain ? chain.name : "Unknown Network"; - }; + const { chainId, setImplementationAddress, contractAbi, chains, addChain, setTargetNetwork } = useGlobalState( + state => ({ + chains: state.chains, + addChain: state.addChain, + chainId: state.targetNetwork.id, + setTargetNetwork: state.setTargetNetwork, + setImplementationAddress: state.setImplementationAddress, + contractAbi: state.contractAbi, + }), + ); const { contractData: fetchedContractData, @@ -98,20 +85,16 @@ const ContractDetailPage = ({ addressFromUrl, chainIdFromUrl }: ServerSideProps) useEffect(() => { if (network) { - let normalizedNetwork = network.toLowerCase(); - if (normalizedNetwork === "ethereum" || normalizedNetwork === "mainnet") { - normalizedNetwork = "ethereum"; + const chain = Object.values(chains).find(chain => chain.id === parseInt(network)); + if (chain) { + setTargetNetwork(chain); } - - const chain = Object.values(chains).find(chain => toCamelCase(chain.name) === normalizedNetwork); - const parsedNetworkId = chain ? chain.id : parseInt(network); - setMainChainId(parsedNetworkId); } if (implementationAddress) { setImplementationAddress(implementationAddress); } - }, [network, implementationAddress, chains, setMainChainId, setImplementationAddress]); + }, [network, implementationAddress, chains, setTargetNetwork, setImplementationAddress]); const handleUserProvidedAbi = () => { try { @@ -163,7 +146,7 @@ const ContractDetailPage = ({ addressFromUrl, chainIdFromUrl }: ServerSideProps)

{error?.message}

There was an error loading the contract {contractAddress} on{" "} - {getNetworkName(chainId)}. + {getNetworkName(chains, chainId)}.

Make sure the data is correct and you are connected to the right network. Or add the chain/ABI diff --git a/packages/nextjs/pages/blockexplorer/index.tsx b/packages/nextjs/pages/blockexplorer/index.tsx index 7502c7ed..37299870 100644 --- a/packages/nextjs/pages/blockexplorer/index.tsx +++ b/packages/nextjs/pages/blockexplorer/index.tsx @@ -7,12 +7,12 @@ import { PaginationButton } from "~~/components/blockexplorer/PaginationButton"; import { SearchBar } from "~~/components/blockexplorer/SearchBar"; import { TransactionsTable } from "~~/components/blockexplorer/TransactionsTable"; import { useFetchBlocks } from "~~/hooks/scaffold-eth"; -import { useTargetNetwork } from "~~/hooks/scaffold-eth/useTargetNetwork"; +import { useGlobalState } from "~~/services/store/store"; import { notification } from "~~/utils/scaffold-eth"; const Blockexplorer: NextPage = () => { const { blocks, transactionReceipts, currentPage, totalBlocks, setCurrentPage, error } = useFetchBlocks(); - const { targetNetwork } = useTargetNetwork(); + const targetNetwork = useGlobalState(state => state.targetNetwork); useEffect(() => { if (targetNetwork.id === hardhat.id && error) { diff --git a/packages/nextjs/pages/blockexplorer/transaction/[txHash].tsx b/packages/nextjs/pages/blockexplorer/transaction/[txHash].tsx index 7c326933..9910f1b6 100644 --- a/packages/nextjs/pages/blockexplorer/transaction/[txHash].tsx +++ b/packages/nextjs/pages/blockexplorer/transaction/[txHash].tsx @@ -7,7 +7,7 @@ import { usePublicClient } from "wagmi"; import { MetaHeader } from "~~/components/MetaHeader"; import { MiniHeader } from "~~/components/MiniHeader"; import { Address } from "~~/components/scaffold-eth"; -import { useTargetNetwork } from "~~/hooks/scaffold-eth/useTargetNetwork"; +import { useGlobalState } from "~~/services/store/store"; import { decodeTransactionData, getFunctionDetails } from "~~/utils/scaffold-eth"; import { replacer } from "~~/utils/scaffold-eth/common"; @@ -20,7 +20,7 @@ const TransactionPage: NextPage = () => { const [receipt, setReceipt] = useState(); const [functionCalled, setFunctionCalled] = useState(); - const { targetNetwork } = useTargetNetwork(); + const targetNetwork = useGlobalState(state => state.targetNetwork); useEffect(() => { if (txHash && client) { diff --git a/packages/nextjs/pages/index.tsx b/packages/nextjs/pages/index.tsx index 7c4f449d..7c759dc7 100644 --- a/packages/nextjs/pages/index.tsx +++ b/packages/nextjs/pages/index.tsx @@ -13,7 +13,7 @@ import { NetworksDropdown } from "~~/components/NetworksDropdown/NetworksDropdow import { SwitchTheme } from "~~/components/SwitchTheme"; import { AddressInput } from "~~/components/scaffold-eth"; import useFetchContractAbi from "~~/hooks/useFetchContractAbi"; -import { useAbiNinjaState } from "~~/services/store/store"; +import { useGlobalState } from "~~/services/store/store"; import { parseAndCorrectJSON } from "~~/utils/abi"; import { HEIMDALL_API_URL } from "~~/utils/constants"; import { notification } from "~~/utils/scaffold-eth"; @@ -36,7 +36,7 @@ const Home: NextPage = () => { chainId: parseInt(network), }); - const { setContractAbi, setAbiContractAddress, setImplementationAddress } = useAbiNinjaState(state => ({ + const { setContractAbi, setAbiContractAddress, setImplementationAddress } = useGlobalState(state => ({ setContractAbi: state.setContractAbi, setAbiContractAddress: state.setAbiContractAddress, setImplementationAddress: state.setImplementationAddress, diff --git a/packages/nextjs/scaffold.config.ts b/packages/nextjs/scaffold.config.ts index 1216506a..0ad26307 100644 --- a/packages/nextjs/scaffold.config.ts +++ b/packages/nextjs/scaffold.config.ts @@ -22,7 +22,6 @@ const scaffoldConfig = { chains.arbitrum, chains.gnosis, chains.zkSync, - chains.zkSyncTestnet, chains.scroll, chains.scrollSepolia, chains.hardhat, diff --git a/packages/nextjs/services/store/store.ts b/packages/nextjs/services/store/store.ts index e35a82c5..f2d2bbbf 100644 --- a/packages/nextjs/services/store/store.ts +++ b/packages/nextjs/services/store/store.ts @@ -1,8 +1,8 @@ import { wagmiConnectors } from "../web3/wagmiConnectors"; import { Abi, Address, Chain } from "viem"; +import { mainnet } from "viem/chains"; import { Config, createConfig } from "wagmi"; import create from "zustand"; -import scaffoldConfig from "~~/scaffold.config"; import { baseWagmiConfig, createWagmiClient, enabledChains } from "~~/services/web3/baseWagmiConfig"; import { ChainWithAttributes } from "~~/utils/scaffold-eth"; @@ -16,11 +16,6 @@ type GlobalState = { chains: Chain[]; addChain: (newChain: Chain) => void; removeChain: (chainId: number) => void; -}; - -type AbiNinjaState = { - mainChainId: number; - setMainChainId: (newMainChainId: number) => void; contractAbi: Abi; setContractAbi: (newAbi: Abi) => void; abiContractAddress: Address | ""; @@ -32,7 +27,7 @@ type AbiNinjaState = { export const useGlobalState = create(set => ({ nativeCurrencyPrice: 0, setNativeCurrencyPrice: (newValue: number): void => set(() => ({ nativeCurrencyPrice: newValue })), - targetNetwork: scaffoldConfig.targetNetworks[1], + targetNetwork: mainnet, setTargetNetwork: (newTargetNetwork: ChainWithAttributes) => set(() => ({ targetNetwork: newTargetNetwork })), wagmiConfig: baseWagmiConfig, setWagmiConfig: (newConfig: Config): void => set(() => ({ wagmiConfig: newConfig })), @@ -62,11 +57,6 @@ export const useGlobalState = create(set => ({ }); return { chains: updatedChains, wagmiConfig: updatedWagmiConfig }; }), -})); - -export const useAbiNinjaState = create(set => ({ - mainChainId: scaffoldConfig.targetNetworks[0].id, - setMainChainId: (newValue: number): void => set(() => ({ mainChainId: newValue })), contractAbi: [], setContractAbi: (newAbi: Abi): void => set({ contractAbi: newAbi }), abiContractAddress: "", diff --git a/packages/nextjs/utils/abi.ts b/packages/nextjs/utils/abi.ts index b33e267c..77ab6f0b 100644 --- a/packages/nextjs/utils/abi.ts +++ b/packages/nextjs/utils/abi.ts @@ -1,5 +1,5 @@ import { isZeroAddress } from "./scaffold-eth/common"; -import { Address } from "viem"; +import { Address, Chain } from "viem"; export const fetchContractABIFromEtherscan = async (verifiedContractAddress: Address, chainId: number) => { const apiKey = process.env.NEXT_PUBLIC_ETHERSCAN_V2_API_KEY; @@ -56,3 +56,8 @@ export function parseAndCorrectJSON(input: string): any { throw new Error("Failed to parse JSON"); } } + +export const getNetworkName = (chains: Chain[], chainId: number) => { + const chain = chains.find(chain => chain.id === chainId); + return chain ? chain.name : "Unknown Network"; +}; diff --git a/packages/nextjs/utils/scaffold-eth/fetchPriceFromUniswap.ts b/packages/nextjs/utils/scaffold-eth/fetchPriceFromUniswap.ts index 2a5ab560..64d9711b 100644 --- a/packages/nextjs/utils/scaffold-eth/fetchPriceFromUniswap.ts +++ b/packages/nextjs/utils/scaffold-eth/fetchPriceFromUniswap.ts @@ -16,6 +16,9 @@ const ABI = parseAbi([ ]); export const fetchPriceFromUniswap = async (targetNetwork: ChainWithAttributes): Promise => { + if (!targetNetwork?.nativeCurrency) { + return 0; + } if ( targetNetwork.nativeCurrency.symbol !== "ETH" && targetNetwork.nativeCurrency.symbol !== "SEP" && From a76f18788ba4108fa50121d04843273efca2e1d1 Mon Sep 17 00:00:00 2001 From: Shiv Bhonde Date: Tue, 3 Dec 2024 12:31:02 +0530 Subject: [PATCH 2/4] remove extra useEffect and update selected chain in handler --- .../components/NetworksDropdown/NetworksDropdown.tsx | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/packages/nextjs/components/NetworksDropdown/NetworksDropdown.tsx b/packages/nextjs/components/NetworksDropdown/NetworksDropdown.tsx index e796e8cf..e3470376 100644 --- a/packages/nextjs/components/NetworksDropdown/NetworksDropdown.tsx +++ b/packages/nextjs/components/NetworksDropdown/NetworksDropdown.tsx @@ -32,13 +32,6 @@ export const NetworksDropdown = ({ onChange }: { onChange: (options: any) => any chains: state.chains, })); - useEffect(() => { - if (selectedOption) { - const chain = Object.values(chains).find(chain => chain.id === selectedOption.value); - setTargetNetwork(chain as Chain); - } - }, [selectedOption, setTargetNetwork, chains]); - const seeOtherChainsModalRef = useRef(null); const customChainModalRef = useRef(null); @@ -91,6 +84,10 @@ export const NetworksDropdown = ({ onChange }: { onChange: (options: any) => any } } else { setSelectedOption(selected); + if (selected) { + const chain = Object.values(chains).find(chain => chain.id === selected.value); + setTargetNetwork(chain as Chain); + } onChange(selected); } }; From c0b0d9ccda2cc28da344ed82ea7c4402f853fe82 Mon Sep 17 00:00:00 2001 From: Shiv Bhonde Date: Tue, 3 Dec 2024 12:32:44 +0530 Subject: [PATCH 3/4] remove console.log in AddCustomChainModal --- .../nextjs/components/NetworksDropdown/AddCustomChainModal.tsx | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/nextjs/components/NetworksDropdown/AddCustomChainModal.tsx b/packages/nextjs/components/NetworksDropdown/AddCustomChainModal.tsx index 89bb311c..fbde66a9 100644 --- a/packages/nextjs/components/NetworksDropdown/AddCustomChainModal.tsx +++ b/packages/nextjs/components/NetworksDropdown/AddCustomChainModal.tsx @@ -53,7 +53,6 @@ export const AddCustomChainModal = forwardRef Date: Tue, 3 Dec 2024 12:46:20 +0530 Subject: [PATCH 4/4] udpate test-app.yaml --- .github/workflows/test-app.yaml | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/.github/workflows/test-app.yaml b/.github/workflows/test-app.yaml index 6e887087..d982c52c 100644 --- a/.github/workflows/test-app.yaml +++ b/.github/workflows/test-app.yaml @@ -18,15 +18,8 @@ jobs: - name: Create .env.local in nextjs run: | touch packages/nextjs/.env.local - echo NEXT_PUBLIC_GNOSIS_ETHERSCAN_API_KEY=${{ secrets.NEXT_PUBLIC_GNOSIS_ETHERSCAN_API_KEY }} >> packages/nextjs/.env.local - echo NEXT_PUBLIC_BSC_ETHERSCAN_API_KEY=${{ secrets.NEXT_PUBLIC_BSC_ETHERSCAN_API_KEY }} >> packages/nextjs/.env.local echo NEXT_PUBLIC_HEIMDALL_URL=${{ secrets.NEXT_PUBLIC_HEIMDALL_URL }} >> packages/nextjs/.env.local - echo NEXT_PUBLIC_BASE_ETHERSCAN_API_KEY=${{ secrets.NEXT_PUBLIC_BASE_ETHERSCAN_API_KEY }} >> packages/nextjs/.env.local - echo NEXT_PUBLIC_SCROLL_ETHERSCAN_API_KEY=${{ secrets.NEXT_PUBLIC_SCROLL_ETHERSCAN_API_KEY }} >> packages/nextjs/.env.local - echo NEXT_PUBLIC_OPTIMISM_ETHERSCAN_API_KEY=${{ secrets.NEXT_PUBLIC_OPTIMISM_ETHERSCAN_API_KEY }} >> packages/nextjs/.env.local - echo NEXT_PUBLIC_MAINNET_ETHERSCAN_API_KEY=${{ secrets.NEXT_PUBLIC_MAINNET_ETHERSCAN_API_KEY }} >> packages/nextjs/.env.local - echo NEXT_PUBLIC_POLYGON_ETHERSCAN_API_KEY=${{ secrets.NEXT_PUBLIC_POLYGON_ETHERSCAN_API_KEY }} >> packages/nextjs/.env.local - echo NEXT_PUBLIC_ARBITRUM_ETHERSCAN_API_KEY=${{ secrets.NEXT_PUBLIC_ARBITRUM_ETHERSCAN_API_KEY }} >> packages/nextjs/.env.local + echo NEXT_PUBLIC_ETHERSCAN_V2_API_KEY=${{ secrets.NEXT_PUBLIC_ETHERSCAN_V2_API_KEY }} >> packages/nextjs/.env.local - name: Cypress run uses: cypress-io/github-action@v6