Skip to content

Commit

Permalink
Refactor/sempahore abi to utils (#818)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
Dozie2001 authored Jul 9, 2024
1 parent ced5f6a commit fe5cf65
Show file tree
Hide file tree
Showing 6 changed files with 916 additions and 4 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ yarn format:write
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:

```bash
yarn commit
git commit
```

It will also automatically check that the modified files comply with ESLint and Prettier rules.
Expand Down
5 changes: 4 additions & 1 deletion packages/contracts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
"private": true,
"scripts": {
"start": "hardhat node",
"compile": "hardhat compile",
"copy:abi": "ncp artifacts/contracts/Semaphore.sol/Semaphore.json ../utils/src/semaphore-abi.json",
"compile": "hardhat compile && yarn copy:abi",
"deploy": "hardhat deploy",
"verify": "hardhat run scripts/verify-contracts.ts",
"mock": "hardhat run scripts/create-mock-groups.ts",
Expand All @@ -25,11 +26,13 @@
"@typechain/hardhat": "^9.0.0",
"@types/chai": "^4.2.0",
"@types/mocha": "^10.0.6",
"@types/ncp": "^2",
"@types/node": "^20.10.7",
"chai": "^4.2.0",
"ethers": "^6.4.0",
"hardhat": "^2.19.4",
"hardhat-gas-reporter": "^1.0.8",
"ncp": "^2.0.0",
"prettier-plugin-solidity": "^1.3.1",
"solhint": "^3.3.6",
"solhint-plugin-prettier": "^0.1.0",
Expand Down
4 changes: 2 additions & 2 deletions packages/data/src/ethers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ import {
PocketProvider,
Provider
} from "ethers/providers"
import { SemaphoreABI } from "@semaphore-protocol/utils/constants"
import { EthersNetwork, EthersOptions, GroupResponse } from "./types"
import checkParameter from "./checkParameter"
import getEvents from "./getEvents"
import SemaphoreABI from "./semaphoreABI.json"
import { EthersNetwork, EthersOptions, GroupResponse } from "./types"

/**
* The SemaphoreEthers class provides a high-level interface to interact with the Semaphore smart contract
Expand Down
5 changes: 5 additions & 0 deletions packages/utils/src/constants.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
import _interface from "./semaphore-interface.json"

// Minimum supported tree depth.
export const MIN_DEPTH = 1

// Maximum supported tree depth.
export const MAX_DEPTH = 32

export const SemaphoreABI = _interface.abi
export const SemaphoreBytecode = _interface.bytecode
Loading

0 comments on commit fe5cf65

Please sign in to comment.