📄 Backup.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
19//import {Ownable} from "./Ownable.sol";
20import {IBackup} from "./IBackup.sol";
21import {ErrorLibrary} from "./ErrorLibrary.sol";
22
23contract Backup  {
24
25    IBackup public backupStorage;
26
27    event BackupStorageSet(address indexed storageAddr);
28
29    address _backupOwner;
30    constructor()  {
31        _backupOwner = msg.sender;
32    }
33
34    modifier onlyBackupOwner() {
35        if (msg.sender != _backupOwner) {
36            revert ErrorLibrary.OwnableInvalidOwner(msg.sender);
37        }
38        _;
39    }
40    // Admin: set/replace storage contract
41    function setBackupStorage(address storageAddr) public onlyBackupOwner {
42        if (storageAddr == address(0)) {
43            revert ErrorLibrary.EmptyAddress();
44        }
45        backupStorage = IBackup(storageAddr);
46        emit BackupStorageSet(storageAddr);
47    }
48
49    function userLevel(uint32 userId) external view returns ( uint8  level ) {
50        return backupStorage.userLevel(userId);
51    }
52
53    function nbWrites(uint32 userId) external view returns (uint256) {
54        return backupStorage.nbWrites(userId);
55    }
56
57    function loadActions(uint32 userId) external view  returns (uint256[] memory compressedActions, uint256[] memory indexes, string[] memory stringIndexes) {
58        return backupStorage.loadActions(userId);
59    }
60
61    function loadActionsSince(uint32 userId, uint16 index) external view  returns (uint256[] memory compressedActions, uint256[] memory indexes, string[] memory stringIndexes) {
62        return backupStorage.loadActionsSince(userId, index);
63    }
64
65}