feat: add ABI validation helpers for Ponder (#29)
resolves https://codeberg.org/johba/harb/issues/23 Co-authored-by: openhands <openhands@all-hands.dev> Reviewed-on: https://codeberg.org/johba/harb/pulls/29
This commit is contained in:
parent
0eaf91be13
commit
76d84341de
17 changed files with 2105 additions and 49 deletions
|
|
@ -1,10 +1,20 @@
|
|||
import { createConfig } from "ponder";
|
||||
import type { Abi } from "viem";
|
||||
import KraikenAbi from "./abis/Kraiken.json";
|
||||
import StakeAbi from "./abis/Stake.json";
|
||||
import { KraikenAbi, StakeAbi } from "kraiken-lib";
|
||||
|
||||
// Network configurations keyed by canonical environment name
|
||||
const networks = {
|
||||
type NetworkConfig = {
|
||||
chainId: number;
|
||||
rpc: string;
|
||||
disableCache?: boolean;
|
||||
contracts: {
|
||||
kraiken: string;
|
||||
stake: string;
|
||||
startBlock: number;
|
||||
};
|
||||
};
|
||||
|
||||
const networks: Record<string, NetworkConfig> = {
|
||||
BASE_SEPOLIA_LOCAL_FORK: {
|
||||
chainId: 31337,
|
||||
rpc: process.env.PONDER_RPC_URL_BASE_SEPOLIA_LOCAL_FORK || "http://127.0.0.1:8545",
|
||||
|
|
@ -33,7 +43,7 @@ const networks = {
|
|||
startBlock: 26038614,
|
||||
},
|
||||
},
|
||||
} as const;
|
||||
};
|
||||
|
||||
// Select network based on environment variable
|
||||
const NETWORK = (process.env.PONDER_NETWORK as keyof typeof networks) || "BASE_SEPOLIA_LOCAL_FORK";
|
||||
|
|
@ -57,18 +67,18 @@ export default createConfig({
|
|||
[NETWORK]: {
|
||||
id: selectedNetwork.chainId,
|
||||
rpc: selectedNetwork.rpc,
|
||||
disableCache: selectedNetwork.disableCache,
|
||||
disableCache: selectedNetwork.disableCache ?? false,
|
||||
},
|
||||
},
|
||||
contracts: {
|
||||
Kraiken: {
|
||||
abi: KraikenAbi.abi as Abi,
|
||||
abi: KraikenAbi satisfies Abi,
|
||||
chain: NETWORK,
|
||||
address: selectedNetwork.contracts.kraiken as `0x${string}`,
|
||||
startBlock: selectedNetwork.contracts.startBlock,
|
||||
},
|
||||
Stake: {
|
||||
abi: StakeAbi.abi as Abi,
|
||||
abi: StakeAbi satisfies Abi,
|
||||
chain: NETWORK,
|
||||
address: selectedNetwork.contracts.stake as `0x${string}`,
|
||||
startBlock: selectedNetwork.contracts.startBlock,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue