@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
|
@@ -1,137 +0,0 @@
|
|
|
1
|
-
// SPDX-License-Identifier: MIT
|
|
2
|
-
pragma solidity 0.8.28;
|
|
3
|
-
|
|
4
|
-
import {StdStorage, stdStorage} from "forge-std/StdStorage.sol";
|
|
5
|
-
import {JBDirectory} from "../../../../src/JBDirectory.sol";
|
|
6
|
-
import {JBPermissioned} from "../../../../src/abstract/JBPermissioned.sol";
|
|
7
|
-
import {IJBDirectory} from "../../../../src/interfaces/IJBDirectory.sol";
|
|
8
|
-
import {IJBDirectoryAccessControl} from "../../../../src/interfaces/IJBDirectoryAccessControl.sol";
|
|
9
|
-
import {IJBPermissions} from "../../../../src/interfaces/IJBPermissions.sol";
|
|
10
|
-
import {IJBTerminal} from "../../../../src/interfaces/IJBTerminal.sol";
|
|
11
|
-
import {JBPermissionIds} from "@bananapus/permission-ids-v6/src/JBPermissionIds.sol";
|
|
12
|
-
import {IERC721} from "@openzeppelin/contracts/token/ERC721/IERC721.sol";
|
|
13
|
-
import {IERC165} from "@openzeppelin/contracts/utils/introspection/ERC165.sol";
|
|
14
|
-
import {JBDirectorySetup} from "./JBDirectorySetup.sol";
|
|
15
|
-
|
|
16
|
-
contract TestSetTerminalsOf_Local is JBDirectorySetup {
|
|
17
|
-
using stdStorage for StdStorage;
|
|
18
|
-
|
|
19
|
-
IJBTerminal _terminalToAdd = IJBTerminal(makeAddr("newTerminal"));
|
|
20
|
-
address _mockController = makeAddr("controller");
|
|
21
|
-
address _token = makeAddr("newToken");
|
|
22
|
-
|
|
23
|
-
function setUp() public {
|
|
24
|
-
super.directorySetup();
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
modifier whenCallerHasPermission() {
|
|
28
|
-
// mock ownerOf call
|
|
29
|
-
bytes memory _ownerOfCall = abi.encodeCall(IERC721.ownerOf, (1));
|
|
30
|
-
bytes memory _ownerData = abi.encode(address(this));
|
|
31
|
-
|
|
32
|
-
mockExpect(address(projects), _ownerOfCall, _ownerData);
|
|
33
|
-
_;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
modifier givenSetTerminalsAllowed() {
|
|
37
|
-
// it should revert with revert SET_TERMINALS_NOT_ALLOWED()
|
|
38
|
-
stdstore.target(address(_directory)).sig("controllerOf(uint256)").with_key(1).depth(0)
|
|
39
|
-
.checked_write(_mockController);
|
|
40
|
-
|
|
41
|
-
// mock erc165 call
|
|
42
|
-
bytes memory _supportCall =
|
|
43
|
-
abi.encodeCall(IERC165.supportsInterface, (type(IJBDirectoryAccessControl).interfaceId));
|
|
44
|
-
bytes memory _supportReturned = abi.encode(true);
|
|
45
|
-
|
|
46
|
-
mockExpect(address(_mockController), _supportCall, _supportReturned);
|
|
47
|
-
|
|
48
|
-
// mock setTerminalsAllowed call
|
|
49
|
-
bytes memory _allowedCall = abi.encodeCall(IJBDirectoryAccessControl.setTerminalsAllowed, (1));
|
|
50
|
-
bytes memory _allowedReturn = abi.encode(true);
|
|
51
|
-
|
|
52
|
-
mockExpect(address(_mockController), _allowedCall, _allowedReturn);
|
|
53
|
-
_;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
function test_GivenNotSetTerminalsAllowed() external whenCallerHasPermission {
|
|
57
|
-
// it should revert with revert SET_TERMINALS_NOT_ALLOWED()
|
|
58
|
-
stdstore.target(address(_directory)).sig("controllerOf(uint256)").with_key(1).depth(0)
|
|
59
|
-
.checked_write(_mockController);
|
|
60
|
-
|
|
61
|
-
// mock erc165 call
|
|
62
|
-
bytes memory _supportCall =
|
|
63
|
-
abi.encodeCall(IERC165.supportsInterface, (type(IJBDirectoryAccessControl).interfaceId));
|
|
64
|
-
bytes memory _supportReturned = abi.encode(true);
|
|
65
|
-
|
|
66
|
-
mockExpect(address(_mockController), _supportCall, _supportReturned);
|
|
67
|
-
|
|
68
|
-
// mock setTerminalsAllowed call
|
|
69
|
-
bytes memory _allowedCall = abi.encodeCall(IJBDirectoryAccessControl.setTerminalsAllowed, (1));
|
|
70
|
-
bytes memory _allowedReturn = abi.encode(false);
|
|
71
|
-
|
|
72
|
-
mockExpect(address(_mockController), _allowedCall, _allowedReturn);
|
|
73
|
-
|
|
74
|
-
// needed for the call
|
|
75
|
-
IJBTerminal[] memory _terminals = new IJBTerminal[](1);
|
|
76
|
-
_terminals[0] = _terminalToAdd;
|
|
77
|
-
|
|
78
|
-
vm.expectRevert(abi.encodeWithSelector(JBDirectory.JBDirectory_SetTerminalsNotAllowed.selector, 1));
|
|
79
|
-
_directory.setTerminalsOf(1, _terminals);
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
function test_WhenCallerHasNoPermission() external {
|
|
83
|
-
// it should revert with UNAUTHORIZED()
|
|
84
|
-
// mock ownerOf call
|
|
85
|
-
bytes memory _ownerOfCall = abi.encodeCall(IERC721.ownerOf, (1));
|
|
86
|
-
address _ownerData = address(1);
|
|
87
|
-
|
|
88
|
-
mockExpect(address(projects), _ownerOfCall, abi.encode(_ownerData));
|
|
89
|
-
|
|
90
|
-
// mock first permissions call
|
|
91
|
-
bytes memory _permissionsCall = abi.encodeCall(
|
|
92
|
-
IJBPermissions.hasPermission, (address(this), address(1), 1, JBPermissionIds.SET_TERMINALS, true, true)
|
|
93
|
-
);
|
|
94
|
-
bytes memory _permissionsReturned = abi.encode(false);
|
|
95
|
-
|
|
96
|
-
mockExpect(address(permissions), _permissionsCall, _permissionsReturned);
|
|
97
|
-
|
|
98
|
-
// needed for the call
|
|
99
|
-
IJBTerminal[] memory _terminals = new IJBTerminal[](1);
|
|
100
|
-
_terminals[0] = _terminalToAdd;
|
|
101
|
-
|
|
102
|
-
vm.expectRevert(
|
|
103
|
-
abi.encodeWithSelector(
|
|
104
|
-
JBPermissioned.JBPermissioned_Unauthorized.selector,
|
|
105
|
-
_ownerData,
|
|
106
|
-
address(this),
|
|
107
|
-
1,
|
|
108
|
-
JBPermissionIds.SET_TERMINALS
|
|
109
|
-
)
|
|
110
|
-
);
|
|
111
|
-
_directory.setTerminalsOf(1, _terminals);
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
function test_GivenDuplicateTerminalsWereAdded() external whenCallerHasPermission givenSetTerminalsAllowed {
|
|
115
|
-
// it should revert with DUPLICATE_TERMINALS()
|
|
116
|
-
// needed for the call
|
|
117
|
-
IJBTerminal[] memory _terminals = new IJBTerminal[](2);
|
|
118
|
-
_terminals[0] = _terminalToAdd;
|
|
119
|
-
_terminals[1] = _terminalToAdd;
|
|
120
|
-
|
|
121
|
-
vm.expectRevert(abi.encodeWithSelector(JBDirectory.JBDirectory_DuplicateTerminals.selector, _terminalToAdd));
|
|
122
|
-
_directory.setTerminalsOf(1, _terminals);
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
function test_GivenDuplicateTerminalsWereNotAdded() external whenCallerHasPermission givenSetTerminalsAllowed {
|
|
126
|
-
// it should set terminals and emit SetTerminals
|
|
127
|
-
|
|
128
|
-
// needed for the call
|
|
129
|
-
IJBTerminal[] memory _terminals = new IJBTerminal[](1);
|
|
130
|
-
_terminals[0] = _terminalToAdd;
|
|
131
|
-
|
|
132
|
-
vm.expectEmit();
|
|
133
|
-
emit IJBDirectory.SetTerminals(1, _terminals, address(this));
|
|
134
|
-
|
|
135
|
-
_directory.setTerminalsOf(1, _terminals);
|
|
136
|
-
}
|
|
137
|
-
}
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
// SPDX-License-Identifier: MIT
|
|
2
|
-
pragma solidity 0.8.28;
|
|
3
|
-
|
|
4
|
-
import {Clones} from "@openzeppelin/contracts/proxy/Clones.sol";
|
|
5
|
-
import {JBERC20} from "../../../../src/JBERC20.sol";
|
|
6
|
-
import {IJBPermissions} from "../../../../src/interfaces/IJBPermissions.sol";
|
|
7
|
-
import {IJBProjects} from "../../../../src/interfaces/IJBProjects.sol";
|
|
8
|
-
import {IJBToken} from "../../../../src/interfaces/IJBToken.sol";
|
|
9
|
-
import {JBTest} from "../../../helpers/JBTest.sol";
|
|
10
|
-
|
|
11
|
-
/*
|
|
12
|
-
Contract that deploys a target contract with other mock contracts to satisfy the constructor.
|
|
13
|
-
Tests relative to this contract will be dependent on mock calls/emits and stdStorage.
|
|
14
|
-
*/
|
|
15
|
-
contract JBERC20Setup is JBTest {
|
|
16
|
-
// Mocks
|
|
17
|
-
address _tokens = makeAddr("tokens");
|
|
18
|
-
IJBProjects _projects = IJBProjects(makeAddr("projects"));
|
|
19
|
-
IJBPermissions _permissions = IJBPermissions(makeAddr("permissions"));
|
|
20
|
-
|
|
21
|
-
// Implementation (constructor sets _name = "invalid", cannot be initialized)
|
|
22
|
-
IJBToken public _implementation;
|
|
23
|
-
|
|
24
|
-
// Target Contract (clone with empty _name, can be initialized)
|
|
25
|
-
IJBToken public _erc20;
|
|
26
|
-
|
|
27
|
-
function erc20Setup() public virtual {
|
|
28
|
-
// Deploy the implementation with immutable permissions and projects
|
|
29
|
-
_implementation = new JBERC20(_permissions, _projects);
|
|
30
|
-
|
|
31
|
-
// Clone it — clones start with empty storage, so initialize() works
|
|
32
|
-
_erc20 = IJBToken(Clones.clone(address(_implementation)));
|
|
33
|
-
}
|
|
34
|
-
}
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
// SPDX-License-Identifier: MIT
|
|
2
|
-
pragma solidity 0.8.28;
|
|
3
|
-
|
|
4
|
-
contract SigUtils {
|
|
5
|
-
// forge-lint: disable-next-line(mixed-case-variable)
|
|
6
|
-
bytes32 internal DOMAIN_SEPARATOR;
|
|
7
|
-
|
|
8
|
-
// forge-lint: disable-next-line(mixed-case-variable)
|
|
9
|
-
constructor(bytes32 _DOMAIN_SEPARATOR) {
|
|
10
|
-
DOMAIN_SEPARATOR = _DOMAIN_SEPARATOR;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
// keccak256("Permit(address owner,address spender,uint256 value,uint256 nonce,uint256 deadline)");
|
|
14
|
-
bytes32 private constant PERMIT_TYPEHASH =
|
|
15
|
-
keccak256("Permit(address owner,address spender,uint256 value,uint256 nonce,uint256 deadline)");
|
|
16
|
-
|
|
17
|
-
struct Permit {
|
|
18
|
-
address owner;
|
|
19
|
-
address spender;
|
|
20
|
-
uint256 value;
|
|
21
|
-
uint256 nonce;
|
|
22
|
-
uint256 deadline;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
// computes the hash of a permit
|
|
26
|
-
function getStructHash(Permit memory _permit) internal pure returns (bytes32) {
|
|
27
|
-
return keccak256(
|
|
28
|
-
abi.encode(PERMIT_TYPEHASH, _permit.owner, _permit.spender, _permit.value, _permit.nonce, _permit.deadline)
|
|
29
|
-
);
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
// computes the hash of the fully encoded EIP-712 message for the domain, which can be used to recover the signer
|
|
33
|
-
function getTypedDataHash(Permit memory _permit) public view returns (bytes32) {
|
|
34
|
-
return keccak256(abi.encodePacked("\x19\x01", DOMAIN_SEPARATOR, getStructHash(_permit)));
|
|
35
|
-
}
|
|
36
|
-
}
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
// SPDX-License-Identifier: MIT
|
|
2
|
-
pragma solidity 0.8.28;
|
|
3
|
-
|
|
4
|
-
import {IERC20Metadata} from "@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol";
|
|
5
|
-
import {JBERC20} from "../../../../src/JBERC20.sol";
|
|
6
|
-
import {JBERC20Setup} from "./JBERC20Setup.sol";
|
|
7
|
-
|
|
8
|
-
contract TestInitialize_Local is JBERC20Setup {
|
|
9
|
-
string _name = "Nana";
|
|
10
|
-
string _symbol = "NANA";
|
|
11
|
-
|
|
12
|
-
function setUp() public {
|
|
13
|
-
super.erc20Setup();
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
function test_ImplementationCannotBeInitialized() external {
|
|
17
|
-
// The implementation has _name = "invalid" set in constructor, so initialize() must revert.
|
|
18
|
-
vm.expectRevert(JBERC20.JBERC20_AlreadyInitialized.selector);
|
|
19
|
-
_implementation.initialize(_name, _symbol, _tokens);
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
function test_WhenANameIsAlreadySet() external {
|
|
23
|
-
// it will revert
|
|
24
|
-
|
|
25
|
-
_erc20.initialize(_name, _symbol, _tokens);
|
|
26
|
-
|
|
27
|
-
// ensure TOKENS is set
|
|
28
|
-
address setTokens = address(JBERC20(address(_erc20)).TOKENS());
|
|
29
|
-
assertEq(setTokens, _tokens);
|
|
30
|
-
|
|
31
|
-
// will fail as internal name is no longer zero length
|
|
32
|
-
vm.expectRevert();
|
|
33
|
-
_erc20.initialize(_name, _symbol, _tokens);
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
function test_WhenName_EQNothing() external {
|
|
37
|
-
// it will revert
|
|
38
|
-
|
|
39
|
-
// will fail as internal name is no longer than zero length
|
|
40
|
-
vm.expectRevert();
|
|
41
|
-
_erc20.initialize("", _symbol, _tokens);
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
function test_WhenNameIsValidAndNotAlreadySet() external {
|
|
45
|
-
// it will set the name, symbol, and store references
|
|
46
|
-
|
|
47
|
-
_erc20.initialize(_name, _symbol, _tokens);
|
|
48
|
-
|
|
49
|
-
// ensure TOKENS is set
|
|
50
|
-
address setTokens = address(JBERC20(address(_erc20)).TOKENS());
|
|
51
|
-
assertEq(setTokens, _tokens);
|
|
52
|
-
|
|
53
|
-
// name is set
|
|
54
|
-
string memory _setName = IERC20Metadata(address(_erc20)).name();
|
|
55
|
-
string memory _setSymbol = IERC20Metadata(address(_erc20)).symbol();
|
|
56
|
-
|
|
57
|
-
assertEq(_setName, _name);
|
|
58
|
-
assertEq(_setSymbol, _symbol);
|
|
59
|
-
}
|
|
60
|
-
}
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
// SPDX-License-Identifier: MIT
|
|
2
|
-
pragma solidity 0.8.28;
|
|
3
|
-
|
|
4
|
-
import {IERC20Metadata} from "@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol";
|
|
5
|
-
import {JBERC20Setup} from "./JBERC20Setup.sol";
|
|
6
|
-
|
|
7
|
-
contract TestName_Local is JBERC20Setup {
|
|
8
|
-
IERC20Metadata _token;
|
|
9
|
-
|
|
10
|
-
function setUp() public {
|
|
11
|
-
super.erc20Setup();
|
|
12
|
-
|
|
13
|
-
_token = IERC20Metadata(address(_erc20));
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
function test_WhenANameIsSet() external {
|
|
17
|
-
// it will return the name
|
|
18
|
-
_erc20.initialize("NANAPUS", "NANA", _tokens);
|
|
19
|
-
|
|
20
|
-
string memory _setName = _token.name();
|
|
21
|
-
assertEq(_setName, "NANAPUS");
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
function test_WhenANameIsNotSet() external view {
|
|
25
|
-
// it will return an empty string
|
|
26
|
-
|
|
27
|
-
string memory _storedName = _token.name();
|
|
28
|
-
assertEq(_storedName, "");
|
|
29
|
-
}
|
|
30
|
-
}
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
// SPDX-License-Identifier: MIT
|
|
2
|
-
pragma solidity 0.8.28;
|
|
3
|
-
|
|
4
|
-
import {IERC20Permit} from "@openzeppelin/contracts/token/ERC20/extensions/IERC20Permit.sol";
|
|
5
|
-
import {JBERC20Setup} from "./JBERC20Setup.sol";
|
|
6
|
-
import {SigUtils} from "./SigUtils.sol";
|
|
7
|
-
|
|
8
|
-
contract TestNonces_Local is JBERC20Setup {
|
|
9
|
-
address _user = makeAddr("user");
|
|
10
|
-
IERC20Permit _token;
|
|
11
|
-
SigUtils sigUtils;
|
|
12
|
-
|
|
13
|
-
// forge-lint: disable-next-line(screaming-snake-case-immutable)
|
|
14
|
-
bytes32 private immutable _hashedName = keccak256(bytes("JBToken"));
|
|
15
|
-
// forge-lint: disable-next-line(screaming-snake-case-immutable)
|
|
16
|
-
bytes32 private immutable _hashedVersion = keccak256(bytes("1"));
|
|
17
|
-
|
|
18
|
-
bytes32 _domain;
|
|
19
|
-
|
|
20
|
-
bytes32 private constant TYPE_HASH =
|
|
21
|
-
keccak256("EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)");
|
|
22
|
-
|
|
23
|
-
function setUp() public {
|
|
24
|
-
super.erc20Setup();
|
|
25
|
-
|
|
26
|
-
_token = IERC20Permit(address(_erc20));
|
|
27
|
-
_domain = keccak256(abi.encode(TYPE_HASH, _hashedName, _hashedVersion, block.chainid, address(_token)));
|
|
28
|
-
sigUtils = new SigUtils(_domain);
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
function test_WhenAUserHasNotCalledPermit() external view {
|
|
32
|
-
// it will return zero
|
|
33
|
-
|
|
34
|
-
uint256 _nonce = _token.nonces(_user);
|
|
35
|
-
|
|
36
|
-
assertEq(_nonce, 0);
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
function test_WhenAUserHasCalledPermit() external {
|
|
40
|
-
// it will return a nonce GT zero
|
|
41
|
-
|
|
42
|
-
(address holder, uint256 holderPk) = makeAddrAndKey("hodler");
|
|
43
|
-
|
|
44
|
-
SigUtils.Permit memory permit = SigUtils.Permit({
|
|
45
|
-
owner: holder,
|
|
46
|
-
spender: address(this),
|
|
47
|
-
value: 1,
|
|
48
|
-
nonce: _token.nonces(holder),
|
|
49
|
-
deadline: block.timestamp + 1 days
|
|
50
|
-
});
|
|
51
|
-
|
|
52
|
-
bytes32 digest = sigUtils.getTypedDataHash(permit);
|
|
53
|
-
|
|
54
|
-
(uint8 v, bytes32 r, bytes32 s) = vm.sign(holderPk, digest);
|
|
55
|
-
|
|
56
|
-
vm.prank(holder);
|
|
57
|
-
_token.permit(holder, address(this), 1, block.timestamp + 1 days, v, r, s);
|
|
58
|
-
|
|
59
|
-
uint256 _nonce = _token.nonces(holder);
|
|
60
|
-
assertEq(_nonce, 1);
|
|
61
|
-
}
|
|
62
|
-
}
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
// SPDX-License-Identifier: MIT
|
|
2
|
-
pragma solidity 0.8.28;
|
|
3
|
-
|
|
4
|
-
import {IERC20Metadata} from "@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol";
|
|
5
|
-
import {JBERC20Setup} from "./JBERC20Setup.sol";
|
|
6
|
-
|
|
7
|
-
contract TestSymbol_Local is JBERC20Setup {
|
|
8
|
-
IERC20Metadata _token;
|
|
9
|
-
|
|
10
|
-
function setUp() public {
|
|
11
|
-
super.erc20Setup();
|
|
12
|
-
|
|
13
|
-
_token = IERC20Metadata(address(_erc20));
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
function test_WhenASymbolIsSet() external {
|
|
17
|
-
// it will return a non-empty string
|
|
18
|
-
|
|
19
|
-
_erc20.initialize("NANAPUS", "NANA", _tokens);
|
|
20
|
-
|
|
21
|
-
string memory _setSymbol = _token.symbol();
|
|
22
|
-
assertEq(_setSymbol, "NANA");
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
function test_WhenASymbolIsNotSet() external view {
|
|
26
|
-
// it will return an empty string
|
|
27
|
-
|
|
28
|
-
string memory _setSymbol = _token.symbol();
|
|
29
|
-
assertEq(_setSymbol, "");
|
|
30
|
-
}
|
|
31
|
-
}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
// SPDX-License-Identifier: MIT
|
|
2
|
-
pragma solidity 0.8.28;
|
|
3
|
-
|
|
4
|
-
import {JBFeelessAddresses} from "../../../../src/JBFeelessAddresses.sol";
|
|
5
|
-
import {IJBFeelessAddresses} from "../../../../src/interfaces/IJBFeelessAddresses.sol";
|
|
6
|
-
import {JBTest} from "../../../helpers/JBTest.sol";
|
|
7
|
-
|
|
8
|
-
/*
|
|
9
|
-
Contract that deploys a target contract with other mock contracts to satisfy the constructor.
|
|
10
|
-
Tests relative to this contract will be dependent on mock calls/emits and stdStorage.
|
|
11
|
-
*/
|
|
12
|
-
contract JBFeelessSetup is JBTest {
|
|
13
|
-
address _owner = makeAddr("owner");
|
|
14
|
-
|
|
15
|
-
// Target Contract
|
|
16
|
-
IJBFeelessAddresses public _feelessAddresses;
|
|
17
|
-
|
|
18
|
-
function feelessAddressesSetup() public virtual {
|
|
19
|
-
// Instantiate the contract being tested
|
|
20
|
-
_feelessAddresses = new JBFeelessAddresses(_owner);
|
|
21
|
-
}
|
|
22
|
-
}
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
// SPDX-License-Identifier: MIT
|
|
2
|
-
pragma solidity 0.8.28;
|
|
3
|
-
|
|
4
|
-
import {IJBFeelessAddresses} from "../../../../src/interfaces/IJBFeelessAddresses.sol";
|
|
5
|
-
import {IERC165} from "@openzeppelin/contracts/utils/introspection/ERC165.sol";
|
|
6
|
-
import {JBFeelessSetup} from "./JBFeelessSetup.sol";
|
|
7
|
-
|
|
8
|
-
contract TestSupportsInterface_Local is JBFeelessSetup {
|
|
9
|
-
function setUp() public {
|
|
10
|
-
super.feelessAddressesSetup();
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
function test_WhenItSupportsEitherIJBFeelessAddressesOrIERC165() external view {
|
|
14
|
-
// it should return true
|
|
15
|
-
bool result1 = IERC165(address(_feelessAddresses)).supportsInterface(type(IJBFeelessAddresses).interfaceId);
|
|
16
|
-
assertEq(result1, true);
|
|
17
|
-
|
|
18
|
-
bool result2 = IERC165(address(_feelessAddresses)).supportsInterface(type(IERC165).interfaceId);
|
|
19
|
-
assertEq(result2, true);
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
function test_WhenAskedIfSupportsNonIJBFeelessAddressesOrIERC165() external view {
|
|
23
|
-
// it should return false
|
|
24
|
-
bool result1 = IERC165(address(_feelessAddresses)).supportsInterface(0x12345678);
|
|
25
|
-
assertEq(result1, false);
|
|
26
|
-
|
|
27
|
-
bool result2 = IERC165(address(_feelessAddresses)).supportsInterface(0x12345679);
|
|
28
|
-
assertEq(result2, false);
|
|
29
|
-
}
|
|
30
|
-
}
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
// SPDX-License-Identifier: MIT
|
|
2
|
-
pragma solidity 0.8.28;
|
|
3
|
-
|
|
4
|
-
import {IJBFeelessAddresses} from "../../../../src/interfaces/IJBFeelessAddresses.sol";
|
|
5
|
-
import {JBFeelessSetup} from "./JBFeelessSetup.sol";
|
|
6
|
-
|
|
7
|
-
contract TestSetFeelessAddress_Local is JBFeelessSetup {
|
|
8
|
-
address _feeLess = makeAddr("something");
|
|
9
|
-
|
|
10
|
-
function setUp() public {
|
|
11
|
-
super.feelessAddressesSetup();
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
function test_WhenCallerIsOwner() external {
|
|
15
|
-
// it should set isFeeless and emit SetFeelessAddress
|
|
16
|
-
vm.expectEmit();
|
|
17
|
-
emit IJBFeelessAddresses.SetFeelessAddress(_feeLess, true, address(_owner));
|
|
18
|
-
|
|
19
|
-
vm.prank(_owner);
|
|
20
|
-
_feelessAddresses.setFeelessAddress(_feeLess, true);
|
|
21
|
-
|
|
22
|
-
bool result = _feelessAddresses.isFeeless(_feeLess);
|
|
23
|
-
assertEq(result, true);
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
function test_RevertIf_RevertWhen_CallerIsNotOwner() external {
|
|
27
|
-
address _multisig = makeAddr("multisig");
|
|
28
|
-
vm.prank(_multisig);
|
|
29
|
-
// it should revert 0x7FA9385bE102ac3EAc297483Dd6233D62b3e1496
|
|
30
|
-
bytes4 selector = bytes4(keccak256("OwnableUnauthorizedAccount(address)"));
|
|
31
|
-
bytes memory expectedError = abi.encodeWithSelector(selector, _multisig);
|
|
32
|
-
vm.expectRevert(expectedError);
|
|
33
|
-
_feelessAddresses.setFeelessAddress(_feeLess, true);
|
|
34
|
-
}
|
|
35
|
-
}
|
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
// SPDX-License-Identifier: MIT
|
|
2
|
-
pragma solidity 0.8.28;
|
|
3
|
-
|
|
4
|
-
import {JBConstants} from "../../../../src/libraries/JBConstants.sol";
|
|
5
|
-
import {JBTest} from "../../../helpers/JBTest.sol";
|
|
6
|
-
import {JBFees} from "../../../../src/libraries/JBFees.sol";
|
|
7
|
-
|
|
8
|
-
/// @notice Fuzz tests for the JBFees library.
|
|
9
|
-
contract TestFeesFuzz_Local is JBTest {
|
|
10
|
-
function setUp() external {}
|
|
11
|
-
|
|
12
|
-
/// @notice feeAmountFrom with feePercent=0 returns 0.
|
|
13
|
-
function testFuzz_feeAmountFrom_zeroPercent(uint256 amount) external pure {
|
|
14
|
-
amount = bound(amount, 0, type(uint128).max);
|
|
15
|
-
uint256 fee = JBFees.feeAmountFrom(amount, 0);
|
|
16
|
-
assertEq(fee, 0, "fee with 0% should be 0");
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
/// @notice feeAmountFrom with amount=0 returns 0.
|
|
20
|
-
function testFuzz_feeAmountFrom_zeroAmount(uint256 feePercent) external pure {
|
|
21
|
-
feePercent = bound(feePercent, 0, JBConstants.MAX_FEE);
|
|
22
|
-
uint256 fee = JBFees.feeAmountFrom(0, feePercent);
|
|
23
|
-
assertEq(fee, 0, "fee on 0 amount should be 0");
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
/// @notice fee + remainder == amount (conservation).
|
|
27
|
-
/// @dev feeAmountFrom(amount, percent) + (amount - feeAmountFrom(amount, percent)) == amount
|
|
28
|
-
function testFuzz_feeAmountFrom_conservation(uint256 amount, uint256 feePercent) external pure {
|
|
29
|
-
amount = bound(amount, 0, type(uint128).max);
|
|
30
|
-
feePercent = bound(feePercent, 0, JBConstants.MAX_FEE);
|
|
31
|
-
|
|
32
|
-
uint256 fee = JBFees.feeAmountFrom(amount, feePercent);
|
|
33
|
-
uint256 remainder = amount - fee;
|
|
34
|
-
|
|
35
|
-
assertEq(fee + remainder, amount, "fee + remainder must equal amount");
|
|
36
|
-
assertLe(fee, amount, "fee must not exceed amount");
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
/// @notice fee is monotonically increasing with amount (for fixed percent).
|
|
40
|
-
function testFuzz_feeAmountFrom_monotonic(uint256 amount1, uint256 amount2, uint256 feePercent) external pure {
|
|
41
|
-
amount1 = bound(amount1, 0, type(uint64).max);
|
|
42
|
-
amount2 = bound(amount2, amount1, type(uint64).max);
|
|
43
|
-
feePercent = bound(feePercent, 0, JBConstants.MAX_FEE);
|
|
44
|
-
|
|
45
|
-
uint256 fee1 = JBFees.feeAmountFrom(amount1, feePercent);
|
|
46
|
-
uint256 fee2 = JBFees.feeAmountFrom(amount2, feePercent);
|
|
47
|
-
|
|
48
|
-
assertLe(fee1, fee2, "fee should be monotonically increasing with amount");
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
/// @notice feeAmountFrom and feeAmountResultingIn are directionally consistent.
|
|
52
|
-
/// @dev feeAmountResultingIn(afterFee, percent) >= fee from feeAmountFrom.
|
|
53
|
-
/// The reverse operation should always produce a fee that covers the forward fee.
|
|
54
|
-
function testFuzz_feeSymmetry(uint256 amount, uint256 feePercent) external pure {
|
|
55
|
-
amount = bound(amount, 1, type(uint64).max);
|
|
56
|
-
feePercent = bound(feePercent, 1, JBConstants.MAX_FEE - 1); // Avoid 0% and 100%
|
|
57
|
-
|
|
58
|
-
// Forward: calculate fee from amount
|
|
59
|
-
uint256 fee = JBFees.feeAmountFrom(amount, feePercent);
|
|
60
|
-
uint256 afterFee = amount - fee;
|
|
61
|
-
|
|
62
|
-
// Reverse: from afterFee, what fee would produce afterFee as the result?
|
|
63
|
-
uint256 reverseFee = JBFees.feeAmountResultingIn(afterFee, feePercent);
|
|
64
|
-
|
|
65
|
-
// The reverse fee should always be >= the forward fee (it rounds up to ensure
|
|
66
|
-
// the total with fee >= the original amount).
|
|
67
|
-
assertGe(reverseFee, fee, "reverse fee should be >= forward fee");
|
|
68
|
-
|
|
69
|
-
// And the total should be >= the original amount (reverse is conservative)
|
|
70
|
-
assertGe(reverseFee + afterFee, amount, "reverse fee + afterFee should be >= amount");
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
/// @notice feeAmountFrom with MAX_FEE returns the full amount.
|
|
74
|
-
function testFuzz_feeAmountFrom_maxPercent(uint256 amount) external pure {
|
|
75
|
-
amount = bound(amount, 0, type(uint128).max);
|
|
76
|
-
uint256 fee = JBFees.feeAmountFrom(amount, JBConstants.MAX_FEE);
|
|
77
|
-
assertEq(fee, amount, "fee at MAX_FEE should equal amount");
|
|
78
|
-
}
|
|
79
|
-
}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
// SPDX-License-Identifier: MIT
|
|
2
|
-
pragma solidity 0.8.28;
|
|
3
|
-
|
|
4
|
-
import {JBTest} from "../../../helpers/JBTest.sol";
|
|
5
|
-
import {JBFixedPointNumber} from "../../../../src/libraries/JBFixedPointNumber.sol";
|
|
6
|
-
|
|
7
|
-
contract TestAdjustDecimals_Local is JBTest {
|
|
8
|
-
function setUp() external {}
|
|
9
|
-
|
|
10
|
-
function testWhenTargetEqDecimals() external pure {
|
|
11
|
-
// it will return the value parameter provided
|
|
12
|
-
|
|
13
|
-
uint256 returned = JBFixedPointNumber.adjustDecimals(1e18, 6, 6);
|
|
14
|
-
assertEq(returned, 1e18);
|
|
15
|
-
}
|
|
16
|
-
}
|
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
// SPDX-License-Identifier: MIT
|
|
2
|
-
pragma solidity 0.8.28;
|
|
3
|
-
|
|
4
|
-
import {JBTest} from "../../../helpers/JBTest.sol";
|
|
5
|
-
import {JBFixedPointNumber} from "../../../../src/libraries/JBFixedPointNumber.sol";
|
|
6
|
-
|
|
7
|
-
/// @notice Fuzz tests for JBFixedPointNumber.adjustDecimals.
|
|
8
|
-
contract TestAdjustDecimalsFuzz_Local is JBTest {
|
|
9
|
-
function setUp() external {}
|
|
10
|
-
|
|
11
|
-
/// @notice Same decimals returns the value unchanged.
|
|
12
|
-
function testFuzz_sameDecimals(uint256 value, uint8 decimals) external pure {
|
|
13
|
-
decimals = uint8(bound(uint256(decimals), 0, 36));
|
|
14
|
-
uint256 result = JBFixedPointNumber.adjustDecimals(value, decimals, decimals);
|
|
15
|
-
assertEq(result, value, "same decimals should return value unchanged");
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
/// @notice Scale up then down round-trip preserves value (modulo rounding loss).
|
|
19
|
-
function testFuzz_roundTrip_upThenDown(uint256 value, uint8 fromDecimals, uint8 toDecimals) external pure {
|
|
20
|
-
fromDecimals = uint8(bound(uint256(fromDecimals), 0, 18));
|
|
21
|
-
toDecimals = uint8(bound(uint256(toDecimals), fromDecimals, 36));
|
|
22
|
-
|
|
23
|
-
// Avoid overflow: value * 10^(toDecimals - fromDecimals) must fit in uint256
|
|
24
|
-
uint256 scaleFactor = 10 ** (toDecimals - fromDecimals);
|
|
25
|
-
if (scaleFactor > 0 && value > type(uint256).max / scaleFactor) return;
|
|
26
|
-
|
|
27
|
-
uint256 scaled = JBFixedPointNumber.adjustDecimals(value, fromDecimals, toDecimals);
|
|
28
|
-
uint256 restored = JBFixedPointNumber.adjustDecimals(scaled, toDecimals, fromDecimals);
|
|
29
|
-
|
|
30
|
-
assertEq(restored, value, "round trip (up then down) should restore original value");
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
/// @notice Scale down then up loses precision but never exceeds original.
|
|
34
|
-
function testFuzz_roundTrip_downThenUp(uint256 value, uint8 fromDecimals, uint8 toDecimals) external pure {
|
|
35
|
-
fromDecimals = uint8(bound(uint256(fromDecimals), 0, 36));
|
|
36
|
-
toDecimals = uint8(bound(uint256(toDecimals), 0, fromDecimals));
|
|
37
|
-
|
|
38
|
-
uint256 scaled = JBFixedPointNumber.adjustDecimals(value, fromDecimals, toDecimals);
|
|
39
|
-
|
|
40
|
-
// Scale back up
|
|
41
|
-
uint256 scaleFactor = 10 ** (fromDecimals - toDecimals);
|
|
42
|
-
if (scaleFactor > 0 && scaled > type(uint256).max / scaleFactor) return;
|
|
43
|
-
|
|
44
|
-
uint256 restored = JBFixedPointNumber.adjustDecimals(scaled, toDecimals, fromDecimals);
|
|
45
|
-
|
|
46
|
-
assertLe(restored, value, "round trip (down then up) should not exceed original");
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
/// @notice Scaling up increases value when decimals differ.
|
|
50
|
-
function testFuzz_scaleUp_increases(uint256 value, uint8 fromDecimals, uint8 toDecimals) external pure {
|
|
51
|
-
value = bound(value, 1, 1e36);
|
|
52
|
-
fromDecimals = uint8(bound(uint256(fromDecimals), 0, 18));
|
|
53
|
-
toDecimals = uint8(bound(uint256(toDecimals), fromDecimals + 1, 36));
|
|
54
|
-
|
|
55
|
-
uint256 result = JBFixedPointNumber.adjustDecimals(value, fromDecimals, toDecimals);
|
|
56
|
-
assertGt(result, value, "scaling up with more decimals should increase value");
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
/// @notice Scaling down returns zero for small values.
|
|
60
|
-
function testFuzz_scaleDown_smallValue(uint8 fromDecimals, uint8 toDecimals) external pure {
|
|
61
|
-
fromDecimals = uint8(bound(uint256(fromDecimals), 1, 36));
|
|
62
|
-
toDecimals = uint8(bound(uint256(toDecimals), 0, fromDecimals - 1));
|
|
63
|
-
|
|
64
|
-
uint256 scaleFactor = 10 ** (fromDecimals - toDecimals);
|
|
65
|
-
// Value smaller than the scale factor should round to 0
|
|
66
|
-
uint256 value = scaleFactor - 1;
|
|
67
|
-
|
|
68
|
-
uint256 result = JBFixedPointNumber.adjustDecimals(value, fromDecimals, toDecimals);
|
|
69
|
-
assertEq(result, 0, "value below scale factor should round to 0");
|
|
70
|
-
}
|
|
71
|
-
}
|