generated from aragon/osx-plugin-template-hardhat
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
456 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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,54 @@ | ||
// SPDX-License-Identifier: AGPL-3.0-or-later | ||
|
||
pragma solidity 0.8.17; | ||
|
||
import {PermissionCondition} from "@aragon/osx/core/permission/PermissionCondition.sol"; | ||
import {PermissionManager} from "@aragon/osx/core/permission/PermissionManager.sol"; | ||
|
||
/// @notice The condition associated with `TestSharedPlugin` | ||
contract MembersAccessExecuteCondition is PermissionCondition { | ||
/// @notice The ID of the permission required to create proposals on the main voting plugin. | ||
bytes32 public constant MEMBER_PERMISSION_ID = keccak256("MEMBER_PERMISSION"); | ||
|
||
/// @notice The address of the contract where the permission can be granted | ||
address private targetContract; | ||
|
||
/// @notice The constructor of the condition | ||
/// @param _targetContract The address of the contract where the permission can be granted | ||
constructor(address _targetContract) { | ||
targetContract = _targetContract; | ||
} | ||
|
||
function getSelector(bytes memory _data) public pure returns (bytes4 sig) { | ||
assembly { | ||
sig := mload(add(_data, 32)) | ||
} | ||
} | ||
|
||
/// @notice Checks whether the current action wants to grant membership on the predefined address | ||
function isGranted( | ||
address _where, | ||
address _who, | ||
bytes32 _permissionId, | ||
bytes calldata _data | ||
) external view returns (bool) { | ||
(_where, _who, _permissionId); | ||
|
||
bytes4 _requestedFuncSig = getSelector(_data); | ||
if ( | ||
_requestedFuncSig != PermissionManager.grant.selector && | ||
_requestedFuncSig != PermissionManager.revoke.selector | ||
) return false; | ||
|
||
// Decode the call being requested | ||
(address _requestedWhere, , bytes32 _requestedPermission) = abi.decode( | ||
_data[4:], | ||
(address, address, bytes32) | ||
); | ||
|
||
if (_requestedWhere != targetContract) return false; | ||
else if (_requestedPermission != MEMBER_PERMISSION_ID) return false; | ||
|
||
return true; | ||
} | ||
} |
Oops, something went wrong.