Skip to content

Commit

Permalink
add base zkSycn and scroll
Browse files Browse the repository at this point in the history
  • Loading branch information
technophile-04 committed Feb 8, 2024
1 parent 11f19ec commit 20d66bf
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 7 deletions.
6 changes: 6 additions & 0 deletions packages/nextjs/scaffold.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,16 @@ const scaffoldConfig = {
chains.goerli,
chains.optimism,
chains.optimismGoerli,
chains.base,
chains.baseSepolia,
chains.polygon,
chains.polygonMumbai,
chains.arbitrum,
chains.gnosis,
chains.zkSync,
chains.zkSyncTestnet,
chains.scroll,
chains.scrollSepolia,
],

// The interval at which your front-end polls the RPC servers for new data
Expand Down
6 changes: 3 additions & 3 deletions packages/nextjs/utils/abi.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { NETWORKS_EXTRA_DATA } from "./scaffold-eth";
import { NETWORKS_EXTRA_DATA, getTargetNetworks } from "./scaffold-eth";

export const fetchContractABIFromAnyABI = async (verifiedContractAddress: string, chainId: number) => {
const chain = NETWORKS_EXTRA_DATA[chainId];
const chain = getTargetNetworks().find(network => network.id === chainId);

if (!chain) throw new Error(`ChainId ${chainId} not found in supported networks`);

Expand All @@ -21,7 +21,7 @@ export const fetchContractABIFromEtherscan = async (verifiedContractAddress: str
const chain = NETWORKS_EXTRA_DATA[chainId];

if (!chain || (chain && !chain.etherscanApiKey) || !chain.etherscanEndpoint)
throw new Error(`ChainId ${chainId} not found in supported networks`);
throw new Error(`ChainId ${chainId} not found in supported etherscan networks`);

const apiKey = chain.etherscanApiKey;
const url = `${chain.etherscanEndpoint}/api?module=contract&action=getabi&address=${verifiedContractAddress}&apikey=${apiKey}`;
Expand Down
31 changes: 27 additions & 4 deletions packages/nextjs/utils/scaffold-eth/networks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ const MAINNET_ETHERSCAN_API_KEY = process.env.NEXT_PUBLIC_ETHERSCAN_API_KEY || "
const OPTIMISM_ETHERSCAN_API_KEY = process.env.NEXT_PUBLIC_OPTIMISM_ETHERSCAN_API_KEY || "";
const POLYGON_ETHERSCAN_API_KEY = process.env.NEXT_PUBLIC_POLYGON_ETHERSCAN_API_KEY || "";
const ARBITRUM_ETHERSCAN_API_KEY = process.env.NEXT_PUBLIC_ARBITRUM_ETHERSCAN_API_KEY || "";
const ZKSYNC_ETHERSCAN_API_KEY = process.env.NEXT_PUBLIC_ZKSYNC_ETHERSCAN_API_KEY || "";
const BASE_ETHERSCAN_API_KEY = process.env.NEXT_PUBLIC_BASE_ETHERSCAN_API_KEY || "";
const SCROLL_ETHERSCAN_API_KEY = process.env.NEXT_PUBLIC_SCROLL_ETHERSCAN_API_KEY || "";

export const NETWORKS_EXTRA_DATA: Record<string, ChainAttributes> = {
[chains.hardhat.id]: {
Expand Down Expand Up @@ -72,14 +75,34 @@ export const NETWORKS_EXTRA_DATA: Record<string, ChainAttributes> = {
etherscanEndpoint: "https://api.arbiscan.io",
etherscanApiKey: ARBITRUM_ETHERSCAN_API_KEY,
},
[chains.fantom.id]: {
color: "#1969ff",
[chains.zkSync.id]: {
color: "#5f4bb6",
etherscanEndpoint: "https://block-explorer-api.mainnet.zksync.io",
etherscanApiKey: ZKSYNC_ETHERSCAN_API_KEY,
},
[chains.fantomTestnet.id]: {
color: "#1969ff",
[chains.zkSyncTestnet.id]: {
color: "#5f4bb6",
etherscanEndpoint: "https://block-explorer-api.testnets.zksync.dev",
etherscanApiKey: ZKSYNC_ETHERSCAN_API_KEY,
},
[chains.base.id]: {
color: "#1450EE",
etherscanEndpoint: "https://api-sepolia.basescan.org",
etherscanApiKey: BASE_ETHERSCAN_API_KEY,
},
[chains.baseSepolia.id]: {
color: "#1450EE",
etherscanApiKey: BASE_ETHERSCAN_API_KEY,
},
[chains.scroll.id]: {
color: "#fbebd4",
etherscanEndpoint: "https://api.scrollscan.com",
etherscanApiKey: SCROLL_ETHERSCAN_API_KEY,
},
[chains.scrollSepolia.id]: {
color: "#fbebd4",
etherscanEndpoint: "https://api-sepolia.scrollscan.com",
etherscanApiKey: SCROLL_ETHERSCAN_API_KEY,
},
};

Expand Down

0 comments on commit 20d66bf

Please sign in to comment.