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

Version/4 #51

Merged
merged 34 commits into from
Feb 28, 2024
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
84cca9a
chore: upgrade semaphore version
cedoor Jan 31, 2024
62b5cf2
chore(webapp): replace localhost with 127.0.0.1
cedoor Feb 1, 2024
2b5f18f
ci: update deployment env variables
cedoor Feb 1, 2024
d3d2cd3
chore(contracts): add script to verify contracts
cedoor Feb 1, 2024
899decf
chore: add files to ignore to prettierignore
cedoor Feb 1, 2024
f94d16e
style: format code with prettier
cedoor Feb 1, 2024
b5ccb69
refactor(web-app): update ui design
cedoor Feb 1, 2024
a8ae3d6
style(web-app): format code with prettier
cedoor Feb 1, 2024
d43ea19
chore(web-app): update pages' text
cedoor Feb 2, 2024
5961c62
ci: update github actions
cedoor Feb 2, 2024
a5cf76f
chore: update semaphore dependencies
cedoor Feb 7, 2024
4742783
Merge pull request #50 from semaphore-protocol/ci/deploy
cedoor Feb 9, 2024
6ebddf7
Merge pull request #49 from semaphore-protocol/chore/localhost
cedoor Feb 9, 2024
4ae36a4
chore: update semaphore dependencies
cedoor Feb 12, 2024
04e7c11
chore(web-app): upgrade nextjs version
cedoor Feb 14, 2024
f4d8179
chore: remove eslint and ts from root package
cedoor Feb 14, 2024
5b1535e
chore: update env variables and gitignore files
cedoor Feb 14, 2024
b4b086a
ci: remove lint command
cedoor Feb 14, 2024
9ccab26
style: format code with prettier
cedoor Feb 14, 2024
9420098
chore(web-app): remove old next config file
cedoor Feb 14, 2024
7317f58
chore(web-app): replace require with import in next config
cedoor Feb 15, 2024
b3ff96b
chore: update semaphore dependencies
cedoor Feb 15, 2024
76d7bcd
chore(web-app): git-ignore pwa generated files
cedoor Feb 16, 2024
7805010
chore(web-app): git-ignore pwa generated files
cedoor Feb 16, 2024
cd2dfb0
chore(web-app): add npm script to lint code
cedoor Feb 16, 2024
04e363f
chore: update lock file
cedoor Feb 16, 2024
6e8ade1
fix(web-app): set alternative string to undefined
cedoor Feb 16, 2024
9f9ea8d
chore: add env variables to git
cedoor Feb 16, 2024
6ffe7de
fix(web-app): set correct env var name
cedoor Feb 16, 2024
07b1365
fix(web-app): add missing use-effect dependency
cedoor Feb 16, 2024
8e4d887
chore(contracts): update tsconfig include paths
cedoor Feb 28, 2024
45d969c
refactor: uopdate yarn version
vplasencia Feb 28, 2024
333731f
refactor(contracts): remove unnecessary command
vplasencia Feb 28, 2024
aa8bc67
refactor: update semaphore dependencies
vplasencia Feb 28, 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
4 changes: 2 additions & 2 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
DEFAULT_NETWORK=localhost
INFURA_API_KEY=
ETHEREUM_PRIVATE_KEY=ac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80
FEEDBACK_CONTRACT_ADDRESS=0x5fc8d32690cc91d4c39d9d3abcbd16989f875707
SEMAPHORE_CONTRACT_ADDRESS=0xdc64a140aa3e981100a9beca4e685f962f0cf6c9
FEEDBACK_CONTRACT_ADDRESS=0xCf7Ed3AccA5a467e9e704C703E8D87F634fB0Fc9
SEMAPHORE_CONTRACT_ADDRESS=0x9fE46736679d2D9a65F0992F2272dE9f3c7fa6e0
OPENZEPPELIN_AUTOTASK_WEBHOOK=
GROUP_ID=42
REPORT_GAS=false
Expand Down
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,11 @@ node_modules/
# Generate output
dist
build

# Hardhat files
artifacts
cache
typechain-types

# Next.js
.next/
Expand Down
6 changes: 5 additions & 1 deletion .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,13 @@ docs
# production
dist
build
cache
contract-artifacts

# Hardhat files
artifacts
cache
typechain-types

# github
.github/ISSUE_TEMPLATE

Expand Down
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2022 Ethereum Foundation
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
Expand Down
19 changes: 15 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
</a>
</p>

| The repository is divided into two components: [web app](./apps/web-app) and [contracts](./apps/contracts). The app allows users to create their own Semaphore identity, join a group and then send their feedback anonymously (currently on Arbitrum Goerli). |
| -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| The repository is divided into two components: [web app](./apps/web-app) and [contracts](./apps/contracts). The app allows users to create their own Semaphore identity, join a group and then send their feedback anonymously (currently on Sepolia). |
| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |

## 🛠 Install

Expand Down Expand Up @@ -65,19 +65,30 @@ yarn dev
1. Go to the `apps/contracts` directory and deploy your contract:

```bash
yarn deploy --semaphore <semaphore-address> --group <group-id> --network arbitrum-goerli
yarn deploy --semaphore <semaphore-address> --group <group-id> --network sepolia
```

2. Update your `.env` file with your new contract address, the group id and the semaphore contract address.

3. Copy your contract artifacts from `apps/contracts/build/contracts/contracts` folder to `apps/web-app/contract-artifacts` folders manually. Or run `yarn copy:contract-artifacts` in the project root to do it automatically.
3. Copy your contract artifacts from `apps/contracts/build/contracts/contracts` folder to `apps/web-app/contract-artifacts` folders.

> **Note**
> Check the Semaphore contract addresses [here](https://semaphore.pse.dev/docs/deployed-contracts).

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

### Verify the contract

Verify your contract on Etherscan:

```bash
yarn verify <your-contract-address> <semaphore-address> <group-id> --network sepolia
```

> **Note**
> Remember to set the Etherscan API Key in your .env file.

### Code quality and formatting

Run [ESLint](https://eslint.org/) to analyze the code and catch bugs:
Expand Down
22 changes: 16 additions & 6 deletions apps/contracts/contracts/Feedback.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//SPDX-License-Identifier: MIT
pragma solidity ^0.8.4;
pragma solidity ^0.8.23;

import "@semaphore-protocol/contracts/interfaces/ISemaphore.sol";

Expand All @@ -12,19 +12,29 @@ contract Feedback {
semaphore = ISemaphore(semaphoreAddress);
groupId = _groupId;

semaphore.createGroup(groupId, 20, address(this));
semaphore.createGroup(groupId, address(this));
}

function joinGroup(uint256 identityCommitment) external {
semaphore.addMember(groupId, identityCommitment);
}

function sendFeedback(
uint256 feedback,
uint256 merkleTreeDepth,
uint256 merkleTreeRoot,
uint256 nullifierHash,
uint256[8] calldata proof
uint256 nullifier,
uint256 feedback,
uint256[8] calldata points
) external {
semaphore.verifyProof(groupId, merkleTreeRoot, feedback, nullifierHash, groupId, proof);
ISemaphore.SemaphoreProof memory proof = ISemaphore.SemaphoreProof(
merkleTreeDepth,
merkleTreeRoot,
nullifier,
feedback,
groupId,
points
);

semaphore.validateProof(groupId, proof);
}
}
36 changes: 13 additions & 23 deletions apps/contracts/hardhat.config.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import "@nomicfoundation/hardhat-chai-matchers"
import "@nomiclabs/hardhat-ethers"
import "@nomiclabs/hardhat-etherscan"
import "@nomicfoundation/hardhat-ethers"
import "@nomicfoundation/hardhat-verify"
import "@semaphore-protocol/hardhat"
import "@typechain/hardhat"
import { config as dotenvConfig } from "dotenv"
Expand All @@ -9,7 +9,6 @@ import { HardhatUserConfig } from "hardhat/config"
import { NetworksUserConfig } from "hardhat/types"
import { resolve } from "path"
import "solidity-coverage"
import { config } from "./package.json"
import "./tasks/deploy"

dotenvConfig({ path: resolve(__dirname, "../../.env") })
Expand All @@ -23,11 +22,6 @@ function getNetworks(): NetworksUserConfig {
const infuraApiKey = process.env.INFURA_API_KEY

return {
goerli: {
url: `https://goerli.infura.io/v3/${infuraApiKey}`,
chainId: 5,
accounts
},
sepolia: {
url: `https://sepolia.infura.io/v3/${infuraApiKey}`,
chainId: 11155111,
Expand All @@ -38,14 +32,14 @@ function getNetworks(): NetworksUserConfig {
chainId: 80001,
accounts
},
"optimism-goerli": {
url: `https://optimism-goerli.infura.io/v3/${infuraApiKey}`,
chainId: 420,
"optimism-sepolia": {
url: `https://optimism-sepolia.infura.io/v3/${infuraApiKey}`,
chainId: 11155420,
accounts
},
"arbitrum-goerli": {
url: "https://goerli-rollup.arbitrum.io/rpc",
chainId: 421613,
"arbitrum-sepolia": {
url: "https://sepolia-rollup.arbitrum.io/rpc",
chainId: 421614,
accounts
},
arbitrum: {
Expand All @@ -57,13 +51,7 @@ function getNetworks(): NetworksUserConfig {
}

const hardhatConfig: HardhatUserConfig = {
solidity: config.solidity,
paths: {
sources: config.paths.contracts,
tests: config.paths.tests,
cache: config.paths.cache,
artifacts: config.paths.build.contracts
},
solidity: "0.8.23",
networks: {
hardhat: {
chainId: 1337
Expand All @@ -76,11 +64,13 @@ const hardhatConfig: HardhatUserConfig = {
coinmarketcap: process.env.COINMARKETCAP_API_KEY
},
typechain: {
outDir: config.paths.build.typechain,
target: "ethers-v5"
target: "ethers-v6"
},
etherscan: {
apiKey: process.env.ETHERSCAN_API_KEY
},
sourcify: {
enabled: true
}
}

Expand Down
53 changes: 18 additions & 35 deletions apps/contracts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,55 +6,38 @@
"scripts": {
"dev": "hardhat node & yarn compile && yarn deploy --network localhost",
"compile": "hardhat compile",
"download:snark-artifacts": "hardhat run scripts/download-snark-artifacts.ts",
"deploy": "yarn compile && hardhat deploy",
"test": "hardhat run scripts/download-snark-artifacts.ts && hardhat test",
"verify": "hardhat verify",
"test": "hardhat test",
"test:report-gas": "REPORT_GAS=true hardhat test",
"test:coverage": "hardhat coverage",
"typechain": "hardhat typechain",
"lint": "solhint 'contracts/**/*.sol'"
},
"devDependencies": {
"@nomicfoundation/hardhat-chai-matchers": "^1.0.5",
"@nomiclabs/hardhat-ethers": "^2.0.0",
"@nomiclabs/hardhat-etherscan": "^3.1.7",
"@semaphore-protocol/group": "3.15.0",
"@semaphore-protocol/hardhat": "3.15.0",
"@semaphore-protocol/identity": "3.15.0",
"@semaphore-protocol/proof": "3.15.0",
"@typechain/ethers-v5": "^10.0.0",
"@typechain/hardhat": "^6.0.0",
"@types/chai": "^4.3.1",
"@types/download": "^8.0.1",
"@nomicfoundation/hardhat-chai-matchers": "^2.0.3",
"@nomicfoundation/hardhat-ethers": "^3.0.0",
"@nomicfoundation/hardhat-network-helpers": "^1.0.0",
"@nomicfoundation/hardhat-toolbox": "^4.0.0",
"@nomicfoundation/hardhat-verify": "^2.0.0",
"@semaphore-protocol/core": "4.0.0-alpha.6",
"@semaphore-protocol/hardhat": "4.0.0-alpha.6",
"@typechain/ethers-v6": "^0.5.0",
"@typechain/hardhat": "^9.0.0",
"@types/chai": "^4.2.0",
"@types/mocha": "^9.1.1",
"chai": "^4.2.0",
"dotenv": "^14.3.2",
"download": "^8.0.0",
"ethers": "^5.0.0",
"hardhat": "^2.8.4",
"ethers": "^6.4.0",
"hardhat": "^2.19.4",
"hardhat-gas-reporter": "^1.0.8",
"prettier-plugin-solidity": "^1.0.0-beta.19",
"prettier-plugin-solidity": "^1.3.1",
"solhint": "^3.3.6",
"solhint-plugin-prettier": "^0.0.5",
"solidity-coverage": "^0.7.21",
"typechain": "^8.0.0"
"solidity-coverage": "^0.8.0",
"typechain": "^8.3.0"
},
"dependencies": {
"@semaphore-protocol/contracts": "3.15.0"
},
"config": {
"solidity": {
"version": "0.8.4"
},
"paths": {
"contracts": "./contracts",
"tests": "./test",
"cache": "./cache",
"build": {
"snark-artifacts": "./build/snark-artifacts",
"contracts": "./build/contracts",
"typechain": "./build/typechain"
}
}
"@semaphore-protocol/contracts": "4.0.0-alpha.6"
}
}
24 changes: 0 additions & 24 deletions apps/contracts/scripts/download-snark-artifacts.ts

This file was deleted.

6 changes: 2 additions & 4 deletions apps/contracts/tasks/deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ task("deploy", "Deploy a Feedback contract")
logs
})

semaphoreAddress = semaphore.address
semaphoreAddress = await semaphore.getAddress()
}

if (!groupId) {
Expand All @@ -21,10 +21,8 @@ task("deploy", "Deploy a Feedback contract")

const feedbackContract = await FeedbackFactory.deploy(semaphoreAddress, groupId)

await feedbackContract.deployed()

if (logs) {
console.info(`Feedback contract has been deployed to: ${feedbackContract.address}`)
console.info(`Feedback contract has been deployed to: ${await feedbackContract.getAddress()}`)
}

return feedbackContract
Expand Down
Loading
Loading