Skip to content

Commit fe5cf65

Browse files
authored
Refactor/sempahore abi to utils (#818)
* ci(contracts): a script that moves the abi.json file created to utils folder A script could be run immediately after compilation to copy the file artifacts/contracts/Semaphore.sol/Semaphore.json to packages/utils/src/semaphore-abi.json. Then all packages/apps that need the interface can import it from @semaphore-protocol/utils. re #817 * refactor(utils): allows packages to import abi from @semaphore-protocol/utils re #817 * refactor(cli-template-monorepo-ethers): installs ncp and exports Semaphore Abi byte code re #817 * refactor(contracts): added a script that automates movement of semaphore-abi.json * chore(cli): changed the dependency and moved to ncp for copying semaphore abi Changed the importation of abi in utils to _interface and moved the ncp to a dev depency * chore(utils): changed ab to _interface and update to package.json * chore(cli): deleted Cli-template file and made a document change delted some cli-template file, changed yarn commit to git commit and fixed the yarn compile script
1 parent ced5f6a commit fe5cf65

File tree

6 files changed

+916
-4
lines changed

6 files changed

+916
-4
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,7 @@ yarn format:write
313313
Semaphore uses [conventional commits](https://www.conventionalcommits.org/en/v1.0.0/). A [command line utility](https://github.com/commitizen/cz-cli) to commit using the correct syntax can be used by running:
314314

315315
```bash
316-
yarn commit
316+
git commit
317317
```
318318

319319
It will also automatically check that the modified files comply with ESLint and Prettier rules.

packages/contracts/package.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
"private": true,
44
"scripts": {
55
"start": "hardhat node",
6-
"compile": "hardhat compile",
6+
"copy:abi": "ncp artifacts/contracts/Semaphore.sol/Semaphore.json ../utils/src/semaphore-abi.json",
7+
"compile": "hardhat compile && yarn copy:abi",
78
"deploy": "hardhat deploy",
89
"verify": "hardhat run scripts/verify-contracts.ts",
910
"mock": "hardhat run scripts/create-mock-groups.ts",
@@ -25,11 +26,13 @@
2526
"@typechain/hardhat": "^9.0.0",
2627
"@types/chai": "^4.2.0",
2728
"@types/mocha": "^10.0.6",
29+
"@types/ncp": "^2",
2830
"@types/node": "^20.10.7",
2931
"chai": "^4.2.0",
3032
"ethers": "^6.4.0",
3133
"hardhat": "^2.19.4",
3234
"hardhat-gas-reporter": "^1.0.8",
35+
"ncp": "^2.0.0",
3336
"prettier-plugin-solidity": "^1.3.1",
3437
"solhint": "^3.3.6",
3538
"solhint-plugin-prettier": "^0.1.0",

packages/data/src/ethers.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@ import {
1616
PocketProvider,
1717
Provider
1818
} from "ethers/providers"
19+
import { SemaphoreABI } from "@semaphore-protocol/utils/constants"
20+
import { EthersNetwork, EthersOptions, GroupResponse } from "./types"
1921
import checkParameter from "./checkParameter"
2022
import getEvents from "./getEvents"
21-
import SemaphoreABI from "./semaphoreABI.json"
22-
import { EthersNetwork, EthersOptions, GroupResponse } from "./types"
2323

2424
/**
2525
* The SemaphoreEthers class provides a high-level interface to interact with the Semaphore smart contract

packages/utils/src/constants.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
1+
import _interface from "./semaphore-interface.json"
2+
13
// Minimum supported tree depth.
24
export const MIN_DEPTH = 1
35

46
// Maximum supported tree depth.
57
export const MAX_DEPTH = 32
8+
9+
export const SemaphoreABI = _interface.abi
10+
export const SemaphoreBytecode = _interface.bytecode

0 commit comments

Comments
 (0)