@croptop/core-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/STYLE_GUIDE.md CHANGED
@@ -2,8 +2,6 @@
2
2
 
3
3
  How we write Solidity and organize repos across the Juicebox V6 ecosystem. `nana-core-v6` is the gold standard — when in doubt, match what it does.
4
4
 
5
- **This repo's scope:** `@croptop/` (not `@bananapus/`). Standard foundry config with no deviations.
6
-
7
5
  ## File Organization
8
6
 
9
7
  ```
@@ -19,8 +17,6 @@ src/
19
17
 
20
18
  One contract/interface/struct/enum per file. Name the file after the type it contains.
21
19
 
22
- **Structs, enums, libraries, and interfaces always go in their subdirectories** (`src/structs/`, `src/enums/`, `src/libraries/`, `src/interfaces/`) — never inline in contract files or placed in `src/` root. This keeps type definitions discoverable and import paths consistent across repos.
23
-
24
20
  ## Pragma Versions
25
21
 
26
22
  ```solidity
@@ -108,14 +104,6 @@ contract JBExample is JBPermissioned, IJBExample {
108
104
  // -------------------------- constructor ---------------------------- //
109
105
  //*********************************************************************//
110
106
 
111
- //*********************************************************************//
112
- // ---------------------- receive / fallback ------------------------- //
113
- //*********************************************************************//
114
-
115
- //*********************************************************************//
116
- // --------------------------- modifiers ----------------------------- //
117
- //*********************************************************************//
118
-
119
107
  //*********************************************************************//
120
108
  // ---------------------- external transactions ---------------------- //
121
109
  //*********************************************************************//
@@ -143,28 +131,23 @@ contract JBExample is JBPermissioned, IJBExample {
143
131
  ```
144
132
 
145
133
  **Section order:**
146
- 1. `using` declarations
147
- 2. Custom errors
148
- 3. Public constants
149
- 4. Internal constants
150
- 5. Public immutable stored properties
151
- 6. Internal immutable stored properties
152
- 7. Public stored properties
153
- 8. Internal stored properties
154
- 9. Constructor
155
- 10. `receive` / `fallback`
156
- 11. Modifiers
157
- 12. External transactions
158
- 13. External views
159
- 14. Public transactions
160
- 15. Internal helpers
161
- 16. Internal views
162
- 17. Private helpers
134
+ 1. Custom errors
135
+ 2. Public constants
136
+ 3. Internal constants
137
+ 4. Public immutable stored properties
138
+ 5. Internal immutable stored properties
139
+ 6. Public stored properties
140
+ 7. Internal stored properties
141
+ 8. Constructor
142
+ 9. External transactions
143
+ 10. External views
144
+ 11. Public transactions
145
+ 12. Internal helpers
146
+ 13. Internal views
147
+ 14. Private helpers
163
148
 
164
149
  Functions are alphabetized within each section.
165
150
 
166
- **Events:** Events are declared in interfaces only, never in implementation contracts. Implementations inherit events from their interface and emit them unqualified. This keeps the ABI definition in one place and allows tests to use interface-qualified event expectations (e.g., `emit IJBController.LaunchProject(...)`).
167
-
168
151
  ## Interface Structure
169
152
 
170
153
  ```solidity
@@ -336,9 +319,6 @@ optimizer_runs = 200
336
319
  libs = ["node_modules", "lib"]
337
320
  fs_permissions = [{ access = "read-write", path = "./"}]
338
321
 
339
- [profile.ci_sizes]
340
- optimizer_runs = 200
341
-
342
322
  [fuzz]
343
323
  runs = 4096
344
324
 
@@ -353,10 +333,14 @@ multiline_func_header = "all"
353
333
  wrap_comments = true
354
334
  ```
355
335
 
356
- **Variations:**
357
- - `evm_version = 'cancun'` for repos using transient storage (buyback-hook, router-terminal, univ4-router)
358
- - `via_ir = true` for repos hitting stack-too-deep (buyback-hook, banny-retail, univ4-lp-split-hook, deploy-all)
359
- - `optimizer = false` only for deploy-all-v6 (stack-too-deep with optimization)
336
+ **Optional sections (add only when needed):**
337
+ - `[rpc_endpoints]` repos with fork tests. Maps named endpoints to env vars (e.g. `ethereum = "${RPC_ETHEREUM_MAINNET}"`).
338
+ - `[profile.ci_sizes]` only when CI needs different optimizer settings than defaults for the size check step (e.g. `optimizer_runs = 200` when the default profile uses a lower value).
339
+
340
+ **Common variations:**
341
+ - `via_ir = true` when hitting stack-too-deep
342
+ - `optimizer = false` when optimization causes stack-too-deep
343
+ - `optimizer_runs` reduced when deep struct nesting causes stack-too-deep at 200 runs
360
344
 
361
345
  ### CI Workflows
362
346
 
@@ -386,8 +370,10 @@ jobs:
386
370
  uses: foundry-rs/foundry-toolchain@v1
387
371
  - name: Run tests
388
372
  run: forge test --fail-fast --summary --detailed --skip "*/script/**"
373
+ env:
374
+ RPC_ETHEREUM_MAINNET: ${{ secrets.RPC_ETHEREUM_MAINNET }}
389
375
  - name: Check contract sizes
390
- run: FOUNDRY_PROFILE=ci_sizes forge build --sizes --skip "*/test/**" --skip "*/script/**" --skip SphinxUtils
376
+ run: forge build --sizes --skip "*/test/**" --skip "*/script/**" --skip SphinxUtils
391
377
  ```
392
378
 
393
379
  **lint.yml:**
@@ -409,11 +395,60 @@ jobs:
409
395
  run: forge fmt --check
410
396
  ```
411
397
 
398
+ **slither.yml** (repos with `src/` contracts only):
399
+ ```yaml
400
+ name: slither
401
+ on:
402
+ pull_request:
403
+ branches:
404
+ - main
405
+ push:
406
+ branches:
407
+ - main
408
+ jobs:
409
+ analyze:
410
+ runs-on: ubuntu-latest
411
+ steps:
412
+ - uses: actions/checkout@v4
413
+ with:
414
+ submodules: recursive
415
+ - uses: actions/setup-node@v4
416
+ with:
417
+ node-version: latest
418
+ - name: Install npm dependencies
419
+ run: npm install --omit=dev
420
+ - name: Install Foundry
421
+ uses: foundry-rs/foundry-toolchain@v1
422
+ - name: Run slither
423
+ uses: crytic/slither-action@v0.3.1
424
+ with:
425
+ slither-config: slither-ci.config.json
426
+ fail-on: medium
427
+ ```
428
+
429
+ **slither-ci.config.json:**
430
+ ```json
431
+ {
432
+ "detectors_to_exclude": "timestamp,uninitialized-local,naming-convention,solc-version,shadowing-local",
433
+ "exclude_informational": true,
434
+ "exclude_low": false,
435
+ "exclude_medium": false,
436
+ "exclude_high": false,
437
+ "disable_color": false,
438
+ "filter_paths": "(mocks/|test/|node_modules/|lib/)",
439
+ "legacy_ast": false
440
+ }
441
+ ```
442
+
443
+ **Variations:**
444
+ - Deployer-only repos (no `src/`, only `script/`) skip slither entirely — the action's internal `forge build` skips `test/` and `script/` by default, leaving nothing to compile.
445
+ - Use inline `// slither-disable-next-line <detector>` to suppress known false positives rather than adding to `detectors_to_exclude` in the config. The comment must be on the line immediately before the flagged expression.
446
+
412
447
  ### package.json
413
448
 
414
449
  ```json
415
450
  {
416
- "name": "@croptop/core-v6",
451
+ "name": "@bananapus/package-name-v6",
417
452
  "version": "x.x.x",
418
453
  "license": "MIT",
419
454
  "repository": { "type": "git", "url": "git+https://github.com/Org/repo.git" },
@@ -433,13 +468,62 @@ jobs:
433
468
 
434
469
  ### remappings.txt
435
470
 
436
- Every repo has a `remappings.txt`. Minimal content:
471
+ Every repo has a `remappings.txt` as the **single source of truth** for import remappings. Never add remappings to `foundry.toml`.
472
+
473
+ **Principle:** Import paths in Solidity source must match npm package names exactly. With `libs = ["node_modules", "lib"]`, Foundry auto-resolves `@scope/package/path/File.sol` → `node_modules/@scope/package/path/File.sol`. No remapping needed for packages installed as real directories.
474
+
475
+ **Note:** Auto-resolution does **not** work for symlinked packages (e.g. npm workspace links). Workspace repos like `deploy-all-v6` and `nana-cli-v6` need explicit `@scope/package/=node_modules/@scope/package/` remappings for each symlinked dependency.
476
+
477
+ **Minimal content** (most repos):
437
478
 
438
479
  ```
439
- @sphinx-labs/contracts/=lib/sphinx/packages/contracts/contracts/foundry
480
+ forge-std/=lib/forge-std/src/
440
481
  ```
441
482
 
442
- Additional mappings as needed for repo-specific dependencies.
483
+ Only add extra remappings for:
484
+ - **`forge-std`** — always needed (git submodule with `src/` subdirectory)
485
+ - **Repo-specific `lib/` submodules** that have no npm package (e.g., `hookmate/=lib/hookmate/src/`)
486
+ - **Symlinked npm packages** — need explicit `@scope/package/=node_modules/@scope/package/` entries
487
+ - **Nested transitive deps** — e.g., `@chainlink/contracts-ccip/` nested inside `@bananapus/suckers-v6/node_modules/`
488
+
489
+ **Never add remappings for:**
490
+ - npm packages that match their import path and are installed as real directories — they auto-resolve
491
+ - Short-form aliases (e.g., `@bananapus/core/` → `@bananapus/core-v6/src/`) — fix the import instead
492
+ - Packages available via npm that are also git submodules — remove the submodule, use npm
493
+
494
+ **Import path convention:**
495
+
496
+ | Package | Import path | Resolves to |
497
+ |---------|------------|-------------|
498
+ | `@bananapus/core-v6` | `@bananapus/core-v6/src/libraries/JBConstants.sol` | `node_modules/@bananapus/core-v6/src/...` |
499
+ | `@openzeppelin/contracts` | `@openzeppelin/contracts/token/ERC20/IERC20.sol` | `node_modules/@openzeppelin/contracts/...` |
500
+ | `@uniswap/v4-core` | `@uniswap/v4-core/src/interfaces/IPoolManager.sol` | `node_modules/@uniswap/v4-core/src/...` |
501
+
502
+ ### Linting
503
+
504
+ Solar (Foundry's built-in linter) runs automatically during `forge build`. It scans all `.sol` files in `libs` directories, including `node_modules`.
505
+
506
+ **All test helpers must use relative imports** (e.g. `../../src/structs/JBRuleset.sol`), not bare `src/` imports. This ensures solar can resolve paths when the helper is consumed via npm in downstream repos.
507
+
508
+ ### Fork Tests
509
+
510
+ Fork tests use named RPC endpoints defined in `[rpc_endpoints]` of `foundry.toml`. No skip guards — fork tests should hard-fail if the RPC endpoint is unavailable, making CI failures explicit.
511
+
512
+ ```solidity
513
+ function setUp() public {
514
+ vm.createSelectFork("ethereum");
515
+ // ... setup code
516
+ }
517
+ ```
518
+
519
+ The endpoint name (e.g. `"ethereum"`) maps to an env var via `foundry.toml`:
520
+
521
+ ```toml
522
+ [rpc_endpoints]
523
+ ethereum = "${RPC_ETHEREUM_MAINNET}"
524
+ ```
525
+
526
+ For multi-chain fork tests, add all needed endpoints.
443
527
 
444
528
  ### Formatting
445
529
 
@@ -467,4 +551,8 @@ CI checks formatting via `forge fmt --check`.
467
551
 
468
552
  ### Contract Size Checks
469
553
 
470
- CI runs `FOUNDRY_PROFILE=ci_sizes forge build --sizes` to catch contracts approaching the 24KB limit. The `ci_sizes` profile uses `optimizer_runs = 200` for realistic size measurement even when the default profile has different optimizer settings.
554
+ CI runs `forge build --sizes` to catch contracts approaching the 24KB limit. When the repo's default `optimizer_runs` differs from what you want for size checking, use `FOUNDRY_PROFILE=ci_sizes forge build --sizes` with a `[profile.ci_sizes]` section in `foundry.toml`.
555
+
556
+ ## Repo-Specific Deviations
557
+
558
+ None. This repo follows the standard configuration exactly.
package/foundry.toml CHANGED
@@ -5,9 +5,6 @@ optimizer_runs = 200
5
5
  libs = ["node_modules", "lib"]
6
6
  fs_permissions = [{ access = "read-write", path = "./"}]
7
7
 
8
- [profile.ci_sizes]
9
- optimizer_runs = 200
10
-
11
8
  [fuzz]
12
9
  runs = 4096
13
10
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@croptop/core-v6",
3
- "version": "0.0.10",
3
+ "version": "0.0.12",
4
4
  "license": "MIT",
5
5
  "repository": {
6
6
  "type": "git",
@@ -16,14 +16,14 @@
16
16
  "artifacts": "source ./.env && npx sphinx artifacts --org-id 'ea165b21-7cdc-4d7b-be59-ecdd4c26bee4' --project-name 'croptop-core-v5'"
17
17
  },
18
18
  "dependencies": {
19
- "@bananapus/721-hook-v6": "^0.0.13",
19
+ "@bananapus/721-hook-v6": "^0.0.14",
20
20
  "@bananapus/buyback-hook-v6": "^0.0.9",
21
- "@bananapus/core-v6": "^0.0.13",
21
+ "@bananapus/core-v6": "^0.0.15",
22
22
  "@bananapus/ownable-v6": "^0.0.7",
23
- "@bananapus/permission-ids-v6": "^0.0.6",
23
+ "@bananapus/permission-ids-v6": "^0.0.7",
24
24
  "@bananapus/router-terminal-v6": "^0.0.9",
25
25
  "@bananapus/suckers-v6": "^0.0.8",
26
- "@openzeppelin/contracts": "^5.2.0"
26
+ "@openzeppelin/contracts": "^5.6.1"
27
27
  },
28
28
  "devDependencies": {
29
29
  "@rev-net/core-v6": "^0.0.8",
package/remappings.txt CHANGED
@@ -1,3 +1 @@
1
- @sphinx-labs/contracts/=node_modules/@sphinx-labs/contracts/contracts/foundry
2
- @croptop/core-v5=./
3
- @croptop/core-v6=./
1
+ forge-std/=lib/forge-std/src/
@@ -16,7 +16,6 @@ import {JBDeploy721TiersHookConfig} from "@bananapus/721-hook-v6/src/structs/JBD
16
16
  import {JB721InitTiersConfig} from "@bananapus/721-hook-v6/src/structs/JB721InitTiersConfig.sol";
17
17
  import {JB721TierConfig} from "@bananapus/721-hook-v6/src/structs/JB721TierConfig.sol";
18
18
  import {JB721TiersHookFlags} from "@bananapus/721-hook-v6/src/structs/JB721TiersHookFlags.sol";
19
- import {IJBPrices} from "@bananapus/core-v6/src/interfaces/IJBPrices.sol";
20
19
  import {IJBSplitHook} from "@bananapus/core-v6/src/interfaces/IJBSplitHook.sol";
21
20
  import {IJBTerminal} from "@bananapus/core-v6/src/interfaces/IJBTerminal.sol";
22
21
  import {JBAccountingContext} from "@bananapus/core-v6/src/structs/JBAccountingContext.sol";
@@ -11,7 +11,6 @@ import {JB721InitTiersConfig} from "@bananapus/721-hook-v6/src/structs/JB721Init
11
11
  import {JB721TierConfig} from "@bananapus/721-hook-v6/src/structs/JB721TierConfig.sol";
12
12
  import {JB721TiersHookFlags} from "@bananapus/721-hook-v6/src/structs/JB721TiersHookFlags.sol";
13
13
  import {JBDeploy721TiersHookConfig} from "@bananapus/721-hook-v6/src/structs/JBDeploy721TiersHookConfig.sol";
14
- import {JBLaunchProjectConfig} from "@bananapus/721-hook-v6/src/structs/JBLaunchProjectConfig.sol";
15
14
  import {JBPermissioned} from "@bananapus/core-v6/src/abstract/JBPermissioned.sol";
16
15
  import {IJBController} from "@bananapus/core-v6/src/interfaces/IJBController.sol";
17
16
  import {IJBPermissions} from "@bananapus/core-v6/src/interfaces/IJBPermissions.sol";
@@ -13,7 +13,6 @@ import {IJBPermissions} from "@bananapus/core-v6/src/interfaces/IJBPermissions.s
13
13
  import {IJBTerminal} from "@bananapus/core-v6/src/interfaces/IJBTerminal.sol";
14
14
  import {JBConstants} from "@bananapus/core-v6/src/libraries/JBConstants.sol";
15
15
  import {JBMetadataResolver} from "@bananapus/core-v6/src/libraries/JBMetadataResolver.sol";
16
- import {JBSplit} from "@bananapus/core-v6/src/structs/JBSplit.sol";
17
16
  import {JBOwnable} from "@bananapus/ownable-v6/src/JBOwnable.sol";
18
17
  import {JBPermissionIds} from "@bananapus/permission-ids-v6/src/JBPermissionIds.sol";
19
18
 
@@ -12,7 +12,6 @@ import {IJB721TiersHook} from "@bananapus/721-hook-v6/src/interfaces/IJB721Tiers
12
12
  import {IJB721TiersHookStore} from "@bananapus/721-hook-v6/src/interfaces/IJB721TiersHookStore.sol";
13
13
  import {JBConstants} from "@bananapus/core-v6/src/libraries/JBConstants.sol";
14
14
  import {JBSplit} from "@bananapus/core-v6/src/structs/JBSplit.sol";
15
- import {JBPermissionIds} from "@bananapus/permission-ids-v6/src/JBPermissionIds.sol";
16
15
 
17
16
  import {CTPublisher} from "../src/CTPublisher.sol";
18
17
  import {CTAllowedPost} from "../src/structs/CTAllowedPost.sol";
@@ -5,16 +5,13 @@ import "forge-std/Test.sol";
5
5
 
6
6
  import {IJBPermissions} from "@bananapus/core-v6/src/interfaces/IJBPermissions.sol";
7
7
  import {IJBDirectory} from "@bananapus/core-v6/src/interfaces/IJBDirectory.sol";
8
- import {IJBTerminal} from "@bananapus/core-v6/src/interfaces/IJBTerminal.sol";
9
8
  import {IJBSplitHook} from "@bananapus/core-v6/src/interfaces/IJBSplitHook.sol";
10
9
  import {IJBOwnable} from "@bananapus/ownable-v6/src/interfaces/IJBOwnable.sol";
11
10
  import {IJB721Hook} from "@bananapus/721-hook-v6/src/interfaces/IJB721Hook.sol";
12
11
  import {IJB721TiersHook} from "@bananapus/721-hook-v6/src/interfaces/IJB721TiersHook.sol";
13
12
  import {IJB721TiersHookStore} from "@bananapus/721-hook-v6/src/interfaces/IJB721TiersHookStore.sol";
14
- import {JB721TierConfig} from "@bananapus/721-hook-v6/src/structs/JB721TierConfig.sol";
15
13
  import {JBConstants} from "@bananapus/core-v6/src/libraries/JBConstants.sol";
16
14
  import {JBSplit} from "@bananapus/core-v6/src/structs/JBSplit.sol";
17
- import {JBPermissionIds} from "@bananapus/permission-ids-v6/src/JBPermissionIds.sol";
18
15
 
19
16
  import {CTPublisher} from "../src/CTPublisher.sol";
20
17
  import {CTAllowedPost} from "../src/structs/CTAllowedPost.sol";
package/test/Fork.t.sol CHANGED
@@ -80,15 +80,8 @@ contract ForkTest is Test {
80
80
  CTDeployer deployer;
81
81
 
82
82
  function setUp() public {
83
- // Skip fork tests when the RPC URL is not available (e.g. in CI).
84
- string memory rpcUrl = vm.envOr("RPC_ETHEREUM_MAINNET", string(""));
85
- if (bytes(rpcUrl).length == 0) {
86
- vm.skip(true);
87
- return;
88
- }
89
-
90
83
  // Fork ETH mainnet.
91
- vm.createSelectFork(rpcUrl);
84
+ vm.createSelectFork("ethereum");
92
85
 
93
86
  // Deploy all JB core contracts fresh within the fork.
94
87
  _deployJBCore();
@@ -5,14 +5,11 @@ import "forge-std/Test.sol";
5
5
 
6
6
  import {IJBPermissions} from "@bananapus/core-v6/src/interfaces/IJBPermissions.sol";
7
7
  import {IJBDirectory} from "@bananapus/core-v6/src/interfaces/IJBDirectory.sol";
8
- import {IJBTerminal} from "@bananapus/core-v6/src/interfaces/IJBTerminal.sol";
9
8
  import {IJBOwnable} from "@bananapus/ownable-v6/src/interfaces/IJBOwnable.sol";
10
9
  import {IJB721Hook} from "@bananapus/721-hook-v6/src/interfaces/IJB721Hook.sol";
11
10
  import {IJB721TiersHook} from "@bananapus/721-hook-v6/src/interfaces/IJB721TiersHook.sol";
12
11
  import {IJB721TiersHookStore} from "@bananapus/721-hook-v6/src/interfaces/IJB721TiersHookStore.sol";
13
- import {JBConstants} from "@bananapus/core-v6/src/libraries/JBConstants.sol";
14
12
  import {JBSplit} from "@bananapus/core-v6/src/structs/JBSplit.sol";
15
- import {JBPermissionIds} from "@bananapus/permission-ids-v6/src/JBPermissionIds.sol";
16
13
 
17
14
  import {CTPublisher} from "../../src/CTPublisher.sol";
18
15
  import {CTAllowedPost} from "../../src/structs/CTAllowedPost.sol";
@@ -5,15 +5,12 @@ import "forge-std/Test.sol";
5
5
 
6
6
  import {IJBPermissions} from "@bananapus/core-v6/src/interfaces/IJBPermissions.sol";
7
7
  import {IJBDirectory} from "@bananapus/core-v6/src/interfaces/IJBDirectory.sol";
8
- import {IJBTerminal} from "@bananapus/core-v6/src/interfaces/IJBTerminal.sol";
9
8
  import {IJBOwnable} from "@bananapus/ownable-v6/src/interfaces/IJBOwnable.sol";
10
9
  import {IJB721Hook} from "@bananapus/721-hook-v6/src/interfaces/IJB721Hook.sol";
11
10
  import {IJB721TiersHook} from "@bananapus/721-hook-v6/src/interfaces/IJB721TiersHook.sol";
12
11
  import {IJB721TiersHookStore} from "@bananapus/721-hook-v6/src/interfaces/IJB721TiersHookStore.sol";
13
12
  import {JB721Tier} from "@bananapus/721-hook-v6/src/structs/JB721Tier.sol";
14
- import {JBConstants} from "@bananapus/core-v6/src/libraries/JBConstants.sol";
15
13
  import {JBSplit} from "@bananapus/core-v6/src/structs/JBSplit.sol";
16
- import {JBPermissionIds} from "@bananapus/permission-ids-v6/src/JBPermissionIds.sol";
17
14
 
18
15
  import {CTPublisher} from "../../src/CTPublisher.sol";
19
16
  import {CTAllowedPost} from "../../src/structs/CTAllowedPost.sol";
@@ -10,9 +10,7 @@ import {IJB721Hook} from "@bananapus/721-hook-v6/src/interfaces/IJB721Hook.sol";
10
10
  import {IJB721TiersHook} from "@bananapus/721-hook-v6/src/interfaces/IJB721TiersHook.sol";
11
11
  import {IJB721TiersHookStore} from "@bananapus/721-hook-v6/src/interfaces/IJB721TiersHookStore.sol";
12
12
  import {JB721Tier} from "@bananapus/721-hook-v6/src/structs/JB721Tier.sol";
13
- import {JBConstants} from "@bananapus/core-v6/src/libraries/JBConstants.sol";
14
13
  import {JBSplit} from "@bananapus/core-v6/src/structs/JBSplit.sol";
15
- import {JBPermissionIds} from "@bananapus/permission-ids-v6/src/JBPermissionIds.sol";
16
14
 
17
15
  import {CTPublisher} from "../../src/CTPublisher.sol";
18
16
  import {CTAllowedPost} from "../../src/structs/CTAllowedPost.sol";