From 4f6ddcce519380dafe01cdee0061954adfe2fdc8 Mon Sep 17 00:00:00 2001 From: Cardinal Date: Thu, 31 Jul 2025 15:36:24 +0200 Subject: [PATCH 1/2] change order, add info and docs --- tasks/compare.ts | 20 ++++++++++++++++++++ tasks/contracts.ts | 16 ++++++++++++++++ tasks/copybatch.ts | 28 ++++++++++++++++++++++++++++ tasks/deployments.ts | 13 +++++++++++++ tasks/signatures.ts | 18 ++++++++++++++++++ tasks/status.ts | 17 ++++++++++++++++- 6 files changed, 111 insertions(+), 1 deletion(-) diff --git a/tasks/compare.ts b/tasks/compare.ts index 80399a1f..1c4eb0ea 100644 --- a/tasks/compare.ts +++ b/tasks/compare.ts @@ -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'; diff --git a/tasks/contracts.ts b/tasks/contracts.ts index f8d2d367..5e5da2b3 100644 --- a/tasks/contracts.ts +++ b/tasks/contracts.ts @@ -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'; diff --git a/tasks/copybatch.ts b/tasks/copybatch.ts index 9965adf3..9dd25849 100644 --- a/tasks/copybatch.ts +++ b/tasks/copybatch.ts @@ -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 { diff --git a/tasks/deployments.ts b/tasks/deployments.ts index 6fce50dc..8747cb34 100644 --- a/tasks/deployments.ts +++ b/tasks/deployments.ts @@ -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'; diff --git a/tasks/signatures.ts b/tasks/signatures.ts index 6ebcd51f..3b95a291 100644 --- a/tasks/signatures.ts +++ b/tasks/signatures.ts @@ -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 { diff --git a/tasks/status.ts b/tasks/status.ts index b3bb1e4c..30ce72e7 100644 --- a/tasks/status.ts +++ b/tasks/status.ts @@ -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'; @@ -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; From 01f66c5451938c2d12042aee90368741559e3774 Mon Sep 17 00:00:00 2001 From: Cardinal Date: Mon, 27 Oct 2025 12:51:52 +0100 Subject: [PATCH 2/2] info about all tasks --- tasks/README.md | 152 ++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 146 insertions(+), 6 deletions(-) diff --git a/tasks/README.md b/tasks/README.md index 3995101d..01227993 100644 --- a/tasks/README.md +++ b/tasks/README.md @@ -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 \ No newline at end of file +- `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 \ No newline at end of file