@bananapus/core-v6 0.0.36 → 0.0.38
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 +19 -7
- package/src/JBController.sol +26 -5
- package/src/JBMultiTerminal.sol +85 -47
- package/src/JBTerminalStore.sol +6 -6
- package/src/interfaces/IJBController.sol +4 -1
- package/src/libraries/JBFees.sol +47 -9
- package/src/libraries/JBPayoutSplitGroupLib.sol +2 -2
- package/src/periphery/JBMatchingPriceFeed.sol +1 -1
- package/test/mock/MockMaliciousBeneficiary.sol +15 -15
- package/ADMINISTRATION.md +0 -103
- package/ARCHITECTURE.md +0 -133
- package/AUDIT_INSTRUCTIONS.md +0 -139
- package/RISKS.md +0 -215
- package/SKILLS.md +0 -55
- package/STYLE_GUIDE.md +0 -610
- package/USER_JOURNEYS.md +0 -215
- package/script/Deploy.s.sol +0 -124
- package/script/DeployPeriphery.s.sol +0 -354
- package/slither-ci.config.json +0 -10
- package/test/AuditFixes.t.sol +0 -808
- package/test/ComprehensiveInvariant.t.sol +0 -306
- package/test/CoreExploitTests.t.sol +0 -2741
- package/test/EconomicSimulation.t.sol +0 -348
- package/test/EntryPointPermutations.t.sol +0 -684
- package/test/FlashLoanAttacks.t.sol +0 -797
- package/test/PermissionEscalation.t.sol +0 -711
- package/test/PermissionsInvariant.t.sol +0 -403
- package/test/RulesetTransitions.t.sol +0 -713
- package/test/SplitLoopTests.t.sol +0 -752
- package/test/TestAccessToFunds.sol +0 -2683
- package/test/TestAuditResponseDesignProofs.sol +0 -434
- package/test/TestCashOut.sol +0 -198
- package/test/TestCashOutCountFor.sol +0 -271
- package/test/TestCashOutHooks.sol +0 -351
- package/test/TestCashOutTimingEdge.sol +0 -241
- package/test/TestDataHookFuzzing.sol +0 -524
- package/test/TestDurationUnderflow.sol +0 -233
- package/test/TestFeeFreeCashOutBypass.sol +0 -949
- package/test/TestFeeProcessingFailure.sol +0 -218
- package/test/TestFees.sol +0 -619
- package/test/TestForwardedTokenConsumption.sol +0 -425
- package/test/TestInterfaceSupport.sol +0 -81
- package/test/TestJBERC20Inheritance.sol +0 -103
- package/test/TestL2SequencerPriceFeed.sol +0 -292
- package/test/TestLaunchProject.sol +0 -188
- package/test/TestMetaTx.sol +0 -217
- package/test/TestMetadataOffsetOverflow.sol +0 -179
- package/test/TestMetadataParserLib.sol +0 -471
- package/test/TestMigrationHeldFees.sol +0 -255
- package/test/TestMintTokensOf.sol +0 -185
- package/test/TestMultiTerminalSurplus.sol +0 -348
- package/test/TestMultiTokenSurplus.sol +0 -202
- package/test/TestMultipleAccessLimits.sol +0 -664
- package/test/TestPayBurnRedeemFlow.sol +0 -195
- package/test/TestPayHooks.sol +0 -209
- package/test/TestPermissions.sol +0 -324
- package/test/TestPermissionsEdge.sol +0 -290
- package/test/TestPermit2DataHook.t.sol +0 -360
- package/test/TestPermit2Terminal.sol +0 -372
- package/test/TestRulesetQueueing.sol +0 -1025
- package/test/TestRulesetQueuingStress.sol +0 -806
- package/test/TestRulesetWeightCaching.sol +0 -178
- package/test/TestSplits.sol +0 -391
- package/test/TestTerminalMigration.sol +0 -274
- package/test/TestTerminalPreviewParity.sol +0 -208
- package/test/TestTokenFlow.sol +0 -191
- package/test/TestWeightCacheStaleAfterRejection.sol +0 -303
- package/test/WeirdTokenTests.t.sol +0 -817
- package/test/audit/CashOutReenterPay.t.sol +0 -501
- package/test/audit/CodexHeldFeeRounding.t.sol +0 -159
- package/test/audit/CrossTerminalSurplusSpoof.t.sol +0 -140
- package/test/audit/CycledSurplusAllowanceReset.t.sol +0 -184
- package/test/audit/FeeFreeSurplusLifecycle.t.sol +0 -399
- package/test/audit/FeeFreeSurplusStale.t.sol +0 -248
- package/test/audit/USDTVoidReturnCompat.t.sol +0 -525
- package/test/fork/TestChainlinkPriceFeedFork.sol +0 -254
- package/test/fork/TestSequencerPriceFeedFork.sol +0 -168
- package/test/fork/TestTerminalPreviewParityFork.sol +0 -108
- package/test/formal/BondingCurveProperties.t.sol +0 -420
- package/test/formal/FeeProperties.t.sol +0 -252
- package/test/invariants/Phase3DeepInvariant.t.sol +0 -412
- package/test/invariants/RulesetsInvariant.t.sol +0 -125
- package/test/invariants/TerminalStoreInvariant.t.sol +0 -227
- package/test/invariants/TokensInvariant.t.sol +0 -195
- package/test/invariants/handlers/ComprehensiveHandler.sol +0 -303
- package/test/invariants/handlers/EconomicHandler.sol +0 -377
- package/test/invariants/handlers/Phase3Handler.sol +0 -443
- package/test/invariants/handlers/RulesetsHandler.sol +0 -115
- package/test/invariants/handlers/TerminalStoreHandler.sol +0 -151
- package/test/invariants/handlers/TokensHandler.sol +0 -126
- package/test/regression/HoldFeesCashOutReserved.t.sol +0 -415
- package/test/regression/WeightCacheBoundary.t.sol +0 -291
- package/test/trees/JBController/burnTokensOf.tree +0 -9
- package/test/trees/JBController/claimTokensFor.tree +0 -5
- package/test/trees/JBController/deployERC20For.tree +0 -5
- package/test/trees/JBController/getRulesetOf.tree +0 -5
- package/test/trees/JBController/launchProjectFor.tree +0 -12
- package/test/trees/JBController/launchRulesetsFor.tree +0 -8
- package/test/trees/JBController/migrateController.tree +0 -12
- package/test/trees/JBController/mintTokensOf.tree +0 -12
- package/test/trees/JBController/payReservedTokenToTerminal.tree +0 -8
- package/test/trees/JBController/receiveMigrationFrom.tree +0 -4
- package/test/trees/JBController/sendReservedTokensToSplitsOf.tree +0 -12
- package/test/trees/JBController/setMetadataOf.tree +0 -5
- package/test/trees/JBController/setSplitGroupsOf.tree +0 -5
- package/test/trees/JBController/setTokenFor.tree +0 -5
- package/test/trees/JBController/transferCreditsFrom.tree +0 -8
- package/test/trees/JBDirectory/primaryTerminalOf.tree +0 -8
- package/test/trees/JBDirectory/setControllerOf.tree +0 -11
- package/test/trees/JBDirectory/setPrimaryTerminalOf.tree +0 -15
- package/test/trees/JBDirectory/setTerminalsOf.tree +0 -11
- package/test/trees/JBERC20/initialize.tree +0 -7
- package/test/trees/JBERC20/name.tree +0 -5
- package/test/trees/JBERC20/nonces.tree +0 -5
- package/test/trees/JBERC20/symbol.tree +0 -5
- package/test/trees/JBFeelessAddresses/setFeelessAddress.tree +0 -5
- package/test/trees/JBFeelessAddresses/supportsInterface.tree +0 -5
- package/test/trees/JBFundAccessLimits/payoutLimitOf.tree +0 -5
- package/test/trees/JBFundAccessLimits/payoutLimitsOf.tree +0 -8
- package/test/trees/JBFundAccessLimits/setFundAccessLimitsFor.tree +0 -18
- package/test/trees/JBFundAccessLimits/surplusAllowanceOf.tree +0 -5
- package/test/trees/JBFundAccessLimits/surplusAllowancesOf.tree +0 -8
- package/test/trees/JBMetadataResolver/getDataFor.tree +0 -8
- package/test/trees/JBMultiTerminal/accountingContextsOf.tree +0 -5
- package/test/trees/JBMultiTerminal/addAccountingContextsFor.tree +0 -10
- package/test/trees/JBMultiTerminal/addToBalanceOf.tree +0 -23
- package/test/trees/JBMultiTerminal/cashOutTokensOf.tree +0 -23
- package/test/trees/JBMultiTerminal/executePayout.tree +0 -32
- package/test/trees/JBMultiTerminal/executeProcessFee.tree +0 -14
- package/test/trees/JBMultiTerminal/migrateBalanceOf.tree +0 -12
- package/test/trees/JBMultiTerminal/pay.tree +0 -23
- package/test/trees/JBMultiTerminal/processHeldFeesOf.tree +0 -8
- package/test/trees/JBMultiTerminal/sendPayoutsOf.tree +0 -34
- package/test/trees/JBMultiTerminal/useAllowanceOf.tree +0 -16
- package/test/trees/JBPermissions/hasPermission.tree +0 -8
- package/test/trees/JBPermissions/hasPermissions.tree +0 -8
- package/test/trees/JBPermissions/setPermissionsFor.tree +0 -5
- package/test/trees/JBPrices/addPriceFeedFor.tree +0 -14
- package/test/trees/JBPrices/pricePerUnitOf.tree +0 -11
- package/test/trees/JBProjects/createFor.tree +0 -11
- package/test/trees/JBProjects/setTokenUriResolver.tree +0 -5
- package/test/trees/JBProjects/supportsInterface.tree +0 -9
- package/test/trees/JBProjects/tokenURI.tree +0 -5
- package/test/trees/JBRulesets/currentApprovalStatusForLatestRulesetOf.tree +0 -8
- package/test/trees/JBRulesets/currentOf.tree +0 -12
- package/test/trees/JBRulesets/getRulesetOf.tree +0 -5
- package/test/trees/JBRulesets/latestQueuedRulesetOf.tree +0 -10
- package/test/trees/JBRulesets/rulesetsOf.tree +0 -11
- package/test/trees/JBRulesets/upcomingRulesetOf.tree +0 -20
- package/test/trees/JBRulesets/updateRulesetWeightCache.tree +0 -5
- package/test/trees/JBSplits/setSplitGroupsOf.tree +0 -17
- package/test/trees/JBSplits/splitsOf.tree +0 -5
- package/test/trees/JBTerminalStore/currentReclaimableSurplusOf.tree +0 -16
- package/test/trees/JBTerminalStore/currentSurplusOf.tree +0 -25
- package/test/trees/JBTerminalStore/currentTotalSurplusOf.tree +0 -5
- package/test/trees/JBTerminalStore/recordCashOutsFor.tree +0 -16
- package/test/trees/JBTerminalStore/recordPaymentFrom.tree +0 -14
- package/test/trees/JBTerminalStore/recordPayoutFor.tree +0 -10
- package/test/trees/JBTerminalStore/recordTerminalMigration.tree +0 -5
- package/test/trees/JBTerminalStore/recordUsedAllowanceOf.tree +0 -10
- package/test/trees/JBTokens/burnFrom.tree +0 -10
- package/test/trees/JBTokens/claimTokensFor.tree +0 -10
- package/test/trees/JBTokens/deployERC20For.tree +0 -12
- package/test/trees/JBTokens/mintFor.tree +0 -10
- package/test/trees/JBTokens/setTokenFor.tree +0 -11
- package/test/trees/JBTokens/totalBalanceOf.tree +0 -5
- package/test/trees/JBTokens/totalSupplyOf.tree +0 -5
- package/test/trees/JBTokens/transferCreditsFrom.tree +0 -8
- package/test/trees/mintTokensOf.tree +0 -12
- package/test/units/static/JBChainlinkV3PriceFeed/TestPriceFeed.sol +0 -223
- package/test/units/static/JBController/JBControllerSetup.sol +0 -50
- package/test/units/static/JBController/TestBurnTokensOf.sol +0 -114
- package/test/units/static/JBController/TestClaimTokensFor.sol +0 -63
- package/test/units/static/JBController/TestDeployErc20For.sol +0 -86
- package/test/units/static/JBController/TestLaunchProjectFor.sol +0 -302
- package/test/units/static/JBController/TestLaunchRulesetsFor.sol +0 -342
- package/test/units/static/JBController/TestMigrateController.sol +0 -157
- package/test/units/static/JBController/TestMintTokensOfUnits.sol +0 -111
- package/test/units/static/JBController/TestOmnichainRulesetOperator.sol +0 -324
- package/test/units/static/JBController/TestPayReservedTokenToTerminal.sol +0 -74
- package/test/units/static/JBController/TestPreviewMintOf.sol +0 -117
- package/test/units/static/JBController/TestReceiveMigrationFrom.sol +0 -99
- package/test/units/static/JBController/TestRulesetViews.sol +0 -225
- package/test/units/static/JBController/TestSendReservedTokensToSplitsOf.sol +0 -615
- package/test/units/static/JBController/TestSetSplitGroupsOf.sol +0 -68
- package/test/units/static/JBController/TestSetTokenFor.sol +0 -239
- package/test/units/static/JBController/TestSetUriOf.sol +0 -57
- package/test/units/static/JBController/TestTransferCreditsFrom.sol +0 -169
- package/test/units/static/JBDeadline/TestDeadlineFuzz.sol +0 -211
- package/test/units/static/JBDirectory/JBDirectorySetup.sol +0 -26
- package/test/units/static/JBDirectory/TestPrimaryTerminalOf.sol +0 -126
- package/test/units/static/JBDirectory/TestSetControllerOf.sol +0 -183
- package/test/units/static/JBDirectory/TestSetControllerOfMigrationOrder.sol +0 -104
- package/test/units/static/JBDirectory/TestSetPrimaryTerminalOf.sol +0 -179
- package/test/units/static/JBDirectory/TestSetTerminalsOf.sol +0 -137
- package/test/units/static/JBERC20/JBERC20Setup.sol +0 -34
- package/test/units/static/JBERC20/SigUtils.sol +0 -36
- package/test/units/static/JBERC20/TestInitialize.sol +0 -60
- package/test/units/static/JBERC20/TestName.sol +0 -30
- package/test/units/static/JBERC20/TestNonces.sol +0 -62
- package/test/units/static/JBERC20/TestSymbol.sol +0 -31
- package/test/units/static/JBFeelessAdresses/JBFeelessSetup.sol +0 -22
- package/test/units/static/JBFeelessAdresses/TestInterfaces.sol +0 -30
- package/test/units/static/JBFeelessAdresses/TestSetFeelessAddress.sol +0 -35
- package/test/units/static/JBFees/TestFeesFuzz.sol +0 -79
- package/test/units/static/JBFixedPointNumber/TestAdjustDecimals.sol +0 -16
- package/test/units/static/JBFixedPointNumber/TestAdjustDecimalsFuzz.sol +0 -71
- package/test/units/static/JBFundAccessLimits/JBFundAccessSetup.sol +0 -24
- package/test/units/static/JBFundAccessLimits/TestFundAccessLimitsEdge.sol +0 -163
- package/test/units/static/JBFundAccessLimits/TestPayoutLimitOf.sol +0 -59
- package/test/units/static/JBFundAccessLimits/TestPayoutLimitsOf.sol +0 -101
- package/test/units/static/JBFundAccessLimits/TestSetFundAccessLimitsFor.sol +0 -189
- package/test/units/static/JBFundAccessLimits/TestSurplusAllowanceOf.sol +0 -64
- package/test/units/static/JBFundAccessLimits/TestSurplusAllowancesOf.sol +0 -102
- package/test/units/static/JBMetadataResolver/TestGetDataFor.sol +0 -90
- package/test/units/static/JBMetadataResolver/TestMetadataResolverEdgeCases.sol +0 -247
- package/test/units/static/JBMetadataResolver/TestMetadataResolverFuzz.sol +0 -229
- package/test/units/static/JBMultiTerminal/JBMultiTerminalSetup.sol +0 -50
- package/test/units/static/JBMultiTerminal/TestAccountingContextsOf.sol +0 -72
- package/test/units/static/JBMultiTerminal/TestAddAccountingContextsFor.sol +0 -289
- package/test/units/static/JBMultiTerminal/TestAddToBalanceOf.sol +0 -474
- package/test/units/static/JBMultiTerminal/TestCashOutTokensOf.sol +0 -624
- package/test/units/static/JBMultiTerminal/TestExecutePayout.sol +0 -578
- package/test/units/static/JBMultiTerminal/TestExecuteProcessFee.sol +0 -202
- package/test/units/static/JBMultiTerminal/TestMigrateBalanceOf.sol +0 -222
- package/test/units/static/JBMultiTerminal/TestPay.sol +0 -604
- package/test/units/static/JBMultiTerminal/TestPreviewCashOutFrom.sol +0 -117
- package/test/units/static/JBMultiTerminal/TestPreviewPayFor.sol +0 -114
- package/test/units/static/JBMultiTerminal/TestProcessHeldFeesOf.sol +0 -228
- package/test/units/static/JBMultiTerminal/TestSelfPayRevert.sol +0 -55
- package/test/units/static/JBMultiTerminal/TestSendPayoutsOf.sol +0 -257
- package/test/units/static/JBMultiTerminal/TestUseAllowanceOf.sol +0 -611
- package/test/units/static/JBPermissions/JBPermissionsSetup.sol +0 -20
- package/test/units/static/JBPermissions/TestHasPermission.sol +0 -50
- package/test/units/static/JBPermissions/TestHasPermissions.sol +0 -93
- package/test/units/static/JBPermissions/TestSetPermissionsFor.sol +0 -64
- package/test/units/static/JBPrices/JBPricesSetup.sol +0 -32
- package/test/units/static/JBPrices/TestAddPriceFeedFor.sol +0 -107
- package/test/units/static/JBPrices/TestPricePerUnitOf.sol +0 -132
- package/test/units/static/JBPrices/TestPrices.sol +0 -265
- package/test/units/static/JBProjects/JBProjectsSetup.sol +0 -22
- package/test/units/static/JBProjects/TestCreateFor.sol +0 -71
- package/test/units/static/JBProjects/TestInitialProject.sol +0 -21
- package/test/units/static/JBProjects/TestInterfaces.sol +0 -26
- package/test/units/static/JBProjects/TestSetResolver.sol +0 -37
- package/test/units/static/JBProjects/TestTokenUri.sol +0 -40
- package/test/units/static/JBRulesetMetadataResolver/TestSetCashOutTaxRateTo.sol +0 -108
- package/test/units/static/JBRulesets/JBRulesetsSetup.sol +0 -24
- package/test/units/static/JBRulesets/TestCurrentApprovalStatusForLatestRulesetOf.sol +0 -265
- package/test/units/static/JBRulesets/TestCurrentOf.sol +0 -242
- package/test/units/static/JBRulesets/TestGetRulesetOf.sol +0 -100
- package/test/units/static/JBRulesets/TestLatestQueuedRulesetOf.sol +0 -260
- package/test/units/static/JBRulesets/TestRulesets.sol +0 -632
- package/test/units/static/JBRulesets/TestRulesetsOf.sol +0 -37
- package/test/units/static/JBRulesets/TestUpcomingRulesetOf.sol +0 -522
- package/test/units/static/JBRulesets/TestUpdateRulesetWeightCache.sol +0 -96
- package/test/units/static/JBSplits/JBSplitsSetup.sol +0 -26
- package/test/units/static/JBSplits/TestSelfManagedSplitGroups.sol +0 -552
- package/test/units/static/JBSplits/TestSetSplitGroupsOf.sol +0 -377
- package/test/units/static/JBSplits/TestSplitsLockedEdge.sol +0 -267
- package/test/units/static/JBSplits/TestSplitsOf.sol +0 -24
- package/test/units/static/JBSplits/TestSplitsPacking.sol +0 -36
- package/test/units/static/JBSurplus/TestSurplusFuzz.sol +0 -160
- package/test/units/static/JBTerminalStore/JBTerminalStoreSetup.sol +0 -45
- package/test/units/static/JBTerminalStore/TestCurrentReclaimableSurplusOf.sol +0 -536
- package/test/units/static/JBTerminalStore/TestCurrentSurplusOf.sol +0 -463
- package/test/units/static/JBTerminalStore/TestCurrentTotalSurplusOf.sol +0 -135
- package/test/units/static/JBTerminalStore/TestPreviewCashOutFrom.sol +0 -476
- package/test/units/static/JBTerminalStore/TestPreviewPayFrom.sol +0 -494
- package/test/units/static/JBTerminalStore/TestRecordCashOutsFor.sol +0 -652
- package/test/units/static/JBTerminalStore/TestRecordPaymentFrom.sol +0 -744
- package/test/units/static/JBTerminalStore/TestRecordPayoutFor.sol +0 -289
- package/test/units/static/JBTerminalStore/TestRecordTerminalMigration.sol +0 -138
- package/test/units/static/JBTerminalStore/TestRecordUsedAllowanceOf.sol +0 -415
- package/test/units/static/JBTerminalStore/TestUint224Overflow.sol +0 -219
- package/test/units/static/JBTokens/JBTokensSetup.sol +0 -32
- package/test/units/static/JBTokens/TestBurnFrom.sol +0 -107
- package/test/units/static/JBTokens/TestClaimTokensFor.sol +0 -110
- package/test/units/static/JBTokens/TestDeployERC20ForUnits.sol +0 -92
- package/test/units/static/JBTokens/TestMintFor.sol +0 -100
- package/test/units/static/JBTokens/TestSetTokenFor.sol +0 -98
- package/test/units/static/JBTokens/TestTotalBalanceOf.sol +0 -65
- package/test/units/static/JBTokens/TestTotalSupplyOf.sol +0 -56
- package/test/units/static/JBTokens/TestTransferCreditsFrom.sol +0 -56
|
@@ -1,552 +0,0 @@
|
|
|
1
|
-
// SPDX-License-Identifier: MIT
|
|
2
|
-
pragma solidity 0.8.28;
|
|
3
|
-
|
|
4
|
-
import {JBSplits} from "../../../../src/JBSplits.sol";
|
|
5
|
-
import {JBControlled} from "../../../../src/abstract/JBControlled.sol";
|
|
6
|
-
import {IJBDirectory} from "../../../../src/interfaces/IJBDirectory.sol";
|
|
7
|
-
import {IJBSplitHook} from "../../../../src/interfaces/IJBSplitHook.sol";
|
|
8
|
-
import {IJBSplits} from "../../../../src/interfaces/IJBSplits.sol";
|
|
9
|
-
import {JBConstants} from "../../../../src/libraries/JBConstants.sol";
|
|
10
|
-
import {JBSplit} from "../../../../src/structs/JBSplit.sol";
|
|
11
|
-
import {JBSplitGroup} from "../../../../src/structs/JBSplitGroup.sol";
|
|
12
|
-
import {JBSplitsSetup} from "./JBSplitsSetup.sol";
|
|
13
|
-
|
|
14
|
-
contract TestSelfManagedSplitGroups_Local is JBSplitsSetup {
|
|
15
|
-
address payable _bene = payable(makeAddr("beneficiary"));
|
|
16
|
-
uint64 _projectId = 1;
|
|
17
|
-
uint256 _rulesetId = block.timestamp;
|
|
18
|
-
|
|
19
|
-
function setUp() public {
|
|
20
|
-
super.splitsSetup();
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
// ───────────────────────────────── Helpers
|
|
24
|
-
// ─────────────────────────────────
|
|
25
|
-
|
|
26
|
-
/// @dev Build a single-split group for the given groupId.
|
|
27
|
-
function _makeSplitGroup(
|
|
28
|
-
uint256 groupId,
|
|
29
|
-
uint32 percent,
|
|
30
|
-
address payable beneficiary
|
|
31
|
-
)
|
|
32
|
-
internal
|
|
33
|
-
pure
|
|
34
|
-
returns (JBSplitGroup[] memory groups)
|
|
35
|
-
{
|
|
36
|
-
groups = new JBSplitGroup[](1);
|
|
37
|
-
JBSplit[] memory splits = new JBSplit[](1);
|
|
38
|
-
splits[0] = JBSplit({
|
|
39
|
-
preferAddToBalance: false,
|
|
40
|
-
percent: percent,
|
|
41
|
-
projectId: 0,
|
|
42
|
-
beneficiary: beneficiary,
|
|
43
|
-
lockedUntil: 0,
|
|
44
|
-
hook: IJBSplitHook(address(0))
|
|
45
|
-
});
|
|
46
|
-
groups[0] = JBSplitGroup({groupId: groupId, splits: splits});
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
/// @dev Mock directory to return `controller` for `_projectId`.
|
|
50
|
-
function _mockController(address controller) internal {
|
|
51
|
-
bytes memory call_ = abi.encodeCall(IJBDirectory.controllerOf, (uint256(_projectId)));
|
|
52
|
-
bytes memory ret = abi.encode(controller);
|
|
53
|
-
mockExpect(address(directory), call_, ret);
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
// ──────────────────── Self-managed namespace: happy paths
|
|
57
|
-
// ──────────────────
|
|
58
|
-
|
|
59
|
-
function test_CallerCanSetSplitsInOwnGroupNamespace() external {
|
|
60
|
-
// Self-auth requires non-zero upper 96 bits + lower 160 bits == msg.sender.
|
|
61
|
-
address caller = makeAddr("hookContract");
|
|
62
|
-
uint256 groupId = (1 << 160) | uint256(uint160(caller));
|
|
63
|
-
|
|
64
|
-
JBSplitGroup[] memory groups = _makeSplitGroup(groupId, JBConstants.SPLITS_TOTAL_PERCENT / 2, _bene);
|
|
65
|
-
|
|
66
|
-
vm.prank(caller);
|
|
67
|
-
_splits.setSplitGroupsOf(_projectId, _rulesetId, groups);
|
|
68
|
-
|
|
69
|
-
JBSplit[] memory result = _splits.splitsOf(_projectId, _rulesetId, groupId);
|
|
70
|
-
assertEq(result.length, 1);
|
|
71
|
-
assertEq(result[0].beneficiary, _bene);
|
|
72
|
-
assertEq(result[0].percent, JBConstants.SPLITS_TOTAL_PERCENT / 2);
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
function test_CallerCanSetSplitsWithUpperBitsSubcategory() external {
|
|
76
|
-
// The upper 96 bits are free for sub-categorization.
|
|
77
|
-
address caller = makeAddr("hookContract");
|
|
78
|
-
uint256 subcategory = 42;
|
|
79
|
-
uint256 groupId = (subcategory << 160) | uint256(uint160(caller));
|
|
80
|
-
|
|
81
|
-
JBSplitGroup[] memory groups = _makeSplitGroup(groupId, JBConstants.SPLITS_TOTAL_PERCENT, _bene);
|
|
82
|
-
|
|
83
|
-
vm.prank(caller);
|
|
84
|
-
_splits.setSplitGroupsOf(_projectId, _rulesetId, groups);
|
|
85
|
-
|
|
86
|
-
JBSplit[] memory result = _splits.splitsOf(_projectId, _rulesetId, groupId);
|
|
87
|
-
assertEq(result.length, 1);
|
|
88
|
-
assertEq(result[0].beneficiary, _bene);
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
function test_DifferentSubcategoriesAreIndependent() external {
|
|
92
|
-
// Two different subcategories for the same caller store independently.
|
|
93
|
-
address caller = makeAddr("hookContract");
|
|
94
|
-
uint256 groupIdA = (1 << 160) | uint256(uint160(caller));
|
|
95
|
-
uint256 groupIdB = (2 << 160) | uint256(uint160(caller));
|
|
96
|
-
|
|
97
|
-
address payable beneA = payable(makeAddr("beneA"));
|
|
98
|
-
address payable beneB = payable(makeAddr("beneB"));
|
|
99
|
-
|
|
100
|
-
JBSplitGroup[] memory groupsA = _makeSplitGroup(groupIdA, JBConstants.SPLITS_TOTAL_PERCENT / 2, beneA);
|
|
101
|
-
JBSplitGroup[] memory groupsB = _makeSplitGroup(groupIdB, JBConstants.SPLITS_TOTAL_PERCENT / 3, beneB);
|
|
102
|
-
|
|
103
|
-
vm.prank(caller);
|
|
104
|
-
_splits.setSplitGroupsOf(_projectId, _rulesetId, groupsA);
|
|
105
|
-
|
|
106
|
-
vm.prank(caller);
|
|
107
|
-
_splits.setSplitGroupsOf(_projectId, _rulesetId, groupsB);
|
|
108
|
-
|
|
109
|
-
JBSplit[] memory resultA = _splits.splitsOf(_projectId, _rulesetId, groupIdA);
|
|
110
|
-
JBSplit[] memory resultB = _splits.splitsOf(_projectId, _rulesetId, groupIdB);
|
|
111
|
-
|
|
112
|
-
assertEq(resultA.length, 1);
|
|
113
|
-
assertEq(resultA[0].beneficiary, beneA);
|
|
114
|
-
assertEq(resultA[0].percent, JBConstants.SPLITS_TOTAL_PERCENT / 2);
|
|
115
|
-
|
|
116
|
-
assertEq(resultB.length, 1);
|
|
117
|
-
assertEq(resultB[0].beneficiary, beneB);
|
|
118
|
-
assertEq(resultB[0].percent, JBConstants.SPLITS_TOTAL_PERCENT / 3);
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
function test_CallerCanSetMultipleSplitsInOwnGroup() external {
|
|
122
|
-
// Multiple splits in the same self-managed group.
|
|
123
|
-
address caller = makeAddr("hookContract");
|
|
124
|
-
uint256 groupId = (1 << 160) | uint256(uint160(caller));
|
|
125
|
-
|
|
126
|
-
address payable bene1 = payable(makeAddr("bene1"));
|
|
127
|
-
address payable bene2 = payable(makeAddr("bene2"));
|
|
128
|
-
|
|
129
|
-
JBSplitGroup[] memory groups = new JBSplitGroup[](1);
|
|
130
|
-
JBSplit[] memory splits = new JBSplit[](2);
|
|
131
|
-
splits[0] = JBSplit({
|
|
132
|
-
preferAddToBalance: false,
|
|
133
|
-
percent: JBConstants.SPLITS_TOTAL_PERCENT / 2,
|
|
134
|
-
projectId: 0,
|
|
135
|
-
beneficiary: bene1,
|
|
136
|
-
lockedUntil: 0,
|
|
137
|
-
hook: IJBSplitHook(address(0))
|
|
138
|
-
});
|
|
139
|
-
splits[1] = JBSplit({
|
|
140
|
-
preferAddToBalance: false,
|
|
141
|
-
percent: JBConstants.SPLITS_TOTAL_PERCENT / 2,
|
|
142
|
-
projectId: 0,
|
|
143
|
-
beneficiary: bene2,
|
|
144
|
-
lockedUntil: 0,
|
|
145
|
-
hook: IJBSplitHook(address(0))
|
|
146
|
-
});
|
|
147
|
-
groups[0] = JBSplitGroup({groupId: groupId, splits: splits});
|
|
148
|
-
|
|
149
|
-
vm.prank(caller);
|
|
150
|
-
_splits.setSplitGroupsOf(_projectId, _rulesetId, groups);
|
|
151
|
-
|
|
152
|
-
JBSplit[] memory result = _splits.splitsOf(_projectId, _rulesetId, groupId);
|
|
153
|
-
assertEq(result.length, 2);
|
|
154
|
-
assertEq(result[0].beneficiary, bene1);
|
|
155
|
-
assertEq(result[1].beneficiary, bene2);
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
function test_CallerCanOverwriteOwnSplits() external {
|
|
159
|
-
// Caller can overwrite their own splits.
|
|
160
|
-
address caller = makeAddr("hookContract");
|
|
161
|
-
uint256 groupId = (1 << 160) | uint256(uint160(caller));
|
|
162
|
-
|
|
163
|
-
address payable beneOld = payable(makeAddr("beneOld"));
|
|
164
|
-
address payable beneNew = payable(makeAddr("beneNew"));
|
|
165
|
-
|
|
166
|
-
JBSplitGroup[] memory groups = _makeSplitGroup(groupId, JBConstants.SPLITS_TOTAL_PERCENT / 2, beneOld);
|
|
167
|
-
|
|
168
|
-
vm.prank(caller);
|
|
169
|
-
_splits.setSplitGroupsOf(_projectId, _rulesetId, groups);
|
|
170
|
-
|
|
171
|
-
// Overwrite with new beneficiary.
|
|
172
|
-
groups = _makeSplitGroup(groupId, JBConstants.SPLITS_TOTAL_PERCENT / 3, beneNew);
|
|
173
|
-
|
|
174
|
-
vm.prank(caller);
|
|
175
|
-
_splits.setSplitGroupsOf(_projectId, _rulesetId, groups);
|
|
176
|
-
|
|
177
|
-
JBSplit[] memory result = _splits.splitsOf(_projectId, _rulesetId, groupId);
|
|
178
|
-
assertEq(result.length, 1);
|
|
179
|
-
assertEq(result[0].beneficiary, beneNew);
|
|
180
|
-
assertEq(result[0].percent, JBConstants.SPLITS_TOTAL_PERCENT / 3);
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
function test_SelfManagedSplitsEmitSetSplitEvent() external {
|
|
184
|
-
// Setting self-managed splits emits SetSplit with correct caller.
|
|
185
|
-
address caller = makeAddr("hookContract");
|
|
186
|
-
uint256 groupId = (1 << 160) | uint256(uint160(caller));
|
|
187
|
-
|
|
188
|
-
JBSplitGroup[] memory groups = _makeSplitGroup(groupId, JBConstants.SPLITS_TOTAL_PERCENT, _bene);
|
|
189
|
-
|
|
190
|
-
vm.expectEmit();
|
|
191
|
-
emit IJBSplits.SetSplit(_projectId, _rulesetId, groupId, groups[0].splits[0], caller);
|
|
192
|
-
|
|
193
|
-
vm.prank(caller);
|
|
194
|
-
_splits.setSplitGroupsOf(_projectId, _rulesetId, groups);
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
function test_SelfManagedSplitsWorkAcrossRulesets() external {
|
|
198
|
-
// Caller can set splits in the same group but different rulesets.
|
|
199
|
-
address caller = makeAddr("hookContract");
|
|
200
|
-
uint256 groupId = (1 << 160) | uint256(uint160(caller));
|
|
201
|
-
|
|
202
|
-
uint256 rulesetA = 100;
|
|
203
|
-
uint256 rulesetB = 200;
|
|
204
|
-
|
|
205
|
-
address payable beneA = payable(makeAddr("beneA"));
|
|
206
|
-
address payable beneB = payable(makeAddr("beneB"));
|
|
207
|
-
|
|
208
|
-
vm.prank(caller);
|
|
209
|
-
_splits.setSplitGroupsOf(
|
|
210
|
-
_projectId, rulesetA, _makeSplitGroup(groupId, JBConstants.SPLITS_TOTAL_PERCENT, beneA)
|
|
211
|
-
);
|
|
212
|
-
|
|
213
|
-
vm.prank(caller);
|
|
214
|
-
_splits.setSplitGroupsOf(
|
|
215
|
-
_projectId, rulesetB, _makeSplitGroup(groupId, JBConstants.SPLITS_TOTAL_PERCENT, beneB)
|
|
216
|
-
);
|
|
217
|
-
|
|
218
|
-
JBSplit[] memory resultA = _splits.splitsOf(_projectId, rulesetA, groupId);
|
|
219
|
-
JBSplit[] memory resultB = _splits.splitsOf(_projectId, rulesetB, groupId);
|
|
220
|
-
|
|
221
|
-
assertEq(resultA[0].beneficiary, beneA);
|
|
222
|
-
assertEq(resultB[0].beneficiary, beneB);
|
|
223
|
-
}
|
|
224
|
-
|
|
225
|
-
// ────────────────────── Self-managed: validation still applies
|
|
226
|
-
// ─────────────
|
|
227
|
-
|
|
228
|
-
function test_SelfManagedSplitsRevertOnZeroPercent() external {
|
|
229
|
-
address caller = makeAddr("hookContract");
|
|
230
|
-
uint256 groupId = (1 << 160) | uint256(uint160(caller));
|
|
231
|
-
|
|
232
|
-
JBSplitGroup[] memory groups = new JBSplitGroup[](1);
|
|
233
|
-
JBSplit[] memory splits = new JBSplit[](1);
|
|
234
|
-
splits[0] = JBSplit({
|
|
235
|
-
preferAddToBalance: false,
|
|
236
|
-
percent: 0,
|
|
237
|
-
projectId: 0,
|
|
238
|
-
beneficiary: _bene,
|
|
239
|
-
lockedUntil: 0,
|
|
240
|
-
hook: IJBSplitHook(address(0))
|
|
241
|
-
});
|
|
242
|
-
groups[0] = JBSplitGroup({groupId: groupId, splits: splits});
|
|
243
|
-
|
|
244
|
-
vm.prank(caller);
|
|
245
|
-
vm.expectRevert(JBSplits.JBSplits_ZeroSplitPercent.selector);
|
|
246
|
-
_splits.setSplitGroupsOf(_projectId, _rulesetId, groups);
|
|
247
|
-
}
|
|
248
|
-
|
|
249
|
-
function test_SelfManagedSplitsRevertOnExcessPercent() external {
|
|
250
|
-
address caller = makeAddr("hookContract");
|
|
251
|
-
uint256 groupId = (1 << 160) | uint256(uint160(caller));
|
|
252
|
-
|
|
253
|
-
JBSplitGroup[] memory groups = new JBSplitGroup[](1);
|
|
254
|
-
JBSplit[] memory splits = new JBSplit[](2);
|
|
255
|
-
splits[0] = JBSplit({
|
|
256
|
-
preferAddToBalance: false,
|
|
257
|
-
percent: JBConstants.SPLITS_TOTAL_PERCENT,
|
|
258
|
-
projectId: 0,
|
|
259
|
-
beneficiary: _bene,
|
|
260
|
-
lockedUntil: 0,
|
|
261
|
-
hook: IJBSplitHook(address(0))
|
|
262
|
-
});
|
|
263
|
-
splits[1] = JBSplit({
|
|
264
|
-
preferAddToBalance: false,
|
|
265
|
-
percent: 1,
|
|
266
|
-
projectId: 0,
|
|
267
|
-
beneficiary: _bene,
|
|
268
|
-
lockedUntil: 0,
|
|
269
|
-
hook: IJBSplitHook(address(0))
|
|
270
|
-
});
|
|
271
|
-
groups[0] = JBSplitGroup({groupId: groupId, splits: splits});
|
|
272
|
-
|
|
273
|
-
vm.prank(caller);
|
|
274
|
-
vm.expectRevert(JBSplits.JBSplits_TotalPercentExceeds100.selector);
|
|
275
|
-
_splits.setSplitGroupsOf(_projectId, _rulesetId, groups);
|
|
276
|
-
}
|
|
277
|
-
|
|
278
|
-
function test_SelfManagedSplitsEnforceLocks() external {
|
|
279
|
-
// Locked splits in a self-managed group cannot be removed.
|
|
280
|
-
address caller = makeAddr("hookContract");
|
|
281
|
-
uint256 groupId = (1 << 160) | uint256(uint160(caller));
|
|
282
|
-
|
|
283
|
-
// Set a locked split.
|
|
284
|
-
JBSplitGroup[] memory groups = new JBSplitGroup[](1);
|
|
285
|
-
JBSplit[] memory splits = new JBSplit[](1);
|
|
286
|
-
splits[0] = JBSplit({
|
|
287
|
-
preferAddToBalance: false,
|
|
288
|
-
percent: JBConstants.SPLITS_TOTAL_PERCENT / 2,
|
|
289
|
-
projectId: 0,
|
|
290
|
-
beneficiary: _bene,
|
|
291
|
-
lockedUntil: uint48(block.timestamp + 100),
|
|
292
|
-
hook: IJBSplitHook(address(0))
|
|
293
|
-
});
|
|
294
|
-
groups[0] = JBSplitGroup({groupId: groupId, splits: splits});
|
|
295
|
-
|
|
296
|
-
vm.prank(caller);
|
|
297
|
-
_splits.setSplitGroupsOf(_projectId, _rulesetId, groups);
|
|
298
|
-
|
|
299
|
-
// Try to replace with a different split (omitting the locked one).
|
|
300
|
-
JBSplit[] memory newSplits = new JBSplit[](1);
|
|
301
|
-
newSplits[0] = JBSplit({
|
|
302
|
-
preferAddToBalance: false,
|
|
303
|
-
percent: JBConstants.SPLITS_TOTAL_PERCENT / 2,
|
|
304
|
-
projectId: 0,
|
|
305
|
-
beneficiary: payable(makeAddr("otherBene")),
|
|
306
|
-
lockedUntil: 0,
|
|
307
|
-
hook: IJBSplitHook(address(0))
|
|
308
|
-
});
|
|
309
|
-
groups[0] = JBSplitGroup({groupId: groupId, splits: newSplits});
|
|
310
|
-
|
|
311
|
-
vm.prank(caller);
|
|
312
|
-
vm.expectRevert(
|
|
313
|
-
abi.encodeWithSelector(JBSplits.JBSplits_PreviousLockedSplitsNotIncluded.selector, _projectId, _rulesetId)
|
|
314
|
-
);
|
|
315
|
-
_splits.setSplitGroupsOf(_projectId, _rulesetId, groups);
|
|
316
|
-
}
|
|
317
|
-
|
|
318
|
-
// ──────────────────────── Authorization: revert cases
|
|
319
|
-
// ──────────────────────
|
|
320
|
-
|
|
321
|
-
function test_NonOwnerCannotSetSplitsInOtherNamespace() external {
|
|
322
|
-
// A caller whose address doesn't match the groupId's lower 160 bits is rejected (unless controller).
|
|
323
|
-
address caller = makeAddr("attacker");
|
|
324
|
-
address victim = makeAddr("hookContract");
|
|
325
|
-
uint256 groupId = uint256(uint160(victim));
|
|
326
|
-
|
|
327
|
-
JBSplitGroup[] memory groups = _makeSplitGroup(groupId, JBConstants.SPLITS_TOTAL_PERCENT / 2, _bene);
|
|
328
|
-
|
|
329
|
-
// Mock: controller is someone else entirely.
|
|
330
|
-
_mockController(makeAddr("realController"));
|
|
331
|
-
|
|
332
|
-
vm.prank(caller);
|
|
333
|
-
vm.expectRevert(
|
|
334
|
-
abi.encodeWithSelector(
|
|
335
|
-
JBControlled.JBControlled_ControllerUnauthorized.selector, makeAddr("realController")
|
|
336
|
-
)
|
|
337
|
-
);
|
|
338
|
-
_splits.setSplitGroupsOf(_projectId, _rulesetId, groups);
|
|
339
|
-
}
|
|
340
|
-
|
|
341
|
-
function test_NonOwnerCannotSetSplitsWithSubcategory() external {
|
|
342
|
-
// Even with upper bits, the lower 160 bits must match msg.sender.
|
|
343
|
-
address caller = makeAddr("attacker");
|
|
344
|
-
address victim = makeAddr("hookContract");
|
|
345
|
-
uint256 groupId = (99 << 160) | uint256(uint160(victim));
|
|
346
|
-
|
|
347
|
-
JBSplitGroup[] memory groups = _makeSplitGroup(groupId, JBConstants.SPLITS_TOTAL_PERCENT, _bene);
|
|
348
|
-
|
|
349
|
-
_mockController(makeAddr("realController"));
|
|
350
|
-
|
|
351
|
-
vm.prank(caller);
|
|
352
|
-
vm.expectRevert(
|
|
353
|
-
abi.encodeWithSelector(
|
|
354
|
-
JBControlled.JBControlled_ControllerUnauthorized.selector, makeAddr("realController")
|
|
355
|
-
)
|
|
356
|
-
);
|
|
357
|
-
_splits.setSplitGroupsOf(_projectId, _rulesetId, groups);
|
|
358
|
-
}
|
|
359
|
-
|
|
360
|
-
// ──────────────── Bare-address groupIds require controller auth
|
|
361
|
-
// ───────────────
|
|
362
|
-
|
|
363
|
-
function test_BareAddressGroupIdRequiresControllerEvenForMatchingSender() external {
|
|
364
|
-
// A contract cannot self-auth for groupId == uint256(uint160(self)) (upper 96 bits = 0).
|
|
365
|
-
// This prevents token contracts from hijacking terminal payout splits.
|
|
366
|
-
address caller = makeAddr("maliciousToken");
|
|
367
|
-
uint256 groupId = uint256(uint160(caller)); // bare address, upper bits = 0
|
|
368
|
-
|
|
369
|
-
JBSplitGroup[] memory groups = _makeSplitGroup(groupId, JBConstants.SPLITS_TOTAL_PERCENT, _bene);
|
|
370
|
-
|
|
371
|
-
_mockController(makeAddr("realController"));
|
|
372
|
-
|
|
373
|
-
vm.prank(caller);
|
|
374
|
-
vm.expectRevert(
|
|
375
|
-
abi.encodeWithSelector(
|
|
376
|
-
JBControlled.JBControlled_ControllerUnauthorized.selector, makeAddr("realController")
|
|
377
|
-
)
|
|
378
|
-
);
|
|
379
|
-
_splits.setSplitGroupsOf(_projectId, _rulesetId, groups);
|
|
380
|
-
}
|
|
381
|
-
|
|
382
|
-
function test_BareAddressGroupIdSucceedsWithControllerAuth() external {
|
|
383
|
-
// The controller CAN still set splits for bare-address groupIds (terminal payout groups).
|
|
384
|
-
address controller = makeAddr("controller");
|
|
385
|
-
address token = makeAddr("someToken");
|
|
386
|
-
uint256 groupId = uint256(uint160(token));
|
|
387
|
-
|
|
388
|
-
JBSplitGroup[] memory groups = _makeSplitGroup(groupId, JBConstants.SPLITS_TOTAL_PERCENT, _bene);
|
|
389
|
-
|
|
390
|
-
_mockController(controller);
|
|
391
|
-
|
|
392
|
-
vm.prank(controller);
|
|
393
|
-
_splits.setSplitGroupsOf(_projectId, _rulesetId, groups);
|
|
394
|
-
|
|
395
|
-
JBSplit[] memory result = _splits.splitsOf(_projectId, _rulesetId, groupId);
|
|
396
|
-
assertEq(result.length, 1);
|
|
397
|
-
assertEq(result[0].beneficiary, _bene);
|
|
398
|
-
}
|
|
399
|
-
|
|
400
|
-
// ───────────────────── Controller can still set any group
|
|
401
|
-
// ──────────────────
|
|
402
|
-
|
|
403
|
-
function test_ControllerCanSetSplitsInAnyGroup() external {
|
|
404
|
-
// The controller can set splits in a group that "belongs" to another address.
|
|
405
|
-
address controller = makeAddr("controller");
|
|
406
|
-
address otherContract = makeAddr("hookContract");
|
|
407
|
-
uint256 groupId = uint256(uint160(otherContract));
|
|
408
|
-
|
|
409
|
-
JBSplitGroup[] memory groups = _makeSplitGroup(groupId, JBConstants.SPLITS_TOTAL_PERCENT, _bene);
|
|
410
|
-
|
|
411
|
-
_mockController(controller);
|
|
412
|
-
|
|
413
|
-
vm.prank(controller);
|
|
414
|
-
_splits.setSplitGroupsOf(_projectId, _rulesetId, groups);
|
|
415
|
-
|
|
416
|
-
JBSplit[] memory result = _splits.splitsOf(_projectId, _rulesetId, groupId);
|
|
417
|
-
assertEq(result.length, 1);
|
|
418
|
-
assertEq(result[0].beneficiary, _bene);
|
|
419
|
-
}
|
|
420
|
-
|
|
421
|
-
// ─────────────────── Mixed groups in one call
|
|
422
|
-
// ─────────────────────────────
|
|
423
|
-
|
|
424
|
-
function test_MixedSelfManagedAndControllerGroupsInOneCall() external {
|
|
425
|
-
// A single setSplitGroupsOf call with one self-managed group (non-zero upper bits) and one controller-gated
|
|
426
|
-
// group.
|
|
427
|
-
address caller = makeAddr("hookContract");
|
|
428
|
-
uint256 selfGroupId = (1 << 160) | uint256(uint160(caller));
|
|
429
|
-
uint256 otherGroupId = 0;
|
|
430
|
-
|
|
431
|
-
// Mock: caller IS the controller.
|
|
432
|
-
_mockController(caller);
|
|
433
|
-
|
|
434
|
-
JBSplitGroup[] memory groups = new JBSplitGroup[](2);
|
|
435
|
-
JBSplit[] memory selfSplits = new JBSplit[](1);
|
|
436
|
-
selfSplits[0] = JBSplit({
|
|
437
|
-
preferAddToBalance: false,
|
|
438
|
-
percent: JBConstants.SPLITS_TOTAL_PERCENT,
|
|
439
|
-
projectId: 0,
|
|
440
|
-
beneficiary: payable(makeAddr("selfBene")),
|
|
441
|
-
lockedUntil: 0,
|
|
442
|
-
hook: IJBSplitHook(address(0))
|
|
443
|
-
});
|
|
444
|
-
|
|
445
|
-
JBSplit[] memory otherSplits = new JBSplit[](1);
|
|
446
|
-
otherSplits[0] = JBSplit({
|
|
447
|
-
preferAddToBalance: false,
|
|
448
|
-
percent: JBConstants.SPLITS_TOTAL_PERCENT,
|
|
449
|
-
projectId: 0,
|
|
450
|
-
beneficiary: payable(makeAddr("otherBene")),
|
|
451
|
-
lockedUntil: 0,
|
|
452
|
-
hook: IJBSplitHook(address(0))
|
|
453
|
-
});
|
|
454
|
-
|
|
455
|
-
groups[0] = JBSplitGroup({groupId: selfGroupId, splits: selfSplits});
|
|
456
|
-
groups[1] = JBSplitGroup({groupId: otherGroupId, splits: otherSplits});
|
|
457
|
-
|
|
458
|
-
vm.prank(caller);
|
|
459
|
-
_splits.setSplitGroupsOf(_projectId, _rulesetId, groups);
|
|
460
|
-
|
|
461
|
-
JBSplit[] memory resultSelf = _splits.splitsOf(_projectId, _rulesetId, selfGroupId);
|
|
462
|
-
JBSplit[] memory resultOther = _splits.splitsOf(_projectId, _rulesetId, otherGroupId);
|
|
463
|
-
|
|
464
|
-
assertEq(resultSelf[0].beneficiary, payable(makeAddr("selfBene")));
|
|
465
|
-
assertEq(resultOther[0].beneficiary, payable(makeAddr("otherBene")));
|
|
466
|
-
}
|
|
467
|
-
|
|
468
|
-
function test_MixedCallRevertsIfNonControllerSetsOtherGroup() external {
|
|
469
|
-
// A call with one self-managed group (ok) and one non-owned group (reverts) in the same call.
|
|
470
|
-
address caller = makeAddr("hookContract");
|
|
471
|
-
uint256 selfGroupId = (1 << 160) | uint256(uint160(caller));
|
|
472
|
-
uint256 otherGroupId = 0;
|
|
473
|
-
|
|
474
|
-
_mockController(makeAddr("realController"));
|
|
475
|
-
|
|
476
|
-
JBSplitGroup[] memory groups = new JBSplitGroup[](2);
|
|
477
|
-
JBSplit[] memory selfSplits = new JBSplit[](1);
|
|
478
|
-
selfSplits[0] = JBSplit({
|
|
479
|
-
preferAddToBalance: false,
|
|
480
|
-
percent: JBConstants.SPLITS_TOTAL_PERCENT,
|
|
481
|
-
projectId: 0,
|
|
482
|
-
beneficiary: _bene,
|
|
483
|
-
lockedUntil: 0,
|
|
484
|
-
hook: IJBSplitHook(address(0))
|
|
485
|
-
});
|
|
486
|
-
|
|
487
|
-
JBSplit[] memory otherSplits = new JBSplit[](1);
|
|
488
|
-
otherSplits[0] = JBSplit({
|
|
489
|
-
preferAddToBalance: false,
|
|
490
|
-
percent: JBConstants.SPLITS_TOTAL_PERCENT,
|
|
491
|
-
projectId: 0,
|
|
492
|
-
beneficiary: _bene,
|
|
493
|
-
lockedUntil: 0,
|
|
494
|
-
hook: IJBSplitHook(address(0))
|
|
495
|
-
});
|
|
496
|
-
|
|
497
|
-
// Self-managed group first (passes), then non-owned group (reverts).
|
|
498
|
-
groups[0] = JBSplitGroup({groupId: selfGroupId, splits: selfSplits});
|
|
499
|
-
groups[1] = JBSplitGroup({groupId: otherGroupId, splits: otherSplits});
|
|
500
|
-
|
|
501
|
-
vm.prank(caller);
|
|
502
|
-
vm.expectRevert(
|
|
503
|
-
abi.encodeWithSelector(
|
|
504
|
-
JBControlled.JBControlled_ControllerUnauthorized.selector, makeAddr("realController")
|
|
505
|
-
)
|
|
506
|
-
);
|
|
507
|
-
_splits.setSplitGroupsOf(_projectId, _rulesetId, groups);
|
|
508
|
-
}
|
|
509
|
-
|
|
510
|
-
// ────────────────────── Fuzz tests
|
|
511
|
-
// ─────────────────────────────────────────
|
|
512
|
-
|
|
513
|
-
function testFuzz_AnyAddressCanSetOwnNamespace(address caller, uint96 upperBits, uint32 percent) external {
|
|
514
|
-
vm.assume(caller != address(0));
|
|
515
|
-
vm.assume(percent > 0 && percent <= JBConstants.SPLITS_TOTAL_PERCENT);
|
|
516
|
-
// Self-auth requires non-zero upper bits.
|
|
517
|
-
vm.assume(upperBits > 0);
|
|
518
|
-
|
|
519
|
-
uint256 groupId = (uint256(upperBits) << 160) | uint256(uint160(caller));
|
|
520
|
-
|
|
521
|
-
JBSplitGroup[] memory groups = _makeSplitGroup(groupId, percent, _bene);
|
|
522
|
-
|
|
523
|
-
vm.prank(caller);
|
|
524
|
-
_splits.setSplitGroupsOf(_projectId, _rulesetId, groups);
|
|
525
|
-
|
|
526
|
-
JBSplit[] memory result = _splits.splitsOf(_projectId, _rulesetId, groupId);
|
|
527
|
-
assertEq(result.length, 1);
|
|
528
|
-
assertEq(result[0].percent, percent);
|
|
529
|
-
}
|
|
530
|
-
|
|
531
|
-
function testFuzz_NonOwnerRevertsForMismatchedNamespace(
|
|
532
|
-
address caller,
|
|
533
|
-
address groupOwner,
|
|
534
|
-
address controller
|
|
535
|
-
)
|
|
536
|
-
external
|
|
537
|
-
{
|
|
538
|
-
vm.assume(caller != address(0) && groupOwner != address(0) && controller != address(0));
|
|
539
|
-
vm.assume(caller != groupOwner);
|
|
540
|
-
vm.assume(caller != controller);
|
|
541
|
-
|
|
542
|
-
uint256 groupId = uint256(uint160(groupOwner));
|
|
543
|
-
|
|
544
|
-
JBSplitGroup[] memory groups = _makeSplitGroup(groupId, JBConstants.SPLITS_TOTAL_PERCENT / 2, _bene);
|
|
545
|
-
|
|
546
|
-
_mockController(controller);
|
|
547
|
-
|
|
548
|
-
vm.prank(caller);
|
|
549
|
-
vm.expectRevert(abi.encodeWithSelector(JBControlled.JBControlled_ControllerUnauthorized.selector, controller));
|
|
550
|
-
_splits.setSplitGroupsOf(_projectId, _rulesetId, groups);
|
|
551
|
-
}
|
|
552
|
-
}
|