@bananapus/721-hook-v6 0.0.1 → 0.0.2
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/package.json +1 -1
- package/src/JB721TiersHook.sol +236 -146
- package/src/JB721TiersHookDeployer.sol +1 -0
- package/src/JB721TiersHookStore.sol +17 -4
- package/src/interfaces/IJB721TiersHook.sol +17 -2
- package/src/libraries/JB721TiersHookLib.sol +336 -0
- package/src/structs/JB721Tier.sol +3 -0
- package/src/structs/JB721TierConfig.sol +8 -0
- package/src/structs/JBStored721Tier.sol +5 -4
- package/test/721HookAttacks.t.sol +6 -2
- package/test/E2E/Pay_Mint_Redeem_E2E.t.sol +6 -2
- package/test/invariants/handlers/TierLifecycleHandler.sol +3 -1
- package/test/invariants/handlers/TierStoreHandler.sol +4 -1
- package/test/unit/adjustTier_Unit.t.sol +75 -22
- package/test/unit/getters_constructor_Unit.t.sol +14 -9
- package/test/unit/mintFor_mintReservesFor_Unit.t.sol +12 -12
- package/test/unit/pay_Unit.t.sol +6 -10
- package/test/unit/redeem_Unit.t.sol +13 -11
- package/test/unit/tierSplitRouting_Unit.t.sol +275 -0
- package/src/abstract/JB721Hook.sol +0 -279
- package/src/interfaces/IJB721Hook.sol +0 -21
|
@@ -548,7 +548,9 @@ contract Test_adjustTier_Unit is UnitTestSetup {
|
|
|
548
548
|
transfersPausable: false,
|
|
549
549
|
useVotingUnits: true,
|
|
550
550
|
cannotBeRemoved: false,
|
|
551
|
-
cannotIncreaseDiscountPercent: false
|
|
551
|
+
cannotIncreaseDiscountPercent: false,
|
|
552
|
+
splitPercent: 0,
|
|
553
|
+
splits: new JBSplit[](0)
|
|
552
554
|
});
|
|
553
555
|
tiers[i] = JB721Tier({
|
|
554
556
|
id: uint32(i + 1),
|
|
@@ -565,6 +567,7 @@ contract Test_adjustTier_Unit is UnitTestSetup {
|
|
|
565
567
|
transfersPausable: tierConfigs[i].transfersPausable,
|
|
566
568
|
cannotBeRemoved: tierConfigs[i].cannotBeRemoved,
|
|
567
569
|
cannotIncreaseDiscountPercent: tierConfigs[i].cannotIncreaseDiscountPercent,
|
|
570
|
+
splitPercent: 0,
|
|
568
571
|
resolvedUri: ""
|
|
569
572
|
});
|
|
570
573
|
}
|
|
@@ -671,7 +674,9 @@ contract Test_adjustTier_Unit is UnitTestSetup {
|
|
|
671
674
|
transfersPausable: false,
|
|
672
675
|
useVotingUnits: true,
|
|
673
676
|
cannotBeRemoved: false,
|
|
674
|
-
cannotIncreaseDiscountPercent: false
|
|
677
|
+
cannotIncreaseDiscountPercent: false,
|
|
678
|
+
splitPercent: 0,
|
|
679
|
+
splits: new JBSplit[](0)
|
|
675
680
|
});
|
|
676
681
|
tiers[i] = JB721Tier({
|
|
677
682
|
id: uint32(i + 1),
|
|
@@ -688,6 +693,7 @@ contract Test_adjustTier_Unit is UnitTestSetup {
|
|
|
688
693
|
transfersPausable: tierConfigs[i].transfersPausable,
|
|
689
694
|
cannotBeRemoved: tierConfigs[i].cannotBeRemoved,
|
|
690
695
|
cannotIncreaseDiscountPercent: tierConfigs[i].cannotIncreaseDiscountPercent,
|
|
696
|
+
splitPercent: 0,
|
|
691
697
|
resolvedUri: ""
|
|
692
698
|
});
|
|
693
699
|
}
|
|
@@ -737,7 +743,9 @@ contract Test_adjustTier_Unit is UnitTestSetup {
|
|
|
737
743
|
transfersPausable: false,
|
|
738
744
|
useVotingUnits: true,
|
|
739
745
|
cannotBeRemoved: false,
|
|
740
|
-
cannotIncreaseDiscountPercent: false
|
|
746
|
+
cannotIncreaseDiscountPercent: false,
|
|
747
|
+
splitPercent: 0,
|
|
748
|
+
splits: new JBSplit[](0)
|
|
741
749
|
});
|
|
742
750
|
tiersRemaining[arrayIndex] = JB721Tier({
|
|
743
751
|
id: uint32(i + 1),
|
|
@@ -754,6 +762,7 @@ contract Test_adjustTier_Unit is UnitTestSetup {
|
|
|
754
762
|
transfersPausable: tierConfigsRemaining[arrayIndex].transfersPausable,
|
|
755
763
|
cannotBeRemoved: tierConfigsRemaining[arrayIndex].cannotBeRemoved,
|
|
756
764
|
cannotIncreaseDiscountPercent: tierConfigsRemaining[arrayIndex].cannotIncreaseDiscountPercent,
|
|
765
|
+
splitPercent: 0,
|
|
757
766
|
resolvedUri: ""
|
|
758
767
|
});
|
|
759
768
|
arrayIndex++;
|
|
@@ -783,7 +792,9 @@ contract Test_adjustTier_Unit is UnitTestSetup {
|
|
|
783
792
|
transfersPausable: false,
|
|
784
793
|
useVotingUnits: true,
|
|
785
794
|
cannotBeRemoved: false,
|
|
786
|
-
cannotIncreaseDiscountPercent: false
|
|
795
|
+
cannotIncreaseDiscountPercent: false,
|
|
796
|
+
splitPercent: 0,
|
|
797
|
+
splits: new JBSplit[](0)
|
|
787
798
|
});
|
|
788
799
|
tiersAdded[i] = JB721Tier({
|
|
789
800
|
id: uint32(tiers.length + (i + 1)),
|
|
@@ -800,6 +811,7 @@ contract Test_adjustTier_Unit is UnitTestSetup {
|
|
|
800
811
|
transfersPausable: tierConfigsToAdd[i].transfersPausable,
|
|
801
812
|
cannotBeRemoved: tierConfigsToAdd[i].cannotBeRemoved,
|
|
802
813
|
cannotIncreaseDiscountPercent: tierConfigsToAdd[i].cannotIncreaseDiscountPercent,
|
|
814
|
+
splitPercent: 0,
|
|
803
815
|
resolvedUri: ""
|
|
804
816
|
});
|
|
805
817
|
vm.expectEmit(true, true, true, true, address(hook));
|
|
@@ -855,7 +867,9 @@ contract Test_adjustTier_Unit is UnitTestSetup {
|
|
|
855
867
|
transfersPausable: false,
|
|
856
868
|
useVotingUnits: true,
|
|
857
869
|
cannotBeRemoved: false,
|
|
858
|
-
cannotIncreaseDiscountPercent: false
|
|
870
|
+
cannotIncreaseDiscountPercent: false,
|
|
871
|
+
splitPercent: 0,
|
|
872
|
+
splits: new JBSplit[](0)
|
|
859
873
|
});
|
|
860
874
|
tiers[i] = JB721Tier({
|
|
861
875
|
id: uint32(i + 1),
|
|
@@ -872,6 +886,7 @@ contract Test_adjustTier_Unit is UnitTestSetup {
|
|
|
872
886
|
transfersPausable: tierConfigs[i].transfersPausable,
|
|
873
887
|
cannotBeRemoved: tierConfigs[i].cannotBeRemoved,
|
|
874
888
|
cannotIncreaseDiscountPercent: tierConfigs[i].cannotIncreaseDiscountPercent,
|
|
889
|
+
splitPercent: 0,
|
|
875
890
|
resolvedUri: ""
|
|
876
891
|
});
|
|
877
892
|
}
|
|
@@ -912,7 +927,9 @@ contract Test_adjustTier_Unit is UnitTestSetup {
|
|
|
912
927
|
transfersPausable: false,
|
|
913
928
|
useVotingUnits: true,
|
|
914
929
|
cannotBeRemoved: false,
|
|
915
|
-
cannotIncreaseDiscountPercent: false
|
|
930
|
+
cannotIncreaseDiscountPercent: false,
|
|
931
|
+
splitPercent: 0,
|
|
932
|
+
splits: new JBSplit[](0)
|
|
916
933
|
});
|
|
917
934
|
tiersAdded[i] = JB721Tier({
|
|
918
935
|
id: uint32(tiers.length + (i + 1)),
|
|
@@ -929,6 +946,7 @@ contract Test_adjustTier_Unit is UnitTestSetup {
|
|
|
929
946
|
transfersPausable: tierConfigsToAdd[i].transfersPausable,
|
|
930
947
|
cannotBeRemoved: tierConfigsToAdd[i].cannotBeRemoved,
|
|
931
948
|
cannotIncreaseDiscountPercent: tierConfigsToAdd[i].cannotIncreaseDiscountPercent,
|
|
949
|
+
splitPercent: 0,
|
|
932
950
|
resolvedUri: ""
|
|
933
951
|
});
|
|
934
952
|
}
|
|
@@ -968,7 +986,9 @@ contract Test_adjustTier_Unit is UnitTestSetup {
|
|
|
968
986
|
transfersPausable: false,
|
|
969
987
|
useVotingUnits: true,
|
|
970
988
|
cannotBeRemoved: false,
|
|
971
|
-
cannotIncreaseDiscountPercent: false
|
|
989
|
+
cannotIncreaseDiscountPercent: false,
|
|
990
|
+
splitPercent: 0,
|
|
991
|
+
splits: new JBSplit[](0)
|
|
972
992
|
});
|
|
973
993
|
tiers[i] = JB721Tier({
|
|
974
994
|
id: uint32(i + 1),
|
|
@@ -985,6 +1005,7 @@ contract Test_adjustTier_Unit is UnitTestSetup {
|
|
|
985
1005
|
transfersPausable: tierConfigs[i].transfersPausable,
|
|
986
1006
|
cannotBeRemoved: tierConfigs[i].cannotBeRemoved,
|
|
987
1007
|
cannotIncreaseDiscountPercent: tierConfigs[i].cannotIncreaseDiscountPercent,
|
|
1008
|
+
splitPercent: 0,
|
|
988
1009
|
resolvedUri: ""
|
|
989
1010
|
});
|
|
990
1011
|
}
|
|
@@ -1025,7 +1046,9 @@ contract Test_adjustTier_Unit is UnitTestSetup {
|
|
|
1025
1046
|
transfersPausable: false,
|
|
1026
1047
|
useVotingUnits: true,
|
|
1027
1048
|
cannotBeRemoved: false,
|
|
1028
|
-
cannotIncreaseDiscountPercent: false
|
|
1049
|
+
cannotIncreaseDiscountPercent: false,
|
|
1050
|
+
splitPercent: 0,
|
|
1051
|
+
splits: new JBSplit[](0)
|
|
1029
1052
|
});
|
|
1030
1053
|
tiersAdded[i] = JB721Tier({
|
|
1031
1054
|
id: uint32(tiers.length + (i + 1)),
|
|
@@ -1042,6 +1065,7 @@ contract Test_adjustTier_Unit is UnitTestSetup {
|
|
|
1042
1065
|
transfersPausable: tierConfigsToAdd[i].transfersPausable,
|
|
1043
1066
|
cannotBeRemoved: tierConfigsToAdd[i].cannotBeRemoved,
|
|
1044
1067
|
cannotIncreaseDiscountPercent: tierConfigsToAdd[i].cannotIncreaseDiscountPercent,
|
|
1068
|
+
splitPercent: 0,
|
|
1045
1069
|
resolvedUri: ""
|
|
1046
1070
|
});
|
|
1047
1071
|
}
|
|
@@ -1077,7 +1101,9 @@ contract Test_adjustTier_Unit is UnitTestSetup {
|
|
|
1077
1101
|
transfersPausable: false,
|
|
1078
1102
|
useVotingUnits: true,
|
|
1079
1103
|
cannotBeRemoved: true,
|
|
1080
|
-
cannotIncreaseDiscountPercent: false
|
|
1104
|
+
cannotIncreaseDiscountPercent: false,
|
|
1105
|
+
splitPercent: 0,
|
|
1106
|
+
splits: new JBSplit[](0)
|
|
1081
1107
|
});
|
|
1082
1108
|
tierConfigs[1] = JB721TierConfig({
|
|
1083
1109
|
price: 10,
|
|
@@ -1093,7 +1119,9 @@ contract Test_adjustTier_Unit is UnitTestSetup {
|
|
|
1093
1119
|
transfersPausable: false,
|
|
1094
1120
|
useVotingUnits: true,
|
|
1095
1121
|
cannotBeRemoved: false,
|
|
1096
|
-
cannotIncreaseDiscountPercent: false
|
|
1122
|
+
cannotIncreaseDiscountPercent: false,
|
|
1123
|
+
splitPercent: 0,
|
|
1124
|
+
splits: new JBSplit[](0)
|
|
1097
1125
|
});
|
|
1098
1126
|
// Deploy the hook and its store with the initial tiers.
|
|
1099
1127
|
vm.etch(hook_i, address(hook).code);
|
|
@@ -1148,7 +1176,9 @@ contract Test_adjustTier_Unit is UnitTestSetup {
|
|
|
1148
1176
|
transfersPausable: false,
|
|
1149
1177
|
useVotingUnits: true,
|
|
1150
1178
|
cannotBeRemoved: false,
|
|
1151
|
-
cannotIncreaseDiscountPercent: false
|
|
1179
|
+
cannotIncreaseDiscountPercent: false,
|
|
1180
|
+
splitPercent: 0,
|
|
1181
|
+
splits: new JBSplit[](0)
|
|
1152
1182
|
});
|
|
1153
1183
|
tiers[i] = JB721Tier({
|
|
1154
1184
|
id: uint32(i + 1),
|
|
@@ -1165,6 +1195,7 @@ contract Test_adjustTier_Unit is UnitTestSetup {
|
|
|
1165
1195
|
transfersPausable: tierConfigs[i].transfersPausable,
|
|
1166
1196
|
cannotBeRemoved: tierConfigs[i].cannotBeRemoved,
|
|
1167
1197
|
cannotIncreaseDiscountPercent: tierConfigs[i].cannotIncreaseDiscountPercent,
|
|
1198
|
+
splitPercent: 0,
|
|
1168
1199
|
resolvedUri: ""
|
|
1169
1200
|
});
|
|
1170
1201
|
}
|
|
@@ -1205,7 +1236,9 @@ contract Test_adjustTier_Unit is UnitTestSetup {
|
|
|
1205
1236
|
transfersPausable: false,
|
|
1206
1237
|
useVotingUnits: false,
|
|
1207
1238
|
cannotBeRemoved: false,
|
|
1208
|
-
cannotIncreaseDiscountPercent: false
|
|
1239
|
+
cannotIncreaseDiscountPercent: false,
|
|
1240
|
+
splitPercent: 0,
|
|
1241
|
+
splits: new JBSplit[](0)
|
|
1209
1242
|
});
|
|
1210
1243
|
tiersAdded[i] = JB721Tier({
|
|
1211
1244
|
id: uint32(tiers.length + (i + 1)),
|
|
@@ -1222,6 +1255,7 @@ contract Test_adjustTier_Unit is UnitTestSetup {
|
|
|
1222
1255
|
transfersPausable: tierConfigsToAdd[i].transfersPausable,
|
|
1223
1256
|
cannotBeRemoved: tierConfigsToAdd[i].cannotBeRemoved,
|
|
1224
1257
|
cannotIncreaseDiscountPercent: tierConfigsToAdd[i].cannotIncreaseDiscountPercent,
|
|
1258
|
+
splitPercent: 0,
|
|
1225
1259
|
resolvedUri: ""
|
|
1226
1260
|
});
|
|
1227
1261
|
}
|
|
@@ -1263,7 +1297,9 @@ contract Test_adjustTier_Unit is UnitTestSetup {
|
|
|
1263
1297
|
transfersPausable: false,
|
|
1264
1298
|
cannotBeRemoved: false,
|
|
1265
1299
|
useVotingUnits: true,
|
|
1266
|
-
cannotIncreaseDiscountPercent: false
|
|
1300
|
+
cannotIncreaseDiscountPercent: false,
|
|
1301
|
+
splitPercent: 0,
|
|
1302
|
+
splits: new JBSplit[](0)
|
|
1267
1303
|
});
|
|
1268
1304
|
}
|
|
1269
1305
|
// Set the second to last tier to have a category of `99`, which is less than the last tier's category of `100`.
|
|
@@ -1303,7 +1339,9 @@ contract Test_adjustTier_Unit is UnitTestSetup {
|
|
|
1303
1339
|
transfersPausable: false,
|
|
1304
1340
|
useVotingUnits: false,
|
|
1305
1341
|
cannotBeRemoved: false,
|
|
1306
|
-
cannotIncreaseDiscountPercent: false
|
|
1342
|
+
cannotIncreaseDiscountPercent: false,
|
|
1343
|
+
splitPercent: 0,
|
|
1344
|
+
splits: new JBSplit[](0)
|
|
1307
1345
|
});
|
|
1308
1346
|
}
|
|
1309
1347
|
|
|
@@ -1344,7 +1382,9 @@ contract Test_adjustTier_Unit is UnitTestSetup {
|
|
|
1344
1382
|
transfersPausable: false,
|
|
1345
1383
|
useVotingUnits: false, // <-- If false, voting power is based on tier price
|
|
1346
1384
|
cannotBeRemoved: false,
|
|
1347
|
-
cannotIncreaseDiscountPercent: false
|
|
1385
|
+
cannotIncreaseDiscountPercent: false,
|
|
1386
|
+
splitPercent: 0,
|
|
1387
|
+
splits: new JBSplit[](0)
|
|
1348
1388
|
});
|
|
1349
1389
|
}
|
|
1350
1390
|
|
|
@@ -1384,7 +1424,9 @@ contract Test_adjustTier_Unit is UnitTestSetup {
|
|
|
1384
1424
|
transfersPausable: false,
|
|
1385
1425
|
useVotingUnits: true,
|
|
1386
1426
|
cannotBeRemoved: false,
|
|
1387
|
-
cannotIncreaseDiscountPercent: false
|
|
1427
|
+
cannotIncreaseDiscountPercent: false,
|
|
1428
|
+
splitPercent: 0,
|
|
1429
|
+
splits: new JBSplit[](0)
|
|
1388
1430
|
});
|
|
1389
1431
|
}
|
|
1390
1432
|
|
|
@@ -1425,7 +1467,9 @@ contract Test_adjustTier_Unit is UnitTestSetup {
|
|
|
1425
1467
|
transfersPausable: false,
|
|
1426
1468
|
useVotingUnits: true, // <-- If false, voting power is based on tier price
|
|
1427
1469
|
cannotBeRemoved: false,
|
|
1428
|
-
cannotIncreaseDiscountPercent: false
|
|
1470
|
+
cannotIncreaseDiscountPercent: false,
|
|
1471
|
+
splitPercent: 0,
|
|
1472
|
+
splits: new JBSplit[](0)
|
|
1429
1473
|
});
|
|
1430
1474
|
}
|
|
1431
1475
|
|
|
@@ -1497,14 +1541,16 @@ contract Test_adjustTier_Unit is UnitTestSetup {
|
|
|
1497
1541
|
transfersPausable: false,
|
|
1498
1542
|
useVotingUnits: false,
|
|
1499
1543
|
cannotBeRemoved: false,
|
|
1500
|
-
cannotIncreaseDiscountPercent: false
|
|
1544
|
+
cannotIncreaseDiscountPercent: false,
|
|
1545
|
+
splitPercent: 0,
|
|
1546
|
+
splits: new JBSplit[](0)
|
|
1501
1547
|
});
|
|
1502
1548
|
tiers[i] = JB721Tier({
|
|
1503
1549
|
id: uint32(i + 1),
|
|
1504
1550
|
price: tierConfigs[i].price,
|
|
1505
1551
|
remainingSupply: tierConfigs[i].initialSupply,
|
|
1506
1552
|
initialSupply: tierConfigs[i].initialSupply,
|
|
1507
|
-
votingUnits: tierConfigs[i].
|
|
1553
|
+
votingUnits: tierConfigs[i].price,
|
|
1508
1554
|
reserveFrequency: tierConfigs[i].reserveFrequency,
|
|
1509
1555
|
reserveBeneficiary: i == 0 ? address(0) : tierConfigs[i].reserveBeneficiary,
|
|
1510
1556
|
encodedIPFSUri: tierConfigs[i].encodedIPFSUri,
|
|
@@ -1514,6 +1560,7 @@ contract Test_adjustTier_Unit is UnitTestSetup {
|
|
|
1514
1560
|
transfersPausable: tierConfigs[i].transfersPausable,
|
|
1515
1561
|
cannotBeRemoved: tierConfigs[i].cannotBeRemoved,
|
|
1516
1562
|
cannotIncreaseDiscountPercent: tierConfigs[i].cannotIncreaseDiscountPercent,
|
|
1563
|
+
splitPercent: 0,
|
|
1517
1564
|
resolvedUri: ""
|
|
1518
1565
|
});
|
|
1519
1566
|
}
|
|
@@ -1617,7 +1664,9 @@ contract Test_adjustTier_Unit is UnitTestSetup {
|
|
|
1617
1664
|
transfersPausable: false,
|
|
1618
1665
|
useVotingUnits: true,
|
|
1619
1666
|
cannotBeRemoved: true,
|
|
1620
|
-
cannotIncreaseDiscountPercent: true
|
|
1667
|
+
cannotIncreaseDiscountPercent: true,
|
|
1668
|
+
splitPercent: 0,
|
|
1669
|
+
splits: new JBSplit[](0)
|
|
1621
1670
|
});
|
|
1622
1671
|
// Deploy the hook and its store with the initial tiers.
|
|
1623
1672
|
vm.etch(hook_i, address(hook).code);
|
|
@@ -1672,7 +1721,9 @@ contract Test_adjustTier_Unit is UnitTestSetup {
|
|
|
1672
1721
|
transfersPausable: false,
|
|
1673
1722
|
useVotingUnits: true,
|
|
1674
1723
|
cannotBeRemoved: true,
|
|
1675
|
-
cannotIncreaseDiscountPercent: true
|
|
1724
|
+
cannotIncreaseDiscountPercent: true,
|
|
1725
|
+
splitPercent: 0,
|
|
1726
|
+
splits: new JBSplit[](0)
|
|
1676
1727
|
});
|
|
1677
1728
|
initialConfig[1] = JB721TierConfig({
|
|
1678
1729
|
price: 10,
|
|
@@ -1688,7 +1739,9 @@ contract Test_adjustTier_Unit is UnitTestSetup {
|
|
|
1688
1739
|
transfersPausable: false,
|
|
1689
1740
|
useVotingUnits: true,
|
|
1690
1741
|
cannotBeRemoved: true,
|
|
1691
|
-
cannotIncreaseDiscountPercent: false
|
|
1742
|
+
cannotIncreaseDiscountPercent: false,
|
|
1743
|
+
splitPercent: 0,
|
|
1744
|
+
splits: new JBSplit[](0)
|
|
1692
1745
|
});
|
|
1693
1746
|
|
|
1694
1747
|
// Deploy the hook and its store with the initial tiers.
|
|
@@ -160,6 +160,7 @@ contract Test_Getters_Constructor_Unit is UnitTestSetup {
|
|
|
160
160
|
transfersPausable: false,
|
|
161
161
|
cannotBeRemoved: false,
|
|
162
162
|
cannotIncreaseDiscountPercent: false,
|
|
163
|
+
splitPercent: 0,
|
|
163
164
|
resolvedUri: ""
|
|
164
165
|
})
|
|
165
166
|
);
|
|
@@ -183,11 +184,11 @@ contract Test_Getters_Constructor_Unit is UnitTestSetup {
|
|
|
183
184
|
price: uint104((i + 1) * 10),
|
|
184
185
|
remainingSupply: uint32(100 - (i + 1)),
|
|
185
186
|
initialSupply: uint32(100),
|
|
186
|
-
votingUnits: uint16(0),
|
|
187
187
|
reserveFrequency: uint16(0),
|
|
188
188
|
category: uint24(100),
|
|
189
189
|
discountPercent: uint8(0),
|
|
190
|
-
packedBools: hook.test_store().ForTest_packBools(false, false, false, false, false)
|
|
190
|
+
packedBools: hook.test_store().ForTest_packBools(false, false, false, false, false),
|
|
191
|
+
splitPercent: 0
|
|
191
192
|
})
|
|
192
193
|
);
|
|
193
194
|
}
|
|
@@ -236,11 +237,11 @@ contract Test_Getters_Constructor_Unit is UnitTestSetup {
|
|
|
236
237
|
price: uint104((i + 1) * 10),
|
|
237
238
|
remainingSupply: uint32(initialSupply - totalMinted),
|
|
238
239
|
initialSupply: uint32(initialSupply),
|
|
239
|
-
votingUnits: uint16(0),
|
|
240
240
|
reserveFrequency: uint16(reserveFrequency),
|
|
241
241
|
category: uint24(100),
|
|
242
242
|
discountPercent: uint8(0),
|
|
243
|
-
packedBools: hook.test_store().ForTest_packBools(false, false, false, false, false)
|
|
243
|
+
packedBools: hook.test_store().ForTest_packBools(false, false, false, false, false),
|
|
244
|
+
splitPercent: 0
|
|
244
245
|
})
|
|
245
246
|
);
|
|
246
247
|
// Manually set the number of reserve mints for each tier.
|
|
@@ -277,13 +278,15 @@ contract Test_Getters_Constructor_Unit is UnitTestSetup {
|
|
|
277
278
|
price: uint104(10),
|
|
278
279
|
remainingSupply: uint32(10),
|
|
279
280
|
initialSupply: uint32(20),
|
|
280
|
-
votingUnits: uint16(0),
|
|
281
281
|
reserveFrequency: uint16(100),
|
|
282
282
|
category: uint24(100),
|
|
283
283
|
discountPercent: uint8(0),
|
|
284
|
-
packedBools: hook.test_store().ForTest_packBools(false, false, true, false, false)
|
|
284
|
+
packedBools: hook.test_store().ForTest_packBools(false, false, true, false, false),
|
|
285
|
+
splitPercent: 0
|
|
285
286
|
})
|
|
286
287
|
);
|
|
288
|
+
// Clear the voting units mapping for tier 1 (ForTest_setTier only overwrites the packed struct).
|
|
289
|
+
hook.test_store().ForTest_setTierVotingUnits(address(hook), 1, 0);
|
|
287
290
|
|
|
288
291
|
// Give the beneficiary `balances` NFTs from each tier up to `numberOfTiers`.
|
|
289
292
|
for (uint256 i; i < numberOfTiers; i++) {
|
|
@@ -401,11 +404,11 @@ contract Test_Getters_Constructor_Unit is UnitTestSetup {
|
|
|
401
404
|
price: uint104(i * 10),
|
|
402
405
|
remainingSupply: uint32(10 * i - 5 * i),
|
|
403
406
|
initialSupply: uint32(10 * i),
|
|
404
|
-
votingUnits: uint16(0),
|
|
405
407
|
reserveFrequency: uint16(0),
|
|
406
408
|
category: uint24(100),
|
|
407
409
|
discountPercent: uint8(0),
|
|
408
|
-
packedBools: hook.test_store().ForTest_packBools(false, false, false, false, false)
|
|
410
|
+
packedBools: hook.test_store().ForTest_packBools(false, false, false, false, false),
|
|
411
|
+
splitPercent: 0
|
|
409
412
|
})
|
|
410
413
|
);
|
|
411
414
|
// Calculate the theoretical weight for the current tier. 10 the price multiplier.
|
|
@@ -511,7 +514,9 @@ contract Test_Getters_Constructor_Unit is UnitTestSetup {
|
|
|
511
514
|
transfersPausable: false,
|
|
512
515
|
useVotingUnits: true,
|
|
513
516
|
cannotBeRemoved: false,
|
|
514
|
-
cannotIncreaseDiscountPercent: false
|
|
517
|
+
cannotIncreaseDiscountPercent: false,
|
|
518
|
+
splitPercent: 0,
|
|
519
|
+
splits: new JBSplit[](0)
|
|
515
520
|
});
|
|
516
521
|
}
|
|
517
522
|
|
|
@@ -29,11 +29,11 @@ contract Test_mintFor_mintReservesFor_Unit is UnitTestSetup {
|
|
|
29
29
|
price: uint104((i + 1) * 10),
|
|
30
30
|
remainingSupply: uint32(initialSupply - totalMinted),
|
|
31
31
|
initialSupply: uint32(initialSupply),
|
|
32
|
-
votingUnits: uint16(0),
|
|
33
32
|
reserveFrequency: uint16(reserveFrequency),
|
|
34
33
|
category: uint24(100),
|
|
35
34
|
discountPercent: uint8(0),
|
|
36
|
-
packedBools: hook.test_store().ForTest_packBools(false, false, true, false, false)
|
|
35
|
+
packedBools: hook.test_store().ForTest_packBools(false, false, true, false, false),
|
|
36
|
+
splitPercent: 0
|
|
37
37
|
})
|
|
38
38
|
);
|
|
39
39
|
hook.test_store().ForTest_setReservesMintedFor(address(hook), i + 1, reservedMinted);
|
|
@@ -76,11 +76,11 @@ contract Test_mintFor_mintReservesFor_Unit is UnitTestSetup {
|
|
|
76
76
|
price: uint104(10),
|
|
77
77
|
remainingSupply: uint32(initialSupply),
|
|
78
78
|
initialSupply: uint32(initialSupply),
|
|
79
|
-
votingUnits: uint16(0),
|
|
80
79
|
reserveFrequency: uint16(reserveFrequency),
|
|
81
80
|
category: uint24(100),
|
|
82
81
|
discountPercent: uint8(0),
|
|
83
|
-
packedBools: hook.test_store().ForTest_packBools(true, false, true, false, false)
|
|
82
|
+
packedBools: hook.test_store().ForTest_packBools(true, false, true, false, false),
|
|
83
|
+
splitPercent: 0
|
|
84
84
|
})
|
|
85
85
|
);
|
|
86
86
|
|
|
@@ -179,11 +179,11 @@ contract Test_mintFor_mintReservesFor_Unit is UnitTestSetup {
|
|
|
179
179
|
price: uint104((i + 1) * 10),
|
|
180
180
|
remainingSupply: uint32(initialSupply - totalMinted),
|
|
181
181
|
initialSupply: uint32(initialSupply),
|
|
182
|
-
votingUnits: uint16(0),
|
|
183
182
|
reserveFrequency: uint16(reserveFrequency),
|
|
184
183
|
category: uint24(100),
|
|
185
184
|
discountPercent: uint8(0),
|
|
186
|
-
packedBools: hook.test_store().ForTest_packBools(false, false, true, false, false)
|
|
185
|
+
packedBools: hook.test_store().ForTest_packBools(false, false, true, false, false),
|
|
186
|
+
splitPercent: 0
|
|
187
187
|
})
|
|
188
188
|
);
|
|
189
189
|
|
|
@@ -277,11 +277,11 @@ contract Test_mintFor_mintReservesFor_Unit is UnitTestSetup {
|
|
|
277
277
|
price: uint104((i + 1) * 10),
|
|
278
278
|
remainingSupply: uint32(initialSupply - totalMinted),
|
|
279
279
|
initialSupply: uint32(initialSupply),
|
|
280
|
-
votingUnits: uint16(0),
|
|
281
280
|
reserveFrequency: uint16(reserveFrequency),
|
|
282
281
|
category: uint24(100),
|
|
283
282
|
discountPercent: uint8(0),
|
|
284
|
-
packedBools: hook.test_store().ForTest_packBools(false, false, true, false, false)
|
|
283
|
+
packedBools: hook.test_store().ForTest_packBools(false, false, true, false, false),
|
|
284
|
+
splitPercent: 0
|
|
285
285
|
})
|
|
286
286
|
);
|
|
287
287
|
hook.test_store().ForTest_setReservesMintedFor(address(hook), i + 1, reservedMinted);
|
|
@@ -315,11 +315,11 @@ contract Test_mintFor_mintReservesFor_Unit is UnitTestSetup {
|
|
|
315
315
|
price: uint104((i + 1) * 10),
|
|
316
316
|
remainingSupply: uint32(initialSupply - totalMinted),
|
|
317
317
|
initialSupply: uint32(initialSupply),
|
|
318
|
-
votingUnits: uint16(0),
|
|
319
318
|
reserveFrequency: uint16(reserveFrequency),
|
|
320
319
|
category: uint24(100),
|
|
321
320
|
discountPercent: uint8(0),
|
|
322
|
-
packedBools: hook.test_store().ForTest_packBools(false, false, true, false, false)
|
|
321
|
+
packedBools: hook.test_store().ForTest_packBools(false, false, true, false, false),
|
|
322
|
+
splitPercent: 0
|
|
323
323
|
})
|
|
324
324
|
);
|
|
325
325
|
hook.test_store().ForTest_setReservesMintedFor(address(hook), i + 1, reservedMinted);
|
|
@@ -363,11 +363,11 @@ contract Test_mintFor_mintReservesFor_Unit is UnitTestSetup {
|
|
|
363
363
|
price: uint104((i + 1) * 10),
|
|
364
364
|
remainingSupply: uint32(initialSupply - totalMinted),
|
|
365
365
|
initialSupply: uint32(initialSupply),
|
|
366
|
-
votingUnits: uint16(0),
|
|
367
366
|
reserveFrequency: uint16(reserveFrequency),
|
|
368
367
|
category: uint24(100),
|
|
369
368
|
discountPercent: uint8(0),
|
|
370
|
-
packedBools: hook.test_store().ForTest_packBools(false, false, true, false, false)
|
|
369
|
+
packedBools: hook.test_store().ForTest_packBools(false, false, true, false, false),
|
|
370
|
+
splitPercent: 0
|
|
371
371
|
})
|
|
372
372
|
);
|
|
373
373
|
hook.test_store().ForTest_setReservesMintedFor(address(hook), i + 1, reservedMinted);
|
package/test/unit/pay_Unit.t.sol
CHANGED
|
@@ -965,7 +965,7 @@ contract Test_afterPayRecorded_Unit is UnitTestSetup {
|
|
|
965
965
|
vm.prank(terminal);
|
|
966
966
|
|
|
967
967
|
// Expect a revert for the caller not being a terminal of the project.
|
|
968
|
-
vm.expectRevert(abi.encodeWithSelector(
|
|
968
|
+
vm.expectRevert(abi.encodeWithSelector(JB721TiersHook.JB721TiersHook_InvalidPay.selector));
|
|
969
969
|
|
|
970
970
|
hook.afterPayRecordedWith(
|
|
971
971
|
JBAfterPayRecordedContext({
|
|
@@ -991,7 +991,7 @@ contract Test_afterPayRecorded_Unit is UnitTestSetup {
|
|
|
991
991
|
);
|
|
992
992
|
}
|
|
993
993
|
|
|
994
|
-
function
|
|
994
|
+
function test_afterPayRecorded_silentlyReturnsOnCurrencyMismatchWithoutPriceFeed(address token) public {
|
|
995
995
|
vm.assume(token != JBConstants.NATIVE_TOKEN);
|
|
996
996
|
|
|
997
997
|
// Mock the directory call.
|
|
@@ -1002,14 +1002,7 @@ contract Test_afterPayRecorded_Unit is UnitTestSetup {
|
|
|
1002
1002
|
);
|
|
1003
1003
|
|
|
1004
1004
|
// The payment's currency (18, from positional arg order) doesn't match the hook's pricing currency.
|
|
1005
|
-
// With no price feed configured, this
|
|
1006
|
-
vm.expectRevert(
|
|
1007
|
-
abi.encodeWithSelector(
|
|
1008
|
-
JB721TiersHook.JB721TiersHook_CurrencyMismatch.selector,
|
|
1009
|
-
uint256(18),
|
|
1010
|
-
uint256(uint32(uint160(JBConstants.NATIVE_TOKEN)))
|
|
1011
|
-
)
|
|
1012
|
-
);
|
|
1005
|
+
// With no price feed configured, this silently returns without minting (no revert).
|
|
1013
1006
|
vm.prank(mockTerminalAddress);
|
|
1014
1007
|
hook.afterPayRecordedWith(
|
|
1015
1008
|
JBAfterPayRecordedContext({
|
|
@@ -1028,6 +1021,9 @@ contract Test_afterPayRecorded_Unit is UnitTestSetup {
|
|
|
1028
1021
|
payerMetadata: new bytes(0)
|
|
1029
1022
|
})
|
|
1030
1023
|
);
|
|
1024
|
+
|
|
1025
|
+
// Verify no credits were added (the function returned early).
|
|
1026
|
+
assertEq(hook.payCreditsOf(msg.sender), 0);
|
|
1031
1027
|
}
|
|
1032
1028
|
|
|
1033
1029
|
function test_afterPayRecorded_mintWithExistingCreditsWhenMoreExistingCreditsThanNewCredits() public {
|
|
@@ -21,11 +21,11 @@ contract Test_cashOut_Unit is UnitTestSetup {
|
|
|
21
21
|
price: uint104(i * 10),
|
|
22
22
|
remainingSupply: uint32(10 * i - 5 * i),
|
|
23
23
|
initialSupply: uint32(10 * i),
|
|
24
|
-
votingUnits: uint16(0),
|
|
25
24
|
reserveFrequency: uint16(0),
|
|
26
25
|
category: uint24(100),
|
|
27
26
|
discountPercent: uint8(0),
|
|
28
|
-
packedBools: hook.test_store().ForTest_packBools(false, false, false, false, false)
|
|
27
|
+
packedBools: hook.test_store().ForTest_packBools(false, false, false, false, false),
|
|
28
|
+
splitPercent: 0
|
|
29
29
|
})
|
|
30
30
|
);
|
|
31
31
|
totalWeight += (10 * i - 5 * i) * i * 10;
|
|
@@ -92,11 +92,11 @@ contract Test_cashOut_Unit is UnitTestSetup {
|
|
|
92
92
|
price: uint104(i * 10),
|
|
93
93
|
remainingSupply: uint32(10 * i - 5 * i),
|
|
94
94
|
initialSupply: uint32(10 * i),
|
|
95
|
-
votingUnits: uint16(0),
|
|
96
95
|
reserveFrequency: uint16(0),
|
|
97
96
|
category: uint24(100),
|
|
98
97
|
discountPercent: uint8(0),
|
|
99
|
-
packedBools: hook.test_store().ForTest_packBools(false, false, false, false, false)
|
|
98
|
+
packedBools: hook.test_store().ForTest_packBools(false, false, false, false, false),
|
|
99
|
+
splitPercent: 0
|
|
100
100
|
})
|
|
101
101
|
);
|
|
102
102
|
totalWeight += (10 * i - 5 * i) * i * 10;
|
|
@@ -123,7 +123,7 @@ contract Test_cashOut_Unit is UnitTestSetup {
|
|
|
123
123
|
}),
|
|
124
124
|
useTotalSurplus: true,
|
|
125
125
|
cashOutTaxRate: cashOutTaxRate,
|
|
126
|
-
metadata: abi.encode(bytes32(0), type(
|
|
126
|
+
metadata: abi.encode(bytes32(0), type(IJB721TiersHook).interfaceId, tokenList)
|
|
127
127
|
})
|
|
128
128
|
);
|
|
129
129
|
|
|
@@ -149,11 +149,11 @@ contract Test_cashOut_Unit is UnitTestSetup {
|
|
|
149
149
|
price: uint104(i * 10),
|
|
150
150
|
remainingSupply: uint32(10 * i - 5 * i),
|
|
151
151
|
initialSupply: uint32(10 * i),
|
|
152
|
-
votingUnits: uint16(0),
|
|
153
152
|
reserveFrequency: uint16(0),
|
|
154
153
|
category: uint24(100),
|
|
155
154
|
discountPercent: uint8(0),
|
|
156
|
-
packedBools: hook.test_store().ForTest_packBools(false, false, false, false, false)
|
|
155
|
+
packedBools: hook.test_store().ForTest_packBools(false, false, false, false, false),
|
|
156
|
+
splitPercent: 0
|
|
157
157
|
})
|
|
158
158
|
);
|
|
159
159
|
totalWeight += (10 * i - 5 * i) * i * 10;
|
|
@@ -206,7 +206,7 @@ contract Test_cashOut_Unit is UnitTestSetup {
|
|
|
206
206
|
vm.assume(tokenCount > 0);
|
|
207
207
|
|
|
208
208
|
// Expect a revert on account of the token count being non-zero while the total supply is zero.
|
|
209
|
-
vm.expectRevert(abi.encodeWithSelector(
|
|
209
|
+
vm.expectRevert(abi.encodeWithSelector(JB721TiersHook.JB721TiersHook_UnexpectedTokenCashedOut.selector));
|
|
210
210
|
|
|
211
211
|
hook.beforeCashOutRecordedWith(
|
|
212
212
|
JBBeforeCashOutRecordedContext({
|
|
@@ -347,7 +347,7 @@ contract Test_cashOut_Unit is UnitTestSetup {
|
|
|
347
347
|
);
|
|
348
348
|
|
|
349
349
|
// Expect to revert on account of the project ID being incorrect.
|
|
350
|
-
vm.expectRevert(abi.encodeWithSelector(
|
|
350
|
+
vm.expectRevert(abi.encodeWithSelector(JB721TiersHook.JB721TiersHook_InvalidCashOut.selector));
|
|
351
351
|
|
|
352
352
|
vm.prank(mockTerminalAddress);
|
|
353
353
|
hook.afterCashOutRecordedWith(
|
|
@@ -382,7 +382,7 @@ contract Test_cashOut_Unit is UnitTestSetup {
|
|
|
382
382
|
);
|
|
383
383
|
|
|
384
384
|
// Expect to revert on account of the caller not being a terminal of the project.
|
|
385
|
-
vm.expectRevert(abi.encodeWithSelector(
|
|
385
|
+
vm.expectRevert(abi.encodeWithSelector(JB721TiersHook.JB721TiersHook_InvalidCashOut.selector));
|
|
386
386
|
|
|
387
387
|
vm.prank(mockTerminalAddress);
|
|
388
388
|
hook.afterCashOutRecordedWith(
|
|
@@ -434,7 +434,9 @@ contract Test_cashOut_Unit is UnitTestSetup {
|
|
|
434
434
|
abi.encode(true)
|
|
435
435
|
);
|
|
436
436
|
|
|
437
|
-
vm.expectRevert(
|
|
437
|
+
vm.expectRevert(
|
|
438
|
+
abi.encodeWithSelector(JB721TiersHook.JB721TiersHook_UnauthorizedToken.selector, tokenId, wrongHolder)
|
|
439
|
+
);
|
|
438
440
|
|
|
439
441
|
vm.prank(mockTerminalAddress);
|
|
440
442
|
hook.afterCashOutRecordedWith(
|