@bananapus/ownable-v6 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,45 @@
1
+ // SPDX-License-Identifier: UNLICENSED
2
+ pragma solidity ^0.8.23;
3
+
4
+ import {JBOwnable, JBOwnableOverrides} from "../../src/JBOwnable.sol";
5
+ import {IJBProjects} from "@bananapus/core-v6/src/interfaces/IJBProjects.sol";
6
+ import {IJBPermissions} from "@bananapus/core-v6/src/interfaces/IJBPermissions.sol";
7
+
8
+ contract MockOwnable is JBOwnable {
9
+ event ProtectedMethodCalled();
10
+
11
+ uint256 permissionId;
12
+
13
+ function setPermission(uint256 newPermissionId) external {
14
+ permissionId = newPermissionId;
15
+ }
16
+
17
+ constructor(
18
+ IJBProjects projects,
19
+ IJBPermissions permissions,
20
+ address initialOwner,
21
+ uint88 initialprojectIdOwner
22
+ )
23
+ JBOwnable(permissions, projects, initialOwner, initialprojectIdOwner)
24
+ {}
25
+
26
+ function protectedMethod() external onlyOwner {
27
+ emit ProtectedMethodCalled();
28
+ }
29
+
30
+ function protectedMethodWithRequirePermission() external {
31
+ uint256 projectId = jbOwner.projectId;
32
+
33
+ _requirePermissionFrom({account: PROJECTS.ownerOf(projectId), projectId: projectId, permissionId: permissionId});
34
+
35
+ emit ProtectedMethodCalled();
36
+ }
37
+
38
+ function protectedMethodWithRequireFromOwner() external {
39
+ uint256 projectId = jbOwner.projectId;
40
+
41
+ _requirePermissionFrom({account: PROJECTS.ownerOf(projectId), projectId: projectId, permissionId: permissionId});
42
+
43
+ emit ProtectedMethodCalled();
44
+ }
45
+ }