Skip to content

Commit

Permalink
refactor: use ethers conditional exports
Browse files Browse the repository at this point in the history
re #632
  • Loading branch information
cedoor committed Feb 15, 2024
1 parent 169445a commit 22d391d
Show file tree
Hide file tree
Showing 9 changed files with 17 additions and 16 deletions.
8 changes: 4 additions & 4 deletions packages/data/src/ethers.ts
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
2 changes: 1 addition & 1 deletion packages/data/src/getEvents.ts
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
7 changes: 4 additions & 3 deletions packages/data/tests/ethers.test.ts
Original file line number Diff line number Diff line change
@@ -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"

Expand All @@ -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(
() =>
({
Expand Down
2 changes: 1 addition & 1 deletion packages/data/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"extends": "../../tsconfig.json",
"include": ["src", "rollup.config.ts"]
"include": ["src", "tests", "rollup.config.ts"]
}
1 change: 0 additions & 1 deletion packages/proof/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
1 change: 0 additions & 1 deletion packages/proof/src/generate-proof.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
3 changes: 2 additions & 1 deletion packages/proof/src/hash.ts
Original file line number Diff line number Diff line change
@@ -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"

Expand Down
3 changes: 2 additions & 1 deletion packages/proof/src/to-bigint.ts
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down
6 changes: 3 additions & 3 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
"baseUrl": ".",
"strict": true,
"target": "ES5",
"module": "ES6",
"moduleResolution": "node",
"module": "ESNext",
"moduleResolution": "Bundler",
"esModuleInterop": true,
"preserveConstEnums": true,
"resolveJsonModule": true,
Expand All @@ -14,7 +14,7 @@
"declarationDir": "types",
"typeRoots": ["node_modules/@types", "types"],
"paths": {
"@semaphore-protocol/*": ["packages/*/src"]
"@semaphore-protocol/*": ["./packages/*/src"]
}
},
"ts-node": {
Expand Down

0 comments on commit 22d391d

Please sign in to comment.