build: migrate evm stablecoin contracts to Hardhat 3 - #154
sachushaji wants to merge 1 commit into
Conversation
Upgrade the Hardhat toolchain to the supported Hardhat 3 ESM APIs, migrate tests and scripts to shared network connections, and preserve existing contract behavior. Ticket: SCAAS-11243 Signed-off-by: Sachu Shaji Abraham <sachuabraham@bitgo.com>
There was a problem hiding this comment.
🟡 Changes recommended
Several tests use an invalid Chai matcher (.to.be.revert(ethers)), and scripts/deploy-deterministic.ts’s ESM entry guard likely prevents main() from running when executed via npx hardhat run.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
Migrates the EVM stablecoin contracts Hardhat workspace from Hardhat 2 to Hardhat 3, switching the project to ESM and updating scripts/tests to the new Hardhat 3 connection model and OpenZeppelin upgrades API.
Changes:
- Update Hardhat configuration to Hardhat 3
defineConfig+ plugin registration and Hardhat 3 network type declarations. - Migrate tests and scripts to
hre.network.getOrCreate()and OpenZeppelinupgrades(hre, connection)factory usage. - Replace Hardhat Solhint integration with standalone Solhint + add ESM/module adjustments (e.g.,
import.meta.urlpatterns).
File summaries
| File | Description |
|---|---|
| test/supply.ts | Migrates Hardhat 3 connection usage; updates revert assertions. |
| test/supply-validator.ts | Migrates Hardhat 3 connection usage; updates revert assertions. |
| test/rate-limiting.ts | Migrates Hardhat 3 connection usage; updates revert assertions. |
| test/pause.ts | Migrates Hardhat 3 connection usage and upgrades factory. |
| test/initialize.ts | Migrates Hardhat 3 connection usage and upgrades factory. |
| test/deploy-deterministic.ts | Updates network provider calls and ESM path handling for Hardhat 3. |
| test/blacklist.ts | Migrates Hardhat 3 connection usage and upgrades factory. |
| scripts/upgrade-token.ts | Migrates upgrade script to Hardhat 3 connection + upgrades factory. |
| scripts/manage-roles.ts | Migrates role management script to Hardhat 3 connection usage. |
| scripts/deploy-token.ts | Migrates deploy script to Hardhat 3 connection + upgrades factory. |
| scripts/deploy-deterministic.ts | Hardhat 3/ESM migration for deterministic deploy + artifact build-info access. |
| package.json | Updates dependencies for Hardhat 3; swaps lint flow to Solhint; enables ESM via type: module. |
| hardhat.config.ts | Converts config to Hardhat 3 defineConfig, plugin array, and network typing. |
| eslint.config.mjs | Adds ignores for generated types directory under ESM ESLint flat config. |
| contracts/Blacklistable.sol | Adds OZ upgrades annotation for missing initializer warning suppression. |
| .solhint.json | Introduces Solhint config for standalone Solhint usage. |
| .gitignore | Ignores generated types/ output directory. |
Review details
Suppressed comments (4)
test/supply.ts:904
.to.be.revert(ethers)is not a valid Hardhat/Chai matcher and will cause this assertion to fail. Use.to.be.revertedfor an unspecified revert.
).to.be.revert(ethers); // Will revert due to lack of MINTER role
test/rate-limiting.ts:215
.to.be.revert(ethers)is not a valid Hardhat/Chai matcher. Replace with.to.be.revertedto assert a revert without matching the reason.
).to.be.revert(ethers);
test/rate-limiting.ts:361
.to.be.revert(ethers)is not a valid Hardhat/Chai matcher. Use.to.be.revertedfor a generic revert assertion.
).to.be.revert(ethers);
test/rate-limiting.ts:858
.to.be.revert(ethers)is not a valid Hardhat/Chai matcher and will fail at runtime. Use.to.be.revertedfor a generic revert assertion.
).to.be.revert(ethers);
- Files reviewed: 16/18 changed files
- Comments generated: 4
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| } | ||
|
|
||
| if (require.main === module) { | ||
| if (process.argv[1] && import.meta.url === pathToFileURL(process.argv[1]).href) { |
| .connect(randomAddress) | ||
| .configureMinter(randomAddress.address, DAILY_MINT_LIMIT, DAILY_BURN_LIMIT) | ||
| ).to.be.reverted; | ||
| ).to.be.revert(ethers); |
| await expect( | ||
| contractInstance.connect(unauthorized).setSupplyValidator(mockValidator.getAddress()) | ||
| ).to.be.reverted; | ||
| ).to.be.revert(ethers); |
| transferAmount | ||
| ) | ||
| ).to.be.reverted; | ||
| ).to.be.revert(ethers); |
Summary
Consolidates the remaining breaking Dependabot upgrades into a Hardhat 3 migration.
Dependency changes
@nomicfoundation/hardhat-toolbox→ supported@nomicfoundation/hardhat-toolbox-mocha-ethers3.0.7@openzeppelin/hardhat-upgrades3 → 4.1.0Compatibility changes
defineConfig.network.getOrCreate()connections.Verification
npm ci --no-audit --no-fundnpm run lintnpm test— 207 passingThis supersedes the remaining major-upgrade Dependabot PRs #120, #125, #126, and #147 after review and merge.
Ticket: SCAAS-11243