Merge pull request #634 from semaphore-protocol/refactor/conditional-exports

`ethers` conditional exports
This commit is contained in:
Cedoor
2024-02-15 19:11:19 +00:00
committed by GitHub
15 changed files with 757 additions and 1489 deletions

View File

@@ -1,3 +0,0 @@
{
"presets": [["@babel/preset-env", { "targets": { "node": "current" } }], "@babel/preset-typescript"]
}

View File

@@ -1,5 +1,5 @@
import fs from "fs"
import type { Config } from "@jest/types"
import type { Config } from "jest"
const exclude = ["circuits", "contracts"]
@@ -8,6 +8,7 @@ const projects: any = fs
.filter((directory) => directory.isDirectory())
.filter((directory) => !exclude.includes(directory.name))
.map(({ name }) => ({
preset: "ts-jest",
rootDir: `packages/${name}`,
displayName: name,
setupFiles: ["dotenv/config"],
@@ -16,11 +17,10 @@ const projects: any = fs
}
}))
export default async (): Promise<Config.InitialOptions> => ({
const config: Config = {
projects,
verbose: true,
coverageDirectory: "./coverage/libraries",
collectCoverageFrom: ["<rootDir>/src/**/*.ts", "!<rootDir>/src/**/index.ts", "!<rootDir>/src/**/*.d.ts"],
coverageThreshold: {
global: {
branches: 90,
@@ -29,4 +29,6 @@ export default async (): Promise<Config.InitialOptions> => ({
statements: 95
}
}
})
}
export default config

View File

@@ -48,21 +48,17 @@
],
"packageManager": "yarn@3.2.1",
"devDependencies": {
"@babel/core": "^7.16.7",
"@babel/preset-env": "^7.16.8",
"@babel/preset-typescript": "^7.17.12",
"@commitlint/cli": "^16.0.2",
"@commitlint/config-conventional": "^16.0.0",
"@rollup/plugin-typescript": "^11.1.6",
"@types/circomlibjs": "^0.1.4",
"@types/download": "^8.0.1",
"@types/glob": "^7.2.0",
"@types/jest": "^27.4.0",
"@types/jest": "^29.5.12",
"@types/node": "^20",
"@types/rimraf": "^3.0.2",
"@typescript-eslint/eslint-plugin": "^5.9.1",
"@typescript-eslint/parser": "^5.9.1",
"babel-jest": "^27.4.6",
"changelogithub": "0.12.7",
"commitizen": "^4.2.4",
"cz-conventional-changelog": "^3.3.0",
@@ -72,18 +68,19 @@
"eslint-config-airbnb-typescript": "^16.1.0",
"eslint-config-prettier": "^8.3.0",
"eslint-plugin-import": "^2.25.2",
"eslint-plugin-jest": "^25.7.0",
"eslint-plugin-jest": "^27.8.0",
"eslint-plugin-jsx-a11y": "^6.8.0",
"eslint-plugin-react": "^7.33.2",
"eslint-plugin-react-hooks": "^4.6.0",
"husky": "^8.0.3",
"jest": "^27.4.1",
"jest-config": "^27.4.7",
"jest": "^29.7.0",
"jest-config": "^29.7.0",
"lint-staged": "^12.1.7",
"prettier": "^2.5.1",
"rimraf": "^3.0.2",
"rollup": "^4.9.6",
"snarkjs": "^0.7.2",
"ts-jest": "^29.1.2",
"ts-node": "^10.9.2",
"tslib": "^2.6.2",
"typedoc": "^0.25.7",

View File

@@ -1,15 +1,15 @@
import { ZeroAddress } from "ethers/constants"
import { Contract } from "ethers/contract"
import {
AlchemyProvider,
AnkrProvider,
CloudflareProvider,
Contract,
EtherscanProvider,
InfuraProvider,
JsonRpcProvider,
PocketProvider,
Provider,
ZeroAddress
} from "ethers"
Provider
} from "ethers/providers"
import checkParameter from "./checkParameter"
import getEvents from "./getEvents"
import SemaphoreABI from "./semaphoreABI.json"

View File

@@ -1,5 +1,5 @@
/* istanbul ignore file */
import { Contract, EventLog } from "ethers"
import { Contract, EventLog } from "ethers/contract"
/**
* Returns the list of events of a contract with possible filters.

View File

@@ -1,5 +1,6 @@
/* eslint-disable no-sparse-arrays */
import { Contract, ZeroAddress } from "ethers"
import { ZeroAddress } from "ethers/constants"
import { Contract } from "ethers/contract"
import SemaphoreEthers from "../src/ethers"
import getEvents from "../src/getEvents"
@@ -8,9 +9,9 @@ jest.mock("../src/getEvents", () => ({
default: jest.fn()
}))
jest.mock("ethers", () => ({
jest.mock("ethers/contract", () => ({
__esModule: true,
...jest.requireActual("ethers"),
...jest.requireActual("ethers/contract"),
Contract: jest.fn(
() =>
({

View File

@@ -1,4 +1,4 @@
import { jsDateToGraphqlDate } from "./utils"
import { jsDateToGraphqlDate } from "../src/utils"
describe("Utils", () => {
describe("# jsDateToGraphqlDate", () => {

View File

@@ -1,4 +1,4 @@
{
"extends": "../../tsconfig.json",
"include": ["src", "rollup.config.ts"]
"include": ["src", "tests", "rollup.config.ts"]
}

View File

@@ -98,8 +98,6 @@ describe("Group", () => {
const exportedGroup = group.export()
console.log(exportedGroup)
expect(typeof exportedGroup).toBe("string")
expect(JSON.parse(exportedGroup)).toHaveLength(3)
expect(JSON.parse(exportedGroup)[0]).toHaveLength(3)

View File

@@ -38,7 +38,6 @@
"access": "public"
},
"devDependencies": {
"@ethersproject/strings": "^5.7.0",
"@rollup/plugin-alias": "^5.1.0",
"@rollup/plugin-json": "^6.1.0",
"@types/download": "^8.0.5",

View File

@@ -48,7 +48,6 @@ export default async function generateProof(
}
// If the Snark artifacts are not defined they will be automatically downloaded.
/* istanbul ignore next */
if (!snarkArtifacts) {
snarkArtifacts = await getSnarkArtifacts(merkleTreeDepth)
}

View File

@@ -1,4 +1,5 @@
import { keccak256, toBeHex } from "ethers"
import { keccak256 } from "ethers/crypto"
import { toBeHex } from "ethers/utils"
import { NumericString } from "snarkjs"
import { BigNumberish } from "./types"

View File

@@ -1,4 +1,5 @@
import { encodeBytes32String, toBigInt as _toBigInt } from "ethers"
import { encodeBytes32String } from "ethers/abi"
import { toBigInt as _toBigInt } from "ethers/utils"
import { BigNumberish } from "./types"
export default function toBigInt(value: BigNumberish | Uint8Array | string): bigint {

View File

@@ -3,8 +3,8 @@
"baseUrl": ".",
"strict": true,
"target": "ES5",
"module": "ES6",
"moduleResolution": "node",
"module": "ESNext",
"moduleResolution": "Bundler",
"esModuleInterop": true,
"preserveConstEnums": true,
"resolveJsonModule": true,
@@ -14,7 +14,7 @@
"declarationDir": "types",
"typeRoots": ["node_modules/@types", "types"],
"paths": {
"@semaphore-protocol/*": ["packages/*/src"]
"@semaphore-protocol/*": ["./packages/*/src"]
}
},
"ts-node": {

2183
yarn.lock

File diff suppressed because it is too large Load Diff