|
1 | 1 | import { createConfig } from "ponder"; |
2 | 2 | // Use deployed ABIs to avoid drift with contracts |
3 | 3 | import { easGetAttestationAbi } from "./abis/EASAbi"; |
4 | | -import MarketplaceDeployment from "../hardhat/deployments/base/Marketplace.json" assert { type: "json" }; |
| 4 | +import MarketplaceDeploymentBase from "../hardhat/deployments/base/Marketplace.json" assert { type: "json" }; |
| 5 | +import MarketplaceDeploymentHardhat from "../hardhat/deployments/localhost/Marketplace.json" assert { type: "json" }; |
5 | 6 | import EASConfig from "./src/easConfig.json" assert { type: "json" }; |
6 | 7 | import { Abi } from "viem"; |
7 | 8 |
|
| 9 | +const CHAIN_ID = Number(process.env.PONDER_CHAIN_ID ?? 8453); |
| 10 | +const CHAIN_NAME = CHAIN_ID === 31337 ? "hardhat" : "base"; |
| 11 | +const EASConfigForChain = EASConfig[String(CHAIN_ID) as keyof typeof EASConfig]; |
| 12 | +const MarketplaceDeploymentForChain = CHAIN_ID === 31337 ? MarketplaceDeploymentHardhat : MarketplaceDeploymentBase; |
| 13 | + |
8 | 14 | export default createConfig({ |
9 | 15 | chains: { |
10 | | - base: { |
11 | | - id: 8453, |
12 | | - rpc: process.env.PONDER_RPC_URL_8453 ?? "https://base.llamarpc.com", |
| 16 | + [CHAIN_NAME]: { |
| 17 | + id: Number(process.env.PONDER_CHAIN_ID ?? 8453), |
| 18 | + rpc: process.env[`PONDER_RPC_URL_${process.env.PONDER_CHAIN_ID}`] ?? "https://base.llamarpc.com", |
13 | 19 | }, |
14 | 20 | }, |
15 | 21 | contracts: { |
16 | 22 | Marketplace: { |
17 | | - chain: "base", |
18 | | - abi: MarketplaceDeployment.abi as Abi, |
19 | | - address: MarketplaceDeployment.address as `0x${string}`, |
20 | | - startBlock: MarketplaceDeployment.receipt.blockNumber, |
| 23 | + chain: CHAIN_NAME, |
| 24 | + abi: MarketplaceDeploymentForChain.abi as Abi, |
| 25 | + address: MarketplaceDeploymentForChain.address as `0x${string}`, |
| 26 | + startBlock: MarketplaceDeploymentForChain.receipt.blockNumber, |
21 | 27 | }, |
22 | 28 | // Index EAS core contract using the deployed ABI to match emitted events |
23 | 29 | EAS: { |
24 | | - chain: "base", |
| 30 | + chain: CHAIN_NAME, |
25 | 31 | abi: easGetAttestationAbi, |
26 | | - address: EASConfig["8453"].eas as `0x${string}`, |
27 | | - startBlock: MarketplaceDeployment.receipt.blockNumber, |
| 32 | + address: EASConfigForChain.eas as `0x${string}`, |
| 33 | + startBlock: MarketplaceDeploymentForChain.receipt.blockNumber, |
28 | 34 | }, |
29 | 35 | }, |
30 | 36 | }); |
0 commit comments