-
Notifications
You must be signed in to change notification settings - Fork 21
feat: Proxy admin for ownable #114
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
Open
donosonaumczuk
wants to merge
37
commits into
development
Choose a base branch
from
feat/proxy-admin-for-ownable
base: development
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 3 commits
Commits
Show all changes
37 commits
Select commit
Hold shift + click to select a range
8c0479e
feat: Two approaches for ProxyAdminForOwnable
donosonaumczuk b3b536a
feat: Third approach for ProxyAdminForOwnable
donosonaumczuk abd0339
feat: Approach B decided + DependentLock contract implemented
vicnaum f792e1e
test: MockOwnableUniversal added and ProxyAdmin tests adapted
donosonaumczuk ee3048c
Merge branch 'development' into feat/proxy-admin-for-ownable
donosonaumczuk 89ba3fd
test: More tests added
donosonaumczuk f114df8
misc: mockOwnerOnNextCall added to ownable test mock
donosonaumczuk a2307ce
test: Add pending tests before test re-work
donosonaumczuk 402b567
test: ProxyAdminForOwnable tests improved
donosonaumczuk 4e4d9f0
fix: Tests fixed
donosonaumczuk 2ce9955
feat: Factory includes new ProxyAdminForOwnable
donosonaumczuk b69d1ab
misc: Remove unused code
donosonaumczuk 2d754bd
Merge branch 'development' into feat/proxy-admin-for-ownable
donosonaumczuk 618b79f
misc: Fix warnings after sync with development
donosonaumczuk ac16973
test: Tests fixed
donosonaumczuk e9fae10
Merge branch 'development' into feat/proxy-admin-for-ownable
donosonaumczuk 78f72f2
misc: Deployment script for ProxyAdminForOwnable and DependentLock
vicnaum 5d78e62
deploy: [Testnet] AccountDependentLock and AccountProxyAdminForOwnable
vicnaum 7bfd97c
misc: Testnet Addressbook updated to include factory implementations
vicnaum 7b76237
misc: added global primitives to fork tests
vicnaum d9cc715
feat: ProxyAdminForOwnable restricted to only BeaconProxy admin calls
vicnaum 9e78db8
misc: formatting and magic number removal
vicnaum 019237a
Merge pull request #139 from lens-protocol/feat/proxy-admin-for-ownab…
donosonaumczuk 0f06099
deploy: [Testnet] AccountProxyAdminForOwnable with more restrictions …
vicnaum b7a85b7
deploy: [Mainnet] AccountDependentLock and AccountProxyAdminForOwnable
vicnaum 3ad379e
misc: proxyAdminForOwnable scripts added to package.json
vicnaum 0a728db
test: Namespace tests refactor for compile size
vicnaum 5eeeb1d
test: PostFork Actions added and some fixes for fork AccountDependent…
vicnaum 684d2fc
misc: script to deploy factory implementations for ProxyAdminForOwnable
vicnaum 4fbcc36
deploy: [Testnet] AccountFactoryImpl and LensFactoryImpl (no upgrade …
vicnaum 0e497e5
deploy: [Mainnet] AccountFactoryImpl and LensFactoryImpl (no upgrade …
vicnaum ae11239
test: BaseDeployment script improved and mainnet addressbook updated …
vicnaum a21a512
misc: scripts to transfer factory ownerships to LensAccount and Back
vicnaum 4521640
misc: remove owner as manager script
vicnaum 8fea70c
deploy: [Testnet] AccountFactory and LensFactory upgraded to support …
vicnaum 8965422
misc: transferFactoryOwnershipsToSafe script added (and others tweaked)
vicnaum fc794b0
misc: start-env and end-env scripts tweak
vicnaum File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| // SPDX-License-Identifier: UNLICENSED | ||
| // Copyright (C) 2024 Lens Labs. All Rights Reserved. | ||
| pragma solidity ^0.8.26; | ||
|
|
||
| interface IDependentLock { | ||
| /** | ||
| * @dev Returns true if locked for the given address, false if not. | ||
| */ | ||
| function isLocked(address addr) external view returns (bool); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,43 @@ | ||
| // SPDX-License-Identifier: UNLICENSED | ||
| // Copyright (C) 2024 Lens Labs. All Rights Reserved. | ||
| pragma solidity ^0.8.26; | ||
|
|
||
| import {IDependentLock} from "contracts/core/interfaces/IDependentLock.sol"; | ||
| import {Ownable} from "contracts/core/access/Ownable.sol"; | ||
| import {EventEmitterEarly} from "contracts/migration/EventEmitterEarly.sol"; | ||
|
|
||
| contract DependentLock is Ownable, IDependentLock, EventEmitterEarly { | ||
| event Lens_Lock_LockStatusSet(bool indexed locked); | ||
| event Lens_Lock_LockStatusSet(address indexed target, bool indexed locked); | ||
|
|
||
| bool internal _areAllAddressesUnlocked; | ||
| mapping(address => bool) internal _isAddressUnlocked; | ||
|
|
||
| constructor(address owner, bool locked) Ownable() { | ||
| _transferOwnership(owner); | ||
| _setLockStatus(locked); | ||
| } | ||
|
|
||
| function isLocked(address addr) external view override returns (bool) { | ||
| if (_areAllAddressesUnlocked) { | ||
| return false; | ||
| } else { | ||
| return !_isAddressUnlocked[addr]; | ||
| } | ||
| } | ||
|
|
||
| function setLockStatus(bool locked) external onlyOwner { | ||
| _setLockStatus(locked); | ||
| } | ||
|
|
||
| // Only to unlock specific addresses before the global lock is released. | ||
| function setLockStatusForAddress(address target, bool locked) external onlyOwner { | ||
| _isAddressUnlocked[target] = !locked; | ||
| emit Lens_Lock_LockStatusSet(target, locked); | ||
| } | ||
|
|
||
| function _setLockStatus(bool locked) internal { | ||
| _areAllAddressesUnlocked = !locked; | ||
| emit Lens_Lock_LockStatusSet(locked); | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,46 @@ | ||
| // SPDX-License-Identifier: UNLICENSED | ||
| // Copyright (C) 2024 Lens Labs. All Rights Reserved. | ||
| pragma solidity ^0.8.26; | ||
|
|
||
| import {IDependentLock} from "contracts/core/interfaces/IDependentLock.sol"; | ||
| import {IOwnable} from "contracts/core/interfaces/IOwnable.sol"; | ||
| import {BeaconProxy} from "contracts/core/upgradeability/BeaconProxy.sol"; | ||
| import {CallLib} from "contracts/core/libraries/CallLib.sol"; | ||
| import {Errors} from "contracts/core/types/Errors.sol"; | ||
|
|
||
| contract ProxyAdminForOwnable { | ||
| using CallLib for address; | ||
|
|
||
| IDependentLock immutable LOCK; | ||
|
|
||
| constructor(address lock) { | ||
| LOCK = IDependentLock(lock); | ||
| LOCK.isLocked(address(this)); // Aims to verify the given address follows IDependentLock interface | ||
| } | ||
|
|
||
| function call(address to, uint256 value, bytes calldata data) external payable returns (bytes memory) { | ||
| bytes4 selector = bytes4(data); | ||
| if (LOCK.isLocked(to)) { | ||
| // While the Proxy Admin is locked it: | ||
| // - Cannot change Proxy Admin in the Proxy, only in the ProxyAdmin contract itself | ||
| require(selector != BeaconProxy.proxy__changeProxyAdmin.selector, Errors.Locked()); | ||
| // - Cannot change the Beacon in the Proxy | ||
| require(selector != BeaconProxy.proxy__setBeacon.selector, Errors.Locked()); | ||
| // - Cannot change the implementation in the Proxy | ||
| require(selector != BeaconProxy.proxy__setImplementation.selector, Errors.Locked()); | ||
| // - Cannot trigger an upgrade in the Proxy | ||
| require(selector != BeaconProxy.proxy__triggerUpgradeToVersion.selector, Errors.Locked()); | ||
| require(selector != BeaconProxy.proxy__triggerUpgrade.selector, Errors.Locked()); | ||
| // - Cannot opt-out from auto-upgrade in the Proxy | ||
| require(selector != BeaconProxy.proxy__optOutFromAutoUpgrade.selector, Errors.Locked()); | ||
| // - Cannot opt-in to auto-upgrade in the Proxy | ||
| require(selector != BeaconProxy.proxy__optInToAutoUpgrade.selector, Errors.Locked()); | ||
| } | ||
| // Require the msg.sender to match the owner | ||
| require(msg.sender == IOwnable(to).owner(), Errors.InvalidMsgSender()); | ||
| bytes memory returnData = to.handledsafecall(value, data); | ||
| // Require the owner to not be altered by the executed transaction | ||
| require(IOwnable(to).owner() == msg.sender, Errors.UnexpectedValue()); | ||
| return returnData; | ||
| } | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.