@bananapus/ownable-v6 0.0.24 → 0.0.25
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.
- package/README.md +1 -1
- package/package.json +3 -3
- package/references/runtime.md +1 -1
- package/src/JBOwnableOverrides.sol +19 -9
package/README.md
CHANGED
|
@@ -62,7 +62,7 @@ This package is a small ownership adapter:
|
|
|
62
62
|
|
|
63
63
|
1. `test/Ownable.t.sol`
|
|
64
64
|
2. `test/OwnableAttacks.t.sol`
|
|
65
|
-
3. `test/
|
|
65
|
+
3. `test/RegressionUnmintedProjectHijack.t.sol`
|
|
66
66
|
4. `test/regression/BurnLockProtection.t.sol`
|
|
67
67
|
|
|
68
68
|
## Install
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bananapus/ownable-v6",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.25",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -19,8 +19,8 @@
|
|
|
19
19
|
"node": ">=20.0.0"
|
|
20
20
|
},
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"@bananapus/core-v6": "0.0.
|
|
23
|
-
"@bananapus/permission-ids-v6": "0.0.
|
|
22
|
+
"@bananapus/core-v6": "^0.0.54",
|
|
23
|
+
"@bananapus/permission-ids-v6": "^0.0.25",
|
|
24
24
|
"@openzeppelin/contracts": "5.6.1"
|
|
25
25
|
},
|
|
26
26
|
"scripts": {
|
package/references/runtime.md
CHANGED
|
@@ -16,4 +16,4 @@
|
|
|
16
16
|
- [`test/Ownable.t.sol`](../test/Ownable.t.sol) for baseline behavior.
|
|
17
17
|
- [`test/OwnableEdgeCases.t.sol`](../test/OwnableEdgeCases.t.sol) and [`test/OwnableAttacks.t.sol`](../test/OwnableAttacks.t.sol) for edge and adversarial cases.
|
|
18
18
|
- [`test/OwnableInvariantTests.sol`](../test/OwnableInvariantTests.sol) for broader invariants.
|
|
19
|
-
- [`test/regression/BurnLockProtection.t.sol`](../test/regression/BurnLockProtection.t.sol), [`test/regression/ZeroAddressValidation.t.sol`](../test/regression/ZeroAddressValidation.t.sol), and [`test/
|
|
19
|
+
- [`test/regression/BurnLockProtection.t.sol`](../test/regression/BurnLockProtection.t.sol), [`test/regression/ZeroAddressValidation.t.sol`](../test/regression/ZeroAddressValidation.t.sol), and [`test/RegressionUnmintedProjectHijack.t.sol`](../test/RegressionUnmintedProjectHijack.t.sol) for the regressions most likely to matter in review.
|
|
@@ -21,9 +21,19 @@ abstract contract JBOwnableOverrides is Context, JBPermissioned, IJBOwnable {
|
|
|
21
21
|
// --------------------------- custom errors ------------------------- //
|
|
22
22
|
//*********************************************************************//
|
|
23
23
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
24
|
+
/// @notice Thrown when an ownership transfer or constructor input does not identify exactly one valid owner.
|
|
25
|
+
/// @param newOwner The address owner being set.
|
|
26
|
+
/// @param projectId The project owner ID being set.
|
|
27
|
+
error JBOwnableOverrides_InvalidNewOwner(address newOwner, uint256 projectId);
|
|
28
|
+
|
|
29
|
+
/// @notice Thrown when project-based ownership points to a project that has not been minted.
|
|
30
|
+
/// @param projectId The project ID that was requested.
|
|
31
|
+
/// @param projectCount The current number of minted projects.
|
|
32
|
+
error JBOwnableOverrides_ProjectDoesNotExist(uint256 projectId, uint256 projectCount);
|
|
33
|
+
|
|
34
|
+
/// @notice Thrown when project-based ownership is requested without a `JBProjects` contract.
|
|
35
|
+
/// @param projectId The project owner ID that requires a non-zero `JBProjects` contract.
|
|
36
|
+
error JBOwnableOverrides_ZeroAddressProjectsWithProjectOwner(uint256 projectId);
|
|
27
37
|
|
|
28
38
|
//*********************************************************************//
|
|
29
39
|
// ---------------- public immutable stored properties --------------- //
|
|
@@ -79,7 +89,7 @@ abstract contract JBOwnableOverrides is Context, JBPermissioned, IJBOwnable {
|
|
|
79
89
|
// Deploying with projects=address(0) and a non-zero projectId would permanently disable
|
|
80
90
|
// ownership resolution, as all ownerOf() calls would revert on the zero address.
|
|
81
91
|
if (initialProjectIdOwner != 0 && address(projects) == address(0)) {
|
|
82
|
-
revert JBOwnableOverrides_ZeroAddressProjectsWithProjectOwner();
|
|
92
|
+
revert JBOwnableOverrides_ZeroAddressProjectsWithProjectOwner({projectId: initialProjectIdOwner});
|
|
83
93
|
}
|
|
84
94
|
|
|
85
95
|
// We force the inheriting contract to set an owner, as there is a low chance someone will use `JBOwnable` to
|
|
@@ -87,7 +97,7 @@ abstract contract JBOwnableOverrides is Context, JBPermissioned, IJBOwnable {
|
|
|
87
97
|
// It's more likely both were accidentally set to `0`. If you really want an unowned contract, set the owner to
|
|
88
98
|
// an address and call `renounceOwnership()` in the constructor body.
|
|
89
99
|
if (initialProjectIdOwner == 0 && initialOwner == address(0)) {
|
|
90
|
-
revert JBOwnableOverrides_InvalidNewOwner();
|
|
100
|
+
revert JBOwnableOverrides_InvalidNewOwner({newOwner: initialOwner, projectId: initialProjectIdOwner});
|
|
91
101
|
}
|
|
92
102
|
|
|
93
103
|
// No explicit project existence check here — if `initialProjectIdOwner` refers to an unminted project,
|
|
@@ -198,7 +208,7 @@ abstract contract JBOwnableOverrides is Context, JBPermissioned, IJBOwnable {
|
|
|
198
208
|
function transferOwnership(address newOwner) public virtual override {
|
|
199
209
|
_checkOwner();
|
|
200
210
|
if (newOwner == address(0)) {
|
|
201
|
-
revert JBOwnableOverrides_InvalidNewOwner();
|
|
211
|
+
revert JBOwnableOverrides_InvalidNewOwner({newOwner: newOwner, projectId: 0});
|
|
202
212
|
}
|
|
203
213
|
|
|
204
214
|
_transferOwnership({newOwner: newOwner, projectId: 0});
|
|
@@ -213,12 +223,12 @@ abstract contract JBOwnableOverrides is Context, JBPermissioned, IJBOwnable {
|
|
|
213
223
|
function transferOwnershipToProject(uint256 projectId) public virtual override {
|
|
214
224
|
_checkOwner();
|
|
215
225
|
if (projectId == 0 || projectId > type(uint88).max) {
|
|
216
|
-
revert JBOwnableOverrides_InvalidNewOwner();
|
|
226
|
+
revert JBOwnableOverrides_InvalidNewOwner({newOwner: address(0), projectId: projectId});
|
|
217
227
|
}
|
|
218
228
|
|
|
219
229
|
// Make sure the project exists to prevent permanent loss of contract control.
|
|
220
230
|
if (projectId > PROJECTS.count()) {
|
|
221
|
-
revert JBOwnableOverrides_ProjectDoesNotExist();
|
|
231
|
+
revert JBOwnableOverrides_ProjectDoesNotExist({projectId: projectId, projectCount: PROJECTS.count()});
|
|
222
232
|
}
|
|
223
233
|
|
|
224
234
|
// forge-lint: disable-next-line(unsafe-typecast)
|
|
@@ -261,7 +271,7 @@ abstract contract JBOwnableOverrides is Context, JBPermissioned, IJBOwnable {
|
|
|
261
271
|
function _transferOwnership(address newOwner, uint88 projectId) internal virtual {
|
|
262
272
|
// Can't set both a new owner and a new project ID.
|
|
263
273
|
if (projectId != 0 && newOwner != address(0)) {
|
|
264
|
-
revert JBOwnableOverrides_InvalidNewOwner();
|
|
274
|
+
revert JBOwnableOverrides_InvalidNewOwner({newOwner: newOwner, projectId: projectId});
|
|
265
275
|
}
|
|
266
276
|
// Load the owner information from storage.
|
|
267
277
|
JBOwner memory ownerInfo = jbOwner;
|