Skip to content

Commit 3542352

Browse files
authored
Merge pull request #634 from semaphore-protocol/refactor/conditional-exports
`ethers` conditional exports Former-commit-id: 256d00b
2 parents a1a5dd9 + 5a3c4f1 commit 3542352

15 files changed

+30
-35
lines changed

babel.config.json

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

jest.config.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import fs from "fs"
2-
import type { Config } from "@jest/types"
2+
import type { Config } from "jest"
33

44
const exclude = ["circuits", "contracts"]
55

@@ -8,6 +8,7 @@ const projects: any = fs
88
.filter((directory) => directory.isDirectory())
99
.filter((directory) => !exclude.includes(directory.name))
1010
.map(({ name }) => ({
11+
preset: "ts-jest",
1112
rootDir: `packages/${name}`,
1213
displayName: name,
1314
setupFiles: ["dotenv/config"],
@@ -16,11 +17,10 @@ const projects: any = fs
1617
}
1718
}))
1819

19-
export default async (): Promise<Config.InitialOptions> => ({
20+
const config: Config = {
2021
projects,
2122
verbose: true,
2223
coverageDirectory: "./coverage/libraries",
23-
collectCoverageFrom: ["<rootDir>/src/**/*.ts", "!<rootDir>/src/**/index.ts", "!<rootDir>/src/**/*.d.ts"],
2424
coverageThreshold: {
2525
global: {
2626
branches: 90,
@@ -29,4 +29,6 @@ export default async (): Promise<Config.InitialOptions> => ({
2929
statements: 95
3030
}
3131
}
32-
})
32+
}
33+
34+
export default config

package.json

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -48,21 +48,17 @@
4848
],
4949
"packageManager": "[email protected]",
5050
"devDependencies": {
51-
"@babel/core": "^7.16.7",
52-
"@babel/preset-env": "^7.16.8",
53-
"@babel/preset-typescript": "^7.17.12",
5451
"@commitlint/cli": "^16.0.2",
5552
"@commitlint/config-conventional": "^16.0.0",
5653
"@rollup/plugin-typescript": "^11.1.6",
5754
"@types/circomlibjs": "^0.1.4",
5855
"@types/download": "^8.0.1",
5956
"@types/glob": "^7.2.0",
60-
"@types/jest": "^27.4.0",
57+
"@types/jest": "^29.5.12",
6158
"@types/node": "^20",
6259
"@types/rimraf": "^3.0.2",
6360
"@typescript-eslint/eslint-plugin": "^5.9.1",
6461
"@typescript-eslint/parser": "^5.9.1",
65-
"babel-jest": "^27.4.6",
6662
"changelogithub": "0.12.7",
6763
"commitizen": "^4.2.4",
6864
"cz-conventional-changelog": "^3.3.0",
@@ -72,18 +68,19 @@
7268
"eslint-config-airbnb-typescript": "^16.1.0",
7369
"eslint-config-prettier": "^8.3.0",
7470
"eslint-plugin-import": "^2.25.2",
75-
"eslint-plugin-jest": "^25.7.0",
71+
"eslint-plugin-jest": "^27.8.0",
7672
"eslint-plugin-jsx-a11y": "^6.8.0",
7773
"eslint-plugin-react": "^7.33.2",
7874
"eslint-plugin-react-hooks": "^4.6.0",
7975
"husky": "^8.0.3",
80-
"jest": "^27.4.1",
81-
"jest-config": "^27.4.7",
76+
"jest": "^29.7.0",
77+
"jest-config": "^29.7.0",
8278
"lint-staged": "^12.1.7",
8379
"prettier": "^2.5.1",
8480
"rimraf": "^3.0.2",
8581
"rollup": "^4.9.6",
8682
"snarkjs": "^0.7.2",
83+
"ts-jest": "^29.1.2",
8784
"ts-node": "^10.9.2",
8885
"tslib": "^2.6.2",
8986
"typedoc": "^0.25.7",

packages/data/src/ethers.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
1+
import { ZeroAddress } from "ethers/constants"
2+
import { Contract } from "ethers/contract"
13
import {
24
AlchemyProvider,
35
AnkrProvider,
46
CloudflareProvider,
5-
Contract,
67
EtherscanProvider,
78
InfuraProvider,
89
JsonRpcProvider,
910
PocketProvider,
10-
Provider,
11-
ZeroAddress
12-
} from "ethers"
11+
Provider
12+
} from "ethers/providers"
1313
import checkParameter from "./checkParameter"
1414
import getEvents from "./getEvents"
1515
import SemaphoreABI from "./semaphoreABI.json"

packages/data/src/getEvents.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/* istanbul ignore file */
2-
import { Contract, EventLog } from "ethers"
2+
import { Contract, EventLog } from "ethers/contract"
33

44
/**
55
* Returns the list of events of a contract with possible filters.

packages/data/tests/ethers.test.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
/* eslint-disable no-sparse-arrays */
2-
import { Contract, ZeroAddress } from "ethers"
2+
import { ZeroAddress } from "ethers/constants"
3+
import { Contract } from "ethers/contract"
34
import SemaphoreEthers from "../src/ethers"
45
import getEvents from "../src/getEvents"
56

@@ -8,9 +9,9 @@ jest.mock("../src/getEvents", () => ({
89
default: jest.fn()
910
}))
1011

11-
jest.mock("ethers", () => ({
12+
jest.mock("ethers/contract", () => ({
1213
__esModule: true,
13-
...jest.requireActual("ethers"),
14+
...jest.requireActual("ethers/contract"),
1415
Contract: jest.fn(
1516
() =>
1617
({

packages/data/src/utils.test.ts renamed to packages/data/tests/utils.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { jsDateToGraphqlDate } from "./utils"
1+
import { jsDateToGraphqlDate } from "../src/utils"
22

33
describe("Utils", () => {
44
describe("# jsDateToGraphqlDate", () => {

packages/data/tsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
{
22
"extends": "../../tsconfig.json",
3-
"include": ["src", "rollup.config.ts"]
3+
"include": ["src", "tests", "rollup.config.ts"]
44
}

packages/group/tests/index.test.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,6 @@ describe("Group", () => {
9898

9999
const exportedGroup = group.export()
100100

101-
console.log(exportedGroup)
102-
103101
expect(typeof exportedGroup).toBe("string")
104102
expect(JSON.parse(exportedGroup)).toHaveLength(3)
105103
expect(JSON.parse(exportedGroup)[0]).toHaveLength(3)

packages/proof/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@
3838
"access": "public"
3939
},
4040
"devDependencies": {
41-
"@ethersproject/strings": "^5.7.0",
4241
"@rollup/plugin-alias": "^5.1.0",
4342
"@rollup/plugin-json": "^6.1.0",
4443
"@types/download": "^8.0.5",

0 commit comments

Comments
 (0)