From aa96fd89da4081bd65229c19ec6bbe5f5db0055f Mon Sep 17 00:00:00 2001 From: Arthur Abeilice Date: Fri, 29 May 2026 14:15:50 -0300 Subject: [PATCH] feat: add deployment configurations for Goerli, Polygon Mumbai, RSK Testnet, and Sepolia networks refactor: update Hardhat config for cleaner network setup chore: remove outdated MockToken documentation fix: correct DEFAULT_SUPPLY initialization in MockToken module --- README.md | 49 ++-- deploys/{ => old}/goerli.json | 0 deploys/{ => old}/polygon-mumbai.json | 0 deploys/{ => old}/rsktestnet.json | 0 deploys/{ => old}/sepolia.json | 0 docs/lib/mock/MockToken.md | 224 ------------------ docs/lib/mock/mockToken.md | 16 -- hardhat.config.ts | 24 +- ignition/modules/MockToken.ts | 2 +- ignition/modules/P2PIX.ts | 9 +- .../{P2PIXProd.ts => P2PIXWithMock.ts} | 11 +- ignition/parameters/localhost.json | 2 +- ignition/parameters/prod.example.json | 2 +- package.json | 7 +- 14 files changed, 46 insertions(+), 300 deletions(-) rename deploys/{ => old}/goerli.json (100%) rename deploys/{ => old}/polygon-mumbai.json (100%) rename deploys/{ => old}/rsktestnet.json (100%) rename deploys/{ => old}/sepolia.json (100%) delete mode 100644 docs/lib/mock/MockToken.md delete mode 100644 docs/lib/mock/mockToken.md rename ignition/modules/{P2PIXProd.ts => P2PIXWithMock.ts} (73%) diff --git a/README.md b/README.md index d9bb0c2..1dc3c8a 100644 --- a/README.md +++ b/README.md @@ -55,19 +55,13 @@ | Testnet | Token Address | P2pix Address | Reputation Address | Multicall Address | | ------- | ------------------------------------------ | ------------------------------------------ | ------------------------------------------ | ------------------------------------------ | -| Goerli | 0x4A2886EAEc931e04297ed336Cc55c4eb7C75BA00 | 0x2414817FF64A114d91eCFA16a834d3fCf69103d4 | 0x2CFD9354Ec7614fEf036EFd6A730dA1d5fC2762A | 0x8FE009992d96A86c7f0Bccdaf1eC3471E302a8a6 | -| Mumbai | 0xC86042E9F2977C62Da8c9dDF7F9c40fde4796A29 | 0x4A2886EAEc931e04297ed336Cc55c4eb7C75BA00 | 0x570445E3eF413bCDb5De79ed27B1c3840683e385 | 0x718B2C4DE4F9654E1349F610ff561249bfe1c418 | +| Sepolia | 0x3eBE212377D847828eBb9D2a100f5c5EA1EF3A72 | 0xb7cDAE58C6e715Cfd795BB142041E43b9CB02497 | 0xFd1194A56995Ef7B62730F4061408e79d88E5207 | 0x2f7f9848A803E67d79C0C8aa42b663dCF6E1B5ed | - - - - - - - - - + + + + ## Usage @@ -136,19 +130,17 @@ under `ignition/deployments/`. - `ignition/modules/MockToken.ts` — ERC20 mock used in dev / testnets. - `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. +- `ignition/modules/P2PIX.ts` — production deploy (no MockToken). Token + addresses passed via parameters (`tokens` + `allowed`). +- `ignition/modules/P2PIXWithMock.ts` — dev/test deploy. Wires Reputation + + MockToken and deploys P2PIX. ### Per-network parameters Network-specific values (e.g. `defaultBlocks`, `validSigners`, MockToken `supply`) live in `ignition/parameters/.json`. Only -`localhost.json` is checked in; copy it to e.g. `goerli.json` and set the -network values before running the matching `deploy:*` script. +`localhost.json` is checked in; copy it to e.g. `sepolia.json` and set the +network values before running the deploy script. ### Local environment @@ -161,7 +153,7 @@ yarn hardhat node On the second terminal: ```sh -yarn deploy:localhost +yarn deploy:mock --network localhost --parameters ignition/parameters/localhost.json ``` Addresses for every deployed contract are written to @@ -171,17 +163,15 @@ gitignored — local-only state). ### Testnets ```sh -yarn deploy:goerli -yarn deploy:sepolia -yarn deploy:mumbai +yarn deploy:mock --network sepolia ``` -Each command requires the matching `ignition/parameters/.json` -and the relevant API keys in `.env`. +Requires the matching `ignition/parameters/sepolia.json` and the relevant +API keys in `.env`. -### Deploying without MockToken (production / real tokens) +### Production (real tokens) -Use the `P2PIXProd` module when the target network already has the ERC20 +Use the `P2PIX` 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 @@ -192,11 +182,8 @@ tokens you want P2PIX to support — no MockToken is deployed. 2. Run: ```sh - yarn deploy:prod --network --parameters ignition/parameters/.json + yarn deploy --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/deploys/goerli.json b/deploys/old/goerli.json similarity index 100% rename from deploys/goerli.json rename to deploys/old/goerli.json diff --git a/deploys/polygon-mumbai.json b/deploys/old/polygon-mumbai.json similarity index 100% rename from deploys/polygon-mumbai.json rename to deploys/old/polygon-mumbai.json diff --git a/deploys/rsktestnet.json b/deploys/old/rsktestnet.json similarity index 100% rename from deploys/rsktestnet.json rename to deploys/old/rsktestnet.json diff --git a/deploys/sepolia.json b/deploys/old/sepolia.json similarity index 100% rename from deploys/sepolia.json rename to deploys/old/sepolia.json diff --git a/docs/lib/mock/MockToken.md b/docs/lib/mock/MockToken.md deleted file mode 100644 index 49ef399..0000000 --- a/docs/lib/mock/MockToken.md +++ /dev/null @@ -1,224 +0,0 @@ -# MockToken - -## Methods - -### DOMAIN_SEPARATOR - -```solidity -function DOMAIN_SEPARATOR() external view returns (bytes32) -``` - -#### Returns - -| Name | Type | Description | -| ---- | ------- | ----------- | -| \_0 | bytes32 | undefined | - -### allowance - -```solidity -function allowance(address, address) external view returns (uint256) -``` - -#### Parameters - -| Name | Type | Description | -| ---- | ------- | ----------- | -| \_0 | address | undefined | -| \_1 | address | undefined | - -#### Returns - -| Name | Type | Description | -| ---- | ------- | ----------- | -| \_0 | uint256 | undefined | - -### approve - -```solidity -function approve(address spender, uint256 amount) external nonpayable returns (bool) -``` - -#### Parameters - -| Name | Type | Description | -| ------- | ------- | ----------- | -| spender | address | undefined | -| amount | uint256 | undefined | - -#### Returns - -| Name | Type | Description | -| ---- | ---- | ----------- | -| \_0 | bool | undefined | - -### balanceOf - -```solidity -function balanceOf(address) external view returns (uint256) -``` - -#### Parameters - -| Name | Type | Description | -| ---- | ------- | ----------- | -| \_0 | address | undefined | - -#### Returns - -| Name | Type | Description | -| ---- | ------- | ----------- | -| \_0 | uint256 | undefined | - -### decimals - -```solidity -function decimals() external view returns (uint8) -``` - -#### Returns - -| Name | Type | Description | -| ---- | ----- | ----------- | -| \_0 | uint8 | undefined | - -### name - -```solidity -function name() external view returns (string) -``` - -#### Returns - -| Name | Type | Description | -| ---- | ------ | ----------- | -| \_0 | string | undefined | - -### nonces - -```solidity -function nonces(address) external view returns (uint256) -``` - -#### Parameters - -| Name | Type | Description | -| ---- | ------- | ----------- | -| \_0 | address | undefined | - -#### Returns - -| Name | Type | Description | -| ---- | ------- | ----------- | -| \_0 | uint256 | undefined | - -### permit - -```solidity -function permit(address owner, address spender, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s) external nonpayable -``` - -#### Parameters - -| Name | Type | Description | -| -------- | ------- | ----------- | -| owner | address | undefined | -| spender | address | undefined | -| value | uint256 | undefined | -| deadline | uint256 | undefined | -| v | uint8 | undefined | -| r | bytes32 | undefined | -| s | bytes32 | undefined | - -### symbol - -```solidity -function symbol() external view returns (string) -``` - -#### Returns - -| Name | Type | Description | -| ---- | ------ | ----------- | -| \_0 | string | undefined | - -### totalSupply - -```solidity -function totalSupply() external view returns (uint256) -``` - -#### Returns - -| Name | Type | Description | -| ---- | ------- | ----------- | -| \_0 | uint256 | undefined | - -### transfer - -```solidity -function transfer(address to, uint256 amount) external nonpayable returns (bool) -``` - -#### Parameters - -| Name | Type | Description | -| ------ | ------- | ----------- | -| to | address | undefined | -| amount | uint256 | undefined | - -#### Returns - -| Name | Type | Description | -| ---- | ---- | ----------- | -| \_0 | bool | undefined | - -### transferFrom - -```solidity -function transferFrom(address from, address to, uint256 amount) external nonpayable returns (bool) -``` - -#### Parameters - -| Name | Type | Description | -| ------ | ------- | ----------- | -| from | address | undefined | -| to | address | undefined | -| amount | uint256 | undefined | - -#### Returns - -| Name | Type | Description | -| ---- | ---- | ----------- | -| \_0 | bool | undefined | - -## Events - -### Approval - -```solidity -event Approval(address indexed owner, address indexed spender, uint256 amount) -``` - -#### Parameters - -| Name | Type | Description | -| ----------------- | ------- | ----------- | -| owner `indexed` | address | undefined | -| spender `indexed` | address | undefined | -| amount | uint256 | undefined | - -### Transfer - -```solidity -event Transfer(address indexed from, address indexed to, uint256 amount) -``` - -#### Parameters - -| Name | Type | Description | -| -------------- | ------- | ----------- | -| from `indexed` | address | undefined | -| to `indexed` | address | undefined | -| amount | uint256 | undefined | diff --git a/docs/lib/mock/mockToken.md b/docs/lib/mock/mockToken.md deleted file mode 100644 index ae62b10..0000000 --- a/docs/lib/mock/mockToken.md +++ /dev/null @@ -1,16 +0,0 @@ -# Solidity API - -## MockToken - -### constructor - -```solidity -constructor(uint256 supply) public -``` - -### mint - -```solidity -function mint(address[] to, uint256 value) public virtual -``` - diff --git a/hardhat.config.ts b/hardhat.config.ts index 40eb589..d276a09 100644 --- a/hardhat.config.ts +++ b/hardhat.config.ts @@ -24,9 +24,10 @@ const chainIds = { localhost: 31337, mainnet: 1, "eth-sepolia": 11155111, - "polygon-mumbai": 80001, - rootstock:30, - "rootstock-testnet":31, + "polygon-mainnet": 137, + "arb-mainnet": 42161, + rootstock: 30, + "rootstock-testnet": 31, }; function getChainConfig( @@ -56,9 +57,9 @@ const config: HardhatUserConfig = { etherscan: { apiKey: { mainnet: process.env.ETHERSCAN_API_KEY || "", - rinkeby: process.env.ETHERSCAN_API_KEY || "", - goerli: process.env.ETHERSCAN_API_KEY || "", - polygonMumbai: process.env.POLYGONSCAN_API_KEY || "", + sepolia: process.env.ETHERSCAN_API_KEY || "", + polygon: process.env.POLYGONSCAN_API_KEY || "", + arbitrumOne: process.env.ARBISCAN_API_KEY || "", }, }, gasReporter: { @@ -94,11 +95,12 @@ const config: HardhatUserConfig = { }, }, // network: getChainConfig("{INSERT_NAME}"), - mainnet: () => getChainConfig("mainnet"), - sepolia: () => getChainConfig("eth-sepolia"), - mumbai: () => getChainConfig("polygon-mumbai"), - rootstock: () => getChainConfig("rootstock"), - rsktestnet: () => getChainConfig("rootstock-testnet"), + mainnet: getChainConfig("mainnet"), + sepolia: getChainConfig("eth-sepolia"), + polygon: getChainConfig("polygon-mainnet"), + arbitrum: getChainConfig("arb-mainnet"), + rootstock: getChainConfig("rootstock"), + rsktestnet: getChainConfig("rootstock-testnet"), }, paths: { artifacts: "./artifacts", diff --git a/ignition/modules/MockToken.ts b/ignition/modules/MockToken.ts index 8d7e380..8b64f62 100644 --- a/ignition/modules/MockToken.ts +++ b/ignition/modules/MockToken.ts @@ -1,7 +1,7 @@ import { buildModule } from "@nomicfoundation/hardhat-ignition/modules"; import { ethers } from "ethers"; -const DEFAULT_SUPPLY = ethers.utils +const DEFAULT_SUPPLY = ethers .parseEther("20000000") .toString(); diff --git a/ignition/modules/P2PIX.ts b/ignition/modules/P2PIX.ts index cf19e7c..52e65cb 100644 --- a/ignition/modules/P2PIX.ts +++ b/ignition/modules/P2PIX.ts @@ -1,10 +1,8 @@ import { buildModule } from "@nomicfoundation/hardhat-ignition/modules"; -import MockTokenModule from "./MockToken"; import ReputationModule from "./Reputation"; export default buildModule("P2PIX", m => { - const { token } = m.useModule(MockTokenModule); const { reputation, multicall } = m.useModule( ReputationModule, ); @@ -14,19 +12,20 @@ export default buildModule("P2PIX", m => { "validSigners", [], ); + const tokens = m.getParameter("tokens"); + const allowed = m.getParameter("allowed"); const p2pix = m.contract("P2PIX", [ defaultBlocks, validSigners, reputation, - [token], - [true], + tokens, + allowed, ]); return { p2pix, reputation, multicall, - token, }; }); diff --git a/ignition/modules/P2PIXProd.ts b/ignition/modules/P2PIXWithMock.ts similarity index 73% rename from ignition/modules/P2PIXProd.ts rename to ignition/modules/P2PIXWithMock.ts index f46016a..65ef63a 100644 --- a/ignition/modules/P2PIXProd.ts +++ b/ignition/modules/P2PIXWithMock.ts @@ -1,8 +1,10 @@ import { buildModule } from "@nomicfoundation/hardhat-ignition/modules"; +import MockTokenModule from "./MockToken"; import ReputationModule from "./Reputation"; -export default buildModule("P2PIXProd", m => { +export default buildModule("P2PIXWithMock", m => { + const { token } = m.useModule(MockTokenModule); const { reputation, multicall } = m.useModule( ReputationModule, ); @@ -12,20 +14,19 @@ export default buildModule("P2PIXProd", m => { "validSigners", [], ); - const tokens = m.getParameter("tokens"); - const allowed = m.getParameter("allowed"); const p2pix = m.contract("P2PIX", [ defaultBlocks, validSigners, reputation, - tokens, - allowed, + [token], + [true], ]); return { p2pix, reputation, multicall, + token, }; }); diff --git a/ignition/parameters/localhost.json b/ignition/parameters/localhost.json index 380fe06..bf2d824 100644 --- a/ignition/parameters/localhost.json +++ b/ignition/parameters/localhost.json @@ -1,5 +1,5 @@ { - "P2PIX": { + "P2PIXWithMock": { "defaultBlocks": 10, "validSigners": [] }, diff --git a/ignition/parameters/prod.example.json b/ignition/parameters/prod.example.json index 69b5d04..e8769bb 100644 --- a/ignition/parameters/prod.example.json +++ b/ignition/parameters/prod.example.json @@ -1,5 +1,5 @@ { - "P2PIXProd": { + "P2PIX": { "defaultBlocks": 10, "validSigners": [], "tokens": ["0x0000000000000000000000000000000000000000"], diff --git a/package.json b/package.json index 2e64231..f3dd9e9 100644 --- a/package.json +++ b/package.json @@ -13,11 +13,8 @@ "compile": "hardhat compile", "typechain": "hardhat typechain", "test": "hardhat test", - "deploy:localhost": "hardhat ignition deploy ignition/modules/P2PIX.ts --network localhost --parameters ignition/parameters/localhost.json", - "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", + "deploy": "hardhat ignition deploy ignition/modules/P2PIX.ts", + "deploy:mock": "hardhat ignition deploy ignition/modules/P2PIXWithMock.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\"",