@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.
- package/foundry.lock +1 -7
- package/foundry.toml +1 -1
- package/package.json +20 -9
- package/script/Deploy.s.sol +2 -2
- package/src/JB721Checkpoints.sol +60 -18
- package/src/JB721CheckpointsDeployer.sol +10 -5
- package/src/JB721TiersHook.sol +4 -1
- package/src/JB721TiersHookProjectDeployer.sol +68 -30
- package/src/JB721TiersHookStore.sol +1 -4
- package/src/interfaces/IJB721Checkpoints.sol +21 -14
- package/src/interfaces/IJB721CheckpointsDeployer.sol +6 -2
- package/src/interfaces/IJB721TiersHookProjectDeployer.sol +2 -0
- package/test/utils/AccessJBLib.sol +49 -0
- package/test/utils/ForTest_JB721TiersHook.sol +246 -0
- package/test/utils/TestBaseWorkflow.sol +213 -0
- package/test/utils/UnitTestSetup.sol +805 -0
- package/.gas-snapshot +0 -152
- package/ADMINISTRATION.md +0 -87
- package/ARCHITECTURE.md +0 -98
- package/AUDIT_INSTRUCTIONS.md +0 -77
- package/RISKS.md +0 -118
- package/SKILLS.md +0 -43
- package/STYLE_GUIDE.md +0 -610
- package/USER_JOURNEYS.md +0 -121
- package/assets/findings/nana-721-hook-v6-pashov-ai-audit-report-20260330-091257.md +0 -83
- package/slither-ci.config.json +0 -10
- package/test/721HookAttacks.t.sol +0 -408
- package/test/E2E/Pay_Mint_Redeem_E2E.t.sol +0 -985
- package/test/Fork.t.sol +0 -2346
- package/test/TestAuditGaps.sol +0 -1075
- package/test/TestCheckpoints.t.sol +0 -341
- package/test/TestSafeTransferReentrancy.t.sol +0 -305
- package/test/TestVotingUnitsLifecycle.t.sol +0 -313
- package/test/audit/AuditRegressions.t.sol +0 -83
- package/test/audit/CrossCurrencySplitNoPrices.t.sol +0 -123
- package/test/audit/FreshAudit.t.sol +0 -197
- package/test/audit/FutureTierPoC.t.sol +0 -39
- package/test/audit/FutureTierRemoval.t.sol +0 -47
- package/test/audit/Pass12L18.t.sol +0 -80
- package/test/audit/PayCreditsBypassTierSplits.t.sol +0 -200
- package/test/audit/ProjectDeployerAuth.t.sol +0 -266
- package/test/audit/RepoFindings.t.sol +0 -195
- package/test/audit/ReserveActivation.t.sol +0 -87
- package/test/audit/RetroactiveReserveBeneficiaryDilution.t.sol +0 -149
- package/test/audit/SameCurrencyDecimalMismatch.t.sol +0 -249
- package/test/audit/SplitCreditsMismatch.t.sol +0 -219
- package/test/audit/SplitFailureRedistribution.t.sol +0 -143
- package/test/audit/USDTVoidReturnCompat.t.sol +0 -301
- package/test/fork/ERC20CashOutFork.t.sol +0 -633
- package/test/fork/ERC20TierSplitFork.t.sol +0 -596
- package/test/fork/IssueTokensForSplitsFork.t.sol +0 -516
- package/test/invariants/TierLifecycleInvariant.t.sol +0 -188
- package/test/invariants/TieredHookStoreInvariant.t.sol +0 -86
- package/test/invariants/handlers/TierLifecycleHandler.sol +0 -300
- package/test/invariants/handlers/TierStoreHandler.sol +0 -165
- package/test/regression/BrokenTerminalDoesNotDos.t.sol +0 -277
- package/test/regression/CacheTierLookup.t.sol +0 -190
- package/test/regression/ProjectDeployerRulesets.t.sol +0 -358
- package/test/regression/ReserveBeneficiaryOverwrite.t.sol +0 -155
- package/test/regression/SplitDistributionBugs.t.sol +0 -751
- package/test/regression/SplitNoBeneficiary.t.sol +0 -140
- package/test/unit/AuditFixes_Unit.t.sol +0 -624
- package/test/unit/JB721CheckpointsDeployer_AccessControl.t.sol +0 -116
- package/test/unit/JB721TiersRulesetMetadataResolver.t.sol +0 -144
- package/test/unit/JBBitmap.t.sol +0 -170
- package/test/unit/JBIpfsDecoder.t.sol +0 -136
- package/test/unit/TierSupplyReserveCheck.t.sol +0 -221
- package/test/unit/adjustTier_Unit.t.sol +0 -1942
- package/test/unit/deployer_Unit.t.sol +0 -114
- package/test/unit/getters_constructor_Unit.t.sol +0 -593
- package/test/unit/mintFor_mintReservesFor_Unit.t.sol +0 -452
- package/test/unit/pay_CrossCurrency_Unit.t.sol +0 -530
- package/test/unit/pay_Unit.t.sol +0 -1661
- package/test/unit/redeem_Unit.t.sol +0 -473
- package/test/unit/relayBeneficiary_Unit.t.sol +0 -182
- package/test/unit/splitHookDistribution_Unit.t.sol +0 -604
- 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
|
-
}
|