IAccessManager.sol 4.9 KB

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