@bananapus/721-hook-v6 0.0.41 → 0.0.43

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.
Files changed (77) hide show
  1. package/foundry.lock +1 -7
  2. package/foundry.toml +1 -1
  3. package/package.json +20 -9
  4. package/script/Deploy.s.sol +2 -2
  5. package/src/JB721Checkpoints.sol +60 -18
  6. package/src/JB721CheckpointsDeployer.sol +10 -5
  7. package/src/JB721TiersHook.sol +4 -1
  8. package/src/JB721TiersHookProjectDeployer.sol +68 -30
  9. package/src/JB721TiersHookStore.sol +1 -4
  10. package/src/interfaces/IJB721Checkpoints.sol +21 -14
  11. package/src/interfaces/IJB721CheckpointsDeployer.sol +6 -2
  12. package/src/interfaces/IJB721TiersHookProjectDeployer.sol +2 -0
  13. package/test/utils/AccessJBLib.sol +49 -0
  14. package/test/utils/ForTest_JB721TiersHook.sol +246 -0
  15. package/test/utils/TestBaseWorkflow.sol +213 -0
  16. package/test/utils/UnitTestSetup.sol +805 -0
  17. package/.gas-snapshot +0 -152
  18. package/ADMINISTRATION.md +0 -87
  19. package/ARCHITECTURE.md +0 -98
  20. package/AUDIT_INSTRUCTIONS.md +0 -77
  21. package/RISKS.md +0 -118
  22. package/SKILLS.md +0 -43
  23. package/STYLE_GUIDE.md +0 -610
  24. package/USER_JOURNEYS.md +0 -121
  25. package/assets/findings/nana-721-hook-v6-pashov-ai-audit-report-20260330-091257.md +0 -83
  26. package/slither-ci.config.json +0 -10
  27. package/test/721HookAttacks.t.sol +0 -408
  28. package/test/E2E/Pay_Mint_Redeem_E2E.t.sol +0 -985
  29. package/test/Fork.t.sol +0 -2346
  30. package/test/TestAuditGaps.sol +0 -1075
  31. package/test/TestCheckpoints.t.sol +0 -341
  32. package/test/TestSafeTransferReentrancy.t.sol +0 -305
  33. package/test/TestVotingUnitsLifecycle.t.sol +0 -313
  34. package/test/audit/AuditRegressions.t.sol +0 -83
  35. package/test/audit/CrossCurrencySplitNoPrices.t.sol +0 -123
  36. package/test/audit/FreshAudit.t.sol +0 -197
  37. package/test/audit/FutureTierPoC.t.sol +0 -39
  38. package/test/audit/FutureTierRemoval.t.sol +0 -47
  39. package/test/audit/Pass12L18.t.sol +0 -80
  40. package/test/audit/PayCreditsBypassTierSplits.t.sol +0 -200
  41. package/test/audit/ProjectDeployerAuth.t.sol +0 -266
  42. package/test/audit/RepoFindings.t.sol +0 -195
  43. package/test/audit/ReserveActivation.t.sol +0 -87
  44. package/test/audit/RetroactiveReserveBeneficiaryDilution.t.sol +0 -149
  45. package/test/audit/SameCurrencyDecimalMismatch.t.sol +0 -249
  46. package/test/audit/SplitCreditsMismatch.t.sol +0 -219
  47. package/test/audit/SplitFailureRedistribution.t.sol +0 -143
  48. package/test/audit/USDTVoidReturnCompat.t.sol +0 -301
  49. package/test/fork/ERC20CashOutFork.t.sol +0 -633
  50. package/test/fork/ERC20TierSplitFork.t.sol +0 -596
  51. package/test/fork/IssueTokensForSplitsFork.t.sol +0 -516
  52. package/test/invariants/TierLifecycleInvariant.t.sol +0 -188
  53. package/test/invariants/TieredHookStoreInvariant.t.sol +0 -86
  54. package/test/invariants/handlers/TierLifecycleHandler.sol +0 -300
  55. package/test/invariants/handlers/TierStoreHandler.sol +0 -165
  56. package/test/regression/BrokenTerminalDoesNotDos.t.sol +0 -277
  57. package/test/regression/CacheTierLookup.t.sol +0 -190
  58. package/test/regression/ProjectDeployerRulesets.t.sol +0 -358
  59. package/test/regression/ReserveBeneficiaryOverwrite.t.sol +0 -155
  60. package/test/regression/SplitDistributionBugs.t.sol +0 -751
  61. package/test/regression/SplitNoBeneficiary.t.sol +0 -140
  62. package/test/unit/AuditFixes_Unit.t.sol +0 -624
  63. package/test/unit/JB721CheckpointsDeployer_AccessControl.t.sol +0 -116
  64. package/test/unit/JB721TiersRulesetMetadataResolver.t.sol +0 -144
  65. package/test/unit/JBBitmap.t.sol +0 -170
  66. package/test/unit/JBIpfsDecoder.t.sol +0 -136
  67. package/test/unit/TierSupplyReserveCheck.t.sol +0 -221
  68. package/test/unit/adjustTier_Unit.t.sol +0 -1942
  69. package/test/unit/deployer_Unit.t.sol +0 -114
  70. package/test/unit/getters_constructor_Unit.t.sol +0 -593
  71. package/test/unit/mintFor_mintReservesFor_Unit.t.sol +0 -452
  72. package/test/unit/pay_CrossCurrency_Unit.t.sol +0 -530
  73. package/test/unit/pay_Unit.t.sol +0 -1661
  74. package/test/unit/redeem_Unit.t.sol +0 -473
  75. package/test/unit/relayBeneficiary_Unit.t.sol +0 -182
  76. package/test/unit/splitHookDistribution_Unit.t.sol +0 -604
  77. package/test/unit/tierSplitRouting_Unit.t.sol +0 -757
@@ -1,140 +0,0 @@
1
- // SPDX-License-Identifier: MIT
2
- pragma solidity 0.8.28;
3
-
4
- // forge-lint: disable-next-line(unaliased-plain-import)
5
- import "../utils/UnitTestSetup.sol";
6
- import {IJB721TiersHookStore} from "../../src/interfaces/IJB721TiersHookStore.sol";
7
- // forge-lint: disable-next-line(unused-import)
8
- import {JB721TiersHookLib} from "../../src/libraries/JB721TiersHookLib.sol";
9
- import {JBSplit} from "@bananapus/core-v6/src/structs/JBSplit.sol";
10
- import {IJBSplitHook} from "@bananapus/core-v6/src/interfaces/IJBSplitHook.sol";
11
- import {IJBSplits} from "@bananapus/core-v6/src/interfaces/IJBSplits.sol";
12
- import {IJBTerminal} from "@bananapus/core-v6/src/interfaces/IJBTerminal.sol";
13
-
14
- /// @notice Split with no beneficiary and no projectId should route funds to the project's
15
- /// balance instead of silently dropping them.
16
- contract Test_L36_SplitNoBeneficiary is UnitTestSetup {
17
- using stdStorage for StdStorage;
18
-
19
- address mockProjectTerminal = makeAddr("mockProjectTerminal");
20
-
21
- function setUp() public override {
22
- super.setUp();
23
- vm.etch(mockJBSplits, new bytes(0x69));
24
- vm.etch(mockProjectTerminal, new bytes(0x69));
25
- }
26
-
27
- /// @notice Verify that a split with projectId==0 and beneficiary==address(0) routes funds to the project's
28
- /// balance.
29
- function test_splitWithNoBeneficiary_routesToProjectBalance() public {
30
- ForTest_JB721TiersHook testHook = _initializeForTestHook(0);
31
- IJB721TiersHookStore hookStore = testHook.STORE();
32
-
33
- // Add a tier with 50% split.
34
- JB721TierConfig[] memory tierConfigs = new JB721TierConfig[](1);
35
- tierConfigs[0].price = 1 ether;
36
- tierConfigs[0].initialSupply = uint32(100);
37
- tierConfigs[0].category = uint24(1);
38
- tierConfigs[0].encodedIPFSUri = bytes32(uint256(0x1234));
39
- tierConfigs[0].splitPercent = 500_000_000; // 50%
40
-
41
- vm.prank(address(testHook));
42
- uint256[] memory tierIds = hookStore.recordAddTiers(tierConfigs);
43
-
44
- // Mock directory checks.
45
- mockAndExpect(
46
- address(mockJBDirectory),
47
- abi.encodeWithSelector(IJBDirectory.isTerminalOf.selector, projectId, mockTerminalAddress),
48
- abi.encode(true)
49
- );
50
-
51
- // Mock splits: a split with projectId==0 and beneficiary==address(0).
52
- JBSplit[] memory splits = new JBSplit[](1);
53
- splits[0] = JBSplit({
54
- percent: uint32(JBConstants.SPLITS_TOTAL_PERCENT),
55
- projectId: 0,
56
- beneficiary: payable(address(0)),
57
- preferAddToBalance: false,
58
- lockedUntil: 0,
59
- hook: IJBSplitHook(address(0))
60
- });
61
-
62
- uint256 groupId = uint256(uint160(address(testHook))) | (uint256(tierIds[0]) << 160);
63
- mockAndExpect(
64
- mockJBSplits, abi.encodeWithSelector(IJBSplits.splitsOf.selector, projectId, 0, groupId), abi.encode(splits)
65
- );
66
-
67
- // Mock the project's primary terminal for addToBalanceOf (this is the fallback for no-recipient splits).
68
- mockAndExpect(
69
- address(mockJBDirectory),
70
- abi.encodeWithSelector(IJBDirectory.primaryTerminalOf.selector, projectId, JBConstants.NATIVE_TOKEN),
71
- abi.encode(mockProjectTerminal)
72
- );
73
-
74
- // Expect addToBalanceOf to be called on the project's terminal with the split amount (0.5 ether).
75
- vm.expectCall(
76
- mockProjectTerminal,
77
- 0.5 ether,
78
- abi.encodeWithSelector(
79
- IJBTerminal.addToBalanceOf.selector, projectId, JBConstants.NATIVE_TOKEN, 0.5 ether, false, "", ""
80
- )
81
- );
82
- // Mock the addToBalanceOf call to succeed.
83
- vm.mockCall(mockProjectTerminal, abi.encodeWithSelector(IJBTerminal.addToBalanceOf.selector), abi.encode());
84
-
85
- // Build payer metadata.
86
- uint16[] memory mintIds = new uint16[](1);
87
- mintIds[0] = uint16(tierIds[0]);
88
- bytes memory payerMetadata = _buildPayerMetadata(address(testHook), mintIds);
89
-
90
- // Build hook metadata (per-tier split breakdown from beforePayRecordedWith).
91
- uint16[] memory splitTierIds = new uint16[](1);
92
- splitTierIds[0] = uint16(tierIds[0]);
93
- uint256[] memory splitAmounts = new uint256[](1);
94
- splitAmounts[0] = 0.5 ether;
95
-
96
- JBAfterPayRecordedContext memory payContext = JBAfterPayRecordedContext({
97
- payer: beneficiary,
98
- projectId: projectId,
99
- rulesetId: 0,
100
- amount: JBTokenAmount({
101
- token: JBConstants.NATIVE_TOKEN,
102
- value: 1 ether,
103
- decimals: 18,
104
- currency: uint32(uint160(JBConstants.NATIVE_TOKEN))
105
- }),
106
- forwardedAmount: JBTokenAmount({
107
- token: JBConstants.NATIVE_TOKEN,
108
- value: 0.5 ether,
109
- decimals: 18,
110
- currency: uint32(uint160(JBConstants.NATIVE_TOKEN))
111
- }),
112
- weight: 10e18,
113
- newlyIssuedTokenCount: 0,
114
- beneficiary: beneficiary,
115
- hookMetadata: abi.encode(beneficiary, beneficiary, abi.encode(splitTierIds, splitAmounts)),
116
- payerMetadata: payerMetadata
117
- });
118
-
119
- vm.deal(mockTerminalAddress, 1 ether);
120
- vm.prank(mockTerminalAddress);
121
- // Should NOT revert — funds should be routed to the project's balance.
122
- testHook.afterPayRecordedWith{value: 0.5 ether}(payContext);
123
- }
124
-
125
- // Helper: build payer metadata for tier IDs.
126
- function _buildPayerMetadata(
127
- address hookAddress,
128
- uint16[] memory tierIdsToMint
129
- )
130
- internal
131
- view
132
- returns (bytes memory)
133
- {
134
- bytes[] memory data = new bytes[](1);
135
- data[0] = abi.encode(false, tierIdsToMint);
136
- bytes4[] memory ids = new bytes4[](1);
137
- ids[0] = metadataHelper.getId("pay", hookAddress);
138
- return metadataHelper.createMetadata(ids, data);
139
- }
140
- }