IAccessManager.sol 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. // SPDX-License-Identifier: MIT
  2. // OpenZeppelin Contracts (last updated v5.0.0-rc.0) (access/manager/IAccessManager.sol)
  3. pragma solidity ^0.8.20;
  4. import {IAccessManaged} from "./IAccessManaged.sol";
  5. import {Time} from "../../utils/types/Time.sol";
  6. interface IAccessManager {
  7. /**
  8. * @dev A delayed operation was scheduled.
  9. */
  10. event OperationScheduled(
  11. bytes32 indexed operationId,
  12. uint32 indexed nonce,
  13. uint48 schedule,
  14. address caller,
  15. address target,
  16. bytes data
  17. );
  18. /**
  19. * @dev A scheduled operation was executed.
  20. */
  21. event OperationExecuted(bytes32 indexed operationId, uint32 indexed nonce);
  22. /**
  23. * @dev A scheduled operation was canceled.
  24. */
  25. event OperationCanceled(bytes32 indexed operationId, uint32 indexed nonce);
  26. event RoleLabel(uint64 indexed roleId, string label);
  27. /**
  28. * @dev Emitted when `account` is granted `roleId`.
  29. *
  30. * NOTE: The meaning of the `since` argument depends on the `newMember` argument.
  31. * If the role is granted to a new member, the `since` argument indicates when the account becomes a member of the role,
  32. * otherwise it indicates the execution delay for this account and roleId is updated.
  33. */
  34. event RoleGranted(uint64 indexed roleId, address indexed account, uint32 delay, uint48 since, bool newMember);
  35. event RoleRevoked(uint64 indexed roleId, address indexed account);
  36. event RoleAdminChanged(uint64 indexed roleId, uint64 indexed admin);
  37. event RoleGuardianChanged(uint64 indexed roleId, uint64 indexed guardian);
  38. event RoleGrantDelayChanged(uint64 indexed roleId, uint32 delay, uint48 since);
  39. event TargetClosed(address indexed target, bool closed);
  40. event TargetFunctionRoleUpdated(address indexed target, bytes4 selector, uint64 indexed roleId);
  41. event TargetAdminDelayUpdated(address indexed target, uint32 delay, uint48 since);
  42. error AccessManagerAlreadyScheduled(bytes32 operationId);
  43. error AccessManagerNotScheduled(bytes32 operationId);
  44. error AccessManagerNotReady(bytes32 operationId);
  45. error AccessManagerExpired(bytes32 operationId);
  46. error AccessManagerLockedAccount(address account);
  47. error AccessManagerLockedRole(uint64 roleId);
  48. error AccessManagerBadConfirmation();
  49. error AccessManagerUnauthorizedAccount(address msgsender, uint64 roleId);
  50. error AccessManagerUnauthorizedCall(address caller, address target, bytes4 selector);
  51. error AccessManagerUnauthorizedConsume(address target);
  52. error AccessManagerUnauthorizedCancel(address msgsender, address caller, address target, bytes4 selector);
  53. error AccessManagerInvalidInitialAdmin(address initialAdmin);
  54. function canCall(
  55. address caller,
  56. address target,
  57. bytes4 selector
  58. ) external view returns (bool allowed, uint32 delay);
  59. function hashOperation(address caller, address target, bytes calldata data) external view returns (bytes32);
  60. function expiration() external view returns (uint32);
  61. function isTargetClosed(address target) external view returns (bool);
  62. function getTargetFunctionRole(address target, bytes4 selector) external view returns (uint64);
  63. function getTargetAdminDelay(address target) external view returns (uint32);
  64. function getRoleAdmin(uint64 roleId) external view returns (uint64);
  65. function getRoleGuardian(uint64 roleId) external view returns (uint64);
  66. function getRoleGrantDelay(uint64 roleId) external view returns (uint32);
  67. function getAccess(uint64 roleId, address account) external view returns (uint48, uint32, uint32, uint48);
  68. function hasRole(uint64 roleId, address account) external view returns (bool, uint32);
  69. function labelRole(uint64 roleId, string calldata label) external;
  70. function grantRole(uint64 roleId, address account, uint32 executionDelay) external;
  71. function revokeRole(uint64 roleId, address account) external;
  72. function renounceRole(uint64 roleId, address callerConfirmation) external;
  73. function setRoleAdmin(uint64 roleId, uint64 admin) external;
  74. function setRoleGuardian(uint64 roleId, uint64 guardian) external;
  75. function setGrantDelay(uint64 roleId, uint32 newDelay) external;
  76. function setTargetFunctionRole(address target, bytes4[] calldata selectors, uint64 roleId) external;
  77. function setTargetAdminDelay(address target, uint32 newDelay) external;
  78. function setTargetClosed(address target, bool closed) external;
  79. function getSchedule(bytes32 id) external view returns (uint48);
  80. function getNonce(bytes32 id) external view returns (uint32);
  81. function schedule(address target, bytes calldata data, uint48 when) external returns (bytes32, uint32);
  82. function execute(address target, bytes calldata data) external payable returns (uint32);
  83. function cancel(address caller, address target, bytes calldata data) external returns (uint32);
  84. function consumeScheduledOp(address caller, bytes calldata data) external;
  85. function updateAuthority(address target, address newAuthority) external;
  86. }