From cd90e82990164d3fd419bad53427aeca5a1cb371 Mon Sep 17 00:00:00 2001 From: Jimmy Chu <898091+jimmychu0807@users.noreply.github.com> Date: Tue, 26 Aug 2025 13:01:25 +0800 Subject: [PATCH 1/2] updated --- .env.example | 5 +- .gitmodules | 3 - README.md | 4 + packages/contracts/.gitignore | 3 + packages/contracts/lib/listenEvents.ts | 23 +++ packages/contracts/package.json | 16 +- packages/contracts/script/Counter.s.sol | 19 -- .../contracts/script/SelfVerification.s.sol | 29 +++ packages/contracts/src/Counter.sol | 14 -- packages/contracts/src/SelfVerification.sol | 30 ++- packages/contracts/test/Counter.t.sol | 24 --- .../contracts/test/SelfVerification.t.sol | 4 +- packages/web/package.json | 7 +- packages/web/src/app/page.tsx | 11 +- pnpm-lock.yaml | 176 +++++++++++++++++- pnpm-workspace.yaml | 7 +- 16 files changed, 277 insertions(+), 98 deletions(-) delete mode 100644 .gitmodules create mode 100644 packages/contracts/lib/listenEvents.ts delete mode 100644 packages/contracts/script/Counter.s.sol create mode 100644 packages/contracts/script/SelfVerification.s.sol delete mode 100644 packages/contracts/src/Counter.sol delete mode 100644 packages/contracts/test/Counter.t.sol diff --git a/.env.example b/.env.example index d32c744..195c3dd 100644 --- a/.env.example +++ b/.env.example @@ -1,7 +1,8 @@ +DEPLOYER_SK= ID_HUB_ADDR= SELF_SCOPE= SELF_CONFIG_ID= NEXT_PUBLIC_SELF_APP_NAME= -NEXT_PUBLIC_SELF_SCOPE= -NEXT_PUBLIC_SELF_ENDPOINT= +NEXT_PUBLIC_VERIFICATION_DEPLOYED_ADDR= +NEXT_PUBLIC_SELF_SCOPE_ID= diff --git a/.gitmodules b/.gitmodules deleted file mode 100644 index acd01fd..0000000 --- a/.gitmodules +++ /dev/null @@ -1,3 +0,0 @@ -[submodule "packages/contracts/lib/forge-std"] - path = packages/contracts/lib/forge-std - url = https://github.com/foundry-rs/forge-std diff --git a/README.md b/README.md index caa880a..fb7bf1d 100644 --- a/README.md +++ b/README.md @@ -8,3 +8,7 @@ DHK dao snapshot-self plugin prototype - Snapshot: https://docs.snapshot.box/developer-guides/validation-strategy - [DHK dao snapshot page](https://snapshot.box/#/s:dhkdao.eth) + +- Get Celo Alfajores Testnet token at: [learnweb3](https://learnweb3.io/) +- Get LINK testnet token: https://faucets.chain.link/celo-alfajores-testnet +- Swap for Celo native tokens: https://app.mento.org/ diff --git a/packages/contracts/.gitignore b/packages/contracts/.gitignore index 85198aa..39a66cc 100644 --- a/packages/contracts/.gitignore +++ b/packages/contracts/.gitignore @@ -5,6 +5,9 @@ out/ # Ignores development broadcast logs !/broadcast /broadcast/*/31337/ + +# Celo Alfajores Testnet +/broadcast/*/44787/ /broadcast/**/dry-run/ # Docs diff --git a/packages/contracts/lib/listenEvents.ts b/packages/contracts/lib/listenEvents.ts new file mode 100644 index 0000000..09b3230 --- /dev/null +++ b/packages/contracts/lib/listenEvents.ts @@ -0,0 +1,23 @@ +import * as fs from 'fs'; +import * as path from 'path'; +import "dotenv/config"; + +import { createPublicClient, webSocket, parseAbi } from 'viem'; + +const RPC_URL = "http://localhost:8545"; +const contractAddress = process.env.NEXT_PUBLIC_VERIFICATION_DEPLOYED_ADDR || ''; + +const publicClient = createPublicClient({ + transport: webSocket(RPC_URL), +}); + +console.log(`Listening to on-chain events\nrpc-url: ${RPC_URL}, address: ${contractAddress}`); + +// Event types listen to +const unwatch = publicClient.watchEvent({ + address: contractAddress, + events: parseAbi([ + 'event VerificationCompleted(address indexed sender, string indexed nationality, bytes userData)' + ]), + onLogs: (logs) => console.log(logs) +}); diff --git a/packages/contracts/package.json b/packages/contracts/package.json index 67de369..56c7aad 100644 --- a/packages/contracts/package.json +++ b/packages/contracts/package.json @@ -4,15 +4,25 @@ "description": "", "main": "index.js", "scripts": { - "test": "forge test" + "build": "forge build", + "dev": "pnpm build && conc -n 'node,deploy' -c auto 'pnpm node' 'pnpm deploy:dev'", + "node": "anvil -f https://alfajores-forno.celo-testnet.org/", + "test": "forge test", + "deploy:dev": "wait-on -t 10s tcp:localhost:8545 && forge script script/SelfVerification.s.sol --rpc-url http://localhost:8545 --broadcast", + "listenEvents": "tsx lib/listenEvents.ts" }, "keywords": [], "author": "", "license": "ISC", "packageManager": "pnpm@10.14.0", - "dependencies": { + "devDependencies": { "@selfxyz/contracts": "^1.2.0", + "concurrently": "catalog:", + "dotenv": "catalog:", + "viem": "catalog:", "forge-std": "github:foundry-rs/forge-std#v1.10.0", - "solady": "^0.1.24" + "solady": "^0.1.24", + "tsx": "catalog:", + "wait-on": "catalog:" } } diff --git a/packages/contracts/script/Counter.s.sol b/packages/contracts/script/Counter.s.sol deleted file mode 100644 index cdc1fe9..0000000 --- a/packages/contracts/script/Counter.s.sol +++ /dev/null @@ -1,19 +0,0 @@ -// SPDX-License-Identifier: UNLICENSED -pragma solidity ^0.8.13; - -import {Script, console} from "forge-std/Script.sol"; -import {Counter} from "../src/Counter.sol"; - -contract CounterScript is Script { - Counter public counter; - - function setUp() public {} - - function run() public { - vm.startBroadcast(); - - counter = new Counter(); - - vm.stopBroadcast(); - } -} diff --git a/packages/contracts/script/SelfVerification.s.sol b/packages/contracts/script/SelfVerification.s.sol new file mode 100644 index 0000000..ca5ae1b --- /dev/null +++ b/packages/contracts/script/SelfVerification.s.sol @@ -0,0 +1,29 @@ +// SPDX-License-Identifier: UNLICENSED +pragma solidity ^0.8.13; + +import {Script, console} from "forge-std/Script.sol"; +import {SelfVerification} from "../src/SelfVerification.sol"; + +contract SelfVerificationScript is Script { + SelfVerification public sv; + + function setUp() public {} + + function run() public { + uint256 deployerPrivateKey = vm.envUint("DEPLOYER_SK"); + + // what's needed to deploy SelfVerification + address idHubAddr = vm.envAddress("ID_HUB_ADDR"); + uint256 scope = vm.envUint("SELF_SCOPE"); + bytes32 configId = vm.envBytes32("SELF_CONFIG_ID"); + + + vm.startBroadcast(deployerPrivateKey); + + sv = new SelfVerification(idHubAddr, scope, configId); + + console.log("YourContract deployed at:", address(sv)); + + vm.stopBroadcast(); + } +} diff --git a/packages/contracts/src/Counter.sol b/packages/contracts/src/Counter.sol deleted file mode 100644 index aded799..0000000 --- a/packages/contracts/src/Counter.sol +++ /dev/null @@ -1,14 +0,0 @@ -// SPDX-License-Identifier: UNLICENSED -pragma solidity ^0.8.13; - -contract Counter { - uint256 public number; - - function setNumber(uint256 newNumber) public { - number = newNumber; - } - - function increment() public { - number++; - } -} diff --git a/packages/contracts/src/SelfVerification.sol b/packages/contracts/src/SelfVerification.sol index bb46e76..bba4c0c 100644 --- a/packages/contracts/src/SelfVerification.sol +++ b/packages/contracts/src/SelfVerification.sol @@ -6,16 +6,13 @@ import {ISelfVerificationRoot} from "@selfxyz/contracts/contracts/interfaces/ISe import {Ownable} from "solady/auth/Ownable.sol"; contract SelfVerification is SelfVerificationRoot, Ownable { - // Store verification status for each user - mapping(address => bool) public verifiedHumans; + // Store no, of times a wallet owner has been verified with a valid ID + mapping(address => uint32) public verifiedHumans; bytes32 public verificationConfigId; address public lastUserAddress; // Event to track successful verifications - event VerificationCompleted( - ISelfVerificationRoot.GenericDiscloseOutputV2 output, - bytes userData - ); + event VerificationCompleted(address indexed sender, string indexed nationality, bytes userData); /** * @notice Constructor for the contract @@ -42,10 +39,11 @@ contract SelfVerification is SelfVerificationRoot, Ownable { ISelfVerificationRoot.GenericDiscloseOutputV2 memory output, bytes memory userData ) internal override { - lastUserAddress = address(uint160(output.userIdentifier)); - verifiedHumans[lastUserAddress] = true; + address userId = address(uint160(output.userIdentifier)); + string memory nationality = output.nationality; + verifiedHumans[userId] += 1; - emit VerificationCompleted(output, userData); + emit VerificationCompleted(userId, nationality, userData); // Add your custom logic here: // - Mint NFT to verified user @@ -55,9 +53,9 @@ contract SelfVerification is SelfVerificationRoot, Ownable { } function getConfigId( - bytes32 _destinationChainId, - bytes32 _userIdentifier, - bytes memory _userDefinedData + bytes32 /* _destinationChainId */, + bytes32 /* _userIdentifier */, + bytes memory /* _userDefinedData */ ) public view override returns (bytes32) { return verificationConfigId; } @@ -65,11 +63,11 @@ contract SelfVerification is SelfVerificationRoot, Ownable { /** * @notice Check if an address is a verified human */ - function isVerifiedHuman(address _user) external view returns (bool) { - return verifiedHumans[_user]; + function isVerifiedHuman(address user) external view returns (bool) { + return verifiedHumans[user] > 0; } - function setConfigId(bytes32 _configId) external onlyOwner { - verificationConfigId = _configId; + function setConfigId(bytes32 configId) external onlyOwner { + verificationConfigId = configId; } } diff --git a/packages/contracts/test/Counter.t.sol b/packages/contracts/test/Counter.t.sol deleted file mode 100644 index 54b724f..0000000 --- a/packages/contracts/test/Counter.t.sol +++ /dev/null @@ -1,24 +0,0 @@ -// SPDX-License-Identifier: UNLICENSED -pragma solidity ^0.8.13; - -import {Test, console} from "forge-std/Test.sol"; -import {Counter} from "../src/Counter.sol"; - -contract CounterTest is Test { - Counter public counter; - - function setUp() public { - counter = new Counter(); - counter.setNumber(0); - } - - function test_Increment() public { - counter.increment(); - assertEq(counter.number(), 1); - } - - function testFuzz_SetNumber(uint256 x) public { - counter.setNumber(x); - assertEq(counter.number(), x); - } -} diff --git a/packages/contracts/test/SelfVerification.t.sol b/packages/contracts/test/SelfVerification.t.sol index 32f5768..0a3f549 100644 --- a/packages/contracts/test/SelfVerification.t.sol +++ b/packages/contracts/test/SelfVerification.t.sol @@ -1,7 +1,7 @@ // SPDX-License-Identifier: UNLICENSED pragma solidity ^0.8.28; -import {Test, console} from "forge-std/Test.sol"; +import {Test} from "forge-std/Test.sol"; import {SelfVerification} from "../src/SelfVerification.sol"; contract SelfVerificationTest is Test { @@ -15,7 +15,7 @@ contract SelfVerificationTest is Test { sv = new SelfVerification(idHubAddr, scope, configId); } - function test_ConfigId() public { + function test_ConfigId() view public { bytes32 chainId = bytes32(0); bytes32 userId = bytes32(0); bytes memory data = bytes("0x"); diff --git a/packages/web/package.json b/packages/web/package.json index d6b696d..17f62c0 100644 --- a/packages/web/package.json +++ b/packages/web/package.json @@ -6,7 +6,9 @@ "dev": "next dev", "build": "next build", "start": "next start", - "lint": "next lint" + "lint": "next lint", + "ngrok": "ngrok http --url=burro-concise-regularly.ngrok-free.app 3000", + "tunnel": "concurrently -n 'next,ngrok' -c auto 'pnpm dev' 'pnpm ngrok'" }, "dependencies": { "@selfxyz/common": "^0.0.7", @@ -16,7 +18,7 @@ "next": "14.2.30", "react": "^18", "react-dom": "^18", - "viem": "^2.33.3" + "viem": "catalog:" }, "devDependencies": { "@eslint/eslintrc": "^3", @@ -24,6 +26,7 @@ "@types/node": "^20", "@types/react": "^18", "@types/react-dom": "^18", + "concurrently": "catalog:", "eslint": "^9", "eslint-config-next": "15.4.6", "tailwindcss": "^4", diff --git a/packages/web/src/app/page.tsx b/packages/web/src/app/page.tsx index 800d631..d4c0562 100644 --- a/packages/web/src/app/page.tsx +++ b/packages/web/src/app/page.tsx @@ -37,14 +37,17 @@ function VerificationComponent() { useEffect(() => { try { const app = new SelfAppBuilder({ + // Contract integration settings + endpoint: process.env.NEXT_PUBLIC_VERIFICATION_DEPLOYED_ADDR, + endpointType: "staging_celo", + userIdType: "hex", version: 2, + + // app details appName: process.env.NEXT_PUBLIC_SELF_APP_NAME || "", - scope: process.env.NEXT_PUBLIC_SELF_SCOPE || "", - endpoint: `${process.env.NEXT_PUBLIC_SELF_ENDPOINT}`, + scope: process.env.NEXT_PUBLIC_SELF_SCOPE_ID || "", logoBase64: "https://i.postimg.cc/mrmVf9hm/self.png", userId: userId, - endpointType: "staging_https", - userIdType: "hex", userDefinedData: "Bonjour Cannes!", disclosures: { /* 1. what you want to verify from users' identity */ diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 9317ecf..f44da9a 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -4,6 +4,24 @@ settings: autoInstallPeers: true excludeLinksFromLockfile: false +catalogs: + default: + concurrently: + specifier: ^9.2.1 + version: 9.2.1 + dotenv: + specifier: ^17.2.1 + version: 17.2.1 + tsx: + specifier: ^4.20.5 + version: 4.20.5 + viem: + specifier: ^2.33.3 + version: 2.33.3 + wait-on: + specifier: ^8.0.4 + version: 8.0.4 + importers: .: @@ -16,16 +34,31 @@ importers: version: 3.3.0(@types/node@22.7.5)(typescript@5.9.2) packages/contracts: - dependencies: + devDependencies: '@selfxyz/contracts': specifier: ^1.2.0 version: 1.2.0(ethers@6.15.0)(hardhat@2.26.3(typescript@5.9.2)) + concurrently: + specifier: 'catalog:' + version: 9.2.1 + dotenv: + specifier: 'catalog:' + version: 17.2.1 forge-std: specifier: github:foundry-rs/forge-std#v1.10.0 version: https://codeload.github.com/foundry-rs/forge-std/tar.gz/8bbcf6e3f8f62f419e5429a0bd89331c85c37824 solady: specifier: ^0.1.24 version: 0.1.24 + tsx: + specifier: 'catalog:' + version: 4.20.5 + viem: + specifier: 'catalog:' + version: 2.33.3(typescript@5.9.2) + wait-on: + specifier: 'catalog:' + version: 8.0.4 packages/web: dependencies: @@ -37,7 +70,7 @@ importers: version: 1.0.8 '@selfxyz/qrcode': specifier: ^1.0.11 - version: 1.0.11(jiti@2.5.1)(lottie-react@2.4.1(react-dom@18.3.1(react@18.3.1))(react@18.3.1))(postcss@8.5.6)(react-dom@18.3.1(react@18.3.1))(react@18.3.1)(typescript@5.9.2) + version: 1.0.11(jiti@2.5.1)(lottie-react@2.4.1(react-dom@18.3.1(react@18.3.1))(react@18.3.1))(postcss@8.5.6)(react-dom@18.3.1(react@18.3.1))(react@18.3.1)(tsx@4.20.5)(typescript@5.9.2) geist: specifier: ^1.4.2 version: 1.4.2(next@14.2.30(react-dom@18.3.1(react@18.3.1))(react@18.3.1)) @@ -51,7 +84,7 @@ importers: specifier: ^18 version: 18.3.1(react@18.3.1) viem: - specifier: ^2.33.3 + specifier: 'catalog:' version: 2.33.3(typescript@5.9.2) devDependencies: '@eslint/eslintrc': @@ -69,6 +102,9 @@ importers: '@types/react-dom': specifier: ^18 version: 18.3.7(@types/react@18.3.23) + concurrently: + specifier: 'catalog:' + version: 9.2.1 eslint: specifier: ^9 version: 9.33.0(jiti@2.5.1) @@ -443,6 +479,12 @@ packages: resolution: {integrity: sha512-vBZP4NlzfOlerQTnba4aqZoMhE/a9HY7HRqoOPaETQcSQuWEIyZMHGfVu6w9wGtGK5fED5qRs2DteVCjOH60sA==} engines: {node: '>=14'} + '@hapi/hoek@9.3.0': + resolution: {integrity: sha512-/c6rf4UJlmHlC9b5BaNvzAcFv7HZ2QHaV0D4/HNlBdvFnvQq8RI4kYdhyPCl7Xj+oWvTWQ8ujhqS53LIgAe6KQ==} + + '@hapi/topo@5.1.0': + resolution: {integrity: sha512-foQZKJig7Ob0BMAYBfcJk8d77QtOe7Wo4ox7ff1lQYoNNAb6jwcY1ncdoy2e9wQZzvNy7ODZCYJkK8kzmcAnAg==} + '@humanfs/core@0.19.1': resolution: {integrity: sha512-5DyQ4+1JEUzejeK1JGICcideyfUbGixgS9jNgex5nqkW+cY7WZhxBigmieN5Qnw9ZosSNVC9KQKyb+GUaGyKUA==} engines: {node: '>=18.18.0'} @@ -895,6 +937,15 @@ packages: resolution: {integrity: sha512-zaYmoH0NWWtvnJjC9/CBseXMtKHm/tm40sz3YfJRxeQjyzRqNQPgivpd9R/oDJCYj999mzdW382p/qi2ypjLww==} engines: {node: '>=6'} + '@sideway/address@4.1.5': + resolution: {integrity: sha512-IqO/DUQHUkPeixNQ8n0JA6102hT9CmaljNTPmQ1u8MEhBo/R4Q8eKLN/vGZxuebwOroDB4cbpjheD4+/sKFK4Q==} + + '@sideway/formula@3.0.1': + resolution: {integrity: sha512-/poHZJJVjx3L+zVD6g9KgHfYnb443oi7wLu/XKojDviHy6HOEOA6z1Trk5aR1dGcmPenJEgb2sK2I80LeS3MIg==} + + '@sideway/pinpoint@2.0.0': + resolution: {integrity: sha512-RNiOoTPkptFtSVzQevY/yWtZwf/RxyVnPy/OcA9HBM3MlGDnBEYL5B41H0MTn0Uec8Hi+2qUtTfG2WWZBmMejQ==} + '@sinclair/typebox@0.27.8': resolution: {integrity: sha512-+Fj43pSMwJs4KRrH/938Uf+uAELIgVBmQzg/q1YG10djyfA3TnrU8N8XzqCh/okZdszqBQTZf96idMfE5lnwTA==} @@ -1596,6 +1647,10 @@ packages: cliui@7.0.4: resolution: {integrity: sha512-OcRE68cOsVMXp1Yvonl/fzkQOyjLSu/8bhPDfQt0e0/Eb283TKP20Fs2MqoPsr9SwA595rRCA+QMzYc9nBP+JQ==} + cliui@8.0.1: + resolution: {integrity: sha512-BSeNnyus75C4//NQ9gQt1/csTXyo/8Sb+afLAkzAptFuMsod9HFokGNudZpi/oQV73hnVK+sR+5PVRMd+Dr7YQ==} + engines: {node: '>=12'} + clone@1.0.4: resolution: {integrity: sha512-JQHZ2QMW6l3aH/j6xCqQThY/9OH4D/9ls34cgkUBiEeocRTU04tHfKPBsUK1PqZCUQM7GiA0IIXJSuXHI64Kbg==} engines: {node: '>=0.8'} @@ -1636,6 +1691,11 @@ packages: concat-map@0.0.1: resolution: {integrity: sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==} + concurrently@9.2.1: + resolution: {integrity: sha512-fsfrO0MxV64Znoy8/l1vVIjjHa29SZyyqPgQBwhiDcaW8wJc2W3XWVOGx4M3oJBnv/zdUZIIp1gDeS98GzP8Ng==} + engines: {node: '>=18'} + hasBin: true + confbox@0.1.8: resolution: {integrity: sha512-RMtmw0iFkeR4YV+fUOSucriAQNb9g8zFR52MWCtl+cCZOFRNL6zeB395vPzFhEjjn4fMxXudmELnl/KF/WrK6w==} @@ -1789,6 +1849,10 @@ packages: resolution: {integrity: sha512-uBq4egWHTcTt33a72vpSG0z3HnPuIl6NqYcTrKEg2azoEyl2hpW0zqlxysq2pK9HlDIHyHyakeYaYnSAwd8bow==} engines: {node: '>=12'} + dotenv@17.2.1: + resolution: {integrity: sha512-kQhDYKZecqnM0fCnzI5eIv5L4cAe/iRI+HqMbO/hbRdTAeXDG+M9FjipUxNfbARuEg4iHIbhnhs78BCHNbSxEQ==} + engines: {node: '>=12'} + dunder-proto@1.0.1: resolution: {integrity: sha512-KIN/nDJBQRcXw0MLVhZE9iQHmG68qAVIBg9CqmUYjmQIhgij9U5MFvrqkUL5FbtyyzZuOeOt0zdeRe4UY7ct+A==} engines: {node: '>= 0.4'} @@ -2600,6 +2664,9 @@ packages: resolution: {integrity: sha512-twQoecYPiVA5K/h6SxtORw/Bs3ar+mLUtoPSc7iMXzQzK8d7eJ/R09wmTwAjiamETn1cXYPGfNnu7DMoHgu12w==} hasBin: true + joi@17.13.3: + resolution: {integrity: sha512-otDA4ldcIx+ZXsKHWmp0YizCweVRZG96J10b0FevjfuncLO1oX59THoAmHkNubYJ+9gWsYsp5k8v4ib6oDv1fA==} + joycon@3.1.1: resolution: {integrity: sha512-34wB/Y7MW7bzjKRjUKTa46I2Z7eV62Rkhva+KkopW7Qvv/OSWBqvkSY7vusOPrNuZcUG3tApvdVgNB8POj3SPw==} engines: {node: '>=10'} @@ -3391,6 +3458,10 @@ packages: resolution: {integrity: sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==} engines: {node: '>=8'} + shell-quote@1.8.3: + resolution: {integrity: sha512-ObmnIF4hXNg1BqhnHmgbDETF8dLPCggZWBjkQfhZpbszZnYur5DUljTcCHii5LC3J5E0yeO/1LIMyH+UvHQgyw==} + engines: {node: '>= 0.4'} + side-channel-list@1.0.0: resolution: {integrity: sha512-FCLHtRD/gnpCiCHEiJLOwdmFP+wzCmDEkc9y7NsYxeF4u7Btsn1ZuwgwJGxImImHicJArLP4R0yX4c2KCrMrTA==} engines: {node: '>= 0.4'} @@ -3685,6 +3756,11 @@ packages: typescript: optional: true + tsx@4.20.5: + resolution: {integrity: sha512-+wKjMNU9w/EaQayHXb7WA7ZaHY6hN8WgfvHNQ3t1PnU91/7O8TcTnIhCDYTZwnt8JsO9IBqZ30Ln1r7pPF52Aw==} + engines: {node: '>=18.0.0'} + hasBin: true + type-check@0.3.2: resolution: {integrity: sha512-ZCmOJdvOWDBYJlzAoFkC+Q0+bUyEOS1ltgp1MGU03fqHG+dbi9tBFU2Rd9QKiDZFAYrhPh2JUf7rZRIuHRKtOg==} engines: {node: '>= 0.8.0'} @@ -3802,6 +3878,11 @@ packages: typescript: optional: true + wait-on@8.0.4: + resolution: {integrity: sha512-8f9LugAGo4PSc0aLbpKVCVtzayd36sSCp4WLpVngkYq6PK87H79zt77/tlCU6eKCLqR46iFvcl0PU5f+DmtkwA==} + engines: {node: '>=12.0.0'} + hasBin: true + wasmbuilder@0.0.16: resolution: {integrity: sha512-Qx3lEFqaVvp1cEYW7Bfi+ebRJrOiwz2Ieu7ZG2l7YyeSJIok/reEQCQCuicj/Y32ITIJuGIM9xZQppGx5LrQdA==} @@ -3937,6 +4018,10 @@ packages: resolution: {integrity: sha512-y11nGElTIV+CT3Zv9t7VKl+Q3hTQoT9a1Qzezhhl6Rp21gJ/IVTW7Z3y9EWXhuUBC2Shnf+DX0antecpAwSP8w==} engines: {node: '>=10'} + yargs-parser@21.1.1: + resolution: {integrity: sha512-tVpsJW7DdjecAiFpbIB1e3qxIQsE6NoPc5/eTdrbbIC4h0LVsWhnoa3g+m2HclBIujHzsxZ4VJVA+GUuc2/LBw==} + engines: {node: '>=12'} + yargs-unparser@2.0.0: resolution: {integrity: sha512-7pRTIA9Qc1caZ0bZ6RYRGbHJthJWuakf+WmHK0rVeLkNrrGhfoabBNdue6kdINI6r4if7ocq9aD/n7xwKOdzOA==} engines: {node: '>=10'} @@ -3945,6 +4030,10 @@ packages: resolution: {integrity: sha512-D1mvvtDG0L5ft/jGWkLpG1+m0eQxOfaBvTNELraWj22wSVUMWxZUvYgJYcKh6jGGIkJFhH4IZPQhR4TKpc8mBw==} engines: {node: '>=10'} + yargs@17.7.2: + resolution: {integrity: sha512-7dSzzRQ++CKnNI/krKnYRV7JKKPUXMEh61soaHKg9mrWEhzFWhFnxPxGl+69cD1Ou63C13NUPCnmIcrvqCuM6w==} + engines: {node: '>=12'} + yocto-queue@0.1.0: resolution: {integrity: sha512-rVksvsnNCdJ/ohGc6xgPwyN8eheCxsiLM8mxuE/t/mOVqJewPuO1miLpTHQiRgTKCLexL4MeAFVagts7HmNZ2Q==} engines: {node: '>=10'} @@ -4422,6 +4511,12 @@ snapshots: '@fastify/busboy@2.1.1': {} + '@hapi/hoek@9.3.0': {} + + '@hapi/topo@5.1.0': + dependencies: + '@hapi/hoek': 9.3.0 + '@humanfs/core@0.19.1': {} '@humanfs/node@0.16.6': @@ -4874,7 +4969,7 @@ snapshots: - debug - utf-8-validate - '@selfxyz/qrcode@1.0.11(jiti@2.5.1)(lottie-react@2.4.1(react-dom@18.3.1(react@18.3.1))(react@18.3.1))(postcss@8.5.6)(react-dom@18.3.1(react@18.3.1))(react@18.3.1)(typescript@5.9.2)': + '@selfxyz/qrcode@1.0.11(jiti@2.5.1)(lottie-react@2.4.1(react-dom@18.3.1(react@18.3.1))(react@18.3.1))(postcss@8.5.6)(react-dom@18.3.1(react@18.3.1))(react@18.3.1)(tsx@4.20.5)(typescript@5.9.2)': dependencies: '@selfxyz/common': 0.0.7 js-sha1: 0.7.0 @@ -4888,7 +4983,7 @@ snapshots: react-dom: 18.3.1(react@18.3.1) react-spinners: 0.14.1(react-dom@18.3.1(react@18.3.1))(react@18.3.1) socket.io-client: 4.8.1 - tsup: 8.5.0(jiti@2.5.1)(postcss@8.5.6)(typescript@5.9.2) + tsup: 8.5.0(jiti@2.5.1)(postcss@8.5.6)(tsx@4.20.5)(typescript@5.9.2) uuid: 10.0.0 transitivePeerDependencies: - '@microsoft/api-extractor' @@ -4952,6 +5047,14 @@ snapshots: '@sentry/types': 5.30.0 tslib: 1.14.1 + '@sideway/address@4.1.5': + dependencies: + '@hapi/hoek': 9.3.0 + + '@sideway/formula@3.0.1': {} + + '@sideway/pinpoint@2.0.0': {} + '@sinclair/typebox@0.27.8': {} '@socket.io/component-emitter@3.1.2': {} @@ -5694,6 +5797,12 @@ snapshots: strip-ansi: 6.0.1 wrap-ansi: 7.0.0 + cliui@8.0.1: + dependencies: + string-width: 4.2.3 + strip-ansi: 6.0.1 + wrap-ansi: 7.0.0 + clone@1.0.4: {} color-convert@1.9.3: @@ -5740,6 +5849,15 @@ snapshots: concat-map@0.0.1: {} + concurrently@9.2.1: + dependencies: + chalk: 4.1.2 + rxjs: 7.8.2 + shell-quote: 1.8.3 + supports-color: 8.1.1 + tree-kill: 1.2.2 + yargs: 17.7.2 + confbox@0.1.8: {} consola@3.4.2: {} @@ -5874,6 +5992,8 @@ snapshots: dotenv@16.6.1: {} + dotenv@17.2.1: {} + dunder-proto@1.0.1: dependencies: call-bind-apply-helpers: 1.0.2 @@ -7035,6 +7155,14 @@ snapshots: jiti@2.5.1: {} + joi@17.13.3: + dependencies: + '@hapi/hoek': 9.3.0 + '@hapi/topo': 5.1.0 + '@sideway/address': 4.1.5 + '@sideway/formula': 3.0.1 + '@sideway/pinpoint': 2.0.0 + joycon@3.1.1: {} js-sha1@0.7.0: {} @@ -7583,12 +7711,13 @@ snapshots: possible-typed-array-names@1.1.0: {} - postcss-load-config@6.0.1(jiti@2.5.1)(postcss@8.5.6): + postcss-load-config@6.0.1(jiti@2.5.1)(postcss@8.5.6)(tsx@4.20.5): dependencies: lilconfig: 3.1.3 optionalDependencies: jiti: 2.5.1 postcss: 8.5.6 + tsx: 4.20.5 postcss@8.4.31: dependencies: @@ -7849,6 +7978,8 @@ snapshots: shebang-regex@3.0.0: {} + shell-quote@1.8.3: {} + side-channel-list@1.0.0: dependencies: es-errors: 1.3.0 @@ -8176,7 +8307,7 @@ snapshots: tsort@0.0.1: {} - tsup@8.5.0(jiti@2.5.1)(postcss@8.5.6)(typescript@5.9.2): + tsup@8.5.0(jiti@2.5.1)(postcss@8.5.6)(tsx@4.20.5)(typescript@5.9.2): dependencies: bundle-require: 5.1.0(esbuild@0.25.9) cac: 6.7.14 @@ -8187,7 +8318,7 @@ snapshots: fix-dts-default-cjs-exports: 1.0.1 joycon: 3.1.1 picocolors: 1.1.1 - postcss-load-config: 6.0.1(jiti@2.5.1)(postcss@8.5.6) + postcss-load-config: 6.0.1(jiti@2.5.1)(postcss@8.5.6)(tsx@4.20.5) resolve-from: 5.0.0 rollup: 4.46.2 source-map: 0.8.0-beta.0 @@ -8204,6 +8335,13 @@ snapshots: - tsx - yaml + tsx@4.20.5: + dependencies: + esbuild: 0.25.9 + get-tsconfig: 4.10.1 + optionalDependencies: + fsevents: 2.3.3 + type-check@0.3.2: dependencies: prelude-ls: 1.1.2 @@ -8346,6 +8484,16 @@ snapshots: - utf-8-validate - zod + wait-on@8.0.4: + dependencies: + axios: 1.11.0 + joi: 17.13.3 + lodash: 4.17.21 + minimist: 1.2.8 + rxjs: 7.8.2 + transitivePeerDependencies: + - debug + wasmbuilder@0.0.16: {} wasmcurves@0.2.2: @@ -8460,6 +8608,8 @@ snapshots: yargs-parser@20.2.9: {} + yargs-parser@21.1.1: {} + yargs-unparser@2.0.0: dependencies: camelcase: 6.3.0 @@ -8477,4 +8627,14 @@ snapshots: y18n: 5.0.8 yargs-parser: 20.2.9 + yargs@17.7.2: + dependencies: + cliui: 8.0.1 + escalade: 3.2.0 + get-caller-file: 2.0.5 + require-directory: 2.1.1 + string-width: 4.2.3 + y18n: 5.0.8 + yargs-parser: 21.1.1 + yocto-queue@0.1.0: {} diff --git a/pnpm-workspace.yaml b/pnpm-workspace.yaml index 170f713..883b181 100644 --- a/pnpm-workspace.yaml +++ b/pnpm-workspace.yaml @@ -1,6 +1,11 @@ packages: - packages/* - +catalog: + concurrently: "^9.2.1" + dotenv: "^17.2.1" + tsx: "^4.20.5" + wait-on: ^8.0.4 + viem: ^2.33.3 onlyBuiltDependencies: - '@tailwindcss/oxide' - sharp From e5295d9e487160f33efeed70bf289cd1fa15c0f2 Mon Sep 17 00:00:00 2001 From: Jimmy Chu <898091+jimmychu0807@users.noreply.github.com> Date: Tue, 26 Aug 2025 14:16:58 +0800 Subject: [PATCH 2/2] updated --- .env.example | 2 +- README.md | 6 ++++++ packages/contracts/package.json | 2 +- ...elfVerification.s.sol => DeploySelfVerification.s.sol} | 0 packages/contracts/src/SelfVerification.sol | 8 ++++++++ packages/web/src/app/page.tsx | 4 ++-- 6 files changed, 18 insertions(+), 4 deletions(-) rename packages/contracts/script/{SelfVerification.s.sol => DeploySelfVerification.s.sol} (100%) diff --git a/.env.example b/.env.example index 195c3dd..4fad3ca 100644 --- a/.env.example +++ b/.env.example @@ -5,4 +5,4 @@ SELF_CONFIG_ID= NEXT_PUBLIC_SELF_APP_NAME= NEXT_PUBLIC_VERIFICATION_DEPLOYED_ADDR= -NEXT_PUBLIC_SELF_SCOPE_ID= +NEXT_PUBLIC_SELF_SCOPE_SEED= diff --git a/README.md b/README.md index fb7bf1d..fa6f2f2 100644 --- a/README.md +++ b/README.md @@ -12,3 +12,9 @@ DHK dao snapshot-self plugin prototype - Get Celo Alfajores Testnet token at: [learnweb3](https://learnweb3.io/) - Get LINK testnet token: https://faucets.chain.link/celo-alfajores-testnet - Swap for Celo native tokens: https://app.mento.org/ + +## Deployment + +- SelfVerification: + + Celo Alfajores Testnet: [`0xED3C8a827cE54C4D74A6476d93A9352D91d4e88E`](https://celo-alfajores.blockscout.com/address/0xED3C8a827cE54C4D74A6476d93A9352D91d4e88E) diff --git a/packages/contracts/package.json b/packages/contracts/package.json index 56c7aad..7a2df7d 100644 --- a/packages/contracts/package.json +++ b/packages/contracts/package.json @@ -8,7 +8,7 @@ "dev": "pnpm build && conc -n 'node,deploy' -c auto 'pnpm node' 'pnpm deploy:dev'", "node": "anvil -f https://alfajores-forno.celo-testnet.org/", "test": "forge test", - "deploy:dev": "wait-on -t 10s tcp:localhost:8545 && forge script script/SelfVerification.s.sol --rpc-url http://localhost:8545 --broadcast", + "deploy:dev": "wait-on -t 10s tcp:localhost:8545 && forge script script/DeploySelfVerification.s.sol --rpc-url http://localhost:8545 --broadcast", "listenEvents": "tsx lib/listenEvents.ts" }, "keywords": [], diff --git a/packages/contracts/script/SelfVerification.s.sol b/packages/contracts/script/DeploySelfVerification.s.sol similarity index 100% rename from packages/contracts/script/SelfVerification.s.sol rename to packages/contracts/script/DeploySelfVerification.s.sol diff --git a/packages/contracts/src/SelfVerification.sol b/packages/contracts/src/SelfVerification.sol index bba4c0c..d97e4c7 100644 --- a/packages/contracts/src/SelfVerification.sol +++ b/packages/contracts/src/SelfVerification.sol @@ -70,4 +70,12 @@ contract SelfVerification is SelfVerificationRoot, Ownable { function setConfigId(bytes32 configId) external onlyOwner { verificationConfigId = configId; } + + /** + * @notice Expose the internal _setScope function for testing + * @param newScope The new scope value to set + */ + function setScope(uint256 newScope) external onlyOwner { + _setScope(newScope); + } } diff --git a/packages/web/src/app/page.tsx b/packages/web/src/app/page.tsx index d4c0562..c3af3d3 100644 --- a/packages/web/src/app/page.tsx +++ b/packages/web/src/app/page.tsx @@ -45,10 +45,10 @@ function VerificationComponent() { // app details appName: process.env.NEXT_PUBLIC_SELF_APP_NAME || "", - scope: process.env.NEXT_PUBLIC_SELF_SCOPE_ID || "", + scope: process.env.NEXT_PUBLIC_SELF_SCOPE_SEED || "", logoBase64: "https://i.postimg.cc/mrmVf9hm/self.png", userId: userId, - userDefinedData: "Bonjour Cannes!", + userDefinedData: "DHK dao self-prototype", disclosures: { /* 1. what you want to verify from users' identity */ minimumAge: 18,