Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
152 changes: 146 additions & 6 deletions tasks/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,11 +73,151 @@ The task includes robust error handling for:
- Network connectivity issues
- Missing deployment files

### Available Tasks
### Contracts Task

The `contracts` task displays contract deployment information for a specific network.

#### Usage

```bash
# Show mainnet contracts
npx hardhat contracts --target main

# Show testnet contracts
npx hardhat contracts --target test

# Show local contracts
npx hardhat contracts --target local

# Show pretestnet contracts
npx hardhat contracts --target pretestnet

# Show tenderly contracts
npx hardhat contracts --target tenderly
```

#### What it displays

- Contract addresses for the specified network
- Explorer URLs for each contract
- Formatted output for easy copying

---

### Deployments Task

The `deployments` task displays all deployed contracts in a copy-paste friendly format.

#### Usage

```bash
npx hardhat deployments
```

#### What it displays

- All deployed contracts for both mainnet and testnet
- Contract addresses with Etherscan explorer links
- Clean, copy-paste friendly format
- Automatically reads from `mainnet_deployed.json` and `testnet_deployed.json`

---

### Compare Task

The `compare` task compares bytecodes between two deployments to verify consistency.

#### Usage

```bash
# Compare mainnet vs testnet
npx hardhat compare --source mainnet --target testnet

# Compare testnet vs local
npx hardhat compare --source testnet --target local

# Compare mainnet vs tenderly
npx hardhat compare --source mainnet --target tenderly
```

#### What it does

- Compares bytecodes between deployments on different networks
- Shows which contracts are identical vs different
- Identifies missing contracts in either deployment
- Useful for verifying consistent deployments across networks
- Color-coded output: ✅ identical, ❌ different, ⚠️ missing

---

### Signatures Task

The `sigs` task generates ABI signatures for errors and functions.

#### Usage

```bash
# Generate signatures for PostageStamp contract
npx hardhat sigs --c PostageStamp

# Use custom Solidity file name
npx hardhat sigs --c PostageStamp --f MyFile
```

#### Parameters

- `--c`: Contract name (required)
- `--f`: Solidity file name (optional, defaults to contract name)

#### What it does

- Loads contract ABI from artifacts
- Generates error signatures with selectors
- Shows function selectors for debugging
- Useful for error handling and contract interaction

---

### Copy Task

The `copy` task uses the `copyBatch` function from the PostageStamp contract.

#### Usage

```bash
npx hardhat copy \
--owner 0x1234... \
--initialbalance 1000000000000000000 \
--depth 20 \
--bucketdepth 16 \
--batchid 0xabcd... \
--immutable false \
--contract 0x5678...
```

#### Parameters

- `--owner`: The account's address
- `--initialbalance`: Initial balance for the batch
- `--depth`: Batch depth
- `--bucketdepth`: Bucket depth
- `--batchid`: Batch ID
- `--immutable`: Whether batch is immutable (true/false)
- `--contract`: PostageStamp contract address

#### What it does

- Estimates gas for the copyBatch transaction
- Adds 20% buffer to estimated gas
- Executes copyBatch with optimized gas settings

---

## Available Tasks Summary

- `status`: Check contract statuses and roles
- `contracts`: Other contract-related tasks
- `deployments`: Deployment management tasks
- `compare`: Contract comparison utilities
- `signatures`: Signature verification tasks
- `copybatch`: Batch copying utilities
- `contracts`: Display contract deployment information
- `deployments`: Show all deployed contracts in copy-paste friendly format
- `compare`: Compare bytecodes between deployments
- `signatures`: Generate ABI signatures for errors and functions
- `copy`: Use copyBatch function from PostageStamp contract
20 changes: 20 additions & 0 deletions tasks/compare.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,23 @@
/**
* Compare Task - Compare bytecodes between two deployments
*
* Usage:
* npx hardhat compare --source mainnet --target testnet # Compare mainnet vs testnet
* npx hardhat compare --source testnet --target local # Compare testnet vs local
* npx hardhat compare --source mainnet --target tenderly # Compare mainnet vs tenderly
*
* Parameters:
* --source: Source network (mainnet, testnet, local, tenderly, pretestnet)
* --target: Target network (mainnet, testnet, local, tenderly, pretestnet)
*
* This task:
* - Compares bytecodes between deployments on different networks
* - Shows which contracts are identical vs different
* - Identifies missing contracts in either deployment
* - Useful for verifying consistent deployments across networks
* - Color-coded output: ✅ identical, ❌ different, ⚠️ missing
*/

import { task } from 'hardhat/config';
import fs from 'fs';
import path from 'path';
Expand Down
16 changes: 16 additions & 0 deletions tasks/contracts.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
/**
* Contracts Task - Display contract deployment information
*
* Usage:
* npx hardhat contracts --target main # Show mainnet contracts
* npx hardhat contracts --target test # Show testnet contracts
* npx hardhat contracts --target local # Show local contracts
* npx hardhat contracts --target pretestnet # Show pretestnet contracts
* npx hardhat contracts --target tenderly # Show tenderly contracts
*
* This task displays:
* - Contract addresses for the specified network
* - Explorer URLs for each contract
* - Formatted output for easy copying
*/

import { task } from 'hardhat/config';
import fs from 'fs';
import path from 'path';
Expand Down
28 changes: 28 additions & 0 deletions tasks/copybatch.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,31 @@
/**
* Copy Batch Task - Use copyBatch function from PostageStamp contract
*
* Usage:
* npx hardhat copy \
* --owner 0x1234... \
* --initialbalance 1000000000000000000 \
* --depth 20 \
* --bucketdepth 16 \
* --batchid 0xabcd... \
* --immutable false \
* --contract 0x5678...
*
* Parameters:
* --owner: The account's address
* --initialbalance: Initial balance for the batch
* --depth: Batch depth
* --bucketdepth: Bucket depth
* --batchid: Batch ID
* --immutable: Whether batch is immutable (true/false)
* --contract: PostageStamp contract address
*
* This task:
* - Estimates gas for the copyBatch transaction
* - Adds 20% buffer to estimated gas
* - Executes copyBatch with optimized gas settings
*/

import { task } from 'hardhat/config';

interface TaskArguments {
Expand Down
13 changes: 13 additions & 0 deletions tasks/deployments.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
/**
* Deployments Task - Display deployed contracts in copy-paste friendly format
*
* Usage:
* npx hardhat deployments
*
* This task displays:
* - All deployed contracts for both mainnet and testnet
* - Contract addresses with Etherscan explorer links
* - Clean, copy-paste friendly format
* - Automatically reads from mainnet_deployed.json and testnet_deployed.json
*/

import { task } from 'hardhat/config';
import fs from 'fs';
import path from 'path';
Expand Down
18 changes: 18 additions & 0 deletions tasks/signatures.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,21 @@
/**
* Signatures Task - Generate ABI signatures for errors and functions
*
* Usage:
* npx hardhat sigs --c PostageStamp # Generate signatures for PostageStamp contract
* npx hardhat sigs --c PostageStamp --f MyFile # Use custom Solidity file name
*
* Parameters:
* --c: Contract name (required)
* --f: Solidity file name (optional, defaults to contract name)
*
* This task:
* - Loads contract ABI from artifacts
* - Generates error signatures with selectors
* - Shows function selectors for debugging
* - Useful for error handling and contract interaction
*/

import { task } from 'hardhat/config';

interface TaskArgs {
Expand Down
17 changes: 16 additions & 1 deletion tasks/status.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
/**
* Status Task - Check deployed contract statuses and roles
*
* Usage:
* npx hardhat status # Check mainnet (default)
* npx hardhat status --target mainnet # Check mainnet explicitly
* npx hardhat status --target testnet # Check testnet
*
* This task checks:
* - Contract pause/active status
* - Admin role assignments for specified addresses
* - Role verifications (PRICE_ORACLE_ROLE, REDISTRIBUTOR_ROLE, PAUSER_ROLE, etc.)
* - Displays results with visual indicators (✅/❌/🟢/🔴)
*/

import { task } from 'hardhat/config';
import { ethers } from 'ethers';
import * as fs from 'fs';
Expand Down Expand Up @@ -351,7 +366,7 @@ function displayStatus(result: StatusResult) {
}

task('status', 'Check status of deployed contracts and their roles')
.addParam('target', 'Network to check (testnet or mainnet)', 'testnet')
.addParam('target', 'Network to check (testnet or mainnet)', 'mainnet')
.setAction(async (taskArgs) => {
const { target } = taskArgs;

Expand Down
Loading