Skip to content

Upgrade to Hardhat 3 and Enhanced Development Tooling#197

Open
cybervoid0 wants to merge 41 commits into
developfrom
hh3
Open

Upgrade to Hardhat 3 and Enhanced Development Tooling#197
cybervoid0 wants to merge 41 commits into
developfrom
hh3

Conversation

@cybervoid0

Copy link
Copy Markdown
Contributor

Upgrade to Hardhat 3 with Complete Test Suite Refactoring

What

This PR upgrades the project from Hardhat 2 to Hardhat 3 with a complete refactoring of the entire test suite to adopt the new Hardhat 3 syntax and patterns, alongside enhanced development tooling and code quality infrastructure.

Why

  • Hardhat 3 Migration: Leverage the latest Hardhat features, improved performance, and better TypeScript support
  • Test Suite Modernization: Migrate all tests to new Hardhat 3 syntax for better maintainability and type safety
  • Enhanced Code Quality: Implement comprehensive linting and formatting with automated pre-commit hooks
  • Future-Proof Architecture: Ensure compatibility with modern Ethereum development standards

Key Changes

🧪 Complete Test Suite Refactoring

All test files have been completely refactored to use Hardhat 3 syntax (351 test cases):

  • New Import Structure: Migrated from legacy Hardhat imports to modern ES modules
  • Updated Address Handling: Consistent use of new address utilities and type-safe patterns
  • Enhanced Type Safety: Full TypeScript integration with proper contract typing
  • Improved Test Organization: Better structure and readability across all test files

Affected Test Files:

  • BetaBuilders.test.ts - NFT minting and governance tests
  • EarlyAdopters.test.ts - Early adopter functionality
  • Governor.test.ts - DAO governance mechanisms
  • OGContributors.test.ts & OGPartners.test.ts - Original contributor NFTs
  • PlushieSeries1.test.ts - NFT series functionality
  • RIFToken.test.ts - Token contract tests
  • StRIFToken.*.test.ts - Staking token comprehensive test suite
  • Treasury.test.ts - Treasury management tests
  • Vanguard.test.ts - Vanguard NFT functionality
  • And more...

🔧 Hardhat 3 Migration

  • Upgraded from Hardhat 2.x to 3.0.6
  • Updated all Hardhat plugins to v3 compatible versions
  • Migrated to new @nomicfoundation/hardhat-toolbox-mocha-ethers plugin
  • Enhanced network configuration with chain descriptors and block explorer integration

🛠 Task System Overhaul

All Hardhat tasks refactored for Hardhat 3 compatibility:

  • airdrop.ts - Updated deployment and execution patterns
  • cancelProposal.ts - Modern proposal management
  • stRifUpgradeV1-v2.ts - Enhanced upgrade mechanisms
  • updateIpfsFolder.ts & withdrawTreasury.ts - Improved task implementations

📦 Package Management & Tooling

  • Removed yarn.lock and standardized on npm
  • Updated all dependencies to latest compatible versions
  • ESLint: Complete overhaul with flat config format supporting JS, TS, JSON, and Markdown
  • Solhint: Enhanced Solidity linting with automatic fixing capabilities
  • Prettier: Unified formatting across all file types
  • Husky + lint-staged: Automated pre-commit hooks preventing commits with linting errors

📁 Project Structure Improvements

  • Added comprehensive VS Code configuration
  • Updated TypeScript configuration for stricter type checking
  • Cleaned up obsolete files and improved organization
  • Enhanced deployContracts.ts with modern patterns

Breaking Changes

  • Package Manager: Switched from Yarn to npm
  • Test Syntax: All tests now use Hardhat 3 patterns (affects test extensions)
  • Import Paths: Updated import structure may affect external integrations

Migration Impact

  • 17 test files completely refactored
  • 5 task files updated to new patterns
  • 38 total files modified with 9,691 insertions and 6,059 deletions
  • 100% test compatibility maintained while adopting modern syntax

Testing

  • ✅ All existing functionality preserved
  • ✅ Complete test suite passes with new Hardhat 3 syntax
  • ✅ Enhanced type safety across all tests
  • ✅ New linting rules applied successfully
  • ✅ Pre-commit hooks working correctly
  • ✅ Hardhat compilation successful with new configuration

Developer Experience

  • Improved IntelliSense: Better TypeScript support in tests
  • Faster Test Execution: Hardhat 3 performance improvements
  • Better Error Messages: Enhanced debugging capabilities
  • Modern Patterns: Consistent with latest Ethereum development standards

- Enhanced .gitignore to include build artifacts and type definitions.
- Refactored hardhat.config.ts to streamline network configurations and integrate new plugins.
- Updated package.json to reflect version changes and new dependencies.
- Modified tsconfig.json for improved TypeScript settings.
- Removed yarn.lock to transition to npm for package management.
- Refined RIFToken contract to inherit from the updated RIF implementation.
- Adjusted test files to align with new module imports and address type definitions.
- Simplified test structure by updating import paths and removing unnecessary comments.
- Replaced direct address references with calls to `getAddress()` for better clarity.
- Enhanced event emission checks to specify parameter types for clarity.
- Adjusted test cases to ensure consistency in handling addresses and expectations.
…mport paths

- Replaced direct address references with calls to `getAddress()` for better clarity.
- Updated import paths to align with the new module structure.
- Enhanced event emission checks to specify parameter types for consistency.
- Streamlined test cases to ensure uniform handling of addresses and expectations.
- Removed unused plugins from ESLint configuration.
- Updated package versions in package.json and package-lock.json for better compatibility and features.
- Enhanced VSCode settings for improved formatting and linting support across different file types.
…Markdown support

- Added support for JSON and Markdown linting by including respective plugins.
- Configured new rules to enforce no duplicate keys in JSON and to disallow HTML in Markdown files.
…functionality

- Added support for the hardhat-verify plugin in the Hardhat configuration.
- Introduced new Rootstock testnet and mainnet network configurations.
- Updated airdrop task to use options instead of parameters for better usability and clarity.
- Enhanced airdrop task error handling and logging for improved user feedback.
- Refactored task implementations to use options instead of parameters for improved usability.
- Updated import paths to include file extensions for better clarity and compatibility.
- Enhanced error handling and logging in task actions for more informative feedback.
- Adjusted type definitions for Governor contracts to align with new structure.
…mproved usability

- Enhanced .gitignore to exclude new directories and files.
- Updated .prettierrc to include the Solidity plugin for better formatting.
- Modified ESLint configuration to include ignore patterns from .gitignore.
- Refactored Hardhat tasks to improve import paths and type definitions.
- Updated package.json and package-lock.json to include new dependencies and scripts for linting and formatting.
- Improved error handling and logging in task implementations for better user feedback.
@github-actions

github-actions Bot commented Sep 15, 2025

Copy link
Copy Markdown

Dependency Review

The following issues were found:

  • ✅ 0 vulnerable package(s)
  • ✅ 0 package(s) with incompatible licenses
  • ✅ 0 package(s) with invalid SPDX license definitions
  • ⚠️ 3 package(s) with unknown licenses.
  • ⚠️ 33 packages with OpenSSF Scorecard issues.

View full job summary

@cybervoid0 cybervoid0 self-assigned this Sep 15, 2025
@cybervoid0 cybervoid0 added the dependencies Pull requests that update a dependency file label Sep 15, 2025
…ew improvements

- Add solidity-lint.yml workflow as Slither alternative for Hardhat 3 compatibility
- Update dependency_review.yml to ignore false positive in rif-token-contracts
- Update slither.yml with clear migration path and alternative analysis
- Enhance solhint configuration for better code quality
- Remove TypeScript type checking from lint-staged for better performance

@Freshenext Freshenext left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I took a glance at all files; even larger ones. All was done was change code to make it compatible with V3; it looks good and tests are passing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dependencies Pull requests that update a dependency file do not merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants