Removes the barrel export pattern in favor of explicit subpath imports
for better tree-shaking and clearer dependencies.
## Breaking Changes
- Removed `src/helpers.ts` barrel export
- Removed `./helpers` from package.json exports
- Root `kraiken-lib` import now raises build errors
- Consumers MUST use explicit subpaths:
- `kraiken-lib/abis` - Contract ABIs
- `kraiken-lib/staking` - Staking helpers
- `kraiken-lib/snatch` - Snatch selection
- `kraiken-lib/ids` - Position ID utilities
- `kraiken-lib/subgraph` - Byte conversion utilities
- `kraiken-lib/taxRates` - Tax rate constants
- `kraiken-lib/version` - Version validation
## Changes
- kraiken-lib:
- Bumped version to 1.0.0 (breaking change)
- Updated src/index.ts to raise build errors
- Added backward-compatible ABI aliases (KraikenAbi, StakeAbi)
- Updated all test files to use .js extensions and new imports
- Updated documentation (README, AGENTS.md)
- Consumer updates:
- services/ponder: Updated ponder.config.ts to use kraiken-lib/abis
- web-app: Updated all imports to use subpaths
- composables/usePositions.ts: kraiken-lib/subgraph
- contracts/harb.ts: kraiken-lib/abis
- contracts/stake.ts: kraiken-lib/abis
## Migration Guide
```typescript
// OLD
import { getSnatchList } from 'kraiken-lib/helpers';
import { KraikenAbi } from 'kraiken-lib';
// NEW
import { getSnatchList } from 'kraiken-lib/snatch';
import { KraikenAbi } from 'kraiken-lib/abis';
```
Fixes #86
Co-authored-by: openhands <openhands@all-hands.dev>
Reviewed-on: https://codeberg.org/johba/harb/pulls/89
96 lines
2.9 KiB
TypeScript
96 lines
2.9 KiB
TypeScript
import { createConfig } from 'ponder';
|
|
import type { Abi } from 'viem';
|
|
import { KraikenAbi, StakeAbi } from 'kraiken-lib/abis';
|
|
|
|
// Network configurations keyed by canonical environment name
|
|
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',
|
|
disableCache: true,
|
|
contracts: {
|
|
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',
|
|
contracts: {
|
|
kraiken: '0x22c264Ecf8D4E49D1E3CabD8DD39b7C4Ab51C1B8',
|
|
stake: '0xe28020BCdEeAf2779dd47c670A8eFC2973316EE2',
|
|
startBlock: 20940337,
|
|
},
|
|
},
|
|
BASE: {
|
|
chainId: 8453,
|
|
rpc: process.env.PONDER_RPC_URL_BASE || 'https://base.llamarpc.com',
|
|
contracts: {
|
|
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 selectedNetwork = networks[NETWORK as keyof typeof networks];
|
|
|
|
if (!selectedNetwork) {
|
|
throw new Error(`Invalid network: ${NETWORK}. Valid options: ${Object.keys(networks).join(', ')}`);
|
|
}
|
|
|
|
// 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,
|
|
chains: {
|
|
[NETWORK]: {
|
|
id: selectedNetwork.chainId,
|
|
rpc: selectedNetwork.rpc,
|
|
disableCache: selectedNetwork.disableCache ?? false,
|
|
},
|
|
},
|
|
contracts: {
|
|
Kraiken: {
|
|
abi: KraikenAbi satisfies Abi,
|
|
chain: NETWORK,
|
|
address: selectedNetwork.contracts.kraiken as `0x${string}`,
|
|
startBlock: selectedNetwork.contracts.startBlock,
|
|
},
|
|
Stake: {
|
|
abi: StakeAbi satisfies Abi,
|
|
chain: NETWORK,
|
|
address: selectedNetwork.contracts.stake as `0x${string}`,
|
|
startBlock: selectedNetwork.contracts.startBlock,
|
|
},
|
|
},
|
|
blocks: {
|
|
StatsBlock: {
|
|
chain: NETWORK,
|
|
interval: 1,
|
|
startBlock: selectedNetwork.contracts.startBlock,
|
|
},
|
|
},
|
|
});
|