@bananapus/core-v6 0.0.37 → 0.0.39

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 (324) hide show
  1. package/foundry.lock +1 -7
  2. package/foundry.toml +1 -1
  3. package/package.json +19 -7
  4. package/src/JBChainlinkV3PriceFeed.sol +4 -1
  5. package/src/JBChainlinkV3SequencerPriceFeed.sol +4 -2
  6. package/src/JBController.sol +71 -44
  7. package/src/JBDeadline.sol +4 -4
  8. package/src/JBDirectory.sol +34 -32
  9. package/src/JBERC20.sol +5 -4
  10. package/src/JBFeelessAddresses.sol +6 -3
  11. package/src/JBFundAccessLimits.sol +25 -21
  12. package/src/JBMultiTerminal.sol +121 -84
  13. package/src/JBPermissions.sol +34 -37
  14. package/src/JBPrices.sol +23 -18
  15. package/src/JBProjects.sol +6 -3
  16. package/src/JBRulesets.sol +44 -41
  17. package/src/JBSplits.sol +18 -16
  18. package/src/JBTerminalStore.sol +32 -25
  19. package/src/JBTokens.sol +36 -26
  20. package/src/abstract/JBControlled.sol +3 -1
  21. package/src/abstract/JBPermissioned.sol +3 -1
  22. package/src/enums/JBApprovalStatus.sol +7 -1
  23. package/src/interfaces/IJBController.sol +7 -3
  24. package/src/interfaces/IJBDirectory.sol +3 -1
  25. package/src/interfaces/IJBMultiTerminal.sol +3 -2
  26. package/src/interfaces/IJBPermissions.sol +2 -1
  27. package/src/interfaces/IJBPrices.sol +3 -1
  28. package/src/interfaces/IJBRulesets.sol +2 -1
  29. package/src/interfaces/IJBSplits.sol +2 -1
  30. package/src/interfaces/IJBTerminal.sol +3 -1
  31. package/src/interfaces/IJBTerminalStore.sol +3 -1
  32. package/src/interfaces/IJBTokens.sol +2 -1
  33. package/src/libraries/JBCashOuts.sol +6 -1
  34. package/src/libraries/JBConstants.sol +12 -3
  35. package/src/libraries/JBCurrencyIds.sol +2 -0
  36. package/src/libraries/JBFees.sol +52 -10
  37. package/src/libraries/JBFixedPointNumber.sol +2 -0
  38. package/src/libraries/JBPayoutSplitGroupLib.sol +7 -4
  39. package/src/libraries/JBRulesetMetadataResolver.sol +4 -0
  40. package/src/libraries/JBSplitGroupIds.sol +2 -1
  41. package/src/libraries/JBSurplus.sol +3 -1
  42. package/src/periphery/JBMatchingPriceFeed.sol +3 -1
  43. package/src/structs/JBAccountingContext.sol +7 -4
  44. package/src/structs/JBFundAccessLimitGroup.sol +10 -17
  45. package/src/structs/JBRuleset.sol +18 -26
  46. package/src/structs/JBRulesetConfig.sol +13 -25
  47. package/src/structs/JBRulesetMetadata.sol +25 -32
  48. package/test/mock/MockMaliciousBeneficiary.sol +15 -15
  49. package/ADMINISTRATION.md +0 -103
  50. package/ARCHITECTURE.md +0 -133
  51. package/AUDIT_INSTRUCTIONS.md +0 -139
  52. package/RISKS.md +0 -215
  53. package/SKILLS.md +0 -55
  54. package/STYLE_GUIDE.md +0 -610
  55. package/USER_JOURNEYS.md +0 -215
  56. package/script/Deploy.s.sol +0 -124
  57. package/script/DeployPeriphery.s.sol +0 -354
  58. package/slither-ci.config.json +0 -10
  59. package/test/AuditFixes.t.sol +0 -808
  60. package/test/ComprehensiveInvariant.t.sol +0 -306
  61. package/test/CoreExploitTests.t.sol +0 -2741
  62. package/test/EconomicSimulation.t.sol +0 -348
  63. package/test/EntryPointPermutations.t.sol +0 -684
  64. package/test/FlashLoanAttacks.t.sol +0 -797
  65. package/test/PermissionEscalation.t.sol +0 -711
  66. package/test/PermissionsInvariant.t.sol +0 -403
  67. package/test/RulesetTransitions.t.sol +0 -713
  68. package/test/SplitLoopTests.t.sol +0 -752
  69. package/test/TestAccessToFunds.sol +0 -2683
  70. package/test/TestAuditResponseDesignProofs.sol +0 -434
  71. package/test/TestCashOut.sol +0 -198
  72. package/test/TestCashOutCountFor.sol +0 -271
  73. package/test/TestCashOutHooks.sol +0 -351
  74. package/test/TestCashOutTimingEdge.sol +0 -241
  75. package/test/TestDataHookFuzzing.sol +0 -524
  76. package/test/TestDurationUnderflow.sol +0 -233
  77. package/test/TestFeeFreeCashOutBypass.sol +0 -949
  78. package/test/TestFeeProcessingFailure.sol +0 -218
  79. package/test/TestFees.sol +0 -619
  80. package/test/TestForwardedTokenConsumption.sol +0 -425
  81. package/test/TestInterfaceSupport.sol +0 -81
  82. package/test/TestJBERC20Inheritance.sol +0 -103
  83. package/test/TestL2SequencerPriceFeed.sol +0 -292
  84. package/test/TestLaunchProject.sol +0 -188
  85. package/test/TestMetaTx.sol +0 -217
  86. package/test/TestMetadataOffsetOverflow.sol +0 -179
  87. package/test/TestMetadataParserLib.sol +0 -471
  88. package/test/TestMigrationHeldFees.sol +0 -255
  89. package/test/TestMintTokensOf.sol +0 -185
  90. package/test/TestMultiTerminalSurplus.sol +0 -348
  91. package/test/TestMultiTokenSurplus.sol +0 -202
  92. package/test/TestMultipleAccessLimits.sol +0 -664
  93. package/test/TestPayBurnRedeemFlow.sol +0 -195
  94. package/test/TestPayHooks.sol +0 -209
  95. package/test/TestPermissions.sol +0 -324
  96. package/test/TestPermissionsEdge.sol +0 -290
  97. package/test/TestPermit2DataHook.t.sol +0 -360
  98. package/test/TestPermit2Terminal.sol +0 -372
  99. package/test/TestRulesetQueueing.sol +0 -1025
  100. package/test/TestRulesetQueuingStress.sol +0 -806
  101. package/test/TestRulesetWeightCaching.sol +0 -178
  102. package/test/TestSplits.sol +0 -391
  103. package/test/TestTerminalMigration.sol +0 -274
  104. package/test/TestTerminalPreviewParity.sol +0 -208
  105. package/test/TestTokenFlow.sol +0 -191
  106. package/test/TestWeightCacheStaleAfterRejection.sol +0 -303
  107. package/test/WeirdTokenTests.t.sol +0 -817
  108. package/test/audit/CashOutReenterPay.t.sol +0 -501
  109. package/test/audit/CodexHeldFeeRounding.t.sol +0 -159
  110. package/test/audit/CodexMigrationFeeFailure.t.sol +0 -163
  111. package/test/audit/CrossTerminalSurplusSpoof.t.sol +0 -140
  112. package/test/audit/CycledSurplusAllowanceReset.t.sol +0 -184
  113. package/test/audit/FeeFreeSurplusLifecycle.t.sol +0 -399
  114. package/test/audit/FeeFreeSurplusStale.t.sol +0 -248
  115. package/test/audit/USDTVoidReturnCompat.t.sol +0 -525
  116. package/test/fork/TestChainlinkPriceFeedFork.sol +0 -254
  117. package/test/fork/TestSequencerPriceFeedFork.sol +0 -168
  118. package/test/fork/TestTerminalPreviewParityFork.sol +0 -108
  119. package/test/formal/BondingCurveProperties.t.sol +0 -420
  120. package/test/formal/FeeProperties.t.sol +0 -252
  121. package/test/invariants/Phase3DeepInvariant.t.sol +0 -412
  122. package/test/invariants/RulesetsInvariant.t.sol +0 -125
  123. package/test/invariants/TerminalStoreInvariant.t.sol +0 -227
  124. package/test/invariants/TokensInvariant.t.sol +0 -195
  125. package/test/invariants/handlers/ComprehensiveHandler.sol +0 -303
  126. package/test/invariants/handlers/EconomicHandler.sol +0 -377
  127. package/test/invariants/handlers/Phase3Handler.sol +0 -443
  128. package/test/invariants/handlers/RulesetsHandler.sol +0 -115
  129. package/test/invariants/handlers/TerminalStoreHandler.sol +0 -151
  130. package/test/invariants/handlers/TokensHandler.sol +0 -126
  131. package/test/regression/HoldFeesCashOutReserved.t.sol +0 -415
  132. package/test/regression/WeightCacheBoundary.t.sol +0 -291
  133. package/test/trees/JBController/burnTokensOf.tree +0 -9
  134. package/test/trees/JBController/claimTokensFor.tree +0 -5
  135. package/test/trees/JBController/deployERC20For.tree +0 -5
  136. package/test/trees/JBController/getRulesetOf.tree +0 -5
  137. package/test/trees/JBController/launchProjectFor.tree +0 -12
  138. package/test/trees/JBController/launchRulesetsFor.tree +0 -8
  139. package/test/trees/JBController/migrateController.tree +0 -12
  140. package/test/trees/JBController/mintTokensOf.tree +0 -12
  141. package/test/trees/JBController/payReservedTokenToTerminal.tree +0 -8
  142. package/test/trees/JBController/receiveMigrationFrom.tree +0 -4
  143. package/test/trees/JBController/sendReservedTokensToSplitsOf.tree +0 -12
  144. package/test/trees/JBController/setMetadataOf.tree +0 -5
  145. package/test/trees/JBController/setSplitGroupsOf.tree +0 -5
  146. package/test/trees/JBController/setTokenFor.tree +0 -5
  147. package/test/trees/JBController/transferCreditsFrom.tree +0 -8
  148. package/test/trees/JBDirectory/primaryTerminalOf.tree +0 -8
  149. package/test/trees/JBDirectory/setControllerOf.tree +0 -11
  150. package/test/trees/JBDirectory/setPrimaryTerminalOf.tree +0 -15
  151. package/test/trees/JBDirectory/setTerminalsOf.tree +0 -11
  152. package/test/trees/JBERC20/initialize.tree +0 -7
  153. package/test/trees/JBERC20/name.tree +0 -5
  154. package/test/trees/JBERC20/nonces.tree +0 -5
  155. package/test/trees/JBERC20/symbol.tree +0 -5
  156. package/test/trees/JBFeelessAddresses/setFeelessAddress.tree +0 -5
  157. package/test/trees/JBFeelessAddresses/supportsInterface.tree +0 -5
  158. package/test/trees/JBFundAccessLimits/payoutLimitOf.tree +0 -5
  159. package/test/trees/JBFundAccessLimits/payoutLimitsOf.tree +0 -8
  160. package/test/trees/JBFundAccessLimits/setFundAccessLimitsFor.tree +0 -18
  161. package/test/trees/JBFundAccessLimits/surplusAllowanceOf.tree +0 -5
  162. package/test/trees/JBFundAccessLimits/surplusAllowancesOf.tree +0 -8
  163. package/test/trees/JBMetadataResolver/getDataFor.tree +0 -8
  164. package/test/trees/JBMultiTerminal/accountingContextsOf.tree +0 -5
  165. package/test/trees/JBMultiTerminal/addAccountingContextsFor.tree +0 -10
  166. package/test/trees/JBMultiTerminal/addToBalanceOf.tree +0 -23
  167. package/test/trees/JBMultiTerminal/cashOutTokensOf.tree +0 -23
  168. package/test/trees/JBMultiTerminal/executePayout.tree +0 -32
  169. package/test/trees/JBMultiTerminal/executeProcessFee.tree +0 -14
  170. package/test/trees/JBMultiTerminal/migrateBalanceOf.tree +0 -12
  171. package/test/trees/JBMultiTerminal/pay.tree +0 -23
  172. package/test/trees/JBMultiTerminal/processHeldFeesOf.tree +0 -8
  173. package/test/trees/JBMultiTerminal/sendPayoutsOf.tree +0 -34
  174. package/test/trees/JBMultiTerminal/useAllowanceOf.tree +0 -16
  175. package/test/trees/JBPermissions/hasPermission.tree +0 -8
  176. package/test/trees/JBPermissions/hasPermissions.tree +0 -8
  177. package/test/trees/JBPermissions/setPermissionsFor.tree +0 -5
  178. package/test/trees/JBPrices/addPriceFeedFor.tree +0 -14
  179. package/test/trees/JBPrices/pricePerUnitOf.tree +0 -11
  180. package/test/trees/JBProjects/createFor.tree +0 -11
  181. package/test/trees/JBProjects/setTokenUriResolver.tree +0 -5
  182. package/test/trees/JBProjects/supportsInterface.tree +0 -9
  183. package/test/trees/JBProjects/tokenURI.tree +0 -5
  184. package/test/trees/JBRulesets/currentApprovalStatusForLatestRulesetOf.tree +0 -8
  185. package/test/trees/JBRulesets/currentOf.tree +0 -12
  186. package/test/trees/JBRulesets/getRulesetOf.tree +0 -5
  187. package/test/trees/JBRulesets/latestQueuedRulesetOf.tree +0 -10
  188. package/test/trees/JBRulesets/rulesetsOf.tree +0 -11
  189. package/test/trees/JBRulesets/upcomingRulesetOf.tree +0 -20
  190. package/test/trees/JBRulesets/updateRulesetWeightCache.tree +0 -5
  191. package/test/trees/JBSplits/setSplitGroupsOf.tree +0 -17
  192. package/test/trees/JBSplits/splitsOf.tree +0 -5
  193. package/test/trees/JBTerminalStore/currentReclaimableSurplusOf.tree +0 -16
  194. package/test/trees/JBTerminalStore/currentSurplusOf.tree +0 -25
  195. package/test/trees/JBTerminalStore/currentTotalSurplusOf.tree +0 -5
  196. package/test/trees/JBTerminalStore/recordCashOutsFor.tree +0 -16
  197. package/test/trees/JBTerminalStore/recordPaymentFrom.tree +0 -14
  198. package/test/trees/JBTerminalStore/recordPayoutFor.tree +0 -10
  199. package/test/trees/JBTerminalStore/recordTerminalMigration.tree +0 -5
  200. package/test/trees/JBTerminalStore/recordUsedAllowanceOf.tree +0 -10
  201. package/test/trees/JBTokens/burnFrom.tree +0 -10
  202. package/test/trees/JBTokens/claimTokensFor.tree +0 -10
  203. package/test/trees/JBTokens/deployERC20For.tree +0 -12
  204. package/test/trees/JBTokens/mintFor.tree +0 -10
  205. package/test/trees/JBTokens/setTokenFor.tree +0 -11
  206. package/test/trees/JBTokens/totalBalanceOf.tree +0 -5
  207. package/test/trees/JBTokens/totalSupplyOf.tree +0 -5
  208. package/test/trees/JBTokens/transferCreditsFrom.tree +0 -8
  209. package/test/trees/mintTokensOf.tree +0 -12
  210. package/test/units/static/JBChainlinkV3PriceFeed/TestPriceFeed.sol +0 -223
  211. package/test/units/static/JBController/JBControllerSetup.sol +0 -50
  212. package/test/units/static/JBController/TestBurnTokensOf.sol +0 -114
  213. package/test/units/static/JBController/TestClaimTokensFor.sol +0 -63
  214. package/test/units/static/JBController/TestDeployErc20For.sol +0 -86
  215. package/test/units/static/JBController/TestLaunchProjectFor.sol +0 -302
  216. package/test/units/static/JBController/TestLaunchRulesetsFor.sol +0 -342
  217. package/test/units/static/JBController/TestMigrateController.sol +0 -157
  218. package/test/units/static/JBController/TestMintTokensOfUnits.sol +0 -111
  219. package/test/units/static/JBController/TestOmnichainRulesetOperator.sol +0 -324
  220. package/test/units/static/JBController/TestPayReservedTokenToTerminal.sol +0 -74
  221. package/test/units/static/JBController/TestPreviewMintOf.sol +0 -117
  222. package/test/units/static/JBController/TestReceiveMigrationFrom.sol +0 -99
  223. package/test/units/static/JBController/TestRulesetViews.sol +0 -225
  224. package/test/units/static/JBController/TestSendReservedTokensToSplitsOf.sol +0 -615
  225. package/test/units/static/JBController/TestSetSplitGroupsOf.sol +0 -68
  226. package/test/units/static/JBController/TestSetTokenFor.sol +0 -239
  227. package/test/units/static/JBController/TestSetUriOf.sol +0 -57
  228. package/test/units/static/JBController/TestTransferCreditsFrom.sol +0 -169
  229. package/test/units/static/JBDeadline/TestDeadlineFuzz.sol +0 -211
  230. package/test/units/static/JBDirectory/JBDirectorySetup.sol +0 -26
  231. package/test/units/static/JBDirectory/TestPrimaryTerminalOf.sol +0 -126
  232. package/test/units/static/JBDirectory/TestSetControllerOf.sol +0 -183
  233. package/test/units/static/JBDirectory/TestSetControllerOfMigrationOrder.sol +0 -104
  234. package/test/units/static/JBDirectory/TestSetPrimaryTerminalOf.sol +0 -179
  235. package/test/units/static/JBDirectory/TestSetTerminalsOf.sol +0 -137
  236. package/test/units/static/JBERC20/JBERC20Setup.sol +0 -34
  237. package/test/units/static/JBERC20/SigUtils.sol +0 -36
  238. package/test/units/static/JBERC20/TestInitialize.sol +0 -60
  239. package/test/units/static/JBERC20/TestName.sol +0 -30
  240. package/test/units/static/JBERC20/TestNonces.sol +0 -62
  241. package/test/units/static/JBERC20/TestSymbol.sol +0 -31
  242. package/test/units/static/JBFeelessAdresses/JBFeelessSetup.sol +0 -22
  243. package/test/units/static/JBFeelessAdresses/TestInterfaces.sol +0 -30
  244. package/test/units/static/JBFeelessAdresses/TestSetFeelessAddress.sol +0 -35
  245. package/test/units/static/JBFees/TestFeesFuzz.sol +0 -79
  246. package/test/units/static/JBFixedPointNumber/TestAdjustDecimals.sol +0 -16
  247. package/test/units/static/JBFixedPointNumber/TestAdjustDecimalsFuzz.sol +0 -71
  248. package/test/units/static/JBFundAccessLimits/JBFundAccessSetup.sol +0 -24
  249. package/test/units/static/JBFundAccessLimits/TestFundAccessLimitsEdge.sol +0 -163
  250. package/test/units/static/JBFundAccessLimits/TestPayoutLimitOf.sol +0 -59
  251. package/test/units/static/JBFundAccessLimits/TestPayoutLimitsOf.sol +0 -101
  252. package/test/units/static/JBFundAccessLimits/TestSetFundAccessLimitsFor.sol +0 -189
  253. package/test/units/static/JBFundAccessLimits/TestSurplusAllowanceOf.sol +0 -64
  254. package/test/units/static/JBFundAccessLimits/TestSurplusAllowancesOf.sol +0 -102
  255. package/test/units/static/JBMetadataResolver/TestGetDataFor.sol +0 -90
  256. package/test/units/static/JBMetadataResolver/TestMetadataResolverEdgeCases.sol +0 -247
  257. package/test/units/static/JBMetadataResolver/TestMetadataResolverFuzz.sol +0 -229
  258. package/test/units/static/JBMultiTerminal/JBMultiTerminalSetup.sol +0 -50
  259. package/test/units/static/JBMultiTerminal/TestAccountingContextsOf.sol +0 -72
  260. package/test/units/static/JBMultiTerminal/TestAddAccountingContextsFor.sol +0 -289
  261. package/test/units/static/JBMultiTerminal/TestAddToBalanceOf.sol +0 -474
  262. package/test/units/static/JBMultiTerminal/TestCashOutTokensOf.sol +0 -624
  263. package/test/units/static/JBMultiTerminal/TestExecutePayout.sol +0 -578
  264. package/test/units/static/JBMultiTerminal/TestExecuteProcessFee.sol +0 -202
  265. package/test/units/static/JBMultiTerminal/TestMigrateBalanceOf.sol +0 -222
  266. package/test/units/static/JBMultiTerminal/TestPay.sol +0 -604
  267. package/test/units/static/JBMultiTerminal/TestPreviewCashOutFrom.sol +0 -117
  268. package/test/units/static/JBMultiTerminal/TestPreviewPayFor.sol +0 -114
  269. package/test/units/static/JBMultiTerminal/TestProcessHeldFeesOf.sol +0 -228
  270. package/test/units/static/JBMultiTerminal/TestSelfPayRevert.sol +0 -55
  271. package/test/units/static/JBMultiTerminal/TestSendPayoutsOf.sol +0 -257
  272. package/test/units/static/JBMultiTerminal/TestUseAllowanceOf.sol +0 -611
  273. package/test/units/static/JBPermissions/JBPermissionsSetup.sol +0 -20
  274. package/test/units/static/JBPermissions/TestHasPermission.sol +0 -50
  275. package/test/units/static/JBPermissions/TestHasPermissions.sol +0 -93
  276. package/test/units/static/JBPermissions/TestSetPermissionsFor.sol +0 -64
  277. package/test/units/static/JBPrices/JBPricesSetup.sol +0 -32
  278. package/test/units/static/JBPrices/TestAddPriceFeedFor.sol +0 -107
  279. package/test/units/static/JBPrices/TestPricePerUnitOf.sol +0 -132
  280. package/test/units/static/JBPrices/TestPrices.sol +0 -265
  281. package/test/units/static/JBProjects/JBProjectsSetup.sol +0 -22
  282. package/test/units/static/JBProjects/TestCreateFor.sol +0 -71
  283. package/test/units/static/JBProjects/TestInitialProject.sol +0 -21
  284. package/test/units/static/JBProjects/TestInterfaces.sol +0 -26
  285. package/test/units/static/JBProjects/TestSetResolver.sol +0 -37
  286. package/test/units/static/JBProjects/TestTokenUri.sol +0 -40
  287. package/test/units/static/JBRulesetMetadataResolver/TestSetCashOutTaxRateTo.sol +0 -108
  288. package/test/units/static/JBRulesets/JBRulesetsSetup.sol +0 -24
  289. package/test/units/static/JBRulesets/TestCurrentApprovalStatusForLatestRulesetOf.sol +0 -265
  290. package/test/units/static/JBRulesets/TestCurrentOf.sol +0 -242
  291. package/test/units/static/JBRulesets/TestGetRulesetOf.sol +0 -100
  292. package/test/units/static/JBRulesets/TestLatestQueuedRulesetOf.sol +0 -260
  293. package/test/units/static/JBRulesets/TestRulesets.sol +0 -632
  294. package/test/units/static/JBRulesets/TestRulesetsOf.sol +0 -37
  295. package/test/units/static/JBRulesets/TestUpcomingRulesetOf.sol +0 -522
  296. package/test/units/static/JBRulesets/TestUpdateRulesetWeightCache.sol +0 -96
  297. package/test/units/static/JBSplits/JBSplitsSetup.sol +0 -26
  298. package/test/units/static/JBSplits/TestSelfManagedSplitGroups.sol +0 -552
  299. package/test/units/static/JBSplits/TestSetSplitGroupsOf.sol +0 -377
  300. package/test/units/static/JBSplits/TestSplitsLockedEdge.sol +0 -267
  301. package/test/units/static/JBSplits/TestSplitsOf.sol +0 -24
  302. package/test/units/static/JBSplits/TestSplitsPacking.sol +0 -36
  303. package/test/units/static/JBSurplus/TestSurplusFuzz.sol +0 -160
  304. package/test/units/static/JBTerminalStore/JBTerminalStoreSetup.sol +0 -45
  305. package/test/units/static/JBTerminalStore/TestCurrentReclaimableSurplusOf.sol +0 -536
  306. package/test/units/static/JBTerminalStore/TestCurrentSurplusOf.sol +0 -463
  307. package/test/units/static/JBTerminalStore/TestCurrentTotalSurplusOf.sol +0 -135
  308. package/test/units/static/JBTerminalStore/TestPreviewCashOutFrom.sol +0 -476
  309. package/test/units/static/JBTerminalStore/TestPreviewPayFrom.sol +0 -494
  310. package/test/units/static/JBTerminalStore/TestRecordCashOutsFor.sol +0 -652
  311. package/test/units/static/JBTerminalStore/TestRecordPaymentFrom.sol +0 -744
  312. package/test/units/static/JBTerminalStore/TestRecordPayoutFor.sol +0 -289
  313. package/test/units/static/JBTerminalStore/TestRecordTerminalMigration.sol +0 -138
  314. package/test/units/static/JBTerminalStore/TestRecordUsedAllowanceOf.sol +0 -415
  315. package/test/units/static/JBTerminalStore/TestUint224Overflow.sol +0 -219
  316. package/test/units/static/JBTokens/JBTokensSetup.sol +0 -32
  317. package/test/units/static/JBTokens/TestBurnFrom.sol +0 -107
  318. package/test/units/static/JBTokens/TestClaimTokensFor.sol +0 -110
  319. package/test/units/static/JBTokens/TestDeployERC20ForUnits.sol +0 -92
  320. package/test/units/static/JBTokens/TestMintFor.sol +0 -100
  321. package/test/units/static/JBTokens/TestSetTokenFor.sol +0 -98
  322. package/test/units/static/JBTokens/TestTotalBalanceOf.sol +0 -65
  323. package/test/units/static/JBTokens/TestTotalSupplyOf.sol +0 -56
  324. package/test/units/static/JBTokens/TestTransferCreditsFrom.sol +0 -56
@@ -1,302 +0,0 @@
1
- // SPDX-License-Identifier: MIT
2
- pragma solidity 0.8.28;
3
-
4
- import {JBController} from "../../../../src/JBController.sol";
5
- import {IJBController} from "../../../../src/interfaces/IJBController.sol";
6
- import {IJBDirectory} from "../../../../src/interfaces/IJBDirectory.sol";
7
- import {IJBFundAccessLimits} from "../../../../src/interfaces/IJBFundAccessLimits.sol";
8
- import {IJBProjects} from "../../../../src/interfaces/IJBProjects.sol";
9
- import {IJBRulesetApprovalHook} from "../../../../src/interfaces/IJBRulesetApprovalHook.sol";
10
- import {IJBRulesets} from "../../../../src/interfaces/IJBRulesets.sol";
11
- import {IJBSplitHook} from "../../../../src/interfaces/IJBSplitHook.sol";
12
- import {IJBSplits} from "../../../../src/interfaces/IJBSplits.sol";
13
- import {IJBTerminal} from "../../../../src/interfaces/IJBTerminal.sol";
14
- import {JBConstants} from "../../../../src/libraries/JBConstants.sol";
15
- import {JBRulesetMetadataResolver} from "../../../../src/libraries/JBRulesetMetadataResolver.sol";
16
- import {JBAccountingContext} from "../../../../src/structs/JBAccountingContext.sol";
17
- import {JBFundAccessLimitGroup} from "../../../../src/structs/JBFundAccessLimitGroup.sol";
18
- import {JBRuleset} from "../../../../src/structs/JBRuleset.sol";
19
- import {JBRulesetConfig} from "../../../../src/structs/JBRulesetConfig.sol";
20
- import {JBRulesetMetadata} from "../../../../src/structs/JBRulesetMetadata.sol";
21
- import {JBSplit} from "../../../../src/structs/JBSplit.sol";
22
- import {JBSplitGroup} from "../../../../src/structs/JBSplitGroup.sol";
23
- import {JBTerminalConfig} from "../../../../src/structs/JBTerminalConfig.sol";
24
- import {IERC165} from "@openzeppelin/contracts/utils/introspection/ERC165.sol";
25
- import {JBControllerSetup} from "./JBControllerSetup.sol";
26
-
27
- contract TestLaunchProjectFor_Local is JBControllerSetup {
28
- using JBRulesetMetadataResolver for JBRulesetMetadata;
29
-
30
- address payable _splitsBeneficiary = payable(makeAddr("someone"));
31
- string _metadata = "JUICAY_DATA";
32
- string _memo = "JUICAY_MEMO";
33
-
34
- function setUp() public {
35
- super.controllerSetup();
36
- }
37
-
38
- modifier whenCalledDefault() {
39
- // we must mock calls to Projects, Directory, Rulesets, possibly Splits, and possibly a second call to directory
40
-
41
- bytes memory projectsCall = abi.encodeCall(IJBProjects.createFor, (address(this)));
42
- bytes memory projectsReturn = abi.encode(1);
43
- mockExpect(address(projects), projectsCall, projectsReturn);
44
-
45
- bytes memory setControllerCall =
46
- abi.encodeCall(IJBDirectory.setControllerOf, (1, IERC165(address(_controller))));
47
- bytes memory setControllerReturn = "";
48
- mockExpect(address(directory), setControllerCall, setControllerReturn);
49
- _;
50
- }
51
-
52
- function test_GivenMetadataIsProvided() external whenCalledDefault {
53
- // it will set metadata
54
-
55
- JBRulesetConfig[] memory _rulesets = new JBRulesetConfig[](0);
56
- JBTerminalConfig[] memory _terminals = new JBTerminalConfig[](0);
57
-
58
- vm.expectEmit();
59
- emit IJBController.LaunchProject(0, 1, _metadata, "", address(this));
60
-
61
- _controller.launchProjectFor(address(this), _metadata, _rulesets, _terminals, "");
62
- }
63
-
64
- function test_GivenRulesetHasInvalidReservedPercent() external whenCalledDefault {
65
- // it will revert INVALID_RESERVED_PERCENT()
66
-
67
- JBRulesetMetadata memory _rulesMetadata = JBRulesetMetadata({
68
- reservedPercent: JBConstants.MAX_RESERVED_PERCENT + 1, // invalid
69
- cashOutTaxRate: JBConstants.MAX_CASH_OUT_TAX_RATE / 2, //50%
70
- baseCurrency: uint32(uint160(JBConstants.NATIVE_TOKEN)),
71
- pausePay: false,
72
- pauseCreditTransfers: false,
73
- allowOwnerMinting: false,
74
- allowSetCustomToken: false,
75
- allowTerminalMigration: false,
76
- allowSetTerminals: false,
77
- ownerMustSendPayouts: false,
78
- allowSetController: false,
79
- allowAddAccountingContext: true,
80
- allowAddPriceFeed: false,
81
- holdFees: false,
82
- useTotalSurplusForCashOuts: true,
83
- useDataHookForPay: false,
84
- useDataHookForCashOut: false,
85
- dataHook: address(0),
86
- metadata: 0
87
- });
88
-
89
- JBFundAccessLimitGroup[] memory _fundAccessLimitGroup = new JBFundAccessLimitGroup[](0);
90
- JBTerminalConfig[] memory _terminals = new JBTerminalConfig[](0);
91
-
92
- // Package up the ruleset configuration.
93
- JBRulesetConfig[] memory _rulesetConfigurations = new JBRulesetConfig[](1);
94
- _rulesetConfigurations[0].mustStartAtOrAfter = 0;
95
- _rulesetConfigurations[0].duration = 0;
96
- _rulesetConfigurations[0].weight = 1e18;
97
- _rulesetConfigurations[0].weightCutPercent = 0;
98
- _rulesetConfigurations[0].approvalHook = IJBRulesetApprovalHook(address(0));
99
- _rulesetConfigurations[0].metadata = _rulesMetadata;
100
- _rulesetConfigurations[0].splitGroups = new JBSplitGroup[](0);
101
- _rulesetConfigurations[0].fundAccessLimitGroups = _fundAccessLimitGroup;
102
-
103
- vm.expectRevert(
104
- abi.encodeWithSelector(
105
- JBController.JBController_InvalidReservedPercent.selector,
106
- JBConstants.MAX_RESERVED_PERCENT + 1,
107
- JBConstants.MAX_RESERVED_PERCENT
108
- )
109
- );
110
- _controller.launchProjectFor(address(this), _metadata, _rulesetConfigurations, _terminals, _memo);
111
- }
112
-
113
- function test_GivenRulesetHasInvalidCashOutTaxRate() external whenCalledDefault {
114
- // it will revert INVALID_CASH_OUT_RATE()
115
-
116
- JBRulesetMetadata memory _rulesMetadata = JBRulesetMetadata({
117
- reservedPercent: JBConstants.MAX_RESERVED_PERCENT / 2,
118
- cashOutTaxRate: JBConstants.MAX_CASH_OUT_TAX_RATE + 1, // invalid
119
- baseCurrency: uint32(uint160(JBConstants.NATIVE_TOKEN)),
120
- pausePay: false,
121
- pauseCreditTransfers: false,
122
- allowOwnerMinting: false,
123
- allowSetCustomToken: false,
124
- allowTerminalMigration: false,
125
- allowSetTerminals: false,
126
- ownerMustSendPayouts: false,
127
- allowSetController: false,
128
- allowAddAccountingContext: true,
129
- allowAddPriceFeed: false,
130
- holdFees: false,
131
- useTotalSurplusForCashOuts: true,
132
- useDataHookForPay: false,
133
- useDataHookForCashOut: false,
134
- dataHook: address(0),
135
- metadata: 0
136
- });
137
-
138
- JBFundAccessLimitGroup[] memory _fundAccessLimitGroup = new JBFundAccessLimitGroup[](0);
139
- JBTerminalConfig[] memory _terminals = new JBTerminalConfig[](0);
140
-
141
- // Package up the ruleset configuration.
142
- JBRulesetConfig[] memory _rulesetConfigurations = new JBRulesetConfig[](1);
143
- _rulesetConfigurations[0].mustStartAtOrAfter = 0;
144
- _rulesetConfigurations[0].duration = 0;
145
- _rulesetConfigurations[0].weight = 1e18;
146
- _rulesetConfigurations[0].weightCutPercent = 0;
147
- _rulesetConfigurations[0].approvalHook = IJBRulesetApprovalHook(address(0));
148
- _rulesetConfigurations[0].metadata = _rulesMetadata;
149
- _rulesetConfigurations[0].splitGroups = new JBSplitGroup[](0);
150
- _rulesetConfigurations[0].fundAccessLimitGroups = _fundAccessLimitGroup;
151
-
152
- vm.expectRevert(
153
- abi.encodeWithSelector(
154
- JBController.JBController_InvalidCashOutTaxRate.selector,
155
- JBConstants.MAX_CASH_OUT_TAX_RATE + 1,
156
- JBConstants.MAX_CASH_OUT_TAX_RATE
157
- )
158
- );
159
- _controller.launchProjectFor(address(this), _metadata, _rulesetConfigurations, _terminals, _memo);
160
- }
161
-
162
- function test_GivenSplitsRulesetsAndFundAccessConstraintsAreConfigured() external whenCalledDefault {
163
- // it will set split groups, ruleset, fundAccessConstraints
164
-
165
- JBRulesetMetadata memory _rulesMetadata = JBRulesetMetadata({
166
- reservedPercent: JBConstants.MAX_RESERVED_PERCENT / 2,
167
- cashOutTaxRate: JBConstants.MAX_CASH_OUT_TAX_RATE / 2,
168
- baseCurrency: uint32(uint160(JBConstants.NATIVE_TOKEN)),
169
- pausePay: false,
170
- pauseCreditTransfers: false,
171
- allowOwnerMinting: false,
172
- allowSetCustomToken: false,
173
- allowTerminalMigration: false,
174
- allowSetTerminals: false,
175
- ownerMustSendPayouts: false,
176
- allowSetController: false,
177
- allowAddAccountingContext: true,
178
- allowAddPriceFeed: false,
179
- holdFees: false,
180
- useTotalSurplusForCashOuts: true,
181
- useDataHookForPay: false,
182
- useDataHookForCashOut: false,
183
- dataHook: address(0),
184
- metadata: 0
185
- });
186
-
187
- uint256 _packed = _rulesMetadata.packRulesetMetadata();
188
-
189
- JBFundAccessLimitGroup[] memory _fundAccessLimitGroup = new JBFundAccessLimitGroup[](0);
190
- JBTerminalConfig[] memory _terminals = new JBTerminalConfig[](0);
191
-
192
- // splits
193
- JBSplitGroup[] memory _splitsGroup = new JBSplitGroup[](1);
194
- JBSplit[] memory _splits = new JBSplit[](1);
195
-
196
- _splits[0] = JBSplit({
197
- preferAddToBalance: false,
198
- percent: JBConstants.SPLITS_TOTAL_PERCENT,
199
- projectId: 1,
200
- beneficiary: _splitsBeneficiary,
201
- lockedUntil: 0,
202
- hook: IJBSplitHook(address(0))
203
- });
204
-
205
- _splitsGroup[0] = JBSplitGroup({groupId: uint32(uint160(JBConstants.NATIVE_TOKEN)), splits: _splits});
206
-
207
- // Package up the ruleset configuration.
208
- JBRulesetConfig[] memory _rulesetConfigurations = new JBRulesetConfig[](1);
209
- _rulesetConfigurations[0].mustStartAtOrAfter = 0;
210
- _rulesetConfigurations[0].duration = 0;
211
- _rulesetConfigurations[0].weight = 1e18;
212
- _rulesetConfigurations[0].weightCutPercent = 0;
213
- _rulesetConfigurations[0].approvalHook = IJBRulesetApprovalHook(address(0));
214
- _rulesetConfigurations[0].metadata = _rulesMetadata;
215
- _rulesetConfigurations[0].splitGroups = _splitsGroup;
216
- _rulesetConfigurations[0].fundAccessLimitGroups = _fundAccessLimitGroup;
217
-
218
- // JBRulesets calldata
219
- JBRuleset memory returnedRuleset = JBRuleset({
220
- cycleNumber: uint48(block.timestamp),
221
- id: uint48(block.timestamp),
222
- basedOnId: 0,
223
- start: uint48(block.timestamp),
224
- duration: _rulesetConfigurations[0].duration,
225
- weight: _rulesetConfigurations[0].weight,
226
- weightCutPercent: _rulesetConfigurations[0].weightCutPercent,
227
- approvalHook: _rulesetConfigurations[0].approvalHook,
228
- metadata: _packed
229
- });
230
- bytes memory rulesetsCall = abi.encodeCall(
231
- IJBRulesets.queueFor,
232
- (
233
- 1,
234
- _rulesetConfigurations[0].duration,
235
- _rulesetConfigurations[0].weight,
236
- _rulesetConfigurations[0].weightCutPercent,
237
- _rulesetConfigurations[0].approvalHook,
238
- _packed,
239
- _rulesetConfigurations[0].mustStartAtOrAfter
240
- )
241
- );
242
- bytes memory rulesetsReturned = abi.encode(returnedRuleset);
243
-
244
- // JBRulesets call
245
- mockExpect(address(rulesets), rulesetsCall, rulesetsReturned);
246
-
247
- // JBSplits call
248
- bytes memory splitsCall = abi.encodeCall(IJBSplits.setSplitGroupsOf, (1, block.timestamp, _splitsGroup));
249
- bytes memory splitsReturned = "";
250
- mockExpect(address(splits), splitsCall, splitsReturned);
251
-
252
- // JBFundAccess call
253
- bytes memory fundsCall =
254
- abi.encodeCall(IJBFundAccessLimits.setFundAccessLimitsFor, (1, block.timestamp, _fundAccessLimitGroup));
255
- bytes memory fundsReturned = "";
256
- mockExpect(address(fundAccessLimits), fundsCall, fundsReturned);
257
-
258
- _controller.launchProjectFor(address(this), _metadata, _rulesetConfigurations, _terminals, _memo);
259
- }
260
-
261
- function test_GivenTerminalsAreProvided() external whenCalledDefault {
262
- // it will set terminals
263
- IJBTerminal _terminal = IJBTerminal(makeAddr("terminal"));
264
- address _token = makeAddr("token");
265
-
266
- JBRulesetConfig[] memory _rulesets = new JBRulesetConfig[](0);
267
- JBTerminalConfig[] memory _terminals = new JBTerminalConfig[](1);
268
- JBAccountingContext[] memory _tokensToAccept = new JBAccountingContext[](1);
269
- _tokensToAccept[0] = JBAccountingContext({
270
- token: JBConstants.NATIVE_TOKEN, decimals: 18, currency: uint32(uint160(JBConstants.NATIVE_TOKEN))
271
- });
272
-
273
- _terminals[0] = JBTerminalConfig({terminal: _terminal, accountingContextsToAccept: _tokensToAccept});
274
-
275
- // mock call return data
276
- JBAccountingContext memory _returnedContext =
277
- JBAccountingContext({token: _token, decimals: 18, currency: uint32(uint160(JBConstants.NATIVE_TOKEN))});
278
-
279
- // mock call to the terminal addAccountingContextsFor()
280
- bytes memory addCall = abi.encodeCall(IJBTerminal.addAccountingContextsFor, (1, _tokensToAccept));
281
- bytes memory addReturned = abi.encode(_returnedContext);
282
-
283
- mockExpect(address(_terminal), addCall, addReturned);
284
-
285
- vm.expectEmit();
286
- emit IJBController.LaunchProject(0, 1, _metadata, _memo, address(this));
287
-
288
- _controller.launchProjectFor(address(this), _metadata, _rulesets, _terminals, _memo);
289
- }
290
-
291
- function test_GivenMemoIsProvided() external whenCalledDefault {
292
- // it will be included in the emit
293
-
294
- JBRulesetConfig[] memory _rulesets = new JBRulesetConfig[](0);
295
- JBTerminalConfig[] memory _terminals = new JBTerminalConfig[](0);
296
-
297
- vm.expectEmit();
298
- emit IJBController.LaunchProject(0, 1, _metadata, _memo, address(this));
299
-
300
- _controller.launchProjectFor(address(this), _metadata, _rulesets, _terminals, _memo);
301
- }
302
- }
@@ -1,342 +0,0 @@
1
- // SPDX-License-Identifier: MIT
2
- pragma solidity 0.8.28;
3
-
4
- import {JBController} from "../../../../src/JBController.sol";
5
- import {JBPermissioned} from "../../../../src/abstract/JBPermissioned.sol";
6
- import {IJBController} from "../../../../src/interfaces/IJBController.sol";
7
- import {IJBDirectory} from "../../../../src/interfaces/IJBDirectory.sol";
8
- import {IJBFundAccessLimits} from "../../../../src/interfaces/IJBFundAccessLimits.sol";
9
- import {IJBPermissions} from "../../../../src/interfaces/IJBPermissions.sol";
10
- import {IJBRulesetApprovalHook} from "../../../../src/interfaces/IJBRulesetApprovalHook.sol";
11
- import {IJBRulesets} from "../../../../src/interfaces/IJBRulesets.sol";
12
- import {IJBSplits} from "../../../../src/interfaces/IJBSplits.sol";
13
- import {JBConstants} from "../../../../src/libraries/JBConstants.sol";
14
- import {JBRulesetMetadataResolver} from "../../../../src/libraries/JBRulesetMetadataResolver.sol";
15
- import {JBCurrencyAmount} from "../../../../src/structs/JBCurrencyAmount.sol";
16
- import {JBFundAccessLimitGroup} from "../../../../src/structs/JBFundAccessLimitGroup.sol";
17
- import {JBRuleset} from "../../../../src/structs/JBRuleset.sol";
18
- import {JBRulesetConfig} from "../../../../src/structs/JBRulesetConfig.sol";
19
- import {JBRulesetMetadata} from "../../../../src/structs/JBRulesetMetadata.sol";
20
- import {JBSplitGroup} from "../../../../src/structs/JBSplitGroup.sol";
21
- import {JBTerminalConfig} from "../../../../src/structs/JBTerminalConfig.sol";
22
- import {JBPermissionIds} from "@bananapus/permission-ids-v6/src/JBPermissionIds.sol";
23
- import {IERC721} from "@openzeppelin/contracts/token/ERC721/IERC721.sol";
24
- import {IERC165} from "@openzeppelin/contracts/utils/introspection/ERC165.sol";
25
- import {JBControllerSetup} from "./JBControllerSetup.sol";
26
-
27
- contract TestLaunchRulesetsFor_Local is JBControllerSetup {
28
- function setUp() public {
29
- super.controllerSetup();
30
- }
31
-
32
- modifier whenCallerHasPermission() {
33
- // mock ownerOf call
34
- bytes memory _ownerOfCall = abi.encodeCall(IERC721.ownerOf, (1));
35
- bytes memory _ownerData = abi.encode(address(this));
36
-
37
- mockExpect(address(projects), _ownerOfCall, _ownerData);
38
- _;
39
- }
40
-
41
- modifier whenCallerWithoutPermission() {
42
- // mock ownerOf call
43
- bytes memory _ownerOfCall = abi.encodeCall(IERC721.ownerOf, (1));
44
- bytes memory _ownerData = abi.encode(address(1));
45
-
46
- mockExpect(address(projects), _ownerOfCall, _ownerData);
47
-
48
- // mock permission call
49
- bytes memory _call = abi.encodeCall(
50
- IJBPermissions.hasPermission, (address(this), address(1), 1, JBPermissionIds.LAUNCH_RULESETS, true, true)
51
- );
52
- mockExpect(address(permissions), _call, abi.encode(false));
53
- _;
54
- }
55
-
56
- function genRuleset()
57
- public
58
- pure
59
- returns (JBTerminalConfig[] memory _terminalConfig, JBRulesetConfig[] memory _rulesetConfig)
60
- {
61
- // it should set the controller, queue the rulesets, configure terminals, and emit LaunchRulesets
62
- JBTerminalConfig[] memory _terminalConfigs = new JBTerminalConfig[](0);
63
- JBRulesetConfig[] memory _rulesetConfigs = new JBRulesetConfig[](1);
64
-
65
- JBRulesetMetadata memory _metadata = JBRulesetMetadata({
66
- reservedPercent: JBConstants.MAX_RESERVED_PERCENT / 2, //50%
67
- cashOutTaxRate: JBConstants.MAX_CASH_OUT_TAX_RATE / 2, //50%
68
- baseCurrency: uint32(uint160(JBConstants.NATIVE_TOKEN)),
69
- pausePay: false,
70
- pauseCreditTransfers: false,
71
- allowOwnerMinting: false,
72
- allowSetCustomToken: false,
73
- allowTerminalMigration: false,
74
- allowSetTerminals: false,
75
- ownerMustSendPayouts: false,
76
- allowSetController: false,
77
- allowAddAccountingContext: true,
78
- allowAddPriceFeed: false,
79
- holdFees: false,
80
- useTotalSurplusForCashOuts: true,
81
- useDataHookForPay: false,
82
- useDataHookForCashOut: false,
83
- dataHook: address(0),
84
- metadata: 0
85
- });
86
-
87
- // Package up the limits for the given terminal.
88
- JBFundAccessLimitGroup[] memory _fundAccessLimitGroup = new JBFundAccessLimitGroup[](1);
89
-
90
- // Specify a payout limit.
91
- JBCurrencyAmount[] memory _payoutLimits = new JBCurrencyAmount[](1);
92
- _payoutLimits[0] = JBCurrencyAmount({amount: 0, currency: uint32(uint160(JBConstants.NATIVE_TOKEN))});
93
-
94
- // Specify a surplus allowance.
95
- JBCurrencyAmount[] memory _surplusAllowances = new JBCurrencyAmount[](1);
96
- _surplusAllowances[0] = JBCurrencyAmount({amount: 0, currency: uint32(uint160(JBConstants.NATIVE_TOKEN))});
97
-
98
- _fundAccessLimitGroup[0] = JBFundAccessLimitGroup({
99
- terminal: address(0),
100
- token: JBConstants.NATIVE_TOKEN,
101
- payoutLimits: _payoutLimits,
102
- surplusAllowances: _surplusAllowances
103
- });
104
-
105
- // Package up the ruleset configuration.
106
- _rulesetConfigs[0].mustStartAtOrAfter = 0;
107
- _rulesetConfigs[0].duration = 0;
108
- _rulesetConfigs[0].weight = 0;
109
- _rulesetConfigs[0].weightCutPercent = 0;
110
- _rulesetConfigs[0].approvalHook = IJBRulesetApprovalHook(address(0));
111
- _rulesetConfigs[0].metadata = _metadata;
112
- _rulesetConfigs[0].splitGroups = new JBSplitGroup[](0);
113
- _rulesetConfigs[0].fundAccessLimitGroups = _fundAccessLimitGroup;
114
-
115
- return (_terminalConfigs, _rulesetConfigs);
116
- }
117
-
118
- function test_RevertWhen_RulesetLengthIsZero() external {
119
- // it should revert
120
- JBTerminalConfig[] memory _terminalConfigs = new JBTerminalConfig[](0);
121
- JBRulesetConfig[] memory _rulesetConfigs = new JBRulesetConfig[](0);
122
-
123
- vm.expectRevert(JBController.JBController_RulesetsArrayEmpty.selector);
124
-
125
- _controller.launchRulesetsFor(1, _rulesetConfigs, _terminalConfigs, "");
126
- }
127
-
128
- function test_RevertWhen_CallerDoesNotHavePermission() external whenCallerWithoutPermission {
129
- // it should revert
130
- JBTerminalConfig[] memory _terminalConfigs = new JBTerminalConfig[](0);
131
- JBRulesetConfig[] memory _rulesetConfigs = new JBRulesetConfig[](1);
132
-
133
- vm.expectRevert(
134
- abi.encodeWithSelector(
135
- JBPermissioned.JBPermissioned_Unauthorized.selector,
136
- address(1),
137
- address(this),
138
- 1,
139
- JBPermissionIds.LAUNCH_RULESETS
140
- )
141
- );
142
-
143
- _controller.launchRulesetsFor(1, _rulesetConfigs, _terminalConfigs, "");
144
- }
145
-
146
- function test_Revert_GivenTheProjectAlreadyHasRulesets() external whenCallerHasPermission {
147
- // it should revert
148
- JBTerminalConfig[] memory _terminalConfigs = new JBTerminalConfig[](0);
149
- JBRulesetConfig[] memory _rulesetConfigs = new JBRulesetConfig[](1);
150
-
151
- bytes memory _latestRulesetIdOfCall = abi.encodeCall(IJBRulesets.latestRulesetIdOf, (1));
152
- bytes memory _returnData = abi.encode(1);
153
-
154
- mockExpect(address(rulesets), _latestRulesetIdOfCall, _returnData);
155
-
156
- vm.expectRevert(abi.encodeWithSelector(JBController.JBController_RulesetsAlreadyLaunched.selector, 1));
157
-
158
- _controller.launchRulesetsFor(1, _rulesetConfigs, _terminalConfigs, "");
159
- }
160
-
161
- function test_GivenTheProjectDoesNotYetHaveRulesets() external whenCallerHasPermission {
162
- // setup: needed for the call chain
163
- JBTerminalConfig[] memory _terminalConfigs;
164
- JBRulesetConfig[] memory _rulesetConfigs;
165
- uint48 _ts = uint48(block.timestamp);
166
- uint256 _projectId = 1;
167
- (_terminalConfigs, _rulesetConfigs) = genRuleset();
168
-
169
- // inlined to avoid stack2deep
170
- mockExpect(address(rulesets), abi.encodeCall(IJBRulesets.latestRulesetIdOf, (_projectId)), abi.encode(0));
171
- mockExpect(
172
- address(directory),
173
- abi.encodeCall(IJBDirectory.setControllerOf, (_projectId, IERC165(address(_controller)))),
174
- ""
175
- );
176
-
177
- // mock call to rulesets queueFor
178
- // setup: return data
179
- JBRuleset memory data = JBRuleset({
180
- cycleNumber: 1,
181
- id: _ts,
182
- basedOnId: 0,
183
- start: _ts,
184
- duration: 0,
185
- weight: 0,
186
- weightCutPercent: 0,
187
- approvalHook: IJBRulesetApprovalHook(address(0)),
188
- metadata: 0
189
- });
190
-
191
- // Mock call to rulesets queueFor
192
- bytes memory _queueForCall = abi.encodeCall(
193
- IJBRulesets.queueFor,
194
- (
195
- _projectId,
196
- 0,
197
- 0,
198
- 0,
199
- _rulesetConfigs[0].approvalHook,
200
- JBRulesetMetadataResolver.packRulesetMetadata(_rulesetConfigs[0].metadata),
201
- 0
202
- )
203
- );
204
- bytes memory _queueReturn = abi.encode(data);
205
- mockExpect(address(rulesets), _queueForCall, _queueReturn);
206
-
207
- // Mock call to splits setSplitGroupsOf
208
- bytes memory _setSplitsCall =
209
- abi.encodeCall(IJBSplits.setSplitGroupsOf, (_projectId, _ts, _rulesetConfigs[0].splitGroups));
210
- bytes memory _splitsReturn = "";
211
- mockExpect(address(splits), _setSplitsCall, _splitsReturn);
212
-
213
- // Mock call to fundaccesslimits setFundAccessLimitsFor
214
- bytes memory _fundAccessCall = abi.encodeCall(
215
- IJBFundAccessLimits.setFundAccessLimitsFor, (_projectId, _ts, _rulesetConfigs[0].fundAccessLimitGroups)
216
- );
217
- bytes memory _accessReturn = "";
218
- mockExpect(address(fundAccessLimits), _fundAccessCall, _accessReturn);
219
-
220
- // event as expected
221
- /* vm.expectEmit();
222
- emit IJBController.LaunchRulesets(_ts, 1, "", address(this)); */
223
-
224
- _controller.launchRulesetsFor(_projectId, _rulesetConfigs, _terminalConfigs, "");
225
- }
226
-
227
- function test_GivenCallerOnlyHasLaunchPermission() external {
228
- // it should revert
229
-
230
- // mock ownerOf call
231
- bytes memory _ownerOfCall = abi.encodeCall(IERC721.ownerOf, (1));
232
- address _ownerData = address(1);
233
-
234
- mockExpect(address(projects), _ownerOfCall, abi.encode(_ownerData));
235
-
236
- // mock permission call - caller has LAUNCH_RULESETS
237
- bytes memory _call = abi.encodeCall(
238
- IJBPermissions.hasPermission, (address(this), address(1), 1, JBPermissionIds.LAUNCH_RULESETS, true, true)
239
- );
240
- mockExpect(address(permissions), _call, abi.encode(true));
241
-
242
- // SET_TERMINALS - caller does NOT have this
243
- bytes memory _call3 = abi.encodeCall(
244
- IJBPermissions.hasPermission, (address(this), address(1), 1, JBPermissionIds.SET_TERMINALS, true, true)
245
- );
246
- mockExpect(address(permissions), _call3, abi.encode(false));
247
-
248
- // it should revert
249
- JBTerminalConfig[] memory _terminalConfigs = new JBTerminalConfig[](0);
250
- JBRulesetConfig[] memory _rulesetConfigs = new JBRulesetConfig[](1);
251
-
252
- vm.expectRevert(
253
- abi.encodeWithSelector(
254
- JBPermissioned.JBPermissioned_Unauthorized.selector,
255
- _ownerData,
256
- address(this),
257
- 1,
258
- JBPermissionIds.SET_TERMINALS
259
- )
260
- );
261
-
262
- _controller.launchRulesetsFor(1, _rulesetConfigs, _terminalConfigs, "");
263
- }
264
-
265
- function test_GivenNonOwnerHasBothPermissions() external {
266
- // it will launch rulesets
267
-
268
- // mock ownerOf call
269
- bytes memory _ownerOfCall = abi.encodeCall(IERC721.ownerOf, (1));
270
- bytes memory _ownerData = abi.encode(address(1));
271
-
272
- mockExpect(address(projects), _ownerOfCall, _ownerData);
273
-
274
- // mock permission call - caller has LAUNCH_RULESETS
275
- bytes memory _call = abi.encodeCall(
276
- IJBPermissions.hasPermission, (address(this), address(1), 1, JBPermissionIds.LAUNCH_RULESETS, true, true)
277
- );
278
- mockExpect(address(permissions), _call, abi.encode(true));
279
-
280
- // SET_TERMINALS
281
- bytes memory _call3 = abi.encodeCall(
282
- IJBPermissions.hasPermission, (address(this), address(1), 1, JBPermissionIds.SET_TERMINALS, true, true)
283
- );
284
- mockExpect(address(permissions), _call3, abi.encode(true));
285
-
286
- // setup: needed for the call chain
287
- JBTerminalConfig[] memory _terminalConfigs;
288
- JBRulesetConfig[] memory _rulesetConfigs;
289
- uint48 _ts = uint48(block.timestamp);
290
- uint256 _projectId = 1;
291
- (_terminalConfigs, _rulesetConfigs) = genRuleset();
292
-
293
- // inlined to avoid stack2deep
294
- mockExpect(address(rulesets), abi.encodeCall(IJBRulesets.latestRulesetIdOf, (_projectId)), abi.encode(0));
295
- mockExpect(
296
- address(directory),
297
- abi.encodeCall(IJBDirectory.setControllerOf, (_projectId, IERC165(address(_controller)))),
298
- ""
299
- );
300
-
301
- // mock call to rulesets queueFor
302
- // setup: return data
303
- JBRuleset memory data = JBRuleset({
304
- cycleNumber: 1,
305
- id: _ts,
306
- basedOnId: 0,
307
- start: _ts,
308
- duration: 0,
309
- weight: 0,
310
- weightCutPercent: 0,
311
- approvalHook: IJBRulesetApprovalHook(address(0)),
312
- metadata: 0
313
- });
314
-
315
- // Mock call to rulesets queueFor
316
- bytes memory _queueForCall = abi.encodeCall(
317
- IJBRulesets.queueFor,
318
- (_projectId, 0, 0, 0, _rulesetConfigs[0].approvalHook, 642_241_845_873_572_506_056_833, 0)
319
- );
320
- bytes memory _queueReturn = abi.encode(data);
321
- mockExpect(address(rulesets), _queueForCall, _queueReturn);
322
-
323
- // Mock call to splits setSplitGroupsOf
324
- bytes memory _setSplitsCall =
325
- abi.encodeCall(IJBSplits.setSplitGroupsOf, (_projectId, _ts, _rulesetConfigs[0].splitGroups));
326
- bytes memory _splitsReturn = "";
327
- mockExpect(address(splits), _setSplitsCall, _splitsReturn);
328
-
329
- // Mock call to fundaccesslimits setFundAccessLimitsFor
330
- bytes memory _fundAccessCall = abi.encodeCall(
331
- IJBFundAccessLimits.setFundAccessLimitsFor, (_projectId, _ts, _rulesetConfigs[0].fundAccessLimitGroups)
332
- );
333
- bytes memory _accessReturn = "";
334
- mockExpect(address(fundAccessLimits), _fundAccessCall, _accessReturn);
335
-
336
- // event as expected
337
- vm.expectEmit();
338
- emit IJBController.LaunchRulesets(_ts, 1, "", address(this));
339
-
340
- _controller.launchRulesetsFor(1, _rulesetConfigs, _terminalConfigs, "");
341
- }
342
- }