@bananapus/ownable-v6 0.0.10 → 0.0.12
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/CHANGE_LOG.md +10 -2
- package/package.json +2 -2
- package/docs/book.css +0 -13
- package/docs/book.toml +0 -12
- package/docs/solidity.min.js +0 -74
- package/docs/src/README.md +0 -131
- package/docs/src/SUMMARY.md +0 -9
- package/docs/src/src/JBOwnable.sol/contract.JBOwnable.md +0 -71
- package/docs/src/src/JBOwnableOverrides.sol/abstract.JBOwnableOverrides.md +0 -216
- package/docs/src/src/README.md +0 -7
- package/docs/src/src/interfaces/IJBOwnable.sol/interface.IJBOwnable.md +0 -67
- package/docs/src/src/interfaces/README.md +0 -4
- package/docs/src/src/structs/JBOwner.sol/struct.JBOwner.md +0 -23
- package/docs/src/src/structs/README.md +0 -4
package/CHANGE_LOG.md
CHANGED
|
@@ -36,10 +36,17 @@ In v6, `transferOwnershipToProject()` checks `projectId > PROJECTS.count()` and
|
|
|
36
36
|
|
|
37
37
|
In v6, the constructor reverts with `JBOwnableOverrides_ZeroAddressProjectsWithProjectOwner()` if `initialProjectIdOwner != 0` and `address(projects) == address(0)`. In v5, this combination was silently accepted, which would permanently break ownership resolution since `ownerOf()` calls on `address(0)` would always revert.
|
|
38
38
|
|
|
39
|
-
### `IJBOwnable
|
|
39
|
+
### `IJBOwnable` Return Name Changes
|
|
40
40
|
|
|
41
41
|
The second return value of `jbOwner()` was renamed from `projectOwner` (v5) to `projectId` (v6) in the interface. The type (`uint88`) and position are unchanged, so the ABI is identical, but code referencing the named return will need updating.
|
|
42
42
|
|
|
43
|
+
Additionally, `PROJECTS()` and `owner()` gained named return values in the interface:
|
|
44
|
+
|
|
45
|
+
- `PROJECTS()`: `returns (IJBProjects)` (v5) -> `returns (IJBProjects projects)` (v6)
|
|
46
|
+
- `owner()`: `returns (address)` (v5) -> `returns (address owner)` (v6)
|
|
47
|
+
|
|
48
|
+
These are ABI-compatible but change the Solidity-level interface signature.
|
|
49
|
+
|
|
43
50
|
---
|
|
44
51
|
|
|
45
52
|
## 2. New Features
|
|
@@ -193,7 +200,7 @@ All internal function calls in v6 use named arguments (e.g., `_transferOwnership
|
|
|
193
200
|
|
|
194
201
|
### NatSpec Improvements
|
|
195
202
|
|
|
196
|
-
- `JBOwnable._emitTransferEvent()`: Incomplete comment in v5 (`"some contracts will try to deploy contracts for a project before"`) is completed in v6 (`"some contracts need to deploy contracts for a project before the project's NFT has been minted, so the transfer event resolves the project's current owner at emission time."`).
|
|
203
|
+
- `JBOwnable._emitTransferEvent()`: Incomplete comment in v5 (`"some contracts will try to deploy contracts for a project before"`) is completed in v6 (`"some contracts need to deploy contracts for a project before the project's NFT has been minted, so the transfer event resolves the project's current owner at emission time."`). A new `@dev` comment also explains why this function intentionally does NOT use try-catch (unlike `_transferOwnership`): reverting on a nonexistent new project is desirable to prevent transferring ownership to an invalid project.
|
|
197
204
|
- `JBOwnableOverrides._emitTransferEvent()`: Added `@param` tags for `previousOwner`, `newOwner`, and `newProjectId`.
|
|
198
205
|
- `renounceOwnership()`, `setPermissionId()`: Changed `@notice This can only be called by the current owner.` to `@dev`.
|
|
199
206
|
- `transferOwnership()`, `transferOwnershipToProject()`: Added documentation about `permissionId` being reset to 0 on transfer.
|
|
@@ -215,6 +222,7 @@ All internal function calls in v6 use named arguments (e.g., `_transferOwnership
|
|
|
215
222
|
| `transferOwnershipToProject()` -- no existence check | Reverts with `JBOwnableOverrides_ProjectDoesNotExist()` if `projectId > PROJECTS.count()` | New validation |
|
|
216
223
|
| Constructor allows `projects == address(0)` with `initialProjectIdOwner != 0` | Reverts with `JBOwnableOverrides_ZeroAddressProjectsWithProjectOwner()` | New validation |
|
|
217
224
|
| `IJBOwnable.jbOwner()` returns `(address owner, uint88 projectOwner, uint8 permissionId)` | Returns `(address owner, uint88 projectId, uint8 permissionId)` | Return name change (ABI compatible) |
|
|
225
|
+
| `IJBOwnable.PROJECTS()` returns `(IJBProjects)`, `owner()` returns `(address)` | Returns `(IJBProjects projects)`, `(address owner)` | Named return values added (ABI compatible) |
|
|
218
226
|
| `IJBOwnable` -- no NatSpec | Full NatSpec on all events, functions, params, and returns | Documentation |
|
|
219
227
|
| Positional arguments in internal calls | Named arguments throughout | Style only |
|
|
220
228
|
| 1 custom error | 3 custom errors (`+ ProjectDoesNotExist`, `+ ZeroAddressProjectsWithProjectOwner`) | New errors |
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bananapus/ownable-v6",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.12",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
"node": ">=20.0.0"
|
|
11
11
|
},
|
|
12
12
|
"dependencies": {
|
|
13
|
-
"@bananapus/core-v6": "^0.0.
|
|
13
|
+
"@bananapus/core-v6": "^0.0.22",
|
|
14
14
|
"@bananapus/permission-ids-v6": "^0.0.10",
|
|
15
15
|
"@openzeppelin/contracts": "^5.6.1"
|
|
16
16
|
},
|
package/docs/book.css
DELETED
package/docs/book.toml
DELETED
package/docs/solidity.min.js
DELETED
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
hljs.registerLanguage("solidity",(()=>{"use strict";function e(){try{return!0
|
|
2
|
-
}catch(e){return!1}}
|
|
3
|
-
var a=/-?(\b0[xX]([a-fA-F0-9]_?)*[a-fA-F0-9]|(\b[1-9](_?\d)*(\.((\d_?)*\d)?)?|\.\d(_?\d)*)([eE][-+]?\d(_?\d)*)?|\b0)(?!\w|\$)/
|
|
4
|
-
;e()&&(a=a.source.replace(/\\b/g,"(?<!\\$)\\b"));var s={className:"number",
|
|
5
|
-
begin:a,relevance:0},n={
|
|
6
|
-
keyword:"assembly let function if switch case default for leave break continue u256 jump jumpi stop return revert selfdestruct invalid",
|
|
7
|
-
built_in:"add sub mul div sdiv mod smod exp not lt gt slt sgt eq iszero and or xor byte shl shr sar addmod mulmod signextend keccak256 pc pop dup1 dup2 dup3 dup4 dup5 dup6 dup7 dup8 dup9 dup10 dup11 dup12 dup13 dup14 dup15 dup16 swap1 swap2 swap3 swap4 swap5 swap6 swap7 swap8 swap9 swap10 swap11 swap12 swap13 swap14 swap15 swap16 mload mstore mstore8 sload sstore msize gas address balance selfbalance caller callvalue calldataload calldatasize calldatacopy codesize codecopy extcodesize extcodecopy returndatasize returndatacopy extcodehash create create2 call callcode delegatecall staticcall log0 log1 log2 log3 log4 chainid origin gasprice basefee blockhash coinbase timestamp number difficulty gaslimit",
|
|
8
|
-
literal:"true false"},i={className:"string",
|
|
9
|
-
begin:/\bhex'(([0-9a-fA-F]{2}_?)*[0-9a-fA-F]{2})?'/},t={className:"string",
|
|
10
|
-
begin:/\bhex"(([0-9a-fA-F]{2}_?)*[0-9a-fA-F]{2})?"/};function r(e){
|
|
11
|
-
return e.inherit(e.APOS_STRING_MODE,{begin:/(\bunicode)?'/})}function l(e){
|
|
12
|
-
return e.inherit(e.QUOTE_STRING_MODE,{begin:/(\bunicode)?"/})}var o={
|
|
13
|
-
SOL_ASSEMBLY_KEYWORDS:n,baseAssembly:e=>{
|
|
14
|
-
var a=r(e),o=l(e),c=/[A-Za-z_$][A-Za-z_$0-9.]*/,d=e.inherit(e.TITLE_MODE,{
|
|
15
|
-
begin:/[A-Za-z$_][0-9A-Za-z$_]*/,lexemes:c,keywords:n}),u={className:"params",
|
|
16
|
-
begin:/\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,lexemes:c,keywords:n,
|
|
17
|
-
contains:[e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE,a,o,s]},_={
|
|
18
|
-
className:"operator",begin:/:=|->/};return{keywords:n,lexemes:c,
|
|
19
|
-
contains:[a,o,i,t,e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE,s,_,{
|
|
20
|
-
className:"function",lexemes:c,beginKeywords:"function",end:"{",excludeEnd:!0,
|
|
21
|
-
contains:[d,u,e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE,_]}]}},
|
|
22
|
-
solAposStringMode:r,solQuoteStringMode:l,HEX_APOS_STRING_MODE:i,
|
|
23
|
-
HEX_QUOTE_STRING_MODE:t,SOL_NUMBER:s,isNegativeLookbehindAvailable:e}
|
|
24
|
-
;const{baseAssembly:c,solAposStringMode:d,solQuoteStringMode:u,HEX_APOS_STRING_MODE:_,HEX_QUOTE_STRING_MODE:m,SOL_NUMBER:b,isNegativeLookbehindAvailable:E}=o
|
|
25
|
-
;return e=>{for(var a=d(e),s=u(e),n=[],i=0;i<32;i++)n[i]=i+1
|
|
26
|
-
;var t=n.map((e=>8*e)),r=[];for(i=0;i<=80;i++)r[i]=i
|
|
27
|
-
;var l=n.map((e=>"bytes"+e)).join(" ")+" ",o=t.map((e=>"uint"+e)).join(" ")+" ",g=t.map((e=>"int"+e)).join(" ")+" ",M=[].concat.apply([],t.map((e=>r.map((a=>e+"x"+a))))),p={
|
|
28
|
-
keyword:"var bool string int uint "+g+o+"byte bytes "+l+"fixed ufixed "+M.map((e=>"fixed"+e)).join(" ")+" "+M.map((e=>"ufixed"+e)).join(" ")+" enum struct mapping address new delete if else for while continue break return throw emit try catch revert unchecked _ function modifier event constructor fallback receive error virtual override constant immutable anonymous indexed storage memory calldata external public internal payable pure view private returns import from as using pragma contract interface library is abstract type assembly",
|
|
29
|
-
literal:"true false wei gwei szabo finney ether seconds minutes hours days weeks years",
|
|
30
|
-
built_in:"self this super selfdestruct suicide now msg block tx abi blockhash gasleft assert require Error Panic sha3 sha256 keccak256 ripemd160 ecrecover addmod mulmod log0 log1 log2 log3 log4"
|
|
31
|
-
},O={className:"operator",begin:/[+\-!~*\/%<>&^|=]/
|
|
32
|
-
},C=/[A-Za-z_$][A-Za-z_$0-9]*/,N={className:"params",begin:/\(/,end:/\)/,
|
|
33
|
-
excludeBegin:!0,excludeEnd:!0,lexemes:C,keywords:p,
|
|
34
|
-
contains:[e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE,a,s,b,"self"]},f={
|
|
35
|
-
begin:/\.\s*/,end:/[^A-Za-z0-9$_\.]/,excludeBegin:!0,excludeEnd:!0,keywords:{
|
|
36
|
-
built_in:"gas value selector address length push pop send transfer call callcode delegatecall staticcall balance code codehash wrap unwrap name creationCode runtimeCode interfaceId min max"
|
|
37
|
-
},relevance:2},y=e.inherit(e.TITLE_MODE,{begin:/[A-Za-z$_][0-9A-Za-z$_]*/,
|
|
38
|
-
lexemes:C,keywords:p}),w={className:"built_in",
|
|
39
|
-
begin:(E()?"(?<!\\$)\\b":"\\b")+"(gas|value|salt)(?=:)"};function x(e,a){return{
|
|
40
|
-
begin:(E()?"(?<!\\$)\\b":"\\b")+e+"\\.\\s*",end:/[^A-Za-z0-9$_\.]/,
|
|
41
|
-
excludeBegin:!1,excludeEnd:!0,lexemes:C,keywords:{built_in:e+" "+a},
|
|
42
|
-
contains:[f],relevance:10}}var h=c(e),v=e.inherit(h,{
|
|
43
|
-
contains:h.contains.concat([{begin:/\./,end:/[^A-Za-z0-9$.]/,excludeBegin:!0,
|
|
44
|
-
excludeEnd:!0,keywords:{built_in:"slot offset length address selector"},
|
|
45
|
-
relevance:2},{begin:/_/,end:/[^A-Za-z0-9$.]/,excludeBegin:!0,excludeEnd:!0,
|
|
46
|
-
keywords:{built_in:"slot offset"},relevance:2}])});return{aliases:["sol"],
|
|
47
|
-
keywords:p,lexemes:C,
|
|
48
|
-
contains:[a,s,_,m,e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE,b,w,O,{
|
|
49
|
-
className:"function",lexemes:C,
|
|
50
|
-
beginKeywords:"function modifier event constructor fallback receive error",
|
|
51
|
-
end:/[{;]/,excludeEnd:!0,
|
|
52
|
-
contains:[y,N,w,e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE],illegal:/%/
|
|
53
|
-
},x("msg","gas value data sender sig"),x("block","blockhash coinbase difficulty gaslimit basefee number timestamp chainid"),x("tx","gasprice origin"),x("abi","decode encode encodePacked encodeWithSelector encodeWithSignature encodeCall"),x("bytes","concat"),f,{
|
|
54
|
-
className:"class",lexemes:C,beginKeywords:"contract interface library",end:"{",
|
|
55
|
-
excludeEnd:!0,illegal:/[:"\[\]]/,contains:[{beginKeywords:"is",lexemes:C
|
|
56
|
-
},y,N,w,e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE]},{lexemes:C,
|
|
57
|
-
beginKeywords:"struct enum",end:"{",excludeEnd:!0,illegal:/[:"\[\]]/,
|
|
58
|
-
contains:[y,e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE]},{
|
|
59
|
-
beginKeywords:"import",end:";",lexemes:C,keywords:"import from as",
|
|
60
|
-
contains:[y,a,s,_,m,e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE,O]},{
|
|
61
|
-
beginKeywords:"using",end:";",lexemes:C,keywords:"using for",
|
|
62
|
-
contains:[y,e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE,O]},{className:"meta",
|
|
63
|
-
beginKeywords:"pragma",end:";",lexemes:C,keywords:{
|
|
64
|
-
keyword:"pragma solidity experimental abicoder",
|
|
65
|
-
built_in:"ABIEncoderV2 SMTChecker v1 v2"},
|
|
66
|
-
contains:[e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE,e.inherit(a,{
|
|
67
|
-
className:"meta-string"}),e.inherit(s,{className:"meta-string"})]},{
|
|
68
|
-
beginKeywords:"assembly",end:/\b\B/,
|
|
69
|
-
contains:[e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE,e.inherit(v,{begin:"{",
|
|
70
|
-
end:"}",endsParent:!0,contains:v.contains.concat([e.inherit(v,{begin:"{",
|
|
71
|
-
end:"}",contains:v.contains.concat(["self"])})])})]}],illegal:/#/}}})());
|
|
72
|
-
|
|
73
|
-
// Ugly hack to reload HLJS
|
|
74
|
-
hljs.initHighlightingOnLoad();
|
package/docs/src/README.md
DELETED
|
@@ -1,131 +0,0 @@
|
|
|
1
|
-
# Bananapus Ownable
|
|
2
|
-
|
|
3
|
-
A Bananapus variation on OpenZeppelin [`Ownable`](https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/access/Ownable.sol) to enable owner-based access control incorporating Juicebox project ownership and `JBPermissions`.
|
|
4
|
-
|
|
5
|
-
<details>
|
|
6
|
-
<summary>Table of Contents</summary>
|
|
7
|
-
<ol>
|
|
8
|
-
<li><a href="#repository-layout">Repository Layout</a></li>
|
|
9
|
-
<li><a href="#usage">Usage</a></li>
|
|
10
|
-
<ul>
|
|
11
|
-
<li><a href="#install">Install</a></li>
|
|
12
|
-
<li><a href="#develop">Develop</a></li>
|
|
13
|
-
<li><a href="#scripts">Scripts</a></li>
|
|
14
|
-
<li><a href="#tips">Tips</a></li>
|
|
15
|
-
</ul>
|
|
16
|
-
</ul>
|
|
17
|
-
</ol>
|
|
18
|
-
</details>
|
|
19
|
-
|
|
20
|
-
This implementation adds:
|
|
21
|
-
|
|
22
|
-
- The ability to transfer contract ownership to a Juicebox Project instead of a specific address.
|
|
23
|
-
- The ability to grant other addresses `OnlyOwner` access using `JBPermissions`.
|
|
24
|
-
- Includes the `JBPermissioned` modifiers with support for OpenZeppelin [`Context`](https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/utils/Context.sol). This enables optional meta-transaction support.
|
|
25
|
-
|
|
26
|
-
All features are backwards compatible with OpenZeppelin `Ownable`. This should be a drop-in replacement.
|
|
27
|
-
|
|
28
|
-
This repo contains 2 contracts:
|
|
29
|
-
|
|
30
|
-
1. If your contract does not already use `Ownable` or access controls, use `JBOwnable`.
|
|
31
|
-
2. If your contract extends a contract you cannot easily modify (e.g. a core dependency), and that contract inherits from OpenZeppelin `Ownable`, use `JBOwnableOverride`.
|
|
32
|
-
|
|
33
|
-
**NOTICE:** Only use `JBOwnableOverride` if you are overriding OpenZeppelin `Ownable` v4.7.0 or higher. Otherwise, `JBPermissions` functionality for `onlyOwner` will not work.
|
|
34
|
-
|
|
35
|
-
This repo was forked from [`jbx-protocol/juice-ownable`](https://github.com/jbx-protocol/juice-ownable).
|
|
36
|
-
|
|
37
|
-
_If you're having trouble understanding this contract, take a look at the [core protocol contracts](https://github.com/Bananapus/nana-core) and the [documentation](https://docs.juicebox.money/) first. If you have questions, reach out on [Discord](https://discord.com/invite/ErQYmth4dS)._
|
|
38
|
-
|
|
39
|
-
## Repository Layout
|
|
40
|
-
|
|
41
|
-
The root directory contains this README, an MIT license, and config files.
|
|
42
|
-
|
|
43
|
-
```
|
|
44
|
-
nana-ownable/
|
|
45
|
-
├── src/ - The Solidity source code for the contracts.
|
|
46
|
-
│ ├── JBOwnable.sol - Implements ownable access control for Juicebox projects/permissions.
|
|
47
|
-
│ ├── JBOwnableOverrides.sol - Abstract base contract used by JBOwnable.
|
|
48
|
-
│ ├── interfaces/ - Contract interfaces.
|
|
49
|
-
│ │ └── IJBOwnable.sol - Interface used by JBOwnableOverrides.
|
|
50
|
-
│ └── structs/ - Structs.
|
|
51
|
-
│ └── JBOwner.sol - Owner information for a given instance of JBOwnableOverrides.
|
|
52
|
-
├── test/ - Forge tests and testing utilities. Top level contains the main test files.
|
|
53
|
-
│ ├── handlers/ - Custom handlers for tests.
|
|
54
|
-
│ ├── mock/ - Mocking utilities.
|
|
55
|
-
│ ├── Ownable.t.sol - Main tests.
|
|
56
|
-
│ └── OwnableInvariantTests.t.sol - Invariant test.
|
|
57
|
-
└── .github/
|
|
58
|
-
└── workflows/ - CI/CD workflows.
|
|
59
|
-
```
|
|
60
|
-
|
|
61
|
-
## Usage
|
|
62
|
-
|
|
63
|
-
### Install
|
|
64
|
-
|
|
65
|
-
How to install `nana-ownable` in another project.
|
|
66
|
-
|
|
67
|
-
For projects using `npm` to manage dependencies (recommended):
|
|
68
|
-
|
|
69
|
-
```bash
|
|
70
|
-
npm install @bananapus/ownable
|
|
71
|
-
```
|
|
72
|
-
|
|
73
|
-
For projects using `forge` to manage dependencies (not recommended):
|
|
74
|
-
|
|
75
|
-
```bash
|
|
76
|
-
forge install Bananapus/nana-ownable
|
|
77
|
-
```
|
|
78
|
-
|
|
79
|
-
If you're using `forge` to manage dependencies, add `@bananapus/ownable/=lib/nana-ownable/` to `remappings.txt`. You'll also need to install `nana-ownable`'s dependencies and add similar remappings for them.
|
|
80
|
-
|
|
81
|
-
### Develop
|
|
82
|
-
|
|
83
|
-
`nana-ownable` uses [npm](https://www.npmjs.com/) (version >=20.0.0) for package management and the [Foundry](https://github.com/foundry-rs/foundry) development toolchain for builds, tests, and deployments. To get set up, [install Node.js](https://nodejs.org/en/download) and install [Foundry](https://github.com/foundry-rs/foundry):
|
|
84
|
-
|
|
85
|
-
```bash
|
|
86
|
-
curl -L https://foundry.paradigm.xyz | sh
|
|
87
|
-
```
|
|
88
|
-
|
|
89
|
-
You can download and install dependencies with:
|
|
90
|
-
|
|
91
|
-
```bash
|
|
92
|
-
npm ci && forge install
|
|
93
|
-
```
|
|
94
|
-
|
|
95
|
-
If you run into trouble with `forge install`, try using `git submodule update --init --recursive` to ensure that nested submodules have been properly initialized.
|
|
96
|
-
|
|
97
|
-
Some useful commands:
|
|
98
|
-
|
|
99
|
-
| Command | Description |
|
|
100
|
-
| --------------------- | --------------------------------------------------- |
|
|
101
|
-
| `forge build` | Compile the contracts and write artifacts to `out`. |
|
|
102
|
-
| `forge fmt` | Lint. |
|
|
103
|
-
| `forge test` | Run the tests. |
|
|
104
|
-
| `forge build --sizes` | Get contract sizes. |
|
|
105
|
-
| `forge coverage` | Generate a test coverage report. |
|
|
106
|
-
| `foundryup` | Update foundry. Run this periodically. |
|
|
107
|
-
| `forge clean` | Remove the build artifacts and cache directories. |
|
|
108
|
-
|
|
109
|
-
To learn more, visit the [Foundry Book](https://book.getfoundry.sh/) docs.
|
|
110
|
-
|
|
111
|
-
### Scripts
|
|
112
|
-
|
|
113
|
-
For convenience, several utility commands are available in `package.json`.
|
|
114
|
-
|
|
115
|
-
| Command | Description |
|
|
116
|
-
| --------------------------------- | -------------------------------------- |
|
|
117
|
-
| `npm test` | Run local tests. |
|
|
118
|
-
| `npm run test:fork` | Run fork tests (for use in CI). |
|
|
119
|
-
| `npm run coverage` | Generate an LCOV test coverage report. |
|
|
120
|
-
|
|
121
|
-
### Tips
|
|
122
|
-
|
|
123
|
-
To view test coverage, run `npm run coverage` to generate an LCOV test report. You can use an extension like [Coverage Gutters](https://marketplace.visualstudio.com/items?itemName=ryanluker.vscode-coverage-gutters) to view coverage in your editor.
|
|
124
|
-
|
|
125
|
-
If you're using Nomic Foundation's [Solidity](https://marketplace.visualstudio.com/items?itemName=NomicFoundation.hardhat-solidity) extension in VSCode, you may run into LSP errors because the extension cannot find dependencies outside of `lib`. You can often fix this by running:
|
|
126
|
-
|
|
127
|
-
```bash
|
|
128
|
-
forge remappings >> remappings.txt
|
|
129
|
-
```
|
|
130
|
-
|
|
131
|
-
This makes the extension aware of default remappings.
|
package/docs/src/SUMMARY.md
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
# Summary
|
|
2
|
-
- [Home](README.md)
|
|
3
|
-
# src
|
|
4
|
-
- [❱ interfaces](src/interfaces/README.md)
|
|
5
|
-
- [IJBOwnable](src/interfaces/IJBOwnable.sol/interface.IJBOwnable.md)
|
|
6
|
-
- [❱ structs](src/structs/README.md)
|
|
7
|
-
- [JBOwner](src/structs/JBOwner.sol/structs.JBOwner.md)
|
|
8
|
-
- [JBOwnable](src/JBOwnable.sol/contract.JBOwnable.md)
|
|
9
|
-
- [JBOwnableOverrides](src/JBOwnableOverrides.sol/abstract.JBOwnableOverrides.md)
|
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
# JBOwnable
|
|
2
|
-
[Git Source](https://github.com/Bananapus/nana-ownable/blob/a74b3181e75adaf0ee0c93cb00bcc5709ca8f314/src/JBOwnable.sol)
|
|
3
|
-
|
|
4
|
-
**Inherits:**
|
|
5
|
-
[JBOwnableOverrides](/src/JBOwnableOverrides.sol/abstract.JBOwnableOverrides.md)
|
|
6
|
-
|
|
7
|
-
A function restricted by `JBOwnable` can only be called by a Juicebox project's owner, a specified owner
|
|
8
|
-
address (if set), or addresses with permission from the owner.
|
|
9
|
-
|
|
10
|
-
*A function with the `onlyOwner` modifier from `JBOwnable` can only be called by addresses with owner access
|
|
11
|
-
based on a `JBOwner` struct:
|
|
12
|
-
1. If `JBOwner.projectId` isn't zero, the address holding the `JBProjects` NFT with the `JBOwner.projectId` ID is
|
|
13
|
-
the owner.
|
|
14
|
-
2. If `JBOwner.projectId` is set to `0`, the `JBOwner.owner` address is the owner.
|
|
15
|
-
3. The owner can give other addresses access with `JBPermissions.setPermissionsFor(...)`, using the
|
|
16
|
-
`JBOwner.permissionId` permission.*
|
|
17
|
-
|
|
18
|
-
*To use `onlyOwner`, inherit this contract and apply the modifier to a function.*
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
## Functions
|
|
22
|
-
### constructor
|
|
23
|
-
|
|
24
|
-
*To make a Juicebox project's owner this contract's owner, pass that project's ID as the
|
|
25
|
-
`initialProjectIdOwner`.*
|
|
26
|
-
|
|
27
|
-
*To make a specific address the owner, pass that address as the `initialOwner` and `0` as the
|
|
28
|
-
`initialProjectIdOwner`.*
|
|
29
|
-
|
|
30
|
-
*The owner can give other addresses owner access through the `permissions` contract.*
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
```solidity
|
|
34
|
-
constructor(
|
|
35
|
-
IJBPermissions permissions,
|
|
36
|
-
IJBProjects projects,
|
|
37
|
-
address initialOwner,
|
|
38
|
-
uint88 initialProjectIdOwner
|
|
39
|
-
)
|
|
40
|
-
JBOwnableOverrides(permissions, projects, initialOwner, initialProjectIdOwner);
|
|
41
|
-
```
|
|
42
|
-
**Parameters**
|
|
43
|
-
|
|
44
|
-
|Name|Type|Description|
|
|
45
|
-
|----|----|-----------|
|
|
46
|
-
|`permissions`|`IJBPermissions`|A contract storing permissions.|
|
|
47
|
-
|`projects`|`IJBProjects`|Mints ERC-721s that represent project ownership and transfers.|
|
|
48
|
-
|`initialOwner`|`address`|An address with owner access (until ownership is transferred).|
|
|
49
|
-
|`initialProjectIdOwner`|`uint88`|The ID of the Juicebox project whose owner has owner access (until ownership is transferred).|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
### onlyOwner
|
|
53
|
-
|
|
54
|
-
Reverts if called by an address without owner access.
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
```solidity
|
|
58
|
-
modifier onlyOwner() virtual;
|
|
59
|
-
```
|
|
60
|
-
|
|
61
|
-
### _emitTransferEvent
|
|
62
|
-
|
|
63
|
-
Either `newOwner` or `newProjectId` is non-zero or both are zero. But they can never both be non-zero.
|
|
64
|
-
|
|
65
|
-
*This function exists because some contracts will try to deploy contracts for a project before*
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
```solidity
|
|
69
|
-
function _emitTransferEvent(address previousOwner, address newOwner, uint88 newProjectId) internal virtual override;
|
|
70
|
-
```
|
|
71
|
-
|
|
@@ -1,216 +0,0 @@
|
|
|
1
|
-
# JBOwnableOverrides
|
|
2
|
-
[Git Source](https://github.com/Bananapus/nana-ownable/blob/a74b3181e75adaf0ee0c93cb00bcc5709ca8f314/src/JBOwnableOverrides.sol)
|
|
3
|
-
|
|
4
|
-
**Inherits:**
|
|
5
|
-
Context, JBPermissioned, [IJBOwnable](/src/interfaces/IJBOwnable.sol/interface.IJBOwnable.md)
|
|
6
|
-
|
|
7
|
-
An abstract base for `JBOwnable`, which restricts functions so they can only be called by a Juicebox
|
|
8
|
-
project's owner or a specific owner address. The owner can give access permission to other addresses with
|
|
9
|
-
`JBPermissions`.
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
## State Variables
|
|
13
|
-
### PROJECTS
|
|
14
|
-
Mints ERC-721s that represent project ownership and transfers.
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
```solidity
|
|
18
|
-
IJBProjects public immutable override PROJECTS;
|
|
19
|
-
```
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
### jbOwner
|
|
23
|
-
This contract's owner information.
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
```solidity
|
|
27
|
-
JBOwner public override jbOwner;
|
|
28
|
-
```
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
## Functions
|
|
32
|
-
### constructor
|
|
33
|
-
|
|
34
|
-
*To restrict access to a Juicebox project's owner, pass that project's ID as the `initialProjectIdOwner` and
|
|
35
|
-
the zero address as the `initialOwner`.
|
|
36
|
-
To restrict access to a specific address, pass that address as the `initialOwner` and `0` as the
|
|
37
|
-
`initialProjectIdOwner`.*
|
|
38
|
-
|
|
39
|
-
*The owner can give owner access to other addresses through the `permissions` contract.*
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
```solidity
|
|
43
|
-
constructor(
|
|
44
|
-
IJBPermissions permissions,
|
|
45
|
-
IJBProjects projects,
|
|
46
|
-
address initialOwner,
|
|
47
|
-
uint88 initialProjectIdOwner
|
|
48
|
-
)
|
|
49
|
-
JBPermissioned(permissions);
|
|
50
|
-
```
|
|
51
|
-
**Parameters**
|
|
52
|
-
|
|
53
|
-
|Name|Type|Description|
|
|
54
|
-
|----|----|-----------|
|
|
55
|
-
|`permissions`|`IJBPermissions`|A contract storing permissions.|
|
|
56
|
-
|`projects`|`IJBProjects`|Mints ERC-721s that represent project ownership and transfers.|
|
|
57
|
-
|`initialOwner`|`address`|The owner if the `intialProjectIdOwner` is 0 (until ownership is transferred).|
|
|
58
|
-
|`initialProjectIdOwner`|`uint88`|The ID of the Juicebox project whose owner is this contract's owner (until ownership is transferred).|
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
### owner
|
|
62
|
-
|
|
63
|
-
Returns the owner's address based on this contract's `JBOwner`.
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
```solidity
|
|
67
|
-
function owner() public view virtual returns (address);
|
|
68
|
-
```
|
|
69
|
-
|
|
70
|
-
### _checkOwner
|
|
71
|
-
|
|
72
|
-
Reverts if the sender is not the owner.
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
```solidity
|
|
76
|
-
function _checkOwner() internal view virtual;
|
|
77
|
-
```
|
|
78
|
-
|
|
79
|
-
### renounceOwnership
|
|
80
|
-
|
|
81
|
-
Gives up ownership of this contract, making it impossible to call `onlyOwner` and `_checkOwner`
|
|
82
|
-
functions.
|
|
83
|
-
|
|
84
|
-
This can only be called by the current owner.
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
```solidity
|
|
88
|
-
function renounceOwnership() public virtual override;
|
|
89
|
-
```
|
|
90
|
-
|
|
91
|
-
### setPermissionId
|
|
92
|
-
|
|
93
|
-
Sets the permission ID the owner can use to give other addresses owner access.
|
|
94
|
-
|
|
95
|
-
This can only be called by the current owner.
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
```solidity
|
|
99
|
-
function setPermissionId(uint8 permissionId) public virtual override;
|
|
100
|
-
```
|
|
101
|
-
**Parameters**
|
|
102
|
-
|
|
103
|
-
|Name|Type|Description|
|
|
104
|
-
|----|----|-----------|
|
|
105
|
-
|`permissionId`|`uint8`|The permission ID to use for `onlyOwner`.|
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
### transferOwnership
|
|
109
|
-
|
|
110
|
-
Transfers ownership of this contract to a new address (the `newOwner`). Can only be called by the
|
|
111
|
-
current owner.
|
|
112
|
-
|
|
113
|
-
This can only be called by the current owner.
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
```solidity
|
|
117
|
-
function transferOwnership(address newOwner) public virtual override;
|
|
118
|
-
```
|
|
119
|
-
**Parameters**
|
|
120
|
-
|
|
121
|
-
|Name|Type|Description|
|
|
122
|
-
|----|----|-----------|
|
|
123
|
-
|`newOwner`|`address`|The address to transfer ownership to.|
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
### transferOwnershipToProject
|
|
127
|
-
|
|
128
|
-
Transfer ownership of this contract to a new Juicebox project.
|
|
129
|
-
|
|
130
|
-
This can only be called by the current owner.
|
|
131
|
-
|
|
132
|
-
*The `projectId` must fit within a `uint88`.*
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
```solidity
|
|
136
|
-
function transferOwnershipToProject(uint256 projectId) public virtual override;
|
|
137
|
-
```
|
|
138
|
-
**Parameters**
|
|
139
|
-
|
|
140
|
-
|Name|Type|Description|
|
|
141
|
-
|----|----|-----------|
|
|
142
|
-
|`projectId`|`uint256`|The ID of the project to transfer ownership to.|
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
### _emitTransferEvent
|
|
146
|
-
|
|
147
|
-
Either `newOwner` or `newProjectId` is non-zero or both are zero. But they can never both be non-zero.
|
|
148
|
-
|
|
149
|
-
*This function exists because some contracts will try to deploy contracts for a project before*
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
```solidity
|
|
153
|
-
function _emitTransferEvent(address previousOwner, address newOwner, uint88 newProjectId) internal virtual;
|
|
154
|
-
```
|
|
155
|
-
|
|
156
|
-
### _setPermissionId
|
|
157
|
-
|
|
158
|
-
Sets the permission ID the owner can use to give other addresses owner access.
|
|
159
|
-
|
|
160
|
-
*Internal function without access restriction.*
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
```solidity
|
|
164
|
-
function _setPermissionId(uint8 permissionId) internal virtual;
|
|
165
|
-
```
|
|
166
|
-
**Parameters**
|
|
167
|
-
|
|
168
|
-
|Name|Type|Description|
|
|
169
|
-
|----|----|-----------|
|
|
170
|
-
|`permissionId`|`uint8`|The permission ID to use for `onlyOwner`.|
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
### _transferOwnership
|
|
174
|
-
|
|
175
|
-
Helper to allow for drop-in replacement of OpenZeppelin `Ownable`.
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
```solidity
|
|
179
|
-
function _transferOwnership(address newOwner) internal virtual;
|
|
180
|
-
```
|
|
181
|
-
**Parameters**
|
|
182
|
-
|
|
183
|
-
|Name|Type|Description|
|
|
184
|
-
|----|----|-----------|
|
|
185
|
-
|`newOwner`|`address`|The address that should receive ownership of this contract.|
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
### _transferOwnership
|
|
189
|
-
|
|
190
|
-
Transfers this contract's ownership to an address (`newOwner`) OR a Juicebox project (`projectId`).
|
|
191
|
-
|
|
192
|
-
*Updates this contract's `JBOwner` owner information and resets the `JBOwner.permissionId`.*
|
|
193
|
-
|
|
194
|
-
*If both `newOwner` and `projectId` are set, this will revert.*
|
|
195
|
-
|
|
196
|
-
*Internal function without access restriction.*
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
```solidity
|
|
200
|
-
function _transferOwnership(address newOwner, uint88 projectId) internal virtual;
|
|
201
|
-
```
|
|
202
|
-
**Parameters**
|
|
203
|
-
|
|
204
|
-
|Name|Type|Description|
|
|
205
|
-
|----|----|-----------|
|
|
206
|
-
|`newOwner`|`address`|The address that should become this contract's owner.|
|
|
207
|
-
|`projectId`|`uint88`|The ID of the project whose owner should become this contract's owner.|
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
## Errors
|
|
211
|
-
### JBOwnableOverrides_InvalidNewOwner
|
|
212
|
-
|
|
213
|
-
```solidity
|
|
214
|
-
error JBOwnableOverrides_InvalidNewOwner();
|
|
215
|
-
```
|
|
216
|
-
|
package/docs/src/src/README.md
DELETED
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
# IJBOwnable
|
|
2
|
-
[Git Source](https://github.com/Bananapus/nana-ownable/blob/a74b3181e75adaf0ee0c93cb00bcc5709ca8f314/src/interfaces/IJBOwnable.sol)
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
## Functions
|
|
6
|
-
### PROJECTS
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
```solidity
|
|
10
|
-
function PROJECTS() external view returns (IJBProjects);
|
|
11
|
-
```
|
|
12
|
-
|
|
13
|
-
### jbOwner
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
```solidity
|
|
17
|
-
function jbOwner() external view returns (address owner, uint88 projectOwner, uint8 permissionId);
|
|
18
|
-
```
|
|
19
|
-
|
|
20
|
-
### owner
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
```solidity
|
|
24
|
-
function owner() external view returns (address);
|
|
25
|
-
```
|
|
26
|
-
|
|
27
|
-
### renounceOwnership
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
```solidity
|
|
31
|
-
function renounceOwnership() external;
|
|
32
|
-
```
|
|
33
|
-
|
|
34
|
-
### setPermissionId
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
```solidity
|
|
38
|
-
function setPermissionId(uint8 permissionId) external;
|
|
39
|
-
```
|
|
40
|
-
|
|
41
|
-
### transferOwnership
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
```solidity
|
|
45
|
-
function transferOwnership(address newOwner) external;
|
|
46
|
-
```
|
|
47
|
-
|
|
48
|
-
### transferOwnershipToProject
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
```solidity
|
|
52
|
-
function transferOwnershipToProject(uint256 projectId) external;
|
|
53
|
-
```
|
|
54
|
-
|
|
55
|
-
## Events
|
|
56
|
-
### PermissionIdChanged
|
|
57
|
-
|
|
58
|
-
```solidity
|
|
59
|
-
event PermissionIdChanged(uint8 newId, address caller);
|
|
60
|
-
```
|
|
61
|
-
|
|
62
|
-
### OwnershipTransferred
|
|
63
|
-
|
|
64
|
-
```solidity
|
|
65
|
-
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner, address caller);
|
|
66
|
-
```
|
|
67
|
-
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
# JBOwner
|
|
2
|
-
[Git Source](https://github.com/Bananapus/nana-ownable/blob/a74b3181e75adaf0ee0c93cb00bcc5709ca8f314/src/struct/JBOwner.sol)
|
|
3
|
-
|
|
4
|
-
Owner information for a given instance of `JBOwnableOverrides`.
|
|
5
|
-
|
|
6
|
-
**Notes:**
|
|
7
|
-
- member: owner If `projectId` is 0, this address has owner access.
|
|
8
|
-
|
|
9
|
-
- member: projectId The owner of the `JBProjects` ERC-721 with this ID has owner access. If this is 0, the
|
|
10
|
-
`owner` address has owner access.
|
|
11
|
-
|
|
12
|
-
- member: permissionId The permission ID which corresponds to owner access. See `JBPermissions` in `nana-core`
|
|
13
|
-
and `nana-permission-ids`.
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
```solidity
|
|
17
|
-
struct JBOwner {
|
|
18
|
-
address owner;
|
|
19
|
-
uint88 projectId;
|
|
20
|
-
uint8 permissionId;
|
|
21
|
-
}
|
|
22
|
-
```
|
|
23
|
-
|