From 131f53a731c815d45a51dc2a37f551df722e7eb5 Mon Sep 17 00:00:00 2001 From: Arthur Abeilice Date: Thu, 21 May 2026 23:35:10 -0300 Subject: [PATCH] feat: add P2PIXProd Ignition module for deploys without MockToken --- README.md | 26 ++++++++++++++++++++++ ignition/modules/P2PIXProd.ts | 31 +++++++++++++++++++++++++++ ignition/parameters/prod.example.json | 8 +++++++ package.json | 1 + 4 files changed, 66 insertions(+) create mode 100644 ignition/modules/P2PIXProd.ts create mode 100644 ignition/parameters/prod.example.json diff --git a/README.md b/README.md index 53c087a..d9bb0c2 100644 --- a/README.md +++ b/README.md @@ -138,6 +138,10 @@ under `ignition/deployments/`. - `ignition/modules/Reputation.ts` — Reputation + Multicall. - `ignition/modules/P2PIX.ts` — wires Reputation + MockToken and deploys P2PIX via its constructor, returning the full set of addresses. +- `ignition/modules/P2PIXProd.ts` — same as `P2PIX.ts` but **does not** + deploy MockToken. Token addresses are passed in via parameters + (`tokens` + `allowed`), so existing on-chain tokens (e.g. BRZ, USDC) + can be wired directly. ### Per-network parameters @@ -174,3 +178,25 @@ yarn deploy:mumbai Each command requires the matching `ignition/parameters/.json` and the relevant API keys in `.env`. + +### Deploying without MockToken (production / real tokens) + +Use the `P2PIXProd` module when the target network already has the ERC20 +tokens you want P2PIX to support — no MockToken is deployed. + +1. Copy `ignition/parameters/prod.example.json` to + `ignition/parameters/.json` and set: + - `defaultBlocks`, `validSigners` + - `tokens` — array of ERC20 addresses on the target network + - `allowed` — array of booleans, same length as `tokens` +2. Run: + + ```sh + yarn deploy:prod --network --parameters ignition/parameters/.json + ``` + + (e.g. `--network mainnet` or `--network polygon`, with the network + defined in `hardhat.config.ts`). + +The deployed Reputation/Multicall/P2PIX addresses are written to +`ignition/deployments/chain-/deployed_addresses.json`. diff --git a/ignition/modules/P2PIXProd.ts b/ignition/modules/P2PIXProd.ts new file mode 100644 index 0000000..f46016a --- /dev/null +++ b/ignition/modules/P2PIXProd.ts @@ -0,0 +1,31 @@ +import { buildModule } from "@nomicfoundation/hardhat-ignition/modules"; + +import ReputationModule from "./Reputation"; + +export default buildModule("P2PIXProd", m => { + const { reputation, multicall } = m.useModule( + ReputationModule, + ); + + const defaultBlocks = m.getParameter("defaultBlocks", 10); + const validSigners = m.getParameter( + "validSigners", + [], + ); + const tokens = m.getParameter("tokens"); + const allowed = m.getParameter("allowed"); + + const p2pix = m.contract("P2PIX", [ + defaultBlocks, + validSigners, + reputation, + tokens, + allowed, + ]); + + return { + p2pix, + reputation, + multicall, + }; +}); diff --git a/ignition/parameters/prod.example.json b/ignition/parameters/prod.example.json new file mode 100644 index 0000000..69b5d04 --- /dev/null +++ b/ignition/parameters/prod.example.json @@ -0,0 +1,8 @@ +{ + "P2PIXProd": { + "defaultBlocks": 10, + "validSigners": [], + "tokens": ["0x0000000000000000000000000000000000000000"], + "allowed": [true] + } +} diff --git a/package.json b/package.json index 1e0a504..8803ea8 100644 --- a/package.json +++ b/package.json @@ -17,6 +17,7 @@ "deploy:goerli": "hardhat ignition deploy ignition/modules/P2PIX.ts --network goerli --parameters ignition/parameters/goerli.json", "deploy:sepolia": "hardhat ignition deploy ignition/modules/P2PIX.ts --network sepolia --parameters ignition/parameters/sepolia.json", "deploy:mumbai": "hardhat ignition deploy ignition/modules/P2PIX.ts --network polygon-mumbai --parameters ignition/parameters/mumbai.json", + "deploy:prod": "hardhat ignition deploy ignition/modules/P2PIXProd.ts", "coverage": "hardhat coverage --solcoverjs ./.solcover.js --temp artifacts --testfiles \"test/**/*.ts\" && yarn typechain", "lint": "yarn lint:sol && yarn lint:ts && yarn prettier:check", "lint:sol": "solhint --config ./.solhint.json --max-warnings 0 \"contracts/**/*.sol\"",