@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.
- package/foundry.lock +1 -7
- package/foundry.toml +1 -1
- package/package.json +19 -7
- package/src/JBController.sol +19 -1
- package/src/JBMultiTerminal.sol +68 -34
- package/src/JBTerminalStore.sol +6 -6
- package/src/interfaces/IJBController.sol +4 -1
- package/src/libraries/JBFees.sol +47 -9
- package/src/libraries/JBPayoutSplitGroupLib.sol +2 -2
- package/src/periphery/JBMatchingPriceFeed.sol +1 -1
- package/test/mock/MockMaliciousBeneficiary.sol +15 -15
- package/ADMINISTRATION.md +0 -103
- package/ARCHITECTURE.md +0 -133
- package/AUDIT_INSTRUCTIONS.md +0 -139
- package/RISKS.md +0 -215
- package/SKILLS.md +0 -55
- package/STYLE_GUIDE.md +0 -610
- package/USER_JOURNEYS.md +0 -215
- package/script/Deploy.s.sol +0 -124
- package/script/DeployPeriphery.s.sol +0 -354
- package/slither-ci.config.json +0 -10
- package/test/AuditFixes.t.sol +0 -808
- package/test/ComprehensiveInvariant.t.sol +0 -306
- package/test/CoreExploitTests.t.sol +0 -2741
- package/test/EconomicSimulation.t.sol +0 -348
- package/test/EntryPointPermutations.t.sol +0 -684
- package/test/FlashLoanAttacks.t.sol +0 -797
- package/test/PermissionEscalation.t.sol +0 -711
- package/test/PermissionsInvariant.t.sol +0 -403
- package/test/RulesetTransitions.t.sol +0 -713
- package/test/SplitLoopTests.t.sol +0 -752
- package/test/TestAccessToFunds.sol +0 -2683
- package/test/TestAuditResponseDesignProofs.sol +0 -434
- package/test/TestCashOut.sol +0 -198
- package/test/TestCashOutCountFor.sol +0 -271
- package/test/TestCashOutHooks.sol +0 -351
- package/test/TestCashOutTimingEdge.sol +0 -241
- package/test/TestDataHookFuzzing.sol +0 -524
- package/test/TestDurationUnderflow.sol +0 -233
- package/test/TestFeeFreeCashOutBypass.sol +0 -949
- package/test/TestFeeProcessingFailure.sol +0 -218
- package/test/TestFees.sol +0 -619
- package/test/TestForwardedTokenConsumption.sol +0 -425
- package/test/TestInterfaceSupport.sol +0 -81
- package/test/TestJBERC20Inheritance.sol +0 -103
- package/test/TestL2SequencerPriceFeed.sol +0 -292
- package/test/TestLaunchProject.sol +0 -188
- package/test/TestMetaTx.sol +0 -217
- package/test/TestMetadataOffsetOverflow.sol +0 -179
- package/test/TestMetadataParserLib.sol +0 -471
- package/test/TestMigrationHeldFees.sol +0 -255
- package/test/TestMintTokensOf.sol +0 -185
- package/test/TestMultiTerminalSurplus.sol +0 -348
- package/test/TestMultiTokenSurplus.sol +0 -202
- package/test/TestMultipleAccessLimits.sol +0 -664
- package/test/TestPayBurnRedeemFlow.sol +0 -195
- package/test/TestPayHooks.sol +0 -209
- package/test/TestPermissions.sol +0 -324
- package/test/TestPermissionsEdge.sol +0 -290
- package/test/TestPermit2DataHook.t.sol +0 -360
- package/test/TestPermit2Terminal.sol +0 -372
- package/test/TestRulesetQueueing.sol +0 -1025
- package/test/TestRulesetQueuingStress.sol +0 -806
- package/test/TestRulesetWeightCaching.sol +0 -178
- package/test/TestSplits.sol +0 -391
- package/test/TestTerminalMigration.sol +0 -274
- package/test/TestTerminalPreviewParity.sol +0 -208
- package/test/TestTokenFlow.sol +0 -191
- package/test/TestWeightCacheStaleAfterRejection.sol +0 -303
- package/test/WeirdTokenTests.t.sol +0 -817
- package/test/audit/CashOutReenterPay.t.sol +0 -501
- package/test/audit/CodexHeldFeeRounding.t.sol +0 -159
- package/test/audit/CodexMigrationFeeFailure.t.sol +0 -163
- package/test/audit/CrossTerminalSurplusSpoof.t.sol +0 -140
- package/test/audit/CycledSurplusAllowanceReset.t.sol +0 -184
- package/test/audit/FeeFreeSurplusLifecycle.t.sol +0 -399
- package/test/audit/FeeFreeSurplusStale.t.sol +0 -248
- package/test/audit/USDTVoidReturnCompat.t.sol +0 -525
- package/test/fork/TestChainlinkPriceFeedFork.sol +0 -254
- package/test/fork/TestSequencerPriceFeedFork.sol +0 -168
- package/test/fork/TestTerminalPreviewParityFork.sol +0 -108
- package/test/formal/BondingCurveProperties.t.sol +0 -420
- package/test/formal/FeeProperties.t.sol +0 -252
- package/test/invariants/Phase3DeepInvariant.t.sol +0 -412
- package/test/invariants/RulesetsInvariant.t.sol +0 -125
- package/test/invariants/TerminalStoreInvariant.t.sol +0 -227
- package/test/invariants/TokensInvariant.t.sol +0 -195
- package/test/invariants/handlers/ComprehensiveHandler.sol +0 -303
- package/test/invariants/handlers/EconomicHandler.sol +0 -377
- package/test/invariants/handlers/Phase3Handler.sol +0 -443
- package/test/invariants/handlers/RulesetsHandler.sol +0 -115
- package/test/invariants/handlers/TerminalStoreHandler.sol +0 -151
- package/test/invariants/handlers/TokensHandler.sol +0 -126
- package/test/regression/HoldFeesCashOutReserved.t.sol +0 -415
- package/test/regression/WeightCacheBoundary.t.sol +0 -291
- package/test/trees/JBController/burnTokensOf.tree +0 -9
- package/test/trees/JBController/claimTokensFor.tree +0 -5
- package/test/trees/JBController/deployERC20For.tree +0 -5
- package/test/trees/JBController/getRulesetOf.tree +0 -5
- package/test/trees/JBController/launchProjectFor.tree +0 -12
- package/test/trees/JBController/launchRulesetsFor.tree +0 -8
- package/test/trees/JBController/migrateController.tree +0 -12
- package/test/trees/JBController/mintTokensOf.tree +0 -12
- package/test/trees/JBController/payReservedTokenToTerminal.tree +0 -8
- package/test/trees/JBController/receiveMigrationFrom.tree +0 -4
- package/test/trees/JBController/sendReservedTokensToSplitsOf.tree +0 -12
- package/test/trees/JBController/setMetadataOf.tree +0 -5
- package/test/trees/JBController/setSplitGroupsOf.tree +0 -5
- package/test/trees/JBController/setTokenFor.tree +0 -5
- package/test/trees/JBController/transferCreditsFrom.tree +0 -8
- package/test/trees/JBDirectory/primaryTerminalOf.tree +0 -8
- package/test/trees/JBDirectory/setControllerOf.tree +0 -11
- package/test/trees/JBDirectory/setPrimaryTerminalOf.tree +0 -15
- package/test/trees/JBDirectory/setTerminalsOf.tree +0 -11
- package/test/trees/JBERC20/initialize.tree +0 -7
- package/test/trees/JBERC20/name.tree +0 -5
- package/test/trees/JBERC20/nonces.tree +0 -5
- package/test/trees/JBERC20/symbol.tree +0 -5
- package/test/trees/JBFeelessAddresses/setFeelessAddress.tree +0 -5
- package/test/trees/JBFeelessAddresses/supportsInterface.tree +0 -5
- package/test/trees/JBFundAccessLimits/payoutLimitOf.tree +0 -5
- package/test/trees/JBFundAccessLimits/payoutLimitsOf.tree +0 -8
- package/test/trees/JBFundAccessLimits/setFundAccessLimitsFor.tree +0 -18
- package/test/trees/JBFundAccessLimits/surplusAllowanceOf.tree +0 -5
- package/test/trees/JBFundAccessLimits/surplusAllowancesOf.tree +0 -8
- package/test/trees/JBMetadataResolver/getDataFor.tree +0 -8
- package/test/trees/JBMultiTerminal/accountingContextsOf.tree +0 -5
- package/test/trees/JBMultiTerminal/addAccountingContextsFor.tree +0 -10
- package/test/trees/JBMultiTerminal/addToBalanceOf.tree +0 -23
- package/test/trees/JBMultiTerminal/cashOutTokensOf.tree +0 -23
- package/test/trees/JBMultiTerminal/executePayout.tree +0 -32
- package/test/trees/JBMultiTerminal/executeProcessFee.tree +0 -14
- package/test/trees/JBMultiTerminal/migrateBalanceOf.tree +0 -12
- package/test/trees/JBMultiTerminal/pay.tree +0 -23
- package/test/trees/JBMultiTerminal/processHeldFeesOf.tree +0 -8
- package/test/trees/JBMultiTerminal/sendPayoutsOf.tree +0 -34
- package/test/trees/JBMultiTerminal/useAllowanceOf.tree +0 -16
- package/test/trees/JBPermissions/hasPermission.tree +0 -8
- package/test/trees/JBPermissions/hasPermissions.tree +0 -8
- package/test/trees/JBPermissions/setPermissionsFor.tree +0 -5
- package/test/trees/JBPrices/addPriceFeedFor.tree +0 -14
- package/test/trees/JBPrices/pricePerUnitOf.tree +0 -11
- package/test/trees/JBProjects/createFor.tree +0 -11
- package/test/trees/JBProjects/setTokenUriResolver.tree +0 -5
- package/test/trees/JBProjects/supportsInterface.tree +0 -9
- package/test/trees/JBProjects/tokenURI.tree +0 -5
- package/test/trees/JBRulesets/currentApprovalStatusForLatestRulesetOf.tree +0 -8
- package/test/trees/JBRulesets/currentOf.tree +0 -12
- package/test/trees/JBRulesets/getRulesetOf.tree +0 -5
- package/test/trees/JBRulesets/latestQueuedRulesetOf.tree +0 -10
- package/test/trees/JBRulesets/rulesetsOf.tree +0 -11
- package/test/trees/JBRulesets/upcomingRulesetOf.tree +0 -20
- package/test/trees/JBRulesets/updateRulesetWeightCache.tree +0 -5
- package/test/trees/JBSplits/setSplitGroupsOf.tree +0 -17
- package/test/trees/JBSplits/splitsOf.tree +0 -5
- package/test/trees/JBTerminalStore/currentReclaimableSurplusOf.tree +0 -16
- package/test/trees/JBTerminalStore/currentSurplusOf.tree +0 -25
- package/test/trees/JBTerminalStore/currentTotalSurplusOf.tree +0 -5
- package/test/trees/JBTerminalStore/recordCashOutsFor.tree +0 -16
- package/test/trees/JBTerminalStore/recordPaymentFrom.tree +0 -14
- package/test/trees/JBTerminalStore/recordPayoutFor.tree +0 -10
- package/test/trees/JBTerminalStore/recordTerminalMigration.tree +0 -5
- package/test/trees/JBTerminalStore/recordUsedAllowanceOf.tree +0 -10
- package/test/trees/JBTokens/burnFrom.tree +0 -10
- package/test/trees/JBTokens/claimTokensFor.tree +0 -10
- package/test/trees/JBTokens/deployERC20For.tree +0 -12
- package/test/trees/JBTokens/mintFor.tree +0 -10
- package/test/trees/JBTokens/setTokenFor.tree +0 -11
- package/test/trees/JBTokens/totalBalanceOf.tree +0 -5
- package/test/trees/JBTokens/totalSupplyOf.tree +0 -5
- package/test/trees/JBTokens/transferCreditsFrom.tree +0 -8
- package/test/trees/mintTokensOf.tree +0 -12
- package/test/units/static/JBChainlinkV3PriceFeed/TestPriceFeed.sol +0 -223
- package/test/units/static/JBController/JBControllerSetup.sol +0 -50
- package/test/units/static/JBController/TestBurnTokensOf.sol +0 -114
- package/test/units/static/JBController/TestClaimTokensFor.sol +0 -63
- package/test/units/static/JBController/TestDeployErc20For.sol +0 -86
- package/test/units/static/JBController/TestLaunchProjectFor.sol +0 -302
- package/test/units/static/JBController/TestLaunchRulesetsFor.sol +0 -342
- package/test/units/static/JBController/TestMigrateController.sol +0 -157
- package/test/units/static/JBController/TestMintTokensOfUnits.sol +0 -111
- package/test/units/static/JBController/TestOmnichainRulesetOperator.sol +0 -324
- package/test/units/static/JBController/TestPayReservedTokenToTerminal.sol +0 -74
- package/test/units/static/JBController/TestPreviewMintOf.sol +0 -117
- package/test/units/static/JBController/TestReceiveMigrationFrom.sol +0 -99
- package/test/units/static/JBController/TestRulesetViews.sol +0 -225
- package/test/units/static/JBController/TestSendReservedTokensToSplitsOf.sol +0 -615
- package/test/units/static/JBController/TestSetSplitGroupsOf.sol +0 -68
- package/test/units/static/JBController/TestSetTokenFor.sol +0 -239
- package/test/units/static/JBController/TestSetUriOf.sol +0 -57
- package/test/units/static/JBController/TestTransferCreditsFrom.sol +0 -169
- package/test/units/static/JBDeadline/TestDeadlineFuzz.sol +0 -211
- package/test/units/static/JBDirectory/JBDirectorySetup.sol +0 -26
- package/test/units/static/JBDirectory/TestPrimaryTerminalOf.sol +0 -126
- package/test/units/static/JBDirectory/TestSetControllerOf.sol +0 -183
- package/test/units/static/JBDirectory/TestSetControllerOfMigrationOrder.sol +0 -104
- package/test/units/static/JBDirectory/TestSetPrimaryTerminalOf.sol +0 -179
- package/test/units/static/JBDirectory/TestSetTerminalsOf.sol +0 -137
- package/test/units/static/JBERC20/JBERC20Setup.sol +0 -34
- package/test/units/static/JBERC20/SigUtils.sol +0 -36
- package/test/units/static/JBERC20/TestInitialize.sol +0 -60
- package/test/units/static/JBERC20/TestName.sol +0 -30
- package/test/units/static/JBERC20/TestNonces.sol +0 -62
- package/test/units/static/JBERC20/TestSymbol.sol +0 -31
- package/test/units/static/JBFeelessAdresses/JBFeelessSetup.sol +0 -22
- package/test/units/static/JBFeelessAdresses/TestInterfaces.sol +0 -30
- package/test/units/static/JBFeelessAdresses/TestSetFeelessAddress.sol +0 -35
- package/test/units/static/JBFees/TestFeesFuzz.sol +0 -79
- package/test/units/static/JBFixedPointNumber/TestAdjustDecimals.sol +0 -16
- package/test/units/static/JBFixedPointNumber/TestAdjustDecimalsFuzz.sol +0 -71
- package/test/units/static/JBFundAccessLimits/JBFundAccessSetup.sol +0 -24
- package/test/units/static/JBFundAccessLimits/TestFundAccessLimitsEdge.sol +0 -163
- package/test/units/static/JBFundAccessLimits/TestPayoutLimitOf.sol +0 -59
- package/test/units/static/JBFundAccessLimits/TestPayoutLimitsOf.sol +0 -101
- package/test/units/static/JBFundAccessLimits/TestSetFundAccessLimitsFor.sol +0 -189
- package/test/units/static/JBFundAccessLimits/TestSurplusAllowanceOf.sol +0 -64
- package/test/units/static/JBFundAccessLimits/TestSurplusAllowancesOf.sol +0 -102
- package/test/units/static/JBMetadataResolver/TestGetDataFor.sol +0 -90
- package/test/units/static/JBMetadataResolver/TestMetadataResolverEdgeCases.sol +0 -247
- package/test/units/static/JBMetadataResolver/TestMetadataResolverFuzz.sol +0 -229
- package/test/units/static/JBMultiTerminal/JBMultiTerminalSetup.sol +0 -50
- package/test/units/static/JBMultiTerminal/TestAccountingContextsOf.sol +0 -72
- package/test/units/static/JBMultiTerminal/TestAddAccountingContextsFor.sol +0 -289
- package/test/units/static/JBMultiTerminal/TestAddToBalanceOf.sol +0 -474
- package/test/units/static/JBMultiTerminal/TestCashOutTokensOf.sol +0 -624
- package/test/units/static/JBMultiTerminal/TestExecutePayout.sol +0 -578
- package/test/units/static/JBMultiTerminal/TestExecuteProcessFee.sol +0 -202
- package/test/units/static/JBMultiTerminal/TestMigrateBalanceOf.sol +0 -222
- package/test/units/static/JBMultiTerminal/TestPay.sol +0 -604
- package/test/units/static/JBMultiTerminal/TestPreviewCashOutFrom.sol +0 -117
- package/test/units/static/JBMultiTerminal/TestPreviewPayFor.sol +0 -114
- package/test/units/static/JBMultiTerminal/TestProcessHeldFeesOf.sol +0 -228
- package/test/units/static/JBMultiTerminal/TestSelfPayRevert.sol +0 -55
- package/test/units/static/JBMultiTerminal/TestSendPayoutsOf.sol +0 -257
- package/test/units/static/JBMultiTerminal/TestUseAllowanceOf.sol +0 -611
- package/test/units/static/JBPermissions/JBPermissionsSetup.sol +0 -20
- package/test/units/static/JBPermissions/TestHasPermission.sol +0 -50
- package/test/units/static/JBPermissions/TestHasPermissions.sol +0 -93
- package/test/units/static/JBPermissions/TestSetPermissionsFor.sol +0 -64
- package/test/units/static/JBPrices/JBPricesSetup.sol +0 -32
- package/test/units/static/JBPrices/TestAddPriceFeedFor.sol +0 -107
- package/test/units/static/JBPrices/TestPricePerUnitOf.sol +0 -132
- package/test/units/static/JBPrices/TestPrices.sol +0 -265
- package/test/units/static/JBProjects/JBProjectsSetup.sol +0 -22
- package/test/units/static/JBProjects/TestCreateFor.sol +0 -71
- package/test/units/static/JBProjects/TestInitialProject.sol +0 -21
- package/test/units/static/JBProjects/TestInterfaces.sol +0 -26
- package/test/units/static/JBProjects/TestSetResolver.sol +0 -37
- package/test/units/static/JBProjects/TestTokenUri.sol +0 -40
- package/test/units/static/JBRulesetMetadataResolver/TestSetCashOutTaxRateTo.sol +0 -108
- package/test/units/static/JBRulesets/JBRulesetsSetup.sol +0 -24
- package/test/units/static/JBRulesets/TestCurrentApprovalStatusForLatestRulesetOf.sol +0 -265
- package/test/units/static/JBRulesets/TestCurrentOf.sol +0 -242
- package/test/units/static/JBRulesets/TestGetRulesetOf.sol +0 -100
- package/test/units/static/JBRulesets/TestLatestQueuedRulesetOf.sol +0 -260
- package/test/units/static/JBRulesets/TestRulesets.sol +0 -632
- package/test/units/static/JBRulesets/TestRulesetsOf.sol +0 -37
- package/test/units/static/JBRulesets/TestUpcomingRulesetOf.sol +0 -522
- package/test/units/static/JBRulesets/TestUpdateRulesetWeightCache.sol +0 -96
- package/test/units/static/JBSplits/JBSplitsSetup.sol +0 -26
- package/test/units/static/JBSplits/TestSelfManagedSplitGroups.sol +0 -552
- package/test/units/static/JBSplits/TestSetSplitGroupsOf.sol +0 -377
- package/test/units/static/JBSplits/TestSplitsLockedEdge.sol +0 -267
- package/test/units/static/JBSplits/TestSplitsOf.sol +0 -24
- package/test/units/static/JBSplits/TestSplitsPacking.sol +0 -36
- package/test/units/static/JBSurplus/TestSurplusFuzz.sol +0 -160
- package/test/units/static/JBTerminalStore/JBTerminalStoreSetup.sol +0 -45
- package/test/units/static/JBTerminalStore/TestCurrentReclaimableSurplusOf.sol +0 -536
- package/test/units/static/JBTerminalStore/TestCurrentSurplusOf.sol +0 -463
- package/test/units/static/JBTerminalStore/TestCurrentTotalSurplusOf.sol +0 -135
- package/test/units/static/JBTerminalStore/TestPreviewCashOutFrom.sol +0 -476
- package/test/units/static/JBTerminalStore/TestPreviewPayFrom.sol +0 -494
- package/test/units/static/JBTerminalStore/TestRecordCashOutsFor.sol +0 -652
- package/test/units/static/JBTerminalStore/TestRecordPaymentFrom.sol +0 -744
- package/test/units/static/JBTerminalStore/TestRecordPayoutFor.sol +0 -289
- package/test/units/static/JBTerminalStore/TestRecordTerminalMigration.sol +0 -138
- package/test/units/static/JBTerminalStore/TestRecordUsedAllowanceOf.sol +0 -415
- package/test/units/static/JBTerminalStore/TestUint224Overflow.sol +0 -219
- package/test/units/static/JBTokens/JBTokensSetup.sol +0 -32
- package/test/units/static/JBTokens/TestBurnFrom.sol +0 -107
- package/test/units/static/JBTokens/TestClaimTokensFor.sol +0 -110
- package/test/units/static/JBTokens/TestDeployERC20ForUnits.sol +0 -92
- package/test/units/static/JBTokens/TestMintFor.sol +0 -100
- package/test/units/static/JBTokens/TestSetTokenFor.sol +0 -98
- package/test/units/static/JBTokens/TestTotalBalanceOf.sol +0 -65
- package/test/units/static/JBTokens/TestTotalSupplyOf.sol +0 -56
- package/test/units/static/JBTokens/TestTransferCreditsFrom.sol +0 -56
package/test/TestPermissions.sol
DELETED
|
@@ -1,324 +0,0 @@
|
|
|
1
|
-
// SPDX-License-Identifier: MIT
|
|
2
|
-
pragma solidity ^0.8.6;
|
|
3
|
-
|
|
4
|
-
import {TestBaseWorkflow} from "./helpers/TestBaseWorkflow.sol";
|
|
5
|
-
import {MockERC20} from "./mock/MockERC20.sol";
|
|
6
|
-
import {JBPermissions} from "../src/JBPermissions.sol";
|
|
7
|
-
import {JBPermissioned} from "../src/abstract/JBPermissioned.sol";
|
|
8
|
-
import {IJBController} from "../src/interfaces/IJBController.sol";
|
|
9
|
-
import {IJBPermissions} from "../src/interfaces/IJBPermissions.sol";
|
|
10
|
-
import {IJBRulesetApprovalHook} from "../src/interfaces/IJBRulesetApprovalHook.sol";
|
|
11
|
-
import {IJBTerminal} from "../src/interfaces/IJBTerminal.sol";
|
|
12
|
-
import {IJBToken} from "../src/interfaces/IJBToken.sol";
|
|
13
|
-
import {JBConstants} from "../src/libraries/JBConstants.sol";
|
|
14
|
-
import {JBAccountingContext} from "../src/structs/JBAccountingContext.sol";
|
|
15
|
-
import {JBFundAccessLimitGroup} from "../src/structs/JBFundAccessLimitGroup.sol";
|
|
16
|
-
import {JBPermissionsData} from "../src/structs/JBPermissionsData.sol";
|
|
17
|
-
import {JBRulesetConfig} from "../src/structs/JBRulesetConfig.sol";
|
|
18
|
-
import {JBRulesetMetadata} from "../src/structs/JBRulesetMetadata.sol";
|
|
19
|
-
import {JBSplitGroup} from "../src/structs/JBSplitGroup.sol";
|
|
20
|
-
import {JBTerminalConfig} from "../src/structs/JBTerminalConfig.sol";
|
|
21
|
-
import {JBPermissionIds} from "@bananapus/permission-ids-v6/src/JBPermissionIds.sol";
|
|
22
|
-
|
|
23
|
-
contract TestPermissions_Local is TestBaseWorkflow {
|
|
24
|
-
IJBController private _controller;
|
|
25
|
-
JBRulesetMetadata private _metadata;
|
|
26
|
-
IJBTerminal private _terminal;
|
|
27
|
-
IJBPermissions private _permissions;
|
|
28
|
-
|
|
29
|
-
address private _projectOwner;
|
|
30
|
-
uint64 private _projectZero;
|
|
31
|
-
uint64 private _projectOne;
|
|
32
|
-
|
|
33
|
-
function setUp() public override {
|
|
34
|
-
super.setUp();
|
|
35
|
-
|
|
36
|
-
_projectOwner = multisig();
|
|
37
|
-
_terminal = jbMultiTerminal();
|
|
38
|
-
_controller = jbController();
|
|
39
|
-
_permissions = jbPermissions();
|
|
40
|
-
|
|
41
|
-
_metadata = JBRulesetMetadata({
|
|
42
|
-
reservedPercent: 0,
|
|
43
|
-
cashOutTaxRate: 0,
|
|
44
|
-
baseCurrency: uint32(uint160(JBConstants.NATIVE_TOKEN)),
|
|
45
|
-
pausePay: false,
|
|
46
|
-
pauseCreditTransfers: false,
|
|
47
|
-
allowOwnerMinting: false,
|
|
48
|
-
allowSetCustomToken: true,
|
|
49
|
-
allowTerminalMigration: false,
|
|
50
|
-
allowSetTerminals: false,
|
|
51
|
-
ownerMustSendPayouts: false,
|
|
52
|
-
allowSetController: false,
|
|
53
|
-
allowAddAccountingContext: true,
|
|
54
|
-
allowAddPriceFeed: false,
|
|
55
|
-
holdFees: false,
|
|
56
|
-
useTotalSurplusForCashOuts: false,
|
|
57
|
-
useDataHookForPay: false,
|
|
58
|
-
useDataHookForCashOut: false,
|
|
59
|
-
dataHook: address(0),
|
|
60
|
-
metadata: 0
|
|
61
|
-
});
|
|
62
|
-
|
|
63
|
-
// Package up ruleset configuration.
|
|
64
|
-
JBRulesetConfig[] memory _rulesetConfig = new JBRulesetConfig[](1);
|
|
65
|
-
_rulesetConfig[0].mustStartAtOrAfter = 0;
|
|
66
|
-
_rulesetConfig[0].duration = 0;
|
|
67
|
-
_rulesetConfig[0].weight = 0;
|
|
68
|
-
_rulesetConfig[0].weightCutPercent = 0;
|
|
69
|
-
_rulesetConfig[0].approvalHook = IJBRulesetApprovalHook(address(0));
|
|
70
|
-
_rulesetConfig[0].metadata = _metadata;
|
|
71
|
-
_rulesetConfig[0].splitGroups = new JBSplitGroup[](0);
|
|
72
|
-
_rulesetConfig[0].fundAccessLimitGroups = new JBFundAccessLimitGroup[](0);
|
|
73
|
-
|
|
74
|
-
// Package up terminal configuration.
|
|
75
|
-
JBTerminalConfig[] memory _terminalConfigurations = new JBTerminalConfig[](1);
|
|
76
|
-
JBAccountingContext[] memory _tokensToAccept = new JBAccountingContext[](1);
|
|
77
|
-
_tokensToAccept[0] = JBAccountingContext({
|
|
78
|
-
token: JBConstants.NATIVE_TOKEN, decimals: 18, currency: uint32(uint160(JBConstants.NATIVE_TOKEN))
|
|
79
|
-
});
|
|
80
|
-
_terminalConfigurations[0] =
|
|
81
|
-
JBTerminalConfig({terminal: _terminal, accountingContextsToAccept: _tokensToAccept});
|
|
82
|
-
|
|
83
|
-
_projectZero = uint64(
|
|
84
|
-
_controller.launchProjectFor({
|
|
85
|
-
owner: makeAddr("zeroOwner"),
|
|
86
|
-
projectUri: "myIPFSHash",
|
|
87
|
-
rulesetConfigurations: _rulesetConfig,
|
|
88
|
-
terminalConfigurations: _terminalConfigurations,
|
|
89
|
-
memo: ""
|
|
90
|
-
})
|
|
91
|
-
);
|
|
92
|
-
|
|
93
|
-
_projectOne = uint64(
|
|
94
|
-
_controller.launchProjectFor({
|
|
95
|
-
owner: _projectOwner,
|
|
96
|
-
projectUri: "myIPFSHash",
|
|
97
|
-
rulesetConfigurations: _rulesetConfig,
|
|
98
|
-
terminalConfigurations: _terminalConfigurations,
|
|
99
|
-
memo: ""
|
|
100
|
-
})
|
|
101
|
-
);
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
function test_RevertIf_MostBasicAccess() public {
|
|
105
|
-
// Package up ruleset configuration.
|
|
106
|
-
JBRulesetConfig[] memory _rulesetConfig = new JBRulesetConfig[](1);
|
|
107
|
-
_rulesetConfig[0].mustStartAtOrAfter = 0;
|
|
108
|
-
_rulesetConfig[0].duration = 0;
|
|
109
|
-
_rulesetConfig[0].weight = 0;
|
|
110
|
-
_rulesetConfig[0].weightCutPercent = 0;
|
|
111
|
-
_rulesetConfig[0].approvalHook = IJBRulesetApprovalHook(address(0));
|
|
112
|
-
_rulesetConfig[0].metadata = _metadata;
|
|
113
|
-
_rulesetConfig[0].splitGroups = new JBSplitGroup[](0);
|
|
114
|
-
_rulesetConfig[0].fundAccessLimitGroups = new JBFundAccessLimitGroup[](0);
|
|
115
|
-
|
|
116
|
-
vm.prank(makeAddr("zeroOwner"));
|
|
117
|
-
vm.expectRevert(
|
|
118
|
-
abi.encodeWithSelector(
|
|
119
|
-
JBPermissioned.JBPermissioned_Unauthorized.selector,
|
|
120
|
-
_projectOwner,
|
|
121
|
-
makeAddr("zeroOwner"),
|
|
122
|
-
_projectOne,
|
|
123
|
-
JBPermissionIds.QUEUE_RULESETS
|
|
124
|
-
)
|
|
125
|
-
);
|
|
126
|
-
uint256 queued = _controller.queueRulesetsOf(_projectOne, _rulesetConfig, "");
|
|
127
|
-
|
|
128
|
-
assertNotEq(queued, block.timestamp);
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
function test_RevertIf_SetOperators() public {
|
|
132
|
-
// Pack up our permission data.
|
|
133
|
-
JBPermissionsData[] memory permData = new JBPermissionsData[](1);
|
|
134
|
-
|
|
135
|
-
uint8[] memory permIds = new uint8[](256);
|
|
136
|
-
|
|
137
|
-
// Push an index higher than 255.
|
|
138
|
-
for (uint8 i; i < 255; i++) {
|
|
139
|
-
permIds[i] = i;
|
|
140
|
-
|
|
141
|
-
permData[0] = JBPermissionsData({operator: address(0), projectId: _projectOne, permissionIds: permIds});
|
|
142
|
-
|
|
143
|
-
// Set em.
|
|
144
|
-
vm.prank(_projectOwner);
|
|
145
|
-
vm.expectRevert(JBPermissions.JBPermissions_NoZeroPermission.selector);
|
|
146
|
-
_permissions.setPermissionsFor(_projectOwner, permData[0]);
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
function testHasPermissions(
|
|
151
|
-
address _account,
|
|
152
|
-
address _op,
|
|
153
|
-
uint56 _projectId,
|
|
154
|
-
uint8 _checkedId,
|
|
155
|
-
// forge-lint: disable-next-line(mixed-case-variable)
|
|
156
|
-
uint8[] memory _set_permissions
|
|
157
|
-
)
|
|
158
|
-
public
|
|
159
|
-
{
|
|
160
|
-
vm.assume(_projectId != 0);
|
|
161
|
-
vm.assume(_set_permissions.length != 0);
|
|
162
|
-
vm.assume(_account != trustedForwarder());
|
|
163
|
-
|
|
164
|
-
// forge-lint: disable-next-line(mixed-case-variable)
|
|
165
|
-
uint256[] memory _check_permissions = new uint256[](1);
|
|
166
|
-
_check_permissions[0] = _checkedId;
|
|
167
|
-
|
|
168
|
-
bool hasPerm;
|
|
169
|
-
bool hasZero;
|
|
170
|
-
for (uint256 i; i < _set_permissions.length; i++) {
|
|
171
|
-
// Flag if index is zero, meaning set call should revert later.
|
|
172
|
-
if (_set_permissions[i] == 0) hasZero = true;
|
|
173
|
-
|
|
174
|
-
// Flag if hasPermissions check will be true if the array contains it or has root ID.
|
|
175
|
-
if (_set_permissions[i] == _checkedId) hasPerm = true;
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
// If setting with a zero permission id, will revert.
|
|
179
|
-
if (hasZero) vm.expectRevert(JBPermissions.JBPermissions_NoZeroPermission.selector);
|
|
180
|
-
|
|
181
|
-
// Set the permissions.
|
|
182
|
-
vm.prank(_account);
|
|
183
|
-
_permissions.setPermissionsFor(
|
|
184
|
-
_account, JBPermissionsData({operator: _op, projectId: _projectId, permissionIds: _set_permissions})
|
|
185
|
-
);
|
|
186
|
-
|
|
187
|
-
// Check permissions if the call didn't revert.
|
|
188
|
-
if (!hasZero) {
|
|
189
|
-
// Call has permissions and assert.
|
|
190
|
-
assertEq(_permissions.hasPermissions(_op, _account, _projectId, _check_permissions, false, false), hasPerm);
|
|
191
|
-
}
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
function testBasicAccessSetup() public {
|
|
195
|
-
address zeroOwner = makeAddr("zeroOwner");
|
|
196
|
-
address token = address(usdcToken());
|
|
197
|
-
|
|
198
|
-
// Pack up our permission data.
|
|
199
|
-
JBPermissionsData[] memory permData = new JBPermissionsData[](1);
|
|
200
|
-
uint8[] memory permIds = new uint8[](1);
|
|
201
|
-
permIds[0] = 1;
|
|
202
|
-
|
|
203
|
-
permData[0] = JBPermissionsData({operator: address(this), projectId: _projectZero, permissionIds: permIds});
|
|
204
|
-
|
|
205
|
-
// Set em.
|
|
206
|
-
vm.prank(zeroOwner);
|
|
207
|
-
_permissions.setPermissionsFor(zeroOwner, permData[0]);
|
|
208
|
-
|
|
209
|
-
// Should be true given root check
|
|
210
|
-
bool _check = _permissions.hasPermission(address(this), zeroOwner, _projectZero, 2, true, true);
|
|
211
|
-
assertEq(_check, true);
|
|
212
|
-
|
|
213
|
-
// Will revert attempting to set another projects token
|
|
214
|
-
vm.expectRevert(
|
|
215
|
-
abi.encodeWithSelector(
|
|
216
|
-
JBPermissioned.JBPermissioned_Unauthorized.selector,
|
|
217
|
-
_projectOwner,
|
|
218
|
-
address(this),
|
|
219
|
-
2,
|
|
220
|
-
JBPermissionIds.SET_TOKEN
|
|
221
|
-
)
|
|
222
|
-
);
|
|
223
|
-
_controller.setTokenFor(2, IJBToken(token));
|
|
224
|
-
|
|
225
|
-
// Will succeed when setting the correct projects token
|
|
226
|
-
mockExpect(token, abi.encodeCall(MockERC20.decimals, ()), abi.encode(18));
|
|
227
|
-
mockExpect(token, abi.encodeCall(IJBToken.canBeAddedTo, (1)), abi.encode(true));
|
|
228
|
-
_controller.setTokenFor(1, IJBToken(token));
|
|
229
|
-
}
|
|
230
|
-
|
|
231
|
-
function testCannotForwardRoot() public {
|
|
232
|
-
address zeroOwner = makeAddr("zeroOwner");
|
|
233
|
-
|
|
234
|
-
// Pack up our permission data.
|
|
235
|
-
JBPermissionsData[] memory permData = new JBPermissionsData[](1);
|
|
236
|
-
uint8[] memory permIds = new uint8[](1);
|
|
237
|
-
permIds[0] = 1;
|
|
238
|
-
|
|
239
|
-
permData[0] = JBPermissionsData({operator: address(this), projectId: _projectZero, permissionIds: permIds});
|
|
240
|
-
|
|
241
|
-
// Set em.
|
|
242
|
-
vm.prank(zeroOwner);
|
|
243
|
-
_permissions.setPermissionsFor(zeroOwner, permData[0]);
|
|
244
|
-
|
|
245
|
-
// Should be true given root check
|
|
246
|
-
bool _check = _permissions.hasPermission(address(this), zeroOwner, _projectZero, 2, true, true);
|
|
247
|
-
assertEq(_check, true);
|
|
248
|
-
|
|
249
|
-
// Pack up our non-root permission data.
|
|
250
|
-
JBPermissionsData[] memory permData2 = new JBPermissionsData[](1);
|
|
251
|
-
uint8[] memory permIds2 = new uint8[](1);
|
|
252
|
-
permIds2[0] = 2;
|
|
253
|
-
|
|
254
|
-
permData2[0] = JBPermissionsData({operator: address(0), projectId: _projectZero, permissionIds: permIds2});
|
|
255
|
-
|
|
256
|
-
// Should be able to forward other permissions
|
|
257
|
-
// Note that this contract is now authorized to do so above- address(this)
|
|
258
|
-
|
|
259
|
-
// in emit
|
|
260
|
-
uint256 packed;
|
|
261
|
-
|
|
262
|
-
vm.expectEmit();
|
|
263
|
-
emit IJBPermissions.OperatorPermissionsSet(
|
|
264
|
-
permData2[0].operator,
|
|
265
|
-
zeroOwner,
|
|
266
|
-
permData2[0].projectId,
|
|
267
|
-
permData2[0].permissionIds,
|
|
268
|
-
packed |= 1 << 2,
|
|
269
|
-
address(this)
|
|
270
|
-
);
|
|
271
|
-
_permissions.setPermissionsFor(zeroOwner, permData2[0]);
|
|
272
|
-
|
|
273
|
-
// Change the permission being set back to root
|
|
274
|
-
permData2[0] = JBPermissionsData({operator: address(0), projectId: _projectZero, permissionIds: permIds});
|
|
275
|
-
|
|
276
|
-
// Shouldn't be able to forward root
|
|
277
|
-
vm.expectRevert(
|
|
278
|
-
abi.encodeWithSelector(
|
|
279
|
-
JBPermissions.JBPermissions_Unauthorized.selector,
|
|
280
|
-
zeroOwner,
|
|
281
|
-
address(this),
|
|
282
|
-
_projectZero,
|
|
283
|
-
JBPermissionIds.ROOT
|
|
284
|
-
)
|
|
285
|
-
);
|
|
286
|
-
_permissions.setPermissionsFor(zeroOwner, permData2[0]);
|
|
287
|
-
}
|
|
288
|
-
|
|
289
|
-
function testWildcardCannotBeSetForWildcardRootOperator() public {
|
|
290
|
-
address zeroOwner = makeAddr("zeroOwner");
|
|
291
|
-
|
|
292
|
-
// Pack up our permission data.
|
|
293
|
-
JBPermissionsData[] memory permData = new JBPermissionsData[](1);
|
|
294
|
-
uint8[] memory permIds = new uint8[](1);
|
|
295
|
-
permIds[0] = 1;
|
|
296
|
-
|
|
297
|
-
uint56 wildcardProjectId = 0;
|
|
298
|
-
|
|
299
|
-
permData[0] = JBPermissionsData({operator: address(this), projectId: wildcardProjectId, permissionIds: permIds});
|
|
300
|
-
|
|
301
|
-
// Set em.
|
|
302
|
-
vm.prank(zeroOwner);
|
|
303
|
-
_permissions.setPermissionsFor(zeroOwner, permData[0]);
|
|
304
|
-
|
|
305
|
-
// Should be true given root check
|
|
306
|
-
bool _check = _permissions.hasPermission(address(this), zeroOwner, _projectZero, 2, true, true);
|
|
307
|
-
assertEq(_check, true);
|
|
308
|
-
|
|
309
|
-
// Pack up our non-root wildcard permission data.
|
|
310
|
-
JBPermissionsData[] memory permData2 = new JBPermissionsData[](1);
|
|
311
|
-
uint8[] memory permIds2 = new uint8[](1);
|
|
312
|
-
permIds2[0] = 2;
|
|
313
|
-
|
|
314
|
-
permData2[0] = JBPermissionsData({operator: address(0), projectId: wildcardProjectId, permissionIds: permIds2});
|
|
315
|
-
|
|
316
|
-
// Shouldn't be able to set permission for wildcard project
|
|
317
|
-
vm.expectRevert(
|
|
318
|
-
abi.encodeWithSelector(
|
|
319
|
-
JBPermissions.JBPermissions_Unauthorized.selector, zeroOwner, address(this), 0, JBPermissionIds.ROOT
|
|
320
|
-
)
|
|
321
|
-
);
|
|
322
|
-
_permissions.setPermissionsFor(zeroOwner, permData2[0]);
|
|
323
|
-
}
|
|
324
|
-
}
|
|
@@ -1,290 +0,0 @@
|
|
|
1
|
-
// SPDX-License-Identifier: MIT
|
|
2
|
-
pragma solidity ^0.8.6;
|
|
3
|
-
|
|
4
|
-
import {TestBaseWorkflow} from "./helpers/TestBaseWorkflow.sol";
|
|
5
|
-
import {JBPermissions} from "../src/JBPermissions.sol";
|
|
6
|
-
import {JBPermissionsData} from "../src/structs/JBPermissionsData.sol";
|
|
7
|
-
import {JBPermissionIds} from "@bananapus/permission-ids-v6/src/JBPermissionIds.sol";
|
|
8
|
-
|
|
9
|
-
/// @notice Defense-in-depth validation of JBPermissions ROOT escalation prevention.
|
|
10
|
-
/// Verifies that ROOT operators cannot forward ROOT, cannot set wildcard permissions,
|
|
11
|
-
/// and that the permission bitmap maintains integrity through set/get cycles.
|
|
12
|
-
contract TestPermissionsEdge_Local is TestBaseWorkflow {
|
|
13
|
-
JBPermissions private _permissions;
|
|
14
|
-
|
|
15
|
-
address private _account;
|
|
16
|
-
address private _operator;
|
|
17
|
-
address private _thirdParty;
|
|
18
|
-
|
|
19
|
-
uint64 constant PROJECT_ID = 5;
|
|
20
|
-
|
|
21
|
-
function setUp() public override {
|
|
22
|
-
super.setUp();
|
|
23
|
-
_permissions = jbPermissions();
|
|
24
|
-
_account = makeAddr("account");
|
|
25
|
-
_operator = makeAddr("operator");
|
|
26
|
-
_thirdParty = makeAddr("thirdParty");
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
// ───────────────────── ROOT cannot be forwarded
|
|
30
|
-
// ─────────────────────
|
|
31
|
-
|
|
32
|
-
/// @notice An operator with ROOT on project N cannot set ROOT for another operator.
|
|
33
|
-
function test_rootCannotBeForwarded() external {
|
|
34
|
-
// Give operator ROOT permission on PROJECT_ID.
|
|
35
|
-
uint8[] memory rootPermissions = new uint8[](1);
|
|
36
|
-
rootPermissions[0] = JBPermissionIds.ROOT;
|
|
37
|
-
|
|
38
|
-
vm.prank(_account);
|
|
39
|
-
_permissions.setPermissionsFor(
|
|
40
|
-
_account, JBPermissionsData({operator: _operator, projectId: PROJECT_ID, permissionIds: rootPermissions})
|
|
41
|
-
);
|
|
42
|
-
|
|
43
|
-
// Verify operator has ROOT.
|
|
44
|
-
assertTrue(
|
|
45
|
-
_permissions.hasPermission(_operator, _account, PROJECT_ID, JBPermissionIds.ROOT, false, false),
|
|
46
|
-
"Operator should have ROOT"
|
|
47
|
-
);
|
|
48
|
-
|
|
49
|
-
// Now operator tries to forward ROOT to thirdParty.
|
|
50
|
-
uint8[] memory rootForThird = new uint8[](1);
|
|
51
|
-
rootForThird[0] = JBPermissionIds.ROOT;
|
|
52
|
-
|
|
53
|
-
vm.prank(_operator);
|
|
54
|
-
vm.expectRevert(
|
|
55
|
-
abi.encodeWithSelector(
|
|
56
|
-
JBPermissions.JBPermissions_Unauthorized.selector, _account, _operator, PROJECT_ID, JBPermissionIds.ROOT
|
|
57
|
-
)
|
|
58
|
-
);
|
|
59
|
-
_permissions.setPermissionsFor(
|
|
60
|
-
_account, JBPermissionsData({operator: _thirdParty, projectId: PROJECT_ID, permissionIds: rootForThird})
|
|
61
|
-
);
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
// ───────────────────── Wildcard cannot be set by operator
|
|
65
|
-
// ─────────────────────
|
|
66
|
-
|
|
67
|
-
/// @notice An operator with ROOT cannot set permissions for the wildcard project ID.
|
|
68
|
-
function test_wildcardCannotBeSetByOperator() external {
|
|
69
|
-
// Give operator ROOT on PROJECT_ID.
|
|
70
|
-
uint8[] memory rootPermissions = new uint8[](1);
|
|
71
|
-
rootPermissions[0] = JBPermissionIds.ROOT;
|
|
72
|
-
|
|
73
|
-
vm.prank(_account);
|
|
74
|
-
_permissions.setPermissionsFor(
|
|
75
|
-
_account, JBPermissionsData({operator: _operator, projectId: PROJECT_ID, permissionIds: rootPermissions})
|
|
76
|
-
);
|
|
77
|
-
|
|
78
|
-
// Operator tries to set permissions on wildcard (project 0).
|
|
79
|
-
uint8[] memory somePermission = new uint8[](1);
|
|
80
|
-
somePermission[0] = 5; // Some non-ROOT permission.
|
|
81
|
-
|
|
82
|
-
vm.prank(_operator);
|
|
83
|
-
vm.expectRevert(
|
|
84
|
-
abi.encodeWithSelector(
|
|
85
|
-
JBPermissions.JBPermissions_Unauthorized.selector, _account, _operator, 0, JBPermissionIds.ROOT
|
|
86
|
-
)
|
|
87
|
-
);
|
|
88
|
-
_permissions.setPermissionsFor(
|
|
89
|
-
_account, JBPermissionsData({operator: _thirdParty, projectId: 0, permissionIds: somePermission})
|
|
90
|
-
);
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
// ───────────────────── ROOT grants all permissions
|
|
94
|
-
// ─────────────────────
|
|
95
|
-
|
|
96
|
-
/// @notice Fuzz: ROOT holder always has permission for any ID (when includeRoot=true).
|
|
97
|
-
function testFuzz_rootGrantsAllPermissions(uint8 permissionId) external {
|
|
98
|
-
vm.assume(permissionId > 0); // 0 is reserved.
|
|
99
|
-
|
|
100
|
-
// Give operator ROOT.
|
|
101
|
-
uint8[] memory rootPermissions = new uint8[](1);
|
|
102
|
-
rootPermissions[0] = JBPermissionIds.ROOT;
|
|
103
|
-
|
|
104
|
-
vm.prank(_account);
|
|
105
|
-
_permissions.setPermissionsFor(
|
|
106
|
-
_account, JBPermissionsData({operator: _operator, projectId: PROJECT_ID, permissionIds: rootPermissions})
|
|
107
|
-
);
|
|
108
|
-
|
|
109
|
-
// Check any permissionId with includeRoot=true.
|
|
110
|
-
assertTrue(
|
|
111
|
-
_permissions.hasPermission(_operator, _account, PROJECT_ID, permissionId, true, false),
|
|
112
|
-
"ROOT should grant all permissions when includeRoot=true"
|
|
113
|
-
);
|
|
114
|
-
|
|
115
|
-
// Without includeRoot, only ROOT bit should be set.
|
|
116
|
-
if (permissionId != JBPermissionIds.ROOT) {
|
|
117
|
-
assertFalse(
|
|
118
|
-
_permissions.hasPermission(_operator, _account, PROJECT_ID, permissionId, false, false),
|
|
119
|
-
"Without includeRoot, only ROOT bit should match"
|
|
120
|
-
);
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
// ───────────────────── Permission ID boundaries
|
|
125
|
-
// ─────────────────────
|
|
126
|
-
|
|
127
|
-
/// @notice Permission 0 cannot be set.
|
|
128
|
-
function test_permissionId0_cannotBeSet() external {
|
|
129
|
-
uint8[] memory zeroPermission = new uint8[](1);
|
|
130
|
-
zeroPermission[0] = 0;
|
|
131
|
-
|
|
132
|
-
vm.prank(_account);
|
|
133
|
-
vm.expectRevert(JBPermissions.JBPermissions_NoZeroPermission.selector);
|
|
134
|
-
_permissions.setPermissionsFor(
|
|
135
|
-
_account, JBPermissionsData({operator: _operator, projectId: PROJECT_ID, permissionIds: zeroPermission})
|
|
136
|
-
);
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
/// @notice Permission 255 (highest) works correctly.
|
|
140
|
-
function test_permissionId255_works() external {
|
|
141
|
-
uint8[] memory maxPermission = new uint8[](1);
|
|
142
|
-
maxPermission[0] = 255;
|
|
143
|
-
|
|
144
|
-
vm.prank(_account);
|
|
145
|
-
_permissions.setPermissionsFor(
|
|
146
|
-
_account, JBPermissionsData({operator: _operator, projectId: PROJECT_ID, permissionIds: maxPermission})
|
|
147
|
-
);
|
|
148
|
-
|
|
149
|
-
assertTrue(
|
|
150
|
-
_permissions.hasPermission(_operator, _account, PROJECT_ID, 255, false, false), "Permission 255 should work"
|
|
151
|
-
);
|
|
152
|
-
|
|
153
|
-
// Permission 254 should NOT be set.
|
|
154
|
-
assertFalse(
|
|
155
|
-
_permissions.hasPermission(_operator, _account, PROJECT_ID, 254, false, false),
|
|
156
|
-
"Permission 254 should not be set"
|
|
157
|
-
);
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
// ───────────────────── Replacement not additive
|
|
161
|
-
// ─────────────────────
|
|
162
|
-
|
|
163
|
-
/// @notice Setting new permissions replaces old ones (old permissions lost).
|
|
164
|
-
function test_replacementNotAdditive() external {
|
|
165
|
-
// Set permission 5.
|
|
166
|
-
uint8[] memory perm5 = new uint8[](1);
|
|
167
|
-
perm5[0] = 5;
|
|
168
|
-
|
|
169
|
-
vm.prank(_account);
|
|
170
|
-
_permissions.setPermissionsFor(
|
|
171
|
-
_account, JBPermissionsData({operator: _operator, projectId: PROJECT_ID, permissionIds: perm5})
|
|
172
|
-
);
|
|
173
|
-
|
|
174
|
-
assertTrue(_permissions.hasPermission(_operator, _account, PROJECT_ID, 5, false, false), "Should have perm 5");
|
|
175
|
-
|
|
176
|
-
// Now set permission 10 — should REPLACE, not add to perm 5.
|
|
177
|
-
uint8[] memory perm10 = new uint8[](1);
|
|
178
|
-
perm10[0] = 10;
|
|
179
|
-
|
|
180
|
-
vm.prank(_account);
|
|
181
|
-
_permissions.setPermissionsFor(
|
|
182
|
-
_account, JBPermissionsData({operator: _operator, projectId: PROJECT_ID, permissionIds: perm10})
|
|
183
|
-
);
|
|
184
|
-
|
|
185
|
-
assertTrue(_permissions.hasPermission(_operator, _account, PROJECT_ID, 10, false, false), "Should have perm 10");
|
|
186
|
-
assertFalse(
|
|
187
|
-
_permissions.hasPermission(_operator, _account, PROJECT_ID, 5, false, false),
|
|
188
|
-
"Perm 5 should be LOST after replacement"
|
|
189
|
-
);
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
// ───────────────────── Wildcard overrides project-specific
|
|
193
|
-
// ─────────────────────
|
|
194
|
-
|
|
195
|
-
/// @notice Wildcard permission grants access to all projects.
|
|
196
|
-
function test_wildcardOverridesProjectSpecific() external {
|
|
197
|
-
// Set permission 5 on wildcard project (0).
|
|
198
|
-
uint8[] memory perm5 = new uint8[](1);
|
|
199
|
-
perm5[0] = 5;
|
|
200
|
-
|
|
201
|
-
vm.prank(_account);
|
|
202
|
-
_permissions.setPermissionsFor(
|
|
203
|
-
_account, JBPermissionsData({operator: _operator, projectId: 0, permissionIds: perm5})
|
|
204
|
-
);
|
|
205
|
-
|
|
206
|
-
// Check with includeWildcardProjectId=true on any project.
|
|
207
|
-
assertTrue(
|
|
208
|
-
_permissions.hasPermission(_operator, _account, PROJECT_ID, 5, false, true),
|
|
209
|
-
"Wildcard should grant permission on any project"
|
|
210
|
-
);
|
|
211
|
-
|
|
212
|
-
// Check without wildcard — should not have permission on specific project.
|
|
213
|
-
assertFalse(
|
|
214
|
-
_permissions.hasPermission(_operator, _account, PROJECT_ID, 5, false, false),
|
|
215
|
-
"Without wildcard flag, specific project check fails"
|
|
216
|
-
);
|
|
217
|
-
}
|
|
218
|
-
|
|
219
|
-
// ───────────────────── Bit integrity fuzz
|
|
220
|
-
// ─────────────────────
|
|
221
|
-
|
|
222
|
-
/// @notice Fuzz: packed permissions maintain bit integrity through set/get cycle.
|
|
223
|
-
function testFuzz_setPermissions_bitIntegrity(uint256 bitmap) external {
|
|
224
|
-
// Build permission ID array from bitmap.
|
|
225
|
-
// Count set bits (excluding bit 0).
|
|
226
|
-
uint256 count;
|
|
227
|
-
for (uint256 i = 1; i < 256; i++) {
|
|
228
|
-
if ((bitmap >> i) & 1 == 1) count++;
|
|
229
|
-
}
|
|
230
|
-
|
|
231
|
-
if (count == 0) return; // Skip empty bitmaps.
|
|
232
|
-
|
|
233
|
-
uint8[] memory ids = new uint8[](count);
|
|
234
|
-
uint256 idx;
|
|
235
|
-
for (uint256 i = 1; i < 256; i++) {
|
|
236
|
-
if ((bitmap >> i) & 1 == 1) {
|
|
237
|
-
// forge-lint: disable-next-line(unsafe-typecast)
|
|
238
|
-
ids[idx] = uint8(i);
|
|
239
|
-
idx++;
|
|
240
|
-
}
|
|
241
|
-
}
|
|
242
|
-
|
|
243
|
-
vm.prank(_account);
|
|
244
|
-
_permissions.setPermissionsFor(
|
|
245
|
-
_account, JBPermissionsData({operator: _operator, projectId: PROJECT_ID, permissionIds: ids})
|
|
246
|
-
);
|
|
247
|
-
|
|
248
|
-
// Verify packed value matches.
|
|
249
|
-
uint256 packed = _permissions.permissionsOf(_operator, _account, PROJECT_ID);
|
|
250
|
-
|
|
251
|
-
// Check each bit.
|
|
252
|
-
for (uint256 i = 1; i < 256; i++) {
|
|
253
|
-
bool expected = (bitmap >> i) & 1 == 1;
|
|
254
|
-
bool actual = ((packed >> i) & 1) == 1;
|
|
255
|
-
assertEq(actual, expected, string.concat("Bit mismatch at position ", vm.toString(i)));
|
|
256
|
-
}
|
|
257
|
-
|
|
258
|
-
// Bit 0 should never be set.
|
|
259
|
-
assertFalse(((packed >> 0) & 1) == 1, "Bit 0 should never be set");
|
|
260
|
-
}
|
|
261
|
-
|
|
262
|
-
// ───────────────────── ROOT operator can set non-ROOT permissions
|
|
263
|
-
// ─────────────────────
|
|
264
|
-
|
|
265
|
-
/// @notice ROOT operator CAN set non-ROOT permissions for others on the same project.
|
|
266
|
-
function test_rootOperator_canSetNonRootPermissions() external {
|
|
267
|
-
// Give operator ROOT.
|
|
268
|
-
uint8[] memory rootPermissions = new uint8[](1);
|
|
269
|
-
rootPermissions[0] = JBPermissionIds.ROOT;
|
|
270
|
-
|
|
271
|
-
vm.prank(_account);
|
|
272
|
-
_permissions.setPermissionsFor(
|
|
273
|
-
_account, JBPermissionsData({operator: _operator, projectId: PROJECT_ID, permissionIds: rootPermissions})
|
|
274
|
-
);
|
|
275
|
-
|
|
276
|
-
// Operator sets non-ROOT permission for thirdParty — should succeed.
|
|
277
|
-
uint8[] memory nonRootPerm = new uint8[](1);
|
|
278
|
-
nonRootPerm[0] = 5;
|
|
279
|
-
|
|
280
|
-
vm.prank(_operator);
|
|
281
|
-
_permissions.setPermissionsFor(
|
|
282
|
-
_account, JBPermissionsData({operator: _thirdParty, projectId: PROJECT_ID, permissionIds: nonRootPerm})
|
|
283
|
-
);
|
|
284
|
-
|
|
285
|
-
assertTrue(
|
|
286
|
-
_permissions.hasPermission(_thirdParty, _account, PROJECT_ID, 5, false, false),
|
|
287
|
-
"ROOT operator should be able to delegate non-ROOT permissions"
|
|
288
|
-
);
|
|
289
|
-
}
|
|
290
|
-
}
|