@bananapus/core-v6 0.0.37 → 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.
Files changed (287) hide show
  1. package/foundry.lock +1 -7
  2. package/foundry.toml +1 -1
  3. package/package.json +19 -7
  4. package/src/JBController.sol +19 -1
  5. package/src/JBMultiTerminal.sol +68 -34
  6. package/src/JBTerminalStore.sol +6 -6
  7. package/src/interfaces/IJBController.sol +4 -1
  8. package/src/libraries/JBFees.sol +47 -9
  9. package/src/libraries/JBPayoutSplitGroupLib.sol +2 -2
  10. package/src/periphery/JBMatchingPriceFeed.sol +1 -1
  11. package/test/mock/MockMaliciousBeneficiary.sol +15 -15
  12. package/ADMINISTRATION.md +0 -103
  13. package/ARCHITECTURE.md +0 -133
  14. package/AUDIT_INSTRUCTIONS.md +0 -139
  15. package/RISKS.md +0 -215
  16. package/SKILLS.md +0 -55
  17. package/STYLE_GUIDE.md +0 -610
  18. package/USER_JOURNEYS.md +0 -215
  19. package/script/Deploy.s.sol +0 -124
  20. package/script/DeployPeriphery.s.sol +0 -354
  21. package/slither-ci.config.json +0 -10
  22. package/test/AuditFixes.t.sol +0 -808
  23. package/test/ComprehensiveInvariant.t.sol +0 -306
  24. package/test/CoreExploitTests.t.sol +0 -2741
  25. package/test/EconomicSimulation.t.sol +0 -348
  26. package/test/EntryPointPermutations.t.sol +0 -684
  27. package/test/FlashLoanAttacks.t.sol +0 -797
  28. package/test/PermissionEscalation.t.sol +0 -711
  29. package/test/PermissionsInvariant.t.sol +0 -403
  30. package/test/RulesetTransitions.t.sol +0 -713
  31. package/test/SplitLoopTests.t.sol +0 -752
  32. package/test/TestAccessToFunds.sol +0 -2683
  33. package/test/TestAuditResponseDesignProofs.sol +0 -434
  34. package/test/TestCashOut.sol +0 -198
  35. package/test/TestCashOutCountFor.sol +0 -271
  36. package/test/TestCashOutHooks.sol +0 -351
  37. package/test/TestCashOutTimingEdge.sol +0 -241
  38. package/test/TestDataHookFuzzing.sol +0 -524
  39. package/test/TestDurationUnderflow.sol +0 -233
  40. package/test/TestFeeFreeCashOutBypass.sol +0 -949
  41. package/test/TestFeeProcessingFailure.sol +0 -218
  42. package/test/TestFees.sol +0 -619
  43. package/test/TestForwardedTokenConsumption.sol +0 -425
  44. package/test/TestInterfaceSupport.sol +0 -81
  45. package/test/TestJBERC20Inheritance.sol +0 -103
  46. package/test/TestL2SequencerPriceFeed.sol +0 -292
  47. package/test/TestLaunchProject.sol +0 -188
  48. package/test/TestMetaTx.sol +0 -217
  49. package/test/TestMetadataOffsetOverflow.sol +0 -179
  50. package/test/TestMetadataParserLib.sol +0 -471
  51. package/test/TestMigrationHeldFees.sol +0 -255
  52. package/test/TestMintTokensOf.sol +0 -185
  53. package/test/TestMultiTerminalSurplus.sol +0 -348
  54. package/test/TestMultiTokenSurplus.sol +0 -202
  55. package/test/TestMultipleAccessLimits.sol +0 -664
  56. package/test/TestPayBurnRedeemFlow.sol +0 -195
  57. package/test/TestPayHooks.sol +0 -209
  58. package/test/TestPermissions.sol +0 -324
  59. package/test/TestPermissionsEdge.sol +0 -290
  60. package/test/TestPermit2DataHook.t.sol +0 -360
  61. package/test/TestPermit2Terminal.sol +0 -372
  62. package/test/TestRulesetQueueing.sol +0 -1025
  63. package/test/TestRulesetQueuingStress.sol +0 -806
  64. package/test/TestRulesetWeightCaching.sol +0 -178
  65. package/test/TestSplits.sol +0 -391
  66. package/test/TestTerminalMigration.sol +0 -274
  67. package/test/TestTerminalPreviewParity.sol +0 -208
  68. package/test/TestTokenFlow.sol +0 -191
  69. package/test/TestWeightCacheStaleAfterRejection.sol +0 -303
  70. package/test/WeirdTokenTests.t.sol +0 -817
  71. package/test/audit/CashOutReenterPay.t.sol +0 -501
  72. package/test/audit/CodexHeldFeeRounding.t.sol +0 -159
  73. package/test/audit/CodexMigrationFeeFailure.t.sol +0 -163
  74. package/test/audit/CrossTerminalSurplusSpoof.t.sol +0 -140
  75. package/test/audit/CycledSurplusAllowanceReset.t.sol +0 -184
  76. package/test/audit/FeeFreeSurplusLifecycle.t.sol +0 -399
  77. package/test/audit/FeeFreeSurplusStale.t.sol +0 -248
  78. package/test/audit/USDTVoidReturnCompat.t.sol +0 -525
  79. package/test/fork/TestChainlinkPriceFeedFork.sol +0 -254
  80. package/test/fork/TestSequencerPriceFeedFork.sol +0 -168
  81. package/test/fork/TestTerminalPreviewParityFork.sol +0 -108
  82. package/test/formal/BondingCurveProperties.t.sol +0 -420
  83. package/test/formal/FeeProperties.t.sol +0 -252
  84. package/test/invariants/Phase3DeepInvariant.t.sol +0 -412
  85. package/test/invariants/RulesetsInvariant.t.sol +0 -125
  86. package/test/invariants/TerminalStoreInvariant.t.sol +0 -227
  87. package/test/invariants/TokensInvariant.t.sol +0 -195
  88. package/test/invariants/handlers/ComprehensiveHandler.sol +0 -303
  89. package/test/invariants/handlers/EconomicHandler.sol +0 -377
  90. package/test/invariants/handlers/Phase3Handler.sol +0 -443
  91. package/test/invariants/handlers/RulesetsHandler.sol +0 -115
  92. package/test/invariants/handlers/TerminalStoreHandler.sol +0 -151
  93. package/test/invariants/handlers/TokensHandler.sol +0 -126
  94. package/test/regression/HoldFeesCashOutReserved.t.sol +0 -415
  95. package/test/regression/WeightCacheBoundary.t.sol +0 -291
  96. package/test/trees/JBController/burnTokensOf.tree +0 -9
  97. package/test/trees/JBController/claimTokensFor.tree +0 -5
  98. package/test/trees/JBController/deployERC20For.tree +0 -5
  99. package/test/trees/JBController/getRulesetOf.tree +0 -5
  100. package/test/trees/JBController/launchProjectFor.tree +0 -12
  101. package/test/trees/JBController/launchRulesetsFor.tree +0 -8
  102. package/test/trees/JBController/migrateController.tree +0 -12
  103. package/test/trees/JBController/mintTokensOf.tree +0 -12
  104. package/test/trees/JBController/payReservedTokenToTerminal.tree +0 -8
  105. package/test/trees/JBController/receiveMigrationFrom.tree +0 -4
  106. package/test/trees/JBController/sendReservedTokensToSplitsOf.tree +0 -12
  107. package/test/trees/JBController/setMetadataOf.tree +0 -5
  108. package/test/trees/JBController/setSplitGroupsOf.tree +0 -5
  109. package/test/trees/JBController/setTokenFor.tree +0 -5
  110. package/test/trees/JBController/transferCreditsFrom.tree +0 -8
  111. package/test/trees/JBDirectory/primaryTerminalOf.tree +0 -8
  112. package/test/trees/JBDirectory/setControllerOf.tree +0 -11
  113. package/test/trees/JBDirectory/setPrimaryTerminalOf.tree +0 -15
  114. package/test/trees/JBDirectory/setTerminalsOf.tree +0 -11
  115. package/test/trees/JBERC20/initialize.tree +0 -7
  116. package/test/trees/JBERC20/name.tree +0 -5
  117. package/test/trees/JBERC20/nonces.tree +0 -5
  118. package/test/trees/JBERC20/symbol.tree +0 -5
  119. package/test/trees/JBFeelessAddresses/setFeelessAddress.tree +0 -5
  120. package/test/trees/JBFeelessAddresses/supportsInterface.tree +0 -5
  121. package/test/trees/JBFundAccessLimits/payoutLimitOf.tree +0 -5
  122. package/test/trees/JBFundAccessLimits/payoutLimitsOf.tree +0 -8
  123. package/test/trees/JBFundAccessLimits/setFundAccessLimitsFor.tree +0 -18
  124. package/test/trees/JBFundAccessLimits/surplusAllowanceOf.tree +0 -5
  125. package/test/trees/JBFundAccessLimits/surplusAllowancesOf.tree +0 -8
  126. package/test/trees/JBMetadataResolver/getDataFor.tree +0 -8
  127. package/test/trees/JBMultiTerminal/accountingContextsOf.tree +0 -5
  128. package/test/trees/JBMultiTerminal/addAccountingContextsFor.tree +0 -10
  129. package/test/trees/JBMultiTerminal/addToBalanceOf.tree +0 -23
  130. package/test/trees/JBMultiTerminal/cashOutTokensOf.tree +0 -23
  131. package/test/trees/JBMultiTerminal/executePayout.tree +0 -32
  132. package/test/trees/JBMultiTerminal/executeProcessFee.tree +0 -14
  133. package/test/trees/JBMultiTerminal/migrateBalanceOf.tree +0 -12
  134. package/test/trees/JBMultiTerminal/pay.tree +0 -23
  135. package/test/trees/JBMultiTerminal/processHeldFeesOf.tree +0 -8
  136. package/test/trees/JBMultiTerminal/sendPayoutsOf.tree +0 -34
  137. package/test/trees/JBMultiTerminal/useAllowanceOf.tree +0 -16
  138. package/test/trees/JBPermissions/hasPermission.tree +0 -8
  139. package/test/trees/JBPermissions/hasPermissions.tree +0 -8
  140. package/test/trees/JBPermissions/setPermissionsFor.tree +0 -5
  141. package/test/trees/JBPrices/addPriceFeedFor.tree +0 -14
  142. package/test/trees/JBPrices/pricePerUnitOf.tree +0 -11
  143. package/test/trees/JBProjects/createFor.tree +0 -11
  144. package/test/trees/JBProjects/setTokenUriResolver.tree +0 -5
  145. package/test/trees/JBProjects/supportsInterface.tree +0 -9
  146. package/test/trees/JBProjects/tokenURI.tree +0 -5
  147. package/test/trees/JBRulesets/currentApprovalStatusForLatestRulesetOf.tree +0 -8
  148. package/test/trees/JBRulesets/currentOf.tree +0 -12
  149. package/test/trees/JBRulesets/getRulesetOf.tree +0 -5
  150. package/test/trees/JBRulesets/latestQueuedRulesetOf.tree +0 -10
  151. package/test/trees/JBRulesets/rulesetsOf.tree +0 -11
  152. package/test/trees/JBRulesets/upcomingRulesetOf.tree +0 -20
  153. package/test/trees/JBRulesets/updateRulesetWeightCache.tree +0 -5
  154. package/test/trees/JBSplits/setSplitGroupsOf.tree +0 -17
  155. package/test/trees/JBSplits/splitsOf.tree +0 -5
  156. package/test/trees/JBTerminalStore/currentReclaimableSurplusOf.tree +0 -16
  157. package/test/trees/JBTerminalStore/currentSurplusOf.tree +0 -25
  158. package/test/trees/JBTerminalStore/currentTotalSurplusOf.tree +0 -5
  159. package/test/trees/JBTerminalStore/recordCashOutsFor.tree +0 -16
  160. package/test/trees/JBTerminalStore/recordPaymentFrom.tree +0 -14
  161. package/test/trees/JBTerminalStore/recordPayoutFor.tree +0 -10
  162. package/test/trees/JBTerminalStore/recordTerminalMigration.tree +0 -5
  163. package/test/trees/JBTerminalStore/recordUsedAllowanceOf.tree +0 -10
  164. package/test/trees/JBTokens/burnFrom.tree +0 -10
  165. package/test/trees/JBTokens/claimTokensFor.tree +0 -10
  166. package/test/trees/JBTokens/deployERC20For.tree +0 -12
  167. package/test/trees/JBTokens/mintFor.tree +0 -10
  168. package/test/trees/JBTokens/setTokenFor.tree +0 -11
  169. package/test/trees/JBTokens/totalBalanceOf.tree +0 -5
  170. package/test/trees/JBTokens/totalSupplyOf.tree +0 -5
  171. package/test/trees/JBTokens/transferCreditsFrom.tree +0 -8
  172. package/test/trees/mintTokensOf.tree +0 -12
  173. package/test/units/static/JBChainlinkV3PriceFeed/TestPriceFeed.sol +0 -223
  174. package/test/units/static/JBController/JBControllerSetup.sol +0 -50
  175. package/test/units/static/JBController/TestBurnTokensOf.sol +0 -114
  176. package/test/units/static/JBController/TestClaimTokensFor.sol +0 -63
  177. package/test/units/static/JBController/TestDeployErc20For.sol +0 -86
  178. package/test/units/static/JBController/TestLaunchProjectFor.sol +0 -302
  179. package/test/units/static/JBController/TestLaunchRulesetsFor.sol +0 -342
  180. package/test/units/static/JBController/TestMigrateController.sol +0 -157
  181. package/test/units/static/JBController/TestMintTokensOfUnits.sol +0 -111
  182. package/test/units/static/JBController/TestOmnichainRulesetOperator.sol +0 -324
  183. package/test/units/static/JBController/TestPayReservedTokenToTerminal.sol +0 -74
  184. package/test/units/static/JBController/TestPreviewMintOf.sol +0 -117
  185. package/test/units/static/JBController/TestReceiveMigrationFrom.sol +0 -99
  186. package/test/units/static/JBController/TestRulesetViews.sol +0 -225
  187. package/test/units/static/JBController/TestSendReservedTokensToSplitsOf.sol +0 -615
  188. package/test/units/static/JBController/TestSetSplitGroupsOf.sol +0 -68
  189. package/test/units/static/JBController/TestSetTokenFor.sol +0 -239
  190. package/test/units/static/JBController/TestSetUriOf.sol +0 -57
  191. package/test/units/static/JBController/TestTransferCreditsFrom.sol +0 -169
  192. package/test/units/static/JBDeadline/TestDeadlineFuzz.sol +0 -211
  193. package/test/units/static/JBDirectory/JBDirectorySetup.sol +0 -26
  194. package/test/units/static/JBDirectory/TestPrimaryTerminalOf.sol +0 -126
  195. package/test/units/static/JBDirectory/TestSetControllerOf.sol +0 -183
  196. package/test/units/static/JBDirectory/TestSetControllerOfMigrationOrder.sol +0 -104
  197. package/test/units/static/JBDirectory/TestSetPrimaryTerminalOf.sol +0 -179
  198. package/test/units/static/JBDirectory/TestSetTerminalsOf.sol +0 -137
  199. package/test/units/static/JBERC20/JBERC20Setup.sol +0 -34
  200. package/test/units/static/JBERC20/SigUtils.sol +0 -36
  201. package/test/units/static/JBERC20/TestInitialize.sol +0 -60
  202. package/test/units/static/JBERC20/TestName.sol +0 -30
  203. package/test/units/static/JBERC20/TestNonces.sol +0 -62
  204. package/test/units/static/JBERC20/TestSymbol.sol +0 -31
  205. package/test/units/static/JBFeelessAdresses/JBFeelessSetup.sol +0 -22
  206. package/test/units/static/JBFeelessAdresses/TestInterfaces.sol +0 -30
  207. package/test/units/static/JBFeelessAdresses/TestSetFeelessAddress.sol +0 -35
  208. package/test/units/static/JBFees/TestFeesFuzz.sol +0 -79
  209. package/test/units/static/JBFixedPointNumber/TestAdjustDecimals.sol +0 -16
  210. package/test/units/static/JBFixedPointNumber/TestAdjustDecimalsFuzz.sol +0 -71
  211. package/test/units/static/JBFundAccessLimits/JBFundAccessSetup.sol +0 -24
  212. package/test/units/static/JBFundAccessLimits/TestFundAccessLimitsEdge.sol +0 -163
  213. package/test/units/static/JBFundAccessLimits/TestPayoutLimitOf.sol +0 -59
  214. package/test/units/static/JBFundAccessLimits/TestPayoutLimitsOf.sol +0 -101
  215. package/test/units/static/JBFundAccessLimits/TestSetFundAccessLimitsFor.sol +0 -189
  216. package/test/units/static/JBFundAccessLimits/TestSurplusAllowanceOf.sol +0 -64
  217. package/test/units/static/JBFundAccessLimits/TestSurplusAllowancesOf.sol +0 -102
  218. package/test/units/static/JBMetadataResolver/TestGetDataFor.sol +0 -90
  219. package/test/units/static/JBMetadataResolver/TestMetadataResolverEdgeCases.sol +0 -247
  220. package/test/units/static/JBMetadataResolver/TestMetadataResolverFuzz.sol +0 -229
  221. package/test/units/static/JBMultiTerminal/JBMultiTerminalSetup.sol +0 -50
  222. package/test/units/static/JBMultiTerminal/TestAccountingContextsOf.sol +0 -72
  223. package/test/units/static/JBMultiTerminal/TestAddAccountingContextsFor.sol +0 -289
  224. package/test/units/static/JBMultiTerminal/TestAddToBalanceOf.sol +0 -474
  225. package/test/units/static/JBMultiTerminal/TestCashOutTokensOf.sol +0 -624
  226. package/test/units/static/JBMultiTerminal/TestExecutePayout.sol +0 -578
  227. package/test/units/static/JBMultiTerminal/TestExecuteProcessFee.sol +0 -202
  228. package/test/units/static/JBMultiTerminal/TestMigrateBalanceOf.sol +0 -222
  229. package/test/units/static/JBMultiTerminal/TestPay.sol +0 -604
  230. package/test/units/static/JBMultiTerminal/TestPreviewCashOutFrom.sol +0 -117
  231. package/test/units/static/JBMultiTerminal/TestPreviewPayFor.sol +0 -114
  232. package/test/units/static/JBMultiTerminal/TestProcessHeldFeesOf.sol +0 -228
  233. package/test/units/static/JBMultiTerminal/TestSelfPayRevert.sol +0 -55
  234. package/test/units/static/JBMultiTerminal/TestSendPayoutsOf.sol +0 -257
  235. package/test/units/static/JBMultiTerminal/TestUseAllowanceOf.sol +0 -611
  236. package/test/units/static/JBPermissions/JBPermissionsSetup.sol +0 -20
  237. package/test/units/static/JBPermissions/TestHasPermission.sol +0 -50
  238. package/test/units/static/JBPermissions/TestHasPermissions.sol +0 -93
  239. package/test/units/static/JBPermissions/TestSetPermissionsFor.sol +0 -64
  240. package/test/units/static/JBPrices/JBPricesSetup.sol +0 -32
  241. package/test/units/static/JBPrices/TestAddPriceFeedFor.sol +0 -107
  242. package/test/units/static/JBPrices/TestPricePerUnitOf.sol +0 -132
  243. package/test/units/static/JBPrices/TestPrices.sol +0 -265
  244. package/test/units/static/JBProjects/JBProjectsSetup.sol +0 -22
  245. package/test/units/static/JBProjects/TestCreateFor.sol +0 -71
  246. package/test/units/static/JBProjects/TestInitialProject.sol +0 -21
  247. package/test/units/static/JBProjects/TestInterfaces.sol +0 -26
  248. package/test/units/static/JBProjects/TestSetResolver.sol +0 -37
  249. package/test/units/static/JBProjects/TestTokenUri.sol +0 -40
  250. package/test/units/static/JBRulesetMetadataResolver/TestSetCashOutTaxRateTo.sol +0 -108
  251. package/test/units/static/JBRulesets/JBRulesetsSetup.sol +0 -24
  252. package/test/units/static/JBRulesets/TestCurrentApprovalStatusForLatestRulesetOf.sol +0 -265
  253. package/test/units/static/JBRulesets/TestCurrentOf.sol +0 -242
  254. package/test/units/static/JBRulesets/TestGetRulesetOf.sol +0 -100
  255. package/test/units/static/JBRulesets/TestLatestQueuedRulesetOf.sol +0 -260
  256. package/test/units/static/JBRulesets/TestRulesets.sol +0 -632
  257. package/test/units/static/JBRulesets/TestRulesetsOf.sol +0 -37
  258. package/test/units/static/JBRulesets/TestUpcomingRulesetOf.sol +0 -522
  259. package/test/units/static/JBRulesets/TestUpdateRulesetWeightCache.sol +0 -96
  260. package/test/units/static/JBSplits/JBSplitsSetup.sol +0 -26
  261. package/test/units/static/JBSplits/TestSelfManagedSplitGroups.sol +0 -552
  262. package/test/units/static/JBSplits/TestSetSplitGroupsOf.sol +0 -377
  263. package/test/units/static/JBSplits/TestSplitsLockedEdge.sol +0 -267
  264. package/test/units/static/JBSplits/TestSplitsOf.sol +0 -24
  265. package/test/units/static/JBSplits/TestSplitsPacking.sol +0 -36
  266. package/test/units/static/JBSurplus/TestSurplusFuzz.sol +0 -160
  267. package/test/units/static/JBTerminalStore/JBTerminalStoreSetup.sol +0 -45
  268. package/test/units/static/JBTerminalStore/TestCurrentReclaimableSurplusOf.sol +0 -536
  269. package/test/units/static/JBTerminalStore/TestCurrentSurplusOf.sol +0 -463
  270. package/test/units/static/JBTerminalStore/TestCurrentTotalSurplusOf.sol +0 -135
  271. package/test/units/static/JBTerminalStore/TestPreviewCashOutFrom.sol +0 -476
  272. package/test/units/static/JBTerminalStore/TestPreviewPayFrom.sol +0 -494
  273. package/test/units/static/JBTerminalStore/TestRecordCashOutsFor.sol +0 -652
  274. package/test/units/static/JBTerminalStore/TestRecordPaymentFrom.sol +0 -744
  275. package/test/units/static/JBTerminalStore/TestRecordPayoutFor.sol +0 -289
  276. package/test/units/static/JBTerminalStore/TestRecordTerminalMigration.sol +0 -138
  277. package/test/units/static/JBTerminalStore/TestRecordUsedAllowanceOf.sol +0 -415
  278. package/test/units/static/JBTerminalStore/TestUint224Overflow.sol +0 -219
  279. package/test/units/static/JBTokens/JBTokensSetup.sol +0 -32
  280. package/test/units/static/JBTokens/TestBurnFrom.sol +0 -107
  281. package/test/units/static/JBTokens/TestClaimTokensFor.sol +0 -110
  282. package/test/units/static/JBTokens/TestDeployERC20ForUnits.sol +0 -92
  283. package/test/units/static/JBTokens/TestMintFor.sol +0 -100
  284. package/test/units/static/JBTokens/TestSetTokenFor.sol +0 -98
  285. package/test/units/static/JBTokens/TestTotalBalanceOf.sol +0 -65
  286. package/test/units/static/JBTokens/TestTotalSupplyOf.sol +0 -56
  287. package/test/units/static/JBTokens/TestTransferCreditsFrom.sol +0 -56
@@ -1,377 +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 TestSetSplitGroupsOf_Local is JBSplitsSetup {
15
- address _notThis = makeAddr("notThis");
16
- address payable _bene = payable(makeAddr("guy"));
17
- uint64 _projectId = 1;
18
- uint256 _rulesetId = block.timestamp;
19
-
20
- function setUp() public {
21
- super.splitsSetup();
22
- }
23
-
24
- function test_WhenCallerIsNotController() external {
25
- // it will revert with CONTROLLER_UNAUTHORIZED
26
-
27
- // data for call
28
- JBSplitGroup[] memory _splitsGroup = new JBSplitGroup[](1);
29
- JBSplit[] memory _splitsArray = new JBSplit[](1);
30
-
31
- // Set up a payout split recipient.
32
- _splitsArray[0] = JBSplit({
33
- preferAddToBalance: false,
34
- percent: JBConstants.SPLITS_TOTAL_PERCENT / 2,
35
- projectId: _projectId,
36
- beneficiary: _bene,
37
- lockedUntil: 0,
38
- hook: IJBSplitHook(address(0))
39
- });
40
-
41
- // outer structure
42
- _splitsGroup[0] = JBSplitGroup({groupId: 0, splits: _splitsArray});
43
-
44
- // mock the directory controllerOf call
45
- bytes memory _controllerCall = abi.encodeCall(IJBDirectory.controllerOf, (1));
46
- bytes memory _return = abi.encode(_notThis);
47
- mockExpect(address(directory), _controllerCall, _return);
48
-
49
- // not controller so revert
50
- vm.expectRevert(abi.encodeWithSelector(JBControlled.JBControlled_ControllerUnauthorized.selector, _notThis));
51
- _splits.setSplitGroupsOf(_projectId, _rulesetId, _splitsGroup);
52
- }
53
-
54
- modifier whenCallerIsController() {
55
- // mock the directory controllerOf call
56
- bytes memory _controllerCall = abi.encodeCall(IJBDirectory.controllerOf, (1));
57
- bytes memory _return = abi.encode(address(this));
58
- mockExpect(address(directory), _controllerCall, _return);
59
- _;
60
- }
61
-
62
- function test_GivenPreviouslyLockedSplitsAreNotIncluded() external whenCallerIsController {
63
- // it will revert with PREVIOUS_LOCKED_SPLITS_NOT_INCLUDED
64
-
65
- // data for first call to set locked splits
66
- JBSplitGroup[] memory _splitsGroup = new JBSplitGroup[](1);
67
- JBSplit[] memory _splitsArray = new JBSplit[](1);
68
-
69
- // Set up a payout split recipient.
70
- _splitsArray[0] = JBSplit({
71
- preferAddToBalance: false,
72
- percent: JBConstants.SPLITS_TOTAL_PERCENT / 2,
73
- projectId: _projectId,
74
- beneficiary: _bene,
75
- lockedUntil: uint48(block.timestamp + 100),
76
- hook: IJBSplitHook(address(0))
77
- });
78
-
79
- // outer structure
80
- _splitsGroup[0] = JBSplitGroup({groupId: 0, splits: _splitsArray});
81
-
82
- _splits.setSplitGroupsOf(_projectId, _rulesetId, _splitsGroup);
83
-
84
- // Re-set up a payout split recipient.
85
- _splitsArray[0] = JBSplit({
86
- preferAddToBalance: false,
87
- percent: JBConstants.SPLITS_TOTAL_PERCENT / 2,
88
- projectId: _projectId,
89
- beneficiary: _bene,
90
- lockedUntil: 0,
91
- hook: IJBSplitHook(address(0))
92
- });
93
-
94
- // outer structure
95
- _splitsGroup[0] = JBSplitGroup({groupId: 0, splits: _splitsArray});
96
-
97
- vm.expectRevert(
98
- abi.encodeWithSelector(JBSplits.JBSplits_PreviousLockedSplitsNotIncluded.selector, _projectId, _rulesetId)
99
- );
100
- _splits.setSplitGroupsOf(_projectId, _rulesetId, _splitsGroup);
101
- }
102
-
103
- function test_GivenAnyConfiguredSplitPercentIsZero() external whenCallerIsController {
104
- // it will revert with INVALID_SPLIT_PERCENT
105
-
106
- // data for call to set invalid splits
107
- JBSplitGroup[] memory _splitsGroup = new JBSplitGroup[](1);
108
- JBSplit[] memory _splitsArray = new JBSplit[](1);
109
-
110
- // Set up a payout split recipient.
111
- _splitsArray[0] = JBSplit({
112
- preferAddToBalance: false,
113
- // invalid percent
114
- percent: 0,
115
- projectId: _projectId,
116
- beneficiary: _bene,
117
- lockedUntil: 0,
118
- hook: IJBSplitHook(address(0))
119
- });
120
-
121
- // outer structure
122
- _splitsGroup[0] = JBSplitGroup({groupId: 0, splits: _splitsArray});
123
-
124
- vm.expectRevert(JBSplits.JBSplits_ZeroSplitPercent.selector);
125
- _splits.setSplitGroupsOf(_projectId, _rulesetId, _splitsGroup);
126
- }
127
-
128
- function test_GivenSplitsTotalToGtSPLITS_TOTAL_PERCENT() external whenCallerIsController {
129
- // it will revert with INVALID_TOTAL_PERCENT
130
-
131
- // data for call with total percent > 100
132
- JBSplitGroup[] memory _splitsGroup = new JBSplitGroup[](1);
133
- JBSplit[] memory _splitsArray = new JBSplit[](2);
134
-
135
- // Set up a payout split recipient.
136
- _splitsArray[0] = JBSplit({
137
- preferAddToBalance: false,
138
- percent: JBConstants.SPLITS_TOTAL_PERCENT / 2,
139
- projectId: _projectId,
140
- beneficiary: _bene,
141
- lockedUntil: 0,
142
- hook: IJBSplitHook(address(0))
143
- });
144
-
145
- // Set up a second payout split recipient.
146
- _splitsArray[1] = JBSplit({
147
- preferAddToBalance: false,
148
- percent: JBConstants.SPLITS_TOTAL_PERCENT,
149
- projectId: _projectId,
150
- beneficiary: _bene,
151
- lockedUntil: 0,
152
- hook: IJBSplitHook(address(0))
153
- });
154
-
155
- // outer structure
156
- _splitsGroup[0] = JBSplitGroup({groupId: 0, splits: _splitsArray});
157
-
158
- vm.expectRevert(JBSplits.JBSplits_TotalPercentExceeds100.selector);
159
- _splits.setSplitGroupsOf(_projectId, _rulesetId, _splitsGroup);
160
- }
161
-
162
- function test_HappyPath() external whenCallerIsController {
163
- // it will store splits and emit SetSplit for each configured
164
-
165
- // data for call
166
- JBSplitGroup[] memory _splitsGroup = new JBSplitGroup[](1);
167
- JBSplit[] memory _splitsArray = new JBSplit[](2);
168
-
169
- // Set up a valid payout split recipient.
170
- _splitsArray[0] = JBSplit({
171
- preferAddToBalance: false,
172
- percent: JBConstants.SPLITS_TOTAL_PERCENT / 2,
173
- projectId: _projectId,
174
- beneficiary: _bene,
175
- lockedUntil: 0,
176
- hook: IJBSplitHook(address(0))
177
- });
178
-
179
- // Set up a second valid payout split recipient.
180
- _splitsArray[1] = JBSplit({
181
- preferAddToBalance: false,
182
- percent: JBConstants.SPLITS_TOTAL_PERCENT / 2,
183
- projectId: _projectId,
184
- beneficiary: payable(makeAddr("anotherBene")),
185
- lockedUntil: 0,
186
- hook: IJBSplitHook(address(0))
187
- });
188
-
189
- // outer structure
190
- _splitsGroup[0] = JBSplitGroup({groupId: 0, splits: _splitsArray});
191
-
192
- // should emit an event for each split
193
- vm.expectEmit();
194
- emit IJBSplits.SetSplit(_projectId, block.timestamp, 0, _splitsArray[0], address(this));
195
-
196
- vm.expectEmit();
197
- emit IJBSplits.SetSplit(_projectId, block.timestamp, 0, _splitsArray[1], address(this));
198
-
199
- _splits.setSplitGroupsOf(_projectId, _rulesetId, _splitsGroup);
200
- }
201
-
202
- function test_GivenSettingExistingIdDomainAndGroup() external whenCallerIsController {
203
- // it will overwrite
204
-
205
- // data for call
206
- JBSplitGroup[] memory _splitsGroup = new JBSplitGroup[](1);
207
- JBSplit[] memory _splitsArray = new JBSplit[](1);
208
-
209
- // Set up a payout split recipient.
210
- _splitsArray[0] = JBSplit({
211
- preferAddToBalance: false,
212
- percent: JBConstants.SPLITS_TOTAL_PERCENT / 2,
213
- projectId: _projectId,
214
- beneficiary: _bene,
215
- lockedUntil: 0,
216
- hook: IJBSplitHook(address(0))
217
- });
218
-
219
- // outer structure
220
- _splitsGroup[0] = JBSplitGroup({groupId: 0, splits: _splitsArray});
221
-
222
- vm.expectEmit();
223
- emit IJBSplits.SetSplit(_projectId, block.timestamp, 0, _splitsArray[0], address(this));
224
-
225
- _splits.setSplitGroupsOf(_projectId, _rulesetId, _splitsGroup);
226
-
227
- // Second or "reconfig" call
228
-
229
- // Re-Set up a payout split recipient.
230
- _splitsArray[0] = JBSplit({
231
- // Different attributes
232
- preferAddToBalance: true,
233
- percent: JBConstants.SPLITS_TOTAL_PERCENT / 3,
234
- projectId: _projectId,
235
- beneficiary: _bene,
236
- lockedUntil: 0,
237
- hook: IJBSplitHook(address(0))
238
- });
239
-
240
- // outer structure
241
- _splitsGroup[0] = JBSplitGroup({groupId: 0, splits: _splitsArray});
242
-
243
- vm.expectEmit();
244
- emit IJBSplits.SetSplit(_projectId, block.timestamp, 0, _splitsArray[0], address(this));
245
-
246
- _splits.setSplitGroupsOf(_projectId, block.timestamp, _splitsGroup);
247
-
248
- JBSplit[] memory _current = _splits.splitsOf(_projectId, block.timestamp, 0);
249
-
250
- assertEq(_current[0].preferAddToBalance, true);
251
- }
252
-
253
- function test_GivenAddingNewLockedSplitsIncludingPreviouslyLocked() external whenCallerIsController {
254
- // it will reconfigure and extend previously locked splits
255
-
256
- // data for call
257
- JBSplitGroup[] memory _splitsGroup = new JBSplitGroup[](1);
258
- JBSplit[] memory _splitsArray = new JBSplit[](1);
259
-
260
- // Set up a payout split recipient.
261
- _splitsArray[0] = JBSplit({
262
- preferAddToBalance: false,
263
- percent: JBConstants.SPLITS_TOTAL_PERCENT / 2,
264
- projectId: _projectId,
265
- beneficiary: _bene,
266
- lockedUntil: uint48(block.timestamp + 100),
267
- hook: IJBSplitHook(address(0))
268
- });
269
-
270
- // outer structure
271
- _splitsGroup[0] = JBSplitGroup({groupId: 0, splits: _splitsArray});
272
-
273
- vm.expectEmit();
274
- emit IJBSplits.SetSplit(_projectId, block.timestamp, 0, _splitsArray[0], address(this));
275
-
276
- _splits.setSplitGroupsOf(_projectId, _rulesetId, _splitsGroup);
277
-
278
- // Second or "reconfig" call
279
-
280
- JBSplit[] memory _splitsArray2 = new JBSplit[](2);
281
-
282
- // Re-Set up a payout split recipient.
283
- _splitsArray2[0] = JBSplit({
284
- preferAddToBalance: false,
285
- percent: JBConstants.SPLITS_TOTAL_PERCENT / 2,
286
- projectId: _projectId,
287
- beneficiary: _bene,
288
- lockedUntil: uint48(block.timestamp + 100),
289
- hook: IJBSplitHook(address(0))
290
- });
291
-
292
- // Re-Set up a payout split recipient.
293
- _splitsArray2[1] = JBSplit({
294
- preferAddToBalance: true,
295
- percent: JBConstants.SPLITS_TOTAL_PERCENT / 2,
296
- projectId: _projectId,
297
- beneficiary: _bene,
298
- lockedUntil: uint48(block.timestamp + 200),
299
- hook: IJBSplitHook(address(0))
300
- });
301
-
302
- // outer structure
303
- _splitsGroup[0] = JBSplitGroup({groupId: 0, splits: _splitsArray2});
304
-
305
- vm.expectEmit();
306
- emit IJBSplits.SetSplit(_projectId, block.timestamp, 0, _splitsArray2[0], address(this));
307
-
308
- _splits.setSplitGroupsOf(_projectId, block.timestamp, _splitsGroup);
309
-
310
- JBSplit[] memory _current = _splits.splitsOf(_projectId, block.timestamp, 0);
311
-
312
- assertEq(_current[0].lockedUntil, block.timestamp + 100);
313
- assertEq(_current[1].lockedUntil, block.timestamp + 200);
314
- }
315
-
316
- function test_GivenOverwritingExistingLockedSplitWithReorderedGroup() external whenCallerIsController {
317
- // it will overwrite
318
-
319
- // data for call
320
- JBSplitGroup[] memory _splitsGroup = new JBSplitGroup[](1);
321
- JBSplit[] memory _splitsArray = new JBSplit[](1);
322
-
323
- // Set up a payout split recipient.
324
- _splitsArray[0] = JBSplit({
325
- preferAddToBalance: false,
326
- percent: JBConstants.SPLITS_TOTAL_PERCENT / 2,
327
- projectId: _projectId,
328
- beneficiary: _bene,
329
- lockedUntil: uint48(block.timestamp + 100),
330
- hook: IJBSplitHook(address(0))
331
- });
332
-
333
- // outer structure
334
- _splitsGroup[0] = JBSplitGroup({groupId: 0, splits: _splitsArray});
335
-
336
- vm.expectEmit();
337
- emit IJBSplits.SetSplit(_projectId, block.timestamp, 0, _splitsArray[0], address(this));
338
-
339
- _splits.setSplitGroupsOf(_projectId, _rulesetId, _splitsGroup);
340
-
341
- // Second or "reconfig" call
342
- JBSplitGroup[] memory _secondSplitsGroup = new JBSplitGroup[](1);
343
- JBSplit[] memory _secondSplitsArray = new JBSplit[](2);
344
-
345
- // Re-Set up a payout split recipient.
346
- _secondSplitsArray[1] = JBSplit({
347
- preferAddToBalance: false,
348
- percent: JBConstants.SPLITS_TOTAL_PERCENT / 2,
349
- projectId: _projectId,
350
- beneficiary: _bene,
351
- lockedUntil: uint48(block.timestamp + 100),
352
- hook: IJBSplitHook(address(0))
353
- });
354
-
355
- _secondSplitsArray[0] = JBSplit({
356
- preferAddToBalance: false,
357
- percent: JBConstants.SPLITS_TOTAL_PERCENT / 2,
358
- projectId: _projectId,
359
- beneficiary: _bene,
360
- lockedUntil: 0,
361
- hook: IJBSplitHook(address(0))
362
- });
363
-
364
- // outer structure
365
- _secondSplitsGroup[0] = JBSplitGroup({groupId: 0, splits: _secondSplitsArray});
366
-
367
- vm.expectEmit();
368
- emit IJBSplits.SetSplit(_projectId, block.timestamp, 0, _secondSplitsArray[0], address(this));
369
- emit IJBSplits.SetSplit(_projectId, block.timestamp, 0, _secondSplitsArray[1], address(this));
370
-
371
- _splits.setSplitGroupsOf(_projectId, block.timestamp, _secondSplitsGroup);
372
-
373
- JBSplit[] memory _current = _splits.splitsOf(_projectId, block.timestamp, 0);
374
-
375
- assertEq(_current[0].preferAddToBalance, false);
376
- }
377
- }
@@ -1,267 +0,0 @@
1
- // SPDX-License-Identifier: MIT
2
- pragma solidity 0.8.28;
3
-
4
- import {JBSplits} from "../../../../src/JBSplits.sol";
5
- import {IJBDirectory} from "../../../../src/interfaces/IJBDirectory.sol";
6
- import {IJBSplitHook} from "../../../../src/interfaces/IJBSplitHook.sol";
7
- import {IJBSplits} from "../../../../src/interfaces/IJBSplits.sol";
8
- import {JBSplit} from "../../../../src/structs/JBSplit.sol";
9
- import {JBSplitGroup} from "../../../../src/structs/JBSplitGroup.sol";
10
- import {JBSplitsSetup} from "./JBSplitsSetup.sol";
11
-
12
- /// @notice Edge case tests for JBSplits lock enforcement.
13
- /// Key finding: locks only enforce within the SAME rulesetId. A project owner
14
- /// can bypass a locked split by setting splits under a different rulesetId.
15
- contract TestSplitsLockedEdge_Local is JBSplitsSetup {
16
- uint256 constant PROJECT_ID = 1;
17
- uint256 constant RULESET_ID_A = 100;
18
- uint256 constant RULESET_ID_B = 200;
19
- uint256 constant GROUP_ID = 1;
20
- address constant BENEFICIARY = address(0xBEEF);
21
-
22
- IJBSplits public splits;
23
-
24
- function setUp() public {
25
- super.splitsSetup();
26
- splits = IJBSplits(address(_splits));
27
-
28
- // Mock controllerOf to return this contract.
29
- vm.mockCall(
30
- address(directory), abi.encodeCall(IJBDirectory.controllerOf, (PROJECT_ID)), abi.encode(address(this))
31
- );
32
- }
33
-
34
- // Helper to create a split with specified parameters.
35
- function _makeSplit(
36
- uint32 percent,
37
- address beneficiary_,
38
- uint48 lockedUntil
39
- )
40
- internal
41
- pure
42
- returns (JBSplit memory)
43
- {
44
- return JBSplit({
45
- percent: percent,
46
- projectId: 0,
47
- beneficiary: payable(beneficiary_),
48
- preferAddToBalance: false,
49
- lockedUntil: lockedUntil,
50
- hook: IJBSplitHook(address(0))
51
- });
52
- }
53
-
54
- // ───────────────────── Lock enforcement within same ruleset
55
- // ─────────────────────
56
-
57
- /// @notice Removing a locked split within the same rulesetId should revert.
58
- function test_lockEnforcement_withinSameRuleset() external {
59
- // Set a locked split.
60
- JBSplit[] memory initialSplits = new JBSplit[](1);
61
- initialSplits[0] = _makeSplit(500_000_000, BENEFICIARY, uint48(block.timestamp + 365 days));
62
-
63
- JBSplitGroup[] memory groups = new JBSplitGroup[](1);
64
- groups[0] = JBSplitGroup({groupId: GROUP_ID, splits: initialSplits});
65
-
66
- splits.setSplitGroupsOf(PROJECT_ID, RULESET_ID_A, groups);
67
-
68
- // Try to remove the locked split.
69
- JBSplit[] memory newSplits = new JBSplit[](1);
70
- newSplits[0] = _makeSplit(500_000_000, address(0xDEAD), 0); // Different beneficiary.
71
-
72
- JBSplitGroup[] memory newGroups = new JBSplitGroup[](1);
73
- newGroups[0] = JBSplitGroup({groupId: GROUP_ID, splits: newSplits});
74
-
75
- vm.expectRevert(
76
- abi.encodeWithSelector(JBSplits.JBSplits_PreviousLockedSplitsNotIncluded.selector, PROJECT_ID, RULESET_ID_A)
77
- );
78
- splits.setSplitGroupsOf(PROJECT_ID, RULESET_ID_A, newGroups);
79
- }
80
-
81
- // ───────────────────── Lock DOES NOT carry across rulesets
82
- // ─────────────────────
83
-
84
- /// @notice DESIGN ISSUE: Locked splits in rulesetId A don't constrain rulesetId B.
85
- /// A project owner can bypass a lock by queuing a new ruleset without the split.
86
- function test_lockEnforcement_acrossRulesets() external {
87
- // Set a locked split in rulesetId A.
88
- JBSplit[] memory initialSplits = new JBSplit[](1);
89
- initialSplits[0] = _makeSplit(500_000_000, BENEFICIARY, uint48(block.timestamp + 365 days));
90
-
91
- JBSplitGroup[] memory groups = new JBSplitGroup[](1);
92
- groups[0] = JBSplitGroup({groupId: GROUP_ID, splits: initialSplits});
93
-
94
- splits.setSplitGroupsOf(PROJECT_ID, RULESET_ID_A, groups);
95
-
96
- // Set completely different splits in rulesetId B — this SUCCEEDS even though
97
- // the locked split from rulesetId A is not included.
98
- JBSplit[] memory newSplits = new JBSplit[](1);
99
- newSplits[0] = _makeSplit(500_000_000, address(0xDEAD), 0); // No lock, different beneficiary.
100
-
101
- JBSplitGroup[] memory newGroups = new JBSplitGroup[](1);
102
- newGroups[0] = JBSplitGroup({groupId: GROUP_ID, splits: newSplits});
103
-
104
- // This should succeed — locks don't carry across rulesets.
105
- splits.setSplitGroupsOf(PROJECT_ID, RULESET_ID_B, newGroups);
106
-
107
- // Verify the new ruleset has different splits.
108
- JBSplit[] memory rulesetsB = splits.splitsOf(PROJECT_ID, RULESET_ID_B, GROUP_ID);
109
- assertEq(rulesetsB.length, 1, "Ruleset B should have splits");
110
- assertEq(rulesetsB[0].beneficiary, address(0xDEAD), "Locked split bypassed via new rulesetId");
111
- }
112
-
113
- // ───────────────────── Lock extension allowed
114
- // ─────────────────────
115
-
116
- /// @notice Extending lockedUntil to a later time should succeed.
117
- function test_lockExtension_allowed() external {
118
- uint48 originalLock = uint48(block.timestamp + 180 days);
119
- uint48 extendedLock = uint48(block.timestamp + 365 days);
120
-
121
- JBSplit[] memory initialSplits = new JBSplit[](1);
122
- initialSplits[0] = _makeSplit(500_000_000, BENEFICIARY, originalLock);
123
-
124
- JBSplitGroup[] memory groups = new JBSplitGroup[](1);
125
- groups[0] = JBSplitGroup({groupId: GROUP_ID, splits: initialSplits});
126
- splits.setSplitGroupsOf(PROJECT_ID, RULESET_ID_A, groups);
127
-
128
- // Extend the lock.
129
- JBSplit[] memory extendedSplits = new JBSplit[](1);
130
- extendedSplits[0] = _makeSplit(500_000_000, BENEFICIARY, extendedLock);
131
-
132
- JBSplitGroup[] memory extendedGroups = new JBSplitGroup[](1);
133
- extendedGroups[0] = JBSplitGroup({groupId: GROUP_ID, splits: extendedSplits});
134
-
135
- // Should succeed — lock extension is allowed.
136
- splits.setSplitGroupsOf(PROJECT_ID, RULESET_ID_A, extendedGroups);
137
-
138
- JBSplit[] memory result = splits.splitsOf(PROJECT_ID, RULESET_ID_A, GROUP_ID);
139
- assertEq(result[0].lockedUntil, extendedLock, "Lock should be extended");
140
- }
141
-
142
- // ───────────────────── Lock reduction blocked
143
- // ─────────────────────
144
-
145
- /// @notice Reducing lockedUntil (while still locked) should revert.
146
- function test_lockReduction_blocked() external {
147
- uint48 originalLock = uint48(block.timestamp + 365 days);
148
- uint48 reducedLock = uint48(block.timestamp + 90 days);
149
-
150
- JBSplit[] memory initialSplits = new JBSplit[](1);
151
- initialSplits[0] = _makeSplit(500_000_000, BENEFICIARY, originalLock);
152
-
153
- JBSplitGroup[] memory groups = new JBSplitGroup[](1);
154
- groups[0] = JBSplitGroup({groupId: GROUP_ID, splits: initialSplits});
155
- splits.setSplitGroupsOf(PROJECT_ID, RULESET_ID_A, groups);
156
-
157
- // Try to reduce the lock — should fail.
158
- JBSplit[] memory reducedSplits = new JBSplit[](1);
159
- reducedSplits[0] = _makeSplit(500_000_000, BENEFICIARY, reducedLock);
160
-
161
- JBSplitGroup[] memory reducedGroups = new JBSplitGroup[](1);
162
- reducedGroups[0] = JBSplitGroup({groupId: GROUP_ID, splits: reducedSplits});
163
-
164
- vm.expectRevert(
165
- abi.encodeWithSelector(JBSplits.JBSplits_PreviousLockedSplitsNotIncluded.selector, PROJECT_ID, RULESET_ID_A)
166
- );
167
- splits.setSplitGroupsOf(PROJECT_ID, RULESET_ID_A, reducedGroups);
168
- }
169
-
170
- // ───────────────────── Lock expired allows removal
171
- // ─────────────────────
172
-
173
- /// @notice After lockedUntil passes, split can be removed.
174
- function test_lockExpired_canRemove() external {
175
- uint48 lockTime = uint48(block.timestamp + 30 days);
176
-
177
- JBSplit[] memory initialSplits = new JBSplit[](1);
178
- initialSplits[0] = _makeSplit(500_000_000, BENEFICIARY, lockTime);
179
-
180
- JBSplitGroup[] memory groups = new JBSplitGroup[](1);
181
- groups[0] = JBSplitGroup({groupId: GROUP_ID, splits: initialSplits});
182
- splits.setSplitGroupsOf(PROJECT_ID, RULESET_ID_A, groups);
183
-
184
- // Warp past lock expiry.
185
- vm.warp(lockTime + 1);
186
-
187
- // Now remove the split — should succeed.
188
- JBSplit[] memory newSplits = new JBSplit[](1);
189
- newSplits[0] = _makeSplit(500_000_000, address(0xDEAD), 0);
190
-
191
- JBSplitGroup[] memory newGroups = new JBSplitGroup[](1);
192
- newGroups[0] = JBSplitGroup({groupId: GROUP_ID, splits: newSplits});
193
-
194
- splits.setSplitGroupsOf(PROJECT_ID, RULESET_ID_A, newGroups);
195
-
196
- JBSplit[] memory result = splits.splitsOf(PROJECT_ID, RULESET_ID_A, GROUP_ID);
197
- assertEq(result[0].beneficiary, address(0xDEAD), "Expired lock allows removal");
198
- }
199
-
200
- // ───────────────────── Percent validation
201
- // ─────────────────────
202
-
203
- /// @notice Total percent > SPLITS_TOTAL_PERCENT should revert.
204
- function test_percentExceeds100_reverts() external {
205
- JBSplit[] memory splitArray = new JBSplit[](2);
206
- splitArray[0] = _makeSplit(600_000_000, BENEFICIARY, 0); // 60%
207
- splitArray[1] = _makeSplit(500_000_000, address(0xDEAD), 0); // 50% → total 110%
208
-
209
- JBSplitGroup[] memory groups = new JBSplitGroup[](1);
210
- groups[0] = JBSplitGroup({groupId: GROUP_ID, splits: splitArray});
211
-
212
- vm.expectRevert(JBSplits.JBSplits_TotalPercentExceeds100.selector);
213
- splits.setSplitGroupsOf(PROJECT_ID, RULESET_ID_A, groups);
214
- }
215
-
216
- /// @notice Any split with percent=0 should revert.
217
- function test_zeroPercent_reverts() external {
218
- JBSplit[] memory splitArray = new JBSplit[](1);
219
- splitArray[0] = _makeSplit(0, BENEFICIARY, 0);
220
-
221
- JBSplitGroup[] memory groups = new JBSplitGroup[](1);
222
- groups[0] = JBSplitGroup({groupId: GROUP_ID, splits: splitArray});
223
-
224
- vm.expectRevert(JBSplits.JBSplits_ZeroSplitPercent.selector);
225
- splits.setSplitGroupsOf(PROJECT_ID, RULESET_ID_A, groups);
226
- }
227
-
228
- // ───────────────────── Hook and beneficiary edge cases
229
- // ─────────────────────
230
-
231
- /// @notice Arbitrary address as hook is accepted (no interface check).
232
- function test_hookAddress_notValidated() external {
233
- JBSplit[] memory splitArray = new JBSplit[](1);
234
- splitArray[0] = JBSplit({
235
- percent: 500_000_000,
236
- projectId: 0,
237
- beneficiary: payable(BENEFICIARY),
238
- preferAddToBalance: false,
239
- lockedUntil: 0,
240
- hook: IJBSplitHook(address(0x1234)) // Arbitrary address — no interface validation.
241
- });
242
-
243
- JBSplitGroup[] memory groups = new JBSplitGroup[](1);
244
- groups[0] = JBSplitGroup({groupId: GROUP_ID, splits: splitArray});
245
-
246
- // Should succeed — no ERC165 or interface check.
247
- splits.setSplitGroupsOf(PROJECT_ID, RULESET_ID_A, groups);
248
-
249
- JBSplit[] memory result = splits.splitsOf(PROJECT_ID, RULESET_ID_A, GROUP_ID);
250
- assertEq(address(result[0].hook), address(0x1234), "Arbitrary hook address accepted");
251
- }
252
-
253
- /// @notice address(0) beneficiary is valid (potential footgun).
254
- function test_beneficiaryZero_accepted() external {
255
- JBSplit[] memory splitArray = new JBSplit[](1);
256
- splitArray[0] = _makeSplit(500_000_000, address(0), 0);
257
-
258
- JBSplitGroup[] memory groups = new JBSplitGroup[](1);
259
- groups[0] = JBSplitGroup({groupId: GROUP_ID, splits: splitArray});
260
-
261
- // Should succeed — no zero-address check.
262
- splits.setSplitGroupsOf(PROJECT_ID, RULESET_ID_A, groups);
263
-
264
- JBSplit[] memory result = splits.splitsOf(PROJECT_ID, RULESET_ID_A, GROUP_ID);
265
- assertEq(result[0].beneficiary, address(0), "Zero beneficiary accepted (footgun)");
266
- }
267
- }
@@ -1,24 +0,0 @@
1
- // SPDX-License-Identifier: MIT
2
- pragma solidity 0.8.28;
3
-
4
- import {JBSplit} from "../../../../src/structs/JBSplit.sol";
5
- import {JBSplitsSetup} from "./JBSplitsSetup.sol";
6
-
7
- contract TestSplitsOf_Local is JBSplitsSetup {
8
- function setUp() public {
9
- super.splitsSetup();
10
- }
11
-
12
- // This is covered under TestSetSplitGroupsOf
13
- /* function test_WhenThereAreDefinedSplits() external {
14
- // it should return the defined splits
15
- } */
16
-
17
- function test_WhenThereAreNoSplitsDefined() external view {
18
- // it should return the default splits for FALLBACK_RULESET_ID
19
-
20
- JBSplit[] memory _current = _splits.splitsOf(1, block.timestamp, 0);
21
-
22
- assertEq(_current.length, 0);
23
- }
24
- }