chore(codegen): restore minimal wagmi.config.ts (hardhat plugin)
Reverts wagmi.config.ts to the pre-existing simpler shape (hardhat
plugin auto-discovers artifacts) and drops our hand-rolled readFileSync
bootstrap. The plugin emits ABIs for every compiled contract; unused
ones are tree-shaken out of the production bundle, and the file itself
is gitignored so the extra bytes never hit the repo.
The plugin runs `npx hardhat compile` internally, which loads
hardhat.config.ts at import time and throws when ALCHEMY_API_KEY is
missing — env vars from our wrapper script don't propagate into the
plugin's subprocess. Fix: prewagmi:gen now bootstraps a placeholder
.env inside the submodule (gitignored there via *.env), instead of
running our own `hardhat compile` with inline env vars.
- wagmi.config.ts: hardhat({ project: 'p2pix-smart-contracts' }), no
explicit contracts/loadAbi
- package.json: contracts:compile -> contracts:setup
(bun install + create .env if absent); the wagmi hardhat plugin
handles the actual compile
This commit is contained in:
@@ -13,8 +13,8 @@
|
|||||||
"lint:fix": "eslint . --fix",
|
"lint:fix": "eslint . --fix",
|
||||||
"format": "prettier --write \"src/**/*.{ts,vue,json}\"",
|
"format": "prettier --write \"src/**/*.{ts,vue,json}\"",
|
||||||
"format:check": "prettier --check \"src/**/*.{ts,vue,json}\"",
|
"format:check": "prettier --check \"src/**/*.{ts,vue,json}\"",
|
||||||
"contracts:compile": "pushd p2pix-smart-contracts && bun install && ALCHEMY_API_KEY=placeholder MNEMONIC='test test test test test test test test test test test junk' bunx hardhat compile && popd",
|
"contracts:setup": "pushd p2pix-smart-contracts && bun install && ([ -f .env ] || echo 'ALCHEMY_API_KEY=placeholder' > .env) && popd",
|
||||||
"prewagmi:gen": "bun run contracts:compile",
|
"prewagmi:gen": "bun run contracts:setup",
|
||||||
"wagmi:gen": "bun ./node_modules/@wagmi/cli/dist/esm/cli.js generate"
|
"wagmi:gen": "bun ./node_modules/@wagmi/cli/dist/esm/cli.js generate"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
|||||||
@@ -1,30 +1,12 @@
|
|||||||
import { defineConfig } from '@wagmi/cli';
|
import { defineConfig } from '@wagmi/cli';
|
||||||
import { readFileSync } from 'node:fs';
|
import { hardhat } from '@wagmi/cli/plugins';
|
||||||
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({
|
export default defineConfig({
|
||||||
out: 'src/blockchain/abi.ts',
|
out: 'src/blockchain/abi.ts',
|
||||||
contracts: [
|
contracts: [],
|
||||||
{ name: 'P2Pix', abi: loadAbi('p2pix.sol/P2PIX.json') as never },
|
plugins: [
|
||||||
{
|
hardhat({
|
||||||
name: 'Reputation',
|
project: 'p2pix-smart-contracts',
|
||||||
abi: loadAbi('Reputation.sol/Reputation.json') as never,
|
}),
|
||||||
},
|
|
||||||
{
|
|
||||||
name: 'MockToken',
|
|
||||||
abi: loadAbi('lib/mock/mockToken.sol/MockToken.json') as never,
|
|
||||||
},
|
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user