Skip to content

Commit

Permalink
add deployment of semaphore user registry
Browse files Browse the repository at this point in the history
  • Loading branch information
yuetloo committed Mar 6, 2024
1 parent 37881f4 commit 4afcec3
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ import '@openzeppelin/contracts/access/Ownable.sol';
import './IUserRegistry.sol';

/**
* @dev A simple user registry managed by a trusted entity.
* @dev A simple semaphore user registry managed by a trusted entity.
*/
contract ZupassUserRegistry is Ownable, IUserRegistry {
contract SemaphoreUserRegistry is Ownable, IUserRegistry {

mapping(address => bool) private users;
mapping(uint256 => bool) private semaphoreIds;
mapping(address => uint256) private userTosemaphoreId;
mapping(address => uint256) private userToSemaphoreId;

// Events
event UserAdded(address indexed _user, uint256 _semaphoreId);
Expand All @@ -32,7 +32,7 @@ contract ZupassUserRegistry is Ownable, IUserRegistry {
require(!semaphoreIds[_semaphoreId], 'UserRegistry: Semaphore Id already registered' );
users[_user] = true;
semaphoreIds[_semaphoreId] = true;
userTosemaphoreId[_user] = _semaphoreId;
userToSemaphoreId[_user] = _semaphoreId;
emit UserAdded(_user, _semaphoreId);
}

Expand All @@ -44,10 +44,10 @@ contract ZupassUserRegistry is Ownable, IUserRegistry {
onlyOwner
{
require(users[_user], 'UserRegistry: User is not in the registry');
uint256 _semaphoreId = userTosemaphoreId[_user];
uint256 _semaphoreId = userToSemaphoreId[_user];
delete users[_user];
delete semaphoreIds[_semaphoreId];
delete userTosemaphoreId[_user];
delete userToSemaphoreId[_user];
emit UserRemoved(_user);
}

Expand Down
2 changes: 1 addition & 1 deletion contracts/tasks/deploy/newClrFund.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ task('new-clrfund', 'Deploy a new ClrFund instance')
.addOptionalParam('userRegistryAddress', 'The user registry address')
.addOptionalParam(
'userRegistryType',
'The user registry type: simple, brightid, merkle, storage',
'The user registry type: simple, semaphore, brightid, merkle, storage',
'simple'
)
.addOptionalParam('brightidContext', 'The brightid context')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,19 @@ import { Contract, Wallet } from 'ethers'
import { ZERO_ADDRESS } from '../utils/constants'
import { HardhatEthersSigner } from '@nomicfoundation/hardhat-ethers/signers'

describe('Zupass User Registry', () => {
describe('Semaphore User Registry', () => {
let registry: Contract
let user: HardhatEthersSigner

beforeEach(async () => {
let deployer: HardhatEthersSigner
;[, deployer, user] = await ethers.getSigners()

const ZupassUserRegistry = await ethers.getContractFactory(
'ZupassUserRegistry',
const SemaphoreUserRegistry = await ethers.getContractFactory(
'SemaphoreUserRegistry',
deployer
)
registry = await ZupassUserRegistry.deploy()
registry = await SemaphoreUserRegistry.deploy()
})

describe('managing verified users', () => {
Expand Down
1 change: 1 addition & 0 deletions contracts/utils/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export enum EContracts {
OptimisticRecipientRegistry = 'OptimisticRecipientRegistry',
KlerosGTCRAdapter = 'KlerosGTCRAdapter',
SimpleUserRegistry = 'SimpleUserRegistry',
SemaphoreUserRegistry = 'SemaphoreUserRegistry',
BrightIdUserRegistry = 'BrightIdUserRegistry',
AnyOldERC20Token = 'AnyOldERC20Token',
BrightIdSponsor = 'BrightIdSponsor',
Expand Down
6 changes: 3 additions & 3 deletions subgraph/config/optimism-sepolia.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"network": "optimism-sepolia",
"address": "0x87790498127fF044f43b9230506833Ca89113757",
"clrFundStartBlock": 8344520,
"recipientRegistryStartBlock": 8344520
"address": "0x9deB2f0A56FeCEe7ECE9B742Ab4f5Bc21A634F83",
"clrFundStartBlock": 8973710,
"recipientRegistryStartBlock": 8973710
}

0 comments on commit 4afcec3

Please sign in to comment.