Skip to content

Commit

Permalink
Deployment script for mainnet and sepolia
Browse files Browse the repository at this point in the history
  • Loading branch information
brickpop committed May 30, 2024
1 parent edec658 commit 86a35cd
Showing 1 changed file with 87 additions and 23 deletions.
110 changes: 87 additions & 23 deletions script/Deploy.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
pragma solidity ^0.8.17;

import {Script, console} from "forge-std/Script.sol";
import {DAO} from "@aragon/osx/core/dao/DAO.sol";
import {TaikoDaoFactory} from "../src/factory/TaikoDaoFactory.sol";
import {IVotesUpgradeable} from "@openzeppelin/contracts-upgradeable/governance/utils/IVotesUpgradeable.sol";
import {GovernanceERC20} from "@aragon/osx/token/ERC20/governance/GovernanceERC20.sol";
Expand All @@ -13,17 +14,48 @@ import {PublicKeyRegistry} from "../src/PublicKeyRegistry.sol";
import {PluginRepo} from "@aragon/osx/framework/plugin/repo/PluginRepo.sol";
import {PluginRepoFactory} from "@aragon/osx/framework/plugin/repo/PluginRepoFactory.sol";
import {PluginSetupProcessor} from "@aragon/osx/framework/plugin/setup/PluginSetupProcessor.sol";
import {DAO} from "@aragon/osx/core/dao/DAO.sol";
import {GovernanceERC20Mock} from "../test/mocks/GovernanceERC20Mock.sol";
import {TaikoL1Mock} from "../test/mocks/TaikoL1Mock.sol";

contract Deploy is Script {
function run() public {
vm.startBroadcast(vm.envUint("DEPLOYMENT_PRIVATE_KEY"));

// JSON list of members
string memory path = string.concat(vm.projectRoot(), "/script/multisig-members.json");
string memory json = vm.readFile(path);
TaikoDaoFactory.DeploymentSettings memory settings;
if (block.chainid == 1) {
settings = getMainnetSettings();
} else {
settings = getTestnetSettings();
}

TaikoDaoFactory factory = new TaikoDaoFactory(settings);
TaikoDaoFactory.Deployment memory deployment = factory.getDeployment();

vm.stopBroadcast();

// Print summary
console.log("Chain ID:", block.chainid);
console.log("");
console.log("Factory contract:", address(this));
console.log("");
console.log("DAO contract:", address(deployment.dao));
console.log("");

TaikoDaoFactory.DeploymentSettings memory settings = TaikoDaoFactory.DeploymentSettings({
console.log("- Multisig plugin:", address(deployment.multisigPlugin));
console.log("- Emergency multisig plugin:", address(deployment.emergencyMultisigPlugin));
console.log("- Optimistic token voting plugin:", address(deployment.optimisticTokenVotingPlugin));
console.log("");

console.log("- Multisig plugin repository:", address(deployment.multisigPluginRepo));
console.log("- Emergency multisig plugin repository:", address(deployment.emergencyMultisigPluginRepo));
console.log("- Optimistic token voting plugin repository:", address(deployment.optimisticTokenVotingPluginRepo));
console.log("");

console.log("Public key registry", address(deployment.publicKeyRegistry));
}

function getMainnetSettings() internal view returns (TaikoDaoFactory.DeploymentSettings memory settings) {
settings = TaikoDaoFactory.DeploymentSettings({
// Taiko contract settings
tokenAddress: IVotesUpgradeable(vm.envAddress("TOKEN_ADDRESS")),
taikoL1ContractAddress: vm.envAddress("TAIKO_L1_ADDRESS"),
Expand All @@ -42,34 +74,66 @@ contract Deploy is Script {
governanceErc20Base: GovernanceERC20(vm.envAddress("GOVERNANCE_ERC20_BASE")),
governanceErcWrapped20Base: GovernanceWrappedERC20(vm.envAddress("GOVERNANCE_WRAPPED_ERC20_BASE")),
// Multisig
multisigMembers: vm.parseJsonAddressArray(json, "$.addresses"),
multisigMembers: readMultisigMembers(),
// ENS
stdMultisigEnsDomain: vm.envString("STD_MULTISIG_ENS_DOMAIN"),
emergencyMultisigEnsDomain: vm.envString("EMERGENCY_MULTISIG_ENS_DOMAIN"),
optimisticTokenVotingEnsDomain: vm.envString("OPTIMISTIC_TOKEN_VOTING_ENS_DOMAIN")
});
}

TaikoDaoFactory factory = new TaikoDaoFactory(settings);
TaikoDaoFactory.Deployment memory deployment = factory.getDeployment();
function getTestnetSettings() internal returns (TaikoDaoFactory.DeploymentSettings memory settings) {
address taikoBridgeAddress = vm.envAddress("TAIKO_BRIDGE_ADDRESS");
address[] memory multisigMembers = readMultisigMembers();
address votingToken = createTestToken(multisigMembers, taikoBridgeAddress);

vm.stopBroadcast();
console.log("Test voting token:", votingToken);

// Print summary
console.log("Factory contract", address(this));
console.log("");
console.log("DAO contract", address(deployment.dao));
console.log("");
settings = TaikoDaoFactory.DeploymentSettings({
// Taiko contract settings
tokenAddress: IVotesUpgradeable(votingToken),
taikoL1ContractAddress: address(new TaikoL1Mock()),
taikoBridgeAddress: taikoBridgeAddress,
l2InactivityPeriod: uint64(vm.envUint("L2_INACTIVITY_PERIOD")),
l2AggregationGracePeriod: uint64(vm.envUint("L2_AGGREGATION_GRACE_PERIOD")),
// Voting settings
minVetoRatio: uint32(vm.envUint("MIN_VETO_RATIO")),
minStdProposalDelay: uint64(vm.envUint("MIN_STD_PROPOSAL_DELAY")),
minStdApprovals: uint16(vm.envUint("MIN_STD_APPROVALS")),
minEmergencyApprovals: uint16(vm.envUint("MIN_EMERGENCY_APPROVALS")),
// OSx contracts
pluginSetupProcessor: PluginSetupProcessor(vm.envAddress("PLUGIN_SETUP_PROCESSOR")),
pluginRepoFactory: PluginRepoFactory(vm.envAddress("PLUGIN_REPO_FACTORY")),
// Token contracts
governanceErc20Base: GovernanceERC20(vm.envAddress("GOVERNANCE_ERC20_BASE")),
governanceErcWrapped20Base: GovernanceWrappedERC20(vm.envAddress("GOVERNANCE_WRAPPED_ERC20_BASE")),
// Multisig
multisigMembers: multisigMembers,
// ENS
stdMultisigEnsDomain: vm.envString("STD_MULTISIG_ENS_DOMAIN"),
emergencyMultisigEnsDomain: vm.envString("EMERGENCY_MULTISIG_ENS_DOMAIN"),
optimisticTokenVotingEnsDomain: vm.envString("OPTIMISTIC_TOKEN_VOTING_ENS_DOMAIN")
});
}

console.log("Multisig plugin", address(deployment.multisigPlugin));
console.log("Emergency multisig plugin", address(deployment.emergencyMultisigPlugin));
console.log("Optimistic token voting plugin", address(deployment.optimisticTokenVotingPlugin));
console.log("");
function readMultisigMembers() internal view returns (address[] memory) {
// JSON list of members
string memory path = string.concat(vm.projectRoot(), "/script/multisig-members.json");
string memory json = vm.readFile(path);
return vm.parseJsonAddressArray(json, "$.addresses");
}

console.log("Multisig plugin repository", address(deployment.multisigPluginRepo));
console.log("Emergency multisig plugin repository", address(deployment.emergencyMultisigPluginRepo));
console.log("Optimistic token voting plugin repository", address(deployment.optimisticTokenVotingPluginRepo));
console.log("");
function createTestToken(address[] memory members, address taikoBridge) internal returns (address) {
GovernanceERC20Mock testToken = new GovernanceERC20Mock(address(0));
console.log("Minting test tokens for the multisig members");

console.log("Public key registry", address(deployment.publicKeyRegistry));
for (uint256 i = 0; i < members.length; i++) {
testToken.mintAndDelegate(members[i], 10 ether);
}

console.log("Minting test tokens for the multisig members");
testToken.mintAndDelegate(taikoBridge, 10 ether);

return address(testToken);
}
}

0 comments on commit 86a35cd

Please sign in to comment.