Skip to content

build: migrate evm stablecoin contracts to Hardhat 3 - #154

Closed
sachushaji wants to merge 1 commit into
masterfrom
sachuabraham/scaas-11243-hardhat-3-migration
Closed

sachushaji wants to merge 1 commit into
masterfrom
sachuabraham/scaas-11243-hardhat-3-migration

Conversation

@sachushaji

Copy link
Copy Markdown
Contributor

Summary

Consolidates the remaining breaking Dependabot upgrades into a Hardhat 3 migration.

Dependency changes

  • Hardhat 2.22.6 → 3.14.0
  • @nomicfoundation/hardhat-toolbox → supported @nomicfoundation/hardhat-toolbox-mocha-ethers 3.0.7
  • @openzeppelin/hardhat-upgrades 3 → 4.1.0
  • Hardhat ethers 4.0.13 and verify 3.0.22
  • Replace the incompatible Hardhat Solhint plugin with standalone Solhint 5.0.3

Compatibility changes

  • Enable ESM and Hardhat 3 network types.
  • Register toolbox and OpenZeppelin plugins through defineConfig.
  • Migrate tests/scripts to shared network.getOrCreate() connections.
  • Use the Hardhat 3 OpenZeppelin upgrade API.
  • Migrate artifact/build-info and ESM path access.
  • Replace deprecated revert assertions.
  • Preserve existing Solidity contract behavior; the initializer annotation documents the existing inherited-initializer design.

Verification

  • npm ci --no-audit --no-fund
  • npm run lint
  • npm test — 207 passing

This supersedes the remaining major-upgrade Dependabot PRs #120, #125, #126, and #147 after review and merge.

Ticket: SCAAS-11243

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>
@sachushaji
sachushaji requested a review from a team as a code owner September 3, 2026 11:41
@linear-code

linear-code Bot commented Sep 3, 2026

Copy link
Copy Markdown

SCAAS-11243

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 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 OpenZeppelin upgrades(hre, connection) factory usage.
  • Replace Hardhat Solhint integration with standalone Solhint + add ESM/module adjustments (e.g., import.meta.url patterns).
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.reverted for 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.reverted to 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.reverted for 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.reverted for 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) {
Comment thread test/rate-limiting.ts
.connect(randomAddress)
.configureMinter(randomAddress.address, DAILY_MINT_LIMIT, DAILY_BURN_LIMIT)
).to.be.reverted;
).to.be.revert(ethers);
Comment thread test/supply-validator.ts
await expect(
contractInstance.connect(unauthorized).setSupplyValidator(mockValidator.getAddress())
).to.be.reverted;
).to.be.revert(ethers);
Comment thread test/supply.ts
transferAmount
)
).to.be.reverted;
).to.be.revert(ethers);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants