Skip to content

Remove hardhat and replace with vitest #27

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Jul 8, 2025
Merged

Conversation

jeffsmale90
Copy link
Collaborator

@jeffsmale90 jeffsmale90 commented Jul 8, 2025

📝 Description

Removes hardhat and related dependencies. Adds vitest as test runner for packages/delegation-toolkit.

Previously packages/delegation-toolkit tests were run with hardhat.

Coverage report is now shown when yarn:test is executed.

🚀 Why?

Test runners are inconsistent throughout the monorepo - vitest, hardhat. Additionally anvil and hardhat-network are used in different packages for network simulation.

Hardhat introduces a complex dependency graph, including some critical dependencies. Removing this, and depending on vitest for these unit tests brings consistency, and reduces dependency management.

Additionally this simplifies our unit-testing, forcing us to isolate the component under test, while we can continue to do integration testing with our e2e test suite.

Resolves the following vulnerabilities:

🧪 How to Test?

This should bring no breaking changes, but improves the developer experience when running unit tests in /packages/delegation-toolkit.

Because this impacts how @metamask/delegation-core and @metamask/delegation-toolkit are bundled, it's important to test both esm and commonjs consumers for both packages.

I have validated this with commonjs with nodejs directly:

require("@metamask/delegation-core");
require("@metamask/delegation-core/actions");
require("@metamask/delegation-core/experimental");
require("@metamask/delegation-core/contracts");

ensuring that each is correctly resolved.

I have validated with esm with the following:

import * as dtk from "@metamask/delegation-toolkit";
import * as contracts from "@metamask/delegation-toolkit/contracts";
import * as experimental from "@metamask/delegation-toolkit/experimental";
import * as actions from "@metamask/delegation-toolkit/actions";
console.log({
  dtk: Object.keys(dtk),
  contracts: Object.keys(contracts),
  experimental: Object.keys(experimental),
  actions: Object.keys(actions),
});

⚠️ Breaking Changes

List any breaking changes:

  • No breaking changes
  • Breaking changes (describe below):

📋 Checklist

Check off completed items:

  • Code follows the project's coding standards
  • Self-review completed
  • Documentation updated (if needed)
  • Tests added/updated
  • Changelog updated (if needed)
  • All CI checks pass

🔗 Related Issues

Link to related issues:
Closes #
Related to #

📚 Additional Notes

Any additional information, concerns, or context:

@jeffsmale90 jeffsmale90 requested a review from a team as a code owner July 8, 2025 02:28
Copy link

socket-security bot commented Jul 8, 2025

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Added@​vitest/​coverage-v8@​3.2.4991007097100
Addedundici-types@​6.19.81001007293100
Updatedvitest@​2.1.9 ⏵ 3.2.4971007797100
Updated@​types/​node@​18.15.13 ⏵ 22.7.51001008096100

View full report

Copy link

socket-security bot commented Jul 8, 2025

All alerts resolved. Learn more about Socket for GitHub.

This PR previously contained dependency changes with security issues that have been resolved, removed, or ignored.

Ignoring alerts on:

View full report

cursor[bot]

This comment was marked as outdated.

@jeffsmale90
Copy link
Collaborator Author

@SocketSecurity ignore npm/[email protected]

@jeffsmale90 jeffsmale90 force-pushed the chore/remove-hardhat branch 3 times, most recently from 5184882 to e1e119b Compare July 8, 2025 03:55
Copy link
Contributor

@hanzel98 hanzel98 left a comment

Choose a reason for hiding this comment

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

- standardise vitest dependency across monorepo.
- update packages to 'type':'module' to fix vitest configuration resolution.
- fix exports in @metamask/delegation-core to correctly target commonjs and esm.
@jeffsmale90 jeffsmale90 force-pushed the chore/remove-hardhat branch from e1e119b to fb342c2 Compare July 8, 2025 19:07
@jeffsmale90 jeffsmale90 requested a review from hanzel98 July 8, 2025 19:39
Comment on lines +7 to +14
const factory = '0xfD9261637e09DD3c58643cDecC64A75EA235bBe8';
const implementations = {
HybridDeleGatorImpl: '0x4Ec9f3fDaBCA7b4588f6C0bA94464De12Bbd2E22',
MultiSigDeleGatorImpl: '0xa8F73EC8374b6fF40712AF6C21D1e79e1a5186aa',
} as const;
const deploySalt =
'0x11a8b2a8c7cf03cd3ef899b0e934306bff980bdb10a1d9e84c7598253fee9bcf';
const ownerAddress = '0x72ec0f88409247ebf9dc04a3521e5162d90cab1e';
Copy link
Contributor

Choose a reason for hiding this comment

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

I wonder if these hardcoded addresses could give us false positives in the future, meaning that they seem to work but maybe only for an old version

@jeffsmale90 jeffsmale90 merged commit 34fd9c9 into main Jul 8, 2025
14 checks passed
@jeffsmale90 jeffsmale90 deleted the chore/remove-hardhat branch July 8, 2025 20:08
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