Skip to content

Commit

Permalink
👷 add method stubs to GovernorModule
Browse files Browse the repository at this point in the history
  • Loading branch information
cmontecoding committed Sep 29, 2023
1 parent edce935 commit e923e64
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 0 deletions.
35 changes: 35 additions & 0 deletions src/GovernorModule.sol
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ contract GovernorModule {
safeProxy = Safe(payable(address(_safeProxy)));
}

/// @notice this is to call replaceOwner() on the safe
/// @dev done with execTransactionFromModule()
//todo: check if this function is still needed
// we might only need addOwnerWithThreshold(), removeOwner(), and setupOwners()
function replaceOwner(address prevOwner, address oldOwner, address newOwner) internal {
bytes memory swapOwner = abi.encodeWithSignature(
"swapOwner(address,address,address)",
Expand All @@ -26,6 +30,8 @@ contract GovernorModule {
);
}

/// @notice this is to call addOwnerWithThreshold() on the safe
/// @dev done with execTransactionFromModule()
function addOwnerWithThreshold(address newOwner, uint256 threshold) internal {
bytes memory addOwner = abi.encodeWithSignature(
"addOwnerWithThreshold(address,uint256)",
Expand All @@ -40,6 +46,8 @@ contract GovernorModule {
);
}

/// @notice this is to call removeOwner() on the safe
/// @dev done with execTransactionFromModule()
function removeOwner(
address prevOwner,
address owner,
Expand All @@ -58,4 +66,31 @@ contract GovernorModule {
Enum.Operation.Call
);
}

/// @notice this is to remove one owner from the safe when a replacement election starts
/// @dev removeOwner() needs a prevOwner param as well which is the owner that points to the owner to be removed in the linked list
function removeSingleOwner(address owner) internal {

/// @dev this is to get the previous owner param
for (int i = 0; i < safeProxy.getOwners().length; i++) {
//todo: get prevOwner
if (safeProxy.getOwner(prevOwner) == owner) {
break;
}
}

//todo: removeOwner and adjust threshold accordingly
removeOwner(address(0), owner, 1);
}

/// @notice this is to add one owner to the safe when a replacement election ends
/// @dev threshold is justed according to the number of owners
/// should always be majority
function addSingleOwner(address owner) internal {
addOwnerWithThreshold(owner, 1);
}

function putInFullElection() internal {

}
}
3 changes: 3 additions & 0 deletions test/Echidna.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
pragma solidity ^0.8.19;

//todo: fix with stakingV2
// this is all commented out because the deployment process
// is different now because AutomatedVoting now uses StakingRewardsV2

// import {AutomatedVoting} from "../src/AutomatedVoting.sol";
// import {StakingRewards} from "../lib/token/contracts/StakingRewards.sol";
// import {Kwenta} from "../lib/token/contracts/Kwenta.sol";
Expand Down

0 comments on commit e923e64

Please sign in to comment.