@bananapus/permission-ids-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.
- package/LICENSE +21 -0
- package/README.md +32 -0
- package/SKILLS.md +82 -0
- package/foundry.lock +5 -0
- package/foundry.toml +20 -0
- package/package.json +12 -0
- package/slither-ci.config.json +10 -0
- package/src/JBPermissionIds.sol +59 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 Bananapus
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
# nana-permission-ids-v6
|
|
2
|
+
|
|
3
|
+
Library of `uint8` constants defining all permission IDs used with `JBPermissions` across the Juicebox V6 ecosystem.
|
|
4
|
+
|
|
5
|
+
## Architecture
|
|
6
|
+
|
|
7
|
+
| Contract | Description |
|
|
8
|
+
|----------|-------------|
|
|
9
|
+
| `JBPermissionIds` | Solidity library with 34 `uint8 internal constant` permission IDs. No state, no functions. |
|
|
10
|
+
|
|
11
|
+
### Permission ID Ranges
|
|
12
|
+
|
|
13
|
+
| IDs | Repository | Permissions |
|
|
14
|
+
|-----|------------|-------------|
|
|
15
|
+
| 1 | All | `ROOT` -- grants all permissions. |
|
|
16
|
+
| 2--20 | nana-core-v6 | `QUEUE_RULESETS`, `LAUNCH_RULESETS`, `CASH_OUT_TOKENS`, `SEND_PAYOUTS`, `MIGRATE_TERMINAL`, `SET_PROJECT_URI`, `DEPLOY_ERC20`, `SET_TOKEN`, `MINT_TOKENS`, `BURN_TOKENS`, `CLAIM_TOKENS`, `TRANSFER_CREDITS`, `SET_CONTROLLER`, `SET_TERMINALS`, `SET_PRIMARY_TERMINAL`, `USE_ALLOWANCE`, `SET_SPLIT_GROUPS`, `ADD_PRICE_FEED`, `ADD_ACCOUNTING_CONTEXTS` |
|
|
17
|
+
| 21--24 | nana-721-hook-v6 | `ADJUST_721_TIERS`, `SET_721_METADATA`, `MINT_721`, `SET_721_DISCOUNT_PERCENT` |
|
|
18
|
+
| 25--27 | nana-buyback-hook-v6 | `SET_BUYBACK_TWAP`, `SET_BUYBACK_POOL`, `SET_BUYBACK_HOOK` |
|
|
19
|
+
| 28--30 | nana-swap-terminal-v6 | `ADD_SWAP_TERMINAL_POOL`, `ADD_SWAP_TERMINAL_TWAP_PARAMS`, `SET_SWAP_TERMINAL` |
|
|
20
|
+
| 31--34 | nana-suckers-v6 | `MAP_SUCKER_TOKEN`, `DEPLOY_SUCKERS`, `SUCKER_SAFETY`, `SET_SUCKER_DEPRECATION` |
|
|
21
|
+
|
|
22
|
+
## Install
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
npm install
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## Develop
|
|
29
|
+
|
|
30
|
+
| Command | Description |
|
|
31
|
+
|---------|-------------|
|
|
32
|
+
| `forge build` | Compile contracts |
|
package/SKILLS.md
ADDED
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
# nana-permission-ids-v5
|
|
2
|
+
|
|
3
|
+
## Purpose
|
|
4
|
+
|
|
5
|
+
Defines all `uint8` permission ID constants used across the Juicebox V5 ecosystem, passed to `JBPermissions.setPermissionsFor()` to grant scoped access to protocol functions.
|
|
6
|
+
|
|
7
|
+
## Contracts
|
|
8
|
+
|
|
9
|
+
| Contract | Role |
|
|
10
|
+
|----------|------|
|
|
11
|
+
| `JBPermissionIds` | Constants-only library. No state, no functions. Pragma `^0.8.0` for maximum compatibility. |
|
|
12
|
+
|
|
13
|
+
## Key Functions
|
|
14
|
+
|
|
15
|
+
N/A -- this is a constants-only library with no callable functions.
|
|
16
|
+
|
|
17
|
+
## All Permission IDs
|
|
18
|
+
|
|
19
|
+
| ID | Name | Grants access to |
|
|
20
|
+
|----|------|-----------------|
|
|
21
|
+
| 1 | `ROOT` | All permissions across every contract. |
|
|
22
|
+
| 2 | `QUEUE_RULESETS` | `JBController.queueRulesetsOf`, `launchRulesetsFor` |
|
|
23
|
+
| 3 | `CASH_OUT_TOKENS` | `JBMultiTerminal.cashOutTokensOf` |
|
|
24
|
+
| 4 | `SEND_PAYOUTS` | `JBMultiTerminal.sendPayoutsOf` |
|
|
25
|
+
| 5 | `MIGRATE_TERMINAL` | `JBMultiTerminal.migrateBalanceOf` |
|
|
26
|
+
| 6 | `SET_PROJECT_URI` | `JBController.setUriOf` |
|
|
27
|
+
| 7 | `DEPLOY_ERC20` | `JBController.deployERC20For` |
|
|
28
|
+
| 8 | `SET_TOKEN` | `JBController.setTokenFor` |
|
|
29
|
+
| 9 | `MINT_TOKENS` | `JBController.mintTokensOf` |
|
|
30
|
+
| 10 | `BURN_TOKENS` | `JBController.burnTokensOf` |
|
|
31
|
+
| 11 | `CLAIM_TOKENS` | `JBController.claimTokensFor` |
|
|
32
|
+
| 12 | `TRANSFER_CREDITS` | `JBController.transferCreditsFrom` |
|
|
33
|
+
| 13 | `SET_CONTROLLER` | `JBDirectory.setControllerOf` |
|
|
34
|
+
| 14 | `SET_TERMINALS` | `JBDirectory.setTerminalsOf` |
|
|
35
|
+
| 15 | `SET_PRIMARY_TERMINAL` | `JBDirectory.setPrimaryTerminalOf` |
|
|
36
|
+
| 16 | `USE_ALLOWANCE` | `JBMultiTerminal.useAllowanceOf` |
|
|
37
|
+
| 17 | `SET_SPLIT_GROUPS` | `JBController.setSplitGroupsOf` |
|
|
38
|
+
| 18 | `ADD_PRICE_FEED` | `JBPrices.addPriceFeedFor` |
|
|
39
|
+
| 19 | `ADD_ACCOUNTING_CONTEXTS` | `JBMultiTerminal.addAccountingContextsFor` |
|
|
40
|
+
| 20 | `ADJUST_721_TIERS` | `JB721TiersHook.adjustTiers` |
|
|
41
|
+
| 21 | `SET_721_METADATA` | `JB721TiersHook.setMetadata` |
|
|
42
|
+
| 22 | `MINT_721` | `JB721TiersHook.mintFor` |
|
|
43
|
+
| 23 | `SET_721_DISCOUNT_PERCENT` | `JB721TiersHook.setDiscountPercentOf` |
|
|
44
|
+
| 24 | `SET_BUYBACK_TWAP` | `JBBuybackHook.setTwapWindowOf`, `setTwapSlippageToleranceOf` |
|
|
45
|
+
| 25 | `SET_BUYBACK_POOL` | `JBBuybackHook.setPoolFor` |
|
|
46
|
+
| 26 | `ADD_SWAP_TERMINAL_POOL` | `JBSwapTerminal.addDefaultPool` |
|
|
47
|
+
| 27 | `ADD_SWAP_TERMINAL_TWAP_PARAMS` | `JBSwapTerminal.addTwapParamsFor` |
|
|
48
|
+
| 28 | `MAP_SUCKER_TOKEN` | `BPSucker.mapToken` |
|
|
49
|
+
| 29 | `DEPLOY_SUCKERS` | `BPSuckerRegistry.deploySuckersFor` |
|
|
50
|
+
| 30 | `SUCKER_SAFETY` | `BPSucker.enableEmergencyHatchFor`, `setDeprecation` |
|
|
51
|
+
|
|
52
|
+
## Integration Points
|
|
53
|
+
|
|
54
|
+
| Dependency | Import | Used For |
|
|
55
|
+
|------------|--------|----------|
|
|
56
|
+
| None | -- | This library has no dependencies. It is imported by all permission-gated Juicebox contracts. |
|
|
57
|
+
|
|
58
|
+
## Key Types
|
|
59
|
+
|
|
60
|
+
N/A -- no structs or enums.
|
|
61
|
+
|
|
62
|
+
## Gotchas
|
|
63
|
+
|
|
64
|
+
- `ROOT` (ID 1) grants all permissions across every contract. Must be granted with extreme care.
|
|
65
|
+
- `SET_TERMINALS` (ID 14) can be used to remove the primary terminal -- the comment in the source warns about this.
|
|
66
|
+
- Permissions are scoped by `(operator, account, projectId)` tuple. Granting with `projectId=0` is a wildcard that applies to all projects for that account.
|
|
67
|
+
- The `uint8` type limits IDs to 0--255. Currently 30 are defined (1--30).
|
|
68
|
+
|
|
69
|
+
## Example Integration
|
|
70
|
+
|
|
71
|
+
```solidity
|
|
72
|
+
import {JBPermissionIds} from "@bananapus/permission-ids-v5/src/JBPermissionIds.sol";
|
|
73
|
+
|
|
74
|
+
// Grant an operator permission to queue rulesets for project 5
|
|
75
|
+
uint8[] memory permissionIds = new uint8[](1);
|
|
76
|
+
permissionIds[0] = JBPermissionIds.QUEUE_RULESETS;
|
|
77
|
+
permissions.setPermissionsFor(account, JBPermissionsData({
|
|
78
|
+
operator: operatorAddress,
|
|
79
|
+
projectId: 5,
|
|
80
|
+
permissionIds: permissionIds
|
|
81
|
+
}));
|
|
82
|
+
```
|
package/foundry.lock
ADDED
package/foundry.toml
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
[profile.default]
|
|
2
|
+
solc = '0.8.23'
|
|
3
|
+
evm_version = 'paris' # Required for L2s (Optimism, Arbitrum, etc.)
|
|
4
|
+
match_contract = "_Local" # Do not run fork tests
|
|
5
|
+
sizes = true
|
|
6
|
+
verbosity = 3 # display errors
|
|
7
|
+
optimizer_runs = 200
|
|
8
|
+
block_number = 14126430
|
|
9
|
+
block_timestamp = 1643802347
|
|
10
|
+
runs = 4096
|
|
11
|
+
libs = ["node_modules", "lib"]
|
|
12
|
+
|
|
13
|
+
[profile.fork] # run via FOUNDRY_PROFILE=fork foundry test
|
|
14
|
+
fs_permissions = [{ access = "read", path = "./deployments/mainnet" }] # Get the deployment addresses for forking
|
|
15
|
+
match_contract = "_Fork"
|
|
16
|
+
|
|
17
|
+
[fmt]
|
|
18
|
+
number_underscore = "thousands"
|
|
19
|
+
multiline_func_header = "all"
|
|
20
|
+
wrap_comments = true
|
package/package.json
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
{
|
|
2
|
+
"detectors_to_exclude": "timestamp,uninitialized-local,naming-convention,solc-version,shadowing-local",
|
|
3
|
+
"exclude_informational": true,
|
|
4
|
+
"exclude_low": false,
|
|
5
|
+
"exclude_medium": false,
|
|
6
|
+
"exclude_high": false,
|
|
7
|
+
"disable_color": false,
|
|
8
|
+
"filter_paths": "(mocks/|test/|node_modules/)",
|
|
9
|
+
"legacy_ast": false
|
|
10
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
// SPDX-License-Identifier: MIT
|
|
2
|
+
// slither-disable-next-line solc-version
|
|
3
|
+
pragma solidity ^0.8.0;
|
|
4
|
+
|
|
5
|
+
/// @notice Permission IDs for `JBPermissions`, used throughout the Bananapus ecosystem. See
|
|
6
|
+
/// [`JBPermissions`](https://github.com/Bananapus/nana-core/blob/main/src/JBPermissions.sol)
|
|
7
|
+
/// @dev `JBPermissions` allows one address to grant another address permission to call functions in Juicebox contracts
|
|
8
|
+
/// on their behalf. Each ID in `JBPermissionIds` grants access to a specific set of these functions.
|
|
9
|
+
library JBPermissionIds {
|
|
10
|
+
uint8 internal constant ROOT = 1; // All permissions across every contract. Very dangerous. BE CAREFUL!
|
|
11
|
+
|
|
12
|
+
/* Used by `nana-core`: https://github.com/Bananapus/nana-core */
|
|
13
|
+
uint8 internal constant QUEUE_RULESETS = 2; // Permission to call `JBController.queueRulesetsOf`.
|
|
14
|
+
uint8 internal constant LAUNCH_RULESETS = 3; // Permission to call `JBController.launchRulesetsFor`.
|
|
15
|
+
uint8 internal constant CASH_OUT_TOKENS = 4; // Permission to call `JBMultiTerminal.cashOutTokensOf`.
|
|
16
|
+
uint8 internal constant SEND_PAYOUTS = 5; // Permission to call `JBMultiTerminal.sendPayoutsOf`.
|
|
17
|
+
uint8 internal constant MIGRATE_TERMINAL = 6; // Permission to call `JBMultiTerminal.migrateBalanceOf`.
|
|
18
|
+
uint8 internal constant SET_PROJECT_URI = 7; // Permission to call `JBController.setUriOf`.
|
|
19
|
+
uint8 internal constant DEPLOY_ERC20 = 8; // Permission to call `JBController.deployERC20For`.
|
|
20
|
+
uint8 internal constant SET_TOKEN = 9; // Permission to call `JBController.setTokenFor`.
|
|
21
|
+
uint8 internal constant MINT_TOKENS = 10; // Permission to call `JBController.mintTokensOf`.
|
|
22
|
+
uint8 internal constant BURN_TOKENS = 11; // Permission to call `JBController.burnTokensOf`.
|
|
23
|
+
uint8 internal constant CLAIM_TOKENS = 12; // Permission to call `JBController.claimTokensFor`.
|
|
24
|
+
uint8 internal constant TRANSFER_CREDITS = 13; // Permission to call `JBController.transferCreditsFrom`.
|
|
25
|
+
uint8 internal constant SET_CONTROLLER = 14; // Permission to call `JBDirectory.setControllerOf`.
|
|
26
|
+
uint8 internal constant SET_TERMINALS = 15; // Permission to call `JBDirectory.setTerminalsOf`.
|
|
27
|
+
// Be careful - `SET_TERMINALS` can be used to remove the primary terminal.
|
|
28
|
+
uint8 internal constant SET_PRIMARY_TERMINAL = 16; // Permission to call `JBDirectory.setPrimaryTerminalOf`.
|
|
29
|
+
uint8 internal constant USE_ALLOWANCE = 17; // Permission to call `JBMultiTerminal.useAllowanceOf`.
|
|
30
|
+
uint8 internal constant SET_SPLIT_GROUPS = 18; // Permission to call `JBController.setSplitGroupsOf`.
|
|
31
|
+
uint8 internal constant ADD_PRICE_FEED = 19; // Permission to call `JBPrices.addPriceFeedFor`.
|
|
32
|
+
uint8 internal constant ADD_ACCOUNTING_CONTEXTS = 20; // Permission to call
|
|
33
|
+
// `JBMultiTerminal.addAccountingContextsFor`.
|
|
34
|
+
|
|
35
|
+
/* Used by `nana-721-hook`: https://github.com/Bananapus/nana-721-hook */
|
|
36
|
+
uint8 internal constant ADJUST_721_TIERS = 21; // Permission to call `JB721TiersHook.adjustTiers`.
|
|
37
|
+
uint8 internal constant SET_721_METADATA = 22; // Permission to call `JB721TiersHook.setMetadata`.
|
|
38
|
+
uint8 internal constant MINT_721 = 23; // Permission to call `JB721TiersHook.mintFor`.
|
|
39
|
+
uint8 internal constant SET_721_DISCOUNT_PERCENT = 24; // Permission to call `JB721TiersHook.setDiscountPercentOf`.
|
|
40
|
+
|
|
41
|
+
/* Used by `nana-buyback-hook`: https://github.com/Bananapus/nana-buyback-hook */
|
|
42
|
+
uint8 internal constant SET_BUYBACK_TWAP = 25; // Permission to call `JBBuybackHook.setTwapWindowOf`.
|
|
43
|
+
uint8 internal constant SET_BUYBACK_POOL = 26; // Permission to call `JBBuybackHook.setPoolFor`.
|
|
44
|
+
uint8 internal constant SET_BUYBACK_HOOK = 27; // Permission to call `JBBuybackHookRegistry.setHookFor` and
|
|
45
|
+
// `JBBuybackHookRegistry.lockHookFor`.
|
|
46
|
+
|
|
47
|
+
/* Used by `nana-swap-terminal`: https://github.com/Bananapus/nana-swap-terminal */
|
|
48
|
+
uint8 internal constant ADD_SWAP_TERMINAL_POOL = 28; // Permission to call `JBSwapTerminal.addDefaultPool`.
|
|
49
|
+
uint8 internal constant ADD_SWAP_TERMINAL_TWAP_PARAMS = 29; // Permission to call
|
|
50
|
+
// `JBSwapTerminal.addTwapParamsFor`.
|
|
51
|
+
uint8 internal constant SET_SWAP_TERMINAL = 30; // Permission to call `JBSwapTerminalRegistry.setTerminalFor` and
|
|
52
|
+
// `JBSwapTerminalRegistry.lockTerminalFor`.
|
|
53
|
+
|
|
54
|
+
/* Used by `nana-suckers`: https://github.com/Bananapus/nana-suckers */
|
|
55
|
+
uint8 internal constant MAP_SUCKER_TOKEN = 31; // Permission to call `JBSucker.mapToken`.
|
|
56
|
+
uint8 internal constant DEPLOY_SUCKERS = 32; // Permission to call `JBSuckerRegistry.deploySuckersFor`.
|
|
57
|
+
uint8 internal constant SUCKER_SAFETY = 33; // Permission to call `JBSucker.enableEmergencyHatchFor`.
|
|
58
|
+
uint8 internal constant SET_SUCKER_DEPRECATION = 34; // Permission to call `JBSucker.setDeprecation`.
|
|
59
|
+
}
|