Skip to content

Commit

Permalink
deploy revolution builder upgrade script
Browse files Browse the repository at this point in the history
  • Loading branch information
rocketman-21 committed Mar 30, 2024
1 parent 8662719 commit 2ea5e9e
Show file tree
Hide file tree
Showing 4 changed files with 131 additions and 3 deletions.
4 changes: 2 additions & 2 deletions packages/revolution/deploys/84532.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ Builder: 0x20e882943e630f54e56cc8d9320d8e4ca9e88e13
RevolutionToken implementation: 0xdfa8c2eb7a53294a8d308f175b7b9629f021faf6
Descriptor implementation: 0xad4d14fb590c180ce4c51742fed74abc672a4ec7
Auction implementation: 0x5f3e317a7b2cef88b0383cae5bb3638af6c472f5
Executor implementation: 0x1a15f3b4cd39cde36489ee3ac3357a252213915d
Executor implementation: 0x36ecc90668b2d35a7918a5065f0ec035247af876
DAO implementation: 0x4ab52b333fa8416c597dfea5d9785444ac2c7b54
Builder implementation: 0x7c320c0eaae165d190fae8710e866fef71e7ec07
Builder implementation: 0xfa5656162d67781d7ecc328a6562b6c8dc9ce016
Culture Index implementation: 0xceabc08735b414f2fb245215e482478c8ba37ea7
Max Heap implementation: 0x2559056557600458c7df5d553aa0efe53a7cda62
Points implementation: 0x9c7432701b4bc68d0e7ace2bf2712321b0d3ad8a
Expand Down
1 change: 1 addition & 0 deletions packages/revolution/deploys/84532.upgradeBuilder.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Builder implementation: 0xfa5656162d67781d7ecc328a6562b6c8dc9ce016
2 changes: 1 addition & 1 deletion packages/revolution/script/DAOExecutorUpgrade.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ contract DAOExecutorUpgrade is Script {

string configFile;

function _getKey(string memory key) internal returns (address result) {
function _getKey(string memory key) internal view returns (address result) {
(result) = abi.decode(vm.parseJson(configFile, string.concat(".", key)), (address));
}

Expand Down
127 changes: 127 additions & 0 deletions packages/revolution/script/RevolutionBuilderUpgrade.s.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
// SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity 0.8.22;

import "forge-std/Script.sol";
import "forge-std/console2.sol";
import { Strings } from "@openzeppelin/contracts/utils/Strings.sol";

import { IRevolutionBuilder, RevolutionBuilder } from "../src/builder/RevolutionBuilder.sol";

contract RevolutionBuilderUpgrade is Script {
using Strings for uint256;

string configFile;

function _getKey(string memory key) internal view returns (address result) {
(result) = abi.decode(vm.parseJson(configFile, string.concat(".", key)), (address));
}

function run() public {
uint256 chainID = vm.envUint("CHAIN_ID");
console.log("CHAIN_ID", chainID);
uint256 key = vm.envUint("PRIVATE_KEY");
address deployerAddress = vm.addr(key);

configFile = vm.readFile(string.concat("./addresses/", Strings.toString(chainID), ".json"));

console.log("CONFIG FILE", configFile);

console2.log("~~~~~~~~~~ DEPLOYER ADDRESS ~~~~~~~~~~~");
console2.logAddress(deployerAddress);

console2.log("~~~~~~~~~~ BUILDER PROXY ~~~~~~~~~~~");
console2.logAddress(_getKey("BuilderProxy"));

console2.log("~~~~~~~~~~ REVOLUTION TOKEN ~~~~~~~~~~~");
console2.logAddress(_getKey("RevolutionToken"));

console2.log("~~~~~~~~~~ DESCRIPTOR ~~~~~~~~~~~");
console2.logAddress(_getKey("Descriptor"));

console2.log("~~~~~~~~~~ AUCTION ~~~~~~~~~~~");
console2.logAddress(_getKey("Auction"));

console2.log("~~~~~~~~~~ CULTURE INDEX ~~~~~~~~~~~");
console2.logAddress(_getKey("CultureIndex"));

console2.log("~~~~~~~~~~ DAO ~~~~~~~~~~~");
console2.logAddress(_getKey("DAO"));

console2.log("~~~~~~~~~~ MAX HEAP ~~~~~~~~~~~");
console2.logAddress(_getKey("MaxHeap"));

console2.log("~~~~~~~~~~ REVOLUTION POINTS ~~~~~~~~~~~");
console2.logAddress(_getKey("Points"));

console2.log("~~~~~~~~~~ REVOLUTION POINTS EMITTER ~~~~~~~~~~~");
console2.logAddress(_getKey("PointsEmitter"));

console2.log("~~~~~~~~~~ REVOLUTION VOTING POWER ~~~~~~~~~~~");
console2.logAddress(_getKey("RevolutionVotingPower"));

console2.log("~~~~~~~~~~ VRGDAC ~~~~~~~~~~~");
console2.logAddress(_getKey("VRGDAC"));

console2.log("~~~~~~~~~~ SPLIT MAIN ~~~~~~~~~~~");
console2.logAddress(_getKey("SplitMain"));

console2.log("~~~~~~~~~~ DEPLOYING DAO EXECUTOR UPGRADE ~~~~~~~~~~~");

vm.startBroadcast(deployerAddress);

address builderImpl = address(
new RevolutionBuilder(
IRevolutionBuilder.PointsImplementations({
revolutionPointsEmitter: _getKey("PointsEmitter"),
revolutionPoints: _getKey("Points"),
splitsCreator: _getKey("SplitMain"),
vrgda: _getKey("VRGDAC")
}),
IRevolutionBuilder.TokenImplementations({
revolutionToken: _getKey("RevolutionToken"),
descriptor: _getKey("Descriptor"),
auction: _getKey("Auction")
}),
IRevolutionBuilder.DAOImplementations({
revolutionVotingPower: _getKey("RevolutionVotingPower"),
executor: _getKey("Executor"),
dao: _getKey("DAO")
}),
IRevolutionBuilder.CultureIndexImplementations({
cultureIndex: _getKey("CultureIndex"),
maxHeap: _getKey("MaxHeap")
})
)
);

console2.log("BUILDER IMPLEMENTATION");
console2.log(builderImpl);

// console2.log("OWNER", manager.owner());

// builder.upgradeTo(builderImpl);

vm.stopBroadcast();

string memory filePath = string(abi.encodePacked("deploys/", chainID.toString(), ".upgradeBuilder.txt"));
vm.writeFile(filePath, "");
vm.writeLine(filePath, string(abi.encodePacked("Builder implementation: ", addressToString(builderImpl))));
}

function addressToString(address _addr) private pure returns (string memory) {
bytes memory s = new bytes(40);
for (uint256 i = 0; i < 20; i++) {
bytes1 b = bytes1(uint8(uint256(uint160(_addr)) / (2 ** (8 * (19 - i)))));
bytes1 hi = bytes1(uint8(b) / 16);
bytes1 lo = bytes1(uint8(b) - 16 * uint8(hi));
s[2 * i] = char(hi);
s[2 * i + 1] = char(lo);
}
return string(abi.encodePacked("0x", string(s)));
}

function char(bytes1 b) private pure returns (bytes1 c) {
if (uint8(b) < 10) return bytes1(uint8(b) + 0x30);
else return bytes1(uint8(b) + 0x57);
}
}

0 comments on commit 2ea5e9e

Please sign in to comment.