@bananapus/721-hook-v6 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (100) hide show
  1. package/.gas-snapshot +152 -0
  2. package/LICENSE +21 -0
  3. package/README.md +253 -0
  4. package/SKILLS.md +140 -0
  5. package/docs/book.css +13 -0
  6. package/docs/book.toml +12 -0
  7. package/docs/solidity.min.js +74 -0
  8. package/docs/src/README.md +253 -0
  9. package/docs/src/SUMMARY.md +38 -0
  10. package/docs/src/src/JB721TiersHook.sol/contract.JB721TiersHook.md +645 -0
  11. package/docs/src/src/JB721TiersHookDeployer.sol/contract.JB721TiersHookDeployer.md +99 -0
  12. package/docs/src/src/JB721TiersHookProjectDeployer.sol/contract.JB721TiersHookProjectDeployer.md +288 -0
  13. package/docs/src/src/JB721TiersHookStore.sol/contract.JB721TiersHookStore.md +1096 -0
  14. package/docs/src/src/README.md +11 -0
  15. package/docs/src/src/abstract/ERC721.sol/abstract.ERC721.md +430 -0
  16. package/docs/src/src/abstract/JB721Hook.sol/abstract.JB721Hook.md +309 -0
  17. package/docs/src/src/abstract/README.md +5 -0
  18. package/docs/src/src/interfaces/IJB721Hook.sol/interface.IJB721Hook.md +29 -0
  19. package/docs/src/src/interfaces/IJB721TiersHook.sol/interface.IJB721TiersHook.md +203 -0
  20. package/docs/src/src/interfaces/IJB721TiersHookDeployer.sol/interface.IJB721TiersHookDeployer.md +25 -0
  21. package/docs/src/src/interfaces/IJB721TiersHookProjectDeployer.sol/interface.IJB721TiersHookProjectDeployer.md +64 -0
  22. package/docs/src/src/interfaces/IJB721TiersHookStore.sol/interface.IJB721TiersHookStore.md +265 -0
  23. package/docs/src/src/interfaces/IJB721TokenUriResolver.sol/interface.IJB721TokenUriResolver.md +12 -0
  24. package/docs/src/src/interfaces/README.md +9 -0
  25. package/docs/src/src/libraries/JB721Constants.sol/library.JB721Constants.md +14 -0
  26. package/docs/src/src/libraries/JB721TiersRulesetMetadataResolver.sol/library.JB721TiersRulesetMetadataResolver.md +68 -0
  27. package/docs/src/src/libraries/JBBitmap.sol/library.JBBitmap.md +82 -0
  28. package/docs/src/src/libraries/JBIpfsDecoder.sol/library.JBIpfsDecoder.md +61 -0
  29. package/docs/src/src/libraries/README.md +7 -0
  30. package/docs/src/src/structs/JB721InitTiersConfig.sol/struct.JB721InitTiersConfig.md +27 -0
  31. package/docs/src/src/structs/JB721Tier.sol/struct.JB721Tier.md +59 -0
  32. package/docs/src/src/structs/JB721TierConfig.sol/struct.JB721TierConfig.md +60 -0
  33. package/docs/src/src/structs/JB721TiersHookFlags.sol/struct.JB721TiersHookFlags.md +26 -0
  34. package/docs/src/src/structs/JB721TiersMintReservesConfig.sol/struct.JB721TiersMintReservesConfig.md +16 -0
  35. package/docs/src/src/structs/JB721TiersRulesetMetadata.sol/struct.JB721TiersRulesetMetadata.md +20 -0
  36. package/docs/src/src/structs/JB721TiersSetDiscountPercentConfig.sol/struct.JB721TiersSetDiscountPercentConfig.md +16 -0
  37. package/docs/src/src/structs/JBBitmapWord.sol/struct.JBBitmapWord.md +19 -0
  38. package/docs/src/src/structs/JBDeploy721TiersHookConfig.sol/struct.JBDeploy721TiersHookConfig.md +34 -0
  39. package/docs/src/src/structs/JBLaunchProjectConfig.sol/struct.JBLaunchProjectConfig.md +23 -0
  40. package/docs/src/src/structs/JBLaunchRulesetsConfig.sol/struct.JBLaunchRulesetsConfig.md +22 -0
  41. package/docs/src/src/structs/JBPayDataHookRulesetConfig.sol/struct.JBPayDataHookRulesetConfig.md +51 -0
  42. package/docs/src/src/structs/JBPayDataHookRulesetMetadata.sol/struct.JBPayDataHookRulesetMetadata.md +66 -0
  43. package/docs/src/src/structs/JBQueueRulesetsConfig.sol/struct.JBQueueRulesetsConfig.md +21 -0
  44. package/docs/src/src/structs/JBStored721Tier.sol/struct.JBStored721Tier.md +42 -0
  45. package/docs/src/src/structs/README.md +18 -0
  46. package/foundry.lock +11 -0
  47. package/foundry.toml +22 -0
  48. package/package.json +31 -0
  49. package/remappings.txt +1 -0
  50. package/script/Deploy.s.sol +140 -0
  51. package/script/helpers/Hook721DeploymentLib.sol +81 -0
  52. package/slither-ci.config.json +10 -0
  53. package/sphinx.lock +476 -0
  54. package/src/JB721TiersHook.sol +765 -0
  55. package/src/JB721TiersHookDeployer.sol +114 -0
  56. package/src/JB721TiersHookProjectDeployer.sol +413 -0
  57. package/src/JB721TiersHookStore.sol +1195 -0
  58. package/src/abstract/ERC721.sol +484 -0
  59. package/src/abstract/JB721Hook.sol +279 -0
  60. package/src/interfaces/IJB721Hook.sol +21 -0
  61. package/src/interfaces/IJB721TiersHook.sol +135 -0
  62. package/src/interfaces/IJB721TiersHookDeployer.sol +22 -0
  63. package/src/interfaces/IJB721TiersHookProjectDeployer.sol +76 -0
  64. package/src/interfaces/IJB721TiersHookStore.sol +220 -0
  65. package/src/interfaces/IJB721TokenUriResolver.sol +10 -0
  66. package/src/libraries/JB721Constants.sol +7 -0
  67. package/src/libraries/JB721TiersRulesetMetadataResolver.sol +44 -0
  68. package/src/libraries/JBBitmap.sol +57 -0
  69. package/src/libraries/JBIpfsDecoder.sol +95 -0
  70. package/src/structs/JB721InitTiersConfig.sol +20 -0
  71. package/src/structs/JB721Tier.sol +39 -0
  72. package/src/structs/JB721TierConfig.sol +40 -0
  73. package/src/structs/JB721TiersHookFlags.sol +17 -0
  74. package/src/structs/JB721TiersMintReservesConfig.sol +9 -0
  75. package/src/structs/JB721TiersRulesetMetadata.sol +12 -0
  76. package/src/structs/JB721TiersSetDiscountPercentConfig.sol +9 -0
  77. package/src/structs/JBBitmapWord.sol +11 -0
  78. package/src/structs/JBDeploy721TiersHookConfig.sol +25 -0
  79. package/src/structs/JBLaunchProjectConfig.sol +18 -0
  80. package/src/structs/JBLaunchRulesetsConfig.sol +17 -0
  81. package/src/structs/JBPayDataHookRulesetConfig.sol +44 -0
  82. package/src/structs/JBPayDataHookRulesetMetadata.sol +46 -0
  83. package/src/structs/JBQueueRulesetsConfig.sol +13 -0
  84. package/src/structs/JBStored721Tier.sol +24 -0
  85. package/test/721HookAttacks.t.sol +396 -0
  86. package/test/E2E/Pay_Mint_Redeem_E2E.t.sol +944 -0
  87. package/test/invariants/TierLifecycleInvariant.t.sol +187 -0
  88. package/test/invariants/TieredHookStoreInvariant.t.sol +81 -0
  89. package/test/invariants/handlers/TierLifecycleHandler.sol +262 -0
  90. package/test/invariants/handlers/TierStoreHandler.sol +155 -0
  91. package/test/unit/JB721TiersRulesetMetadataResolver.t.sol +141 -0
  92. package/test/unit/JBBitmap.t.sol +169 -0
  93. package/test/unit/JBIpfsDecoder.t.sol +131 -0
  94. package/test/unit/M6_TierSupplyCheck.t.sol +220 -0
  95. package/test/unit/adjustTier_Unit.t.sol +1740 -0
  96. package/test/unit/deployer_Unit.t.sol +103 -0
  97. package/test/unit/getters_constructor_Unit.t.sol +548 -0
  98. package/test/unit/mintFor_mintReservesFor_Unit.t.sol +443 -0
  99. package/test/unit/pay_Unit.t.sol +1537 -0
  100. package/test/unit/redeem_Unit.t.sol +459 -0
@@ -0,0 +1,99 @@
1
+ # JB721TiersHookDeployer
2
+ [Git Source](https://github.com/Bananapus/nana-721-hook/blob/e813fb5b7d17cd3d18023137d70a7b2f3911ad99/src/JB721TiersHookDeployer.sol)
3
+
4
+ **Inherits:**
5
+ ERC2771Context, [IJB721TiersHookDeployer](/src/interfaces/IJB721TiersHookDeployer.sol/interface.IJB721TiersHookDeployer.md)
6
+
7
+ Deploys a `JB721TiersHook` for an existing project.
8
+
9
+
10
+ ## State Variables
11
+ ### ADDRESS_REGISTRY
12
+ A registry which stores references to contracts and their deployers.
13
+
14
+
15
+ ```solidity
16
+ IJBAddressRegistry public immutable ADDRESS_REGISTRY;
17
+ ```
18
+
19
+
20
+ ### HOOK
21
+ A 721 tiers hook.
22
+
23
+
24
+ ```solidity
25
+ JB721TiersHook public immutable HOOK;
26
+ ```
27
+
28
+
29
+ ### STORE
30
+ The contract that stores and manages data for this contract's NFTs.
31
+
32
+
33
+ ```solidity
34
+ IJB721TiersHookStore public immutable STORE;
35
+ ```
36
+
37
+
38
+ ### _nonce
39
+ This contract's current nonce, used for the Juicebox address registry.
40
+
41
+
42
+ ```solidity
43
+ uint256 internal _nonce;
44
+ ```
45
+
46
+
47
+ ## Functions
48
+ ### constructor
49
+
50
+
51
+ ```solidity
52
+ constructor(
53
+ JB721TiersHook hook,
54
+ IJB721TiersHookStore store,
55
+ IJBAddressRegistry addressRegistry,
56
+ address trustedForwarder
57
+ )
58
+ ERC2771Context(trustedForwarder);
59
+ ```
60
+ **Parameters**
61
+
62
+ |Name|Type|Description|
63
+ |----|----|-----------|
64
+ |`hook`|`JB721TiersHook`|Reference copy of a hook.|
65
+ |`store`|`IJB721TiersHookStore`|The contract that stores and manages data for this contract's NFTs.|
66
+ |`addressRegistry`|`IJBAddressRegistry`|A registry which stores references to contracts and their deployers.|
67
+ |`trustedForwarder`|`address`|The trusted forwarder for the ERC2771Context.|
68
+
69
+
70
+ ### deployHookFor
71
+
72
+ Deploys a 721 tiers hook for the specified project.
73
+
74
+
75
+ ```solidity
76
+ function deployHookFor(
77
+ uint256 projectId,
78
+ JBDeploy721TiersHookConfig calldata deployTiersHookConfig,
79
+ bytes32 salt
80
+ )
81
+ external
82
+ override
83
+ returns (IJB721TiersHook newHook);
84
+ ```
85
+ **Parameters**
86
+
87
+ |Name|Type|Description|
88
+ |----|----|-----------|
89
+ |`projectId`|`uint256`|The ID of the project to deploy the hook for.|
90
+ |`deployTiersHookConfig`|`JBDeploy721TiersHookConfig`|The config to deploy the hook with, which determines its behavior.|
91
+ |`salt`|`bytes32`|A salt to use for the deterministic deployment.|
92
+
93
+ **Returns**
94
+
95
+ |Name|Type|Description|
96
+ |----|----|-----------|
97
+ |`newHook`|`IJB721TiersHook`|The address of the newly deployed hook.|
98
+
99
+
@@ -0,0 +1,288 @@
1
+ # JB721TiersHookProjectDeployer
2
+ [Git Source](https://github.com/Bananapus/nana-721-hook/blob/e813fb5b7d17cd3d18023137d70a7b2f3911ad99/src/JB721TiersHookProjectDeployer.sol)
3
+
4
+ **Inherits:**
5
+ ERC2771Context, JBPermissioned, [IJB721TiersHookProjectDeployer](/src/interfaces/IJB721TiersHookProjectDeployer.sol/interface.IJB721TiersHookProjectDeployer.md)
6
+
7
+ Deploys a project and a 721 tiers hook for it. Can be used to queue rulesets for the project if given
8
+ `JBPermissionIds.QUEUE_RULESETS`.
9
+
10
+
11
+ ## State Variables
12
+ ### DIRECTORY
13
+ The directory of terminals and controllers for projects.
14
+
15
+
16
+ ```solidity
17
+ IJBDirectory public immutable override DIRECTORY;
18
+ ```
19
+
20
+
21
+ ### HOOK_DEPLOYER
22
+ The 721 tiers hook deployer.
23
+
24
+
25
+ ```solidity
26
+ IJB721TiersHookDeployer public immutable override HOOK_DEPLOYER;
27
+ ```
28
+
29
+
30
+ ## Functions
31
+ ### constructor
32
+
33
+
34
+ ```solidity
35
+ constructor(
36
+ IJBDirectory directory,
37
+ IJBPermissions permissions,
38
+ IJB721TiersHookDeployer hookDeployer,
39
+ address trustedForwarder
40
+ )
41
+ JBPermissioned(permissions)
42
+ ERC2771Context(trustedForwarder);
43
+ ```
44
+ **Parameters**
45
+
46
+ |Name|Type|Description|
47
+ |----|----|-----------|
48
+ |`directory`|`IJBDirectory`|The directory of terminals and controllers for projects.|
49
+ |`permissions`|`IJBPermissions`|A contract storing permissions.|
50
+ |`hookDeployer`|`IJB721TiersHookDeployer`|The 721 tiers hook deployer.|
51
+ |`trustedForwarder`|`address`|The trusted forwarder for the ERC2771Context.|
52
+
53
+
54
+ ### launchProjectFor
55
+
56
+ Launches a new project with a 721 tiers hook attached.
57
+
58
+
59
+ ```solidity
60
+ function launchProjectFor(
61
+ address owner,
62
+ JBDeploy721TiersHookConfig calldata deployTiersHookConfig,
63
+ JBLaunchProjectConfig calldata launchProjectConfig,
64
+ IJBController controller,
65
+ bytes32 salt
66
+ )
67
+ external
68
+ override
69
+ returns (uint256 projectId, IJB721TiersHook hook);
70
+ ```
71
+ **Parameters**
72
+
73
+ |Name|Type|Description|
74
+ |----|----|-----------|
75
+ |`owner`|`address`|The address to set as the owner of the project. The ERC-721 which confers this project's ownership will be sent to this address.|
76
+ |`deployTiersHookConfig`|`JBDeploy721TiersHookConfig`|Configuration which dictates the behavior of the 721 tiers hook which is being deployed.|
77
+ |`launchProjectConfig`|`JBLaunchProjectConfig`|Configuration which dictates the behavior of the project which is being launched.|
78
+ |`controller`|`IJBController`|The controller that the project's rulesets will be queued with.|
79
+ |`salt`|`bytes32`|A salt to use for the deterministic deployment.|
80
+
81
+ **Returns**
82
+
83
+ |Name|Type|Description|
84
+ |----|----|-----------|
85
+ |`projectId`|`uint256`|The ID of the newly launched project.|
86
+ |`hook`|`IJB721TiersHook`|The 721 tiers hook that was deployed for the project.|
87
+
88
+
89
+ ### launchRulesetsFor
90
+
91
+ Launches rulesets for a project with an attached 721 tiers hook.
92
+
93
+ *Only a project's owner or an operator with the `QUEUE_RULESETS & SET_TERMINALS` permission can launch its
94
+ rulesets.*
95
+
96
+
97
+ ```solidity
98
+ function launchRulesetsFor(
99
+ uint256 projectId,
100
+ JBDeploy721TiersHookConfig calldata deployTiersHookConfig,
101
+ JBLaunchRulesetsConfig calldata launchRulesetsConfig,
102
+ IJBController controller,
103
+ bytes32 salt
104
+ )
105
+ external
106
+ override
107
+ returns (uint256 rulesetId, IJB721TiersHook hook);
108
+ ```
109
+ **Parameters**
110
+
111
+ |Name|Type|Description|
112
+ |----|----|-----------|
113
+ |`projectId`|`uint256`|The ID of the project that rulesets are being launched for.|
114
+ |`deployTiersHookConfig`|`JBDeploy721TiersHookConfig`|Configuration which dictates the behavior of the 721 tiers hook which is being deployed.|
115
+ |`launchRulesetsConfig`|`JBLaunchRulesetsConfig`|Configuration which dictates the project's new rulesets.|
116
+ |`controller`|`IJBController`|The controller that the project's rulesets will be queued with.|
117
+ |`salt`|`bytes32`|A salt to use for the deterministic deployment.|
118
+
119
+ **Returns**
120
+
121
+ |Name|Type|Description|
122
+ |----|----|-----------|
123
+ |`rulesetId`|`uint256`|The ID of the successfully created ruleset.|
124
+ |`hook`|`IJB721TiersHook`|The 721 tiers hook that was deployed for the project.|
125
+
126
+
127
+ ### queueRulesetsOf
128
+
129
+ Queues rulesets for a project with an attached 721 tiers hook.
130
+
131
+ *Only a project's owner or an operator with the `QUEUE_RULESETS` permission can queue its rulesets.*
132
+
133
+
134
+ ```solidity
135
+ function queueRulesetsOf(
136
+ uint256 projectId,
137
+ JBDeploy721TiersHookConfig calldata deployTiersHookConfig,
138
+ JBQueueRulesetsConfig calldata queueRulesetsConfig,
139
+ IJBController controller,
140
+ bytes32 salt
141
+ )
142
+ external
143
+ override
144
+ returns (uint256 rulesetId, IJB721TiersHook hook);
145
+ ```
146
+ **Parameters**
147
+
148
+ |Name|Type|Description|
149
+ |----|----|-----------|
150
+ |`projectId`|`uint256`|The ID of the project that rulesets are being queued for.|
151
+ |`deployTiersHookConfig`|`JBDeploy721TiersHookConfig`|Configuration which dictates the behavior of the 721 tiers hook which is being deployed.|
152
+ |`queueRulesetsConfig`|`JBQueueRulesetsConfig`|Configuration which dictates the project's newly queued rulesets.|
153
+ |`controller`|`IJBController`|The controller that the project's rulesets will be queued with.|
154
+ |`salt`|`bytes32`|A salt to use for the deterministic deployment.|
155
+
156
+ **Returns**
157
+
158
+ |Name|Type|Description|
159
+ |----|----|-----------|
160
+ |`rulesetId`|`uint256`|The ID of the successfully created ruleset.|
161
+ |`hook`|`IJB721TiersHook`|The 721 tiers hook that was deployed for the project.|
162
+
163
+
164
+ ### _launchProjectFor
165
+
166
+ Launches a project.
167
+
168
+
169
+ ```solidity
170
+ function _launchProjectFor(
171
+ address owner,
172
+ JBLaunchProjectConfig memory launchProjectConfig,
173
+ IJB721TiersHook dataHook,
174
+ IJBController controller
175
+ )
176
+ internal;
177
+ ```
178
+ **Parameters**
179
+
180
+ |Name|Type|Description|
181
+ |----|----|-----------|
182
+ |`owner`|`address`|The address that will own the project.|
183
+ |`launchProjectConfig`|`JBLaunchProjectConfig`|Configuration which dictates the behavior of the project which is being launched.|
184
+ |`dataHook`|`IJB721TiersHook`|The data hook to use for the project.|
185
+ |`controller`|`IJBController`|The controller that the project's rulesets will be queued with.|
186
+
187
+
188
+ ### _launchRulesetsFor
189
+
190
+ Launches rulesets for a project.
191
+
192
+
193
+ ```solidity
194
+ function _launchRulesetsFor(
195
+ uint256 projectId,
196
+ JBLaunchRulesetsConfig memory launchRulesetsConfig,
197
+ IJB721TiersHook dataHook,
198
+ IJBController controller
199
+ )
200
+ internal
201
+ returns (uint256);
202
+ ```
203
+ **Parameters**
204
+
205
+ |Name|Type|Description|
206
+ |----|----|-----------|
207
+ |`projectId`|`uint256`|The ID of the project to launch rulesets for.|
208
+ |`launchRulesetsConfig`|`JBLaunchRulesetsConfig`|Configuration which dictates the behavior of the project's rulesets.|
209
+ |`dataHook`|`IJB721TiersHook`|The data hook to use for the project.|
210
+ |`controller`|`IJBController`|The controller that the project's rulesets will be queued with.|
211
+
212
+ **Returns**
213
+
214
+ |Name|Type|Description|
215
+ |----|----|-----------|
216
+ |`<none>`|`uint256`|rulesetId The ID of the successfully created ruleset.|
217
+
218
+
219
+ ### _queueRulesetsOf
220
+
221
+ Queues rulesets for a project.
222
+
223
+
224
+ ```solidity
225
+ function _queueRulesetsOf(
226
+ uint256 projectId,
227
+ JBQueueRulesetsConfig memory queueRulesetsConfig,
228
+ IJB721TiersHook dataHook,
229
+ IJBController controller
230
+ )
231
+ internal
232
+ returns (uint256);
233
+ ```
234
+ **Parameters**
235
+
236
+ |Name|Type|Description|
237
+ |----|----|-----------|
238
+ |`projectId`|`uint256`|The ID of the project to queue rulesets for.|
239
+ |`queueRulesetsConfig`|`JBQueueRulesetsConfig`|Configuration which dictates the behavior of the project's rulesets.|
240
+ |`dataHook`|`IJB721TiersHook`|The data hook to use for the project.|
241
+ |`controller`|`IJBController`|The controller that the project's rulesets will be queued with.|
242
+
243
+ **Returns**
244
+
245
+ |Name|Type|Description|
246
+ |----|----|-----------|
247
+ |`<none>`|`uint256`|The ID of the successfully created ruleset.|
248
+
249
+
250
+ ### _msgData
251
+
252
+ The calldata. Preferred to use over `msg.data`.
253
+
254
+
255
+ ```solidity
256
+ function _msgData() internal view override(ERC2771Context, Context) returns (bytes calldata);
257
+ ```
258
+ **Returns**
259
+
260
+ |Name|Type|Description|
261
+ |----|----|-----------|
262
+ |`<none>`|`bytes`|calldata The `msg.data` of this call.|
263
+
264
+
265
+ ### _msgSender
266
+
267
+ The message's sender. Preferred to use over `msg.sender`.
268
+
269
+
270
+ ```solidity
271
+ function _msgSender() internal view override(ERC2771Context, Context) returns (address sender);
272
+ ```
273
+ **Returns**
274
+
275
+ |Name|Type|Description|
276
+ |----|----|-----------|
277
+ |`sender`|`address`|The address which sent this call.|
278
+
279
+
280
+ ### _contextSuffixLength
281
+
282
+ *ERC-2771 specifies the context as being a single address (20 bytes).*
283
+
284
+
285
+ ```solidity
286
+ function _contextSuffixLength() internal view virtual override(ERC2771Context, Context) returns (uint256);
287
+ ```
288
+