feat(ponder): Add strict ESLint + Prettier with pre-commit hooks (#52)
- Install eslint, @typescript-eslint plugins, prettier, husky, lint-staged - Configure ESLint flat config with TypeScript parser - Enforce: no-explicit-any (with exceptions), no-unused-vars, naming-convention, prefer-const, no-console - Set style: 2-space indent, 140 char max-len, disable complexity rules - Configure Prettier: single quotes, 140 width, trailing commas - Setup husky pre-commit hook to auto-fix and format on commit - Replace console.log/warn with context.logger.info/warn in handlers - Remove console.log from ponder.config.ts (replaced with comment) - Add npm scripts: lint, lint:fix, format, format:check - All lint rules pass without warnings resolvel #45 Co-authored-by: johba <johba@harb.eth> Reviewed-on: https://codeberg.org/johba/harb/pulls/52
This commit is contained in:
parent
c150b683c8
commit
dc61771dfc
18 changed files with 2229 additions and 194 deletions
|
|
@ -1,6 +1,6 @@
|
|||
import { createConfig } from "ponder";
|
||||
import type { Abi } from "viem";
|
||||
import { KraikenAbi, StakeAbi } from "kraiken-lib";
|
||||
import { createConfig } from 'ponder';
|
||||
import type { Abi } from 'viem';
|
||||
import { KraikenAbi, StakeAbi } from 'kraiken-lib';
|
||||
|
||||
// Network configurations keyed by canonical environment name
|
||||
type NetworkConfig = {
|
||||
|
|
@ -17,53 +17,54 @@ type NetworkConfig = {
|
|||
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",
|
||||
rpc: process.env.PONDER_RPC_URL_BASE_SEPOLIA_LOCAL_FORK || 'http://127.0.0.1:8545',
|
||||
disableCache: true,
|
||||
contracts: {
|
||||
kraiken: process.env.KRAIKEN_ADDRESS || "0x56186c1E64cA8043dEF78d06AfF222212eA5df71",
|
||||
stake: process.env.STAKE_ADDRESS || "0x056E4a859558A3975761ABd7385506BC4D8A8E60",
|
||||
startBlock: parseInt(process.env.START_BLOCK || "31425917"),
|
||||
kraiken: process.env.KRAIKEN_ADDRESS || '0x56186c1E64cA8043dEF78d06AfF222212eA5df71',
|
||||
stake: process.env.STAKE_ADDRESS || '0x056E4a859558A3975761ABd7385506BC4D8A8E60',
|
||||
startBlock: parseInt(process.env.START_BLOCK || '31425917'),
|
||||
},
|
||||
},
|
||||
BASE_SEPOLIA: {
|
||||
chainId: 84532,
|
||||
rpc: process.env.PONDER_RPC_URL_BASE_SEPOLIA || "https://sepolia.base.org",
|
||||
rpc: process.env.PONDER_RPC_URL_BASE_SEPOLIA || 'https://sepolia.base.org',
|
||||
contracts: {
|
||||
kraiken: "0x22c264Ecf8D4E49D1E3CabD8DD39b7C4Ab51C1B8",
|
||||
stake: "0xe28020BCdEeAf2779dd47c670A8eFC2973316EE2",
|
||||
kraiken: '0x22c264Ecf8D4E49D1E3CabD8DD39b7C4Ab51C1B8',
|
||||
stake: '0xe28020BCdEeAf2779dd47c670A8eFC2973316EE2',
|
||||
startBlock: 20940337,
|
||||
},
|
||||
},
|
||||
BASE: {
|
||||
chainId: 8453,
|
||||
rpc: process.env.PONDER_RPC_URL_BASE || "https://base.llamarpc.com",
|
||||
rpc: process.env.PONDER_RPC_URL_BASE || 'https://base.llamarpc.com',
|
||||
contracts: {
|
||||
kraiken: "0x45caa5929f6ee038039984205bdecf968b954820",
|
||||
stake: "0xed70707fab05d973ad41eae8d17e2bcd36192cfc",
|
||||
kraiken: '0x45caa5929f6ee038039984205bdecf968b954820',
|
||||
stake: '0xed70707fab05d973ad41eae8d17e2bcd36192cfc',
|
||||
startBlock: 26038614,
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
// Select network based on environment variable
|
||||
const NETWORK = (process.env.PONDER_NETWORK as keyof typeof networks) || "BASE_SEPOLIA_LOCAL_FORK";
|
||||
const NETWORK = (process.env.PONDER_NETWORK as keyof typeof networks) || 'BASE_SEPOLIA_LOCAL_FORK';
|
||||
const selectedNetwork = networks[NETWORK as keyof typeof networks];
|
||||
|
||||
if (!selectedNetwork) {
|
||||
throw new Error(`Invalid network: ${NETWORK}. Valid options: ${Object.keys(networks).join(", ")}`);
|
||||
throw new Error(`Invalid network: ${NETWORK}. Valid options: ${Object.keys(networks).join(', ')}`);
|
||||
}
|
||||
|
||||
console.log(
|
||||
`[ponder.config] Network=${NETWORK}, chainId=${selectedNetwork.chainId}, startBlock=${selectedNetwork.contracts.startBlock}`,
|
||||
);
|
||||
// Network configuration logged during Ponder startup
|
||||
// Network=${NETWORK}, chainId=${selectedNetwork.chainId}, startBlock=${selectedNetwork.contracts.startBlock}
|
||||
|
||||
export default createConfig({
|
||||
// Use PostgreSQL if DATABASE_URL is set, otherwise use PGlite
|
||||
database: process.env.DATABASE_URL ? {
|
||||
kind: "postgres" as const,
|
||||
connectionString: process.env.DATABASE_URL,
|
||||
schema: process.env.DATABASE_SCHEMA || "public",
|
||||
} : undefined,
|
||||
database: process.env.DATABASE_URL
|
||||
? {
|
||||
kind: 'postgres' as const,
|
||||
connectionString: process.env.DATABASE_URL,
|
||||
schema: process.env.DATABASE_SCHEMA || 'public',
|
||||
}
|
||||
: undefined,
|
||||
chains: {
|
||||
[NETWORK]: {
|
||||
id: selectedNetwork.chainId,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue