فهرست منبع

Consolidate admin fields in State and remove PulseSchedulerGovInstructions.sol

Co-Authored-By: Tejas Badadare <tejas@dourolabs.xyz>
Devin AI 7 ماه پیش
والد
کامیت
2f1c4f79f9

+ 0 - 45
target_chains/ethereum/contracts/contracts/pulse/PulseSchedulerGovInstructions.sol

@@ -1,45 +0,0 @@
-// SPDX-License-Identifier: Apache 2
-pragma solidity ^0.8.0;
-
-import "../pyth/PythGovernanceInstructions.sol";
-import "./SchedulerUpgradeable.sol";
-
-/**
- * @dev `PulseSchedulerGovInstructions` handles governance instructions for the Pulse Scheduler contract.
- * Initially, it only supports the upgrade contract instruction.
- */
-contract PulseSchedulerGovInstructions {
-    // Instance of PythGovernanceInstructions for parsing payloads
-    PythGovernanceInstructions private pythGov;
-    
-    constructor() {
-        pythGov = new PythGovernanceInstructions();
-    }
-    
-    /**
-     * @dev Processes a governance instruction for the Pulse Scheduler contract.
-     * @param instruction The governance instruction to process.
-     * @param scheduler The Pulse Scheduler contract to apply the instruction to.
-     */
-    function processInstruction(
-        PythGovernanceInstructions.GovernanceInstruction memory instruction,
-        SchedulerUpgradeable scheduler
-    ) external {
-        // Only the admin can process governance instructions
-        if (msg.sender != scheduler.getAdmin()) {
-            revert("Unauthorized");
-        }
-
-        // Currently only supports the upgrade contract instruction
-        if (instruction.action != PythGovernanceInstructions.GovernanceAction.UpgradeContract) {
-            revert("Unsupported governance action");
-        }
-
-        // Parse the upgrade contract payload
-        PythGovernanceInstructions.UpgradeContractPayload memory payload = 
-            pythGov.parseUpgradeContractPayload(instruction.payload);
-
-        // Upgrade the contract
-        scheduler.upgradeTo(payload.newImplementation);
-    }
-}

+ 4 - 4
target_chains/ethereum/contracts/contracts/pulse/PulseSchedulerGovernance.sol

@@ -22,7 +22,7 @@ abstract contract PulseSchedulerGovernance is SchedulerState {
      * @dev Returns the address of the current admin.
      */
     function getAdmin() external view returns (address) {
-        return _admin;
+        return _state.admin;
     }
 
     /**
@@ -35,7 +35,7 @@ abstract contract PulseSchedulerGovernance is SchedulerState {
         _authorizeAdminAction();
 
         _proposedAdmin = newAdmin;
-        emit NewAdminProposed(_admin, newAdmin);
+        emit NewAdminProposed(_state.admin, newAdmin);
     }
 
     /**
@@ -45,8 +45,8 @@ abstract contract PulseSchedulerGovernance is SchedulerState {
         if (msg.sender != _proposedAdmin)
             revert("Unauthorized");
 
-        address oldAdmin = _admin;
-        _admin = msg.sender;
+        address oldAdmin = _state.admin;
+        _state.admin = msg.sender;
 
         _proposedAdmin = address(0);
         emit NewAdminAccepted(oldAdmin, msg.sender);

+ 0 - 3
target_chains/ethereum/contracts/contracts/pulse/SchedulerState.sol

@@ -45,9 +45,6 @@ contract SchedulerState {
     // proposedAdmin is the new admin's account address proposed by either the owner or the current admin.
     // If there is no pending transfer request, this value will hold `address(0)`.
     address internal _proposedAdmin;
-    
-    // Admin address for governance actions
-    address internal _admin;
 
     struct SubscriptionParams {
         bytes32[] priceIds;

+ 1 - 4
target_chains/ethereum/contracts/contracts/pulse/SchedulerUpgradeable.sol

@@ -33,9 +33,6 @@ contract SchedulerUpgradeable is
 
         Scheduler._initialize(admin, pythAddress);
         
-        // Set admin for governance
-        _admin = admin;
-
         _transferOwnership(owner);
     }
 
@@ -46,7 +43,7 @@ contract SchedulerUpgradeable is
     
     // Authorize actions that both admin and owner can perform
     function _authorizeAdminAction() internal view override {
-        if (msg.sender != owner() && msg.sender != _admin)
+        if (msg.sender != owner() && msg.sender != _state.admin)
             revert("Unauthorized");
     }