-
Notifications
You must be signed in to change notification settings - Fork 48
feat: ownership transfer script can set arbitrary manager #234
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 3 commits
f957940
4fa9311
b8caeb0
14c8f9f
d3d1a69
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -11,15 +11,19 @@ import {NetworksJson} from "./lib/NetworksJson.sol"; | |
| contract TransferOwnership is NetworksJson { | ||
| // Required input | ||
| string private constant INPUT_ENV_NEW_OWNER = "NEW_OWNER"; | ||
| string private constant INPUT_ENV_RESET_MANAGER = "RESET_MANAGER"; | ||
| string private constant INPUT_ENV_NEW_MANAGER = "NEW_MANAGER"; | ||
| // 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; | ||
| bool resetManager; | ||
| /// Contains either the value `NO_MANAGER` if the manager should not be | ||
| /// updated or the address of the new manager. | ||
| address newManager; | ||
| ERC173 authenticatorProxy; | ||
| } | ||
|
|
||
|
|
@@ -46,17 +50,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.resetManager) { | ||
| if (params.newManager != NO_MANAGER) { | ||
| console.log( | ||
| string.concat( | ||
| "Setting new solver manager from ", | ||
| vm.toString(authenticator.manager()), | ||
| " to ", | ||
| vm.toString(params.newOwner) | ||
| vm.toString(params.newManager) | ||
| ) | ||
| ); | ||
| vm.broadcast(msg.sender); | ||
| authenticator.setManager(params.newOwner); | ||
| authenticator.setManager(params.newManager); | ||
| console.log("Set new solver manager account."); | ||
| } | ||
|
|
||
|
|
@@ -68,11 +72,23 @@ contract TransferOwnership is NetworksJson { | |
| vm.broadcast(msg.sender); | ||
| params.authenticatorProxy.transferOwnership(params.newOwner); | ||
| console.log("Set new owner of the authenticator proxy."); | ||
|
|
||
| console.log(string.concat("Final owner: ", vm.toString(params.authenticatorProxy.owner()))); | ||
| console.log(string.concat("Final manager: ", vm.toString(authenticator.manager()))); | ||
| } | ||
|
|
||
| function paramsFromEnv() internal view returns (ScriptParams memory) { | ||
| address newOwner = vm.envAddress(INPUT_ENV_NEW_OWNER); | ||
| bool resetManager = vm.envBool(INPUT_ENV_RESET_MANAGER); | ||
|
|
||
| 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 authenticatorProxy; | ||
| try vm.envAddress(INPUT_ENV_AUTHENTICATOR_PROXY) returns (address env) { | ||
|
|
@@ -95,11 +111,8 @@ contract TransferOwnership is NetworksJson { | |
| } | ||
| } | ||
|
|
||
| return ScriptParams({ | ||
| newOwner: newOwner, | ||
| resetManager: resetManager, | ||
| authenticatorProxy: ERC173(authenticatorProxy) | ||
| }); | ||
| return | ||
| ScriptParams({newOwner: newOwner, newManager: newManager, authenticatorProxy: ERC173(authenticatorProxy)}); | ||
| } | ||
|
|
||
| function checkIsProxy(address candidate) internal view { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for safety purposes, wouldn't it be better than we change manager and owner is optional? mostly because if we change the manager but not the owner, it is easy to fix, but if we change the owner and not the manager, and the owner is a SAFE... it will be hard to amend.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This script is intended to be used only during the first deployment of the script, after that both the owner and the manager are expected to be a multisig and this script wouldn't be used anymore.
That is, I wouldn't expect this script to be used to just change the manager.
But this is maybe a good argument to make the manager mandatory and not offer a default behavior if there's no manager.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I removed the unneeded complexity in 14c8f9f.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thank you! the README still applies as it is?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep! The only change is in d3d1a69.