feat: add group verification and message posting through smart contract (#80)

Co-authored-by: Philippe Schommers <philippe@schommers.be>
This commit is contained in:
Vojtech Simetka 2023-01-24 07:51:42 +01:00 committed by GitHub
parent 6159f5fef2
commit 657b850a4e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
71 changed files with 48418 additions and 1883 deletions

View File

@ -19,11 +19,20 @@ jobs:
- name: Use Node.js 18
uses: actions/setup-node@v3
with:
cache: npm
node-version: 18
- name: Install npm deps
run: npm ci
# Hardhat is missing some dependencies on linux due to https://github.com/npm/cli/issues/4828
run: rm -rf package-lock.json && npm install
- name: Install browser runners
run: npx playwright install
- name: Download snark-artifacts
run: npm run download:snark-artifacts --workspaces --if-present
- name: Test
run: npm run test --workspaces --if-present
- name: Check the build
run: npm run check --workspaces --if-present

7
.gitignore vendored
View File

@ -1 +1,6 @@
node_modules/
build/
dist/
node_modules/
cache/
coverage/
coverage.json

18571
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -6,5 +6,8 @@
],
"devDependencies": {
"lerna": "^6.3.0"
},
"dependencies": {
"dotenv": "^16.0.3"
}
}

View File

@ -0,0 +1,3 @@
{
"extends": "solhint:default"
}

View File

@ -0,0 +1,53 @@
//SPDX-License-Identifier: MIT
pragma solidity ^0.8.4;
import "@semaphore-protocol/contracts/interfaces/ISemaphore.sol";
contract GlobalAnonymousFeed {
error IdentityAlreadyExists();
event NewMessage(string message);
event NewIdentity(uint256 identityCommitment);
ISemaphore public semaphore;
uint256 public groupId;
mapping(uint256 => bool) public registeredIdentities;
constructor(address semaphoreAddress, uint256 _groupId) {
semaphore = ISemaphore(semaphoreAddress);
groupId = _groupId;
semaphore.createGroup(groupId, 20, address(this));
}
function joinGroup(uint256 identityCommitment) external {
if (registeredIdentities[identityCommitment] == true) {
revert IdentityAlreadyExists();
}
semaphore.addMember(groupId, identityCommitment);
registeredIdentities[identityCommitment] = true;
emit NewIdentity(identityCommitment);
}
function sendMessage(
string calldata message,
uint256 merkleTreeRoot,
uint256 nullifierHash,
uint256 externalNullifier,
uint256[8] calldata proof
) external {
semaphore.verifyProof(
groupId,
merkleTreeRoot,
uint256(keccak256(abi.encodePacked(message))),
nullifierHash,
externalNullifier,
proof
);
emit NewMessage(message);
}
}

View File

@ -0,0 +1,62 @@
import "@nomiclabs/hardhat-ethers"
import "@nomicfoundation/hardhat-chai-matchers"
import "@semaphore-protocol/hardhat"
import "@typechain/hardhat"
import { config as dotenvConfig } from "dotenv"
import "hardhat-gas-reporter"
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") })
function getNetworks(): NetworksUserConfig {
if (process.env.ETHEREUM_URL && process.env.ETHEREUM_PRIVATE_KEY) {
const accounts = [`0x${process.env.ETHEREUM_PRIVATE_KEY}`]
return {
goerli: {
url: process.env.ETHEREUM_URL,
chainId: 5,
accounts
},
sepolia: {
url: process.env.ETHEREUM_URL,
chainId: 11155111,
accounts
}
}
}
return {}
}
const hardhatConfig: HardhatUserConfig = {
solidity: config.solidity,
paths: {
sources: config.paths.contracts,
tests: config.paths.tests,
cache: config.paths.cache,
artifacts: config.paths.build.contracts
},
networks: {
hardhat: {
chainId: 1337
},
...getNetworks()
},
gasReporter: {
currency: "USD",
enabled: process.env.REPORT_GAS === "true",
coinmarketcap: process.env.COINMARKETCAP_API_KEY
},
typechain: {
outDir: config.paths.build.typechain,
target: "ethers-v5"
}
}
export default hardhatConfig

24493
packages/contracts/package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,60 @@
{
"name": "contracts",
"version": "1.0.0",
"private": true,
"main": "index.js",
"scripts": {
"start": "npm run compile && npm run deploy -- --network localhost",
"start:blockchain": "hardhat node",
"compile": "hardhat compile",
"download:snark-artifacts": "hardhat run scripts/download-snark-artifacts.ts",
"deploy": "npm run compile && hardhat deploy",
"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.2.2",
"@semaphore-protocol/group": "3.0.0-beta.7",
"@semaphore-protocol/hardhat": "3.0.0-beta.7",
"@semaphore-protocol/identity": "3.0.0-beta.7",
"@semaphore-protocol/proof": "3.0.0-beta.7",
"@typechain/ethers-v5": "^10.2.0",
"@typechain/hardhat": "^6.1.5",
"@types/chai": "^4.3.4",
"@types/download": "^8.0.2",
"@types/mocha": "^10.0.1",
"chai": "^4.3.7",
"circomlibjs": "0.1.7",
"download": "^8.0.0",
"ethers": "^5.7.2",
"hardhat": "^2.12.6",
"hardhat-gas-reporter": "^1.0.9",
"mocha": "^10.2.0",
"solhint": "^3.3.8",
"solidity-coverage": "^0.8.2",
"ts-node": "^10.9.1",
"typechain": "^8.1.1"
},
"dependencies": {
"@semaphore-protocol/contracts": "3.0.0-beta.7"
},
"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"
}
}
}
}

View File

@ -0,0 +1,24 @@
import download from "download"
import fs from "fs"
import { config } from "../package.json"
async function main() {
const snarkArtifactsPath = config.paths.build["snark-artifacts"]
const url = `http://www.trusted-setup-pse.org/semaphore/${20}`
if (!fs.existsSync(snarkArtifactsPath)) {
fs.mkdirSync(snarkArtifactsPath, { recursive: true })
}
if (!fs.existsSync(`${snarkArtifactsPath}/semaphore.zkey`)) {
await download(`${url}/semaphore.wasm`, snarkArtifactsPath)
await download(`${url}/semaphore.zkey`, snarkArtifactsPath)
}
}
main()
.then(() => process.exit(0))
.catch((error) => {
console.error(error)
process.exit(1)
})

View File

@ -0,0 +1,27 @@
import { task, types } from "hardhat/config"
task("deploy", "Deploy a GlobalAnonymousFeed contract")
.addOptionalParam("semaphore", "Semaphore contract address", undefined, types.string)
.addOptionalParam("group", "Group id", 42, types.int)
.addOptionalParam("logs", "Print the logs", true, types.boolean)
.setAction(async ({ logs, semaphore: semaphoreAddress, group: groupId }, { ethers, run }) => {
if (!semaphoreAddress) {
const { semaphore } = await run("deploy:semaphore", {
logs
})
semaphoreAddress = semaphore.address
}
const globalAnonymousFeedFactory = await ethers.getContractFactory("GlobalAnonymousFeed")
const globalAnonymousFeedContract = await globalAnonymousFeedFactory.deploy(semaphoreAddress, groupId)
await globalAnonymousFeedContract.deployed()
if (logs) {
console.info(`GlobalAnonymousFeedContract contract has been deployed to: ${globalAnonymousFeedContract.address}`)
}
return globalAnonymousFeedContract
})

View File

@ -0,0 +1,96 @@
import { Group } from "@semaphore-protocol/group"
import { Identity } from "@semaphore-protocol/identity"
import { generateProof, packToSolidityProof } from "@semaphore-protocol/proof"
import { expect } from "chai"
import { solidityKeccak256 } from "ethers/lib/utils"
import { run, ethers } from "hardhat"
import { GlobalAnonymousFeed } from "../build/typechain"
import { config } from "../package.json"
import type { Signer } from "ethers/lib/ethers"
describe("Global Anonymous Feed Contract", () => {
let postContract: GlobalAnonymousFeed
let identities: Identity[] = []
const groupId = 42
const group = new Group(groupId)
const identitySeed = 'identity'
let accounts: Signer[]
before(async () => {
postContract = await run("deploy", { logs: false, group: groupId })
accounts = await ethers.getSigners()
for (let i = 0; i < 2; i++) {
identities.push(new Identity(await accounts[i].signMessage(identitySeed)))
}
identities.forEach(i => group.addMember(i.getCommitment()))
})
describe("joinGroup", () => {
it("Should allow users to join the group", async () => {
for (let i = 0; i < group.members.length; i += 1) {
const transaction = postContract.joinGroup(group.members[i])
await expect(transaction)
.to.emit(postContract, "NewIdentity")
.withArgs(group.members[i])
}
})
it("Should not allow users to join the group with the same identity", async () => {
const transaction = postContract.joinGroup(group.members[0])
await expect(transaction).to.be.revertedWithCustomError(postContract, "IdentityAlreadyExists")
})
})
describe("sendMessage", () => {
const wasmFilePath = `${config.paths.build["snark-artifacts"]}/semaphore.wasm`
const zkeyFilePath = `${config.paths.build["snark-artifacts"]}/semaphore.zkey`
it("Should allow users to send message anonymously", async () => {
const feedback = "Hello World"
const feedbackHash = solidityKeccak256(["string"], [feedback])
const nullifier = 69
const fullProof = await generateProof(identities[1], group, nullifier, feedbackHash, {
wasmFilePath,
zkeyFilePath
})
const solidityProof = packToSolidityProof(fullProof.proof)
const transaction = postContract.sendMessage(
feedback,
fullProof.publicSignals.merkleTreeRoot,
fullProof.publicSignals.nullifierHash,
nullifier, //fullProof.publicSignals.externalNullifier,
solidityProof
)
await expect(transaction).to.emit(postContract, "NewMessage").withArgs(feedback)
})
it("Should allow users to send message anonymously", async () => {
const feedback = "Hello World"
const feedbackHash = solidityKeccak256(["string"], [feedback])
const externalNullifier = 80
const fullProof = await generateProof(identities[1], group, externalNullifier, feedbackHash, {
wasmFilePath,
zkeyFilePath
})
const solidityProof = packToSolidityProof(fullProof.proof)
const transaction = postContract.sendMessage(
feedback,
fullProof.publicSignals.merkleTreeRoot,
fullProof.publicSignals.nullifierHash,
externalNullifier, //fullProof.publicSignals.externalNullifier,
solidityProof
)
await expect(transaction).to.emit(postContract, "NewMessage").withArgs(feedback)
})
})
})

View File

@ -0,0 +1,15 @@
{
"compilerOptions": {
"moduleResolution": "Node",
"noImplicitAny": true,
"resolveJsonModule": true,
"target": "ES2018",
"module": "CommonJS",
"strict": true,
"esModuleInterop": true,
"outDir": "dist",
"typeRoots": ["node_modules/@types", "types"]
},
"include": ["scripts/**/*", "tasks/**/*", "test/**/*", "build/typechain/**/*", "types/**/*"],
"files": ["./hardhat.config.ts"]
}

View File

@ -0,0 +1,895 @@
/** Declaration file generated by dts-gen */
declare module "circomlibjs" {
export class evmasm {
constructor(...args: any[])
add(...args: any[]): void
addmod(...args: any[]): void
address(...args: any[]): void
and(...args: any[]): void
balance(...args: any[]): void
blockhash(...args: any[]): void
byte(...args: any[]): void
call(...args: any[]): void
callcode(...args: any[]): void
calldatacopy(...args: any[]): void
calldataload(...args: any[]): void
calldatasize(...args: any[]): void
caller(...args: any[]): void
callvalue(...args: any[]): void
codecopy(...args: any[]): void
codesize(...args: any[]): void
coinbase(...args: any[]): void
create(...args: any[]): void
createTxData(...args: any[]): void
delegatecall(...args: any[]): void
difficulty(...args: any[]): void
div(...args: any[]): void
dup(...args: any[]): void
eq(...args: any[]): void
exp(...args: any[]): void
extcodecopy(...args: any[]): void
extcodesize(...args: any[]): void
gas(...args: any[]): void
gaslimit(...args: any[]): void
gasprice(...args: any[]): void
gt(...args: any[]): void
invalid(...args: any[]): void
iszero(...args: any[]): void
jmp(...args: any[]): void
jmpi(...args: any[]): void
keccak(...args: any[]): void
label(...args: any[]): void
log0(...args: any[]): void
log1(...args: any[]): void
log2(...args: any[]): void
log3(...args: any[]): void
log4(...args: any[]): void
lt(...args: any[]): void
mload(...args: any[]): void
mod(...args: any[]): void
msize(...args: any[]): void
mstore(...args: any[]): void
mstore8(...args: any[]): void
mul(...args: any[]): void
mulmod(...args: any[]): void
not(...args: any[]): void
number(...args: any[]): void
or(...args: any[]): void
origin(...args: any[]): void
pc(...args: any[]): void
pop(...args: any[]): void
push(...args: any[]): void
return(...args: any[]): void
returndatacopy(...args: any[]): void
returndatasize(...args: any[]): void
revert(...args: any[]): void
sdiv(...args: any[]): void
selfdestruct(...args: any[]): void
sgt(...args: any[]): void
sha3(...args: any[]): void
shor(...args: any[]): void
signextend(...args: any[]): void
sload(...args: any[]): void
slt(...args: any[]): void
smod(...args: any[]): void
sstore(...args: any[]): void
staticcall(...args: any[]): void
stop(...args: any[]): void
sub(...args: any[]): void
swap(...args: any[]): void
timestamp(...args: any[]): void
}
export class smt_memdb {
constructor(...args: any[])
get(...args: any[]): void
getRoot(...args: any[]): void
multiDel(...args: any[]): void
multiGet(...args: any[]): void
multiIns(...args: any[]): void
setRoot(...args: any[]): void
}
export function poseidon(inputs: any): any
export function poseidon_slow(inputs: any): any
export namespace babyjub {
const A: any
const Base8: any[]
const D: any
const Generator: any[]
const order: any
const p: any
const subOrder: any
function addPoint(a: any, b: any): any
function inCurve(P: any): any
function inSubgroup(P: any): any
function mulPointEscalar(base: any, e: any): any
function packPoint(P: any): any
function unpackPoint(_buff: any): any
namespace F {
const R: any
const Ri: any
const bitLength: number
const half: any
const m: number
const mask: any
const n32: number
const n64: number
const n8: number
const negone: any
const nqr: any
const nqr_to_t: any
const one: any
const p: any
const s: number
const sqrt_q: any
const sqrt_s: number
const sqrt_t: any
const sqrt_tm1d2: any
const sqrt_z: any
const t: any
const two: any
const type: string
const zero: any
function add(...args: any[]): void
function band(...args: any[]): void
function bnot(...args: any[]): void
function bor(...args: any[]): void
function bxor(...args: any[]): void
function div(...args: any[]): void
function e(...args: any[]): void
function eq(...args: any[]): void
function exp(...args: any[]): void
function fromRng(...args: any[]): void
function fromRprBE(...args: any[]): void
function fromRprBEM(...args: any[]): void
function fromRprLE(...args: any[]): void
function fromRprLEM(...args: any[]): void
function geq(...args: any[]): void
function gt(...args: any[]): void
function idiv(...args: any[]): void
function inv(...args: any[]): void
function isZero(...args: any[]): void
function land(...args: any[]): void
function leq(...args: any[]): void
function lnot(...args: any[]): void
function lor(...args: any[]): void
function lt(...args: any[]): void
function mod(...args: any[]): void
function mul(...args: any[]): void
function mulScalar(...args: any[]): void
function neg(...args: any[]): void
function neq(...args: any[]): void
function normalize(...args: any[]): void
function pow(...args: any[]): void
function random(...args: any[]): void
function shl(...args: any[]): void
function shr(...args: any[]): void
function sqrt(a: any): any
function sqrt_old(...args: any[]): void
function square(...args: any[]): void
function sub(...args: any[]): void
function toRprBE(...args: any[]): void
function toRprBEM(...args: any[]): void
function toRprLE(...args: any[]): void
function toRprLEM(...args: any[]): void
function toString(...args: any[]): void
}
}
export namespace eddsa {
function packSignature(sig: any): any
function pruneBuffer(_buff: any): any
function prv2pub(prv: any): any
function sign(prv: any, msg: any): any
function signMiMC(prv: any, msg: any): any
function signMiMCSponge(prv: any, msg: any): any
function signPoseidon(prv: any, msg: any): any
function unpackSignature(sigBuff: any): any
function verify(msg: any, sig: any, A: any): any
function verifyMiMC(msg: any, sig: any, A: any): any
function verifyMiMCSponge(msg: any, sig: any, A: any): any
function verifyPoseidon(msg: any, sig: any, A: any): any
}
export namespace mimc7 {
function getConstants(seed: any, nRounds: any): any
function getIV(seed: any): any
function hash(_x_in: any, _k: any): any
function multiHash(arr: any, key: any): any
namespace F {
const R: any
const Ri: any
const bitLength: number
const half: any
const m: number
const mask: any
const n32: number
const n64: number
const n8: number
const negone: any
const nqr: any
const nqr_to_t: any
const one: any
const p: any
const s: number
const sqrt_q: any
const sqrt_s: number
const sqrt_t: any
const sqrt_tm1d2: any
const sqrt_z: any
const t: any
const two: any
const type: string
const zero: any
function add(...args: any[]): void
function band(...args: any[]): void
function bnot(...args: any[]): void
function bor(...args: any[]): void
function bxor(...args: any[]): void
function div(...args: any[]): void
function e(...args: any[]): void
function eq(...args: any[]): void
function exp(...args: any[]): void
function fromRng(...args: any[]): void
function fromRprBE(...args: any[]): void
function fromRprBEM(...args: any[]): void
function fromRprLE(...args: any[]): void
function fromRprLEM(...args: any[]): void
function geq(...args: any[]): void
function gt(...args: any[]): void
function idiv(...args: any[]): void
function inv(...args: any[]): void
function isZero(...args: any[]): void
function land(...args: any[]): void
function leq(...args: any[]): void
function lnot(...args: any[]): void
function lor(...args: any[]): void
function lt(...args: any[]): void
function mod(...args: any[]): void
function mul(...args: any[]): void
function mulScalar(...args: any[]): void
function neg(...args: any[]): void
function neq(...args: any[]): void
function normalize(...args: any[]): void
function pow(...args: any[]): void
function random(...args: any[]): void
function shl(...args: any[]): void
function shr(...args: any[]): void
function sqrt(a: any): any
function sqrt_old(...args: any[]): void
function square(...args: any[]): void
function sub(...args: any[]): void
function toRprBE(...args: any[]): void
function toRprBEM(...args: any[]): void
function toRprLE(...args: any[]): void
function toRprLEM(...args: any[]): void
function toString(...args: any[]): void
}
}
export namespace mimc_gencontract {
const abi: {
constant: boolean
inputs: {
name: string
type: string
}[]
name: string
outputs: {
name: string
type: string
}[]
payable: boolean
stateMutability: string
type: string
}[]
function createCode(seed: any, n: any): any
}
export namespace mimcsponge {
function getConstants(seed: any, nRounds: any): any
function getIV(seed: any): any
function hash(_xL_in: any, _xR_in: any, _k: any): any
function multiHash(arr: any, key: any, numOutputs: any): any
}
export namespace mimcsponge_gencontract {
const abi: {
constant: boolean
inputs: {
name: string
type: string
}[]
name: string
outputs: {
name: string
type: string
}[]
payable: boolean
stateMutability: string
type: string
}[]
function createCode(seed: any, n: any): any
}
export namespace pedersenHash {
function getBasePoint(baseHashType: any, pointIdx: any): any
function hash(msg: any, options: any): any
}
export namespace poseidon_gencontract {
function createCode(nInputs: any): any
function generateABI(nInputs: any): any
}
export namespace smt {
class SMT {
constructor(...args: any[])
delete(...args: any[]): void
find(...args: any[]): void
insert(...args: any[]): void
update(...args: any[]): void
}
class SMTMemDB {
constructor(...args: any[])
get(...args: any[]): void
getRoot(...args: any[]): void
multiDel(...args: any[]): void
multiGet(...args: any[]): void
multiIns(...args: any[]): void
setRoot(...args: any[]): void
}
function loadFromFile(fileName: any): void
function newMemEmptyTrie(): any
}
export namespace smt_hashes_mimc {
function hash0(left: any, right: any): any
function hash1(key: any, value: any): any
namespace F {
const R: any
const Ri: any
const bitLength: number
const half: any
const m: number
const mask: any
const n32: number
const n64: number
const n8: number
const negone: any
const nqr: any
const nqr_to_t: any
const one: any
const p: any
const s: number
const sqrt_q: any
const sqrt_s: number
const sqrt_t: any
const sqrt_tm1d2: any
const sqrt_z: any
const t: any
const two: any
const type: string
const zero: any
function add(...args: any[]): void
function band(...args: any[]): void
function bnot(...args: any[]): void
function bor(...args: any[]): void
function bxor(...args: any[]): void
function div(...args: any[]): void
function e(...args: any[]): void
function eq(...args: any[]): void
function exp(...args: any[]): void
function fromRng(...args: any[]): void
function fromRprBE(...args: any[]): void
function fromRprBEM(...args: any[]): void
function fromRprLE(...args: any[]): void
function fromRprLEM(...args: any[]): void
function geq(...args: any[]): void
function gt(...args: any[]): void
function idiv(...args: any[]): void
function inv(...args: any[]): void
function isZero(...args: any[]): void
function land(...args: any[]): void
function leq(...args: any[]): void
function lnot(...args: any[]): void
function lor(...args: any[]): void
function lt(...args: any[]): void
function mod(...args: any[]): void
function mul(...args: any[]): void
function mulScalar(...args: any[]): void
function neg(...args: any[]): void
function neq(...args: any[]): void
function normalize(...args: any[]): void
function pow(...args: any[]): void
function random(...args: any[]): void
function shl(...args: any[]): void
function shr(...args: any[]): void
function sqrt(a: any): any
function sqrt_old(...args: any[]): void
function square(...args: any[]): void
function sub(...args: any[]): void
function toRprBE(...args: any[]): void
function toRprBEM(...args: any[]): void
function toRprLE(...args: any[]): void
function toRprLEM(...args: any[]): void
function toString(...args: any[]): void
}
}
export namespace smt_hashes_poseidon {
function hash0(left: any, right: any): any
function hash1(key: any, value: any): any
namespace F {
const R: any
const Ri: any
const bitLength: number
const half: any
const m: number
const mask: any
const n32: number
const n64: number
const n8: number
const negone: any
const nqr: any
const nqr_to_t: any
const one: any
const p: any
const s: number
const sqrt_q: any
const sqrt_s: number
const sqrt_t: any
const sqrt_tm1d2: any
const sqrt_z: any
const t: any
const two: any
const type: string
const zero: any
function add(...args: any[]): void
function band(...args: any[]): void
function bnot(...args: any[]): void
function bor(...args: any[]): void
function bxor(...args: any[]): void
function div(...args: any[]): void
function e(...args: any[]): void
function eq(...args: any[]): void
function exp(...args: any[]): void
function fromRng(...args: any[]): void
function fromRprBE(...args: any[]): void
function fromRprBEM(...args: any[]): void
function fromRprLE(...args: any[]): void
function fromRprLEM(...args: any[]): void
function geq(...args: any[]): void
function gt(...args: any[]): void
function idiv(...args: any[]): void
function inv(...args: any[]): void
function isZero(...args: any[]): void
function land(...args: any[]): void
function leq(...args: any[]): void
function lnot(...args: any[]): void
function lor(...args: any[]): void
function lt(...args: any[]): void
function mod(...args: any[]): void
function mul(...args: any[]): void
function mulScalar(...args: any[]): void
function neg(...args: any[]): void
function neq(...args: any[]): void
function normalize(...args: any[]): void
function pow(...args: any[]): void
function random(...args: any[]): void
function shl(...args: any[]): void
function shr(...args: any[]): void
function sqrt(a: any): any
function sqrt_old(...args: any[]): void
function square(...args: any[]): void
function sub(...args: any[]): void
function toRprBE(...args: any[]): void
function toRprBEM(...args: any[]): void
function toRprLE(...args: any[]): void
function toRprLEM(...args: any[]): void
function toString(...args: any[]): void
}
}
}

3
packages/ui/.env Normal file
View File

@ -0,0 +1,3 @@
PUBLIC_PROVIDER=https://goerli.infura.io/v3/6d4ffa9d4df447ebb73468f4efcb8e8e
PUBLIC_GROUP_ID=38219357914
PUBLIC_GLOBAL_ANONYMOUS_FEED_ADDRESS=0x7A5fe8899b9e189483Db0545c71D6cad92df93F0

View File

@ -10,16 +10,19 @@
"check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json",
"check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch",
"lint": "prettier --plugin-search-dir . --check . && eslint .",
"format": "prettier --plugin-search-dir . --write . && eslint . --fix"
"format": "prettier --plugin-search-dir . --write . && eslint . --fix",
"waku:start": "docker-compose -f ./tests/docker-compose.yaml up -d",
"waku:stop": "docker kill tests-waku-1"
},
"devDependencies": {
"@esbuild-plugins/node-globals-polyfill": "^0.1.1",
"@esbuild-plugins/node-modules-polyfill": "^0.1.4",
"@fontsource/source-code-pro": "^4.5.12",
"@fontsource/source-sans-pro": "^4.5.11",
"@fontsource/source-serif-pro": "^4.5.9",
"@playwright/test": "1.29.1",
"@semaphore-protocol/identity": "^2.6.1",
"@rollup/plugin-inject": "^5.0.3",
"@semaphore-protocol/group": "3.0.0-beta.6",
"@semaphore-protocol/identity": "3.0.0-beta.6",
"@semaphore-protocol/proof": "3.0.0-beta.6",
"@sveltejs/adapter-static": "^1.0.0",
"@sveltejs/kit": "^1.0.1",
"@typescript-eslint/eslint-plugin": "^5.47.1",
@ -29,6 +32,7 @@
"eslint-config-prettier": "^8.5.0",
"eslint-plugin-svelte3": "^4.0.0",
"ethers": "^5.7.2",
"node-stdlib-browser": "^1.2.0",
"prettier": "^2.8.1",
"prettier-plugin-svelte": "^2.9.0",
"sass": "^1.57.1",

Binary file not shown.

Binary file not shown.

View File

@ -0,0 +1,826 @@
/* Autogenerated file. Do not edit manually. */
/* tslint:disable */
/* eslint-disable */
import type {
BaseContract,
BigNumber,
BigNumberish,
BytesLike,
CallOverrides,
ContractTransaction,
Overrides,
PopulatedTransaction,
Signer,
utils,
} from 'ethers'
import type { FunctionFragment, Result, EventFragment } from '@ethersproject/abi'
import type { Listener, Provider } from '@ethersproject/providers'
import type {
TypedEventFilter,
TypedEvent,
TypedListener,
OnEvent,
PromiseOrValue,
} from '../../common'
export interface SemaphoreInterface extends utils.Interface {
functions: {
'addMember(uint256,uint256)': FunctionFragment
'addMembers(uint256,uint256[])': FunctionFragment
'createGroup(uint256,uint256,address,uint256)': FunctionFragment
'createGroup(uint256,uint256,address)': FunctionFragment
'getMerkleTreeDepth(uint256)': FunctionFragment
'getMerkleTreeRoot(uint256)': FunctionFragment
'getNumberOfMerkleTreeLeaves(uint256)': FunctionFragment
'groups(uint256)': FunctionFragment
'removeMember(uint256,uint256,uint256[],uint8[])': FunctionFragment
'updateGroupAdmin(uint256,address)': FunctionFragment
'updateGroupMerkleTreeDuration(uint256,uint256)': FunctionFragment
'updateMember(uint256,uint256,uint256,uint256[],uint8[])': FunctionFragment
'verifier()': FunctionFragment
'verifyProof(uint256,uint256,uint256,uint256,uint256,uint256[8])': FunctionFragment
}
getFunction(
nameOrSignatureOrTopic:
| 'addMember'
| 'addMembers'
| 'createGroup(uint256,uint256,address,uint256)'
| 'createGroup(uint256,uint256,address)'
| 'getMerkleTreeDepth'
| 'getMerkleTreeRoot'
| 'getNumberOfMerkleTreeLeaves'
| 'groups'
| 'removeMember'
| 'updateGroupAdmin'
| 'updateGroupMerkleTreeDuration'
| 'updateMember'
| 'verifier'
| 'verifyProof',
): FunctionFragment
encodeFunctionData(
functionFragment: 'addMember',
values: [PromiseOrValue<BigNumberish>, PromiseOrValue<BigNumberish>],
): string
encodeFunctionData(
functionFragment: 'addMembers',
values: [PromiseOrValue<BigNumberish>, PromiseOrValue<BigNumberish>[]],
): string
encodeFunctionData(
functionFragment: 'createGroup(uint256,uint256,address,uint256)',
values: [
PromiseOrValue<BigNumberish>,
PromiseOrValue<BigNumberish>,
PromiseOrValue<string>,
PromiseOrValue<BigNumberish>,
],
): string
encodeFunctionData(
functionFragment: 'createGroup(uint256,uint256,address)',
values: [PromiseOrValue<BigNumberish>, PromiseOrValue<BigNumberish>, PromiseOrValue<string>],
): string
encodeFunctionData(
functionFragment: 'getMerkleTreeDepth',
values: [PromiseOrValue<BigNumberish>],
): string
encodeFunctionData(
functionFragment: 'getMerkleTreeRoot',
values: [PromiseOrValue<BigNumberish>],
): string
encodeFunctionData(
functionFragment: 'getNumberOfMerkleTreeLeaves',
values: [PromiseOrValue<BigNumberish>],
): string
encodeFunctionData(functionFragment: 'groups', values: [PromiseOrValue<BigNumberish>]): string
encodeFunctionData(
functionFragment: 'removeMember',
values: [
PromiseOrValue<BigNumberish>,
PromiseOrValue<BigNumberish>,
PromiseOrValue<BigNumberish>[],
PromiseOrValue<BigNumberish>[],
],
): string
encodeFunctionData(
functionFragment: 'updateGroupAdmin',
values: [PromiseOrValue<BigNumberish>, PromiseOrValue<string>],
): string
encodeFunctionData(
functionFragment: 'updateGroupMerkleTreeDuration',
values: [PromiseOrValue<BigNumberish>, PromiseOrValue<BigNumberish>],
): string
encodeFunctionData(
functionFragment: 'updateMember',
values: [
PromiseOrValue<BigNumberish>,
PromiseOrValue<BigNumberish>,
PromiseOrValue<BigNumberish>,
PromiseOrValue<BigNumberish>[],
PromiseOrValue<BigNumberish>[],
],
): string
encodeFunctionData(functionFragment: 'verifier', values?: undefined): string
encodeFunctionData(
functionFragment: 'verifyProof',
values: [
PromiseOrValue<BigNumberish>,
PromiseOrValue<BigNumberish>,
PromiseOrValue<BigNumberish>,
PromiseOrValue<BigNumberish>,
PromiseOrValue<BigNumberish>,
PromiseOrValue<BigNumberish>[],
],
): string
decodeFunctionResult(functionFragment: 'addMember', data: BytesLike): Result
decodeFunctionResult(functionFragment: 'addMembers', data: BytesLike): Result
decodeFunctionResult(
functionFragment: 'createGroup(uint256,uint256,address,uint256)',
data: BytesLike,
): Result
decodeFunctionResult(
functionFragment: 'createGroup(uint256,uint256,address)',
data: BytesLike,
): Result
decodeFunctionResult(functionFragment: 'getMerkleTreeDepth', data: BytesLike): Result
decodeFunctionResult(functionFragment: 'getMerkleTreeRoot', data: BytesLike): Result
decodeFunctionResult(functionFragment: 'getNumberOfMerkleTreeLeaves', data: BytesLike): Result
decodeFunctionResult(functionFragment: 'groups', data: BytesLike): Result
decodeFunctionResult(functionFragment: 'removeMember', data: BytesLike): Result
decodeFunctionResult(functionFragment: 'updateGroupAdmin', data: BytesLike): Result
decodeFunctionResult(functionFragment: 'updateGroupMerkleTreeDuration', data: BytesLike): Result
decodeFunctionResult(functionFragment: 'updateMember', data: BytesLike): Result
decodeFunctionResult(functionFragment: 'verifier', data: BytesLike): Result
decodeFunctionResult(functionFragment: 'verifyProof', data: BytesLike): Result
events: {
'GroupAdminUpdated(uint256,address,address)': EventFragment
'GroupCreated(uint256,uint256,uint256)': EventFragment
'GroupMerkleTreeDurationUpdated(uint256,uint256,uint256)': EventFragment
'MemberAdded(uint256,uint256,uint256,uint256)': EventFragment
'MemberRemoved(uint256,uint256,uint256,uint256)': EventFragment
'MemberUpdated(uint256,uint256,uint256,uint256,uint256)': EventFragment
'ProofVerified(uint256,uint256,uint256,uint256,uint256)': EventFragment
}
getEvent(nameOrSignatureOrTopic: 'GroupAdminUpdated'): EventFragment
getEvent(nameOrSignatureOrTopic: 'GroupCreated'): EventFragment
getEvent(nameOrSignatureOrTopic: 'GroupMerkleTreeDurationUpdated'): EventFragment
getEvent(nameOrSignatureOrTopic: 'MemberAdded'): EventFragment
getEvent(nameOrSignatureOrTopic: 'MemberRemoved'): EventFragment
getEvent(nameOrSignatureOrTopic: 'MemberUpdated'): EventFragment
getEvent(nameOrSignatureOrTopic: 'ProofVerified'): EventFragment
}
export interface GroupAdminUpdatedEventObject {
groupId: BigNumber
oldAdmin: string
newAdmin: string
}
export type GroupAdminUpdatedEvent = TypedEvent<
[BigNumber, string, string],
GroupAdminUpdatedEventObject
>
export type GroupAdminUpdatedEventFilter = TypedEventFilter<GroupAdminUpdatedEvent>
export interface GroupCreatedEventObject {
groupId: BigNumber
merkleTreeDepth: BigNumber
zeroValue: BigNumber
}
export type GroupCreatedEvent = TypedEvent<
[BigNumber, BigNumber, BigNumber],
GroupCreatedEventObject
>
export type GroupCreatedEventFilter = TypedEventFilter<GroupCreatedEvent>
export interface GroupMerkleTreeDurationUpdatedEventObject {
groupId: BigNumber
oldMerkleTreeDuration: BigNumber
newMerkleTreeDuration: BigNumber
}
export type GroupMerkleTreeDurationUpdatedEvent = TypedEvent<
[BigNumber, BigNumber, BigNumber],
GroupMerkleTreeDurationUpdatedEventObject
>
export type GroupMerkleTreeDurationUpdatedEventFilter =
TypedEventFilter<GroupMerkleTreeDurationUpdatedEvent>
export interface MemberAddedEventObject {
groupId: BigNumber
index: BigNumber
identityCommitment: BigNumber
merkleTreeRoot: BigNumber
}
export type MemberAddedEvent = TypedEvent<
[BigNumber, BigNumber, BigNumber, BigNumber],
MemberAddedEventObject
>
export type MemberAddedEventFilter = TypedEventFilter<MemberAddedEvent>
export interface MemberRemovedEventObject {
groupId: BigNumber
index: BigNumber
identityCommitment: BigNumber
merkleTreeRoot: BigNumber
}
export type MemberRemovedEvent = TypedEvent<
[BigNumber, BigNumber, BigNumber, BigNumber],
MemberRemovedEventObject
>
export type MemberRemovedEventFilter = TypedEventFilter<MemberRemovedEvent>
export interface MemberUpdatedEventObject {
groupId: BigNumber
index: BigNumber
identityCommitment: BigNumber
newIdentityCommitment: BigNumber
merkleTreeRoot: BigNumber
}
export type MemberUpdatedEvent = TypedEvent<
[BigNumber, BigNumber, BigNumber, BigNumber, BigNumber],
MemberUpdatedEventObject
>
export type MemberUpdatedEventFilter = TypedEventFilter<MemberUpdatedEvent>
export interface ProofVerifiedEventObject {
groupId: BigNumber
merkleTreeRoot: BigNumber
externalNullifier: BigNumber
nullifierHash: BigNumber
signal: BigNumber
}
export type ProofVerifiedEvent = TypedEvent<
[BigNumber, BigNumber, BigNumber, BigNumber, BigNumber],
ProofVerifiedEventObject
>
export type ProofVerifiedEventFilter = TypedEventFilter<ProofVerifiedEvent>
export interface Semaphore extends BaseContract {
connect(signerOrProvider: Signer | Provider | string): this
attach(addressOrName: string): this
deployed(): Promise<this>
interface: SemaphoreInterface
queryFilter<TEvent extends TypedEvent>(
event: TypedEventFilter<TEvent>,
fromBlockOrBlockhash?: string | number | undefined,
toBlock?: string | number | undefined,
): Promise<Array<TEvent>>
listeners<TEvent extends TypedEvent>(
eventFilter?: TypedEventFilter<TEvent>,
): Array<TypedListener<TEvent>>
listeners(eventName?: string): Array<Listener>
removeAllListeners<TEvent extends TypedEvent>(eventFilter: TypedEventFilter<TEvent>): this
removeAllListeners(eventName?: string): this
off: OnEvent<this>
on: OnEvent<this>
once: OnEvent<this>
removeListener: OnEvent<this>
functions: {
addMember(
groupId: PromiseOrValue<BigNumberish>,
identityCommitment: PromiseOrValue<BigNumberish>,
overrides?: Overrides & { from?: PromiseOrValue<string> },
): Promise<ContractTransaction>
addMembers(
groupId: PromiseOrValue<BigNumberish>,
identityCommitments: PromiseOrValue<BigNumberish>[],
overrides?: Overrides & { from?: PromiseOrValue<string> },
): Promise<ContractTransaction>
'createGroup(uint256,uint256,address,uint256)'(
groupId: PromiseOrValue<BigNumberish>,
merkleTreeDepth: PromiseOrValue<BigNumberish>,
admin: PromiseOrValue<string>,
merkleTreeDuration: PromiseOrValue<BigNumberish>,
overrides?: Overrides & { from?: PromiseOrValue<string> },
): Promise<ContractTransaction>
'createGroup(uint256,uint256,address)'(
groupId: PromiseOrValue<BigNumberish>,
merkleTreeDepth: PromiseOrValue<BigNumberish>,
admin: PromiseOrValue<string>,
overrides?: Overrides & { from?: PromiseOrValue<string> },
): Promise<ContractTransaction>
getMerkleTreeDepth(
groupId: PromiseOrValue<BigNumberish>,
overrides?: CallOverrides,
): Promise<[BigNumber]>
getMerkleTreeRoot(
groupId: PromiseOrValue<BigNumberish>,
overrides?: CallOverrides,
): Promise<[BigNumber]>
getNumberOfMerkleTreeLeaves(
groupId: PromiseOrValue<BigNumberish>,
overrides?: CallOverrides,
): Promise<[BigNumber]>
groups(
arg0: PromiseOrValue<BigNumberish>,
overrides?: CallOverrides,
): Promise<[string, BigNumber] & { admin: string; merkleTreeDuration: BigNumber }>
removeMember(
groupId: PromiseOrValue<BigNumberish>,
identityCommitment: PromiseOrValue<BigNumberish>,
proofSiblings: PromiseOrValue<BigNumberish>[],
proofPathIndices: PromiseOrValue<BigNumberish>[],
overrides?: Overrides & { from?: PromiseOrValue<string> },
): Promise<ContractTransaction>
updateGroupAdmin(
groupId: PromiseOrValue<BigNumberish>,
newAdmin: PromiseOrValue<string>,
overrides?: Overrides & { from?: PromiseOrValue<string> },
): Promise<ContractTransaction>
updateGroupMerkleTreeDuration(
groupId: PromiseOrValue<BigNumberish>,
newMerkleTreeDuration: PromiseOrValue<BigNumberish>,
overrides?: Overrides & { from?: PromiseOrValue<string> },
): Promise<ContractTransaction>
updateMember(
groupId: PromiseOrValue<BigNumberish>,
identityCommitment: PromiseOrValue<BigNumberish>,
newIdentityCommitment: PromiseOrValue<BigNumberish>,
proofSiblings: PromiseOrValue<BigNumberish>[],
proofPathIndices: PromiseOrValue<BigNumberish>[],
overrides?: Overrides & { from?: PromiseOrValue<string> },
): Promise<ContractTransaction>
verifier(overrides?: CallOverrides): Promise<[string]>
verifyProof(
groupId: PromiseOrValue<BigNumberish>,
merkleTreeRoot: PromiseOrValue<BigNumberish>,
signal: PromiseOrValue<BigNumberish>,
nullifierHash: PromiseOrValue<BigNumberish>,
externalNullifier: PromiseOrValue<BigNumberish>,
proof: PromiseOrValue<BigNumberish>[],
overrides?: Overrides & { from?: PromiseOrValue<string> },
): Promise<ContractTransaction>
}
addMember(
groupId: PromiseOrValue<BigNumberish>,
identityCommitment: PromiseOrValue<BigNumberish>,
overrides?: Overrides & { from?: PromiseOrValue<string> },
): Promise<ContractTransaction>
addMembers(
groupId: PromiseOrValue<BigNumberish>,
identityCommitments: PromiseOrValue<BigNumberish>[],
overrides?: Overrides & { from?: PromiseOrValue<string> },
): Promise<ContractTransaction>
'createGroup(uint256,uint256,address,uint256)'(
groupId: PromiseOrValue<BigNumberish>,
merkleTreeDepth: PromiseOrValue<BigNumberish>,
admin: PromiseOrValue<string>,
merkleTreeDuration: PromiseOrValue<BigNumberish>,
overrides?: Overrides & { from?: PromiseOrValue<string> },
): Promise<ContractTransaction>
'createGroup(uint256,uint256,address)'(
groupId: PromiseOrValue<BigNumberish>,
merkleTreeDepth: PromiseOrValue<BigNumberish>,
admin: PromiseOrValue<string>,
overrides?: Overrides & { from?: PromiseOrValue<string> },
): Promise<ContractTransaction>
getMerkleTreeDepth(
groupId: PromiseOrValue<BigNumberish>,
overrides?: CallOverrides,
): Promise<BigNumber>
getMerkleTreeRoot(
groupId: PromiseOrValue<BigNumberish>,
overrides?: CallOverrides,
): Promise<BigNumber>
getNumberOfMerkleTreeLeaves(
groupId: PromiseOrValue<BigNumberish>,
overrides?: CallOverrides,
): Promise<BigNumber>
groups(
arg0: PromiseOrValue<BigNumberish>,
overrides?: CallOverrides,
): Promise<[string, BigNumber] & { admin: string; merkleTreeDuration: BigNumber }>
removeMember(
groupId: PromiseOrValue<BigNumberish>,
identityCommitment: PromiseOrValue<BigNumberish>,
proofSiblings: PromiseOrValue<BigNumberish>[],
proofPathIndices: PromiseOrValue<BigNumberish>[],
overrides?: Overrides & { from?: PromiseOrValue<string> },
): Promise<ContractTransaction>
updateGroupAdmin(
groupId: PromiseOrValue<BigNumberish>,
newAdmin: PromiseOrValue<string>,
overrides?: Overrides & { from?: PromiseOrValue<string> },
): Promise<ContractTransaction>
updateGroupMerkleTreeDuration(
groupId: PromiseOrValue<BigNumberish>,
newMerkleTreeDuration: PromiseOrValue<BigNumberish>,
overrides?: Overrides & { from?: PromiseOrValue<string> },
): Promise<ContractTransaction>
updateMember(
groupId: PromiseOrValue<BigNumberish>,
identityCommitment: PromiseOrValue<BigNumberish>,
newIdentityCommitment: PromiseOrValue<BigNumberish>,
proofSiblings: PromiseOrValue<BigNumberish>[],
proofPathIndices: PromiseOrValue<BigNumberish>[],
overrides?: Overrides & { from?: PromiseOrValue<string> },
): Promise<ContractTransaction>
verifier(overrides?: CallOverrides): Promise<string>
verifyProof(
groupId: PromiseOrValue<BigNumberish>,
merkleTreeRoot: PromiseOrValue<BigNumberish>,
signal: PromiseOrValue<BigNumberish>,
nullifierHash: PromiseOrValue<BigNumberish>,
externalNullifier: PromiseOrValue<BigNumberish>,
proof: PromiseOrValue<BigNumberish>[],
overrides?: Overrides & { from?: PromiseOrValue<string> },
): Promise<ContractTransaction>
callStatic: {
addMember(
groupId: PromiseOrValue<BigNumberish>,
identityCommitment: PromiseOrValue<BigNumberish>,
overrides?: CallOverrides,
): Promise<void>
addMembers(
groupId: PromiseOrValue<BigNumberish>,
identityCommitments: PromiseOrValue<BigNumberish>[],
overrides?: CallOverrides,
): Promise<void>
'createGroup(uint256,uint256,address,uint256)'(
groupId: PromiseOrValue<BigNumberish>,
merkleTreeDepth: PromiseOrValue<BigNumberish>,
admin: PromiseOrValue<string>,
merkleTreeDuration: PromiseOrValue<BigNumberish>,
overrides?: CallOverrides,
): Promise<void>
'createGroup(uint256,uint256,address)'(
groupId: PromiseOrValue<BigNumberish>,
merkleTreeDepth: PromiseOrValue<BigNumberish>,
admin: PromiseOrValue<string>,
overrides?: CallOverrides,
): Promise<void>
getMerkleTreeDepth(
groupId: PromiseOrValue<BigNumberish>,
overrides?: CallOverrides,
): Promise<BigNumber>
getMerkleTreeRoot(
groupId: PromiseOrValue<BigNumberish>,
overrides?: CallOverrides,
): Promise<BigNumber>
getNumberOfMerkleTreeLeaves(
groupId: PromiseOrValue<BigNumberish>,
overrides?: CallOverrides,
): Promise<BigNumber>
groups(
arg0: PromiseOrValue<BigNumberish>,
overrides?: CallOverrides,
): Promise<[string, BigNumber] & { admin: string; merkleTreeDuration: BigNumber }>
removeMember(
groupId: PromiseOrValue<BigNumberish>,
identityCommitment: PromiseOrValue<BigNumberish>,
proofSiblings: PromiseOrValue<BigNumberish>[],
proofPathIndices: PromiseOrValue<BigNumberish>[],
overrides?: CallOverrides,
): Promise<void>
updateGroupAdmin(
groupId: PromiseOrValue<BigNumberish>,
newAdmin: PromiseOrValue<string>,
overrides?: CallOverrides,
): Promise<void>
updateGroupMerkleTreeDuration(
groupId: PromiseOrValue<BigNumberish>,
newMerkleTreeDuration: PromiseOrValue<BigNumberish>,
overrides?: CallOverrides,
): Promise<void>
updateMember(
groupId: PromiseOrValue<BigNumberish>,
identityCommitment: PromiseOrValue<BigNumberish>,
newIdentityCommitment: PromiseOrValue<BigNumberish>,
proofSiblings: PromiseOrValue<BigNumberish>[],
proofPathIndices: PromiseOrValue<BigNumberish>[],
overrides?: CallOverrides,
): Promise<void>
verifier(overrides?: CallOverrides): Promise<string>
verifyProof(
groupId: PromiseOrValue<BigNumberish>,
merkleTreeRoot: PromiseOrValue<BigNumberish>,
signal: PromiseOrValue<BigNumberish>,
nullifierHash: PromiseOrValue<BigNumberish>,
externalNullifier: PromiseOrValue<BigNumberish>,
proof: PromiseOrValue<BigNumberish>[],
overrides?: CallOverrides,
): Promise<void>
}
filters: {
'GroupAdminUpdated(uint256,address,address)'(
groupId?: PromiseOrValue<BigNumberish> | null,
oldAdmin?: PromiseOrValue<string> | null,
newAdmin?: PromiseOrValue<string> | null,
): GroupAdminUpdatedEventFilter
GroupAdminUpdated(
groupId?: PromiseOrValue<BigNumberish> | null,
oldAdmin?: PromiseOrValue<string> | null,
newAdmin?: PromiseOrValue<string> | null,
): GroupAdminUpdatedEventFilter
'GroupCreated(uint256,uint256,uint256)'(
groupId?: PromiseOrValue<BigNumberish> | null,
merkleTreeDepth?: null,
zeroValue?: null,
): GroupCreatedEventFilter
GroupCreated(
groupId?: PromiseOrValue<BigNumberish> | null,
merkleTreeDepth?: null,
zeroValue?: null,
): GroupCreatedEventFilter
'GroupMerkleTreeDurationUpdated(uint256,uint256,uint256)'(
groupId?: PromiseOrValue<BigNumberish> | null,
oldMerkleTreeDuration?: null,
newMerkleTreeDuration?: null,
): GroupMerkleTreeDurationUpdatedEventFilter
GroupMerkleTreeDurationUpdated(
groupId?: PromiseOrValue<BigNumberish> | null,
oldMerkleTreeDuration?: null,
newMerkleTreeDuration?: null,
): GroupMerkleTreeDurationUpdatedEventFilter
'MemberAdded(uint256,uint256,uint256,uint256)'(
groupId?: PromiseOrValue<BigNumberish> | null,
index?: null,
identityCommitment?: null,
merkleTreeRoot?: null,
): MemberAddedEventFilter
MemberAdded(
groupId?: PromiseOrValue<BigNumberish> | null,
index?: null,
identityCommitment?: null,
merkleTreeRoot?: null,
): MemberAddedEventFilter
'MemberRemoved(uint256,uint256,uint256,uint256)'(
groupId?: PromiseOrValue<BigNumberish> | null,
index?: null,
identityCommitment?: null,
merkleTreeRoot?: null,
): MemberRemovedEventFilter
MemberRemoved(
groupId?: PromiseOrValue<BigNumberish> | null,
index?: null,
identityCommitment?: null,
merkleTreeRoot?: null,
): MemberRemovedEventFilter
'MemberUpdated(uint256,uint256,uint256,uint256,uint256)'(
groupId?: PromiseOrValue<BigNumberish> | null,
index?: null,
identityCommitment?: null,
newIdentityCommitment?: null,
merkleTreeRoot?: null,
): MemberUpdatedEventFilter
MemberUpdated(
groupId?: PromiseOrValue<BigNumberish> | null,
index?: null,
identityCommitment?: null,
newIdentityCommitment?: null,
merkleTreeRoot?: null,
): MemberUpdatedEventFilter
'ProofVerified(uint256,uint256,uint256,uint256,uint256)'(
groupId?: PromiseOrValue<BigNumberish> | null,
merkleTreeRoot?: PromiseOrValue<BigNumberish> | null,
externalNullifier?: PromiseOrValue<BigNumberish> | null,
nullifierHash?: null,
signal?: null,
): ProofVerifiedEventFilter
ProofVerified(
groupId?: PromiseOrValue<BigNumberish> | null,
merkleTreeRoot?: PromiseOrValue<BigNumberish> | null,
externalNullifier?: PromiseOrValue<BigNumberish> | null,
nullifierHash?: null,
signal?: null,
): ProofVerifiedEventFilter
}
estimateGas: {
addMember(
groupId: PromiseOrValue<BigNumberish>,
identityCommitment: PromiseOrValue<BigNumberish>,
overrides?: Overrides & { from?: PromiseOrValue<string> },
): Promise<BigNumber>
addMembers(
groupId: PromiseOrValue<BigNumberish>,
identityCommitments: PromiseOrValue<BigNumberish>[],
overrides?: Overrides & { from?: PromiseOrValue<string> },
): Promise<BigNumber>
'createGroup(uint256,uint256,address,uint256)'(
groupId: PromiseOrValue<BigNumberish>,
merkleTreeDepth: PromiseOrValue<BigNumberish>,
admin: PromiseOrValue<string>,
merkleTreeDuration: PromiseOrValue<BigNumberish>,
overrides?: Overrides & { from?: PromiseOrValue<string> },
): Promise<BigNumber>
'createGroup(uint256,uint256,address)'(
groupId: PromiseOrValue<BigNumberish>,
merkleTreeDepth: PromiseOrValue<BigNumberish>,
admin: PromiseOrValue<string>,
overrides?: Overrides & { from?: PromiseOrValue<string> },
): Promise<BigNumber>
getMerkleTreeDepth(
groupId: PromiseOrValue<BigNumberish>,
overrides?: CallOverrides,
): Promise<BigNumber>
getMerkleTreeRoot(
groupId: PromiseOrValue<BigNumberish>,
overrides?: CallOverrides,
): Promise<BigNumber>
getNumberOfMerkleTreeLeaves(
groupId: PromiseOrValue<BigNumberish>,
overrides?: CallOverrides,
): Promise<BigNumber>
groups(arg0: PromiseOrValue<BigNumberish>, overrides?: CallOverrides): Promise<BigNumber>
removeMember(
groupId: PromiseOrValue<BigNumberish>,
identityCommitment: PromiseOrValue<BigNumberish>,
proofSiblings: PromiseOrValue<BigNumberish>[],
proofPathIndices: PromiseOrValue<BigNumberish>[],
overrides?: Overrides & { from?: PromiseOrValue<string> },
): Promise<BigNumber>
updateGroupAdmin(
groupId: PromiseOrValue<BigNumberish>,
newAdmin: PromiseOrValue<string>,
overrides?: Overrides & { from?: PromiseOrValue<string> },
): Promise<BigNumber>
updateGroupMerkleTreeDuration(
groupId: PromiseOrValue<BigNumberish>,
newMerkleTreeDuration: PromiseOrValue<BigNumberish>,
overrides?: Overrides & { from?: PromiseOrValue<string> },
): Promise<BigNumber>
updateMember(
groupId: PromiseOrValue<BigNumberish>,
identityCommitment: PromiseOrValue<BigNumberish>,
newIdentityCommitment: PromiseOrValue<BigNumberish>,
proofSiblings: PromiseOrValue<BigNumberish>[],
proofPathIndices: PromiseOrValue<BigNumberish>[],
overrides?: Overrides & { from?: PromiseOrValue<string> },
): Promise<BigNumber>
verifier(overrides?: CallOverrides): Promise<BigNumber>
verifyProof(
groupId: PromiseOrValue<BigNumberish>,
merkleTreeRoot: PromiseOrValue<BigNumberish>,
signal: PromiseOrValue<BigNumberish>,
nullifierHash: PromiseOrValue<BigNumberish>,
externalNullifier: PromiseOrValue<BigNumberish>,
proof: PromiseOrValue<BigNumberish>[],
overrides?: Overrides & { from?: PromiseOrValue<string> },
): Promise<BigNumber>
}
populateTransaction: {
addMember(
groupId: PromiseOrValue<BigNumberish>,
identityCommitment: PromiseOrValue<BigNumberish>,
overrides?: Overrides & { from?: PromiseOrValue<string> },
): Promise<PopulatedTransaction>
addMembers(
groupId: PromiseOrValue<BigNumberish>,
identityCommitments: PromiseOrValue<BigNumberish>[],
overrides?: Overrides & { from?: PromiseOrValue<string> },
): Promise<PopulatedTransaction>
'createGroup(uint256,uint256,address,uint256)'(
groupId: PromiseOrValue<BigNumberish>,
merkleTreeDepth: PromiseOrValue<BigNumberish>,
admin: PromiseOrValue<string>,
merkleTreeDuration: PromiseOrValue<BigNumberish>,
overrides?: Overrides & { from?: PromiseOrValue<string> },
): Promise<PopulatedTransaction>
'createGroup(uint256,uint256,address)'(
groupId: PromiseOrValue<BigNumberish>,
merkleTreeDepth: PromiseOrValue<BigNumberish>,
admin: PromiseOrValue<string>,
overrides?: Overrides & { from?: PromiseOrValue<string> },
): Promise<PopulatedTransaction>
getMerkleTreeDepth(
groupId: PromiseOrValue<BigNumberish>,
overrides?: CallOverrides,
): Promise<PopulatedTransaction>
getMerkleTreeRoot(
groupId: PromiseOrValue<BigNumberish>,
overrides?: CallOverrides,
): Promise<PopulatedTransaction>
getNumberOfMerkleTreeLeaves(
groupId: PromiseOrValue<BigNumberish>,
overrides?: CallOverrides,
): Promise<PopulatedTransaction>
groups(
arg0: PromiseOrValue<BigNumberish>,
overrides?: CallOverrides,
): Promise<PopulatedTransaction>
removeMember(
groupId: PromiseOrValue<BigNumberish>,
identityCommitment: PromiseOrValue<BigNumberish>,
proofSiblings: PromiseOrValue<BigNumberish>[],
proofPathIndices: PromiseOrValue<BigNumberish>[],
overrides?: Overrides & { from?: PromiseOrValue<string> },
): Promise<PopulatedTransaction>
updateGroupAdmin(
groupId: PromiseOrValue<BigNumberish>,
newAdmin: PromiseOrValue<string>,
overrides?: Overrides & { from?: PromiseOrValue<string> },
): Promise<PopulatedTransaction>
updateGroupMerkleTreeDuration(
groupId: PromiseOrValue<BigNumberish>,
newMerkleTreeDuration: PromiseOrValue<BigNumberish>,
overrides?: Overrides & { from?: PromiseOrValue<string> },
): Promise<PopulatedTransaction>
updateMember(
groupId: PromiseOrValue<BigNumberish>,
identityCommitment: PromiseOrValue<BigNumberish>,
newIdentityCommitment: PromiseOrValue<BigNumberish>,
proofSiblings: PromiseOrValue<BigNumberish>[],
proofPathIndices: PromiseOrValue<BigNumberish>[],
overrides?: Overrides & { from?: PromiseOrValue<string> },
): Promise<PopulatedTransaction>
verifier(overrides?: CallOverrides): Promise<PopulatedTransaction>
verifyProof(
groupId: PromiseOrValue<BigNumberish>,
merkleTreeRoot: PromiseOrValue<BigNumberish>,
signal: PromiseOrValue<BigNumberish>,
nullifierHash: PromiseOrValue<BigNumberish>,
externalNullifier: PromiseOrValue<BigNumberish>,
proof: PromiseOrValue<BigNumberish>[],
overrides?: Overrides & { from?: PromiseOrValue<string> },
): Promise<PopulatedTransaction>
}
}

View File

@ -0,0 +1,245 @@
/* Autogenerated file. Do not edit manually. */
/* tslint:disable */
/* eslint-disable */
import type {
BaseContract,
BigNumber,
BigNumberish,
BytesLike,
CallOverrides,
PopulatedTransaction,
Signer,
utils,
} from 'ethers'
import type { FunctionFragment, Result } from '@ethersproject/abi'
import type { Listener, Provider } from '@ethersproject/providers'
import type {
TypedEventFilter,
TypedEvent,
TypedListener,
OnEvent,
PromiseOrValue,
} from '../../../common'
export declare namespace Pairing {
export type G1PointStruct = {
X: PromiseOrValue<BigNumberish>
Y: PromiseOrValue<BigNumberish>
}
export type G1PointStructOutput = [BigNumber, BigNumber] & {
X: BigNumber
Y: BigNumber
}
export type G2PointStruct = {
X: [PromiseOrValue<BigNumberish>, PromiseOrValue<BigNumberish>]
Y: [PromiseOrValue<BigNumberish>, PromiseOrValue<BigNumberish>]
}
export type G2PointStructOutput = [[BigNumber, BigNumber], [BigNumber, BigNumber]] & {
X: [BigNumber, BigNumber]
Y: [BigNumber, BigNumber]
}
}
export interface PairingInterface extends utils.Interface {
functions: {
'P1()': FunctionFragment
'P2()': FunctionFragment
'addition((uint256,uint256),(uint256,uint256))': FunctionFragment
'negate((uint256,uint256))': FunctionFragment
'pairingCheck((uint256,uint256)[],(uint256[2],uint256[2])[])': FunctionFragment
'scalar_mul((uint256,uint256),uint256)': FunctionFragment
}
getFunction(
nameOrSignatureOrTopic: 'P1' | 'P2' | 'addition' | 'negate' | 'pairingCheck' | 'scalar_mul',
): FunctionFragment
encodeFunctionData(functionFragment: 'P1', values?: undefined): string
encodeFunctionData(functionFragment: 'P2', values?: undefined): string
encodeFunctionData(
functionFragment: 'addition',
values: [Pairing.G1PointStruct, Pairing.G1PointStruct],
): string
encodeFunctionData(functionFragment: 'negate', values: [Pairing.G1PointStruct]): string
encodeFunctionData(
functionFragment: 'pairingCheck',
values: [Pairing.G1PointStruct[], Pairing.G2PointStruct[]],
): string
encodeFunctionData(
functionFragment: 'scalar_mul',
values: [Pairing.G1PointStruct, PromiseOrValue<BigNumberish>],
): string
decodeFunctionResult(functionFragment: 'P1', data: BytesLike): Result
decodeFunctionResult(functionFragment: 'P2', data: BytesLike): Result
decodeFunctionResult(functionFragment: 'addition', data: BytesLike): Result
decodeFunctionResult(functionFragment: 'negate', data: BytesLike): Result
decodeFunctionResult(functionFragment: 'pairingCheck', data: BytesLike): Result
decodeFunctionResult(functionFragment: 'scalar_mul', data: BytesLike): Result
events: {}
}
export interface Pairing extends BaseContract {
connect(signerOrProvider: Signer | Provider | string): this
attach(addressOrName: string): this
deployed(): Promise<this>
interface: PairingInterface
queryFilter<TEvent extends TypedEvent>(
event: TypedEventFilter<TEvent>,
fromBlockOrBlockhash?: string | number | undefined,
toBlock?: string | number | undefined,
): Promise<Array<TEvent>>
listeners<TEvent extends TypedEvent>(
eventFilter?: TypedEventFilter<TEvent>,
): Array<TypedListener<TEvent>>
listeners(eventName?: string): Array<Listener>
removeAllListeners<TEvent extends TypedEvent>(eventFilter: TypedEventFilter<TEvent>): this
removeAllListeners(eventName?: string): this
off: OnEvent<this>
on: OnEvent<this>
once: OnEvent<this>
removeListener: OnEvent<this>
functions: {
P1(overrides?: CallOverrides): Promise<[Pairing.G1PointStructOutput]>
P2(overrides?: CallOverrides): Promise<[Pairing.G2PointStructOutput]>
addition(
p1: Pairing.G1PointStruct,
p2: Pairing.G1PointStruct,
overrides?: CallOverrides,
): Promise<[Pairing.G1PointStructOutput] & { r: Pairing.G1PointStructOutput }>
negate(
p: Pairing.G1PointStruct,
overrides?: CallOverrides,
): Promise<[Pairing.G1PointStructOutput] & { r: Pairing.G1PointStructOutput }>
pairingCheck(
p1: Pairing.G1PointStruct[],
p2: Pairing.G2PointStruct[],
overrides?: CallOverrides,
): Promise<[void]>
scalar_mul(
p: Pairing.G1PointStruct,
s: PromiseOrValue<BigNumberish>,
overrides?: CallOverrides,
): Promise<[Pairing.G1PointStructOutput] & { r: Pairing.G1PointStructOutput }>
}
P1(overrides?: CallOverrides): Promise<Pairing.G1PointStructOutput>
P2(overrides?: CallOverrides): Promise<Pairing.G2PointStructOutput>
addition(
p1: Pairing.G1PointStruct,
p2: Pairing.G1PointStruct,
overrides?: CallOverrides,
): Promise<Pairing.G1PointStructOutput>
negate(p: Pairing.G1PointStruct, overrides?: CallOverrides): Promise<Pairing.G1PointStructOutput>
pairingCheck(
p1: Pairing.G1PointStruct[],
p2: Pairing.G2PointStruct[],
overrides?: CallOverrides,
): Promise<void>
scalar_mul(
p: Pairing.G1PointStruct,
s: PromiseOrValue<BigNumberish>,
overrides?: CallOverrides,
): Promise<Pairing.G1PointStructOutput>
callStatic: {
P1(overrides?: CallOverrides): Promise<Pairing.G1PointStructOutput>
P2(overrides?: CallOverrides): Promise<Pairing.G2PointStructOutput>
addition(
p1: Pairing.G1PointStruct,
p2: Pairing.G1PointStruct,
overrides?: CallOverrides,
): Promise<Pairing.G1PointStructOutput>
negate(
p: Pairing.G1PointStruct,
overrides?: CallOverrides,
): Promise<Pairing.G1PointStructOutput>
pairingCheck(
p1: Pairing.G1PointStruct[],
p2: Pairing.G2PointStruct[],
overrides?: CallOverrides,
): Promise<void>
scalar_mul(
p: Pairing.G1PointStruct,
s: PromiseOrValue<BigNumberish>,
overrides?: CallOverrides,
): Promise<Pairing.G1PointStructOutput>
}
filters: {}
estimateGas: {
P1(overrides?: CallOverrides): Promise<BigNumber>
P2(overrides?: CallOverrides): Promise<BigNumber>
addition(
p1: Pairing.G1PointStruct,
p2: Pairing.G1PointStruct,
overrides?: CallOverrides,
): Promise<BigNumber>
negate(p: Pairing.G1PointStruct, overrides?: CallOverrides): Promise<BigNumber>
pairingCheck(
p1: Pairing.G1PointStruct[],
p2: Pairing.G2PointStruct[],
overrides?: CallOverrides,
): Promise<BigNumber>
scalar_mul(
p: Pairing.G1PointStruct,
s: PromiseOrValue<BigNumberish>,
overrides?: CallOverrides,
): Promise<BigNumber>
}
populateTransaction: {
P1(overrides?: CallOverrides): Promise<PopulatedTransaction>
P2(overrides?: CallOverrides): Promise<PopulatedTransaction>
addition(
p1: Pairing.G1PointStruct,
p2: Pairing.G1PointStruct,
overrides?: CallOverrides,
): Promise<PopulatedTransaction>
negate(p: Pairing.G1PointStruct, overrides?: CallOverrides): Promise<PopulatedTransaction>
pairingCheck(
p1: Pairing.G1PointStruct[],
p2: Pairing.G2PointStruct[],
overrides?: CallOverrides,
): Promise<PopulatedTransaction>
scalar_mul(
p: Pairing.G1PointStruct,
s: PromiseOrValue<BigNumberish>,
overrides?: CallOverrides,
): Promise<PopulatedTransaction>
}
}

View File

@ -0,0 +1,280 @@
/* Autogenerated file. Do not edit manually. */
/* tslint:disable */
/* eslint-disable */
import type {
BaseContract,
BigNumber,
BigNumberish,
BytesLike,
CallOverrides,
PopulatedTransaction,
Signer,
utils,
} from 'ethers'
import type { FunctionFragment, Result, EventFragment } from '@ethersproject/abi'
import type { Listener, Provider } from '@ethersproject/providers'
import type {
TypedEventFilter,
TypedEvent,
TypedListener,
OnEvent,
PromiseOrValue,
} from '../../../common'
export interface SemaphoreGroupsInterface extends utils.Interface {
functions: {
'getMerkleTreeDepth(uint256)': FunctionFragment
'getMerkleTreeRoot(uint256)': FunctionFragment
'getNumberOfMerkleTreeLeaves(uint256)': FunctionFragment
}
getFunction(
nameOrSignatureOrTopic:
| 'getMerkleTreeDepth'
| 'getMerkleTreeRoot'
| 'getNumberOfMerkleTreeLeaves',
): FunctionFragment
encodeFunctionData(
functionFragment: 'getMerkleTreeDepth',
values: [PromiseOrValue<BigNumberish>],
): string
encodeFunctionData(
functionFragment: 'getMerkleTreeRoot',
values: [PromiseOrValue<BigNumberish>],
): string
encodeFunctionData(
functionFragment: 'getNumberOfMerkleTreeLeaves',
values: [PromiseOrValue<BigNumberish>],
): string
decodeFunctionResult(functionFragment: 'getMerkleTreeDepth', data: BytesLike): Result
decodeFunctionResult(functionFragment: 'getMerkleTreeRoot', data: BytesLike): Result
decodeFunctionResult(functionFragment: 'getNumberOfMerkleTreeLeaves', data: BytesLike): Result
events: {
'GroupCreated(uint256,uint256,uint256)': EventFragment
'MemberAdded(uint256,uint256,uint256,uint256)': EventFragment
'MemberRemoved(uint256,uint256,uint256,uint256)': EventFragment
'MemberUpdated(uint256,uint256,uint256,uint256,uint256)': EventFragment
}
getEvent(nameOrSignatureOrTopic: 'GroupCreated'): EventFragment
getEvent(nameOrSignatureOrTopic: 'MemberAdded'): EventFragment
getEvent(nameOrSignatureOrTopic: 'MemberRemoved'): EventFragment
getEvent(nameOrSignatureOrTopic: 'MemberUpdated'): EventFragment
}
export interface GroupCreatedEventObject {
groupId: BigNumber
merkleTreeDepth: BigNumber
zeroValue: BigNumber
}
export type GroupCreatedEvent = TypedEvent<
[BigNumber, BigNumber, BigNumber],
GroupCreatedEventObject
>
export type GroupCreatedEventFilter = TypedEventFilter<GroupCreatedEvent>
export interface MemberAddedEventObject {
groupId: BigNumber
index: BigNumber
identityCommitment: BigNumber
merkleTreeRoot: BigNumber
}
export type MemberAddedEvent = TypedEvent<
[BigNumber, BigNumber, BigNumber, BigNumber],
MemberAddedEventObject
>
export type MemberAddedEventFilter = TypedEventFilter<MemberAddedEvent>
export interface MemberRemovedEventObject {
groupId: BigNumber
index: BigNumber
identityCommitment: BigNumber
merkleTreeRoot: BigNumber
}
export type MemberRemovedEvent = TypedEvent<
[BigNumber, BigNumber, BigNumber, BigNumber],
MemberRemovedEventObject
>
export type MemberRemovedEventFilter = TypedEventFilter<MemberRemovedEvent>
export interface MemberUpdatedEventObject {
groupId: BigNumber
index: BigNumber
identityCommitment: BigNumber
newIdentityCommitment: BigNumber
merkleTreeRoot: BigNumber
}
export type MemberUpdatedEvent = TypedEvent<
[BigNumber, BigNumber, BigNumber, BigNumber, BigNumber],
MemberUpdatedEventObject
>
export type MemberUpdatedEventFilter = TypedEventFilter<MemberUpdatedEvent>
export interface SemaphoreGroups extends BaseContract {
connect(signerOrProvider: Signer | Provider | string): this
attach(addressOrName: string): this
deployed(): Promise<this>
interface: SemaphoreGroupsInterface
queryFilter<TEvent extends TypedEvent>(
event: TypedEventFilter<TEvent>,
fromBlockOrBlockhash?: string | number | undefined,
toBlock?: string | number | undefined,
): Promise<Array<TEvent>>
listeners<TEvent extends TypedEvent>(
eventFilter?: TypedEventFilter<TEvent>,
): Array<TypedListener<TEvent>>
listeners(eventName?: string): Array<Listener>
removeAllListeners<TEvent extends TypedEvent>(eventFilter: TypedEventFilter<TEvent>): this
removeAllListeners(eventName?: string): this
off: OnEvent<this>
on: OnEvent<this>
once: OnEvent<this>
removeListener: OnEvent<this>
functions: {
getMerkleTreeDepth(
groupId: PromiseOrValue<BigNumberish>,
overrides?: CallOverrides,
): Promise<[BigNumber]>
getMerkleTreeRoot(
groupId: PromiseOrValue<BigNumberish>,
overrides?: CallOverrides,
): Promise<[BigNumber]>
getNumberOfMerkleTreeLeaves(
groupId: PromiseOrValue<BigNumberish>,
overrides?: CallOverrides,
): Promise<[BigNumber]>
}
getMerkleTreeDepth(
groupId: PromiseOrValue<BigNumberish>,
overrides?: CallOverrides,
): Promise<BigNumber>
getMerkleTreeRoot(
groupId: PromiseOrValue<BigNumberish>,
overrides?: CallOverrides,
): Promise<BigNumber>
getNumberOfMerkleTreeLeaves(
groupId: PromiseOrValue<BigNumberish>,
overrides?: CallOverrides,
): Promise<BigNumber>
callStatic: {
getMerkleTreeDepth(
groupId: PromiseOrValue<BigNumberish>,
overrides?: CallOverrides,
): Promise<BigNumber>
getMerkleTreeRoot(
groupId: PromiseOrValue<BigNumberish>,
overrides?: CallOverrides,
): Promise<BigNumber>
getNumberOfMerkleTreeLeaves(
groupId: PromiseOrValue<BigNumberish>,
overrides?: CallOverrides,
): Promise<BigNumber>
}
filters: {
'GroupCreated(uint256,uint256,uint256)'(
groupId?: PromiseOrValue<BigNumberish> | null,
merkleTreeDepth?: null,
zeroValue?: null,
): GroupCreatedEventFilter
GroupCreated(
groupId?: PromiseOrValue<BigNumberish> | null,
merkleTreeDepth?: null,
zeroValue?: null,
): GroupCreatedEventFilter
'MemberAdded(uint256,uint256,uint256,uint256)'(
groupId?: PromiseOrValue<BigNumberish> | null,
index?: null,
identityCommitment?: null,
merkleTreeRoot?: null,
): MemberAddedEventFilter
MemberAdded(
groupId?: PromiseOrValue<BigNumberish> | null,
index?: null,
identityCommitment?: null,
merkleTreeRoot?: null,
): MemberAddedEventFilter
'MemberRemoved(uint256,uint256,uint256,uint256)'(
groupId?: PromiseOrValue<BigNumberish> | null,
index?: null,
identityCommitment?: null,
merkleTreeRoot?: null,
): MemberRemovedEventFilter
MemberRemoved(
groupId?: PromiseOrValue<BigNumberish> | null,
index?: null,
identityCommitment?: null,
merkleTreeRoot?: null,
): MemberRemovedEventFilter
'MemberUpdated(uint256,uint256,uint256,uint256,uint256)'(
groupId?: PromiseOrValue<BigNumberish> | null,
index?: null,
identityCommitment?: null,
newIdentityCommitment?: null,
merkleTreeRoot?: null,
): MemberUpdatedEventFilter
MemberUpdated(
groupId?: PromiseOrValue<BigNumberish> | null,
index?: null,
identityCommitment?: null,
newIdentityCommitment?: null,
merkleTreeRoot?: null,
): MemberUpdatedEventFilter
}
estimateGas: {
getMerkleTreeDepth(
groupId: PromiseOrValue<BigNumberish>,
overrides?: CallOverrides,
): Promise<BigNumber>
getMerkleTreeRoot(
groupId: PromiseOrValue<BigNumberish>,
overrides?: CallOverrides,
): Promise<BigNumber>
getNumberOfMerkleTreeLeaves(
groupId: PromiseOrValue<BigNumberish>,
overrides?: CallOverrides,
): Promise<BigNumber>
}
populateTransaction: {
getMerkleTreeDepth(
groupId: PromiseOrValue<BigNumberish>,
overrides?: CallOverrides,
): Promise<PopulatedTransaction>
getMerkleTreeRoot(
groupId: PromiseOrValue<BigNumberish>,
overrides?: CallOverrides,
): Promise<PopulatedTransaction>
getNumberOfMerkleTreeLeaves(
groupId: PromiseOrValue<BigNumberish>,
overrides?: CallOverrides,
): Promise<PopulatedTransaction>
}
}

View File

@ -0,0 +1,131 @@
/* Autogenerated file. Do not edit manually. */
/* tslint:disable */
/* eslint-disable */
import type {
BaseContract,
BigNumber,
BigNumberish,
BytesLike,
CallOverrides,
PopulatedTransaction,
Signer,
utils,
} from 'ethers'
import type { FunctionFragment, Result } from '@ethersproject/abi'
import type { Listener, Provider } from '@ethersproject/providers'
import type {
TypedEventFilter,
TypedEvent,
TypedListener,
OnEvent,
PromiseOrValue,
} from '../../../common'
export interface SemaphoreVerifierInterface extends utils.Interface {
functions: {
'verifyProof(uint256,uint256,uint256,uint256,uint256[8],uint256)': FunctionFragment
}
getFunction(nameOrSignatureOrTopic: 'verifyProof'): FunctionFragment
encodeFunctionData(
functionFragment: 'verifyProof',
values: [
PromiseOrValue<BigNumberish>,
PromiseOrValue<BigNumberish>,
PromiseOrValue<BigNumberish>,
PromiseOrValue<BigNumberish>,
PromiseOrValue<BigNumberish>[],
PromiseOrValue<BigNumberish>,
],
): string
decodeFunctionResult(functionFragment: 'verifyProof', data: BytesLike): Result
events: {}
}
export interface SemaphoreVerifier extends BaseContract {
connect(signerOrProvider: Signer | Provider | string): this
attach(addressOrName: string): this
deployed(): Promise<this>
interface: SemaphoreVerifierInterface
queryFilter<TEvent extends TypedEvent>(
event: TypedEventFilter<TEvent>,
fromBlockOrBlockhash?: string | number | undefined,
toBlock?: string | number | undefined,
): Promise<Array<TEvent>>
listeners<TEvent extends TypedEvent>(
eventFilter?: TypedEventFilter<TEvent>,
): Array<TypedListener<TEvent>>
listeners(eventName?: string): Array<Listener>
removeAllListeners<TEvent extends TypedEvent>(eventFilter: TypedEventFilter<TEvent>): this
removeAllListeners(eventName?: string): this
off: OnEvent<this>
on: OnEvent<this>
once: OnEvent<this>
removeListener: OnEvent<this>
functions: {
verifyProof(
merkleTreeRoot: PromiseOrValue<BigNumberish>,
nullifierHash: PromiseOrValue<BigNumberish>,
signal: PromiseOrValue<BigNumberish>,
externalNullifier: PromiseOrValue<BigNumberish>,
proof: PromiseOrValue<BigNumberish>[],
merkleTreeDepth: PromiseOrValue<BigNumberish>,
overrides?: CallOverrides,
): Promise<[void]>
}
verifyProof(
merkleTreeRoot: PromiseOrValue<BigNumberish>,
nullifierHash: PromiseOrValue<BigNumberish>,
signal: PromiseOrValue<BigNumberish>,
externalNullifier: PromiseOrValue<BigNumberish>,
proof: PromiseOrValue<BigNumberish>[],
merkleTreeDepth: PromiseOrValue<BigNumberish>,
overrides?: CallOverrides,
): Promise<void>
callStatic: {
verifyProof(
merkleTreeRoot: PromiseOrValue<BigNumberish>,
nullifierHash: PromiseOrValue<BigNumberish>,
signal: PromiseOrValue<BigNumberish>,
externalNullifier: PromiseOrValue<BigNumberish>,
proof: PromiseOrValue<BigNumberish>[],
merkleTreeDepth: PromiseOrValue<BigNumberish>,
overrides?: CallOverrides,
): Promise<void>
}
filters: {}
estimateGas: {
verifyProof(
merkleTreeRoot: PromiseOrValue<BigNumberish>,
nullifierHash: PromiseOrValue<BigNumberish>,
signal: PromiseOrValue<BigNumberish>,
externalNullifier: PromiseOrValue<BigNumberish>,
proof: PromiseOrValue<BigNumberish>[],
merkleTreeDepth: PromiseOrValue<BigNumberish>,
overrides?: CallOverrides,
): Promise<BigNumber>
}
populateTransaction: {
verifyProof(
merkleTreeRoot: PromiseOrValue<BigNumberish>,
nullifierHash: PromiseOrValue<BigNumberish>,
signal: PromiseOrValue<BigNumberish>,
externalNullifier: PromiseOrValue<BigNumberish>,
proof: PromiseOrValue<BigNumberish>[],
merkleTreeDepth: PromiseOrValue<BigNumberish>,
overrides?: CallOverrides,
): Promise<PopulatedTransaction>
}
}

View File

@ -0,0 +1,6 @@
/* Autogenerated file. Do not edit manually. */
/* tslint:disable */
/* eslint-disable */
export type { Pairing } from './Pairing'
export type { SemaphoreGroups } from './SemaphoreGroups'
export type { SemaphoreVerifier } from './SemaphoreVerifier'

View File

@ -0,0 +1,8 @@
/* Autogenerated file. Do not edit manually. */
/* tslint:disable */
/* eslint-disable */
import type * as base from './base'
export type { base }
import type * as interfaces from './interfaces'
export type { interfaces }
export type { Semaphore } from './Semaphore'

View File

@ -0,0 +1,578 @@
/* Autogenerated file. Do not edit manually. */
/* tslint:disable */
/* eslint-disable */
import type {
BaseContract,
BigNumber,
BigNumberish,
BytesLike,
CallOverrides,
ContractTransaction,
Overrides,
PopulatedTransaction,
Signer,
utils,
} from 'ethers'
import type { FunctionFragment, Result, EventFragment } from '@ethersproject/abi'
import type { Listener, Provider } from '@ethersproject/providers'
import type {
TypedEventFilter,
TypedEvent,
TypedListener,
OnEvent,
PromiseOrValue,
} from '../../../common'
export interface ISemaphoreInterface extends utils.Interface {
functions: {
'addMember(uint256,uint256)': FunctionFragment
'addMembers(uint256,uint256[])': FunctionFragment
'createGroup(uint256,uint256,address,uint256)': FunctionFragment
'createGroup(uint256,uint256,address)': FunctionFragment
'removeMember(uint256,uint256,uint256[],uint8[])': FunctionFragment
'updateGroupAdmin(uint256,address)': FunctionFragment
'updateGroupMerkleTreeDuration(uint256,uint256)': FunctionFragment
'updateMember(uint256,uint256,uint256,uint256[],uint8[])': FunctionFragment
'verifyProof(uint256,uint256,uint256,uint256,uint256,uint256[8])': FunctionFragment
}
getFunction(
nameOrSignatureOrTopic:
| 'addMember'
| 'addMembers'
| 'createGroup(uint256,uint256,address,uint256)'
| 'createGroup(uint256,uint256,address)'
| 'removeMember'
| 'updateGroupAdmin'
| 'updateGroupMerkleTreeDuration'
| 'updateMember'
| 'verifyProof',
): FunctionFragment
encodeFunctionData(
functionFragment: 'addMember',
values: [PromiseOrValue<BigNumberish>, PromiseOrValue<BigNumberish>],
): string
encodeFunctionData(
functionFragment: 'addMembers',
values: [PromiseOrValue<BigNumberish>, PromiseOrValue<BigNumberish>[]],
): string
encodeFunctionData(
functionFragment: 'createGroup(uint256,uint256,address,uint256)',
values: [
PromiseOrValue<BigNumberish>,
PromiseOrValue<BigNumberish>,
PromiseOrValue<string>,
PromiseOrValue<BigNumberish>,
],
): string
encodeFunctionData(
functionFragment: 'createGroup(uint256,uint256,address)',
values: [PromiseOrValue<BigNumberish>, PromiseOrValue<BigNumberish>, PromiseOrValue<string>],
): string
encodeFunctionData(
functionFragment: 'removeMember',
values: [
PromiseOrValue<BigNumberish>,
PromiseOrValue<BigNumberish>,
PromiseOrValue<BigNumberish>[],
PromiseOrValue<BigNumberish>[],
],
): string
encodeFunctionData(
functionFragment: 'updateGroupAdmin',
values: [PromiseOrValue<BigNumberish>, PromiseOrValue<string>],
): string
encodeFunctionData(
functionFragment: 'updateGroupMerkleTreeDuration',
values: [PromiseOrValue<BigNumberish>, PromiseOrValue<BigNumberish>],
): string
encodeFunctionData(
functionFragment: 'updateMember',
values: [
PromiseOrValue<BigNumberish>,
PromiseOrValue<BigNumberish>,
PromiseOrValue<BigNumberish>,
PromiseOrValue<BigNumberish>[],
PromiseOrValue<BigNumberish>[],
],
): string
encodeFunctionData(
functionFragment: 'verifyProof',
values: [
PromiseOrValue<BigNumberish>,
PromiseOrValue<BigNumberish>,
PromiseOrValue<BigNumberish>,
PromiseOrValue<BigNumberish>,
PromiseOrValue<BigNumberish>,
PromiseOrValue<BigNumberish>[],
],
): string
decodeFunctionResult(functionFragment: 'addMember', data: BytesLike): Result
decodeFunctionResult(functionFragment: 'addMembers', data: BytesLike): Result
decodeFunctionResult(
functionFragment: 'createGroup(uint256,uint256,address,uint256)',
data: BytesLike,
): Result
decodeFunctionResult(
functionFragment: 'createGroup(uint256,uint256,address)',
data: BytesLike,
): Result
decodeFunctionResult(functionFragment: 'removeMember', data: BytesLike): Result
decodeFunctionResult(functionFragment: 'updateGroupAdmin', data: BytesLike): Result
decodeFunctionResult(functionFragment: 'updateGroupMerkleTreeDuration', data: BytesLike): Result
decodeFunctionResult(functionFragment: 'updateMember', data: BytesLike): Result
decodeFunctionResult(functionFragment: 'verifyProof', data: BytesLike): Result
events: {
'GroupAdminUpdated(uint256,address,address)': EventFragment
'GroupMerkleTreeDurationUpdated(uint256,uint256,uint256)': EventFragment
'ProofVerified(uint256,uint256,uint256,uint256,uint256)': EventFragment
}
getEvent(nameOrSignatureOrTopic: 'GroupAdminUpdated'): EventFragment
getEvent(nameOrSignatureOrTopic: 'GroupMerkleTreeDurationUpdated'): EventFragment
getEvent(nameOrSignatureOrTopic: 'ProofVerified'): EventFragment
}
export interface GroupAdminUpdatedEventObject {
groupId: BigNumber
oldAdmin: string
newAdmin: string
}
export type GroupAdminUpdatedEvent = TypedEvent<
[BigNumber, string, string],
GroupAdminUpdatedEventObject
>
export type GroupAdminUpdatedEventFilter = TypedEventFilter<GroupAdminUpdatedEvent>
export interface GroupMerkleTreeDurationUpdatedEventObject {
groupId: BigNumber
oldMerkleTreeDuration: BigNumber
newMerkleTreeDuration: BigNumber
}
export type GroupMerkleTreeDurationUpdatedEvent = TypedEvent<
[BigNumber, BigNumber, BigNumber],
GroupMerkleTreeDurationUpdatedEventObject
>
export type GroupMerkleTreeDurationUpdatedEventFilter =
TypedEventFilter<GroupMerkleTreeDurationUpdatedEvent>
export interface ProofVerifiedEventObject {
groupId: BigNumber
merkleTreeRoot: BigNumber
externalNullifier: BigNumber
nullifierHash: BigNumber
signal: BigNumber
}
export type ProofVerifiedEvent = TypedEvent<
[BigNumber, BigNumber, BigNumber, BigNumber, BigNumber],
ProofVerifiedEventObject
>
export type ProofVerifiedEventFilter = TypedEventFilter<ProofVerifiedEvent>
export interface ISemaphore extends BaseContract {
connect(signerOrProvider: Signer | Provider | string): this
attach(addressOrName: string): this
deployed(): Promise<this>
interface: ISemaphoreInterface
queryFilter<TEvent extends TypedEvent>(
event: TypedEventFilter<TEvent>,
fromBlockOrBlockhash?: string | number | undefined,
toBlock?: string | number | undefined,
): Promise<Array<TEvent>>
listeners<TEvent extends TypedEvent>(
eventFilter?: TypedEventFilter<TEvent>,
): Array<TypedListener<TEvent>>
listeners(eventName?: string): Array<Listener>
removeAllListeners<TEvent extends TypedEvent>(eventFilter: TypedEventFilter<TEvent>): this
removeAllListeners(eventName?: string): this
off: OnEvent<this>
on: OnEvent<this>
once: OnEvent<this>
removeListener: OnEvent<this>
functions: {
addMember(
groupId: PromiseOrValue<BigNumberish>,
identityCommitment: PromiseOrValue<BigNumberish>,
overrides?: Overrides & { from?: PromiseOrValue<string> },
): Promise<ContractTransaction>
addMembers(
groupId: PromiseOrValue<BigNumberish>,
identityCommitments: PromiseOrValue<BigNumberish>[],
overrides?: Overrides & { from?: PromiseOrValue<string> },
): Promise<ContractTransaction>
'createGroup(uint256,uint256,address,uint256)'(
groupId: PromiseOrValue<BigNumberish>,
depth: PromiseOrValue<BigNumberish>,
admin: PromiseOrValue<string>,
merkleTreeRootDuration: PromiseOrValue<BigNumberish>,
overrides?: Overrides & { from?: PromiseOrValue<string> },
): Promise<ContractTransaction>
'createGroup(uint256,uint256,address)'(
groupId: PromiseOrValue<BigNumberish>,
depth: PromiseOrValue<BigNumberish>,
admin: PromiseOrValue<string>,
overrides?: Overrides & { from?: PromiseOrValue<string> },
): Promise<ContractTransaction>
removeMember(
groupId: PromiseOrValue<BigNumberish>,
identityCommitment: PromiseOrValue<BigNumberish>,
proofSiblings: PromiseOrValue<BigNumberish>[],
proofPathIndices: PromiseOrValue<BigNumberish>[],
overrides?: Overrides & { from?: PromiseOrValue<string> },
): Promise<ContractTransaction>
updateGroupAdmin(
groupId: PromiseOrValue<BigNumberish>,
newAdmin: PromiseOrValue<string>,
overrides?: Overrides & { from?: PromiseOrValue<string> },
): Promise<ContractTransaction>
updateGroupMerkleTreeDuration(
groupId: PromiseOrValue<BigNumberish>,
newMerkleTreeDuration: PromiseOrValue<BigNumberish>,
overrides?: Overrides & { from?: PromiseOrValue<string> },
): Promise<ContractTransaction>
updateMember(
groupId: PromiseOrValue<BigNumberish>,
identityCommitment: PromiseOrValue<BigNumberish>,
newIdentityCommitment: PromiseOrValue<BigNumberish>,
proofSiblings: PromiseOrValue<BigNumberish>[],
proofPathIndices: PromiseOrValue<BigNumberish>[],
overrides?: Overrides & { from?: PromiseOrValue<string> },
): Promise<ContractTransaction>
verifyProof(
groupId: PromiseOrValue<BigNumberish>,
merkleTreeRoot: PromiseOrValue<BigNumberish>,
signal: PromiseOrValue<BigNumberish>,
nullifierHash: PromiseOrValue<BigNumberish>,
externalNullifier: PromiseOrValue<BigNumberish>,
proof: PromiseOrValue<BigNumberish>[],
overrides?: Overrides & { from?: PromiseOrValue<string> },
): Promise<ContractTransaction>
}
addMember(
groupId: PromiseOrValue<BigNumberish>,
identityCommitment: PromiseOrValue<BigNumberish>,
overrides?: Overrides & { from?: PromiseOrValue<string> },
): Promise<ContractTransaction>
addMembers(
groupId: PromiseOrValue<BigNumberish>,
identityCommitments: PromiseOrValue<BigNumberish>[],
overrides?: Overrides & { from?: PromiseOrValue<string> },
): Promise<ContractTransaction>
'createGroup(uint256,uint256,address,uint256)'(
groupId: PromiseOrValue<BigNumberish>,
depth: PromiseOrValue<BigNumberish>,
admin: PromiseOrValue<string>,
merkleTreeRootDuration: PromiseOrValue<BigNumberish>,
overrides?: Overrides & { from?: PromiseOrValue<string> },
): Promise<ContractTransaction>
'createGroup(uint256,uint256,address)'(
groupId: PromiseOrValue<BigNumberish>,
depth: PromiseOrValue<BigNumberish>,
admin: PromiseOrValue<string>,
overrides?: Overrides & { from?: PromiseOrValue<string> },
): Promise<ContractTransaction>
removeMember(
groupId: PromiseOrValue<BigNumberish>,
identityCommitment: PromiseOrValue<BigNumberish>,
proofSiblings: PromiseOrValue<BigNumberish>[],
proofPathIndices: PromiseOrValue<BigNumberish>[],
overrides?: Overrides & { from?: PromiseOrValue<string> },
): Promise<ContractTransaction>
updateGroupAdmin(
groupId: PromiseOrValue<BigNumberish>,
newAdmin: PromiseOrValue<string>,
overrides?: Overrides & { from?: PromiseOrValue<string> },
): Promise<ContractTransaction>
updateGroupMerkleTreeDuration(
groupId: PromiseOrValue<BigNumberish>,
newMerkleTreeDuration: PromiseOrValue<BigNumberish>,
overrides?: Overrides & { from?: PromiseOrValue<string> },
): Promise<ContractTransaction>
updateMember(
groupId: PromiseOrValue<BigNumberish>,
identityCommitment: PromiseOrValue<BigNumberish>,
newIdentityCommitment: PromiseOrValue<BigNumberish>,
proofSiblings: PromiseOrValue<BigNumberish>[],
proofPathIndices: PromiseOrValue<BigNumberish>[],
overrides?: Overrides & { from?: PromiseOrValue<string> },
): Promise<ContractTransaction>
verifyProof(
groupId: PromiseOrValue<BigNumberish>,
merkleTreeRoot: PromiseOrValue<BigNumberish>,
signal: PromiseOrValue<BigNumberish>,
nullifierHash: PromiseOrValue<BigNumberish>,
externalNullifier: PromiseOrValue<BigNumberish>,
proof: PromiseOrValue<BigNumberish>[],
overrides?: Overrides & { from?: PromiseOrValue<string> },
): Promise<ContractTransaction>
callStatic: {
addMember(
groupId: PromiseOrValue<BigNumberish>,
identityCommitment: PromiseOrValue<BigNumberish>,
overrides?: CallOverrides,
): Promise<void>
addMembers(
groupId: PromiseOrValue<BigNumberish>,
identityCommitments: PromiseOrValue<BigNumberish>[],
overrides?: CallOverrides,
): Promise<void>
'createGroup(uint256,uint256,address,uint256)'(
groupId: PromiseOrValue<BigNumberish>,
depth: PromiseOrValue<BigNumberish>,
admin: PromiseOrValue<string>,
merkleTreeRootDuration: PromiseOrValue<BigNumberish>,
overrides?: CallOverrides,
): Promise<void>
'createGroup(uint256,uint256,address)'(
groupId: PromiseOrValue<BigNumberish>,
depth: PromiseOrValue<BigNumberish>,
admin: PromiseOrValue<string>,
overrides?: CallOverrides,
): Promise<void>
removeMember(
groupId: PromiseOrValue<BigNumberish>,
identityCommitment: PromiseOrValue<BigNumberish>,
proofSiblings: PromiseOrValue<BigNumberish>[],
proofPathIndices: PromiseOrValue<BigNumberish>[],
overrides?: CallOverrides,
): Promise<void>
updateGroupAdmin(
groupId: PromiseOrValue<BigNumberish>,
newAdmin: PromiseOrValue<string>,
overrides?: CallOverrides,
): Promise<void>
updateGroupMerkleTreeDuration(
groupId: PromiseOrValue<BigNumberish>,
newMerkleTreeDuration: PromiseOrValue<BigNumberish>,
overrides?: CallOverrides,
): Promise<void>
updateMember(
groupId: PromiseOrValue<BigNumberish>,
identityCommitment: PromiseOrValue<BigNumberish>,
newIdentityCommitment: PromiseOrValue<BigNumberish>,
proofSiblings: PromiseOrValue<BigNumberish>[],
proofPathIndices: PromiseOrValue<BigNumberish>[],
overrides?: CallOverrides,
): Promise<void>
verifyProof(
groupId: PromiseOrValue<BigNumberish>,
merkleTreeRoot: PromiseOrValue<BigNumberish>,
signal: PromiseOrValue<BigNumberish>,
nullifierHash: PromiseOrValue<BigNumberish>,
externalNullifier: PromiseOrValue<BigNumberish>,
proof: PromiseOrValue<BigNumberish>[],
overrides?: CallOverrides,
): Promise<void>
}
filters: {
'GroupAdminUpdated(uint256,address,address)'(
groupId?: PromiseOrValue<BigNumberish> | null,
oldAdmin?: PromiseOrValue<string> | null,
newAdmin?: PromiseOrValue<string> | null,
): GroupAdminUpdatedEventFilter
GroupAdminUpdated(
groupId?: PromiseOrValue<BigNumberish> | null,
oldAdmin?: PromiseOrValue<string> | null,
newAdmin?: PromiseOrValue<string> | null,
): GroupAdminUpdatedEventFilter
'GroupMerkleTreeDurationUpdated(uint256,uint256,uint256)'(
groupId?: PromiseOrValue<BigNumberish> | null,
oldMerkleTreeDuration?: null,
newMerkleTreeDuration?: null,
): GroupMerkleTreeDurationUpdatedEventFilter
GroupMerkleTreeDurationUpdated(
groupId?: PromiseOrValue<BigNumberish> | null,
oldMerkleTreeDuration?: null,
newMerkleTreeDuration?: null,
): GroupMerkleTreeDurationUpdatedEventFilter
'ProofVerified(uint256,uint256,uint256,uint256,uint256)'(
groupId?: PromiseOrValue<BigNumberish> | null,
merkleTreeRoot?: PromiseOrValue<BigNumberish> | null,
externalNullifier?: PromiseOrValue<BigNumberish> | null,
nullifierHash?: null,
signal?: null,
): ProofVerifiedEventFilter
ProofVerified(
groupId?: PromiseOrValue<BigNumberish> | null,
merkleTreeRoot?: PromiseOrValue<BigNumberish> | null,
externalNullifier?: PromiseOrValue<BigNumberish> | null,
nullifierHash?: null,
signal?: null,
): ProofVerifiedEventFilter
}
estimateGas: {
addMember(
groupId: PromiseOrValue<BigNumberish>,
identityCommitment: PromiseOrValue<BigNumberish>,
overrides?: Overrides & { from?: PromiseOrValue<string> },
): Promise<BigNumber>
addMembers(
groupId: PromiseOrValue<BigNumberish>,
identityCommitments: PromiseOrValue<BigNumberish>[],
overrides?: Overrides & { from?: PromiseOrValue<string> },
): Promise<BigNumber>
'createGroup(uint256,uint256,address,uint256)'(
groupId: PromiseOrValue<BigNumberish>,
depth: PromiseOrValue<BigNumberish>,
admin: PromiseOrValue<string>,
merkleTreeRootDuration: PromiseOrValue<BigNumberish>,
overrides?: Overrides & { from?: PromiseOrValue<string> },
): Promise<BigNumber>
'createGroup(uint256,uint256,address)'(
groupId: PromiseOrValue<BigNumberish>,
depth: PromiseOrValue<BigNumberish>,
admin: PromiseOrValue<string>,
overrides?: Overrides & { from?: PromiseOrValue<string> },
): Promise<BigNumber>
removeMember(
groupId: PromiseOrValue<BigNumberish>,
identityCommitment: PromiseOrValue<BigNumberish>,
proofSiblings: PromiseOrValue<BigNumberish>[],
proofPathIndices: PromiseOrValue<BigNumberish>[],
overrides?: Overrides & { from?: PromiseOrValue<string> },
): Promise<BigNumber>
updateGroupAdmin(
groupId: PromiseOrValue<BigNumberish>,
newAdmin: PromiseOrValue<string>,
overrides?: Overrides & { from?: PromiseOrValue<string> },
): Promise<BigNumber>
updateGroupMerkleTreeDuration(
groupId: PromiseOrValue<BigNumberish>,
newMerkleTreeDuration: PromiseOrValue<BigNumberish>,
overrides?: Overrides & { from?: PromiseOrValue<string> },
): Promise<BigNumber>
updateMember(
groupId: PromiseOrValue<BigNumberish>,
identityCommitment: PromiseOrValue<BigNumberish>,
newIdentityCommitment: PromiseOrValue<BigNumberish>,
proofSiblings: PromiseOrValue<BigNumberish>[],
proofPathIndices: PromiseOrValue<BigNumberish>[],
overrides?: Overrides & { from?: PromiseOrValue<string> },
): Promise<BigNumber>
verifyProof(
groupId: PromiseOrValue<BigNumberish>,
merkleTreeRoot: PromiseOrValue<BigNumberish>,
signal: PromiseOrValue<BigNumberish>,
nullifierHash: PromiseOrValue<BigNumberish>,
externalNullifier: PromiseOrValue<BigNumberish>,
proof: PromiseOrValue<BigNumberish>[],
overrides?: Overrides & { from?: PromiseOrValue<string> },
): Promise<BigNumber>
}
populateTransaction: {
addMember(
groupId: PromiseOrValue<BigNumberish>,
identityCommitment: PromiseOrValue<BigNumberish>,
overrides?: Overrides & { from?: PromiseOrValue<string> },
): Promise<PopulatedTransaction>
addMembers(
groupId: PromiseOrValue<BigNumberish>,
identityCommitments: PromiseOrValue<BigNumberish>[],
overrides?: Overrides & { from?: PromiseOrValue<string> },
): Promise<PopulatedTransaction>
'createGroup(uint256,uint256,address,uint256)'(
groupId: PromiseOrValue<BigNumberish>,
depth: PromiseOrValue<BigNumberish>,
admin: PromiseOrValue<string>,
merkleTreeRootDuration: PromiseOrValue<BigNumberish>,
overrides?: Overrides & { from?: PromiseOrValue<string> },
): Promise<PopulatedTransaction>
'createGroup(uint256,uint256,address)'(
groupId: PromiseOrValue<BigNumberish>,
depth: PromiseOrValue<BigNumberish>,
admin: PromiseOrValue<string>,
overrides?: Overrides & { from?: PromiseOrValue<string> },
): Promise<PopulatedTransaction>
removeMember(
groupId: PromiseOrValue<BigNumberish>,
identityCommitment: PromiseOrValue<BigNumberish>,
proofSiblings: PromiseOrValue<BigNumberish>[],
proofPathIndices: PromiseOrValue<BigNumberish>[],
overrides?: Overrides & { from?: PromiseOrValue<string> },
): Promise<PopulatedTransaction>
updateGroupAdmin(
groupId: PromiseOrValue<BigNumberish>,
newAdmin: PromiseOrValue<string>,
overrides?: Overrides & { from?: PromiseOrValue<string> },
): Promise<PopulatedTransaction>
updateGroupMerkleTreeDuration(
groupId: PromiseOrValue<BigNumberish>,
newMerkleTreeDuration: PromiseOrValue<BigNumberish>,
overrides?: Overrides & { from?: PromiseOrValue<string> },
): Promise<PopulatedTransaction>
updateMember(
groupId: PromiseOrValue<BigNumberish>,
identityCommitment: PromiseOrValue<BigNumberish>,
newIdentityCommitment: PromiseOrValue<BigNumberish>,
proofSiblings: PromiseOrValue<BigNumberish>[],
proofPathIndices: PromiseOrValue<BigNumberish>[],
overrides?: Overrides & { from?: PromiseOrValue<string> },
): Promise<PopulatedTransaction>
verifyProof(
groupId: PromiseOrValue<BigNumberish>,
merkleTreeRoot: PromiseOrValue<BigNumberish>,
signal: PromiseOrValue<BigNumberish>,
nullifierHash: PromiseOrValue<BigNumberish>,
externalNullifier: PromiseOrValue<BigNumberish>,
proof: PromiseOrValue<BigNumberish>[],
overrides?: Overrides & { from?: PromiseOrValue<string> },
): Promise<PopulatedTransaction>
}
}

View File

@ -0,0 +1,280 @@
/* Autogenerated file. Do not edit manually. */
/* tslint:disable */
/* eslint-disable */
import type {
BaseContract,
BigNumber,
BigNumberish,
BytesLike,
CallOverrides,
PopulatedTransaction,
Signer,
utils,
} from 'ethers'
import type { FunctionFragment, Result, EventFragment } from '@ethersproject/abi'
import type { Listener, Provider } from '@ethersproject/providers'
import type {
TypedEventFilter,
TypedEvent,
TypedListener,
OnEvent,
PromiseOrValue,
} from '../../../common'
export interface ISemaphoreGroupsInterface extends utils.Interface {
functions: {
'getMerkleTreeDepth(uint256)': FunctionFragment
'getMerkleTreeRoot(uint256)': FunctionFragment
'getNumberOfMerkleTreeLeaves(uint256)': FunctionFragment
}
getFunction(
nameOrSignatureOrTopic:
| 'getMerkleTreeDepth'
| 'getMerkleTreeRoot'
| 'getNumberOfMerkleTreeLeaves',
): FunctionFragment
encodeFunctionData(
functionFragment: 'getMerkleTreeDepth',
values: [PromiseOrValue<BigNumberish>],
): string
encodeFunctionData(
functionFragment: 'getMerkleTreeRoot',
values: [PromiseOrValue<BigNumberish>],
): string
encodeFunctionData(
functionFragment: 'getNumberOfMerkleTreeLeaves',
values: [PromiseOrValue<BigNumberish>],
): string
decodeFunctionResult(functionFragment: 'getMerkleTreeDepth', data: BytesLike): Result
decodeFunctionResult(functionFragment: 'getMerkleTreeRoot', data: BytesLike): Result
decodeFunctionResult(functionFragment: 'getNumberOfMerkleTreeLeaves', data: BytesLike): Result
events: {
'GroupCreated(uint256,uint256,uint256)': EventFragment
'MemberAdded(uint256,uint256,uint256,uint256)': EventFragment
'MemberRemoved(uint256,uint256,uint256,uint256)': EventFragment
'MemberUpdated(uint256,uint256,uint256,uint256,uint256)': EventFragment
}
getEvent(nameOrSignatureOrTopic: 'GroupCreated'): EventFragment
getEvent(nameOrSignatureOrTopic: 'MemberAdded'): EventFragment
getEvent(nameOrSignatureOrTopic: 'MemberRemoved'): EventFragment
getEvent(nameOrSignatureOrTopic: 'MemberUpdated'): EventFragment
}
export interface GroupCreatedEventObject {
groupId: BigNumber
merkleTreeDepth: BigNumber
zeroValue: BigNumber
}
export type GroupCreatedEvent = TypedEvent<
[BigNumber, BigNumber, BigNumber],
GroupCreatedEventObject
>
export type GroupCreatedEventFilter = TypedEventFilter<GroupCreatedEvent>
export interface MemberAddedEventObject {
groupId: BigNumber
index: BigNumber
identityCommitment: BigNumber
merkleTreeRoot: BigNumber
}
export type MemberAddedEvent = TypedEvent<
[BigNumber, BigNumber, BigNumber, BigNumber],
MemberAddedEventObject
>
export type MemberAddedEventFilter = TypedEventFilter<MemberAddedEvent>
export interface MemberRemovedEventObject {
groupId: BigNumber
index: BigNumber
identityCommitment: BigNumber
merkleTreeRoot: BigNumber
}
export type MemberRemovedEvent = TypedEvent<
[BigNumber, BigNumber, BigNumber, BigNumber],
MemberRemovedEventObject
>
export type MemberRemovedEventFilter = TypedEventFilter<MemberRemovedEvent>
export interface MemberUpdatedEventObject {
groupId: BigNumber
index: BigNumber
identityCommitment: BigNumber
newIdentityCommitment: BigNumber
merkleTreeRoot: BigNumber
}
export type MemberUpdatedEvent = TypedEvent<
[BigNumber, BigNumber, BigNumber, BigNumber, BigNumber],
MemberUpdatedEventObject
>
export type MemberUpdatedEventFilter = TypedEventFilter<MemberUpdatedEvent>
export interface ISemaphoreGroups extends BaseContract {
connect(signerOrProvider: Signer | Provider | string): this
attach(addressOrName: string): this
deployed(): Promise<this>
interface: ISemaphoreGroupsInterface
queryFilter<TEvent extends TypedEvent>(
event: TypedEventFilter<TEvent>,
fromBlockOrBlockhash?: string | number | undefined,
toBlock?: string | number | undefined,
): Promise<Array<TEvent>>
listeners<TEvent extends TypedEvent>(
eventFilter?: TypedEventFilter<TEvent>,
): Array<TypedListener<TEvent>>
listeners(eventName?: string): Array<Listener>
removeAllListeners<TEvent extends TypedEvent>(eventFilter: TypedEventFilter<TEvent>): this
removeAllListeners(eventName?: string): this
off: OnEvent<this>
on: OnEvent<this>
once: OnEvent<this>
removeListener: OnEvent<this>
functions: {
getMerkleTreeDepth(
groupId: PromiseOrValue<BigNumberish>,
overrides?: CallOverrides,
): Promise<[BigNumber]>
getMerkleTreeRoot(
groupId: PromiseOrValue<BigNumberish>,
overrides?: CallOverrides,
): Promise<[BigNumber]>
getNumberOfMerkleTreeLeaves(
groupId: PromiseOrValue<BigNumberish>,
overrides?: CallOverrides,
): Promise<[BigNumber]>
}
getMerkleTreeDepth(
groupId: PromiseOrValue<BigNumberish>,
overrides?: CallOverrides,
): Promise<BigNumber>
getMerkleTreeRoot(
groupId: PromiseOrValue<BigNumberish>,
overrides?: CallOverrides,
): Promise<BigNumber>
getNumberOfMerkleTreeLeaves(
groupId: PromiseOrValue<BigNumberish>,
overrides?: CallOverrides,
): Promise<BigNumber>
callStatic: {
getMerkleTreeDepth(
groupId: PromiseOrValue<BigNumberish>,
overrides?: CallOverrides,
): Promise<BigNumber>
getMerkleTreeRoot(
groupId: PromiseOrValue<BigNumberish>,
overrides?: CallOverrides,
): Promise<BigNumber>
getNumberOfMerkleTreeLeaves(
groupId: PromiseOrValue<BigNumberish>,
overrides?: CallOverrides,
): Promise<BigNumber>
}
filters: {
'GroupCreated(uint256,uint256,uint256)'(
groupId?: PromiseOrValue<BigNumberish> | null,
merkleTreeDepth?: null,
zeroValue?: null,
): GroupCreatedEventFilter
GroupCreated(
groupId?: PromiseOrValue<BigNumberish> | null,
merkleTreeDepth?: null,
zeroValue?: null,
): GroupCreatedEventFilter
'MemberAdded(uint256,uint256,uint256,uint256)'(
groupId?: PromiseOrValue<BigNumberish> | null,
index?: null,
identityCommitment?: null,
merkleTreeRoot?: null,
): MemberAddedEventFilter
MemberAdded(
groupId?: PromiseOrValue<BigNumberish> | null,
index?: null,
identityCommitment?: null,
merkleTreeRoot?: null,
): MemberAddedEventFilter
'MemberRemoved(uint256,uint256,uint256,uint256)'(
groupId?: PromiseOrValue<BigNumberish> | null,
index?: null,
identityCommitment?: null,
merkleTreeRoot?: null,
): MemberRemovedEventFilter
MemberRemoved(
groupId?: PromiseOrValue<BigNumberish> | null,
index?: null,
identityCommitment?: null,
merkleTreeRoot?: null,
): MemberRemovedEventFilter
'MemberUpdated(uint256,uint256,uint256,uint256,uint256)'(
groupId?: PromiseOrValue<BigNumberish> | null,
index?: null,
identityCommitment?: null,
newIdentityCommitment?: null,
merkleTreeRoot?: null,
): MemberUpdatedEventFilter
MemberUpdated(
groupId?: PromiseOrValue<BigNumberish> | null,
index?: null,
identityCommitment?: null,
newIdentityCommitment?: null,
merkleTreeRoot?: null,
): MemberUpdatedEventFilter
}
estimateGas: {
getMerkleTreeDepth(
groupId: PromiseOrValue<BigNumberish>,
overrides?: CallOverrides,
): Promise<BigNumber>
getMerkleTreeRoot(
groupId: PromiseOrValue<BigNumberish>,
overrides?: CallOverrides,
): Promise<BigNumber>
getNumberOfMerkleTreeLeaves(
groupId: PromiseOrValue<BigNumberish>,
overrides?: CallOverrides,
): Promise<BigNumber>
}
populateTransaction: {
getMerkleTreeDepth(
groupId: PromiseOrValue<BigNumberish>,
overrides?: CallOverrides,
): Promise<PopulatedTransaction>
getMerkleTreeRoot(
groupId: PromiseOrValue<BigNumberish>,
overrides?: CallOverrides,
): Promise<PopulatedTransaction>
getNumberOfMerkleTreeLeaves(
groupId: PromiseOrValue<BigNumberish>,
overrides?: CallOverrides,
): Promise<PopulatedTransaction>
}
}

View File

@ -0,0 +1,131 @@
/* Autogenerated file. Do not edit manually. */
/* tslint:disable */
/* eslint-disable */
import type {
BaseContract,
BigNumber,
BigNumberish,
BytesLike,
CallOverrides,
PopulatedTransaction,
Signer,
utils,
} from 'ethers'
import type { FunctionFragment, Result } from '@ethersproject/abi'
import type { Listener, Provider } from '@ethersproject/providers'
import type {
TypedEventFilter,
TypedEvent,
TypedListener,
OnEvent,
PromiseOrValue,
} from '../../../common'
export interface ISemaphoreVerifierInterface extends utils.Interface {
functions: {
'verifyProof(uint256,uint256,uint256,uint256,uint256[8],uint256)': FunctionFragment
}
getFunction(nameOrSignatureOrTopic: 'verifyProof'): FunctionFragment
encodeFunctionData(
functionFragment: 'verifyProof',
values: [
PromiseOrValue<BigNumberish>,
PromiseOrValue<BigNumberish>,
PromiseOrValue<BigNumberish>,
PromiseOrValue<BigNumberish>,
PromiseOrValue<BigNumberish>[],
PromiseOrValue<BigNumberish>,
],
): string
decodeFunctionResult(functionFragment: 'verifyProof', data: BytesLike): Result
events: {}
}
export interface ISemaphoreVerifier extends BaseContract {
connect(signerOrProvider: Signer | Provider | string): this
attach(addressOrName: string): this
deployed(): Promise<this>
interface: ISemaphoreVerifierInterface
queryFilter<TEvent extends TypedEvent>(
event: TypedEventFilter<TEvent>,
fromBlockOrBlockhash?: string | number | undefined,
toBlock?: string | number | undefined,
): Promise<Array<TEvent>>
listeners<TEvent extends TypedEvent>(
eventFilter?: TypedEventFilter<TEvent>,
): Array<TypedListener<TEvent>>
listeners(eventName?: string): Array<Listener>
removeAllListeners<TEvent extends TypedEvent>(eventFilter: TypedEventFilter<TEvent>): this
removeAllListeners(eventName?: string): this
off: OnEvent<this>
on: OnEvent<this>
once: OnEvent<this>
removeListener: OnEvent<this>
functions: {
verifyProof(
merkleTreeRoot: PromiseOrValue<BigNumberish>,
nullifierHash: PromiseOrValue<BigNumberish>,
signal: PromiseOrValue<BigNumberish>,
externalNullifier: PromiseOrValue<BigNumberish>,
proof: PromiseOrValue<BigNumberish>[],
merkleTreeDepth: PromiseOrValue<BigNumberish>,
overrides?: CallOverrides,
): Promise<[void]>
}
verifyProof(
merkleTreeRoot: PromiseOrValue<BigNumberish>,
nullifierHash: PromiseOrValue<BigNumberish>,
signal: PromiseOrValue<BigNumberish>,
externalNullifier: PromiseOrValue<BigNumberish>,
proof: PromiseOrValue<BigNumberish>[],
merkleTreeDepth: PromiseOrValue<BigNumberish>,
overrides?: CallOverrides,
): Promise<void>
callStatic: {
verifyProof(
merkleTreeRoot: PromiseOrValue<BigNumberish>,
nullifierHash: PromiseOrValue<BigNumberish>,
signal: PromiseOrValue<BigNumberish>,
externalNullifier: PromiseOrValue<BigNumberish>,
proof: PromiseOrValue<BigNumberish>[],
merkleTreeDepth: PromiseOrValue<BigNumberish>,
overrides?: CallOverrides,
): Promise<void>
}
filters: {}
estimateGas: {
verifyProof(
merkleTreeRoot: PromiseOrValue<BigNumberish>,
nullifierHash: PromiseOrValue<BigNumberish>,
signal: PromiseOrValue<BigNumberish>,
externalNullifier: PromiseOrValue<BigNumberish>,
proof: PromiseOrValue<BigNumberish>[],
merkleTreeDepth: PromiseOrValue<BigNumberish>,
overrides?: CallOverrides,
): Promise<BigNumber>
}
populateTransaction: {
verifyProof(
merkleTreeRoot: PromiseOrValue<BigNumberish>,
nullifierHash: PromiseOrValue<BigNumberish>,
signal: PromiseOrValue<BigNumberish>,
externalNullifier: PromiseOrValue<BigNumberish>,
proof: PromiseOrValue<BigNumberish>[],
merkleTreeDepth: PromiseOrValue<BigNumberish>,
overrides?: CallOverrides,
): Promise<PopulatedTransaction>
}
}

View File

@ -0,0 +1,6 @@
/* Autogenerated file. Do not edit manually. */
/* tslint:disable */
/* eslint-disable */
export type { ISemaphore } from './ISemaphore'
export type { ISemaphoreGroups } from './ISemaphoreGroups'
export type { ISemaphoreVerifier } from './ISemaphoreVerifier'

View File

@ -0,0 +1,5 @@
/* Autogenerated file. Do not edit manually. */
/* tslint:disable */
/* eslint-disable */
import type * as contracts from './contracts'
export type { contracts }

View File

@ -0,0 +1,99 @@
/* Autogenerated file. Do not edit manually. */
/* tslint:disable */
/* eslint-disable */
import type {
BaseContract,
BigNumber,
BigNumberish,
BytesLike,
CallOverrides,
PopulatedTransaction,
Signer,
utils,
} from 'ethers'
import type { FunctionFragment, Result } from '@ethersproject/abi'
import type { Listener, Provider } from '@ethersproject/providers'
import type {
TypedEventFilter,
TypedEvent,
TypedListener,
OnEvent,
PromiseOrValue,
} from '../../../common'
export interface PoseidonT3Interface extends utils.Interface {
functions: {
'poseidon(uint256[2])': FunctionFragment
}
getFunction(nameOrSignatureOrTopic: 'poseidon'): FunctionFragment
encodeFunctionData(
functionFragment: 'poseidon',
values: [[PromiseOrValue<BigNumberish>, PromiseOrValue<BigNumberish>]],
): string
decodeFunctionResult(functionFragment: 'poseidon', data: BytesLike): Result
events: {}
}
export interface PoseidonT3 extends BaseContract {
connect(signerOrProvider: Signer | Provider | string): this
attach(addressOrName: string): this
deployed(): Promise<this>
interface: PoseidonT3Interface
queryFilter<TEvent extends TypedEvent>(
event: TypedEventFilter<TEvent>,
fromBlockOrBlockhash?: string | number | undefined,
toBlock?: string | number | undefined,
): Promise<Array<TEvent>>
listeners<TEvent extends TypedEvent>(
eventFilter?: TypedEventFilter<TEvent>,
): Array<TypedListener<TEvent>>
listeners(eventName?: string): Array<Listener>
removeAllListeners<TEvent extends TypedEvent>(eventFilter: TypedEventFilter<TEvent>): this
removeAllListeners(eventName?: string): this
off: OnEvent<this>
on: OnEvent<this>
once: OnEvent<this>
removeListener: OnEvent<this>
functions: {
poseidon(
arg0: [PromiseOrValue<BigNumberish>, PromiseOrValue<BigNumberish>],
overrides?: CallOverrides,
): Promise<[BigNumber]>
}
poseidon(
arg0: [PromiseOrValue<BigNumberish>, PromiseOrValue<BigNumberish>],
overrides?: CallOverrides,
): Promise<BigNumber>
callStatic: {
poseidon(
arg0: [PromiseOrValue<BigNumberish>, PromiseOrValue<BigNumberish>],
overrides?: CallOverrides,
): Promise<BigNumber>
}
filters: {}
estimateGas: {
poseidon(
arg0: [PromiseOrValue<BigNumberish>, PromiseOrValue<BigNumberish>],
overrides?: CallOverrides,
): Promise<BigNumber>
}
populateTransaction: {
poseidon(
arg0: [PromiseOrValue<BigNumberish>, PromiseOrValue<BigNumberish>],
overrides?: CallOverrides,
): Promise<PopulatedTransaction>
}
}

View File

@ -0,0 +1,137 @@
/* Autogenerated file. Do not edit manually. */
/* tslint:disable */
/* eslint-disable */
import type {
BaseContract,
BigNumber,
BigNumberish,
BytesLike,
CallOverrides,
PopulatedTransaction,
Signer,
utils,
} from 'ethers'
import type { FunctionFragment, Result } from '@ethersproject/abi'
import type { Listener, Provider } from '@ethersproject/providers'
import type {
TypedEventFilter,
TypedEvent,
TypedListener,
OnEvent,
PromiseOrValue,
} from '../../../common'
export interface PoseidonT6Interface extends utils.Interface {
functions: {
'poseidon(uint256[5])': FunctionFragment
}
getFunction(nameOrSignatureOrTopic: 'poseidon'): FunctionFragment
encodeFunctionData(
functionFragment: 'poseidon',
values: [
[
PromiseOrValue<BigNumberish>,
PromiseOrValue<BigNumberish>,
PromiseOrValue<BigNumberish>,
PromiseOrValue<BigNumberish>,
PromiseOrValue<BigNumberish>,
],
],
): string
decodeFunctionResult(functionFragment: 'poseidon', data: BytesLike): Result
events: {}
}
export interface PoseidonT6 extends BaseContract {
connect(signerOrProvider: Signer | Provider | string): this
attach(addressOrName: string): this
deployed(): Promise<this>
interface: PoseidonT6Interface
queryFilter<TEvent extends TypedEvent>(
event: TypedEventFilter<TEvent>,
fromBlockOrBlockhash?: string | number | undefined,
toBlock?: string | number | undefined,
): Promise<Array<TEvent>>
listeners<TEvent extends TypedEvent>(
eventFilter?: TypedEventFilter<TEvent>,
): Array<TypedListener<TEvent>>
listeners(eventName?: string): Array<Listener>
removeAllListeners<TEvent extends TypedEvent>(eventFilter: TypedEventFilter<TEvent>): this
removeAllListeners(eventName?: string): this
off: OnEvent<this>
on: OnEvent<this>
once: OnEvent<this>
removeListener: OnEvent<this>
functions: {
poseidon(
arg0: [
PromiseOrValue<BigNumberish>,
PromiseOrValue<BigNumberish>,
PromiseOrValue<BigNumberish>,
PromiseOrValue<BigNumberish>,
PromiseOrValue<BigNumberish>,
],
overrides?: CallOverrides,
): Promise<[BigNumber]>
}
poseidon(
arg0: [
PromiseOrValue<BigNumberish>,
PromiseOrValue<BigNumberish>,
PromiseOrValue<BigNumberish>,
PromiseOrValue<BigNumberish>,
PromiseOrValue<BigNumberish>,
],
overrides?: CallOverrides,
): Promise<BigNumber>
callStatic: {
poseidon(
arg0: [
PromiseOrValue<BigNumberish>,
PromiseOrValue<BigNumberish>,
PromiseOrValue<BigNumberish>,
PromiseOrValue<BigNumberish>,
PromiseOrValue<BigNumberish>,
],
overrides?: CallOverrides,
): Promise<BigNumber>
}
filters: {}
estimateGas: {
poseidon(
arg0: [
PromiseOrValue<BigNumberish>,
PromiseOrValue<BigNumberish>,
PromiseOrValue<BigNumberish>,
PromiseOrValue<BigNumberish>,
PromiseOrValue<BigNumberish>,
],
overrides?: CallOverrides,
): Promise<BigNumber>
}
populateTransaction: {
poseidon(
arg0: [
PromiseOrValue<BigNumberish>,
PromiseOrValue<BigNumberish>,
PromiseOrValue<BigNumberish>,
PromiseOrValue<BigNumberish>,
PromiseOrValue<BigNumberish>,
],
overrides?: CallOverrides,
): Promise<PopulatedTransaction>
}
}

View File

@ -0,0 +1,5 @@
/* Autogenerated file. Do not edit manually. */
/* tslint:disable */
/* eslint-disable */
export type { PoseidonT3 } from './PoseidonT3'
export type { PoseidonT6 } from './PoseidonT6'

View File

@ -0,0 +1,5 @@
/* Autogenerated file. Do not edit manually. */
/* tslint:disable */
/* eslint-disable */
import type * as hashesSol from './Hashes.sol'
export type { hashesSol }

View File

@ -0,0 +1,5 @@
/* Autogenerated file. Do not edit manually. */
/* tslint:disable */
/* eslint-disable */
import type * as incrementalMerkleTreeSol from './incremental-merkle-tree.sol'
export type { incrementalMerkleTreeSol }

View File

@ -0,0 +1,37 @@
/* Autogenerated file. Do not edit manually. */
/* tslint:disable */
/* eslint-disable */
import type { Listener } from '@ethersproject/providers'
import type { Event, EventFilter } from 'ethers'
export interface TypedEvent<TArgsArray extends Array<any> = any, TArgsObject = any> extends Event {
args: TArgsArray & TArgsObject
}
export interface TypedEventFilter<_TEvent extends TypedEvent> extends EventFilter {}
export interface TypedListener<TEvent extends TypedEvent> {
(...listenerArg: [...__TypechainArgsArray<TEvent>, TEvent]): void
}
type __TypechainArgsArray<T> = T extends TypedEvent<infer U> ? U : never
export interface OnEvent<TRes> {
<TEvent extends TypedEvent>(
eventFilter: TypedEventFilter<TEvent>,
listener: TypedListener<TEvent>,
): TRes
(eventName: string, listener: Listener): TRes
}
export type MinEthersFactory<C, ARGS> = {
deploy(...a: ARGS[]): Promise<C>
}
export type GetContractTypeFromFactory<F> = F extends MinEthersFactory<infer C, any> ? C : never
export type GetARGsTypeFromFactory<F> = F extends MinEthersFactory<any, any>
? Parameters<F['deploy']>
: never
export type PromiseOrValue<T> = T | Promise<T>

View File

@ -0,0 +1,245 @@
/* Autogenerated file. Do not edit manually. */
/* tslint:disable */
/* eslint-disable */
import type {
BaseContract,
BigNumber,
BigNumberish,
BytesLike,
CallOverrides,
ContractTransaction,
Overrides,
PopulatedTransaction,
Signer,
utils,
} from 'ethers'
import type { FunctionFragment, Result, EventFragment } from '@ethersproject/abi'
import type { Listener, Provider } from '@ethersproject/providers'
import type {
TypedEventFilter,
TypedEvent,
TypedListener,
OnEvent,
PromiseOrValue,
} from '../common'
export interface GlobalAnonymousFeedInterface extends utils.Interface {
functions: {
'groupId()': FunctionFragment
'joinGroup(uint256)': FunctionFragment
'registeredIdentities(uint256)': FunctionFragment
'semaphore()': FunctionFragment
'sendMessage(string,uint256,uint256,uint256,uint256[8])': FunctionFragment
}
getFunction(
nameOrSignatureOrTopic:
| 'groupId'
| 'joinGroup'
| 'registeredIdentities'
| 'semaphore'
| 'sendMessage',
): FunctionFragment
encodeFunctionData(functionFragment: 'groupId', values?: undefined): string
encodeFunctionData(functionFragment: 'joinGroup', values: [PromiseOrValue<BigNumberish>]): string
encodeFunctionData(
functionFragment: 'registeredIdentities',
values: [PromiseOrValue<BigNumberish>],
): string
encodeFunctionData(functionFragment: 'semaphore', values?: undefined): string
encodeFunctionData(
functionFragment: 'sendMessage',
values: [
PromiseOrValue<string>,
PromiseOrValue<BigNumberish>,
PromiseOrValue<BigNumberish>,
PromiseOrValue<BigNumberish>,
PromiseOrValue<BigNumberish>[],
],
): string
decodeFunctionResult(functionFragment: 'groupId', data: BytesLike): Result
decodeFunctionResult(functionFragment: 'joinGroup', data: BytesLike): Result
decodeFunctionResult(functionFragment: 'registeredIdentities', data: BytesLike): Result
decodeFunctionResult(functionFragment: 'semaphore', data: BytesLike): Result
decodeFunctionResult(functionFragment: 'sendMessage', data: BytesLike): Result
events: {
'NewIdentity(uint256)': EventFragment
'NewMessage(string)': EventFragment
}
getEvent(nameOrSignatureOrTopic: 'NewIdentity'): EventFragment
getEvent(nameOrSignatureOrTopic: 'NewMessage'): EventFragment
}
export interface NewIdentityEventObject {
identityCommitment: BigNumber
}
export type NewIdentityEvent = TypedEvent<[BigNumber], NewIdentityEventObject>
export type NewIdentityEventFilter = TypedEventFilter<NewIdentityEvent>
export interface NewMessageEventObject {
message: string
}
export type NewMessageEvent = TypedEvent<[string], NewMessageEventObject>
export type NewMessageEventFilter = TypedEventFilter<NewMessageEvent>
export interface GlobalAnonymousFeed extends BaseContract {
connect(signerOrProvider: Signer | Provider | string): this
attach(addressOrName: string): this
deployed(): Promise<this>
interface: GlobalAnonymousFeedInterface
queryFilter<TEvent extends TypedEvent>(
event: TypedEventFilter<TEvent>,
fromBlockOrBlockhash?: string | number | undefined,
toBlock?: string | number | undefined,
): Promise<Array<TEvent>>
listeners<TEvent extends TypedEvent>(
eventFilter?: TypedEventFilter<TEvent>,
): Array<TypedListener<TEvent>>
listeners(eventName?: string): Array<Listener>
removeAllListeners<TEvent extends TypedEvent>(eventFilter: TypedEventFilter<TEvent>): this
removeAllListeners(eventName?: string): this
off: OnEvent<this>
on: OnEvent<this>
once: OnEvent<this>
removeListener: OnEvent<this>
functions: {
groupId(overrides?: CallOverrides): Promise<[BigNumber]>
joinGroup(
identityCommitment: PromiseOrValue<BigNumberish>,
overrides?: Overrides & { from?: PromiseOrValue<string> },
): Promise<ContractTransaction>
registeredIdentities(
arg0: PromiseOrValue<BigNumberish>,
overrides?: CallOverrides,
): Promise<[boolean]>
semaphore(overrides?: CallOverrides): Promise<[string]>
sendMessage(
message: PromiseOrValue<string>,
merkleTreeRoot: PromiseOrValue<BigNumberish>,
nullifierHash: PromiseOrValue<BigNumberish>,
externalNullifier: PromiseOrValue<BigNumberish>,
proof: PromiseOrValue<BigNumberish>[],
overrides?: Overrides & { from?: PromiseOrValue<string> },
): Promise<ContractTransaction>
}
groupId(overrides?: CallOverrides): Promise<BigNumber>
joinGroup(
identityCommitment: PromiseOrValue<BigNumberish>,
overrides?: Overrides & { from?: PromiseOrValue<string> },
): Promise<ContractTransaction>
registeredIdentities(
arg0: PromiseOrValue<BigNumberish>,
overrides?: CallOverrides,
): Promise<boolean>
semaphore(overrides?: CallOverrides): Promise<string>
sendMessage(
message: PromiseOrValue<string>,
merkleTreeRoot: PromiseOrValue<BigNumberish>,
nullifierHash: PromiseOrValue<BigNumberish>,
externalNullifier: PromiseOrValue<BigNumberish>,
proof: PromiseOrValue<BigNumberish>[],
overrides?: Overrides & { from?: PromiseOrValue<string> },
): Promise<ContractTransaction>
callStatic: {
groupId(overrides?: CallOverrides): Promise<BigNumber>
joinGroup(
identityCommitment: PromiseOrValue<BigNumberish>,
overrides?: CallOverrides,
): Promise<void>
registeredIdentities(
arg0: PromiseOrValue<BigNumberish>,
overrides?: CallOverrides,
): Promise<boolean>
semaphore(overrides?: CallOverrides): Promise<string>
sendMessage(
message: PromiseOrValue<string>,
merkleTreeRoot: PromiseOrValue<BigNumberish>,
nullifierHash: PromiseOrValue<BigNumberish>,
externalNullifier: PromiseOrValue<BigNumberish>,
proof: PromiseOrValue<BigNumberish>[],
overrides?: CallOverrides,
): Promise<void>
}
filters: {
'NewIdentity(uint256)'(identityCommitment?: null): NewIdentityEventFilter
NewIdentity(identityCommitment?: null): NewIdentityEventFilter
'NewMessage(string)'(message?: null): NewMessageEventFilter
NewMessage(message?: null): NewMessageEventFilter
}
estimateGas: {
groupId(overrides?: CallOverrides): Promise<BigNumber>
joinGroup(
identityCommitment: PromiseOrValue<BigNumberish>,
overrides?: Overrides & { from?: PromiseOrValue<string> },
): Promise<BigNumber>
registeredIdentities(
arg0: PromiseOrValue<BigNumberish>,
overrides?: CallOverrides,
): Promise<BigNumber>
semaphore(overrides?: CallOverrides): Promise<BigNumber>
sendMessage(
message: PromiseOrValue<string>,
merkleTreeRoot: PromiseOrValue<BigNumberish>,
nullifierHash: PromiseOrValue<BigNumberish>,
externalNullifier: PromiseOrValue<BigNumberish>,
proof: PromiseOrValue<BigNumberish>[],
overrides?: Overrides & { from?: PromiseOrValue<string> },
): Promise<BigNumber>
}
populateTransaction: {
groupId(overrides?: CallOverrides): Promise<PopulatedTransaction>
joinGroup(
identityCommitment: PromiseOrValue<BigNumberish>,
overrides?: Overrides & { from?: PromiseOrValue<string> },
): Promise<PopulatedTransaction>
registeredIdentities(
arg0: PromiseOrValue<BigNumberish>,
overrides?: CallOverrides,
): Promise<PopulatedTransaction>
semaphore(overrides?: CallOverrides): Promise<PopulatedTransaction>
sendMessage(
message: PromiseOrValue<string>,
merkleTreeRoot: PromiseOrValue<BigNumberish>,
nullifierHash: PromiseOrValue<BigNumberish>,
externalNullifier: PromiseOrValue<BigNumberish>,
proof: PromiseOrValue<BigNumberish>[],
overrides?: Overrides & { from?: PromiseOrValue<string> },
): Promise<PopulatedTransaction>
}
}

View File

@ -0,0 +1,4 @@
/* Autogenerated file. Do not edit manually. */
/* tslint:disable */
/* eslint-disable */
export type { GlobalAnonymousFeed } from './GlobalAnonymousFeed'

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,214 @@
/* Autogenerated file. Do not edit manually. */
/* tslint:disable */
/* eslint-disable */
import { Contract, Signer, utils } from 'ethers'
import type { Provider } from '@ethersproject/providers'
import type {
SemaphoreGroups,
SemaphoreGroupsInterface,
} from '../../../../@semaphore-protocol/contracts/base/SemaphoreGroups'
const _abi = [
{
inputs: [],
name: 'Semaphore__GroupAlreadyExists',
type: 'error',
},
{
inputs: [],
name: 'Semaphore__GroupDoesNotExist',
type: 'error',
},
{
anonymous: false,
inputs: [
{
indexed: true,
internalType: 'uint256',
name: 'groupId',
type: 'uint256',
},
{
indexed: false,
internalType: 'uint256',
name: 'merkleTreeDepth',
type: 'uint256',
},
{
indexed: false,
internalType: 'uint256',
name: 'zeroValue',
type: 'uint256',
},
],
name: 'GroupCreated',
type: 'event',
},
{
anonymous: false,
inputs: [
{
indexed: true,
internalType: 'uint256',
name: 'groupId',
type: 'uint256',
},
{
indexed: false,
internalType: 'uint256',
name: 'index',
type: 'uint256',
},
{
indexed: false,
internalType: 'uint256',
name: 'identityCommitment',
type: 'uint256',
},
{
indexed: false,
internalType: 'uint256',
name: 'merkleTreeRoot',
type: 'uint256',
},
],
name: 'MemberAdded',
type: 'event',
},
{
anonymous: false,
inputs: [
{
indexed: true,
internalType: 'uint256',
name: 'groupId',
type: 'uint256',
},
{
indexed: false,
internalType: 'uint256',
name: 'index',
type: 'uint256',
},
{
indexed: false,
internalType: 'uint256',
name: 'identityCommitment',
type: 'uint256',
},
{
indexed: false,
internalType: 'uint256',
name: 'merkleTreeRoot',
type: 'uint256',
},
],
name: 'MemberRemoved',
type: 'event',
},
{
anonymous: false,
inputs: [
{
indexed: true,
internalType: 'uint256',
name: 'groupId',
type: 'uint256',
},
{
indexed: false,
internalType: 'uint256',
name: 'index',
type: 'uint256',
},
{
indexed: false,
internalType: 'uint256',
name: 'identityCommitment',
type: 'uint256',
},
{
indexed: false,
internalType: 'uint256',
name: 'newIdentityCommitment',
type: 'uint256',
},
{
indexed: false,
internalType: 'uint256',
name: 'merkleTreeRoot',
type: 'uint256',
},
],
name: 'MemberUpdated',
type: 'event',
},
{
inputs: [
{
internalType: 'uint256',
name: 'groupId',
type: 'uint256',
},
],
name: 'getMerkleTreeDepth',
outputs: [
{
internalType: 'uint256',
name: '',
type: 'uint256',
},
],
stateMutability: 'view',
type: 'function',
},
{
inputs: [
{
internalType: 'uint256',
name: 'groupId',
type: 'uint256',
},
],
name: 'getMerkleTreeRoot',
outputs: [
{
internalType: 'uint256',
name: '',
type: 'uint256',
},
],
stateMutability: 'view',
type: 'function',
},
{
inputs: [
{
internalType: 'uint256',
name: 'groupId',
type: 'uint256',
},
],
name: 'getNumberOfMerkleTreeLeaves',
outputs: [
{
internalType: 'uint256',
name: '',
type: 'uint256',
},
],
stateMutability: 'view',
type: 'function',
},
] as const
export class SemaphoreGroups__factory {
static readonly abi = _abi
static createInterface(): SemaphoreGroupsInterface {
return new utils.Interface(_abi) as SemaphoreGroupsInterface
}
static connect(address: string, signerOrProvider: Signer | Provider): SemaphoreGroups {
return new Contract(address, _abi, signerOrProvider) as SemaphoreGroups
}
}

View File

@ -0,0 +1,6 @@
/* Autogenerated file. Do not edit manually. */
/* tslint:disable */
/* eslint-disable */
export { Pairing__factory } from './Pairing__factory'
export { SemaphoreGroups__factory } from './SemaphoreGroups__factory'
export { SemaphoreVerifier__factory } from './SemaphoreVerifier__factory'

View File

@ -0,0 +1,6 @@
/* Autogenerated file. Do not edit manually. */
/* tslint:disable */
/* eslint-disable */
export * as base from './base'
export * as interfaces from './interfaces'
export { Semaphore__factory } from './Semaphore__factory'

View File

@ -0,0 +1,214 @@
/* Autogenerated file. Do not edit manually. */
/* tslint:disable */
/* eslint-disable */
import { Contract, Signer, utils } from 'ethers'
import type { Provider } from '@ethersproject/providers'
import type {
ISemaphoreGroups,
ISemaphoreGroupsInterface,
} from '../../../../@semaphore-protocol/contracts/interfaces/ISemaphoreGroups'
const _abi = [
{
inputs: [],
name: 'Semaphore__GroupAlreadyExists',
type: 'error',
},
{
inputs: [],
name: 'Semaphore__GroupDoesNotExist',
type: 'error',
},
{
anonymous: false,
inputs: [
{
indexed: true,
internalType: 'uint256',
name: 'groupId',
type: 'uint256',
},
{
indexed: false,
internalType: 'uint256',
name: 'merkleTreeDepth',
type: 'uint256',
},
{
indexed: false,
internalType: 'uint256',
name: 'zeroValue',
type: 'uint256',
},
],
name: 'GroupCreated',
type: 'event',
},
{
anonymous: false,
inputs: [
{
indexed: true,
internalType: 'uint256',
name: 'groupId',
type: 'uint256',
},
{
indexed: false,
internalType: 'uint256',
name: 'index',
type: 'uint256',
},
{
indexed: false,
internalType: 'uint256',
name: 'identityCommitment',
type: 'uint256',
},
{
indexed: false,
internalType: 'uint256',
name: 'merkleTreeRoot',
type: 'uint256',
},
],
name: 'MemberAdded',
type: 'event',
},
{
anonymous: false,
inputs: [
{
indexed: true,
internalType: 'uint256',
name: 'groupId',
type: 'uint256',
},
{
indexed: false,
internalType: 'uint256',
name: 'index',
type: 'uint256',
},
{
indexed: false,
internalType: 'uint256',
name: 'identityCommitment',
type: 'uint256',
},
{
indexed: false,
internalType: 'uint256',
name: 'merkleTreeRoot',
type: 'uint256',
},
],
name: 'MemberRemoved',
type: 'event',
},
{
anonymous: false,
inputs: [
{
indexed: true,
internalType: 'uint256',
name: 'groupId',
type: 'uint256',
},
{
indexed: false,
internalType: 'uint256',
name: 'index',
type: 'uint256',
},
{
indexed: false,
internalType: 'uint256',
name: 'identityCommitment',
type: 'uint256',
},
{
indexed: false,
internalType: 'uint256',
name: 'newIdentityCommitment',
type: 'uint256',
},
{
indexed: false,
internalType: 'uint256',
name: 'merkleTreeRoot',
type: 'uint256',
},
],
name: 'MemberUpdated',
type: 'event',
},
{
inputs: [
{
internalType: 'uint256',
name: 'groupId',
type: 'uint256',
},
],
name: 'getMerkleTreeDepth',
outputs: [
{
internalType: 'uint256',
name: '',
type: 'uint256',
},
],
stateMutability: 'view',
type: 'function',
},
{
inputs: [
{
internalType: 'uint256',
name: 'groupId',
type: 'uint256',
},
],
name: 'getMerkleTreeRoot',
outputs: [
{
internalType: 'uint256',
name: '',
type: 'uint256',
},
],
stateMutability: 'view',
type: 'function',
},
{
inputs: [
{
internalType: 'uint256',
name: 'groupId',
type: 'uint256',
},
],
name: 'getNumberOfMerkleTreeLeaves',
outputs: [
{
internalType: 'uint256',
name: '',
type: 'uint256',
},
],
stateMutability: 'view',
type: 'function',
},
] as const
export class ISemaphoreGroups__factory {
static readonly abi = _abi
static createInterface(): ISemaphoreGroupsInterface {
return new utils.Interface(_abi) as ISemaphoreGroupsInterface
}
static connect(address: string, signerOrProvider: Signer | Provider): ISemaphoreGroups {
return new Contract(address, _abi, signerOrProvider) as ISemaphoreGroups
}
}

View File

@ -0,0 +1,61 @@
/* Autogenerated file. Do not edit manually. */
/* tslint:disable */
/* eslint-disable */
import { Contract, Signer, utils } from 'ethers'
import type { Provider } from '@ethersproject/providers'
import type {
ISemaphoreVerifier,
ISemaphoreVerifierInterface,
} from '../../../../@semaphore-protocol/contracts/interfaces/ISemaphoreVerifier'
const _abi = [
{
inputs: [
{
internalType: 'uint256',
name: 'merkleTreeRoot',
type: 'uint256',
},
{
internalType: 'uint256',
name: 'nullifierHash',
type: 'uint256',
},
{
internalType: 'uint256',
name: 'signal',
type: 'uint256',
},
{
internalType: 'uint256',
name: 'externalNullifier',
type: 'uint256',
},
{
internalType: 'uint256[8]',
name: 'proof',
type: 'uint256[8]',
},
{
internalType: 'uint256',
name: 'merkleTreeDepth',
type: 'uint256',
},
],
name: 'verifyProof',
outputs: [],
stateMutability: 'view',
type: 'function',
},
] as const
export class ISemaphoreVerifier__factory {
static readonly abi = _abi
static createInterface(): ISemaphoreVerifierInterface {
return new utils.Interface(_abi) as ISemaphoreVerifierInterface
}
static connect(address: string, signerOrProvider: Signer | Provider): ISemaphoreVerifier {
return new Contract(address, _abi, signerOrProvider) as ISemaphoreVerifier
}
}

View File

@ -0,0 +1,357 @@
/* Autogenerated file. Do not edit manually. */
/* tslint:disable */
/* eslint-disable */
import { Contract, Signer, utils } from 'ethers'
import type { Provider } from '@ethersproject/providers'
import type {
ISemaphore,
ISemaphoreInterface,
} from '../../../../@semaphore-protocol/contracts/interfaces/ISemaphore'
const _abi = [
{
inputs: [],
name: 'Semaphore__CallerIsNotTheGroupAdmin',
type: 'error',
},
{
inputs: [],
name: 'Semaphore__MerkleTreeDepthIsNotSupported',
type: 'error',
},
{
inputs: [],
name: 'Semaphore__MerkleTreeRootIsExpired',
type: 'error',
},
{
inputs: [],
name: 'Semaphore__MerkleTreeRootIsNotPartOfTheGroup',
type: 'error',
},
{
inputs: [],
name: 'Semaphore__YouAreUsingTheSameNillifierTwice',
type: 'error',
},
{
anonymous: false,
inputs: [
{
indexed: true,
internalType: 'uint256',
name: 'groupId',
type: 'uint256',
},
{
indexed: true,
internalType: 'address',
name: 'oldAdmin',
type: 'address',
},
{
indexed: true,
internalType: 'address',
name: 'newAdmin',
type: 'address',
},
],
name: 'GroupAdminUpdated',
type: 'event',
},
{
anonymous: false,
inputs: [
{
indexed: true,
internalType: 'uint256',
name: 'groupId',
type: 'uint256',
},
{
indexed: false,
internalType: 'uint256',
name: 'oldMerkleTreeDuration',
type: 'uint256',
},
{
indexed: false,
internalType: 'uint256',
name: 'newMerkleTreeDuration',
type: 'uint256',
},
],
name: 'GroupMerkleTreeDurationUpdated',
type: 'event',
},
{
anonymous: false,
inputs: [
{
indexed: true,
internalType: 'uint256',
name: 'groupId',
type: 'uint256',
},
{
indexed: true,
internalType: 'uint256',
name: 'merkleTreeRoot',
type: 'uint256',
},
{
indexed: true,
internalType: 'uint256',
name: 'externalNullifier',
type: 'uint256',
},
{
indexed: false,
internalType: 'uint256',
name: 'nullifierHash',
type: 'uint256',
},
{
indexed: false,
internalType: 'uint256',
name: 'signal',
type: 'uint256',
},
],
name: 'ProofVerified',
type: 'event',
},
{
inputs: [
{
internalType: 'uint256',
name: 'groupId',
type: 'uint256',
},
{
internalType: 'uint256',
name: 'identityCommitment',
type: 'uint256',
},
],
name: 'addMember',
outputs: [],
stateMutability: 'nonpayable',
type: 'function',
},
{
inputs: [
{
internalType: 'uint256',
name: 'groupId',
type: 'uint256',
},
{
internalType: 'uint256[]',
name: 'identityCommitments',
type: 'uint256[]',
},
],
name: 'addMembers',
outputs: [],
stateMutability: 'nonpayable',
type: 'function',
},
{
inputs: [
{
internalType: 'uint256',
name: 'groupId',
type: 'uint256',
},
{
internalType: 'uint256',
name: 'depth',
type: 'uint256',
},
{
internalType: 'address',
name: 'admin',
type: 'address',
},
{
internalType: 'uint256',
name: 'merkleTreeRootDuration',
type: 'uint256',
},
],
name: 'createGroup',
outputs: [],
stateMutability: 'nonpayable',
type: 'function',
},
{
inputs: [
{
internalType: 'uint256',
name: 'groupId',
type: 'uint256',
},
{
internalType: 'uint256',
name: 'depth',
type: 'uint256',
},
{
internalType: 'address',
name: 'admin',
type: 'address',
},
],
name: 'createGroup',
outputs: [],
stateMutability: 'nonpayable',
type: 'function',
},
{
inputs: [
{
internalType: 'uint256',
name: 'groupId',
type: 'uint256',
},
{
internalType: 'uint256',
name: 'identityCommitment',
type: 'uint256',
},
{
internalType: 'uint256[]',
name: 'proofSiblings',
type: 'uint256[]',
},
{
internalType: 'uint8[]',
name: 'proofPathIndices',
type: 'uint8[]',
},
],
name: 'removeMember',
outputs: [],
stateMutability: 'nonpayable',
type: 'function',
},
{
inputs: [
{
internalType: 'uint256',
name: 'groupId',
type: 'uint256',
},
{
internalType: 'address',
name: 'newAdmin',
type: 'address',
},
],
name: 'updateGroupAdmin',
outputs: [],
stateMutability: 'nonpayable',
type: 'function',
},
{
inputs: [
{
internalType: 'uint256',
name: 'groupId',
type: 'uint256',
},
{
internalType: 'uint256',
name: 'newMerkleTreeDuration',
type: 'uint256',
},
],
name: 'updateGroupMerkleTreeDuration',
outputs: [],
stateMutability: 'nonpayable',
type: 'function',
},
{
inputs: [
{
internalType: 'uint256',
name: 'groupId',
type: 'uint256',
},
{
internalType: 'uint256',
name: 'identityCommitment',
type: 'uint256',
},
{
internalType: 'uint256',
name: 'newIdentityCommitment',
type: 'uint256',
},
{
internalType: 'uint256[]',
name: 'proofSiblings',
type: 'uint256[]',
},
{
internalType: 'uint8[]',
name: 'proofPathIndices',
type: 'uint8[]',
},
],
name: 'updateMember',
outputs: [],
stateMutability: 'nonpayable',
type: 'function',
},
{
inputs: [
{
internalType: 'uint256',
name: 'groupId',
type: 'uint256',
},
{
internalType: 'uint256',
name: 'merkleTreeRoot',
type: 'uint256',
},
{
internalType: 'uint256',
name: 'signal',
type: 'uint256',
},
{
internalType: 'uint256',
name: 'nullifierHash',
type: 'uint256',
},
{
internalType: 'uint256',
name: 'externalNullifier',
type: 'uint256',
},
{
internalType: 'uint256[8]',
name: 'proof',
type: 'uint256[8]',
},
],
name: 'verifyProof',
outputs: [],
stateMutability: 'nonpayable',
type: 'function',
},
] as const
export class ISemaphore__factory {
static readonly abi = _abi
static createInterface(): ISemaphoreInterface {
return new utils.Interface(_abi) as ISemaphoreInterface
}
static connect(address: string, signerOrProvider: Signer | Provider): ISemaphore {
return new Contract(address, _abi, signerOrProvider) as ISemaphore
}
}

View File

@ -0,0 +1,6 @@
/* Autogenerated file. Do not edit manually. */
/* tslint:disable */
/* eslint-disable */
export { ISemaphore__factory } from './ISemaphore__factory'
export { ISemaphoreGroups__factory } from './ISemaphoreGroups__factory'
export { ISemaphoreVerifier__factory } from './ISemaphoreVerifier__factory'

View File

@ -0,0 +1,4 @@
/* Autogenerated file. Do not edit manually. */
/* tslint:disable */
/* eslint-disable */
export * as contracts from './contracts'

View File

@ -0,0 +1,75 @@
/* Autogenerated file. Do not edit manually. */
/* tslint:disable */
/* eslint-disable */
import { Signer, utils, Contract, ContractFactory, type Overrides } from 'ethers'
import type { Provider, TransactionRequest } from '@ethersproject/providers'
import type { PromiseOrValue } from '../../../../common'
import type {
PoseidonT3,
PoseidonT3Interface,
} from '../../../../@zk-kit/incremental-merkle-tree.sol/Hashes.sol/PoseidonT3'
const _abi = [
{
inputs: [
{
internalType: 'uint256[2]',
name: '',
type: 'uint256[2]',
},
],
name: 'poseidon',
outputs: [
{
internalType: 'uint256',
name: '',
type: 'uint256',
},
],
stateMutability: 'pure',
type: 'function',
},
] as const
const _bytecode =
'0x610276610053600b82828239805160001a607314610046577f4e487b7100000000000000000000000000000000000000000000000000000000600052600060045260246000fd5b30600052607381538281f3fe73000000000000000000000000000000000000000030146080604052600436106100355760003560e01c806329a5f2f61461003a575b600080fd5b610054600480360381019061004f9190610110565b61006a565b6040516100619190610148565b60405180910390f35b6000919050565b600061008461007f84610188565b610163565b9050808285602086028201111561009a57600080fd5b60005b858110156100ca57816100b088826100fb565b84526020840193506020830192505060018101905061009d565b5050509392505050565b600082601f8301126100e557600080fd5b60026100f2848285610071565b91505092915050565b60008135905061010a81610229565b92915050565b60006040828403121561012257600080fd5b6000610130848285016100d4565b91505092915050565b610142816101ae565b82525050565b600060208201905061015d6000830184610139565b92915050565b600061016d61017e565b905061017982826101b8565b919050565b6000604051905090565b600067ffffffffffffffff8211156101a3576101a26101e9565b5b602082029050919050565b6000819050919050565b6101c182610218565b810181811067ffffffffffffffff821117156101e0576101df6101e9565b5b80604052505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6000601f19601f8301169050919050565b610232816101ae565b811461023d57600080fd5b5056fea26469706673582212200f65da5cd40983d95b5c21d21d0205bb75d282002a521263ed6070756a7883bd64736f6c63430008040033'
type PoseidonT3ConstructorParams = [signer?: Signer] | ConstructorParameters<typeof ContractFactory>
const isSuperArgs = (
xs: PoseidonT3ConstructorParams,
): xs is ConstructorParameters<typeof ContractFactory> => xs.length > 1
export class PoseidonT3__factory extends ContractFactory {
constructor(...args: PoseidonT3ConstructorParams) {
if (isSuperArgs(args)) {
super(...args)
} else {
super(_abi, _bytecode, args[0])
}
}
override deploy(overrides?: Overrides & { from?: PromiseOrValue<string> }): Promise<PoseidonT3> {
return super.deploy(overrides || {}) as Promise<PoseidonT3>
}
override getDeployTransaction(
overrides?: Overrides & { from?: PromiseOrValue<string> },
): TransactionRequest {
return super.getDeployTransaction(overrides || {})
}
override attach(address: string): PoseidonT3 {
return super.attach(address) as PoseidonT3
}
override connect(signer: Signer): PoseidonT3__factory {
return super.connect(signer) as PoseidonT3__factory
}
static readonly bytecode = _bytecode
static readonly abi = _abi
static createInterface(): PoseidonT3Interface {
return new utils.Interface(_abi) as PoseidonT3Interface
}
static connect(address: string, signerOrProvider: Signer | Provider): PoseidonT3 {
return new Contract(address, _abi, signerOrProvider) as PoseidonT3
}
}

View File

@ -0,0 +1,75 @@
/* Autogenerated file. Do not edit manually. */
/* tslint:disable */
/* eslint-disable */
import { Signer, utils, Contract, ContractFactory, type Overrides } from 'ethers'
import type { Provider, TransactionRequest } from '@ethersproject/providers'
import type { PromiseOrValue } from '../../../../common'
import type {
PoseidonT6,
PoseidonT6Interface,
} from '../../../../@zk-kit/incremental-merkle-tree.sol/Hashes.sol/PoseidonT6'
const _abi = [
{
inputs: [
{
internalType: 'uint256[5]',
name: '',
type: 'uint256[5]',
},
],
name: 'poseidon',
outputs: [
{
internalType: 'uint256',
name: '',
type: 'uint256',
},
],
stateMutability: 'pure',
type: 'function',
},
] as const
const _bytecode =
'0x610276610053600b82828239805160001a607314610046577f4e487b7100000000000000000000000000000000000000000000000000000000600052600060045260246000fd5b30600052607381538281f3fe73000000000000000000000000000000000000000030146080604052600436106100355760003560e01c80634937a2581461003a575b600080fd5b610054600480360381019061004f9190610110565b61006a565b6040516100619190610148565b60405180910390f35b6000919050565b600061008461007f84610188565b610163565b9050808285602086028201111561009a57600080fd5b60005b858110156100ca57816100b088826100fb565b84526020840193506020830192505060018101905061009d565b5050509392505050565b600082601f8301126100e557600080fd5b60056100f2848285610071565b91505092915050565b60008135905061010a81610229565b92915050565b600060a0828403121561012257600080fd5b6000610130848285016100d4565b91505092915050565b610142816101ae565b82525050565b600060208201905061015d6000830184610139565b92915050565b600061016d61017e565b905061017982826101b8565b919050565b6000604051905090565b600067ffffffffffffffff8211156101a3576101a26101e9565b5b602082029050919050565b6000819050919050565b6101c182610218565b810181811067ffffffffffffffff821117156101e0576101df6101e9565b5b80604052505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6000601f19601f8301169050919050565b610232816101ae565b811461023d57600080fd5b5056fea26469706673582212208ba9be6167b72a1e2216af5a98d880b8d392dc69a515c5bde07fb821d4391af064736f6c63430008040033'
type PoseidonT6ConstructorParams = [signer?: Signer] | ConstructorParameters<typeof ContractFactory>
const isSuperArgs = (
xs: PoseidonT6ConstructorParams,
): xs is ConstructorParameters<typeof ContractFactory> => xs.length > 1
export class PoseidonT6__factory extends ContractFactory {
constructor(...args: PoseidonT6ConstructorParams) {
if (isSuperArgs(args)) {
super(...args)
} else {
super(_abi, _bytecode, args[0])
}
}
override deploy(overrides?: Overrides & { from?: PromiseOrValue<string> }): Promise<PoseidonT6> {
return super.deploy(overrides || {}) as Promise<PoseidonT6>
}
override getDeployTransaction(
overrides?: Overrides & { from?: PromiseOrValue<string> },
): TransactionRequest {
return super.getDeployTransaction(overrides || {})
}
override attach(address: string): PoseidonT6 {
return super.attach(address) as PoseidonT6
}
override connect(signer: Signer): PoseidonT6__factory {
return super.connect(signer) as PoseidonT6__factory
}
static readonly bytecode = _bytecode
static readonly abi = _abi
static createInterface(): PoseidonT6Interface {
return new utils.Interface(_abi) as PoseidonT6Interface
}
static connect(address: string, signerOrProvider: Signer | Provider): PoseidonT6 {
return new Contract(address, _abi, signerOrProvider) as PoseidonT6
}
}

View File

@ -0,0 +1,5 @@
/* Autogenerated file. Do not edit manually. */
/* tslint:disable */
/* eslint-disable */
export { PoseidonT3__factory } from './PoseidonT3__factory'
export { PoseidonT6__factory } from './PoseidonT6__factory'

View File

@ -0,0 +1,4 @@
/* Autogenerated file. Do not edit manually. */
/* tslint:disable */
/* eslint-disable */
export * as hashesSol from './Hashes.sol'

View File

@ -0,0 +1,4 @@
/* Autogenerated file. Do not edit manually. */
/* tslint:disable */
/* eslint-disable */
export * as incrementalMerkleTreeSol from './incremental-merkle-tree.sol'

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,4 @@
/* Autogenerated file. Do not edit manually. */
/* tslint:disable */
/* eslint-disable */
export { GlobalAnonymousFeed__factory } from './GlobalAnonymousFeed__factory'

View File

@ -0,0 +1,6 @@
/* Autogenerated file. Do not edit manually. */
/* tslint:disable */
/* eslint-disable */
export * as semaphoreProtocol from './@semaphore-protocol'
export * as zkKit from './@zk-kit'
export * as contracts from './contracts'

View File

@ -0,0 +1,123 @@
/* Autogenerated file. Do not edit manually. */
/* tslint:disable */
/* eslint-disable */
import { ethers } from 'ethers'
import {
FactoryOptions,
HardhatEthersHelpers as HardhatEthersHelpersBase,
} from '@nomiclabs/hardhat-ethers/types'
import * as Contracts from '.'
declare module 'hardhat/types/runtime' {
interface HardhatEthersHelpers extends HardhatEthersHelpersBase {
getContractFactory(
name: 'Pairing',
signerOrOptions?: ethers.Signer | FactoryOptions,
): Promise<Contracts.Pairing__factory>
getContractFactory(
name: 'SemaphoreGroups',
signerOrOptions?: ethers.Signer | FactoryOptions,
): Promise<Contracts.SemaphoreGroups__factory>
getContractFactory(
name: 'SemaphoreVerifier',
signerOrOptions?: ethers.Signer | FactoryOptions,
): Promise<Contracts.SemaphoreVerifier__factory>
getContractFactory(
name: 'ISemaphore',
signerOrOptions?: ethers.Signer | FactoryOptions,
): Promise<Contracts.ISemaphore__factory>
getContractFactory(
name: 'ISemaphoreGroups',
signerOrOptions?: ethers.Signer | FactoryOptions,
): Promise<Contracts.ISemaphoreGroups__factory>
getContractFactory(
name: 'ISemaphoreVerifier',
signerOrOptions?: ethers.Signer | FactoryOptions,
): Promise<Contracts.ISemaphoreVerifier__factory>
getContractFactory(
name: 'Semaphore',
signerOrOptions?: ethers.Signer | FactoryOptions,
): Promise<Contracts.Semaphore__factory>
getContractFactory(
name: 'PoseidonT3',
signerOrOptions?: ethers.Signer | FactoryOptions,
): Promise<Contracts.PoseidonT3__factory>
getContractFactory(
name: 'PoseidonT6',
signerOrOptions?: ethers.Signer | FactoryOptions,
): Promise<Contracts.PoseidonT6__factory>
getContractFactory(
name: 'GlobalAnonymousFeed',
signerOrOptions?: ethers.Signer | FactoryOptions,
): Promise<Contracts.GlobalAnonymousFeed__factory>
getContractAt(
name: 'Pairing',
address: string,
signer?: ethers.Signer,
): Promise<Contracts.Pairing>
getContractAt(
name: 'SemaphoreGroups',
address: string,
signer?: ethers.Signer,
): Promise<Contracts.SemaphoreGroups>
getContractAt(
name: 'SemaphoreVerifier',
address: string,
signer?: ethers.Signer,
): Promise<Contracts.SemaphoreVerifier>
getContractAt(
name: 'ISemaphore',
address: string,
signer?: ethers.Signer,
): Promise<Contracts.ISemaphore>
getContractAt(
name: 'ISemaphoreGroups',
address: string,
signer?: ethers.Signer,
): Promise<Contracts.ISemaphoreGroups>
getContractAt(
name: 'ISemaphoreVerifier',
address: string,
signer?: ethers.Signer,
): Promise<Contracts.ISemaphoreVerifier>
getContractAt(
name: 'Semaphore',
address: string,
signer?: ethers.Signer,
): Promise<Contracts.Semaphore>
getContractAt(
name: 'PoseidonT3',
address: string,
signer?: ethers.Signer,
): Promise<Contracts.PoseidonT3>
getContractAt(
name: 'PoseidonT6',
address: string,
signer?: ethers.Signer,
): Promise<Contracts.PoseidonT6>
getContractAt(
name: 'GlobalAnonymousFeed',
address: string,
signer?: ethers.Signer,
): Promise<Contracts.GlobalAnonymousFeed>
// default types
getContractFactory(
name: string,
signerOrOptions?: ethers.Signer | FactoryOptions,
): Promise<ethers.ContractFactory>
getContractFactory(
abi: any[],
bytecode: ethers.utils.BytesLike,
signer?: ethers.Signer,
): Promise<ethers.ContractFactory>
getContractAt(
nameOrAbi: string | any[],
address: string,
signer?: ethers.Signer,
): Promise<ethers.Contract>
}
}

View File

@ -0,0 +1,30 @@
/* Autogenerated file. Do not edit manually. */
/* tslint:disable */
/* eslint-disable */
import type * as semaphoreProtocol from './@semaphore-protocol'
export type { semaphoreProtocol }
import type * as zkKit from './@zk-kit'
export type { zkKit }
import type * as contracts from './contracts'
export type { contracts }
export * as factories from './factories'
export type { Pairing } from './@semaphore-protocol/contracts/base/Pairing'
export { Pairing__factory } from './factories/@semaphore-protocol/contracts/base/Pairing__factory'
export type { SemaphoreGroups } from './@semaphore-protocol/contracts/base/SemaphoreGroups'
export { SemaphoreGroups__factory } from './factories/@semaphore-protocol/contracts/base/SemaphoreGroups__factory'
export type { SemaphoreVerifier } from './@semaphore-protocol/contracts/base/SemaphoreVerifier'
export { SemaphoreVerifier__factory } from './factories/@semaphore-protocol/contracts/base/SemaphoreVerifier__factory'
export type { ISemaphore } from './@semaphore-protocol/contracts/interfaces/ISemaphore'
export { ISemaphore__factory } from './factories/@semaphore-protocol/contracts/interfaces/ISemaphore__factory'
export type { ISemaphoreGroups } from './@semaphore-protocol/contracts/interfaces/ISemaphoreGroups'
export { ISemaphoreGroups__factory } from './factories/@semaphore-protocol/contracts/interfaces/ISemaphoreGroups__factory'
export type { ISemaphoreVerifier } from './@semaphore-protocol/contracts/interfaces/ISemaphoreVerifier'
export { ISemaphoreVerifier__factory } from './factories/@semaphore-protocol/contracts/interfaces/ISemaphoreVerifier__factory'
export type { Semaphore } from './@semaphore-protocol/contracts/Semaphore'
export { Semaphore__factory } from './factories/@semaphore-protocol/contracts/Semaphore__factory'
export type { PoseidonT3 } from './@zk-kit/incremental-merkle-tree.sol/Hashes.sol/PoseidonT3'
export { PoseidonT3__factory } from './factories/@zk-kit/incremental-merkle-tree.sol/Hashes.sol/PoseidonT3__factory'
export type { PoseidonT6 } from './@zk-kit/incremental-merkle-tree.sol/Hashes.sol/PoseidonT6'
export { PoseidonT6__factory } from './factories/@zk-kit/incremental-merkle-tree.sol/Hashes.sol/PoseidonT6__factory'
export type { GlobalAnonymousFeed } from './contracts/GlobalAnonymousFeed'
export { GlobalAnonymousFeed__factory } from './factories/contracts/GlobalAnonymousFeed__factory'

View File

@ -0,0 +1,9 @@
import {
PUBLIC_PROVIDER,
PUBLIC_GROUP_ID,
PUBLIC_GLOBAL_ANONYMOUS_FEED_ADDRESS,
} from '$env/static/public'
export const GLOBAL_ANONYMOUS_FEED_ADDRESS = PUBLIC_GLOBAL_ANONYMOUS_FEED_ADDRESS
export const GROUP_ID = PUBLIC_GROUP_ID
export const PROVIDER = PUBLIC_PROVIDER

View File

@ -1,10 +1,25 @@
import { providers } from 'ethers'
import { ethers, providers, Signer, type BigNumberish, type ContractTransaction } from 'ethers'
import { Identity } from '@semaphore-protocol/identity'
import { Group, type Member } from '@semaphore-protocol/group'
import {
generateProof,
packToSolidityProof,
verifyProof,
type FullProof,
} from '@semaphore-protocol/proof'
import zkeyFilePath from '$lib/assets/semaphore.zkey?url'
import wasmFilePath from '$lib/assets/semaphore.wasm?url'
import { GlobalAnonymousFeed__factory, type GlobalAnonymousFeed } from '$lib/assets/typechain'
import { GLOBAL_ANONYMOUS_FEED_ADDRESS, GROUP_ID } from '$lib/constants'
import { solidityKeccak256, type BytesLike, type Hexable } from 'ethers/lib/utils'
import type { PromiseOrValue } from '$lib/assets/typechain/common'
type WindowWithEthereum = Window &
typeof globalThis & { ethereum: providers.ExternalProvider | providers.JsonRpcFetchFunc }
export async function connectWallet(network?: providers.Networkish) {
export async function connectWallet(network?: providers.Networkish): Promise<Signer> {
const provider = new providers.Web3Provider((window as WindowWithEthereum).ethereum, network)
await provider.send('eth_requestAccounts', [])
return provider.getSigner()
@ -14,7 +29,74 @@ export function canConnectWallet() {
return Boolean((window as WindowWithEthereum)?.ethereum)
}
export async function createIdentity(signer: providers.JsonRpcSigner, secret: string) {
export async function createIdentity(signer: Signer, secret: string) {
const identitySeed = await signer.signMessage(secret)
return new Identity(identitySeed)
}
export function getGlobalAnonymousFeed(signer?: Signer): GlobalAnonymousFeed {
return new GlobalAnonymousFeed__factory(signer).attach(GLOBAL_ANONYMOUS_FEED_ADDRESS)
}
export async function getContractGroup(
globalAnonymousFeedContract: GlobalAnonymousFeed,
): Promise<Group> {
const group = new Group(GROUP_ID)
const events = await globalAnonymousFeedContract.queryFilter(
globalAnonymousFeedContract.filters.NewIdentity(null),
)
group.addMembers(events.map((e) => e.args.identityCommitment.toBigInt()))
return group
}
export function joinGroupOffChain(group: Group, member: Member): void {
group.addMember(member)
}
export async function joinGroupOnChain(
globalAnonymousFeed: GlobalAnonymousFeed,
identityCommitment: Member,
): Promise<ContractTransaction> {
return globalAnonymousFeed.joinGroup(identityCommitment)
}
export function getRandomExternalNullifier() {
return ethers.utils.keccak256(ethers.utils.toUtf8Bytes(crypto.randomUUID()))
}
export async function generateGroupProof(
group: Group,
identity: Identity,
message: string,
externalNullifier: BytesLike | Hexable | number | bigint,
): Promise<FullProof> {
const messageHash = solidityKeccak256(['string'], [message])
return generateProof(identity, group, externalNullifier, messageHash, {
zkeyFilePath,
wasmFilePath,
})
}
export async function validateProofOffChain(proof: FullProof, treeDepth = 20): Promise<boolean> {
return verifyProof(proof, treeDepth)
}
export function validateProofOnChain(
globalAnonymousFeed: GlobalAnonymousFeed,
fullProof: FullProof,
message: string,
externalNullifier: PromiseOrValue<BigNumberish>,
): Promise<ContractTransaction> {
const solidityProof = packToSolidityProof(fullProof.proof)
return globalAnonymousFeed.sendMessage(
message,
fullProof.publicSignals.merkleTreeRoot,
fullProof.publicSignals.nullifierHash,
externalNullifier,
solidityProof,
)
}

View File

@ -1,27 +1,71 @@
import { writable, type Writable } from 'svelte/store'
import type { User } from './user'
import { browser } from '$app/environment'
import { getGlobalAnonymousFeed } from '$lib/services'
import { providers } from 'ethers'
import { PROVIDER } from '$lib/constants'
export interface Post {
timestamp: number
text: string
user: User
tx: string
}
export interface PostStore extends Writable<Post[]> {
interface PostData {
posts: Post[]
loading: boolean
}
export interface PostStore extends Writable<PostData> {
add: (post: Post) => void
reset: () => void
}
async function pullFeed() {
try {
const provider = new providers.JsonRpcProvider(PROVIDER)
if (provider) {
const contract = getGlobalAnonymousFeed().connect(provider)
const events = await contract.queryFilter(contract.filters.NewMessage())
const messages: Post[] = events.map((e) => ({
text: e.args.message,
tx: e.transactionHash,
timestamp: e.blockNumber,
}))
posts.set({ posts: messages.reverse(), loading: false })
if (browser) {
localStorage.setItem('messages', JSON.stringify(messages))
}
}
} catch (e) {
console.error(e)
}
}
function createPostStore(): PostStore {
const store = writable<Post[]>([])
let posts: Post[] = []
const loading = false
if (browser) {
const messages = localStorage.getItem('messages')
if (messages) {
posts = JSON.parse(messages)
}
}
const store = writable<PostData>({ posts, loading })
pullFeed()
return {
...store,
add: (post: Post) => {
store.update((posts) => [post, ...posts])
},
reset: () => {
store.set([])
store.update(({ posts, loading }) => {
const newPosts = [post, ...posts]
if (browser) {
localStorage.setItem('messages', JSON.stringify(newPosts))
}
return { loading, posts: newPosts }
})
},
}
}

View File

@ -1,9 +1,9 @@
import { writable, type Writable } from 'svelte/store'
import type { providers } from 'ethers'
import type { Signer } from 'ethers'
import type { Identity } from '@semaphore-protocol/identity'
export interface Profile {
signer?: providers.JsonRpcSigner
signer?: Signer
identities: Record<string, Identity>
}

View File

@ -1,132 +0,0 @@
<script lang="ts">
import type { Post } from '$lib/stores/post'
import { users, type User } from '$lib/stores/user'
import { posts } from '$lib/stores/post'
import Button from '$lib/components/button.svelte'
const testPosts: Post[] = [
{
timestamp: new Date().setHours(new Date().getHours() - 6),
text: 'Decision making by awkward silence.',
user: {
name: 'CoyoteRide',
address: '0x2d37a46fad14c4fcaba66660da6a5d99af88bf71',
},
},
{
timestamp: new Date().setHours(new Date().getHours() - 6),
text: "It's an amazing trigger within human nature: the minute someone acknowledges their flaws, not only do we tend to forgive them, but we actually come to admire them.",
user: {
name: 'Lemur',
address: '0x032b3c7a6af9bbf38838f582acc8e4074932f2b8',
},
},
{
timestamp: new Date().setDate(new Date().getDate() - 1),
text: 'What were the skies like when you were young?',
user: {
address: '0x547172511e83121ea8b27f25dc00e7294d9b8b6d',
},
},
{
timestamp: new Date().setDate(new Date().getDate() - 3),
text: 'Unicorn etsy jean shorts gatekeep. Same air plant hashtag tousled poutine pinterest, activated charcoal celiac austin chartreuse.',
user: {
address: '0x33FEd84c219139A464Cc2aF5643584ab51176DaB',
},
},
{
timestamp: new Date().setDate(new Date().getDate() - 3),
text: "Y'all should go check this amazing online magazine https://two.compost.digital/",
user: {
name: 'Cryptocowboy',
address: '0x0554369c1f47B130104fC8A6aa5a94fF3b06b0e1',
},
},
{
timestamp: new Date().setDate(new Date().getDate() - 3),
text: "I'm baby tacos literally vaporware banh mi fam listicle jean shorts coloring book enamel pin occupy",
user: {
address: '0x33FEd84c219139A464Cc2aF5643584ab51176DaB',
},
},
{
timestamp: new Date().setDate(new Date().getDate() - 4),
text: 'Decision making by awkward silence.',
user: {
name: 'CoyoteRide',
address: '0x2d37a46fad14c4fcaba66660da6a5d99af88bf71',
},
},
{
timestamp: new Date().setDate(new Date().getDate() - 4),
text: "It's an amazing trigger within human nature: the minute someone acknowledges their flaws, not only do we tend to forgive them, but we actually come to admire them.",
user: {
name: 'Lemur',
address: '0x032b3c7a6af9bbf38838f582acc8e4074932f2b8',
},
},
{
timestamp: new Date().setDate(new Date().getDate() - 5),
text: 'What were the skies like when you were young?',
user: {
address: '0x547172511e83121ea8b27f25dc00e7294d9b8b6d',
},
},
{
timestamp: new Date().setDate(new Date().getDate() - 5),
text: 'Unicorn etsy jean shorts gatekeep. Same air plant hashtag tousled poutine pinterest, activated charcoal celiac austin chartreuse.',
user: {
address: '0x33FEd84c219139A464Cc2aF5643584ab51176DaB',
},
},
{
timestamp: new Date().setDate(new Date().getDate() - 6),
text: "Y'all should go check this amazing online magazine https://two.compost.digital/",
user: {
name: 'Cryptocowboy',
address: '0x0554369c1f47B130104fC8A6aa5a94fF3b06b0e1',
},
},
{
timestamp: new Date().setDate(new Date().getDate() - 6),
text: "I'm baby tacos literally vaporware banh mi fam listicle jean shorts coloring book enamel pin occupy",
user: {
address: '0x33FEd84c219139A464Cc2aF5643584ab51176DaB',
},
},
{
timestamp: new Date().setDate(new Date().getDate() - 7),
text: 'Decision making by awkward silence.',
user: {
name: 'CoyoteRide',
address: '0x2d37a46fad14c4fcaba66660da6a5d99af88bf71',
},
},
]
function populateWithData() {
posts.set(testPosts)
const uniqueUsers: Map<string, User> = new Map()
testPosts.forEach((p) => uniqueUsers.set(p.user.address, p.user))
users.set(Array.from(uniqueUsers.values()))
}
</script>
<div class="root">
<span>There are no posts yet</span>
<Button on:click={populateWithData} label="populate with testdata" />
</div>
<style>
.root {
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
border-top: 1px solid var(--color-grey-background);
padding: var(--spacing-12);
}
span {
margin-bottom: var(--spacing-12);
}
</style>

View File

@ -1,3 +1,5 @@
import { browser } from '$app/environment'
export function formatAddress(address: string, digits = 4) {
return `${address.substring(0, digits + 2)}${address.substring(address.length - digits - 1)}`
}
@ -22,6 +24,9 @@ export function formatDateFromNow(timestamp: number) {
}
export function formatDateAndTime(timestamp: number) {
if (!browser) {
return ''
}
const locale = navigator.language
const date = new Date(timestamp)

View File

@ -1,7 +1,6 @@
<script lang="ts">
import Header from '$lib/components/header.svelte'
import Post from '$lib/components/post.svelte'
import Populate from '$lib/temp/index.svelte'
import Button from '$lib/components/button.svelte'
import WalletConnect from '$lib/components/wallet-connect.svelte'
import Edit from '$lib/components/icons/edit.svelte'
@ -27,10 +26,10 @@
<WalletConnect />
{/if}
{#each $posts as post}
{#each $posts.posts as post}
<Post {post} />
{:else}
<Populate />
<p>There are no posts yet</p>
{/each}
</div>

View File

@ -4,9 +4,16 @@
import SendAltFilled from '$lib/components/icons/send-alt-filled.svelte'
import InputString from '$lib/components/input-string.svelte'
import { profile } from '$lib/stores/profile'
import { posts } from '$lib/stores/post'
import { goto } from '$app/navigation'
import { ROUTES } from '$lib/routes'
import {
generateGroupProof,
getContractGroup,
getGlobalAnonymousFeed,
getRandomExternalNullifier,
validateProofOnChain,
} from '$lib/services/index'
import { posts } from '$lib/stores/post'
let cls: string | undefined = undefined
export { cls as class }
@ -14,16 +21,31 @@
let postText = ''
async function submit() {
if (!$profile.signer) return
try {
const signer = $profile.signer
if (!signer) throw new Error('no signer')
const address = await $profile.signer.getAddress()
const identity = $profile.identities.anonymous
if (!identity) throw new Error('no identity')
posts.add({
timestamp: Date.now(),
text: postText,
user: { address },
})
goto(ROUTES.HOME)
const globalAnonymousFeed = getGlobalAnonymousFeed(signer)
const group = await getContractGroup(globalAnonymousFeed)
const externalNullifier = getRandomExternalNullifier()
const proof = await generateGroupProof(group, identity, postText, externalNullifier)
const tx = await validateProofOnChain(globalAnonymousFeed, proof, postText, externalNullifier)
const res = await tx.wait()
posts.add({
timestamp: Date.now(),
text: postText,
tx: res.transactionHash,
})
goto(ROUTES.HOME)
} catch (error) {
console.error(error)
}
}
</script>

View File

@ -6,7 +6,15 @@
import Wallet from '$lib/components/icons/wallet.svelte'
import WalletInfo from '$lib/components/wallet-info.svelte'
import { formatAddress } from '$lib/utils'
import { connectWallet, canConnectWallet, createIdentity } from '$lib/services'
import {
connectWallet,
canConnectWallet,
createIdentity,
getGlobalAnonymousFeed,
getContractGroup,
joinGroupOffChain,
joinGroupOnChain,
} from '$lib/services'
import { profile } from '$lib/stores/profile'
let error: Error | undefined = undefined
@ -14,19 +22,29 @@
const handleConnect = async () => {
try {
$profile.signer = await connectWallet()
const signer = await connectWallet()
$profile.signer = signer
const defaultIdentity = 'anonymous'
const identity = await createIdentity($profile.signer, defaultIdentity)
const identity = await createIdentity(signer, defaultIdentity)
$profile.identities = { ...$profile.identities, [defaultIdentity]: identity }
const globalAnonymousFeed = getGlobalAnonymousFeed(signer)
const group = await getContractGroup(globalAnonymousFeed)
const commitment = identity.commitment
if (!group.members.includes(commitment)) {
joinGroupOffChain(group, commitment)
const txres = await joinGroupOnChain(globalAnonymousFeed, commitment)
console.log(txres)
}
} catch (err) {
error = err as Error
}
}
$: console.log($profile.identities)
</script>
<div class="header">
@ -60,7 +78,6 @@
{/if}
</div>
{:else}
<!-- WHY IS THIS AN INPUT? DOES IT HAVE TO BE? -->
<div class="wallet-info-wrapper">
<WalletInfo title="Connected wallet">
{#await $profile.signer.getAddress()}

View File

@ -0,0 +1,20 @@
version: '2.4'
services:
waku:
image: statusteam/nim-waku:v0.12.0
command: |
--nat:pmp
--relay:true
--persist-messages:true
--store:true
--store-capacity:150000
--sqlite-store:true
--sqlite-retention-time:31536000
--filter:true
--lightpush:true
--websocket-support:true
--db-path:/db
--rpc-address:0.0.0.0
--nodekey:7b8d9a670aae6421500b7b3f933d0b5d08b51fcf0f0c2f14cba3a4737c83a228
ports:
- 8000:8000/tcp

View File

@ -1,4 +1,4 @@
import { ROUTES } from '$lib/routes'
import { ROUTES } from '../src/lib/routes.js'
import { expect, test } from '@playwright/test'
test('index page has expected header', async ({ page }) => {

7
packages/ui/vercel.json Normal file
View File

@ -0,0 +1,7 @@
{
"build": {
"env": {
"ENABLE_VC_BUILD": "1"
}
}
}

View File

@ -1,38 +1,25 @@
import { sveltekit } from '@sveltejs/kit/vite'
import type { UserConfig } from 'vite'
import { NodeGlobalsPolyfillPlugin } from '@esbuild-plugins/node-globals-polyfill'
import { NodeModulesPolyfillPlugin } from '@esbuild-plugins/node-modules-polyfill'
import rollupNodePolyFill from 'rollup-plugin-node-polyfills'
import type { InputPluginOption } from 'rollup'
import inject from '@rollup/plugin-inject'
import stdLibBrowser from 'node-stdlib-browser'
const config: UserConfig = {
plugins: [sveltekit()],
// For more info see https://medium.com/@ftaioli/using-node-js-builtin-modules-with-vite-6194737c2cd2
optimizeDeps: {
esbuildOptions: {
// Node.js global to browser globalThis
define: {
global: 'globalThis',
},
// Enable esbuild polyfill plugins
plugins: [
NodeGlobalsPolyfillPlugin({
process: true,
buffer: true,
}),
NodeModulesPolyfillPlugin(),
],
plugins: [
sveltekit(),
{
...inject({
global: ['node-stdlib-browser/helpers/esbuild/shim', 'global'],
process: ['node-stdlib-browser/helpers/esbuild/shim', 'process'],
Buffer: ['node-stdlib-browser/helpers/esbuild/shim', 'Buffer'],
}),
enforce: 'post',
},
],
resolve: {
alias: stdLibBrowser,
},
build: {
rollupOptions: {
plugins: [
// Enable rollup polyfills plugin
// used during production bundling
rollupNodePolyFill() as InputPluginOption,
],
},
optimizeDeps: {
include: ['buffer', 'process'],
},
}