-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(contracts): add registry manager deploy task
- [x] Add RegistryManager to MACI - [x] Add deploy task for RegistryManager - [x] Update deploy config
- Loading branch information
Showing
9 changed files
with
238 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,11 +9,16 @@ import { ITallyFactory } from "maci-contracts/contracts/interfaces/ITallyFactory | |
import { InitialVoiceCreditProxy } from "maci-contracts/contracts/initialVoiceCreditProxy/InitialVoiceCreditProxy.sol"; | ||
import { SignUpGatekeeper } from "maci-contracts/contracts/gatekeepers/SignUpGatekeeper.sol"; | ||
|
||
import { ICommon } from "../interfaces/ICommon.sol"; | ||
import { IPoll } from "../interfaces/IPoll.sol"; | ||
import { IRegistryManager } from "../interfaces/IRegistryManager.sol"; | ||
|
||
/// @title MACI - Minimum Anti-Collusion Infrastructure | ||
/// @notice A contract which allows users to sign up, and deploy new polls | ||
contract MACI is Ownable, BaseMACI { | ||
contract MACI is Ownable, BaseMACI, ICommon { | ||
/// @notice Registry manager | ||
IRegistryManager public registryManager; | ||
|
||
/// @notice Create a new instance of the MACI contract. | ||
/// @param pollFactory The PollFactory contract | ||
/// @param messageProcessorFactory The MessageProcessorFactory contract | ||
|
@@ -53,4 +58,13 @@ contract MACI is Ownable, BaseMACI { | |
poll.init(); | ||
poll.transferOwnership(msg.sender); | ||
} | ||
|
||
/// @notice Set RegistryManager for MACI | ||
function setRegistryManager(address registryManagerAddress) public onlyOwner { | ||
if (registryManagerAddress == address(0)) { | ||
revert InvalidAddress(); | ||
} | ||
|
||
registryManager = IRegistryManager(registryManagerAddress); | ||
} | ||
} | ||
Check warning Code scanning / Slither Contracts that lock Ether Medium
Contract locking ether found:
Contract MACI has payable functions: - MACI.constructor(IPollFactory,IMessageProcessorFactory,ITallyFactory,SignUpGatekeeper,InitialVoiceCreditProxy,uint8,uint256[5]) But does not have a function to withdraw the ether |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
60 changes: 60 additions & 0 deletions
60
packages/contracts/tasks/deploy/maci/10-registryManager.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
import { ContractStorage, Deployment, type IDeployParams } from "maci-contracts"; | ||
|
||
import type { MACI } from "../../../typechain-types"; | ||
|
||
import { EDeploySteps, EContracts } from "../../helpers/constants"; | ||
|
||
const deployment = Deployment.getInstance(); | ||
const storage = ContractStorage.getInstance(); | ||
|
||
/** | ||
* Deploy step registration and task itself | ||
*/ | ||
deployment.deployTask(EDeploySteps.RegistryManager, "Deploy registry manager").then((task) => | ||
task.setAction(async ({ incremental }: IDeployParams, hre) => { | ||
deployment.setHre(hre); | ||
const deployer = await deployment.getDeployer(); | ||
|
||
const registryManagerType = | ||
deployment.getDeployConfigField<keyof typeof EContracts | null>(EContracts.MACI, "registryManager") || | ||
EContracts.RegistryManager; | ||
|
||
const registryManagerContractAddress = storage.getAddress(registryManagerType, hre.network.name); | ||
|
||
if (incremental && registryManagerContractAddress) { | ||
return; | ||
} | ||
|
||
const easAddress = deployment.getDeployConfigField<keyof typeof EContracts | null, keyof typeof EContracts>( | ||
registryManagerType, | ||
"easAddress", | ||
); | ||
|
||
const args = easAddress ? [easAddress] : []; | ||
|
||
const registryManagerContract = await deployment.deployContract( | ||
{ | ||
name: registryManagerType, | ||
signer: deployer, | ||
}, | ||
...args, | ||
); | ||
|
||
const maciContractAddress = storage.mustGetAddress(EContracts.MACI, hre.network.name); | ||
|
||
const maciContract = await deployment.getContract<MACI>({ | ||
name: "contracts/maci/MACI.sol:MACI" as Parameters<typeof deployment.getContract>[0]["name"], | ||
address: maciContractAddress, | ||
}); | ||
|
||
const contractAddress = await registryManagerContract.getAddress(); | ||
await maciContract.setRegistryManager(contractAddress).then((tx) => tx.wait()); | ||
|
||
await storage.register({ | ||
id: registryManagerType, | ||
contract: registryManagerContract, | ||
args, | ||
network: hre.network.name, | ||
}); | ||
}), | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.