@bananapus/721-hook-v6 0.0.17 → 0.0.18

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 (43) hide show
  1. package/CHANGE_LOG.md +47 -11
  2. package/package.json +1 -1
  3. package/docs/book.css +0 -13
  4. package/docs/book.toml +0 -12
  5. package/docs/solidity.min.js +0 -74
  6. package/docs/src/README.md +0 -253
  7. package/docs/src/SUMMARY.md +0 -38
  8. package/docs/src/src/JB721TiersHook.sol/contract.JB721TiersHook.md +0 -645
  9. package/docs/src/src/JB721TiersHookDeployer.sol/contract.JB721TiersHookDeployer.md +0 -99
  10. package/docs/src/src/JB721TiersHookProjectDeployer.sol/contract.JB721TiersHookProjectDeployer.md +0 -288
  11. package/docs/src/src/JB721TiersHookStore.sol/contract.JB721TiersHookStore.md +0 -1096
  12. package/docs/src/src/README.md +0 -11
  13. package/docs/src/src/abstract/ERC721.sol/abstract.ERC721.md +0 -430
  14. package/docs/src/src/abstract/JB721Hook.sol/abstract.JB721Hook.md +0 -309
  15. package/docs/src/src/abstract/README.md +0 -5
  16. package/docs/src/src/interfaces/IJB721Hook.sol/interface.IJB721Hook.md +0 -29
  17. package/docs/src/src/interfaces/IJB721TiersHook.sol/interface.IJB721TiersHook.md +0 -203
  18. package/docs/src/src/interfaces/IJB721TiersHookDeployer.sol/interface.IJB721TiersHookDeployer.md +0 -25
  19. package/docs/src/src/interfaces/IJB721TiersHookProjectDeployer.sol/interface.IJB721TiersHookProjectDeployer.md +0 -64
  20. package/docs/src/src/interfaces/IJB721TiersHookStore.sol/interface.IJB721TiersHookStore.md +0 -265
  21. package/docs/src/src/interfaces/IJB721TokenUriResolver.sol/interface.IJB721TokenUriResolver.md +0 -12
  22. package/docs/src/src/interfaces/README.md +0 -9
  23. package/docs/src/src/libraries/JB721Constants.sol/library.JB721Constants.md +0 -14
  24. package/docs/src/src/libraries/JB721TiersRulesetMetadataResolver.sol/library.JB721TiersRulesetMetadataResolver.md +0 -68
  25. package/docs/src/src/libraries/JBBitmap.sol/library.JBBitmap.md +0 -82
  26. package/docs/src/src/libraries/JBIpfsDecoder.sol/library.JBIpfsDecoder.md +0 -61
  27. package/docs/src/src/libraries/README.md +0 -7
  28. package/docs/src/src/structs/JB721InitTiersConfig.sol/struct.JB721InitTiersConfig.md +0 -27
  29. package/docs/src/src/structs/JB721Tier.sol/struct.JB721Tier.md +0 -59
  30. package/docs/src/src/structs/JB721TierConfig.sol/struct.JB721TierConfig.md +0 -60
  31. package/docs/src/src/structs/JB721TiersHookFlags.sol/struct.JB721TiersHookFlags.md +0 -26
  32. package/docs/src/src/structs/JB721TiersMintReservesConfig.sol/struct.JB721TiersMintReservesConfig.md +0 -16
  33. package/docs/src/src/structs/JB721TiersRulesetMetadata.sol/struct.JB721TiersRulesetMetadata.md +0 -20
  34. package/docs/src/src/structs/JB721TiersSetDiscountPercentConfig.sol/struct.JB721TiersSetDiscountPercentConfig.md +0 -16
  35. package/docs/src/src/structs/JBBitmapWord.sol/struct.JBBitmapWord.md +0 -19
  36. package/docs/src/src/structs/JBDeploy721TiersHookConfig.sol/struct.JBDeploy721TiersHookConfig.md +0 -34
  37. package/docs/src/src/structs/JBLaunchProjectConfig.sol/struct.JBLaunchProjectConfig.md +0 -23
  38. package/docs/src/src/structs/JBLaunchRulesetsConfig.sol/struct.JBLaunchRulesetsConfig.md +0 -22
  39. package/docs/src/src/structs/JBPayDataHookRulesetConfig.sol/struct.JBPayDataHookRulesetConfig.md +0 -51
  40. package/docs/src/src/structs/JBPayDataHookRulesetMetadata.sol/struct.JBPayDataHookRulesetMetadata.md +0 -66
  41. package/docs/src/src/structs/JBQueueRulesetsConfig.sol/struct.JBQueueRulesetsConfig.md +0 -21
  42. package/docs/src/src/structs/JBStored721Tier.sol/struct.JBStored721Tier.md +0 -42
  43. package/docs/src/src/structs/README.md +0 -18
package/CHANGE_LOG.md CHANGED
@@ -113,15 +113,27 @@ The ERC721 collection `name` and `symbol` can now be changed after initializatio
113
113
  | `_setName(string memory)` | Updates the token collection name |
114
114
  | `_setSymbol(string memory)` | Updates the token collection symbol |
115
115
 
116
- ### 2.3 `beforePayRecordedWith` Override in `JB721TiersHook`
116
+ ### 2.3 `split.hook` Support in Tier Distribution
117
+
118
+ Tier split payouts now support the `split.hook` field (`IJBSplitHook`). The distribution priority follows the same order as `JBMultiTerminal`: hook > projectId > beneficiary. In v5, tier splits did not exist. In v6, this ensures full parity with core split behavior.
119
+
120
+ ### 2.4 DOS Protection on Split Distribution
121
+
122
+ All external calls during tier split distribution (split hooks, terminal `pay`/`addToBalanceOf`, and leftover distribution) are wrapped in try-catch. A reverting split recipient or terminal cannot brick payments to the project. On failure, funds are returned to the project balance and a `SplitPayoutReverted` or `AddToBalanceReverted` event is emitted with the revert reason. For ERC-20 split hook failures, tokens are transferred first and the hook callback is best-effort; for ERC-20 terminal failures, the approval is reset to zero.
123
+
124
+ ### 2.5 `splitPercent` Bounds Validation
125
+
126
+ `JB721TiersHookStore.recordAddTiers` now validates that each tier's `splitPercent` does not exceed `JBConstants.SPLITS_TOTAL_PERCENT`. If it does, it reverts with `JB721TiersHookStore_SplitPercentExceedsBounds(uint256 percent, uint256 limit)`.
127
+
128
+ ### 2.6 `beforePayRecordedWith` Override in `JB721TiersHook`
117
129
 
118
130
  v6 overrides `beforePayRecordedWith` in `JB721TiersHook` (not just the base `JB721Hook`). The override calculates per-tier split amounts and adjusts the minting weight so the terminal only mints project tokens for the portion of the payment that actually enters the project. It also sets the `JBPayHookSpecification.amount` to the total split amount so the terminal forwards those funds to the hook for distribution.
119
131
 
120
- ### 2.4 Pricing Decimals Validation
132
+ ### 2.7 Pricing Decimals Validation
121
133
 
122
134
  `initialize(...)` now reverts with `JB721TiersHook_InvalidPricingDecimals` if `tiersConfig.decimals > 18`.
123
135
 
124
- ### 2.5 `allowSetCustomToken` Pass-Through
136
+ ### 2.8 `allowSetCustomToken` Pass-Through
125
137
 
126
138
  The `JBPayDataHookRulesetMetadata` struct gained an `allowSetCustomToken` field. In v5, the project deployer hardcoded this to `false`. In v6, it passes through the value from the config.
127
139
 
@@ -133,8 +145,10 @@ The `JBPayDataHookRulesetMetadata` struct gained an `allowSetCustomToken` field.
133
145
 
134
146
  | Event | Signature | Description |
135
147
  |-------|-----------|-------------|
148
+ | `AddToBalanceReverted` | `AddToBalanceReverted(uint256 indexed projectId, address token, uint256 amount, bytes reason)` | Emitted when leftover distribution's `addToBalanceOf` call fails. Funds remain in the hook contract. |
136
149
  | `SetName` | `SetName(string indexed name, address caller)` | Emitted when the collection name is changed |
137
150
  | `SetSymbol` | `SetSymbol(string indexed symbol, address caller)` | Emitted when the collection symbol is changed |
151
+ | `SplitPayoutReverted` | `SplitPayoutReverted(uint256 indexed projectId, JBSplit split, uint256 amount, bytes reason, address caller)` | Emitted when a split payout reverts during distribution. The failed split's funds route to the project balance. |
138
152
 
139
153
  ### 3.2 New Event on `IJB721TiersHookStore`
140
154
 
@@ -144,7 +158,7 @@ The `JBPayDataHookRulesetMetadata` struct gained an `allowSetCustomToken` field.
144
158
 
145
159
  ### 3.3 Events Unchanged
146
160
 
147
- All other events (`AddPayCredits`, `AddTier`, `Mint`, `MintReservedNft`, `RemoveTier`, `SetBaseUri`, `SetContractUri`, `SetDiscountPercent`, `SetEncodedIPFSUri`, `SetTokenUriResolver`, `UsePayCredits`, `CleanTiers`, `HookDeployed`) remain identical.
161
+ All other events (`AddPayCredits`, `AddTier`, `Mint`, `MintReservedNft`, `RemoveTier`, `SetBaseUri`, `SetContractUri`, `SetDiscountPercent`, `SetEncodedIPFSUri`, `SetTokenUriResolver`, `UsePayCredits`, `CleanTiers`, `HookDeployed`) remain unchanged.
148
162
 
149
163
  ---
150
164
 
@@ -157,11 +171,17 @@ All other events (`AddPayCredits`, `AddTier`, `Mint`, `MintReservedNft`, `Remove
157
171
  | `JB721TiersHook_CurrencyMismatch` | `(uint256 paymentCurrency, uint256 tierCurrency)` | Reserved for currency mismatch detection |
158
172
  | `JB721TiersHook_InvalidPricingDecimals` | `(uint256 decimals)` | Reverts when `tiersConfig.decimals > 18` during initialization |
159
173
 
160
- ### 4.2 Store Errors with Added `tierId` Parameter
174
+ ### 4.2 New Error on `JB721TiersHookStore`
175
+
176
+ | Error | Signature | Description |
177
+ |-------|-----------|-------------|
178
+ | `JB721TiersHookStore_SplitPercentExceedsBounds` | `(uint256 percent, uint256 limit)` | Reverts when a tier's `splitPercent` exceeds `JBConstants.SPLITS_TOTAL_PERCENT` during `recordAddTiers` |
179
+
180
+ ### 4.3 Store Errors with Added `tierId` Parameter
161
181
 
162
182
  See Section 1.7 above. Eight store errors gained a `tierId` parameter for improved debuggability.
163
183
 
164
- ### 4.3 Errors Unchanged
184
+ ### 4.4 Errors Unchanged
165
185
 
166
186
  All other errors (`JB721Hook_InvalidPay`, `JB721Hook_InvalidCashOut`, `JB721Hook_UnauthorizedToken`, `JB721Hook_UnexpectedTokenCashedOut`, `JB721TiersHook_AlreadyInitialized`, `JB721TiersHook_NoProjectId`, `JB721TiersHook_Overspending`, `JB721TiersHook_MintReserveNftsPaused`, `JB721TiersHook_TierTransfersPaused`) remain unchanged.
167
187
 
@@ -240,15 +260,31 @@ In v5, `_packedPricingContext` packed three values: currency (bits 0-31), decima
240
260
 
241
261
  v5 reverted if `msg.value != 0` in `afterPayRecordedWith`. v6 removes this check because the hook now accepts forwarded native token payments for tier split distribution.
242
262
 
243
- ### 6.8 `JB721TiersHookStore.recordAddTiers` — Stores `splitPercent`
263
+ ### 6.8 `JB721TiersHookLib._sendPayoutToSplit` — `split.hook` Priority
264
+
265
+ Split payouts follow the same priority order as `JBMultiTerminal`: if `split.hook` is set, funds are sent to the hook via `processSplitWith`; otherwise if `split.projectId` is set, funds go to the project's primary terminal; otherwise funds go to `split.beneficiary`. For ERC-20 payments to hooks, tokens are transferred first and the hook callback is best-effort (failure does not revert).
266
+
267
+ ### 6.9 `JB721TiersHookLib` — Try-Catch on All External Calls
268
+
269
+ All external calls during split distribution (split hooks, terminal `pay`, terminal `addToBalanceOf`, and leftover `addToBalanceOf`) are wrapped in try-catch. On failure: native token calls return false (funds stay in the hook), ERC-20 terminal call approvals are reset to zero, and `SplitPayoutReverted` or `AddToBalanceReverted` events are emitted with the revert reason.
270
+
271
+ ### 6.10 `JB721TiersHookLib.calculateSplitAmounts` — Discount Applied Before Splits
272
+
273
+ Split amounts are calculated on the discount-adjusted (effective) tier price rather than the base price. This ensures the split amount matches the actual price the minter pays when a tier discount is active.
274
+
275
+ ### 6.11 `JB721TiersHookStore.recordAddTiers` — Validates `splitPercent`
276
+
277
+ `recordAddTiers` now reverts with `JB721TiersHookStore_SplitPercentExceedsBounds` if a tier's `splitPercent` exceeds `JBConstants.SPLITS_TOTAL_PERCENT`.
278
+
279
+ ### 6.12 `JB721TiersHookStore.recordAddTiers` — Stores `splitPercent`
244
280
 
245
281
  The store now stores `splitPercent` in the `JBStored721Tier` packed struct (replacing the `votingUnits` field in storage). The `votingUnits` value continues to be stored in the `_tierVotingUnitsOf` mapping.
246
282
 
247
- ### 6.9 `JB721TiersHookStore.recordAddTiers` — Emits `SetDefaultReserveBeneficiary`
283
+ ### 6.13 `JB721TiersHookStore.recordAddTiers` — Emits `SetDefaultReserveBeneficiary`
248
284
 
249
285
  When a tier config has `useReserveBeneficiaryAsDefault` set and the beneficiary differs from the current default, v6 emits the new `SetDefaultReserveBeneficiary` event.
250
286
 
251
- ### 6.10 `JB721TiersHookProjectDeployer` — `allowSetCustomToken` Pass-Through
287
+ ### 6.14 `JB721TiersHookProjectDeployer` — `allowSetCustomToken` Pass-Through
252
288
 
253
289
  In v5, the project deployer hardcoded `allowSetCustomToken: false` when constructing `JBRulesetMetadata`. In v6, it passes through `payDataRulesetConfig.metadata.allowSetCustomToken`.
254
290
 
@@ -261,7 +297,7 @@ In v5, the project deployer hardcoded `allowSetCustomToken: false` when construc
261
297
  | v5 | v6 | Notes |
262
298
  |----|----|-------|
263
299
  | `IJB721Hook` | `IJB721Hook` | Unchanged (import path updated) |
264
- | `IJB721TiersHook` | `IJB721TiersHook` | `pricingContext()` return changed; `setMetadata()` signature changed; added `PRICES()`, `SPLITS()`, `SetName`, `SetSymbol` |
300
+ | `IJB721TiersHook` | `IJB721TiersHook` | `pricingContext()` return changed; `setMetadata()` signature changed; added `PRICES()`, `SPLITS()`, `SetName`, `SetSymbol`, `SplitPayoutReverted`, `AddToBalanceReverted` |
265
301
  | `IJB721TiersHookDeployer` | `IJB721TiersHookDeployer` | Unchanged |
266
302
  | `IJB721TiersHookProjectDeployer` | `IJB721TiersHookProjectDeployer` | Unchanged |
267
303
  | `IJB721TiersHookStore` | `IJB721TiersHookStore` | Added `SetDefaultReserveBeneficiary` event; NatSpec added |
@@ -274,7 +310,7 @@ In v5, the project deployer hardcoded `allowSetCustomToken: false` when construc
274
310
  | `JB721TiersHook` | `JB721TiersHook` | Constructor gains `prices` and `splits`; tier splits system; code extracted to library |
275
311
  | `JB721TiersHookDeployer` | `JB721TiersHookDeployer` | Unchanged (import paths updated) |
276
312
  | `JB721TiersHookProjectDeployer` | `JB721TiersHookProjectDeployer` | `allowSetCustomToken` pass-through |
277
- | `JB721TiersHookStore` | `JB721TiersHookStore` | `splitPercent` storage; error params added; `SetDefaultReserveBeneficiary` event |
313
+ | `JB721TiersHookStore` | `JB721TiersHookStore` | `splitPercent` storage and validation; error params added; `SplitPercentExceedsBounds` error; `SetDefaultReserveBeneficiary` event |
278
314
  | `JB721Hook` (abstract) | `JB721Hook` (abstract) | `cashOutWeightOf`/`totalCashOutWeight` signatures simplified; `msg.value` check removed from `afterPayRecordedWith` |
279
315
  | `ERC721` (abstract) | `ERC721` (abstract) | Added `_setName()` and `_setSymbol()` |
280
316
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bananapus/721-hook-v6",
3
- "version": "0.0.17",
3
+ "version": "0.0.18",
4
4
  "license": "MIT",
5
5
  "repository": {
6
6
  "type": "git",
package/docs/book.css DELETED
@@ -1,13 +0,0 @@
1
- table {
2
- margin: 0 auto;
3
- border-collapse: collapse;
4
- width: 100%;
5
- }
6
-
7
- table td:first-child {
8
- width: 15%;
9
- }
10
-
11
- table td:nth-child(2) {
12
- width: 25%;
13
- }
package/docs/book.toml DELETED
@@ -1,12 +0,0 @@
1
- [book]
2
- src = "src"
3
- title = ""
4
-
5
- [output.html]
6
- no-section-label = true
7
- additional-js = ["solidity.min.js"]
8
- additional-css = ["book.css"]
9
- git-repository-url = "https://github.com/Bananapus/nana-721-hook-v6"
10
-
11
- [output.html.fold]
12
- enable = true
@@ -1,74 +0,0 @@
1
- hljs.registerLanguage("solidity",(()=>{"use strict";function e(){try{return!0
2
- }catch(e){return!1}}
3
- var a=/-?(\b0[xX]([a-fA-F0-9]_?)*[a-fA-F0-9]|(\b[1-9](_?\d)*(\.((\d_?)*\d)?)?|\.\d(_?\d)*)([eE][-+]?\d(_?\d)*)?|\b0)(?!\w|\$)/
4
- ;e()&&(a=a.source.replace(/\\b/g,"(?<!\\$)\\b"));var s={className:"number",
5
- begin:a,relevance:0},n={
6
- keyword:"assembly let function if switch case default for leave break continue u256 jump jumpi stop return revert selfdestruct invalid",
7
- built_in:"add sub mul div sdiv mod smod exp not lt gt slt sgt eq iszero and or xor byte shl shr sar addmod mulmod signextend keccak256 pc pop dup1 dup2 dup3 dup4 dup5 dup6 dup7 dup8 dup9 dup10 dup11 dup12 dup13 dup14 dup15 dup16 swap1 swap2 swap3 swap4 swap5 swap6 swap7 swap8 swap9 swap10 swap11 swap12 swap13 swap14 swap15 swap16 mload mstore mstore8 sload sstore msize gas address balance selfbalance caller callvalue calldataload calldatasize calldatacopy codesize codecopy extcodesize extcodecopy returndatasize returndatacopy extcodehash create create2 call callcode delegatecall staticcall log0 log1 log2 log3 log4 chainid origin gasprice basefee blockhash coinbase timestamp number difficulty gaslimit",
8
- literal:"true false"},i={className:"string",
9
- begin:/\bhex'(([0-9a-fA-F]{2}_?)*[0-9a-fA-F]{2})?'/},t={className:"string",
10
- begin:/\bhex"(([0-9a-fA-F]{2}_?)*[0-9a-fA-F]{2})?"/};function r(e){
11
- return e.inherit(e.APOS_STRING_MODE,{begin:/(\bunicode)?'/})}function l(e){
12
- return e.inherit(e.QUOTE_STRING_MODE,{begin:/(\bunicode)?"/})}var o={
13
- SOL_ASSEMBLY_KEYWORDS:n,baseAssembly:e=>{
14
- var a=r(e),o=l(e),c=/[A-Za-z_$][A-Za-z_$0-9.]*/,d=e.inherit(e.TITLE_MODE,{
15
- begin:/[A-Za-z$_][0-9A-Za-z$_]*/,lexemes:c,keywords:n}),u={className:"params",
16
- begin:/\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,lexemes:c,keywords:n,
17
- contains:[e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE,a,o,s]},_={
18
- className:"operator",begin:/:=|->/};return{keywords:n,lexemes:c,
19
- contains:[a,o,i,t,e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE,s,_,{
20
- className:"function",lexemes:c,beginKeywords:"function",end:"{",excludeEnd:!0,
21
- contains:[d,u,e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE,_]}]}},
22
- solAposStringMode:r,solQuoteStringMode:l,HEX_APOS_STRING_MODE:i,
23
- HEX_QUOTE_STRING_MODE:t,SOL_NUMBER:s,isNegativeLookbehindAvailable:e}
24
- ;const{baseAssembly:c,solAposStringMode:d,solQuoteStringMode:u,HEX_APOS_STRING_MODE:_,HEX_QUOTE_STRING_MODE:m,SOL_NUMBER:b,isNegativeLookbehindAvailable:E}=o
25
- ;return e=>{for(var a=d(e),s=u(e),n=[],i=0;i<32;i++)n[i]=i+1
26
- ;var t=n.map((e=>8*e)),r=[];for(i=0;i<=80;i++)r[i]=i
27
- ;var l=n.map((e=>"bytes"+e)).join(" ")+" ",o=t.map((e=>"uint"+e)).join(" ")+" ",g=t.map((e=>"int"+e)).join(" ")+" ",M=[].concat.apply([],t.map((e=>r.map((a=>e+"x"+a))))),p={
28
- keyword:"var bool string int uint "+g+o+"byte bytes "+l+"fixed ufixed "+M.map((e=>"fixed"+e)).join(" ")+" "+M.map((e=>"ufixed"+e)).join(" ")+" enum struct mapping address new delete if else for while continue break return throw emit try catch revert unchecked _ function modifier event constructor fallback receive error virtual override constant immutable anonymous indexed storage memory calldata external public internal payable pure view private returns import from as using pragma contract interface library is abstract type assembly",
29
- literal:"true false wei gwei szabo finney ether seconds minutes hours days weeks years",
30
- built_in:"self this super selfdestruct suicide now msg block tx abi blockhash gasleft assert require Error Panic sha3 sha256 keccak256 ripemd160 ecrecover addmod mulmod log0 log1 log2 log3 log4"
31
- },O={className:"operator",begin:/[+\-!~*\/%<>&^|=]/
32
- },C=/[A-Za-z_$][A-Za-z_$0-9]*/,N={className:"params",begin:/\(/,end:/\)/,
33
- excludeBegin:!0,excludeEnd:!0,lexemes:C,keywords:p,
34
- contains:[e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE,a,s,b,"self"]},f={
35
- begin:/\.\s*/,end:/[^A-Za-z0-9$_\.]/,excludeBegin:!0,excludeEnd:!0,keywords:{
36
- built_in:"gas value selector address length push pop send transfer call callcode delegatecall staticcall balance code codehash wrap unwrap name creationCode runtimeCode interfaceId min max"
37
- },relevance:2},y=e.inherit(e.TITLE_MODE,{begin:/[A-Za-z$_][0-9A-Za-z$_]*/,
38
- lexemes:C,keywords:p}),w={className:"built_in",
39
- begin:(E()?"(?<!\\$)\\b":"\\b")+"(gas|value|salt)(?=:)"};function x(e,a){return{
40
- begin:(E()?"(?<!\\$)\\b":"\\b")+e+"\\.\\s*",end:/[^A-Za-z0-9$_\.]/,
41
- excludeBegin:!1,excludeEnd:!0,lexemes:C,keywords:{built_in:e+" "+a},
42
- contains:[f],relevance:10}}var h=c(e),v=e.inherit(h,{
43
- contains:h.contains.concat([{begin:/\./,end:/[^A-Za-z0-9$.]/,excludeBegin:!0,
44
- excludeEnd:!0,keywords:{built_in:"slot offset length address selector"},
45
- relevance:2},{begin:/_/,end:/[^A-Za-z0-9$.]/,excludeBegin:!0,excludeEnd:!0,
46
- keywords:{built_in:"slot offset"},relevance:2}])});return{aliases:["sol"],
47
- keywords:p,lexemes:C,
48
- contains:[a,s,_,m,e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE,b,w,O,{
49
- className:"function",lexemes:C,
50
- beginKeywords:"function modifier event constructor fallback receive error",
51
- end:/[{;]/,excludeEnd:!0,
52
- contains:[y,N,w,e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE],illegal:/%/
53
- },x("msg","gas value data sender sig"),x("block","blockhash coinbase difficulty gaslimit basefee number timestamp chainid"),x("tx","gasprice origin"),x("abi","decode encode encodePacked encodeWithSelector encodeWithSignature encodeCall"),x("bytes","concat"),f,{
54
- className:"class",lexemes:C,beginKeywords:"contract interface library",end:"{",
55
- excludeEnd:!0,illegal:/[:"\[\]]/,contains:[{beginKeywords:"is",lexemes:C
56
- },y,N,w,e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE]},{lexemes:C,
57
- beginKeywords:"struct enum",end:"{",excludeEnd:!0,illegal:/[:"\[\]]/,
58
- contains:[y,e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE]},{
59
- beginKeywords:"import",end:";",lexemes:C,keywords:"import from as",
60
- contains:[y,a,s,_,m,e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE,O]},{
61
- beginKeywords:"using",end:";",lexemes:C,keywords:"using for",
62
- contains:[y,e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE,O]},{className:"meta",
63
- beginKeywords:"pragma",end:";",lexemes:C,keywords:{
64
- keyword:"pragma solidity experimental abicoder",
65
- built_in:"ABIEncoderV2 SMTChecker v1 v2"},
66
- contains:[e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE,e.inherit(a,{
67
- className:"meta-string"}),e.inherit(s,{className:"meta-string"})]},{
68
- beginKeywords:"assembly",end:/\b\B/,
69
- contains:[e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE,e.inherit(v,{begin:"{",
70
- end:"}",endsParent:!0,contains:v.contains.concat([e.inherit(v,{begin:"{",
71
- end:"}",contains:v.contains.concat(["self"])})])})]}],illegal:/#/}}})());
72
-
73
- // Ugly hack to reload HLJS
74
- hljs.initHighlightingOnLoad();
@@ -1,253 +0,0 @@
1
- # Bananapus NFT Hook
2
-
3
- `nana-721-hook` is:
4
-
5
- 1. A pay hook for Juicebox projects to sell tiered NFTs (ERC-721s) with different prices and artwork.
6
- 2. (Optionally) a redeem hook which allows holders to burn their NFTs to reclaim funds from the project, in proportion to the NFT's price.
7
-
8
- <details>
9
- <summary>Table of Contents</summary>
10
- <ol>
11
- <li><a href="#usage">Usage</a></li>
12
- <ul>
13
- <li><a href="#install">Install</a></li>
14
- <li><a href="#develop">Develop</a></li>
15
- <li><a href="#scripts">Scripts</a></li>
16
- <li><a href="#deployments">Deployments</a></li>
17
- <ul>
18
- <li><a href="#with-sphinx">With Sphinx</a></li>
19
- <li><a href="#without-sphinx">Without Sphinx</a></li>
20
- </ul>
21
- <li><a href="#tips">Tips</a></li>
22
- </ul>
23
- <li><a href="#repository-layout">Repository Layout</a></li>
24
- <li><a href="#architecture">Architecture</a></li>
25
- <ul>
26
- <li><a href="#contracts">Contracts</a></li>
27
- </ul>
28
- <li><a href="#description">Description</a></li>
29
- <ul>
30
- <li><a href="#hooks">Hooks</a></li>
31
- <li><a href="#mechanism">Mechanism</a></li>
32
- <li><a href="#setup">Setup</a></li>
33
- </ul>
34
- </ul>
35
- </ol>
36
- </details>
37
-
38
- _If you're having trouble understanding this contract, take a look at the [core protocol contracts](https://github.com/Bananapus/nana-core) and the [documentation](https://docs.juicebox.money/) first. If you have questions, reach out on [Discord](https://discord.com/invite/ErQYmth4dS)._
39
-
40
- ## Usage
41
-
42
- ### Install
43
-
44
- How to install `nana-721-hook` in another project.
45
-
46
- For projects using `npm` to manage dependencies (recommended):
47
-
48
- ```bash
49
- npm install @bananapus/721-hook
50
- ```
51
-
52
- For projects using `forge` to manage dependencies (not recommended):
53
-
54
- ```bash
55
- forge install Bananapus/nana-721-hook
56
- ```
57
-
58
- If you're using `forge` to manage dependencies, add `@bananapus/721-hook/=lib/nana-721-hook/` to `remappings.txt`. You'll also need to install `nana-721-hook`'s dependencies and add similar remappings for them.
59
-
60
- ### Develop
61
-
62
- `nana-721-hook` uses [npm](https://www.npmjs.com/) (version >=20.0.0) for package management and the [Foundry](https://github.com/foundry-rs/foundry) development toolchain for builds, tests, and deployments. To get set up, [install Node.js](https://nodejs.org/en/download) and install [Foundry](https://github.com/foundry-rs/foundry):
63
-
64
- ```bash
65
- curl -L https://foundry.paradigm.xyz | sh
66
- ```
67
-
68
- You can download and install dependencies with:
69
-
70
- ```bash
71
- npm ci && forge install
72
- ```
73
-
74
- If you run into trouble with `forge install`, try using `git submodule update --init --recursive` to ensure that nested submodules have been properly initialized.
75
-
76
- Some useful commands:
77
-
78
- | Command | Description |
79
- | --------------------- | --------------------------------------------------- |
80
- | `forge build` | Compile the contracts and write artifacts to `out`. |
81
- | `forge fmt` | Lint. |
82
- | `forge test` | Run the tests. |
83
- | `forge build --sizes` | Get contract sizes. |
84
- | `forge coverage` | Generate a test coverage report. |
85
- | `foundryup` | Update foundry. Run this periodically. |
86
- | `forge clean` | Remove the build artifacts and cache directories. |
87
-
88
- To learn more, visit the [Foundry Book](https://book.getfoundry.sh/) docs.
89
-
90
- ### Scripts
91
-
92
- For convenience, several utility commands are available in `package.json`.
93
-
94
- | Command | Description |
95
- | ------------------- | ------------------------------------------------------- |
96
- | `npm test` | Run local tests. |
97
- | `npm run coverage` | Generate an LCOV test coverage report. |
98
- | `npm run artifacts` | Fetch Sphinx artifacts and write them to `deployments/` |
99
-
100
- ### Deployments
101
-
102
- #### With Sphinx
103
-
104
- `nana-721-hook` manages deployments with [Sphinx](https://www.sphinx.dev). To run the deployment scripts, install the npm `devDependencies` with:
105
-
106
- ```bash
107
- `npm ci --also=dev`
108
- ```
109
-
110
- You'll also need to set up a `.env` file based on `.example.env`. Then run one of the following commands:
111
-
112
- | Command | Description |
113
- | ------------------------- | ---------------------------- |
114
- | `npm run deploy:mainnets` | Propose mainnet deployments. |
115
- | `npm run deploy:testnets` | Propose testnet deployments. |
116
-
117
- Your teammates can review and approve the proposed deployments in the Sphinx UI. Once approved, the deployments will be executed.
118
-
119
- #### Without Sphinx
120
-
121
- You can use the Sphinx CLI to run the deployment scripts without paying for Sphinx. First, install the npm `devDependencies` with:
122
-
123
- ```bash
124
- `npm ci --also=dev`
125
- ```
126
-
127
- You can deploy the contracts like so:
128
-
129
- ```bash
130
- PRIVATE_KEY="0x123..." RPC_ETHEREUM_SEPOLIA="https://rpc.ankr.com/eth_sepolia" npx sphinx deploy script/Deploy.s.sol --network ethereum_sepolia
131
- ```
132
-
133
- This example deploys `nana-721-hook` to the Sepolia testnet using the specified private key. You can configure new networks in `foundry.toml`.
134
-
135
- ### Tips
136
-
137
- To view test coverage, run `npm run coverage` to generate an LCOV test report. You can use an extension like [Coverage Gutters](https://marketplace.visualstudio.com/items?itemName=ryanluker.vscode-coverage-gutters) to view coverage in your editor.
138
-
139
- If you're using Nomic Foundation's [Solidity](https://marketplace.visualstudio.com/items?itemName=NomicFoundation.hardhat-solidity) extension in VSCode, you may run into LSP errors because the extension cannot find dependencies outside of `lib`. You can often fix this by running:
140
-
141
- ```bash
142
- forge remappings >> remappings.txt
143
- ```
144
-
145
- This makes the extension aware of default remappings.
146
-
147
- ## Repository Layout
148
-
149
- The root directory contains this README, an MIT license, and config files. The important source directories are:
150
-
151
- ```
152
- nana-721-hook/
153
- ├── script/
154
- │ ├── Deploy.s.sol - Deploys core contracts - the hook store, deployer, and project deployer.
155
- │ ├── LaunchProjectFor.s.sol - (DEPRECATED) Deploys a project with a 721 tiers hook.
156
- │ └── helpers/
157
- │ └── Hook721DeploymentLib.sol - Internal helpers for deployment scripts.
158
- ├── src/ - Contract source code. Top level contains implementation contracts.
159
- │ ├── JB721TiersHook.sol - The core tiered NFT pay/redeem hook.
160
- │ ├── JB721TiersHookDeployer.sol - Deploys an NFT hook for a project.
161
- │ ├── JB721TiersHookProjectDeployer.sol - Deploys a project with a tiered NFT hook.
162
- │ ├── JB721TiersHookStore.sol - Stores and manages data for tiered NFT hooks.
163
- │ ├── abstract/
164
- │ │ ├── ERC721.sol - Abstract ERC-721 implementation.
165
- │ │ └── JB721Hook.sol - Abstract NFT hook implementation.
166
- │ ├── interfaces/ - Contract interfaces.
167
- │ ├── libraries/ - Libraries.
168
- │ └── structs/ - Structs.
169
- └── test/ - Forge tests and testing utilities.
170
- ├── E2E/
171
- │ └── Pay_Mint_Redeem_E2E.t.sol - End-to-end test for minting and redeeming NFTs.
172
- ├── unit/ - Unit tests for various components..
173
- └── utils/ - Miscellaneous testing utilities.
174
- ```
175
-
176
- Other directories:
177
-
178
- ```
179
- nana-721-hook/
180
- ├── .github/
181
- │ └── workflows/ - CI/CD workflows.
182
- └── deployments/ - Sphinx deployment logs.
183
- ```
184
-
185
- ## Architecture
186
-
187
- ```mermaid
188
- graph TD;
189
- A[JB721TiersHookProjectDeployer] -->|Launches & queues rulesets for| B[Juicebox projects]
190
- D[JB721TiersHookDeployer] -->|Adds NFT hooks to| B
191
- A -->|Deploys| C[JB721TiersHook]
192
- D -->|Deploys| C
193
- B -->|Calls upon pay/redeem| C
194
- C -->|Stores data in| E[JB721TiersHookStore]
195
- B -->|Uses| F[Pay/redeem terminal]
196
- C -->|Mints NFTs upon payment through| F
197
- C -->|Burns NFTs to reclaim funds through| F
198
- ```
199
-
200
- ### Contracts
201
-
202
- | Contract | Description |
203
- | --------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------- |
204
- | [`JB721TiersHook.sol`](https://github.com/Bananapus/nana-721-hook/blob/main/src/JB721TiersHook.sol) | The core tiered NFT pay/redeem hook implementation. |
205
- | [`JB721TiersHookDeployer.sol`](https://github.com/Bananapus/nana-721-hook/blob/main/src/JB721TiersHookDeployer.sol) | Exposes a `deployHookFor(…)` function which allows deploys an NFT hook for a project. |
206
- | [`JB721TiersHookProjectDeployer.sol`](https://github.com/Bananapus/nana-721-hook/blob/main/src/JB721TiersHookProjectDeployer.sol) | Exposes a `launchProjectFor(…)` function which deploys a project with a tiered NFT hook already set up. |
207
- | [`JB721TiersHookStore.sol`](https://github.com/Bananapus/nana-721-hook/blob/main/src/JB721TiersHookStore.sol) | Stores and manages data for tiered NFT hooks. |
208
-
209
- ## Description
210
-
211
- ### Hooks
212
-
213
- This contract is a _data hook_, a _pay hook_, and a _redeem hook_. Data hooks receive information about a payment or a redemption, and put together a payload for the pay/redeem hook to execute.
214
-
215
- Juicebox projects can specify a data hook in their `JBRulesetMetadata`. When someone attempts to pay or redeem from the project, the project's terminal records the payment in the terminal store, passing information about the payment/redemption to the data hook in the process. The data hook responds with a list of payloads – each payload specifies the address of a pay/redeem hook, as well as some custom data and an amount of funds to send to that pay/redeem hook.
216
-
217
- Each pay/redeem hook can then execute custom behavior based on the custom data (and funds) they receive.
218
-
219
- ### Mechanism
220
-
221
- A project using a 721 tiers hook can specify any number of NFT tiers.
222
-
223
- - NFT tiers can be removed by the project owner as long as they are not locked.
224
- - NFT tiers can be added by the project owner as long as they respect the hook's `flags`. The flags specify if newly added tiers can have votes (voting units), if new tiers can have non-zero reserve frequencies, if new tiers can allow on-demand minting by the project's owner, and if the tier can be removed.
225
-
226
- Each tier has the following optional properties:
227
-
228
- - A price.
229
- - A supply (the maximum number of NFTs which can be minted from the tier).
230
- - A token URI (artwork and metadata), which can be overridden by a URI resolver. The URI resolver can return unique values for each NFT in the tier.
231
- - A category, so tiers can be organized and accessed for different purposes.
232
- - A reserve frequency (optional). With a reserve frequency of 5, an extra NFT will be minted to a pre-specified beneficiary address for every 5 NFTs purchased and minted from the tier.
233
- - A number of votes each NFT should represent on-chain (optional).
234
- - A flag to specify whether the NFTs in the tier can always be transferred, or if transfers can be paused depending on the project's ruleset.
235
- - A flag to specify whether the contract's owner can mint NFTs from the tier on-demand.
236
- - A set of flags which restrict tiers added in the future (the votes/reserved frequency/on-demand minting/can be removed flags noted above).
237
-
238
- Additional notes:
239
-
240
- - A payer can specify any number of tiers to mint as long as the total price does not exceed the amount being paid. If tiers aren't specified, their payment mints the most expensive tier possible, unless they specify that the hook should not mint any NFTs.
241
- - If the payment and a tier's price are specified in different currencies, the `JBPrices` contract is used to normalize the values.
242
- - If some of a payment does not go towards purchasing an NFT, those extra funds will be stored as "NFT credits" which can be used for future purchases. Optionally, the hook can disallow credits and reject payments with leftover funds.
243
- - If enabled by the project owner, holders can burn their NFTs to reclaim funds from the project. These redemptions are proportional to the NFTs price, relative to the combined price of all the NFTs.
244
- - NFT redemptions can be enabled by setting `useDataHookForRedeem` to `true` in the project's `JBRulesetMetadata`. If NFT redemptions are enabled, project token redemptions are disabled.
245
- - The hook's deployer can choose if the NFTs should support on-chain voting (as `ERC721Votes`). This increases the gas fees to interact with the NFTs, and should be disabled if not needed.
246
-
247
- ### Setup
248
-
249
- To use a 721 tiers hook, a Juicebox project should be created by a `JB721TiersHookProjectDeployer` instead of a `JBController`. The deployer will create a `JB721TiersHook` (through an associated `JB721TiersHookDeployer`) and add it to the project's first ruleset. New rulesets can be queued with `JB721TiersHookProjectDeployer.queueRulesetsOf(…)` if the project's owner gives the project deployer the permission [`JBPermissions.QUEUE_RULESETS`](https://github.com/Bananapus/nana-permission-ids/blob/master/src/JBPermissionIds.sol) (ID `2`) in [`JBPermissions`](https://github.com/Bananapus/nana-core/blob/main/src/JBPermissions.sol).
250
-
251
- It's also possible to add a 721 tiers hook to an existing project by calling `JB721TiersHookDeployer.deployHookFor(…)` and adding the hook to the project's ruleset – specifically, the project must set their [`JBRulesetMetadata.dataHook`](https://github.com/Bananapus/nana-core/blob/main/src/structs/JBRulesetMetadata.sol) to the newly deployed hook, and enable `JBRulesetMetadata.useDataHookForPay` and/or `JBRulesetMetadata.useDataHookForRedeem` depending on the functionality they'd like to enable.
252
-
253
- All `JB721TiersHook`s store their data in the `JB721TiersHookStore` contract.
@@ -1,38 +0,0 @@
1
- # Summary
2
- - [Home](README.md)
3
- # src
4
- - [❱ abstract](src/abstract/README.md)
5
- - [ERC721](src/abstract/ERC721.sol/abstract.ERC721.md)
6
- - [JB721Hook](src/abstract/JB721Hook.sol/abstract.JB721Hook.md)
7
- - [❱ interfaces](src/interfaces/README.md)
8
- - [IJB721Hook](src/interfaces/IJB721Hook.sol/interface.IJB721Hook.md)
9
- - [IJB721TiersHook](src/interfaces/IJB721TiersHook.sol/interface.IJB721TiersHook.md)
10
- - [IJB721TiersHookDeployer](src/interfaces/IJB721TiersHookDeployer.sol/interface.IJB721TiersHookDeployer.md)
11
- - [IJB721TiersHookProjectDeployer](src/interfaces/IJB721TiersHookProjectDeployer.sol/interface.IJB721TiersHookProjectDeployer.md)
12
- - [IJB721TiersHookStore](src/interfaces/IJB721TiersHookStore.sol/interface.IJB721TiersHookStore.md)
13
- - [IJB721TokenUriResolver](src/interfaces/IJB721TokenUriResolver.sol/interface.IJB721TokenUriResolver.md)
14
- - [❱ libraries](src/libraries/README.md)
15
- - [JB721Constants](src/libraries/JB721Constants.sol/library.JB721Constants.md)
16
- - [JB721TiersRulesetMetadataResolver](src/libraries/JB721TiersRulesetMetadataResolver.sol/library.JB721TiersRulesetMetadataResolver.md)
17
- - [JBBitmap](src/libraries/JBBitmap.sol/library.JBBitmap.md)
18
- - [JBIpfsDecoder](src/libraries/JBIpfsDecoder.sol/library.JBIpfsDecoder.md)
19
- - [❱ structs](src/structs/README.md)
20
- - [JB721InitTiersConfig](src/structs/JB721InitTiersConfig.sol/struct.JB721InitTiersConfig.md)
21
- - [JB721Tier](src/structs/JB721Tier.sol/struct.JB721Tier.md)
22
- - [JB721TierConfig](src/structs/JB721TierConfig.sol/struct.JB721TierConfig.md)
23
- - [JB721TiersHookFlags](src/structs/JB721TiersHookFlags.sol/struct.JB721TiersHookFlags.md)
24
- - [JB721TiersMintReservesConfig](src/structs/JB721TiersMintReservesConfig.sol/struct.JB721TiersMintReservesConfig.md)
25
- - [JB721TiersRulesetMetadata](src/structs/JB721TiersRulesetMetadata.sol/struct.JB721TiersRulesetMetadata.md)
26
- - [JB721TiersSetDiscountPercentConfig](src/structs/JB721TiersSetDiscountPercentConfig.sol/struct.JB721TiersSetDiscountPercentConfig.md)
27
- - [JBBitmapWord](src/structs/JBBitmapWord.sol/struct.JBBitmapWord.md)
28
- - [JBDeploy721TiersHookConfig](src/structs/JBDeploy721TiersHookConfig.sol/struct.JBDeploy721TiersHookConfig.md)
29
- - [JBLaunchProjectConfig](src/structs/JBLaunchProjectConfig.sol/struct.JBLaunchProjectConfig.md)
30
- - [JBLaunchRulesetsConfig](src/structs/JBLaunchRulesetsConfig.sol/struct.JBLaunchRulesetsConfig.md)
31
- - [JBPayDataHookRulesetConfig](src/structs/JBPayDataHookRulesetConfig.sol/struct.JBPayDataHookRulesetConfig.md)
32
- - [JBPayDataHookRulesetMetadata](src/structs/JBPayDataHookRulesetMetadata.sol/struct.JBPayDataHookRulesetMetadata.md)
33
- - [JBQueueRulesetsConfig](src/structs/JBQueueRulesetsConfig.sol/struct.JBQueueRulesetsConfig.md)
34
- - [JBStored721Tier](src/structs/JBStored721Tier.sol/struct.JBStored721Tier.md)
35
- - [JB721TiersHook](src/JB721TiersHook.sol/contract.JB721TiersHook.md)
36
- - [JB721TiersHookDeployer](src/JB721TiersHookDeployer.sol/contract.JB721TiersHookDeployer.md)
37
- - [JB721TiersHookProjectDeployer](src/JB721TiersHookProjectDeployer.sol/contract.JB721TiersHookProjectDeployer.md)
38
- - [JB721TiersHookStore](src/JB721TiersHookStore.sol/contract.JB721TiersHookStore.md)