Repository navigation
Expand file tree
/
Copy pathDeploySimple.s.sol
More file actions
109 lines (86 loc) · 3.82 KB
/
Copy pathDeploySimple.s.sol
File metadata and controls
109 lines (86 loc) · 3.82 KB
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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.17;
import {Script, console2} from "forge-std/Script.sol";
import {stdJson} from "forge-std/StdJson.sol";
import {PluginRepoFactory} from "@aragon/osx/framework/plugin/repo/PluginRepoFactory.sol";
import {PluginRepo} from "@aragon/osx/framework/plugin/repo/PluginRepo.sol";
import {MyPluginSetup} from "../src/setup/MyPluginSetup.sol";
/**
* This script performs the following tasks:
* - Deploys a new PluginRepo for each available plugin
* - Publishes a new version of each plugin (release 1, build 1)
*/
contract DeploySimple is Script {
using stdJson for string;
address deployer;
PluginRepoFactory pluginRepoFactory;
string pluginEnsSubdomain;
address pluginRepoMaintainerAddress;
// Artifacts
PluginRepo pluginRepo;
MyPluginSetup pluginSetup;
modifier broadcast() {
uint256 privKey = vm.envUint("DEPLOYER_KEY");
vm.startBroadcast(privKey);
deployer = vm.addr(privKey);
console2.log("General");
console2.log("- Deploying from: ", deployer);
console2.log("- Chain ID: ", block.chainid);
console2.log("");
_;
vm.stopBroadcast();
}
function setUp() public {
// Pick the contract addresses from
// https://github.com/aragon/osx/blob/main/packages/artifacts/src/addresses.json
// Prepare the OSx factories for the current network
pluginRepoFactory = PluginRepoFactory(vm.envAddress("PLUGIN_REPO_FACTORY_ADDRESS"));
vm.label(address(pluginRepoFactory), "PluginRepoFactory");
// Read the rest of environment variables
pluginEnsSubdomain = vm.envOr("PLUGIN_ENS_SUBDOMAIN", string(""));
// Using a random subdomain if empty
if (bytes(pluginEnsSubdomain).length == 0) {
pluginEnsSubdomain = string.concat("my-test-plugin-", vm.toString(block.timestamp));
}
pluginRepoMaintainerAddress = vm.envAddress("PLUGIN_REPO_MAINTAINER_ADDRESS");
vm.label(pluginRepoMaintainerAddress, "Maintainer");
}
function run() public broadcast {
// Publish the first version in a new plugin repo
deployPluginRepo();
// Done
printDeployment();
// Write the addresses to a JSON file
if (!vm.envOr("SIMULATION", false)) {
writeJsonArtifacts();
}
}
function deployPluginRepo() public {
// Plugin setup (the installer)
pluginSetup = new MyPluginSetup();
// The new plugin repository
// Publish the plugin in a new repo as release 1, build 1
pluginRepo = pluginRepoFactory.createPluginRepoWithFirstVersion(
pluginEnsSubdomain, address(pluginSetup), pluginRepoMaintainerAddress, " ", " "
);
}
function printDeployment() public view {
console2.log("MyUpgradeablePlugin:");
console2.log("- Plugin repo: ", address(pluginRepo));
console2.log("- Plugin repo maintainer: ", pluginRepoMaintainerAddress);
console2.log("- ENS: ", string.concat(pluginEnsSubdomain, ".plugin.dao.eth"));
console2.log("");
}
function writeJsonArtifacts() internal {
string memory artifacts = "output";
artifacts.serialize("pluginRepo", address(pluginRepo));
artifacts.serialize("pluginRepoMaintainer", pluginRepoMaintainerAddress);
artifacts = artifacts.serialize("pluginEnsDomain", string.concat(pluginEnsSubdomain, ".plugin.dao.eth"));
string memory networkName = vm.envString("NETWORK_NAME");
string memory filePath = string.concat(
vm.projectRoot(), "/artifacts/deployment-", networkName, "-", vm.toString(block.timestamp), ".json"
);
artifacts.write(filePath);
console2.log("Deployment artifacts written to", filePath);
}
}