mirror of
https://github.com/semaphore-protocol/semaphore.git
synced 2026-01-09 14:48:12 -05:00
chore(cli): update template contracts
re #722
Former-commit-id: 895f9e1e9e
This commit is contained in:
@@ -8,11 +8,10 @@ contract Feedback {
|
||||
|
||||
uint256 public groupId;
|
||||
|
||||
constructor(address semaphoreAddress, uint256 _groupId) {
|
||||
constructor(address semaphoreAddress) {
|
||||
semaphore = ISemaphore(semaphoreAddress);
|
||||
groupId = _groupId;
|
||||
|
||||
semaphore.createGroup(groupId, address(this));
|
||||
groupId = semaphore.createGroup();
|
||||
}
|
||||
|
||||
function joinGroup(uint256 identityCommitment) external {
|
||||
|
||||
@@ -2,9 +2,8 @@ import { task, types } from "hardhat/config"
|
||||
|
||||
task("deploy", "Deploy a Feedback contract")
|
||||
.addOptionalParam("semaphore", "Semaphore contract address", undefined, types.string)
|
||||
.addOptionalParam("group", "Group id", "42", types.string)
|
||||
.addOptionalParam("logs", "Print the logs", true, types.boolean)
|
||||
.setAction(async ({ logs, semaphore: semaphoreAddress, group: groupId }, { ethers, run }) => {
|
||||
.setAction(async ({ logs, semaphore: semaphoreAddress }, { ethers, run }) => {
|
||||
if (!semaphoreAddress) {
|
||||
const { semaphore } = await run("deploy:semaphore", {
|
||||
logs
|
||||
@@ -13,13 +12,9 @@ task("deploy", "Deploy a Feedback contract")
|
||||
semaphoreAddress = await semaphore.getAddress()
|
||||
}
|
||||
|
||||
if (!groupId) {
|
||||
groupId = process.env.GROUP_ID
|
||||
}
|
||||
|
||||
const FeedbackFactory = await ethers.getContractFactory("Feedback")
|
||||
|
||||
const feedbackContract = await FeedbackFactory.deploy(semaphoreAddress, groupId)
|
||||
const feedbackContract = await FeedbackFactory.deploy(semaphoreAddress)
|
||||
|
||||
if (logs) {
|
||||
console.info(`Feedback contract has been deployed to: ${await feedbackContract.getAddress()}`)
|
||||
|
||||
@@ -9,8 +9,6 @@ import { Feedback, ISemaphore } from "../typechain-types"
|
||||
|
||||
describe("Feedback", () => {
|
||||
async function deployFeedbackFixture() {
|
||||
const groupId = "42"
|
||||
|
||||
const { semaphore } = await run("deploy:semaphore", {
|
||||
logs: false
|
||||
})
|
||||
@@ -19,10 +17,11 @@ describe("Feedback", () => {
|
||||
|
||||
const feedbackContract: Feedback = await run("deploy", {
|
||||
logs: false,
|
||||
group: groupId,
|
||||
semaphore: await semaphoreContract.getAddress()
|
||||
})
|
||||
|
||||
const groupId = await feedbackContract.groupId()
|
||||
|
||||
return { semaphoreContract, feedbackContract, groupId }
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
DEFAULT_NETWORK=localhost
|
||||
DEFAULT_NETWORK=hardhat
|
||||
ETHEREUM_PRIVATE_KEY=ac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80
|
||||
REPORT_GAS=false
|
||||
COINMARKETCAP_API_KEY=
|
||||
|
||||
@@ -8,11 +8,10 @@ contract Feedback {
|
||||
|
||||
uint256 public groupId;
|
||||
|
||||
constructor(address semaphoreAddress, uint256 _groupId) {
|
||||
constructor(address semaphoreAddress) {
|
||||
semaphore = ISemaphore(semaphoreAddress);
|
||||
groupId = _groupId;
|
||||
|
||||
semaphore.createGroup(groupId, address(this));
|
||||
groupId = semaphore.createGroup();
|
||||
}
|
||||
|
||||
function joinGroup(uint256 identityCommitment) external {
|
||||
|
||||
@@ -10,7 +10,7 @@ dotenvConfig({ path: resolve(__dirname, "../../.env") })
|
||||
|
||||
const config: HardhatUserConfig = {
|
||||
solidity: "0.8.23",
|
||||
defaultNetwork: process.env.DEFAULT_NETWORK || "localhost",
|
||||
defaultNetwork: process.env.DEFAULT_NETWORK || "hardhat",
|
||||
networks: {
|
||||
hardhat: {
|
||||
chainId: 1337
|
||||
|
||||
@@ -2,9 +2,8 @@ import { task, types } from "hardhat/config"
|
||||
|
||||
task("deploy", "Deploy a Feedback contract")
|
||||
.addOptionalParam("semaphore", "Semaphore contract address", undefined, types.string)
|
||||
.addOptionalParam("group", "Group id", "42", types.string)
|
||||
.addOptionalParam("logs", "Print the logs", true, types.boolean)
|
||||
.setAction(async ({ logs, semaphore: semaphoreAddress, group: groupId }, { ethers, run }) => {
|
||||
.setAction(async ({ logs, semaphore: semaphoreAddress }, { ethers, run }) => {
|
||||
if (!semaphoreAddress) {
|
||||
const { semaphore } = await run("deploy:semaphore", {
|
||||
logs
|
||||
@@ -13,13 +12,9 @@ task("deploy", "Deploy a Feedback contract")
|
||||
semaphoreAddress = await semaphore.getAddress()
|
||||
}
|
||||
|
||||
if (!groupId) {
|
||||
groupId = process.env.GROUP_ID
|
||||
}
|
||||
|
||||
const FeedbackFactory = await ethers.getContractFactory("Feedback")
|
||||
|
||||
const feedbackContract = await FeedbackFactory.deploy(semaphoreAddress, groupId)
|
||||
const feedbackContract = await FeedbackFactory.deploy(semaphoreAddress)
|
||||
|
||||
if (logs) {
|
||||
console.info(`Feedback contract has been deployed to: ${await feedbackContract.getAddress()}`)
|
||||
|
||||
@@ -9,8 +9,6 @@ import { Feedback, ISemaphore } from "../typechain-types"
|
||||
|
||||
describe("Feedback", () => {
|
||||
async function deployFeedbackFixture() {
|
||||
const groupId = "42"
|
||||
|
||||
const { semaphore } = await run("deploy:semaphore", {
|
||||
logs: false
|
||||
})
|
||||
@@ -19,10 +17,11 @@ describe("Feedback", () => {
|
||||
|
||||
const feedbackContract: Feedback = await run("deploy", {
|
||||
logs: false,
|
||||
group: groupId,
|
||||
semaphore: await semaphoreContract.getAddress()
|
||||
})
|
||||
|
||||
const groupId = await feedbackContract.groupId()
|
||||
|
||||
return { semaphoreContract, feedbackContract, groupId }
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
NEXT_PUBLIC_DEFAULT_NETWORK=localhost
|
||||
NEXT_PUBLIC_FEEDBACK_CONTRACT_ADDRESS=0xCf7Ed3AccA5a467e9e704C703E8D87F634fB0Fc9
|
||||
NEXT_PUBLIC_SEMAPHORE_CONTRACT_ADDRESS=0x9fE46736679d2D9a65F0992F2272dE9f3c7fa6e0
|
||||
NEXT_PUBLIC_GROUP_ID=42
|
||||
NEXT_PUBLIC_GROUP_ID=0
|
||||
|
||||
5
packages/cli-template-monorepo-ethers/apps/web-app/next-env.d.ts
vendored
Normal file
5
packages/cli-template-monorepo-ethers/apps/web-app/next-env.d.ts
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
/// <reference types="next" />
|
||||
/// <reference types="next/image-types/global" />
|
||||
|
||||
// NOTE: This file should not be edited
|
||||
// see https://nextjs.org/docs/basic-features/typescript for more information.
|
||||
@@ -11,6 +11,7 @@
|
||||
"dependencies": {
|
||||
"@semaphore-protocol/core": "4.0.0-beta.4",
|
||||
"@semaphore-protocol/data": "4.0.0-beta.4",
|
||||
"@semaphore-protocol/utils": "4.0.0-beta.4",
|
||||
"ethers": "^6.11.1",
|
||||
"next": "14.1.0",
|
||||
"next-pwa": "^5.6.0",
|
||||
|
||||
@@ -74,7 +74,7 @@ export default function GroupsPage() {
|
||||
setLoading(false)
|
||||
}, [_identity])
|
||||
|
||||
const userHasJoined = useCallback((identity: Identity) => _users.includes(identity.commitment), [_users])
|
||||
const userHasJoined = useCallback((identity: Identity) => _users.includes(identity.commitment.toString()), [_users])
|
||||
|
||||
return (
|
||||
<>
|
||||
|
||||
@@ -4,7 +4,7 @@ import LogsContext from "@/context/LogsContext"
|
||||
import SemaphoreContext from "@/context/SemaphoreContext"
|
||||
import useSemaphore from "@/hooks/useSemaphore"
|
||||
import shortenString from "@/utils/shortenString"
|
||||
import { SupportedNetwork } from "@semaphore-protocol/data"
|
||||
import { SupportedNetwork } from "@semaphore-protocol/utils"
|
||||
import { usePathname } from "next/navigation"
|
||||
import { useEffect, useState } from "react"
|
||||
import Link from "next/link"
|
||||
@@ -52,7 +52,7 @@ export default function PageContainer({
|
||||
<div>{shortenString(process.env.NEXT_PUBLIC_FEEDBACK_CONTRACT_ADDRESS as string, [6, 4])}</div>
|
||||
</a>
|
||||
<a
|
||||
href="https://github.com/semaphore-protocol/boilerplate"
|
||||
href="https://github.com/semaphore-protocol/semaphore"
|
||||
target="_blank"
|
||||
rel="noreferrer noopener nofollow"
|
||||
>
|
||||
|
||||
@@ -9,7 +9,7 @@ const ethereumNetwork =
|
||||
: process.env.NEXT_PUBLIC_DEFAULT_NETWORK
|
||||
|
||||
export default function useSemaphore(): SemaphoreContextType {
|
||||
const [_users, setUsers] = useState<any[]>([])
|
||||
const [_users, setUsers] = useState<string[]>([])
|
||||
const [_feedback, setFeedback] = useState<string[]>([])
|
||||
|
||||
const refreshUsers = useCallback(async (): Promise<void> => {
|
||||
@@ -19,7 +19,7 @@ export default function useSemaphore(): SemaphoreContextType {
|
||||
|
||||
const members = await semaphore.getGroupMembers(process.env.NEXT_PUBLIC_GROUP_ID as string)
|
||||
|
||||
setUsers(members.map((member) => member.toString()))
|
||||
setUsers(members)
|
||||
}, [])
|
||||
|
||||
const addUser = useCallback(
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
DEFAULT_NETWORK=localhost
|
||||
DEFAULT_NETWORK=hardhat
|
||||
ETHEREUM_PRIVATE_KEY=ac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80
|
||||
REPORT_GAS=false
|
||||
COINMARKETCAP_API_KEY=
|
||||
|
||||
@@ -8,11 +8,10 @@ contract Feedback {
|
||||
|
||||
uint256 public groupId;
|
||||
|
||||
constructor(address semaphoreAddress, uint256 _groupId) {
|
||||
constructor(address semaphoreAddress) {
|
||||
semaphore = ISemaphore(semaphoreAddress);
|
||||
groupId = _groupId;
|
||||
|
||||
semaphore.createGroup(groupId, address(this));
|
||||
groupId = semaphore.createGroup();
|
||||
}
|
||||
|
||||
function joinGroup(uint256 identityCommitment) external {
|
||||
|
||||
@@ -10,7 +10,7 @@ dotenvConfig({ path: resolve(__dirname, "../../.env") })
|
||||
|
||||
const config: HardhatUserConfig = {
|
||||
solidity: "0.8.23",
|
||||
defaultNetwork: process.env.DEFAULT_NETWORK || "localhost",
|
||||
defaultNetwork: process.env.DEFAULT_NETWORK || "hardhat",
|
||||
networks: {
|
||||
hardhat: {
|
||||
chainId: 1337
|
||||
|
||||
@@ -2,9 +2,8 @@ import { task, types } from "hardhat/config"
|
||||
|
||||
task("deploy", "Deploy a Feedback contract")
|
||||
.addOptionalParam("semaphore", "Semaphore contract address", undefined, types.string)
|
||||
.addOptionalParam("group", "Group id", "42", types.string)
|
||||
.addOptionalParam("logs", "Print the logs", true, types.boolean)
|
||||
.setAction(async ({ logs, semaphore: semaphoreAddress, group: groupId }, { ethers, run }) => {
|
||||
.setAction(async ({ logs, semaphore: semaphoreAddress }, { ethers, run }) => {
|
||||
if (!semaphoreAddress) {
|
||||
const { semaphore } = await run("deploy:semaphore", {
|
||||
logs
|
||||
@@ -13,13 +12,9 @@ task("deploy", "Deploy a Feedback contract")
|
||||
semaphoreAddress = await semaphore.getAddress()
|
||||
}
|
||||
|
||||
if (!groupId) {
|
||||
groupId = process.env.GROUP_ID
|
||||
}
|
||||
|
||||
const FeedbackFactory = await ethers.getContractFactory("Feedback")
|
||||
|
||||
const feedbackContract = await FeedbackFactory.deploy(semaphoreAddress, groupId)
|
||||
const feedbackContract = await FeedbackFactory.deploy(semaphoreAddress)
|
||||
|
||||
if (logs) {
|
||||
console.info(`Feedback contract has been deployed to: ${await feedbackContract.getAddress()}`)
|
||||
|
||||
@@ -9,8 +9,6 @@ import { Feedback, ISemaphore } from "../typechain-types"
|
||||
|
||||
describe("Feedback", () => {
|
||||
async function deployFeedbackFixture() {
|
||||
const groupId = "42"
|
||||
|
||||
const { semaphore } = await run("deploy:semaphore", {
|
||||
logs: false
|
||||
})
|
||||
@@ -19,10 +17,11 @@ describe("Feedback", () => {
|
||||
|
||||
const feedbackContract: Feedback = await run("deploy", {
|
||||
logs: false,
|
||||
group: groupId,
|
||||
semaphore: await semaphoreContract.getAddress()
|
||||
})
|
||||
|
||||
const groupId = await feedbackContract.groupId()
|
||||
|
||||
return { semaphoreContract, feedbackContract, groupId }
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
NEXT_PUBLIC_DEFAULT_NETWORK=localhost
|
||||
NEXT_PUBLIC_FEEDBACK_CONTRACT_ADDRESS=0xCf7Ed3AccA5a467e9e704C703E8D87F634fB0Fc9
|
||||
NEXT_PUBLIC_SEMAPHORE_CONTRACT_ADDRESS=0x9fE46736679d2D9a65F0992F2272dE9f3c7fa6e0
|
||||
NEXT_PUBLIC_GROUP_ID=42
|
||||
NEXT_PUBLIC_GROUP_ID=0
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
"dependencies": {
|
||||
"@semaphore-protocol/core": "4.0.0-beta.4",
|
||||
"@semaphore-protocol/data": "4.0.0-beta.4",
|
||||
"@semaphore-protocol/utils": "4.0.0-beta.4",
|
||||
"ethers": "^6.11.1",
|
||||
"next": "14.1.0",
|
||||
"next-pwa": "^5.6.0",
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
"use client"
|
||||
|
||||
import Stepper from "@/components/Stepper"
|
||||
import LogsContext from "@/context/LogsContext"
|
||||
import SemaphoreContext from "@/context/SemaphoreContext"
|
||||
import { Identity } from "@semaphore-protocol/core"
|
||||
import { useRouter } from "next/navigation"
|
||||
import { useCallback, useContext, useEffect, useState } from "react"
|
||||
import Feedback from "../../../contract-artifacts/Feedback.json"
|
||||
import Stepper from "@/components/Stepper"
|
||||
import LogsContext from "@/context/LogsContext"
|
||||
import SemaphoreContext from "@/context/SemaphoreContext"
|
||||
|
||||
export default function GroupsPage() {
|
||||
const router = useRouter()
|
||||
@@ -74,7 +74,7 @@ export default function GroupsPage() {
|
||||
setLoading(false)
|
||||
}, [_identity])
|
||||
|
||||
const userHasJoined = useCallback((identity: Identity) => _users.includes(identity.commitment), [_users])
|
||||
const userHasJoined = useCallback((identity: Identity) => _users.includes(identity.commitment.toString()), [_users])
|
||||
|
||||
return (
|
||||
<>
|
||||
|
||||
@@ -52,7 +52,7 @@ export default function PageContainer({
|
||||
<div>{shortenString(process.env.NEXT_PUBLIC_FEEDBACK_CONTRACT_ADDRESS as string, [6, 4])}</div>
|
||||
</a>
|
||||
<a
|
||||
href="https://github.com/semaphore-protocol/boilerplate"
|
||||
href="https://github.com/semaphore-protocol/semaphore"
|
||||
target="_blank"
|
||||
rel="noreferrer noopener nofollow"
|
||||
>
|
||||
|
||||
@@ -1 +1 @@
|
||||
1247bf70e3976f03369bfa231c9c09573776282c
|
||||
40c5116424f96a0551e5a2c7a9e38f4ed2092871
|
||||
Reference in New Issue
Block a user