Skip to content
Open
Show file tree
Hide file tree
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 Apr 16, 2025
b3b536a
feat: Third approach for ProxyAdminForOwnable
donosonaumczuk Apr 16, 2025
abd0339
feat: Approach B decided + DependentLock contract implemented
vicnaum May 19, 2025
f792e1e
test: MockOwnableUniversal added and ProxyAdmin tests adapted
donosonaumczuk May 29, 2025
ee3048c
Merge branch 'development' into feat/proxy-admin-for-ownable
donosonaumczuk May 29, 2025
89ba3fd
test: More tests added
donosonaumczuk May 30, 2025
f114df8
misc: mockOwnerOnNextCall added to ownable test mock
donosonaumczuk Jun 3, 2025
a2307ce
test: Add pending tests before test re-work
donosonaumczuk Jun 5, 2025
402b567
test: ProxyAdminForOwnable tests improved
donosonaumczuk Jun 5, 2025
4e4d9f0
fix: Tests fixed
donosonaumczuk Jun 6, 2025
2ce9955
feat: Factory includes new ProxyAdminForOwnable
donosonaumczuk Jun 9, 2025
b69d1ab
misc: Remove unused code
donosonaumczuk Jun 17, 2025
2d754bd
Merge branch 'development' into feat/proxy-admin-for-ownable
donosonaumczuk Jun 26, 2025
618b79f
misc: Fix warnings after sync with development
donosonaumczuk Jun 26, 2025
ac16973
test: Tests fixed
donosonaumczuk Jun 26, 2025
e9fae10
Merge branch 'development' into feat/proxy-admin-for-ownable
donosonaumczuk Jul 11, 2025
78f72f2
misc: Deployment script for ProxyAdminForOwnable and DependentLock
vicnaum Jul 15, 2025
5d78e62
deploy: [Testnet] AccountDependentLock and AccountProxyAdminForOwnable
vicnaum Jul 15, 2025
7bfd97c
misc: Testnet Addressbook updated to include factory implementations
vicnaum Jul 15, 2025
7b76237
misc: added global primitives to fork tests
vicnaum Jul 15, 2025
d9cc715
feat: ProxyAdminForOwnable restricted to only BeaconProxy admin calls
vicnaum Jul 16, 2025
9e78db8
misc: formatting and magic number removal
vicnaum Jul 16, 2025
019237a
Merge pull request #139 from lens-protocol/feat/proxy-admin-for-ownab…
donosonaumczuk Jul 16, 2025
0f06099
deploy: [Testnet] AccountProxyAdminForOwnable with more restrictions …
vicnaum Jul 16, 2025
b7a85b7
deploy: [Mainnet] AccountDependentLock and AccountProxyAdminForOwnable
vicnaum Jul 16, 2025
3ad379e
misc: proxyAdminForOwnable scripts added to package.json
vicnaum Jul 16, 2025
0a728db
test: Namespace tests refactor for compile size
vicnaum Jul 17, 2025
5eeeb1d
test: PostFork Actions added and some fixes for fork AccountDependent…
vicnaum Jul 17, 2025
684d2fc
misc: script to deploy factory implementations for ProxyAdminForOwnable
vicnaum Jul 23, 2025
4fbcc36
deploy: [Testnet] AccountFactoryImpl and LensFactoryImpl (no upgrade …
vicnaum Jul 23, 2025
0e497e5
deploy: [Mainnet] AccountFactoryImpl and LensFactoryImpl (no upgrade …
vicnaum Jul 23, 2025
ae11239
test: BaseDeployment script improved and mainnet addressbook updated …
vicnaum Jul 23, 2025
a21a512
misc: scripts to transfer factory ownerships to LensAccount and Back
vicnaum Jul 28, 2025
4521640
misc: remove owner as manager script
vicnaum Jul 28, 2025
8fea70c
deploy: [Testnet] AccountFactory and LensFactory upgraded to support …
vicnaum Jul 31, 2025
8965422
misc: transferFactoryOwnershipsToSafe script added (and others tweaked)
vicnaum Aug 6, 2025
fc794b0
misc: start-env and end-env scripts tweak
vicnaum Aug 6, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions contracts/core/interfaces/IDependentLock.sol
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);
}
43 changes: 43 additions & 0 deletions contracts/core/upgradeability/DependentLock.sol
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);
}
}
46 changes: 46 additions & 0 deletions contracts/core/upgradeability/ProxyAdminForOwnable.sol
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;
}
}
Loading