@bananapus/721-hook-v6 0.0.11 → 0.0.13
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/ADMINISTRATION.md +151 -0
- package/ARCHITECTURE.md +70 -0
- package/RISKS.md +311 -0
- package/SKILLS.md +6 -6
- package/STYLE_GUIDE.md +470 -0
- package/foundry.toml +1 -1
- package/package.json +5 -5
- package/script/Deploy.s.sol +2 -2
- package/src/JB721TiersHook.sol +15 -5
- package/src/interfaces/IJB721TiersHook.sol +5 -0
- package/src/libraries/JB721TiersHookLib.sol +39 -11
- package/test/E2E/Pay_Mint_Redeem_E2E.t.sol +3 -1
- package/test/Fork.t.sol +2272 -0
- package/test/regression/L36_SplitNoBeneficiary.t.sol +2 -10
- package/test/unit/adjustTier_Unit.t.sol +119 -98
- package/test/unit/tierSplitRouting_Unit.t.sol +2 -10
|
@@ -7,7 +7,6 @@ import {JB721TiersHookLib} from "../../src/libraries/JB721TiersHookLib.sol";
|
|
|
7
7
|
import {JBSplit} from "@bananapus/core-v6/src/structs/JBSplit.sol";
|
|
8
8
|
import {IJBSplitHook} from "@bananapus/core-v6/src/interfaces/IJBSplitHook.sol";
|
|
9
9
|
import {IJBSplits} from "@bananapus/core-v6/src/interfaces/IJBSplits.sol";
|
|
10
|
-
import {IJBController} from "@bananapus/core-v6/src/interfaces/IJBController.sol";
|
|
11
10
|
import {IJBTerminal} from "@bananapus/core-v6/src/interfaces/IJBTerminal.sol";
|
|
12
11
|
|
|
13
12
|
/// @notice Split with no beneficiary and no projectId should route funds to the project's
|
|
@@ -15,12 +14,11 @@ import {IJBTerminal} from "@bananapus/core-v6/src/interfaces/IJBTerminal.sol";
|
|
|
15
14
|
contract Test_L36_SplitNoBeneficiary is UnitTestSetup {
|
|
16
15
|
using stdStorage for StdStorage;
|
|
17
16
|
|
|
18
|
-
address mockSplits = makeAddr("mockSplits");
|
|
19
17
|
address mockProjectTerminal = makeAddr("mockProjectTerminal");
|
|
20
18
|
|
|
21
19
|
function setUp() public override {
|
|
22
20
|
super.setUp();
|
|
23
|
-
vm.etch(
|
|
21
|
+
vm.etch(mockJBSplits, new bytes(0x69));
|
|
24
22
|
vm.etch(mockProjectTerminal, new bytes(0x69));
|
|
25
23
|
}
|
|
26
24
|
|
|
@@ -47,12 +45,6 @@ contract Test_L36_SplitNoBeneficiary is UnitTestSetup {
|
|
|
47
45
|
abi.encodeWithSelector(IJBDirectory.isTerminalOf.selector, projectId, mockTerminalAddress),
|
|
48
46
|
abi.encode(true)
|
|
49
47
|
);
|
|
50
|
-
mockAndExpect(
|
|
51
|
-
address(mockJBDirectory),
|
|
52
|
-
abi.encodeWithSelector(IJBDirectory.controllerOf.selector, projectId),
|
|
53
|
-
abi.encode(mockJBController)
|
|
54
|
-
);
|
|
55
|
-
mockAndExpect(mockJBController, abi.encodeWithSelector(IJBController.SPLITS.selector), abi.encode(mockSplits));
|
|
56
48
|
|
|
57
49
|
// Mock splits: a split with projectId==0 and beneficiary==address(0).
|
|
58
50
|
JBSplit[] memory splits = new JBSplit[](1);
|
|
@@ -67,7 +59,7 @@ contract Test_L36_SplitNoBeneficiary is UnitTestSetup {
|
|
|
67
59
|
|
|
68
60
|
uint256 groupId = uint256(uint160(address(testHook))) | (uint256(tierIds[0]) << 160);
|
|
69
61
|
mockAndExpect(
|
|
70
|
-
|
|
62
|
+
mockJBSplits, abi.encodeWithSelector(IJBSplits.splitsOf.selector, projectId, 0, groupId), abi.encode(splits)
|
|
71
63
|
);
|
|
72
64
|
|
|
73
65
|
// Mock the project's primary terminal for addToBalanceOf (this is the fallback for no-recipient splits).
|
|
@@ -573,23 +573,26 @@ contract Test_adjustTier_Unit is UnitTestSetup {
|
|
|
573
573
|
}
|
|
574
574
|
ForTest_JB721TiersHookStore store = new ForTest_JB721TiersHookStore();
|
|
575
575
|
ForTest_JB721TiersHook hook = new ForTest_JB721TiersHook(
|
|
576
|
-
|
|
576
|
+
ForTest_JB721TiersHook.ForTestInitConfig({
|
|
577
|
+
projectId: projectId,
|
|
578
|
+
name: name,
|
|
579
|
+
symbol: symbol,
|
|
580
|
+
baseUri: baseUri,
|
|
581
|
+
tokenUriResolver: IJB721TokenUriResolver(mockTokenUriResolver),
|
|
582
|
+
contractUri: contractUri,
|
|
583
|
+
tiers: tierConfigs,
|
|
584
|
+
flags: JB721TiersHookFlags({
|
|
585
|
+
preventOverspending: false,
|
|
586
|
+
issueTokensForSplits: false,
|
|
587
|
+
noNewTiersWithReserves: false,
|
|
588
|
+
noNewTiersWithVotes: false,
|
|
589
|
+
noNewTiersWithOwnerMinting: true
|
|
590
|
+
})
|
|
591
|
+
}),
|
|
577
592
|
IJBDirectory(mockJBDirectory),
|
|
578
|
-
name,
|
|
579
|
-
symbol,
|
|
580
593
|
IJBRulesets(mockJBRulesets),
|
|
581
|
-
baseUri,
|
|
582
|
-
IJB721TokenUriResolver(mockTokenUriResolver),
|
|
583
|
-
contractUri,
|
|
584
|
-
tierConfigs,
|
|
585
594
|
IJB721TiersHookStore(address(store)),
|
|
586
|
-
|
|
587
|
-
preventOverspending: false,
|
|
588
|
-
issueTokensForSplits: false,
|
|
589
|
-
noNewTiersWithReserves: false,
|
|
590
|
-
noNewTiersWithVotes: false,
|
|
591
|
-
noNewTiersWithOwnerMinting: true
|
|
592
|
-
})
|
|
595
|
+
IJBSplits(mockJBSplits)
|
|
593
596
|
);
|
|
594
597
|
hook.transferOwnership(owner);
|
|
595
598
|
|
|
@@ -894,23 +897,26 @@ contract Test_adjustTier_Unit is UnitTestSetup {
|
|
|
894
897
|
}
|
|
895
898
|
ForTest_JB721TiersHookStore store = new ForTest_JB721TiersHookStore();
|
|
896
899
|
ForTest_JB721TiersHook hook = new ForTest_JB721TiersHook(
|
|
897
|
-
|
|
900
|
+
ForTest_JB721TiersHook.ForTestInitConfig({
|
|
901
|
+
projectId: projectId,
|
|
902
|
+
name: name,
|
|
903
|
+
symbol: symbol,
|
|
904
|
+
baseUri: baseUri,
|
|
905
|
+
tokenUriResolver: IJB721TokenUriResolver(mockTokenUriResolver),
|
|
906
|
+
contractUri: contractUri,
|
|
907
|
+
tiers: tierConfigs,
|
|
908
|
+
flags: JB721TiersHookFlags({
|
|
909
|
+
preventOverspending: false,
|
|
910
|
+
issueTokensForSplits: false,
|
|
911
|
+
noNewTiersWithReserves: false,
|
|
912
|
+
noNewTiersWithVotes: true,
|
|
913
|
+
noNewTiersWithOwnerMinting: true
|
|
914
|
+
})
|
|
915
|
+
}),
|
|
898
916
|
IJBDirectory(mockJBDirectory),
|
|
899
|
-
name,
|
|
900
|
-
symbol,
|
|
901
917
|
IJBRulesets(mockJBRulesets),
|
|
902
|
-
baseUri,
|
|
903
|
-
IJB721TokenUriResolver(mockTokenUriResolver),
|
|
904
|
-
contractUri,
|
|
905
|
-
tierConfigs,
|
|
906
918
|
IJB721TiersHookStore(address(store)),
|
|
907
|
-
|
|
908
|
-
preventOverspending: false,
|
|
909
|
-
issueTokensForSplits: false,
|
|
910
|
-
noNewTiersWithReserves: false,
|
|
911
|
-
noNewTiersWithVotes: true,
|
|
912
|
-
noNewTiersWithOwnerMinting: true
|
|
913
|
-
})
|
|
919
|
+
IJBSplits(mockJBSplits)
|
|
914
920
|
);
|
|
915
921
|
hook.transferOwnership(owner);
|
|
916
922
|
JB721TierConfig[] memory tierConfigsToAdd = new JB721TierConfig[](numberTiersToAdd);
|
|
@@ -1014,23 +1020,26 @@ contract Test_adjustTier_Unit is UnitTestSetup {
|
|
|
1014
1020
|
}
|
|
1015
1021
|
ForTest_JB721TiersHookStore store = new ForTest_JB721TiersHookStore();
|
|
1016
1022
|
ForTest_JB721TiersHook hook = new ForTest_JB721TiersHook(
|
|
1017
|
-
|
|
1023
|
+
ForTest_JB721TiersHook.ForTestInitConfig({
|
|
1024
|
+
projectId: projectId,
|
|
1025
|
+
name: name,
|
|
1026
|
+
symbol: symbol,
|
|
1027
|
+
baseUri: baseUri,
|
|
1028
|
+
tokenUriResolver: IJB721TokenUriResolver(mockTokenUriResolver),
|
|
1029
|
+
contractUri: contractUri,
|
|
1030
|
+
tiers: tierConfigs,
|
|
1031
|
+
flags: JB721TiersHookFlags({
|
|
1032
|
+
preventOverspending: false,
|
|
1033
|
+
issueTokensForSplits: false,
|
|
1034
|
+
noNewTiersWithReserves: true, // <-- This is the flag we're testing.
|
|
1035
|
+
noNewTiersWithVotes: false,
|
|
1036
|
+
noNewTiersWithOwnerMinting: true
|
|
1037
|
+
})
|
|
1038
|
+
}),
|
|
1018
1039
|
IJBDirectory(mockJBDirectory),
|
|
1019
|
-
name,
|
|
1020
|
-
symbol,
|
|
1021
1040
|
IJBRulesets(mockJBRulesets),
|
|
1022
|
-
baseUri,
|
|
1023
|
-
IJB721TokenUriResolver(mockTokenUriResolver),
|
|
1024
|
-
contractUri,
|
|
1025
|
-
tierConfigs,
|
|
1026
1041
|
IJB721TiersHookStore(address(store)),
|
|
1027
|
-
|
|
1028
|
-
preventOverspending: false,
|
|
1029
|
-
issueTokensForSplits: false,
|
|
1030
|
-
noNewTiersWithReserves: true, // <-- This is the flag we're testing.
|
|
1031
|
-
noNewTiersWithVotes: false,
|
|
1032
|
-
noNewTiersWithOwnerMinting: true
|
|
1033
|
-
})
|
|
1042
|
+
IJBSplits(mockJBSplits)
|
|
1034
1043
|
);
|
|
1035
1044
|
hook.transferOwnership(owner);
|
|
1036
1045
|
JB721TierConfig[] memory tierConfigsToAdd = new JB721TierConfig[](numberTiersToAdd);
|
|
@@ -1206,23 +1215,26 @@ contract Test_adjustTier_Unit is UnitTestSetup {
|
|
|
1206
1215
|
}
|
|
1207
1216
|
ForTest_JB721TiersHookStore store = new ForTest_JB721TiersHookStore();
|
|
1208
1217
|
ForTest_JB721TiersHook hook = new ForTest_JB721TiersHook(
|
|
1209
|
-
|
|
1218
|
+
ForTest_JB721TiersHook.ForTestInitConfig({
|
|
1219
|
+
projectId: projectId,
|
|
1220
|
+
name: name,
|
|
1221
|
+
symbol: symbol,
|
|
1222
|
+
baseUri: baseUri,
|
|
1223
|
+
tokenUriResolver: IJB721TokenUriResolver(mockTokenUriResolver),
|
|
1224
|
+
contractUri: contractUri,
|
|
1225
|
+
tiers: tierConfigs,
|
|
1226
|
+
flags: JB721TiersHookFlags({
|
|
1227
|
+
preventOverspending: false,
|
|
1228
|
+
issueTokensForSplits: false,
|
|
1229
|
+
noNewTiersWithReserves: false,
|
|
1230
|
+
noNewTiersWithVotes: false,
|
|
1231
|
+
noNewTiersWithOwnerMinting: true
|
|
1232
|
+
})
|
|
1233
|
+
}),
|
|
1210
1234
|
IJBDirectory(mockJBDirectory),
|
|
1211
|
-
name,
|
|
1212
|
-
symbol,
|
|
1213
1235
|
IJBRulesets(mockJBRulesets),
|
|
1214
|
-
baseUri,
|
|
1215
|
-
IJB721TokenUriResolver(mockTokenUriResolver),
|
|
1216
|
-
contractUri,
|
|
1217
|
-
tierConfigs,
|
|
1218
1236
|
IJB721TiersHookStore(address(store)),
|
|
1219
|
-
|
|
1220
|
-
preventOverspending: false,
|
|
1221
|
-
issueTokensForSplits: false,
|
|
1222
|
-
noNewTiersWithReserves: false,
|
|
1223
|
-
noNewTiersWithVotes: false,
|
|
1224
|
-
noNewTiersWithOwnerMinting: true
|
|
1225
|
-
})
|
|
1237
|
+
IJBSplits(mockJBSplits)
|
|
1226
1238
|
);
|
|
1227
1239
|
hook.transferOwnership(owner);
|
|
1228
1240
|
JB721TierConfig[] memory tierConfigsToAdd = new JB721TierConfig[](numberTiersToAdd);
|
|
@@ -1353,23 +1365,26 @@ contract Test_adjustTier_Unit is UnitTestSetup {
|
|
|
1353
1365
|
|
|
1354
1366
|
ForTest_JB721TiersHookStore store = new ForTest_JB721TiersHookStore();
|
|
1355
1367
|
ForTest_JB721TiersHook hook = new ForTest_JB721TiersHook(
|
|
1356
|
-
|
|
1368
|
+
ForTest_JB721TiersHook.ForTestInitConfig({
|
|
1369
|
+
projectId: projectId,
|
|
1370
|
+
name: name,
|
|
1371
|
+
symbol: symbol,
|
|
1372
|
+
baseUri: baseUri,
|
|
1373
|
+
tokenUriResolver: IJB721TokenUriResolver(mockTokenUriResolver),
|
|
1374
|
+
contractUri: contractUri,
|
|
1375
|
+
tiers: tierConfigs,
|
|
1376
|
+
flags: JB721TiersHookFlags({
|
|
1377
|
+
preventOverspending: false,
|
|
1378
|
+
issueTokensForSplits: false,
|
|
1379
|
+
noNewTiersWithReserves: false,
|
|
1380
|
+
noNewTiersWithVotes: true, // <-- This is the flag we're testing.
|
|
1381
|
+
noNewTiersWithOwnerMinting: true
|
|
1382
|
+
})
|
|
1383
|
+
}),
|
|
1357
1384
|
IJBDirectory(mockJBDirectory),
|
|
1358
|
-
name,
|
|
1359
|
-
symbol,
|
|
1360
1385
|
IJBRulesets(mockJBRulesets),
|
|
1361
|
-
baseUri,
|
|
1362
|
-
IJB721TokenUriResolver(mockTokenUriResolver),
|
|
1363
|
-
contractUri,
|
|
1364
|
-
tierConfigs,
|
|
1365
1386
|
IJB721TiersHookStore(address(store)),
|
|
1366
|
-
|
|
1367
|
-
preventOverspending: false,
|
|
1368
|
-
issueTokensForSplits: false,
|
|
1369
|
-
noNewTiersWithReserves: false,
|
|
1370
|
-
noNewTiersWithVotes: true, // <-- This is the flag we're testing.
|
|
1371
|
-
noNewTiersWithOwnerMinting: true
|
|
1372
|
-
})
|
|
1387
|
+
IJBSplits(mockJBSplits)
|
|
1373
1388
|
);
|
|
1374
1389
|
hook.transferOwnership(owner);
|
|
1375
1390
|
|
|
@@ -1439,23 +1454,26 @@ contract Test_adjustTier_Unit is UnitTestSetup {
|
|
|
1439
1454
|
|
|
1440
1455
|
ForTest_JB721TiersHookStore store = new ForTest_JB721TiersHookStore();
|
|
1441
1456
|
ForTest_JB721TiersHook hook = new ForTest_JB721TiersHook(
|
|
1442
|
-
|
|
1457
|
+
ForTest_JB721TiersHook.ForTestInitConfig({
|
|
1458
|
+
projectId: projectId,
|
|
1459
|
+
name: name,
|
|
1460
|
+
symbol: symbol,
|
|
1461
|
+
baseUri: baseUri,
|
|
1462
|
+
tokenUriResolver: IJB721TokenUriResolver(mockTokenUriResolver),
|
|
1463
|
+
contractUri: contractUri,
|
|
1464
|
+
tiers: tierConfigs,
|
|
1465
|
+
flags: JB721TiersHookFlags({
|
|
1466
|
+
preventOverspending: false,
|
|
1467
|
+
issueTokensForSplits: false,
|
|
1468
|
+
noNewTiersWithReserves: false,
|
|
1469
|
+
noNewTiersWithVotes: true, // <-- This is the flag we're testing.
|
|
1470
|
+
noNewTiersWithOwnerMinting: true
|
|
1471
|
+
})
|
|
1472
|
+
}),
|
|
1443
1473
|
IJBDirectory(mockJBDirectory),
|
|
1444
|
-
name,
|
|
1445
|
-
symbol,
|
|
1446
1474
|
IJBRulesets(mockJBRulesets),
|
|
1447
|
-
baseUri,
|
|
1448
|
-
IJB721TokenUriResolver(mockTokenUriResolver),
|
|
1449
|
-
contractUri,
|
|
1450
|
-
tierConfigs,
|
|
1451
1475
|
IJB721TiersHookStore(address(store)),
|
|
1452
|
-
|
|
1453
|
-
preventOverspending: false,
|
|
1454
|
-
issueTokensForSplits: false,
|
|
1455
|
-
noNewTiersWithReserves: false,
|
|
1456
|
-
noNewTiersWithVotes: true, // <-- This is the flag we're testing.
|
|
1457
|
-
noNewTiersWithOwnerMinting: true
|
|
1458
|
-
})
|
|
1476
|
+
IJBSplits(mockJBSplits)
|
|
1459
1477
|
);
|
|
1460
1478
|
hook.transferOwnership(owner);
|
|
1461
1479
|
|
|
@@ -1574,23 +1592,26 @@ contract Test_adjustTier_Unit is UnitTestSetup {
|
|
|
1574
1592
|
}
|
|
1575
1593
|
ForTest_JB721TiersHookStore store = new ForTest_JB721TiersHookStore();
|
|
1576
1594
|
ForTest_JB721TiersHook hook = new ForTest_JB721TiersHook(
|
|
1577
|
-
|
|
1595
|
+
ForTest_JB721TiersHook.ForTestInitConfig({
|
|
1596
|
+
projectId: projectId,
|
|
1597
|
+
name: name,
|
|
1598
|
+
symbol: symbol,
|
|
1599
|
+
baseUri: baseUri,
|
|
1600
|
+
tokenUriResolver: IJB721TokenUriResolver(mockTokenUriResolver),
|
|
1601
|
+
contractUri: contractUri,
|
|
1602
|
+
tiers: tierConfigs,
|
|
1603
|
+
flags: JB721TiersHookFlags({
|
|
1604
|
+
preventOverspending: false,
|
|
1605
|
+
issueTokensForSplits: false,
|
|
1606
|
+
noNewTiersWithReserves: false,
|
|
1607
|
+
noNewTiersWithVotes: false,
|
|
1608
|
+
noNewTiersWithOwnerMinting: true
|
|
1609
|
+
})
|
|
1610
|
+
}),
|
|
1578
1611
|
IJBDirectory(mockJBDirectory),
|
|
1579
|
-
name,
|
|
1580
|
-
symbol,
|
|
1581
1612
|
IJBRulesets(mockJBRulesets),
|
|
1582
|
-
baseUri,
|
|
1583
|
-
IJB721TokenUriResolver(mockTokenUriResolver),
|
|
1584
|
-
contractUri,
|
|
1585
|
-
tierConfigs,
|
|
1586
1613
|
IJB721TiersHookStore(address(store)),
|
|
1587
|
-
|
|
1588
|
-
preventOverspending: false,
|
|
1589
|
-
issueTokensForSplits: false,
|
|
1590
|
-
noNewTiersWithReserves: false,
|
|
1591
|
-
noNewTiersWithVotes: false,
|
|
1592
|
-
noNewTiersWithOwnerMinting: true
|
|
1593
|
-
})
|
|
1614
|
+
IJBSplits(mockJBSplits)
|
|
1594
1615
|
);
|
|
1595
1616
|
hook.transferOwnership(owner);
|
|
1596
1617
|
// Will be resized later
|
|
@@ -6,7 +6,6 @@ import {IJB721TiersHookStore} from "../../src/interfaces/IJB721TiersHookStore.so
|
|
|
6
6
|
import {JBSplit} from "@bananapus/core-v6/src/structs/JBSplit.sol";
|
|
7
7
|
import {IJBSplitHook} from "@bananapus/core-v6/src/interfaces/IJBSplitHook.sol";
|
|
8
8
|
import {IJBSplits} from "@bananapus/core-v6/src/interfaces/IJBSplits.sol";
|
|
9
|
-
import {IJBController} from "@bananapus/core-v6/src/interfaces/IJBController.sol";
|
|
10
9
|
import {JB721TiersHookFlags} from "../../src/structs/JB721TiersHookFlags.sol";
|
|
11
10
|
|
|
12
11
|
contract Test_TierSplitRouting is UnitTestSetup {
|
|
@@ -14,11 +13,10 @@ contract Test_TierSplitRouting is UnitTestSetup {
|
|
|
14
13
|
|
|
15
14
|
address alice = makeAddr("alice");
|
|
16
15
|
address bob = makeAddr("bob");
|
|
17
|
-
address mockSplits = makeAddr("mockSplits");
|
|
18
16
|
|
|
19
17
|
function setUp() public override {
|
|
20
18
|
super.setUp();
|
|
21
|
-
vm.etch(
|
|
19
|
+
vm.etch(mockJBSplits, new bytes(0x69));
|
|
22
20
|
}
|
|
23
21
|
|
|
24
22
|
// Helper: build a tier config with splits.
|
|
@@ -320,12 +318,6 @@ contract Test_TierSplitRouting is UnitTestSetup {
|
|
|
320
318
|
abi.encodeWithSelector(IJBDirectory.isTerminalOf.selector, projectId, mockTerminalAddress),
|
|
321
319
|
abi.encode(true)
|
|
322
320
|
);
|
|
323
|
-
mockAndExpect(
|
|
324
|
-
address(mockJBDirectory),
|
|
325
|
-
abi.encodeWithSelector(IJBDirectory.controllerOf.selector, projectId),
|
|
326
|
-
abi.encode(mockJBController)
|
|
327
|
-
);
|
|
328
|
-
mockAndExpect(mockJBController, abi.encodeWithSelector(IJBController.SPLITS.selector), abi.encode(mockSplits));
|
|
329
321
|
|
|
330
322
|
// Mock splits: alice gets 100%.
|
|
331
323
|
JBSplit[] memory splits = new JBSplit[](1);
|
|
@@ -340,7 +332,7 @@ contract Test_TierSplitRouting is UnitTestSetup {
|
|
|
340
332
|
|
|
341
333
|
uint256 groupId = uint256(uint160(address(testHook))) | (uint256(tierIds[0]) << 160);
|
|
342
334
|
mockAndExpect(
|
|
343
|
-
|
|
335
|
+
mockJBSplits, abi.encodeWithSelector(IJBSplits.splitsOf.selector, projectId, 0, groupId), abi.encode(splits)
|
|
344
336
|
);
|
|
345
337
|
|
|
346
338
|
// Build payer metadata.
|