diff --git a/package.json b/package.json index 6d980ea..977a154 100644 --- a/package.json +++ b/package.json @@ -13,8 +13,8 @@ "lint:fix": "eslint . --fix", "format": "prettier --write \"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", - "prewagmi:gen": "bun run contracts:compile", + "contracts:setup": "pushd p2pix-smart-contracts && bun install && ([ -f .env ] || echo 'ALCHEMY_API_KEY=placeholder' > .env) && popd", + "prewagmi:gen": "bun run contracts:setup", "wagmi:gen": "bun ./node_modules/@wagmi/cli/dist/esm/cli.js generate" }, "dependencies": { diff --git a/wagmi.config.ts b/wagmi.config.ts index 157357e..bf1f610 100644 --- a/wagmi.config.ts +++ b/wagmi.config.ts @@ -1,30 +1,12 @@ import { defineConfig } from '@wagmi/cli'; -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[]; -}; +import { hardhat } from '@wagmi/cli/plugins'; export default defineConfig({ out: 'src/blockchain/abi.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, - }, + contracts: [], + plugins: [ + hardhat({ + project: 'p2pix-smart-contracts', + }), ], });