<< All versions
Skill v1.0.0
currentAutomated scan100/100cyotee/cyotee-claude-plugin-crane/crane-access
──Details
PublishedDecember 6, 2026 at 05:07 AM
Content Hashsha256:3c60ab2fa318b1c4...
Git SHA31b61f41fccb
──Files
Files (1 file, 6.6 KB)
SKILL.md6.6 KBactive
SKILL.md · 257 lines · 6.6 KB
name: crane-access description: This skill should be used when the user asks about "access control", "onlyOwner", "onlyOperator", "ownership transfer", "MultiStepOwnable", "ERC8023", "operable pattern", "function-level permissions", "reentrancy protection", "reentrancy lock", or needs to restrict function access in Crane Diamond contracts. metadata: version: "1.0.0"
Crane Access Control Components
Crane provides three access control patterns for Diamond proxies: MultiStepOwnable (ERC-8023), Operable, and ReentrancyLock.
Component Selection
| Need | Component | Purpose | |
|---|---|---|---|
| Ownership with time-lock | MultiStepOwnable | Two-step ownership transfer with buffer period | |
| Delegated permissions | Operable | Global and function-level operator authorization | |
| Reentrancy protection | ReentrancyLock | Transient storage lock for cross-function reentrancy |
Quick Start: Add Access Control
solidity
// Import modifiersimport {MultiStepOwnableModifiers} from "@crane/contracts/access/ERC8023/MultiStepOwnableModifiers.sol";import {OperableModifiers} from "@crane/contracts/access/operable/OperableModifiers.sol";import {ReentrancyLockModifiers} from "@crane/contracts/access/reentrancy/ReentrancyLockModifiers.sol";// Use in your Target contractcontract MyTarget is MultiStepOwnableModifiers, OperableModifiers, ReentrancyLockModifiers {function adminOnly() external onlyOwner {// Only owner can call}function operatorOnly() external onlyOperator {// Global operators or function-specific operators}function ownerOrOperator() external onlyOwnerOrOperator {// Either owner or operator can call}function noReentrant() external nonReentrant {// Protected from reentrancy}}
MultiStepOwnable (ERC-8023)
Time-locked two-step ownership transfer with buffer period.
Storage
solidity
struct Storage {address owner;address pendingOwner;bool pendingOwnerConfirmed;uint256 ownershipBufferPeriod; // e.g., 1 daysuint256 bufferPeriodEnd;}
Ownership Transfer Flow
- Initiate: Owner calls
initiateOwnershipTransfer(newOwner) - Wait: Buffer period must elapse
- Confirm: Owner calls
confirmOwnershipTransfer(newOwner) - Accept: New owner calls
acceptOwnershipTransfer()
solidity
// Step 1: Current owner initiatesMultiStepOwnableRepo._initiateOwnershipTransfer(newOwner);// Step 2: Wait for buffer period (e.g., 1 day)// Step 3: Current owner confirmsMultiStepOwnableRepo._confirmOwnershipTransfer(newOwner);// Step 4: New owner acceptsMultiStepOwnableRepo._acceptOwnershipTransfer();// Owner can cancel anytime before acceptanceMultiStepOwnableRepo._cancelPendingOwnershipTransfer();
Guard Functions
solidity
// Revert if msg.sender is not ownerMultiStepOwnableRepo._onlyOwner();// Revert if msg.sender is not pending ownerMultiStepOwnableRepo._onlyPendingOwner();
Modifiers
solidity
modifier onlyOwner() {MultiStepOwnableRepo._onlyOwner();_;}
Initialization
solidity
// In DFPkg.initAccount()MultiStepOwnableRepo._initialize(initialOwner, // First owner1 days // Buffer period for transfers);
Operable Pattern
Delegated authorization for global and function-level permissions.
Storage
solidity
struct Storage {mapping(address => bool) isOperator; // Global operatorsmapping(bytes4 func => mapping(address => bool)) isOperatorFor; // Function-level}
Authorization Levels
- Global Operator: Can call any function protected by
onlyOperator - Function Operator: Can only call specific functions
Setting Permissions (Owner Only)
solidity
// Grant/revoke global operator statusOperableRepo._setOperatorStatus(operatorAddress, true); // GrantOperableRepo._setOperatorStatus(operatorAddress, false); // Revoke// Grant/revoke function-level operatorOperableRepo._setFunctionOperatorStatus(IMyContract.someFunction.selector, // Function selectoroperatorAddress, // Operatortrue // Approval);
Checking Permissions
solidity
// Check global operatorbool isGlobal = OperableRepo._isOperator(account);// Check function operatorbool isForFunc = OperableRepo._isFunctionOperator(IMyContract.someFunction.selector,account);
Guard Functions
solidity
// Revert if not global OR function operator for msg.sigOperableRepo._onlyOperator();// Revert if not owner AND not operatorOperableRepo._onlyOwnerOrOperator();
Modifiers
solidity
// Only global or function-level operatorsmodifier onlyOperator() {OperableRepo._onlyOperator();_;}// Owner OR any operatormodifier onlyOwnerOrOperator() {OperableRepo._onlyOwnerOrOperator();_;}
ReentrancyLock
Transient storage-based reentrancy protection (EIP-1153).
Usage
solidity
modifier nonReentrant() {ReentrancyLockRepo._onlyUnlocked();ReentrancyLockRepo._lock();_;ReentrancyLockRepo._unlock();}
Functions
solidity
// Lock the reentrancy guardReentrancyLockRepo._lock();// Unlock the reentrancy guardReentrancyLockRepo._unlock();// Check if lockedbool locked = ReentrancyLockRepo._isLocked();// Revert if locked (guard function)ReentrancyLockRepo._onlyUnlocked();
Benefits
- Uses transient storage (cleared after transaction)
- Gas efficient compared to storage-based guards
- Protects against cross-function reentrancy
Component Files
| Component | Files | |
|---|---|---|
| MultiStepOwnable | MultiStepOwnableRepo.sol, MultiStepOwnableModifiers.sol, MultiStepOwnableTarget.sol, MultiStepOwnableFacet.sol | |
| Operable | OperableRepo.sol, OperableModifiers.sol, OperableTarget.sol, OperableFacet.sol | |
| ReentrancyLock | ReentrancyLockRepo.sol, ReentrancyLockModifiers.sol, ReentrancyLockTarget.sol, ReentrancyLockFacet.sol |
AccessFacetFactoryService
Deploy access control facets:
solidity
import {AccessFacetFactoryService} from "@crane/contracts/access/AccessFacetFactoryService.sol";// Deploy MultiStepOwnable facetIFacet ownerFacet = AccessFacetFactoryService.deployMultiStepOwnableFacet(create3Factory);// Deploy Operable facetIFacet operableFacet = AccessFacetFactoryService.deployOperableFacet(create3Factory);// Deploy ReentrancyLock facetIFacet reentrancyFacet = AccessFacetFactoryService.deployReentrancyLockFacet(create3Factory);
Additional Resources
Reference Files
For detailed patterns and examples:
- `references/access-patterns.md` - Complete access control integration patterns