Skip to content

Commit

Permalink
from cloneable to uups
Browse files Browse the repository at this point in the history
  • Loading branch information
novaknole committed Sep 25, 2024
1 parent 676ee89 commit e800751
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 8 deletions.
16 changes: 12 additions & 4 deletions packages/contracts/src/Admin.sol
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {IMembership} from "@aragon/osx-commons-contracts/src/plugin/extensions/m

// solhint-disable-next-line max-line-length
import {ProposalUpgradeable} from "@aragon/osx-commons-contracts/src/plugin/extensions/proposal/ProposalUpgradeable.sol";
import {PluginCloneable} from "@aragon/osx-commons-contracts/src/plugin/PluginCloneable.sol";
import {PluginUUPSUpgradeable} from "@aragon/osx-commons-contracts/src/plugin/PluginUUPSUpgradeable.sol";
import {IDAO} from "@aragon/osx-commons-contracts/src/dao/IDAO.sol";
import {IProposal} from "@aragon/osx-commons-contracts/src/plugin/extensions/proposal/IProposal.sol";

Expand All @@ -17,7 +17,7 @@ import {IProposal} from "@aragon/osx-commons-contracts/src/plugin/extensions/pro
/// @notice The admin governance plugin giving execution permission on the DAO to a single address.
/// @dev v1.2 (Release 1, Build 2)
/// @custom:security-contact [email protected]
contract Admin is IMembership, PluginCloneable, ProposalUpgradeable {
contract Admin is IMembership, PluginUUPSUpgradeable, ProposalUpgradeable {
using SafeCastUpgradeable for uint256;

/// @notice The [ERC-165](https://eips.ethereum.org/EIPS/eip-165) interface ID of the contract.
Expand All @@ -34,7 +34,7 @@ contract Admin is IMembership, PluginCloneable, ProposalUpgradeable {
/// @param _dao The associated DAO.
/// @dev This method is required to support [ERC-1167](https://eips.ethereum.org/EIPS/eip-1167).
function initialize(IDAO _dao, TargetConfig calldata _targetConfig) external initializer {
__PluginCloneable_init(_dao);
__PluginUUPSUpgradeable_init(_dao);

_setTargetConfig(_targetConfig);

Expand All @@ -46,7 +46,7 @@ contract Admin is IMembership, PluginCloneable, ProposalUpgradeable {
/// @return Returns `true` if the interface is supported.
function supportsInterface(
bytes4 _interfaceId
) public view override(PluginCloneable, ProposalUpgradeable) returns (bool) {
) public view override(PluginUUPSUpgradeable, ProposalUpgradeable) returns (bool) {
return
_interfaceId == ADMIN_INTERFACE_ID ||
_interfaceId == type(IMembership).interfaceId ||
Expand Down Expand Up @@ -142,4 +142,12 @@ contract Admin is IMembership, PluginCloneable, ProposalUpgradeable {

emit ProposalExecuted(proposalId);
}

/// @notice Internal method authorizing the upgrade of the contract via the [upgradeability mechanism for UUPS proxies](https://docs.openzeppelin.com/contracts/4.x/api/proxy#UUPSUpgradeable) (see [ERC-1822](https://eips.ethereum.org/EIPS/eip-1822)).

Check failure on line 146 in packages/contracts/src/Admin.sol

View workflow job for this annotation

GitHub Actions / checks

Line length must be no more than 120 but current length is 253
/// @dev The Upgradeability disabled.
function _authorizeUpgrade(
address
) internal virtual override auth(UPGRADE_PLUGIN_PERMISSION_ID) {
revert NotAllowedOperation();
}
}
8 changes: 4 additions & 4 deletions packages/contracts/src/AdminSetup.sol
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {PluginSetup} from "@aragon/osx-commons-contracts/src/plugin/setup/Plugin
import {PermissionLib} from "@aragon/osx-commons-contracts/src/permission/PermissionLib.sol";
import {ProxyLib} from "@aragon/osx-commons-contracts/src/utils/deployment/ProxyLib.sol";
import {IDAO} from "@aragon/osx-commons-contracts/src/dao/IDAO.sol";
import {PluginCloneable} from "@aragon/osx-commons-contracts/src/plugin/PluginCloneable.sol";
import {PluginUUPSUpgradeable} from "@aragon/osx-commons-contracts/src/plugin/PluginUUPSUpgradeable.sol";

import {Admin} from "./Admin.sol";

Expand Down Expand Up @@ -36,9 +36,9 @@ contract AdminSetup is PluginSetup {
bytes calldata _data
) external returns (address plugin, PreparedSetupData memory preparedSetupData) {
// Decode `_data` to extract the params needed for cloning and initializing the `Admin` plugin.
(address admin, PluginCloneable.TargetConfig memory targetConfig) = abi.decode(
(address admin, PluginUUPSUpgradeable.TargetConfig memory targetConfig) = abi.decode(
_data,
(address, PluginCloneable.TargetConfig)
(address, PluginUUPSUpgradeable.TargetConfig)
);

if (admin == address(0)) {
Expand All @@ -47,7 +47,7 @@ contract AdminSetup is PluginSetup {

// Clone and initialize the plugin contract.
bytes memory initData = abi.encodeCall(Admin.initialize, (IDAO(_dao), targetConfig));
plugin = IMPLEMENTATION.deployMinimalProxy(initData);
plugin = IMPLEMENTATION.deployUUPSProxy(initData);

// Prepare permissions
PermissionLib.MultiTargetPermission[]
Expand Down

0 comments on commit e800751

Please sign in to comment.