Skip to content

Commit

Permalink
feat: update upgrade script
Browse files Browse the repository at this point in the history
  • Loading branch information
nlecoufl committed Dec 20, 2024
1 parent f72f358 commit af023d8
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 3 deletions.
Binary file modified bun.lockb
Binary file not shown.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"url": "https://github.com/AngleProtocol/merkl-contracts/issues"
},
"devDependencies": {
"@angleprotocol/sdk": "2.34.7",
"@angleprotocol/sdk": "2.35.0",
"@openzeppelin/contracts": "^4.9.0",
"@openzeppelin/contracts-upgradeable": "4.9.0",
"prettier": "^2.0.0",
Expand Down
4 changes: 2 additions & 2 deletions scripts/DistributionCreator.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -523,7 +523,7 @@ contract SignAndCreateCampaign is DistributionCreatorScript {
}

contract UpgradeAndBuildUpgradeToPayload is DistributionCreatorScript {
function run() external {
function run() external broadcast {
uint256 chainId = block.chainid;
address distributionCreator = readAddress(chainId, "Merkl.DistributionCreator");

Expand All @@ -534,7 +534,7 @@ contract UpgradeAndBuildUpgradeToPayload is DistributionCreatorScript {
distributionCreatorImpl
);

try this.externalReadAddress(chainId, "Merkl.AngleLabs") returns (address safe) {
try this.externalReadAddress(chainId, "AngleLabs") returns (address safe) {
_serializeJson(
chainId,
distributionCreator, // target address (the proxy)
Expand Down
28 changes: 28 additions & 0 deletions scripts/Distributor.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { console } from "forge-std/console.sol";
import { ERC1967Proxy } from "@openzeppelin/contracts/proxy/ERC1967/ERC1967Proxy.sol";
import { IERC20 } from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import { JsonReader } from "@utils/JsonReader.sol";
import { ITransparentUpgradeableProxy } from "@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol";

import { BaseScript } from "./utils/Base.s.sol";
import { Distributor, MerkleTree } from "../contracts/Distributor.sol";
Expand Down Expand Up @@ -295,3 +296,30 @@ contract Claim is DistributorScript {
console.log("Claimed rewards for", users.length, "users");
}
}

contract BuildUpgradeToPayload is DistributorScript {
function run() external broadcast {
uint256 chainId = block.chainid;
address distributor = readAddress(chainId, "Merkl.Distributor");

address distributorImpl = address(new Distributor());

bytes memory payload = abi.encodeWithSelector(ITransparentUpgradeableProxy.upgradeTo.selector, distributorImpl);

try this.externalReadAddress(chainId, "AngleLabs") returns (address safe) {
_serializeJson(
chainId,
distributor, // target address (the proxy)
0, // value
payload, // direct upgrade call
Operation.Call, // standard call (not delegate)
hex"", // signature
safe // safe address
);
} catch {}
}

function externalReadAddress(uint256 chainId, string memory key) external view returns (address) {
return readAddress(chainId, key);
}
}

0 comments on commit af023d8

Please sign in to comment.