@bananapus/721-hook-v6 0.0.42 → 0.0.45

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 (86) 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 +61 -19
  6. package/src/JB721CheckpointsDeployer.sol +10 -5
  7. package/src/JB721TiersHook.sol +66 -53
  8. package/src/JB721TiersHookDeployer.sol +8 -5
  9. package/src/JB721TiersHookProjectDeployer.sol +87 -46
  10. package/src/JB721TiersHookStore.sol +137 -107
  11. package/src/abstract/JB721Hook.sol +8 -6
  12. package/src/interfaces/IJB721Checkpoints.sol +21 -14
  13. package/src/interfaces/IJB721CheckpointsDeployer.sol +7 -3
  14. package/src/interfaces/IJB721TiersHook.sol +3 -3
  15. package/src/interfaces/IJB721TiersHookProjectDeployer.sol +4 -2
  16. package/src/interfaces/IJB721TiersHookStore.sol +11 -11
  17. package/src/libraries/JB721TiersHookLib.sol +1 -1
  18. package/src/structs/JB721TiersHookFlags.sol +1 -1
  19. package/src/structs/JBPayDataHookRulesetMetadata.sol +1 -1
  20. package/test/utils/AccessJBLib.sol +49 -0
  21. package/test/utils/ForTest_JB721TiersHook.sol +246 -0
  22. package/test/utils/TestBaseWorkflow.sol +213 -0
  23. package/test/utils/UnitTestSetup.sol +805 -0
  24. package/.gas-snapshot +0 -152
  25. package/ADMINISTRATION.md +0 -87
  26. package/ARCHITECTURE.md +0 -98
  27. package/AUDIT_INSTRUCTIONS.md +0 -77
  28. package/RISKS.md +0 -118
  29. package/SKILLS.md +0 -43
  30. package/STYLE_GUIDE.md +0 -610
  31. package/USER_JOURNEYS.md +0 -121
  32. package/assets/findings/nana-721-hook-v6-pashov-ai-audit-report-20260330-091257.md +0 -83
  33. package/slither-ci.config.json +0 -10
  34. package/test/721HookAttacks.t.sol +0 -408
  35. package/test/E2E/Pay_Mint_Redeem_E2E.t.sol +0 -985
  36. package/test/Fork.t.sol +0 -2346
  37. package/test/TestAuditGaps.sol +0 -1075
  38. package/test/TestCheckpoints.t.sol +0 -341
  39. package/test/TestSafeTransferReentrancy.t.sol +0 -305
  40. package/test/TestVotingUnitsLifecycle.t.sol +0 -313
  41. package/test/audit/AuditRegressions.t.sol +0 -83
  42. package/test/audit/CodexNemesisReserveSellout.t.sol +0 -66
  43. package/test/audit/CrossCurrencySplitNoPrices.t.sol +0 -123
  44. package/test/audit/FreshAudit.t.sol +0 -197
  45. package/test/audit/FutureTierPoC.t.sol +0 -39
  46. package/test/audit/FutureTierRemoval.t.sol +0 -47
  47. package/test/audit/Pass12L18.t.sol +0 -80
  48. package/test/audit/PayCreditsBypassTierSplits.t.sol +0 -200
  49. package/test/audit/ProjectDeployerAuth.t.sol +0 -266
  50. package/test/audit/RepoFindings.t.sol +0 -195
  51. package/test/audit/ReserveActivation.t.sol +0 -87
  52. package/test/audit/ReserveSlotProtection.t.sol +0 -273
  53. package/test/audit/RetroactiveReserveBeneficiaryDilution.t.sol +0 -149
  54. package/test/audit/SameCurrencyDecimalMismatch.t.sol +0 -249
  55. package/test/audit/SplitCreditsMismatch.t.sol +0 -219
  56. package/test/audit/SplitFailureRedistribution.t.sol +0 -143
  57. package/test/audit/USDTVoidReturnCompat.t.sol +0 -301
  58. package/test/fork/ERC20CashOutFork.t.sol +0 -633
  59. package/test/fork/ERC20TierSplitFork.t.sol +0 -596
  60. package/test/fork/IssueTokensForSplitsFork.t.sol +0 -516
  61. package/test/invariants/TierLifecycleInvariant.t.sol +0 -188
  62. package/test/invariants/TieredHookStoreInvariant.t.sol +0 -86
  63. package/test/invariants/handlers/TierLifecycleHandler.sol +0 -300
  64. package/test/invariants/handlers/TierStoreHandler.sol +0 -165
  65. package/test/regression/BrokenTerminalDoesNotDos.t.sol +0 -277
  66. package/test/regression/CacheTierLookup.t.sol +0 -190
  67. package/test/regression/ProjectDeployerRulesets.t.sol +0 -358
  68. package/test/regression/ReserveBeneficiaryOverwrite.t.sol +0 -155
  69. package/test/regression/SplitDistributionBugs.t.sol +0 -751
  70. package/test/regression/SplitNoBeneficiary.t.sol +0 -140
  71. package/test/unit/AuditFixes_Unit.t.sol +0 -624
  72. package/test/unit/JB721CheckpointsDeployer_AccessControl.t.sol +0 -116
  73. package/test/unit/JB721TiersRulesetMetadataResolver.t.sol +0 -144
  74. package/test/unit/JBBitmap.t.sol +0 -170
  75. package/test/unit/JBIpfsDecoder.t.sol +0 -136
  76. package/test/unit/TierSupplyReserveCheck.t.sol +0 -221
  77. package/test/unit/adjustTier_Unit.t.sol +0 -1942
  78. package/test/unit/deployer_Unit.t.sol +0 -114
  79. package/test/unit/getters_constructor_Unit.t.sol +0 -593
  80. package/test/unit/mintFor_mintReservesFor_Unit.t.sol +0 -452
  81. package/test/unit/pay_CrossCurrency_Unit.t.sol +0 -530
  82. package/test/unit/pay_Unit.t.sol +0 -1661
  83. package/test/unit/redeem_Unit.t.sol +0 -473
  84. package/test/unit/relayBeneficiary_Unit.t.sol +0 -182
  85. package/test/unit/splitHookDistribution_Unit.t.sol +0 -604
  86. 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
- }