Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/v4 contracts #14

Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
48e547f
feat(contracts)!: introduces Semaphore extension contracts with v4
Dozie2001 Jul 12, 2024
69eba3f
refactor(contracts): fixing the voters contracts
Dozie2001 Jul 12, 2024
c05a825
docs(contracts): updated instructions on setting up contracts
Dozie2001 Jul 16, 2024
a7e1ac4
ci(contracts): scripts that deploy contracts and gets addresses
Dozie2001 Jul 16, 2024
606b72f
test(contracts): added test for both whistleblowing and voting
Dozie2001 Jul 17, 2024
bd82eef
refactor(contracts): refactored contracts to use v4 and added license…
Dozie2001 Jul 17, 2024
fb0f323
build(contracts): added dependencies and deploye contracts
Dozie2001 Jul 17, 2024
863e967
chore(contracts): corrected dependency
Dozie2001 Jul 17, 2024
0b04d8a
docs(contracts): refactored the docs
Dozie2001 Jul 17, 2024
1824a75
chore(contracts): fixed documentation and configuration files
Dozie2001 Jul 17, 2024
a7d0e46
docs(contracts): created a sym link to README
Dozie2001 Jul 20, 2024
be166c2
ci(contracts): added scripts to test and compile
Dozie2001 Jul 20, 2024
b22c3e2
ci(contracts): fixed config files and solhint script
Dozie2001 Jul 23, 2024
a384dcb
docs(contracts): made README docs more general
Dozie2001 Jul 23, 2024
92c7fc9
fix(contracts): fixed event errors
Dozie2001 Jul 24, 2024
f2ee102
refactor(contracts): changed the groups variable to semaphore since I…
Dozie2001 Jul 26, 2024
4ebca0f
refactor(contracts): removed unsused argument
Dozie2001 Jul 29, 2024
22ca14f
fix(contracts): refactored the contracts and removed unuses parameters
Dozie2001 Jul 30, 2024
ab24a70
docs(contracts): updated Documentation by removing groupId
Dozie2001 Aug 2, 2024
7223265
refactor(contracts): removed inheritance from SemaphoreGroups
Dozie2001 Aug 2, 2024
517ea8f
refactor(contracts): removed SemaphoreGroups import
Dozie2001 Aug 2, 2024
2a436b5
fix(contracts): added proof Validation and fixed contracts deploy
Dozie2001 Aug 5, 2024
f348d67
refactor(contracts): refactored code and removed bool value in saved …
Dozie2001 Aug 7, 2024
1e94729
refactor(contracts): removed nullifiers redudant mapping
Dozie2001 Aug 7, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .lintstagedrc.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"**/*.{js,ts,jsx,tsx,md,json,sol}": "prettier --write",
"**/*.{js,ts,jsx,tsx,md,json,sol,yaml,yml}": "prettier --write",
"**/*.{js,ts,jsx,tsx}": "eslint"
}
13 changes: 13 additions & 0 deletions packages/contracts/.editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#root = true

[*]
indent_style = space
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
max_line_length = 120
indent_size = 4

[*.md]
trim_trailing_whitespace = false
4 changes: 4 additions & 0 deletions packages/contracts/.env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
ETHEREUM_PRIVATE_KEY=
REPORT_GAS=false
ETHERSCAN_API_KEY=
COINMARKETCAP_API_KEY=
23 changes: 23 additions & 0 deletions packages/contracts/.eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# dependencies
node_modules
package-lock.json
yarn.lock
.yarn

# testing
coverage
coverage.json

# hardhat
artifacts
cache
typechain-types

# misc
.DS_Store
*.pem

# debug
npm-debug.log*
yarn-debug.log*
yarn-error.log*
24 changes: 24 additions & 0 deletions packages/contracts/.eslintrc.json
Dozie2001 marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"root": true,
"env": {
"es6": true
},
"extends": ["airbnb-base", "airbnb-typescript/base", "prettier"],
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaVersion": 6,
"sourceType": "module",
"project": ["./tsconfig.json"]
},
"plugins": ["@typescript-eslint"],
"rules": {
"no-underscore-dangle": "off",
"import/no-extraneous-dependencies": "off",
"no-bitwise": "off",
"no-await-in-loop": "off",
"no-restricted-syntax": "off",
"no-console": ["warn", { "allow": ["info", "warn", "error", "log"] }],
"@typescript-eslint/lines-between-class-members": "off",
"no-param-reassign": "off"
}
}
71 changes: 71 additions & 0 deletions packages/contracts/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
node_modules
.env

# Hardhat files
/cache
/artifacts
Dozie2001 marked this conversation as resolved.
Show resolved Hide resolved

# TypeChain files
/typechain
/typechain-types

# solidity-coverage files
/coverage
/coverage.json

# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log*
.pnpm-debug.log*

# Diagnostic reports (https://nodejs.org/api/report.html)
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json

# Runtime data
pids
*.pid
*.seed
*.pid.lock

# IDE
.vscode
.idea

# Dependency directories
node_modules/

# Output of 'npm pack'
*.tgz

# Microbundle cache
.rpt2_cache/
.rts2_cache_cjs/
.rts2_cache_es/
.rts2_cache_umd/

# Yarn Integrity file
.yarn-integrity

# vercel
.vercel

# dotenv environment variable files
.env

# Optional npm cache directory
.npm
.DS_Store

# yarn v3
.pnp.*
.pnp.js
.yarn/*
!.yarn/patches
!.yarn/plugins
!.yarn/releases
!.yarn/sdks
!.yarn/versions
29 changes: 29 additions & 0 deletions packages/contracts/.prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# dependencies
node_modules
package-lock.json
yarn.lock
.yarn

# debug
npm-debug.log*
yarn-debug.log*
yarn-error.log*

# testing
coverage
coverage.json

# hardhat
artifacts
cache
typechain-types

# misc
.DS_Store
*.pem

# debug
npm-debug.log*
yarn-debug.log*
yarn-error.log*

6 changes: 6 additions & 0 deletions packages/contracts/.prettierrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"semi": false,
"arrowParens": "always",
"trailingComma": "none",
"plugins": ["prettier-plugin-solidity"]
}
893 changes: 893 additions & 0 deletions packages/contracts/.yarn/releases/yarn-4.1.0.cjs
Dozie2001 marked this conversation as resolved.
Show resolved Hide resolved

Large diffs are not rendered by default.

7 changes: 7 additions & 0 deletions packages/contracts/.yarnrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
compressionLevel: mixed

enableGlobalCache: false

nodeLinker: node-modules

yarnPath: .yarn/releases/yarn-4.1.0.cjs
108 changes: 108 additions & 0 deletions packages/contracts/README.md
Dozie2001 marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
<p align="center">
<h1 align="center">
Semaphore Extension Contracts
</h1>
<p align="center">Extension contracts to manage Voting and whistleBlowing</p>
</p>

<p align="center">
<a href="https://github.com/semaphore-protocol">
<img src="https://img.shields.io/badge/project-Semaphore-blue.svg?style=flat-square">
</a>
Dozie2001 marked this conversation as resolved.
Show resolved Hide resolved
<div align="center">
<h4>
<a href="https://github.com/semaphore-protocol/extensions/blob/main/CONTRIBUTING.md">
👥 Contributing
</a>
<span>&nbsp;&nbsp;|&nbsp;&nbsp;</span>
<a href="https://github.com/semaphore-protocol/extensions/blob/main/CODE_OF_CONDUCT.md">
🤝 Code of conduct
</a>
<span>&nbsp;&nbsp;|&nbsp;&nbsp;</span>
<a href="https://github.com/semaphore-protocol/extensions/contribute">
🔎 Issues
</a>
<span>&nbsp;&nbsp;|&nbsp;&nbsp;</span>
<a href="https://semaphore.pse.dev/discord">
🗣️ Chat &amp; Support
</a>
</h4>
</div>

## 🛠 Install

### npm or yarn

Install the `@semaphore-extension/contracts` package with npm:

```bash
npm i @semaphore-extension/contracts
```

Dozie2001 marked this conversation as resolved.
Show resolved Hide resolved
## Usage

### Compile contracts

```bash
yarn compile
```

### Test contracts

```bash
yarn test
```

You can also generate a test coverage report:

```bash
yarn test:coverage
```

Or a test gas report:

```bash
yarn test:report-gas
```

1. Copy the `.env.example` file as `.env`.

```bash
cp .env.example .env
```

2. Add your environment variables.

> **Note**
> You should at least set a valid Ethereum URL (e.g. Infura) and a private key with some ethers.

### Deploy contracts

Deploy the `Semaphore.sol` contract without any parameter:
Dozie2001 marked this conversation as resolved.
Show resolved Hide resolved

```bash
yarn deploy
```

> **Warning**
> The group id is a number!

### Code quality and formatting

Run [ESLint](https://eslint.org/) and [solhint](https://github.com/protofire/solhint) to analyze the code and catch bugs:

```bash
yarn lint
```

Run [Prettier](https://prettier.io/) to check formatting rules:

```bash
yarn prettier
```

Or to automatically format the code:

```bash
yarn prettier:write
```
Dozie2001 marked this conversation as resolved.
Show resolved Hide resolved
21 changes: 21 additions & 0 deletions packages/contracts/contracts/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2024 Ethereum Foundation

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
Loading