📄 Ownable.sol
D-OPEN SOVEREIGN

Documentation & Insights

@dev Initializes the contract setting the address provided by the deployer as the initial owner.
@dev Throws if called by any account other than the owner.
@dev Returns the address of the current owner.
@dev Throws if the sender is not the owner.
@dev Leaves the contract without owner. It will not be possible to call
`onlyOwner` functions. Can only be called by the current owner.

NOTE: Renouncing ownership will leave the contract without an owner,
thereby disabling any functionality that is only available to the owner.
@dev Transfers ownership of the contract to a new account (`newOwner`).
Can only be called by the current owner.
@dev Transfers ownership of the contract to a new account (`newOwner`).
Internal function without access restriction.
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
20import {ErrorLibrary} from "./ErrorLibrary.sol";
21
22abstract contract Ownable  {
23    address private _owner;
24
25    event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
26
27    /**
28     * @dev Initializes the contract setting the address provided by the deployer as the initial owner.
29     */
30    constructor(address initialOwner) {
31        if (initialOwner == address(0)) {
32            revert ErrorLibrary.OwnableInvalidOwner(address(0));
33        }
34        _transferOwnership(initialOwner);
35    }
36
37    /**
38     * @dev Throws if called by any account other than the owner.
39     */
40    modifier onlyOwner() {
41        _checkOwner();
42        _;
43    }
44
45    /**
46     * @dev Returns the address of the current owner.
47     */
48    function owner() public view virtual returns (address) {
49        return _owner;
50    }
51
52    /**
53     * @dev Throws if the sender is not the owner.
54     */
55    function _checkOwner() internal view virtual {
56        if (owner() != msg.sender) {
57            revert ErrorLibrary.OwnableUnauthorizedAccount(msg.sender);
58        }
59    }
60
61    /**
62     * @dev Leaves the contract without owner. It will not be possible to call
63     * `onlyOwner` functions. Can only be called by the current owner.
64     *
65     * NOTE: Renouncing ownership will leave the contract without an owner,
66     * thereby disabling any functionality that is only available to the owner.
67     */
68    function renounceOwnership() public virtual onlyOwner {
69        _transferOwnership(address(0));
70    }
71
72    /**
73     * @dev Transfers ownership of the contract to a new account (`newOwner`).
74     * Can only be called by the current owner.
75     */
76    function transferOwnership(address newOwner) public virtual onlyOwner {
77        if (newOwner == address(0)) {
78            revert ErrorLibrary.OwnableInvalidOwner(address(0));
79        }
80        _transferOwnership(newOwner);
81    }
82
83    /**
84     * @dev Transfers ownership of the contract to a new account (`newOwner`).
85     * Internal function without access restriction.
86     */
87    function _transferOwnership(address newOwner) internal virtual {
88        address oldOwner = _owner;
89        _owner = newOwner;
90        emit OwnershipTransferred(oldOwner, newOwner);
91    }
92}
93