- wagmi.config.ts: read ABIs from p2pix-smart-contracts/artifacts/contracts (P2Pix, Reputation, MockToken) and emit src/generated.ts with the @wagmi/cli actions plugin - package.json: add scripts * contracts:compile — installs submodule deps + runs `hardhat compile` * wagmi:gen — runs @wagmi/cli to (re)generate src/generated.ts * prewagmi:gen — chains contracts:compile before wagmi:gen * prestart — runs wagmi:gen, so `bun start` always has fresh ABIs - .gitignore: ignore src/generated.ts (regenerated on every prestart) Note: GraphQL/subgraph codegen is intentionally out of scope here — it will land in its own branch.
33 lines
822 B
TypeScript
33 lines
822 B
TypeScript
import { defineConfig } from '@wagmi/cli';
|
|
import { actions } from '@wagmi/cli/plugins';
|
|
import { readFileSync } from 'node:fs';
|
|
import { resolve } from 'node:path';
|
|
|
|
const artifactsRoot = resolve(
|
|
__dirname,
|
|
'p2pix-smart-contracts/artifacts/contracts',
|
|
);
|
|
|
|
const loadAbi = (relPath: string) => {
|
|
const json = JSON.parse(
|
|
readFileSync(resolve(artifactsRoot, relPath), 'utf8'),
|
|
);
|
|
return json.abi as readonly unknown[];
|
|
};
|
|
|
|
export default defineConfig({
|
|
out: 'src/generated.ts',
|
|
contracts: [
|
|
{ name: 'P2Pix', abi: loadAbi('p2pix.sol/P2PIX.json') as never },
|
|
{
|
|
name: 'Reputation',
|
|
abi: loadAbi('Reputation.sol/Reputation.json') as never,
|
|
},
|
|
{
|
|
name: 'MockToken',
|
|
abi: loadAbi('lib/mock/mockToken.sol/MockToken.json') as never,
|
|
},
|
|
],
|
|
plugins: [actions()],
|
|
});
|