Skip to content

Commit 9d93dd3

Browse files
committed
Renaming the deployment script (plugin repo)
1 parent e162898 commit 9d93dd3

File tree

4 files changed

+136
-11
lines changed

4 files changed

+136
-11
lines changed

Makefile

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ SHELL:=/bin/bash
99
# CONSTANTS
1010

1111
# NOTE: Choose the appropriate deployment script
12-
DEPLOYMENT_SCRIPT := script/Deploy.s.sol:DeployScript
12+
DEPLOYMENT_SCRIPT := DeployPluginRepo
1313

1414
SOLC_VERSION := $(shell cat foundry.toml | grep solc | cut -d= -f2 | xargs echo || echo "0.8.28")
1515
SUPPORTED_VERIFIERS := etherscan blockscout sourcify routescan-mainnet routescan-testnet
@@ -29,6 +29,7 @@ TEST_COVERAGE_SRC_FILES := $(wildcard test/*.sol test/**/*.sol src/*.sol src/**/
2929
TEST_SOURCE_FILES := $(wildcard test/*.t.yaml test/fork-tests/*.t.yaml)
3030
TEST_TREE_FILES := $(TEST_SOURCE_FILES:.t.yaml=.tree)
3131
DEPLOYMENT_ADDRESS := $(shell cast wallet address --private-key $(DEPLOYMENT_PRIVATE_KEY) 2>/dev/null || echo "NOTE: DEPLOYMENT_PRIVATE_KEY is not properly set on .env" > /dev/stderr)
32+
DEPLOYMENT_SCRIPT_PARAM := script/$(DEPLOYMENT_SCRIPT).s.sol:$(DEPLOYMENT_SCRIPT)Script
3233

3334
DEPLOYMENT_LOG_FILE=deployment-$(NETWORK_NAME)-$(shell date +"%y-%m-%d-%H-%M").log
3435

@@ -265,15 +266,15 @@ predeploy: export SIMULATION=true
265266
.PHONY: predeploy
266267
predeploy: ## Simulate a protocol deployment
267268
@echo "Simulating the deployment"
268-
forge script $(DEPLOYMENT_SCRIPT) \
269+
forge script $(DEPLOYMENT_SCRIPT_PARAM) \
269270
--rpc-url $(RPC_URL) \
270271
$(VERBOSITY)
271272

272273
.PHONY: deploy
273274
deploy: test ## Deploy the protocol, verify the source code and write to ./artifacts
274275
@echo "Starting the deployment"
275276
@mkdir -p $(LOGS_FOLDER) $(ARTIFACTS_FOLDER)
276-
forge script $(DEPLOYMENT_SCRIPT) \
277+
forge script $(DEPLOYMENT_SCRIPT_PARAM) \
277278
--rpc-url $(RPC_URL) \
278279
--retries 10 \
279280
--delay 8 \
@@ -287,7 +288,7 @@ deploy: test ## Deploy the protocol, verify the source code and write to ./artif
287288
resume: test ## Retry pending deployment transactions, verify the code and write to ./artifacts
288289
@echo "Retrying the deployment"
289290
@mkdir -p $(LOGS_FOLDER) $(ARTIFACTS_FOLDER)
290-
forge script $(DEPLOYMENT_SCRIPT) \
291+
forge script $(DEPLOYMENT_SCRIPT_PARAM) \
291292
--rpc-url $(RPC_URL) \
292293
--retries 10 \
293294
--delay 8 \
@@ -301,17 +302,17 @@ resume: test ## Retry pending deployment transactions, verify the code and write
301302
## Verification:
302303

303304
.PHONY: verify-etherscan
304-
verify-etherscan: broadcast/Deploy.s.sol/$(CHAIN_ID)/run-latest.json ## Verify the last deployment on an Etherscan (compatible) explorer
305+
verify-etherscan: broadcast/$(DEPLOYMENT_SCRIPT).s.sol/$(CHAIN_ID)/run-latest.json ## Verify the last deployment on an Etherscan (compatible) explorer
305306
forge build
306307
bash $(VERIFY_CONTRACTS_SCRIPT) $(CHAIN_ID) $(VERIFIER) $(VERIFIER_URL) $(VERIFIER_API_KEY)
307308

308309
.PHONY: verify-blockscout
309-
verify-blockscout: broadcast/Deploy.s.sol/$(CHAIN_ID)/run-latest.json ## Verify the last deployment on BlockScout
310+
verify-blockscout: broadcast/$(DEPLOYMENT_SCRIPT).s.sol/$(CHAIN_ID)/run-latest.json ## Verify the last deployment on BlockScout
310311
forge build
311312
bash $(VERIFY_CONTRACTS_SCRIPT) $(CHAIN_ID) $(VERIFIER) https://$(BLOCKSCOUT_HOST_NAME)/api $(VERIFIER_API_KEY)
312313

313314
.PHONY: verify-sourcify
314-
verify-sourcify: broadcast/Deploy.s.sol/$(CHAIN_ID)/run-latest.json ## Verify the last deployment on Sourcify
315+
verify-sourcify: broadcast/$(DEPLOYMENT_SCRIPT).s.sol/$(CHAIN_ID)/run-latest.json ## Verify the last deployment on Sourcify
315316
forge build
316317
bash $(VERIFY_CONTRACTS_SCRIPT) $(CHAIN_ID) $(VERIFIER) "" ""
317318

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,7 @@ When running a production deployment ceremony, you can use these steps as a refe
299299
- [ ] I have uploaded the following files to a shared location:
300300
- `logs/deployment-<network>.log` (the last one)
301301
- `artifacts/deployment-<network>-<timestamp>.json` (the last one)
302-
- `broadcast/Deploy.s.sol/<chain-id>/run-<timestamp>.json` (the last one, or `run-latest.json`)
302+
- `broadcast/DeployPluginRepo.s.sol/<chain-id>/run-<timestamp>.json` (the last one, or `run-latest.json`)
303303
- [ ] The rest of members confirm that the values are correct
304304
- [ ] I have transferred the remaining funds of the deployment wallet to the address that originally funded it
305305
- `make refund`
@@ -322,7 +322,7 @@ Verification:
322322
- make verify-sourcify Verify the last deployment on Sourcify
323323
```
324324

325-
These targets use the last deployment data under `broadcast/Deploy.s.sol/<chain-id>/run-latest.json`.
325+
These targets use the last deployment data under `broadcast/DeployPluginRepo.s.sol/<chain-id>/run-latest.json`.
326326
- Ensure that the required variables are set within the `.env` file.
327327
- Ensure that `NETWORK_NAME` is listed on the right section under `constants.mk`, according to the block explorer that you want to target
328328

script/DeployPluginRepo.s.sol

Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
// SPDX-License-Identifier: UNLICENSED
2+
pragma solidity ^0.8.17;
3+
4+
import {Script, console2} from "forge-std/Script.sol";
5+
import {stdJson} from "forge-std/StdJson.sol";
6+
7+
import {IDAO} from "@aragon/osx/core/dao/DAO.sol";
8+
import {PluginRepoFactory} from "@aragon/osx/framework/plugin/repo/PluginRepoFactory.sol";
9+
import {PluginRepo} from "@aragon/osx/framework/plugin/repo/PluginRepo.sol";
10+
import {hashHelpers, PluginSetupRef} from "@aragon/osx/framework/plugin/setup/PluginSetupProcessorHelpers.sol";
11+
import {TokenVotingSetup} from "../src/TokenVotingSetup.sol";
12+
import {GovernanceERC20} from "../src/erc20/GovernanceERC20.sol";
13+
import {GovernanceWrappedERC20} from "../src/erc20/GovernanceWrappedERC20.sol";
14+
import {IERC20Upgradeable} from "@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol";
15+
16+
/**
17+
* This script performs the following tasks:
18+
* - Deploys a new PluginRepo
19+
* - Publishes the first version (release 1, build 1)
20+
*
21+
* The full plugin deployment should be made from the Protocol Factory.
22+
* This script is provided for separate ad-hoc deployments.
23+
*/
24+
contract DeployPluginRepoScript is Script {
25+
using stdJson for string;
26+
27+
address deployer;
28+
PluginRepoFactory pluginRepoFactory;
29+
string pluginEnsSubdomain;
30+
address pluginRepoMaintainerAddress;
31+
32+
// Artifacts
33+
PluginRepo myPluginRepo;
34+
TokenVotingSetup pluginSetup;
35+
36+
modifier broadcast() {
37+
uint256 privKey = vm.envUint("DEPLOYMENT_PRIVATE_KEY");
38+
vm.startBroadcast(privKey);
39+
40+
deployer = vm.addr(privKey);
41+
console2.log("General");
42+
console2.log("- Deploying from: ", deployer);
43+
console2.log("- Chain ID: ", block.chainid);
44+
console2.log("");
45+
46+
_;
47+
48+
vm.stopBroadcast();
49+
}
50+
51+
function setUp() public {
52+
// Pick the contract addresses from
53+
// https://github.com/aragon/osx/blob/main/packages/artifacts/src/addresses.json
54+
55+
// Prepare the OSx factories for the current network
56+
pluginRepoFactory = PluginRepoFactory(vm.envAddress("PLUGIN_REPO_FACTORY_ADDRESS"));
57+
vm.label(address(pluginRepoFactory), "PluginRepoFactory");
58+
59+
// Read the rest of environment variables
60+
pluginEnsSubdomain = vm.envOr("PLUGIN_ENS_SUBDOMAIN", string(""));
61+
62+
// Using a random subdomain if empty
63+
if (bytes(pluginEnsSubdomain).length == 0) {
64+
pluginEnsSubdomain = string.concat("my-token-voting-plugin-", vm.toString(block.timestamp));
65+
}
66+
67+
pluginRepoMaintainerAddress = vm.envAddress("PLUGIN_REPO_MAINTAINER_ADDRESS");
68+
vm.label(pluginRepoMaintainerAddress, "Maintainer");
69+
}
70+
71+
function run() public broadcast {
72+
// Publish the first version in a new plugin repo
73+
deployPluginRepo();
74+
75+
// Done
76+
printDeployment();
77+
78+
// Write the addresses to a JSON file
79+
if (!vm.envOr("SIMULATION", false)) {
80+
writeJsonArtifacts();
81+
}
82+
}
83+
84+
function deployPluginRepo() public {
85+
// Dependency implementations
86+
GovernanceERC20 governanceERC20 = new GovernanceERC20(
87+
IDAO(address(0)), "", "", GovernanceERC20.MintSettings(new address[](0), new uint256[](0)), new address[](0)
88+
);
89+
GovernanceWrappedERC20 governanceWrappedERC20 =
90+
new GovernanceWrappedERC20(IERC20Upgradeable(address(0)), "", "", new address[](0));
91+
92+
// Plugin setup (the installer)
93+
pluginSetup = new TokenVotingSetup(governanceERC20, governanceWrappedERC20);
94+
95+
// The new plugin repository
96+
// Publish the plugin in a new repo as release 1, build 1
97+
myPluginRepo = pluginRepoFactory.createPluginRepoWithFirstVersion(
98+
pluginEnsSubdomain, address(pluginSetup), pluginRepoMaintainerAddress, " ", " "
99+
);
100+
}
101+
102+
function printDeployment() public view {
103+
console2.log("TokenVoting plugin:");
104+
console2.log("- Plugin repo: ", address(myPluginRepo));
105+
console2.log("- Plugin repo maintainer: ", pluginRepoMaintainerAddress);
106+
console2.log("- ENS: ", string.concat(pluginEnsSubdomain, ".plugin.dao.eth"));
107+
console2.log("");
108+
}
109+
110+
function writeJsonArtifacts() internal {
111+
string memory artifacts = "output";
112+
artifacts.serialize("pluginRepo", address(myPluginRepo));
113+
artifacts.serialize("pluginRepoMaintainer", pluginRepoMaintainerAddress);
114+
artifacts = artifacts.serialize("pluginEnsDomain", string.concat(pluginEnsSubdomain, ".plugin.dao.eth"));
115+
116+
string memory networkName = vm.envString("NETWORK_NAME");
117+
string memory filePath = string.concat(
118+
vm.projectRoot(), "/artifacts/deployment-", networkName, "-", vm.toString(block.timestamp), ".json"
119+
);
120+
artifacts.write(filePath);
121+
122+
console2.log("Deployment artifacts written to", filePath);
123+
}
124+
}

script/verify-contracts.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/bin/bash
22

33
# This script is a fallback for cases where multiple block explorers need to be targeted.
4-
# It reads and verifies all contracts from the latest 'Deploy.s.sol' script run
4+
# It reads and verifies all contracts from the latest 'DeployPluginRepo.s.sol' script run
55
# on a single, specified block explorer.
66
# It reads deployment details from the corresponding run-latest.json broadcast file.
77

@@ -19,7 +19,7 @@
1919
set -uo pipefail # Exit on unset variables and on pipeline errors
2020

2121
# Constants
22-
DEPLOY_SCRIPT_FILENAME="Deploy.s.sol"
22+
DEPLOY_SCRIPT_FILENAME="DeployPluginRepo.s.sol"
2323

2424
# Functions
2525

0 commit comments

Comments
 (0)