Skip to content
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

(groups): upgradeableRenounceableProxy for group policies #78

Merged
merged 16 commits into from
Nov 18, 2024
Merged
Changes from 1 commit
Commits
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
49 changes: 49 additions & 0 deletions src/groups/UpgradeableRenounceableProxy.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
// SPDX-License-Identifier: AGPL-3.0-only
pragma solidity >=0.8.24;

import "@openzeppelin/contracts/proxy/ERC1967/ERC1967Proxy.sol";

benjaminbollen marked this conversation as resolved.
Show resolved Hide resolved
contract UpgradeableRenounceableProxy is ERC1967Proxy {
// Errors

error OnlyAdminError();

error BlockReceive();

// Modifier

modifier onlyAdmin() {
if (msg.sender != ERC1967Utils.getAdmin()) {
revert OnlyAdminError();
}
_;
}

// Constructor

constructor(address _implementation, bytes memory _data) ERC1967Proxy(_implementation, _data) {
// set the admin to the deployer
ERC1967Utils.changeAdmin(msg.sender);
}

function implementation() external view returns (address) {
return _implementation();
}

function upgradeToAndCall(address _newImplementation, bytes memory _data) external onlyAdmin {
ERC1967Utils.upgradeToAndCall(_newImplementation, _data);
}

/**
* @dev It renounces the ability to upgrade the contract, by setting the admin to 0x01.
*/
function renounceUpgradeability() external onlyAdmin {
ERC1967Utils.changeAdmin(address(0x01));
}
benjaminbollen marked this conversation as resolved.
Show resolved Hide resolved

// Fallback function

receive() external payable {
revert BlockReceive();
}
}
Loading