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
This commit is contained in:
2026-05-29 14:15:50 -03:00
committed by hueso
parent 96f66f9cec
commit aa96fd89da
14 changed files with 46 additions and 300 deletions

View File

@@ -55,19 +55,13 @@
| Testnet | Token Address | P2pix Address | Reputation Address | Multicall Address | | Testnet | Token Address | P2pix Address | Reputation Address | Multicall Address |
| ------- | ------------------------------------------ | ------------------------------------------ | ------------------------------------------ | ------------------------------------------ | | ------- | ------------------------------------------ | ------------------------------------------ | ------------------------------------------ | ------------------------------------------ |
| Goerli | 0x4A2886EAEc931e04297ed336Cc55c4eb7C75BA00 | 0x2414817FF64A114d91eCFA16a834d3fCf69103d4 | 0x2CFD9354Ec7614fEf036EFd6A730dA1d5fC2762A | 0x8FE009992d96A86c7f0Bccdaf1eC3471E302a8a6 | | Sepolia | 0x3eBE212377D847828eBb9D2a100f5c5EA1EF3A72 | 0xb7cDAE58C6e715Cfd795BB142041E43b9CB02497 | 0xFd1194A56995Ef7B62730F4061408e79d88E5207 | 0x2f7f9848A803E67d79C0C8aa42b663dCF6E1B5ed |
| Mumbai | 0xC86042E9F2977C62Da8c9dDF7F9c40fde4796A29 | 0x4A2886EAEc931e04297ed336Cc55c4eb7C75BA00 | 0x570445E3eF413bCDb5De79ed27B1c3840683e385 | 0x718B2C4DE4F9654E1349F610ff561249bfe1c418 |
<!-- All contracts deployed by 0x8dC06F985C131166570825F52447E8c88d64aE20 --> <!-- All contracts deployed by 0x8dC06F985C131166570825F52447E8c88d64aE20 -->
<!-- https://goerli.etherscan.io/address/0x4A2886EAEc931e04297ed336Cc55c4eb7C75BA00#code --> <!-- https://sepolia.etherscan.io/address/0x3eBE212377D847828eBb9D2a100f5c5EA1EF3A72#code -->
<!-- https://goerli.etherscan.io/address/0x2414817FF64A114d91eCFA16a834d3fCf69103d4#code --> <!-- https://sepolia.etherscan.io/address/0xb7cDAE58C6e715Cfd795BB142041E43b9CB02497#code -->
<!-- https://goerli.etherscan.io/address/0x2CFD9354Ec7614fEf036EFd6A730dA1d5fC2762A#code --> <!-- https://sepolia.etherscan.io/address/0xFd1194A56995Ef7B62730F4061408e79d88E5207#code -->
<!-- https://goerli.etherscan.io/address/0x8FE009992d96A86c7f0Bccdaf1eC3471E302a8a6#code --> <!-- https://sepolia.etherscan.io/address/0x2f7f9848A803E67d79C0C8aa42b663dCF6E1B5ed#code -->
<!-- https://mumbai.polygonscan.com/address/0xC86042E9F2977C62Da8c9dDF7F9c40fde4796A29#code -->
<!-- https://mumbai.polygonscan.com/address/0x4A2886EAEc931e04297ed336Cc55c4eb7C75BA00#code -->
<!-- https://mumbai.polygonscan.com/address/0x570445e3ef413bcdb5de79ed27b1c3840683e385#code -->
<!-- https://mumbai.polygonscan.com/address/0x718B2C4DE4F9654E1349F610ff561249bfe1c418#code -->
## Usage ## Usage
@@ -136,19 +130,17 @@ under `ignition/deployments/`.
- `ignition/modules/MockToken.ts` — ERC20 mock used in dev / testnets. - `ignition/modules/MockToken.ts` — ERC20 mock used in dev / testnets.
- `ignition/modules/Reputation.ts` — Reputation + Multicall. - `ignition/modules/Reputation.ts` — Reputation + Multicall.
- `ignition/modules/P2PIX.ts`wires Reputation + MockToken and deploys - `ignition/modules/P2PIX.ts`production deploy (no MockToken). Token
P2PIX via its constructor, returning the full set of addresses. addresses passed via parameters (`tokens` + `allowed`).
- `ignition/modules/P2PIXProd.ts` — same as `P2PIX.ts` but **does not** - `ignition/modules/P2PIXWithMock.ts` — dev/test deploy. Wires Reputation +
deploy MockToken. Token addresses are passed in via parameters MockToken and deploys P2PIX.
(`tokens` + `allowed`), so existing on-chain tokens (e.g. BRZ, USDC)
can be wired directly.
### Per-network parameters ### Per-network parameters
Network-specific values (e.g. `defaultBlocks`, `validSigners`, MockToken Network-specific values (e.g. `defaultBlocks`, `validSigners`, MockToken
`supply`) live in `ignition/parameters/<network>.json`. Only `supply`) live in `ignition/parameters/<network>.json`. Only
`localhost.json` is checked in; copy it to e.g. `goerli.json` and set the `localhost.json` is checked in; copy it to e.g. `sepolia.json` and set the
network values before running the matching `deploy:*` script. network values before running the deploy script.
### Local environment ### Local environment
@@ -161,7 +153,7 @@ yarn hardhat node
On the second terminal: On the second terminal:
```sh ```sh
yarn deploy:localhost yarn deploy:mock --network localhost --parameters ignition/parameters/localhost.json
``` ```
Addresses for every deployed contract are written to Addresses for every deployed contract are written to
@@ -171,17 +163,15 @@ gitignored — local-only state).
### Testnets ### Testnets
```sh ```sh
yarn deploy:goerli yarn deploy:mock --network sepolia
yarn deploy:sepolia
yarn deploy:mumbai
``` ```
Each command requires the matching `ignition/parameters/<network>.json` Requires the matching `ignition/parameters/sepolia.json` and the relevant
and the relevant API keys in `.env`. 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. tokens you want P2PIX to support — no MockToken is deployed.
1. Copy `ignition/parameters/prod.example.json` to 1. Copy `ignition/parameters/prod.example.json` to
@@ -192,11 +182,8 @@ tokens you want P2PIX to support — no MockToken is deployed.
2. Run: 2. Run:
```sh ```sh
yarn deploy:prod --network <network> --parameters ignition/parameters/<network>.json yarn deploy --network <network> --parameters ignition/parameters/<network>.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 The deployed Reputation/Multicall/P2PIX addresses are written to
`ignition/deployments/chain-<id>/deployed_addresses.json`. `ignition/deployments/chain-<id>/deployed_addresses.json`.

View File

@@ -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 |

View File

@@ -1,16 +0,0 @@
# Solidity API
## MockToken
### constructor
```solidity
constructor(uint256 supply) public
```
### mint
```solidity
function mint(address[] to, uint256 value) public virtual
```

View File

@@ -24,9 +24,10 @@ const chainIds = {
localhost: 31337, localhost: 31337,
mainnet: 1, mainnet: 1,
"eth-sepolia": 11155111, "eth-sepolia": 11155111,
"polygon-mumbai": 80001, "polygon-mainnet": 137,
rootstock:30, "arb-mainnet": 42161,
"rootstock-testnet":31, rootstock: 30,
"rootstock-testnet": 31,
}; };
function getChainConfig( function getChainConfig(
@@ -56,9 +57,9 @@ const config: HardhatUserConfig = {
etherscan: { etherscan: {
apiKey: { apiKey: {
mainnet: process.env.ETHERSCAN_API_KEY || "", mainnet: process.env.ETHERSCAN_API_KEY || "",
rinkeby: process.env.ETHERSCAN_API_KEY || "", sepolia: process.env.ETHERSCAN_API_KEY || "",
goerli: process.env.ETHERSCAN_API_KEY || "", polygon: process.env.POLYGONSCAN_API_KEY || "",
polygonMumbai: process.env.POLYGONSCAN_API_KEY || "", arbitrumOne: process.env.ARBISCAN_API_KEY || "",
}, },
}, },
gasReporter: { gasReporter: {
@@ -94,11 +95,12 @@ const config: HardhatUserConfig = {
}, },
}, },
// network: getChainConfig("{INSERT_NAME}"), // network: getChainConfig("{INSERT_NAME}"),
mainnet: () => getChainConfig("mainnet"), mainnet: getChainConfig("mainnet"),
sepolia: () => getChainConfig("eth-sepolia"), sepolia: getChainConfig("eth-sepolia"),
mumbai: () => getChainConfig("polygon-mumbai"), polygon: getChainConfig("polygon-mainnet"),
rootstock: () => getChainConfig("rootstock"), arbitrum: getChainConfig("arb-mainnet"),
rsktestnet: () => getChainConfig("rootstock-testnet"), rootstock: getChainConfig("rootstock"),
rsktestnet: getChainConfig("rootstock-testnet"),
}, },
paths: { paths: {
artifacts: "./artifacts", artifacts: "./artifacts",

View File

@@ -1,7 +1,7 @@
import { buildModule } from "@nomicfoundation/hardhat-ignition/modules"; import { buildModule } from "@nomicfoundation/hardhat-ignition/modules";
import { ethers } from "ethers"; import { ethers } from "ethers";
const DEFAULT_SUPPLY = ethers.utils const DEFAULT_SUPPLY = ethers
.parseEther("20000000") .parseEther("20000000")
.toString(); .toString();

View File

@@ -1,10 +1,8 @@
import { buildModule } from "@nomicfoundation/hardhat-ignition/modules"; import { buildModule } from "@nomicfoundation/hardhat-ignition/modules";
import MockTokenModule from "./MockToken";
import ReputationModule from "./Reputation"; import ReputationModule from "./Reputation";
export default buildModule("P2PIX", m => { export default buildModule("P2PIX", m => {
const { token } = m.useModule(MockTokenModule);
const { reputation, multicall } = m.useModule( const { reputation, multicall } = m.useModule(
ReputationModule, ReputationModule,
); );
@@ -14,19 +12,20 @@ export default buildModule("P2PIX", m => {
"validSigners", "validSigners",
[], [],
); );
const tokens = m.getParameter<string[]>("tokens");
const allowed = m.getParameter<boolean[]>("allowed");
const p2pix = m.contract("P2PIX", [ const p2pix = m.contract("P2PIX", [
defaultBlocks, defaultBlocks,
validSigners, validSigners,
reputation, reputation,
[token], tokens,
[true], allowed,
]); ]);
return { return {
p2pix, p2pix,
reputation, reputation,
multicall, multicall,
token,
}; };
}); });

View File

@@ -1,8 +1,10 @@
import { buildModule } from "@nomicfoundation/hardhat-ignition/modules"; import { buildModule } from "@nomicfoundation/hardhat-ignition/modules";
import MockTokenModule from "./MockToken";
import ReputationModule from "./Reputation"; import ReputationModule from "./Reputation";
export default buildModule("P2PIXProd", m => { export default buildModule("P2PIXWithMock", m => {
const { token } = m.useModule(MockTokenModule);
const { reputation, multicall } = m.useModule( const { reputation, multicall } = m.useModule(
ReputationModule, ReputationModule,
); );
@@ -12,20 +14,19 @@ export default buildModule("P2PIXProd", m => {
"validSigners", "validSigners",
[], [],
); );
const tokens = m.getParameter<string[]>("tokens");
const allowed = m.getParameter<boolean[]>("allowed");
const p2pix = m.contract("P2PIX", [ const p2pix = m.contract("P2PIX", [
defaultBlocks, defaultBlocks,
validSigners, validSigners,
reputation, reputation,
tokens, [token],
allowed, [true],
]); ]);
return { return {
p2pix, p2pix,
reputation, reputation,
multicall, multicall,
token,
}; };
}); });

View File

@@ -1,5 +1,5 @@
{ {
"P2PIX": { "P2PIXWithMock": {
"defaultBlocks": 10, "defaultBlocks": 10,
"validSigners": [] "validSigners": []
}, },

View File

@@ -1,5 +1,5 @@
{ {
"P2PIXProd": { "P2PIX": {
"defaultBlocks": 10, "defaultBlocks": 10,
"validSigners": [], "validSigners": [],
"tokens": ["0x0000000000000000000000000000000000000000"], "tokens": ["0x0000000000000000000000000000000000000000"],

View File

@@ -13,11 +13,8 @@
"compile": "hardhat compile", "compile": "hardhat compile",
"typechain": "hardhat typechain", "typechain": "hardhat typechain",
"test": "hardhat test", "test": "hardhat test",
"deploy:localhost": "hardhat ignition deploy ignition/modules/P2PIX.ts --network localhost --parameters ignition/parameters/localhost.json", "deploy": "hardhat ignition deploy ignition/modules/P2PIX.ts",
"deploy:goerli": "hardhat ignition deploy ignition/modules/P2PIX.ts --network goerli --parameters ignition/parameters/goerli.json", "deploy:mock": "hardhat ignition deploy ignition/modules/P2PIXWithMock.ts",
"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", "coverage": "hardhat coverage --solcoverjs ./.solcover.js --temp artifacts --testfiles \"test/**/*.ts\" && yarn typechain",
"lint": "yarn lint:sol && yarn lint:ts && yarn prettier:check", "lint": "yarn lint:sol && yarn lint:ts && yarn prettier:check",
"lint:sol": "solhint --config ./.solhint.json --max-warnings 0 \"contracts/**/*.sol\"", "lint:sol": "solhint --config ./.solhint.json --max-warnings 0 \"contracts/**/*.sol\"",