// SPDX-License-Identifier: MIT pragma solidity ^0.8.24; import "@openzeppelin/contracts/access/AccessControl.sol"; import "@openzeppelin/contracts/token/ERC1155/IERC1155.sol"; contract QuantumMaintenanceRegistry is AccessControl { bytes32 public constant OPERATOR_ROLE = keccak256("OPERATOR_ROLE"); IERC1155 public immutable recordToken; struct ArchiveRecord { address archivedBy; string beneficiary; string usageLocation; string archiveReason; uint64 archivedAt; bool exists; } mapping(uint256 => ArchiveRecord) public archives; event MaintenanceRecordArchived( uint256 indexed tokenId, address indexed archivedBy, string beneficiary, string usageLocation ); constructor(address admin, address recordTokenAddress) { recordToken = IERC1155(recordTokenAddress); _grantRole(DEFAULT_ADMIN_ROLE, admin); _grantRole(OPERATOR_ROLE, admin); } function archiveRecord( uint256 tokenId, string calldata beneficiary, string calldata usageLocation, string calldata archiveReason ) external { require(!archives[tokenId].exists, "already archived"); require(recordToken.balanceOf(msg.sender, tokenId) >= 1, "not token holder"); recordToken.safeTransferFrom(msg.sender, address(this), tokenId, 1, ""); archives[tokenId] = ArchiveRecord({ archivedBy: msg.sender, beneficiary: beneficiary, usageLocation: usageLocation, archiveReason: archiveReason, archivedAt: uint64(block.timestamp), exists: true }); emit MaintenanceRecordArchived(tokenId, msg.sender, beneficiary, usageLocation); } }