|
1 | 1 | // SPDX-License-Identifier: UNLICENSED |
2 | 2 | pragma solidity ^0.8.13; |
3 | 3 |
|
| 4 | +// --- Script Purpose --- |
| 5 | +// This script transfers ownership of the deployed PythLazer contract (proxy) to a new owner contract (typically the governance executor contract). |
| 6 | +// Usage: Run this script after deploying the new executor contract on the target chain. Ensure the executor address is correct and deployed. |
| 7 | +// Preconditions: |
| 8 | +// - The LAZER_PROXY_ADDRESS must point to the deployed PythLazer proxy contract. Currently set to 0xACeA761c27A909d4D3895128EBe6370FDE2dF481, which was made using createX. |
| 9 | +// - The NEW_OWNER must be the deployed executor contract address on this chain. |
| 10 | +// - The script must be run by the current owner (OLD_OWNER) of the PythLazer contract. |
| 11 | +// - The DEPLOYER_PRIVATE_KEY environment variable must be set to the current owner's private key. |
| 12 | +// |
| 13 | +// Steps: |
| 14 | +// 1. Log current and new owner addresses, and the proxy address. |
| 15 | +// 2. Check the current owner matches the expected OLD_OWNER. |
| 16 | +// 3. Transfer ownership to the NEW_OWNER (executor contract). |
| 17 | +// 4. Log the new owner for verification. |
| 18 | +// |
| 19 | +// Note: This script is intended for use with Foundry (forge-std) tooling. |
| 20 | + |
4 | 21 | import {Script, console} from "forge-std/Script.sol"; |
5 | 22 | import {PythLazer} from "../src/PythLazer.sol"; |
6 | 23 | import {ERC1967Proxy} from "@openzeppelin/contracts/proxy/ERC1967/ERC1967Proxy.sol"; |
7 | 24 | import {UUPSUpgradeable} from "@openzeppelin/contracts/proxy/utils/UUPSUpgradeable.sol"; |
8 | 25 |
|
| 26 | +// Main script contract for ownership transfer |
9 | 27 | contract PythLazerChangeOwnership is Script { |
| 28 | + // Address of the deployed PythLazer proxy contract |
10 | 29 | address public constant LAZER_PROXY_ADDRESS = |
11 | 30 | address(0xACeA761c27A909d4D3895128EBe6370FDE2dF481); |
12 | 31 |
|
| 32 | + // Private key of the current owner, loaded from environment variable |
13 | 33 | uint256 public OLD_OWNER_PRIVATE_KEY = vm.envUint("DEPLOYER_PRIVATE_KEY"); |
| 34 | + // Current owner address, derived from private key |
14 | 35 | address public OLD_OWNER = vm.addr(OLD_OWNER_PRIVATE_KEY); |
15 | | - // EVM Executor Contract |
| 36 | + // Address of the new owner (should be the deployed executor contract) |
16 | 37 | address public NEW_OWNER = vm.envAddress("NEW_OWNER"); |
17 | 38 |
|
| 39 | + // Entry point for the script |
18 | 40 | function run() public { |
| 41 | + // Log relevant addresses for traceability |
19 | 42 | console.log("Old owner: %s", OLD_OWNER); |
20 | 43 | console.log("New owner: %s", NEW_OWNER); |
21 | 44 | console.log("Lazer proxy address: %s", LAZER_PROXY_ADDRESS); |
22 | 45 | console.log("Lazer owner: %s", PythLazer(LAZER_PROXY_ADDRESS).owner()); |
23 | 46 | console.log("Moving ownership from %s to %s", OLD_OWNER, NEW_OWNER); |
24 | 47 |
|
| 48 | + // Get the PythLazer contract instance at the proxy address |
25 | 49 | PythLazer lazer = PythLazer(LAZER_PROXY_ADDRESS); |
| 50 | + // Start broadcasting transactions as the old owner |
26 | 51 | vm.startBroadcast(OLD_OWNER_PRIVATE_KEY); |
| 52 | + // Ensure the current owner matches the expected old owner |
27 | 53 | require(lazer.owner() == OLD_OWNER, "Old owner mismatch"); |
| 54 | + // Transfer ownership to the new owner (executor contract) |
28 | 55 | lazer.transferOwnership(NEW_OWNER); |
29 | 56 | console.log("Ownership transferred"); |
| 57 | + // Log the new owner for verification |
30 | 58 | console.log( |
31 | 59 | "New Lazer owner: %s", |
32 | 60 | PythLazer(LAZER_PROXY_ADDRESS).owner() |
33 | 61 | ); |
| 62 | + // Stop broadcasting |
34 | 63 | vm.stopBroadcast(); |
35 | 64 | } |
36 | 65 | } |
0 commit comments