Skip to content

Commit 34fd9c9

Browse files
authored
Remove hardhat and replace with vitest (#27)
* Remove hardhat and related dependencies, replace with vitest * Add vitest coverage report for 'yarn test' * Fix incorrectly named test * Resolve issues with vitest in packages/delegation-toolkit - 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. * Remove hardhat artifacts file
1 parent bad6c89 commit 34fd9c9

55 files changed

Lines changed: 724 additions & 4525 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

package.json

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,6 @@
3232
"@metamask/eslint-config": "^12.0.0",
3333
"@metamask/eslint-config-nodejs": "^12.0.0",
3434
"@metamask/eslint-config-typescript": "^12.0.0",
35-
"@nomicfoundation/hardhat-ignition": "^0.15.1",
36-
"@nomicfoundation/hardhat-ignition-viem": "^0.15.0",
37-
"@nomicfoundation/hardhat-network-helpers": "^1.0.9",
38-
"@nomicfoundation/hardhat-toolbox-viem": "^3.0.0",
39-
"@nomicfoundation/hardhat-verify": "^2.0.0",
40-
"@nomicfoundation/hardhat-viem": "^2.0.0",
41-
"@nomicfoundation/ignition-core": "^0.15.1",
42-
"@nomiclabs/hardhat-ethers": "^2.2.3",
4335
"@types/keccak": "^3.0.4",
4436
"@typescript-eslint/eslint-plugin": "^5.42.1",
4537
"@typescript-eslint/parser": "^5.42.1",

packages/delegation-core/package.json

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
"version": "0.1.0",
44
"description": "Low level core functionality for interacting with the Delegation Framework",
55
"license": "(MIT-0 OR Apache-2.0)",
6+
"type": "module",
67
"keywords": [
78
"MetaMask",
89
"Ethereum"
@@ -18,8 +19,8 @@
1819
"author": "MetaMask <hello@metamask.io>",
1920
"sideEffects": false,
2021
"contributors": [],
21-
"main": "./dist/index.js",
22-
"module": "./dist/index.mjs",
22+
"main": "./dist/index.cjs",
23+
"module": "./dist/index.js",
2324
"types": "./dist/index.d.ts",
2425
"files": [
2526
"dist/**",
@@ -28,12 +29,12 @@
2829
"exports": {
2930
".": {
3031
"require": {
31-
"types": "./dist/index.d.ts",
32-
"default": "./dist/index.js"
32+
"types": "./dist/index.d.cts",
33+
"default": "./dist/index.cjs"
3334
},
3435
"import": {
35-
"types": "./dist/index.d.mts",
36-
"default": "./dist/index.mjs"
36+
"types": "./dist/index.d.ts",
37+
"default": "./dist/index.js"
3738
}
3839
},
3940
"./package.json": "./package.json"
@@ -67,7 +68,7 @@
6768
"@types/node": "^20.10.6",
6869
"tsup": "^8.5.0",
6970
"typescript": "5.0.4",
70-
"vitest": "^2.1.9"
71+
"vitest": "^3.2.4"
7172
},
7273
"dependencies": {
7374
"@metamask/abi-utils": "^3.0.0",

packages/delegation-toolkit/artifacts/artifacts.d.ts

Lines changed: 0 additions & 16 deletions
This file was deleted.

packages/delegation-toolkit/hardhat.config.ts

Lines changed: 0 additions & 26 deletions
This file was deleted.

packages/delegation-toolkit/hardhat.tsconfig.json

Lines changed: 0 additions & 7 deletions
This file was deleted.

packages/delegation-toolkit/package.json

Lines changed: 18 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{
22
"name": "@metamask/delegation-toolkit",
33
"version": "0.12.0",
4+
"type": "module",
45
"description": "The Delegation Toolkit built on top of Viem - a library for interacting with DeleGator Smart Accounts",
56
"license": "(MIT-0 OR Apache-2.0)",
67
"keywords": [
@@ -25,51 +26,51 @@
2526
".": {
2627
"require": {
2728
"types": "./dist/index.d.ts",
28-
"default": "./dist/index.js"
29+
"default": "./dist/index.cjs"
2930
},
3031
"import": {
3132
"types": "./dist/index.d.mts",
32-
"default": "./dist/index.mjs"
33+
"default": "./dist/index.js"
3334
}
3435
},
3536
"./utils": {
3637
"require": {
3738
"types": "./dist/utils/index.d.ts",
38-
"default": "./dist/utils/index.js"
39+
"default": "./dist/utils/index.cjs"
3940
},
4041
"import": {
4142
"types": "./dist/utils/index.d.mts",
42-
"default": "./dist/utils/index.mjs"
43+
"default": "./dist/utils/index.js"
4344
}
4445
},
4546
"./contracts": {
4647
"require": {
4748
"types": "./dist/contracts/index.d.ts",
48-
"default": "./dist/contracts/index.js"
49+
"default": "./dist/contracts/index.cjs"
4950
},
5051
"import": {
5152
"types": "./dist/contracts/index.d.mts",
52-
"default": "./dist/contracts/index.mjs"
53+
"default": "./dist/contracts/index.js"
5354
}
5455
},
5556
"./actions": {
5657
"require": {
5758
"types": "./dist/actions/index.d.ts",
58-
"default": "./dist/actions/index.js"
59+
"default": "./dist/actions/index.cjs"
5960
},
6061
"import": {
6162
"types": "./dist/actions/index.d.mts",
62-
"default": "./dist/actions/index.mjs"
63+
"default": "./dist/actions/index.js"
6364
}
6465
},
6566
"./experimental": {
6667
"require": {
6768
"types": "./dist/experimental/index.d.ts",
68-
"default": "./dist/experimental/index.js"
69+
"default": "./dist/experimental/index.cjs"
6970
},
7071
"import": {
7172
"types": "./dist/experimental/index.d.mts",
72-
"default": "./dist/experimental/index.mjs"
73+
"default": "./dist/experimental/index.js"
7374
}
7475
},
7576
"./package.json": "./package.json"
@@ -84,8 +85,8 @@
8485
"changelog:update": "../../scripts/update-changelog.sh @metamask/delegation-toolkit",
8586
"changelog:validate": "../../scripts/validate-changelog.sh @metamask/delegation-toolkit",
8687
"clean": "rm -rf dist",
87-
"test": "hardhat test --tsconfig hardhat.tsconfig.json",
88-
"test:watch": "npx nodemon -e ts -w ./test -w ./src -x \"yarn test\"",
88+
"test": "npx vitest run --coverage",
89+
"test:watch": "npx vitest watch",
8990
"format": "prettier --write \"src/**/*.{ts,tsx}\" --ignore-path .prettierignore",
9091
"lint": "yarn lint:eslint",
9192
"lint:complete": "yarn lint:eslint && yarn lint:constraints && yarn lint:misc --check && yarn lint:dependencies --check && yarn lint:changelog",
@@ -104,15 +105,10 @@
104105
"allowScripts": {
105106
"@lavamoat/preinstall-always-fail": false,
106107
"tsup>esbuild": true,
107-
"hardhat>@nomicfoundation/ethereumjs-blockchain>level>classic-level": false,
108-
"hardhat>@nomicfoundation/ethereumjs-tx>ethereum-cryptography>secp256k1": false,
109-
"hardhat>keccak": false,
110108
"viem>ws>bufferutil": false,
111109
"viem>ws>utf-8-validate": false,
112-
"@nomicfoundation/hardhat-toolbox-viem>solidity-coverage>hardhat>@nomicfoundation/ethereumjs-tx>ethereum-cryptography>secp256k1": false,
113-
"@nomicfoundation/hardhat-toolbox-viem>solidity-coverage>hardhat>keccak": false,
114-
"@nomicfoundation/hardhat-ignition-viem>@nomicfoundation/hardhat-ignition>hardhat>@nomicfoundation/ethereumjs-tx>ethereum-cryptography>secp256k1": false,
115-
"@nomicfoundation/hardhat-ignition-viem>@nomicfoundation/hardhat-ignition>hardhat>keccak": false
110+
"vitest>vite>esbuild": false,
111+
"vitest>vite>tsx>esbuild": false
116112
}
117113
},
118114
"dependencies": {
@@ -129,35 +125,22 @@
129125
"@metamask/eslint-config": "^12.0.0",
130126
"@metamask/eslint-config-nodejs": "^12.0.0",
131127
"@metamask/eslint-config-typescript": "^12.0.0",
132-
"@nomicfoundation/hardhat-ignition": "^0.15.1",
133-
"@nomicfoundation/hardhat-ignition-viem": "^0.15.0",
134-
"@nomicfoundation/hardhat-network-helpers": "^1.0.9",
135-
"@nomicfoundation/hardhat-toolbox-viem": "^3.0.0",
136-
"@nomicfoundation/hardhat-verify": "^2.0.0",
137-
"@nomicfoundation/hardhat-viem": "^2.0.0",
138-
"@nomicfoundation/ignition-core": "^0.15.1",
139-
"@types/chai": "4",
140-
"@types/chai-as-promised": "^7.1.8",
141-
"@types/mocha": "10.0.2",
142128
"@types/node": "^20.10.6",
143129
"@types/sinon": "^17.0.3",
144130
"@typescript-eslint/eslint-plugin": "^5.42.1",
145131
"@typescript-eslint/parser": "^5.42.1",
146-
"chai": "4",
147-
"chai-as-promised": "^7.1.1",
132+
"@vitest/coverage-v8": "3.2.4",
148133
"dotenv": "^16.3.1",
149134
"eslint": "^8.56.0",
150-
"hardhat": "^2.20.1",
151-
"hardhat-gas-reporter": "^1.0.8",
152135
"import": "^0.0.6",
153136
"prettier": "^3.3.3",
154137
"sinon": "^18.0.0",
155-
"solidity-coverage": "^0.8.1",
156138
"ts-node": "^10.9.2",
157139
"tsconfig-paths": "^4.2.0",
158140
"tsup": "^8.5.0",
159141
"typescript": "5.0.4",
160-
"viem": "2.21.55"
142+
"viem": "2.21.55",
143+
"vitest": "^3.2.4"
161144
},
162145
"peerDependencies": {
163146
"viem": ">=2.18.2 <3.0.0"

packages/delegation-toolkit/test/caveatBuilder/CaveatBuilder.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import { expect } from 'chai';
21
import { spy } from 'sinon';
32
import { toHex } from 'viem';
3+
import { expect, describe, it, beforeEach } from 'vitest';
44

55
import { CaveatBuilder } from '../../src/caveatBuilder/caveatBuilder';
66
import type { Caveat, DeleGatorEnvironment } from '../../src/types';

packages/delegation-toolkit/test/caveatBuilder/allowedCalldataBuilder.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { expect } from 'chai';
21
import { concat, size, toHex, type Hex } from 'viem';
2+
import { expect, describe, it } from 'vitest';
33

44
import { allowedCalldataBuilder } from '../../src/caveatBuilder/allowedCalldataBuilder';
55
import type { DeleGatorEnvironment } from '../../src/types';

packages/delegation-toolkit/test/caveatBuilder/allowedMethodsBuilder.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import { expect } from 'chai';
21
import { concat, toFunctionSelector, size } from 'viem';
32
import type { AbiFunction, Hex } from 'viem';
3+
import { expect, describe, it } from 'vitest';
44

55
import type { MethodSelector } from '../../src/caveatBuilder/allowedMethodsBuilder';
66
import { allowedMethodsBuilder } from '../../src/caveatBuilder/allowedMethodsBuilder';

packages/delegation-toolkit/test/caveatBuilder/allowedTargetsBuilder.test.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
import { expect } from 'chai';
2-
import { concat, size } from 'viem';
3-
import type { Address, Hex } from 'viem';
1+
import { concat, size, type Address, type Hex } from 'viem';
2+
import { expect, describe, it } from 'vitest';
43

54
import { allowedTargetsBuilder } from '../../src/caveatBuilder/allowedTargetsBuilder';
65
import type { DeleGatorEnvironment } from '../../src/types';

0 commit comments

Comments
 (0)