Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: add simple registry and move some arguments to registry config #350

Merged
merged 1 commit into from
Sep 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions packages/contracts/contracts/registry/SimpleRegistry.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;

import { BaseRegistry } from "./BaseRegistry.sol";

contract SimpleRegistry is BaseRegistry {
/// @notice Create a new instance of the registry contract
/// @param max The maximum number of projects that can be registered
/// @param url The metadata url
/// @param ownerAddress The owner address
constructor(
uint256 max,
string memory url,
address ownerAddress
) payable BaseRegistry(max, url, ownerAddress) {}
}
Dismissed Show dismissed Hide dismissed
103 changes: 83 additions & 20 deletions packages/contracts/deploy-config-example.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,23 @@
"groupId": 0
},
"MACI": {
"stateTreeDepth": 10,
"gatekeeper": "EASGatekeeper",
"registryManager": "EASRegistryManager"
"stateTreeDepth": 14,
"gatekeeper": "FreeForAllGatekeeper",
"registryManager": "RegistryManager",
"registry": "SimpleRegistry"
},
"RegistryManager": {},
"EASRegistryManager": {
"easAddress": "0x4200000000000000000000000000000000000021"
},
"SimpleRegistry": {
"maxRecipients": 25,
"metadataUrl": "url"
},
"EASRegistry": {
"maxRecipients": 25,
"metadataUrl": "url",
"easAddress": "0xC2679fBD37d54388Ce493F1DB75320D236e1815e"
"easAddress": "0x4200000000000000000000000000000000000021"
},
"VkRegistry": {
"stateTreeDepth": 10,
Expand Down Expand Up @@ -98,14 +107,23 @@
"groupId": 0
},
"MACI": {
"stateTreeDepth": 10,
"gatekeeper": "ZupassGatekeeper",
"registryManager": "EASRegistryManager"
"stateTreeDepth": 14,
"gatekeeper": "FreeForAllGatekeeper",
"registryManager": "RegistryManager",
"registry": "SimpleRegistry"
},
"RegistryManager": {},
"EASRegistryManager": {
"easAddress": "0x4200000000000000000000000000000000000021"
},
"SimpleRegistry": {
"maxRecipients": 25,
"metadataUrl": "url"
},
"EASRegistry": {
"maxRecipients": 25,
"metadataUrl": "url",
"easAddress": "0xaEF4103A04090071165F78D45D83A0C0782c2B2a"
"easAddress": "0x4200000000000000000000000000000000000021"
},
"VkRegistry": {
"stateTreeDepth": 10,
Expand Down Expand Up @@ -166,11 +184,20 @@
"groupId": 0
},
"MACI": {
"stateTreeDepth": 6,
"gatekeeper": "EASGatekeeper",
"registryManager": "EASRegistryManager"
"stateTreeDepth": 14,
"gatekeeper": "FreeForAllGatekeeper",
"registryManager": "RegistryManager",
"registry": "SimpleRegistry"
},
"RegistryManager": {},
"EASRegistryManager": {
"easAddress": "0x4200000000000000000000000000000000000021"
},
"SimpleRegistry": {
"maxRecipients": 25,
"metadataUrl": "url"
},
"EASRegistry": {
"maxRecipients": 25,
"metadataUrl": "url",
"easAddress": "0x4200000000000000000000000000000000000021"
Expand Down Expand Up @@ -234,14 +261,23 @@
"groupId": 0
},
"MACI": {
"stateTreeDepth": 10,
"stateTreeDepth": 14,
"gatekeeper": "FreeForAllGatekeeper",
"registryManager": "EASRegistryManager"
"registryManager": "RegistryManager",
"registry": "SimpleRegistry"
},
"RegistryManager": {},
"EASRegistryManager": {
"easAddress": "0x4200000000000000000000000000000000000021"
},
"SimpleRegistry": {
"maxRecipients": 25,
"metadataUrl": "url"
},
"EASRegistry": {
"maxRecipients": 25,
"metadataUrl": "url",
"easAddress": "0xC2679fBD37d54388Ce493F1DB75320D236e1815e"
"easAddress": "0x4200000000000000000000000000000000000021"
},
"VkRegistry": {
"stateTreeDepth": 10,
Expand Down Expand Up @@ -302,14 +338,23 @@
"groupId": 0
},
"MACI": {
"stateTreeDepth": 10,
"stateTreeDepth": 14,
"gatekeeper": "FreeForAllGatekeeper",
"registryManager": "EASRegistryManager"
"registryManager": "RegistryManager",
"registry": "SimpleRegistry"
},
"RegistryManager": {},
"EASRegistryManager": {
"easAddress": "0x4200000000000000000000000000000000000021"
},
"SimpleRegistry": {
"maxRecipients": 25,
"metadataUrl": "url"
},
"EASRegistry": {
"maxRecipients": 25,
"metadataUrl": "url",
"easAddress": "0xC2679fBD37d54388Ce493F1DB75320D236e1815e"
"easAddress": "0x4200000000000000000000000000000000000021"
},
"VkRegistry": {
"stateTreeDepth": 10,
Expand Down Expand Up @@ -370,11 +415,20 @@
"groupId": 0
},
"MACI": {
"stateTreeDepth": 10,
"stateTreeDepth": 14,
"gatekeeper": "FreeForAllGatekeeper",
"registryManager": "EASRegistryManager"
"registryManager": "RegistryManager",
"registry": "SimpleRegistry"
},
"RegistryManager": {},
"EASRegistryManager": {
"easAddress": "0x4200000000000000000000000000000000000021"
},
"SimpleRegistry": {
"maxRecipients": 25,
"metadataUrl": "url"
},
"EASRegistry": {
"maxRecipients": 25,
"metadataUrl": "url",
"easAddress": "0x4200000000000000000000000000000000000021"
Expand Down Expand Up @@ -445,9 +499,18 @@
"MACI": {
"stateTreeDepth": 14,
"gatekeeper": "FreeForAllGatekeeper",
"registryManager": "EASRegistryManager"
"registryManager": "RegistryManager",
"registry": "SimpleRegistry"
},
"RegistryManager": {},
"EASRegistryManager": {
"easAddress": "0x4200000000000000000000000000000000000021"
},
"SimpleRegistry": {
"maxRecipients": 25,
"metadataUrl": "url"
},
"EASRegistry": {
"maxRecipients": 25,
"metadataUrl": "url",
"easAddress": "0x4200000000000000000000000000000000000021"
Expand Down
23 changes: 12 additions & 11 deletions packages/contracts/tasks/deploy/poll/01-poll.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { ContractStorage, Deployment, EMode } from "maci-contracts";
import { PubKey } from "maci-domainobjs";

import { type Poll, type MACI } from "../../../typechain-types";
import { EContracts, EDeploySteps, REGISTRY_TYPES, TRegistryManager } from "../../helpers/constants";
import { EContracts, EDeploySteps, REGISTRY_TYPES, TRegistryManager, TRegistry } from "../../helpers/constants";

const deployment = Deployment.getInstance();
const storage = ContractStorage.getInstance();
Expand Down Expand Up @@ -52,20 +52,21 @@ deployment.deployTask(EDeploySteps.Poll, "Deploy poll").then((task) =>
deployment.getDeployConfigField<TRegistryManager | null>(EContracts.MACI, "registryManager") ||
EContracts.EASRegistryManager;
const registryManagerAddress = storage.getAddress(registryManagerType, hre.network.name);

const registryType =
deployment.getDeployConfigField<TRegistry | null>(EContracts.MACI, "registry") || EContracts.EASRegistry;

const maxRecipients = deployment.getDeployConfigField<number, keyof typeof EContracts>(
EContracts.EASRegistryManager,
registryType,
"maxRecipients",
);
const metadataUrl = deployment.getDeployConfigField<string, keyof typeof EContracts>(
EContracts.EASRegistryManager,
"metadataUrl",
);
const easAddress = deployment.getDeployConfigField<string, keyof typeof EContracts>(
EContracts.EASRegistryManager,
"easAddress",
);
const metadataUrl = deployment.getDeployConfigField<string, keyof typeof EContracts>(registryType, "metadataUrl");
const easAddress = deployment.getDeployConfigField<string, keyof typeof EContracts>(registryType, "easAddress");

const registryArgs = [maxRecipients, metadataUrl, easAddress, registryManagerAddress];
const registryArgs =
registryType === EContracts.EASRegistry
? [maxRecipients, metadataUrl, easAddress, registryManagerAddress]
: [maxRecipients, metadataUrl, registryManagerAddress];
const pollRegistry = await deployment.deployContract(
{ name: REGISTRY_TYPES[registryManagerType] },
...registryArgs,
Expand Down
7 changes: 5 additions & 2 deletions packages/contracts/tasks/helpers/constants/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ export const EDeploySteps = {
*/
export enum EPlatformContracts {
EASRegistryManager = "EASRegistryManager",
RegistryManager = "RegistryManager",
EASRegistry = "EASRegistry",
SimpleRegistry = "SimpleRegistry",
}

/**
Expand All @@ -34,18 +36,19 @@ export const EContracts = {
/**
* Supported registry manager types
*/
export type TRegistryManager = EPlatformContracts.EASRegistryManager;
export type TRegistryManager = EPlatformContracts.EASRegistryManager | EPlatformContracts.RegistryManager;

/**
* Supported registry types
*/
export type TRegistry = EPlatformContracts.EASRegistry;
export type TRegistry = EPlatformContracts.EASRegistry | EPlatformContracts.SimpleRegistry;

/**
* Registry types by registry manager
*/
export const REGISTRY_TYPES: Record<TRegistryManager, TRegistry> = {
[EPlatformContracts.EASRegistryManager]: EPlatformContracts.EASRegistry,
[EPlatformContracts.RegistryManager]: EPlatformContracts.SimpleRegistry,
};

/**
Expand Down
Loading