refactor: migrate kraiken-lib to explicit subpath imports (BREAKING CHANGE) (#89)
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
This commit is contained in:
parent
1c6f118f6b
commit
a555a2fdd1
18 changed files with 74 additions and 74 deletions
|
|
@ -2,15 +2,39 @@ import {
|
|||
runAllHealthChecks,
|
||||
formatHealthCheckError,
|
||||
} from './health-checks.js';
|
||||
import { readFileSync } from 'fs';
|
||||
import { join } from 'path';
|
||||
|
||||
const DEFAULT_RPC_URL = 'http://localhost:8081/api/rpc';
|
||||
const DEFAULT_WEBAPP_URL = 'http://localhost:8081';
|
||||
const DEFAULT_GRAPHQL_URL = 'http://localhost:8081/api/graphql';
|
||||
|
||||
export interface ContractAddresses {
|
||||
Kraiken: string;
|
||||
Stake: string;
|
||||
LiquidityManager: string;
|
||||
}
|
||||
|
||||
export interface StackConfig {
|
||||
rpcUrl: string;
|
||||
webAppUrl: string;
|
||||
graphqlUrl: string;
|
||||
contracts: ContractAddresses;
|
||||
}
|
||||
|
||||
/**
|
||||
* Load contract addresses from deployments file
|
||||
*/
|
||||
function loadContractAddresses(): ContractAddresses {
|
||||
try {
|
||||
const deploymentsPath = join(process.cwd(), 'onchain', 'deployments-local.json');
|
||||
const deploymentsJson = readFileSync(deploymentsPath, 'utf-8');
|
||||
const deployments = JSON.parse(deploymentsJson);
|
||||
return deployments.contracts;
|
||||
} catch (error) {
|
||||
console.error('Failed to load contract addresses from deployments-local.json:', error);
|
||||
throw new Error('Cannot run tests without deployed contract addresses');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -22,6 +46,7 @@ export function getStackConfig(): StackConfig {
|
|||
rpcUrl: process.env.STACK_RPC_URL ?? DEFAULT_RPC_URL,
|
||||
webAppUrl: process.env.STACK_WEBAPP_URL ?? DEFAULT_WEBAPP_URL,
|
||||
graphqlUrl: process.env.STACK_GRAPHQL_URL ?? DEFAULT_GRAPHQL_URL,
|
||||
contracts: loadContractAddresses(),
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue