Skip to content

Commit

Permalink
chore: remove unnecessary optional manager feature
Browse files Browse the repository at this point in the history
  • Loading branch information
fedgiac committed Oct 30, 2024
1 parent b8caeb0 commit 14c8f9f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 43 deletions.
39 changes: 12 additions & 27 deletions script/TransferOwnership.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,10 @@ contract TransferOwnership is NetworksJson {
// Optional input
string private constant INPUT_ENV_AUTHENTICATOR_PROXY = "AUTHENTICATOR_PROXY";

address public constant NO_MANAGER = address(0);

NetworksJson internal networksJson;

struct ScriptParams {
address newOwner;
/// Contains either the value `NO_MANAGER` if the manager should not be
/// updated or the address of the new manager.
address newManager;
ERC173 authenticatorProxy;
}
Expand Down Expand Up @@ -50,19 +46,17 @@ contract TransferOwnership is NetworksJson {

// Make sure to reset the manager BEFORE transferring ownership, or else
// we will not be able to do it once we lose permissions.
if (params.newManager != NO_MANAGER) {
console.log(
string.concat(
"Setting new solver manager from ",
vm.toString(authenticator.manager()),
" to ",
vm.toString(params.newManager)
)
);
vm.broadcast(msg.sender);
authenticator.setManager(params.newManager);
console.log("Set new solver manager account.");
}
console.log(
string.concat(
"Setting new solver manager from ",
vm.toString(authenticator.manager()),
" to ",
vm.toString(params.newManager)
)
);
vm.broadcast(msg.sender);
authenticator.setManager(params.newManager);
console.log("Set new solver manager account.");

console.log(
string.concat(
Expand All @@ -79,16 +73,7 @@ contract TransferOwnership is NetworksJson {

function paramsFromEnv() internal view returns (ScriptParams memory) {
address newOwner = vm.envAddress(INPUT_ENV_NEW_OWNER);

address newManager;
try vm.envAddress(INPUT_ENV_NEW_MANAGER) returns (address env) {
if (env == NO_MANAGER) {
revert(string.concat("Invalid parameter: cannot update the manager to address ", vm.toString(env)));
}
newManager = env;
} catch {
newManager = NO_MANAGER;
}
address newManager = vm.envAddress(INPUT_ENV_NEW_MANAGER);

address authenticatorProxy;
try vm.envAddress(INPUT_ENV_AUTHENTICATOR_PROXY) returns (address env) {
Expand Down
16 changes: 0 additions & 16 deletions test/script/TransferOwnership.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -45,22 +45,6 @@ contract TestTransferOwnership is Test {
assertEq(proxyAsAuthenticator.manager(), newManager, "did not change the manager");
}

function test_only_transfers_proxy_ownership() public {
address newOwner = makeAddr("TestTransferOwnership: new proxy owner");
assertEq(proxy.owner(), owner);
assertEq(proxyAsAuthenticator.manager(), owner);

address noManager = script.NO_MANAGER();
require(owner != noManager, "Invalid test setup, owner should not coincide with NO_MANAGER flag address");
TransferOwnership.ScriptParams memory params =
TransferOwnership.ScriptParams({newOwner: newOwner, authenticatorProxy: proxy, newManager: noManager});

script.runWith(params);

assertEq(proxy.owner(), newOwner, "did not change the owner");
assertEq(proxyAsAuthenticator.manager(), owner, "changed the manager");
}

function test_reverts_if_no_proxy_at_target() public {
address notAProxy = makeAddr("not a proxy");
TransferOwnership.ScriptParams memory params = TransferOwnership.ScriptParams({
Expand Down

0 comments on commit 14c8f9f

Please sign in to comment.