-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathCreateDao.s.sol
87 lines (66 loc) · 4.32 KB
/
CreateDao.s.sol
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import {Script, console} from "forge-std/Script.sol";
import {
TokenVotingSetup,
GovernanceERC20
} from "@aragon/osx/plugins/governance/majority-voting/token/TokenVotingSetup.sol";
import {MajorityVotingBase} from "@aragon/osx/plugins/governance/majority-voting/MajorityVotingBase.sol";
import {IDAO} from "@aragon/osx/core/dao/IDAO.sol";
import {IDAOFactory, DAOSettings} from "src/interfaces/IDAOFactory.sol";
import {PluginSetupRef, PluginSettings, PluginRepo} from "src/helpers/PluginRepoHelpers.sol";
contract CreateDao is Script {
/// Здесь необходимо изменить только DEPLOYER_ADDRESS
address constant DEPLOYER_ADDRESS = 0x32bb35Fc246CB3979c4Df996F18366C6c753c29c;
address constant DAO_FACTORY_ADDRESS = 0x7a62da7B56fB3bfCdF70E900787010Bc4c9Ca42e;
address constant TOKEN_VOTING_PLUGIN_REPO_ADDRESS = 0x424F4cA6FA9c24C03f2396DF0E96057eD11CF7dF;
/// Используем DAOFactory в сети Sepolia
IDAOFactory daoFactory = IDAOFactory(DAO_FACTORY_ADDRESS);
function run() external {
/// Шаг 1 - Подготовка настроек для создания DAO
/// 1.1 Для простоты не будем передавать развернутую информацию о DAO
DAOSettings memory daoSettings =
DAOSettings({trustedForwarder: address(0), daoURI: "", subdomain: "", metadata: new bytes(0)});
/// Шаг 2 - Подготовка настроек для установки плагина TokenVoting
/// 2.1 Указываем версию плагина TokenVoting и адрес PluginRepo для этого плагина (Sepolia)
PluginSetupRef memory pluginSetupRef = PluginSetupRef(
PluginRepo.Tag({release: uint8(1), build: uint16(2)}), PluginRepo(TOKEN_VOTING_PLUGIN_REPO_ADDRESS)
);
/// 2.2 Параметры голосования для установки плагина TokenVoting
MajorityVotingBase.VotingSettings memory votingSettings = MajorityVotingBase.VotingSettings({
votingMode: MajorityVotingBase.VotingMode.EarlyExecution, // Разрешено досрочное выполнение
supportThreshold: uint32(500000), // 50%
minParticipation: uint32(150000), // 15%
minDuration: uint64(86400), // 1 day
minProposerVotingPower: 1e18 // Минимальное кол-во токенов для голосования = 1
});
/// 2.3 Параметры для создания токена голосования
TokenVotingSetup.TokenSettings memory tokenSettings = TokenVotingSetup.TokenSettings({
addr: address(0), // create new token
name: "Test",
symbol: "T"
});
/// 2.4 Получатель токенов — адрес деплоера
address[] memory receivers = new address[](1);
receivers[0] = DEPLOYER_ADDRESS;
/// 2.5 Для примера сминтим 10 токенов на адрес деплоера
uint256[] memory amounts = new uint256[](1);
amounts[0] = 10e18;
/// 2.6 Параметры для первоначальной эмиссии токена голосования
GovernanceERC20.MintSettings memory mintSettings = GovernanceERC20.MintSettings(receivers, amounts);
/// 2.7 Наконец, собираем вместе все настройки плагина
bytes memory data = abi.encode(votingSettings, tokenSettings, mintSettings);
PluginSettings[] memory pluginSettings = new PluginSettings[](1);
pluginSettings[0] = PluginSettings(pluginSetupRef, data);
uint256 deployerPrivateKey = vm.envUint("PRIVATE_KEY");
vm.startBroadcast(deployerPrivateKey);
/// Шаг 3 - Создаем DAO
IDAO dao = daoFactory.createDao(daoSettings, pluginSettings);
vm.stopBroadcast();
console.log("------------------ Deployed contracts --------------------");
console.log("DAO : ", address(dao));
console.log("------------------ Deployment info -----------------------");
console.log("Chain id : ", block.chainid);
console.log("Deployer : ", vm.addr(deployerPrivateKey));
}
}