-
Notifications
You must be signed in to change notification settings - Fork 50
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
6 changed files
with
166 additions
and
8 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
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
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,52 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity 0.8.17; | ||
|
||
import { LibDiamond } from "../Libraries/LibDiamond.sol"; | ||
import { LibAccess } from "../Libraries/LibAccess.sol"; | ||
import { CannotAuthoriseSelf } from "../Errors/GenericErrors.sol"; | ||
|
||
/// @title Access Manager Facet | ||
/// @author LI.FI (https://li.fi) | ||
/// @notice Provides functionality for managing method level access control | ||
/// @custom:version 1.0.0 | ||
contract ContractInvalidAudit { | ||
/// Events /// | ||
|
||
event ExecutionAllowed(address indexed account, bytes4 indexed method); | ||
event ExecutionDenied(address indexed account, bytes4 indexed method); | ||
|
||
/// External Methods /// | ||
|
||
/// @notice Sets whether a specific address can call a method | ||
/// @param _selector The method selector to set access for | ||
/// @param _executor The address to set method access for | ||
/// @param _canExecute Whether or not the address can execute the specified method | ||
function setCanExecute( | ||
bytes4 _selector, | ||
address _executor, | ||
bool _canExecute | ||
) external { | ||
if (_executor == address(this)) { | ||
revert CannotAuthoriseSelf(); | ||
} | ||
LibDiamond.enforceIsContractOwner(); | ||
_canExecute | ||
? LibAccess.addAccess(_selector, _executor) | ||
: LibAccess.removeAccess(_selector, _executor); | ||
if (_canExecute) { | ||
emit ExecutionAllowed(_executor, _selector); | ||
} else { | ||
emit ExecutionDenied(_executor, _selector); | ||
} | ||
} | ||
|
||
/// @notice Check if a method can be executed by a specific address | ||
/// @param _selector The method selector to check | ||
/// @param _executor The address to check | ||
function addressCanExecuteMethod( | ||
bytes4 _selector, | ||
address _executor | ||
) external view returns (bool) { | ||
return LibAccess.accessStorage().execAccess[_selector][_executor]; | ||
} | ||
} |
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,52 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity 0.8.17; | ||
|
||
import { LibDiamond } from "../Libraries/LibDiamond.sol"; | ||
import { LibAccess } from "../Libraries/LibAccess.sol"; | ||
import { CannotAuthoriseSelf } from "../Errors/GenericErrors.sol"; | ||
|
||
/// @title Access Manager Facet | ||
/// @author LI.FI (https://li.fi) | ||
/// @notice Provides functionality for managing method level access control | ||
/// @custom:version 1.0.0 | ||
contract ContractMultipleAudits { | ||
/// Events /// | ||
|
||
event ExecutionAllowed(address indexed account, bytes4 indexed method); | ||
event ExecutionDenied(address indexed account, bytes4 indexed method); | ||
|
||
/// External Methods /// | ||
|
||
/// @notice Sets whether a specific address can call a method | ||
/// @param _selector The method selector to set access for | ||
/// @param _executor The address to set method access for | ||
/// @param _canExecute Whether or not the address can execute the specified method | ||
function setCanExecute( | ||
bytes4 _selector, | ||
address _executor, | ||
bool _canExecute | ||
) external { | ||
if (_executor == address(this)) { | ||
revert CannotAuthoriseSelf(); | ||
} | ||
LibDiamond.enforceIsContractOwner(); | ||
_canExecute | ||
? LibAccess.addAccess(_selector, _executor) | ||
: LibAccess.removeAccess(_selector, _executor); | ||
if (_canExecute) { | ||
emit ExecutionAllowed(_executor, _selector); | ||
} else { | ||
emit ExecutionDenied(_executor, _selector); | ||
} | ||
} | ||
|
||
/// @notice Check if a method can be executed by a specific address | ||
/// @param _selector The method selector to check | ||
/// @param _executor The address to check | ||
function addressCanExecuteMethod( | ||
bytes4 _selector, | ||
address _executor | ||
) external view returns (bool) { | ||
return LibAccess.accessStorage().execAccess[_selector][_executor]; | ||
} | ||
} |
File renamed without changes.
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,52 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity 0.8.17; | ||
|
||
import { LibDiamond } from "../Libraries/LibDiamond.sol"; | ||
import { LibAccess } from "../Libraries/LibAccess.sol"; | ||
import { CannotAuthoriseSelf } from "../Errors/GenericErrors.sol"; | ||
|
||
/// @title Access Manager Facet | ||
/// @author LI.FI (https://li.fi) | ||
/// @notice Provides functionality for managing method level access control | ||
/// @custom:version 1.0.0 | ||
contract ContractOneAudit { | ||
/// Events /// | ||
|
||
event ExecutionAllowed(address indexed account, bytes4 indexed method); | ||
event ExecutionDenied(address indexed account, bytes4 indexed method); | ||
|
||
/// External Methods /// | ||
|
||
/// @notice Sets whether a specific address can call a method | ||
/// @param _selector The method selector to set access for | ||
/// @param _executor The address to set method access for | ||
/// @param _canExecute Whether or not the address can execute the specified method | ||
function setCanExecute( | ||
bytes4 _selector, | ||
address _executor, | ||
bool _canExecute | ||
) external { | ||
if (_executor == address(this)) { | ||
revert CannotAuthoriseSelf(); | ||
} | ||
LibDiamond.enforceIsContractOwner(); | ||
_canExecute | ||
? LibAccess.addAccess(_selector, _executor) | ||
: LibAccess.removeAccess(_selector, _executor); | ||
if (_canExecute) { | ||
emit ExecutionAllowed(_executor, _selector); | ||
} else { | ||
emit ExecutionDenied(_executor, _selector); | ||
} | ||
} | ||
|
||
/// @notice Check if a method can be executed by a specific address | ||
/// @param _selector The method selector to check | ||
/// @param _executor The address to check | ||
function addressCanExecuteMethod( | ||
bytes4 _selector, | ||
address _executor | ||
) external view returns (bool) { | ||
return LibAccess.accessStorage().execAccess[_selector][_executor]; | ||
} | ||
} |