📄 Scientist.sol
D-OPEN SOVEREIGN
1/*
2 * Copyright (c) 2026 DataPond D-Library Pty Ltd. ("The Sanctuary")
3 * Non-Profit Public Library — The World Library
4 * 
5 * D-SAFE Certification issued by POND Enterprise.
6 * Published under the D-Open Code Sovereign Licence v1.0 framework
7 * DataPond D-Library All exclusive Right reserved on modifiying the code - CC Attribution to data pond, Non modifiable, Non Commercial.
8 * https://registry.world.bibliotech.com/licence
9 * Source code donated to DataPond D-Library by it's author: data pond.
10 * 
11 * Technical Guardian ("The Shield"): Pond Enterprise Pty Ltd. (ACN 694 747 987)
12 * All liability claims about D-SAFE certification issues coming from the published D-Safe direction must be addressed with Pond Enterprise Pty Ltd.
13 * Code Modification automatically voids the certified liability protection provided by Pond Enterprise.
14 */
15
16// SPDX-License-Identifier: Apache-2.0
17pragma solidity ^0.8.24;
18
19import {IScientistStorage} from "./IScientistStorage.sol";
20import {ErrorLibrary} from "./ErrorLibrary.sol";
21import {ScientistStorage} from "./ScientistStorage.sol";
22
23abstract contract Scientist {
24    IScientistStorage public scientistStorage;
25    // Keep an enum in this facade so callers can pass typed values if desired.
26    // ABI encodes enums as uint8, so this is compatible with the storage contract.
27    enum ActionType {
28        Visit,
29        Download,
30        Share,
31        Rate,
32        VisitPart,
33        DownloadPart,
34        SharePart,
35        RatePart,
36        SetName,
37        SetDescription,
38        Register,
39        LocationWrite
40    }
41    event ScientistStorageSet(address indexed storageAddr);
42    address _scientistOwner;
43    modifier onlyScientistOwner() {
44        if (msg.sender!= _scientistOwner) {
45            revert ErrorLibrary.OwnableInvalidOwner(msg.sender);
46        }
47        _;
48    }
49    constructor() {
50        _scientistOwner = msg.sender;
51        // Ownable initialization will be handled by the inheriting Factory contract
52    }
53    // Admin: set the storage contract reference
54    // Note: Access control handled by inheriting contract (Factory)
55    function setScientistStorage(address storageAddr) public  onlyScientistOwner {
56        if (storageAddr == address(0)) {
57            revert ErrorLibrary.EmptyAddress();
58        }
59        scientistStorage = IScientistStorage(storageAddr);
60        emit ScientistStorageSet(storageAddr);
61    }
62    //    function storeBatchStats(uint64[] calldata objectIds) external {
63    //        // Ensure this method exists and calls scientistStorage
64    //        for(uint i = 0; i < objectIds.length; i++) {
65    //            scientistStorage.storeNewWrite(msg.sender, objectIds[i]);
66    //        }
67    //    }
68
69    // ===== Authorized writes (internal — only callable via Factory's own logic) =====
70    function storeBatchStats(uint256[] calldata patches,  uint16[] calldata textIndex, string[] calldata textData) internal {
71        scientistStorage.storeBatchStats(patches, textIndex, textData);
72    }
73    function storeNewRegister(uint16 countryCode) internal {
74        scientistStorage.storeNewRegister(countryCode);
75    }
76    function storeNewWrite(uint16 countryCode) internal {
77        scientistStorage.storeNewWrite(countryCode);
78    }
79    // ===== Read passthroughs removed =====
80    // Read operations should be performed directly on ScientistStorage contract
81}