@bananapus/721-hook-v6 0.0.9 → 0.0.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/foundry.toml +1 -1
- package/package.json +4 -4
- package/src/JB721TiersHook.sol +9 -9
- package/src/JB721TiersHookDeployer.sol +2 -2
- package/src/JB721TiersHookProjectDeployer.sol +24 -20
- package/src/JB721TiersHookStore.sol +12 -12
- package/src/abstract/JB721Hook.sol +44 -44
- package/src/interfaces/IJB721Hook.sol +1 -0
- package/src/interfaces/IJB721TiersHook.sol +73 -17
- package/src/interfaces/IJB721TiersHookDeployer.sol +5 -0
- package/src/interfaces/IJB721TiersHookProjectDeployer.sol +2 -1
- package/src/interfaces/IJB721TiersHookStore.sol +4 -0
- package/src/interfaces/IJB721TokenUriResolver.sol +1 -0
package/foundry.toml
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bananapus/721-hook-v6",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.10",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -18,9 +18,9 @@
|
|
|
18
18
|
},
|
|
19
19
|
"dependencies": {
|
|
20
20
|
"@bananapus/address-registry-v6": "^0.0.4",
|
|
21
|
-
"@bananapus/core-v6": "^0.0.
|
|
22
|
-
"@bananapus/ownable-v6": "^0.0.
|
|
23
|
-
"@bananapus/permission-ids-v6": "^0.0.
|
|
21
|
+
"@bananapus/core-v6": "^0.0.10",
|
|
22
|
+
"@bananapus/ownable-v6": "^0.0.6",
|
|
23
|
+
"@bananapus/permission-ids-v6": "^0.0.5",
|
|
24
24
|
"@openzeppelin/contracts": "5.2.0",
|
|
25
25
|
"@prb/math": "^4.1.0",
|
|
26
26
|
"solady": "^0.1.8"
|
package/src/JB721TiersHook.sol
CHANGED
|
@@ -23,12 +23,12 @@ import {IJB721TiersHookStore} from "./interfaces/IJB721TiersHookStore.sol";
|
|
|
23
23
|
import {IJB721TokenUriResolver} from "./interfaces/IJB721TokenUriResolver.sol";
|
|
24
24
|
import {JB721TiersHookLib} from "./libraries/JB721TiersHookLib.sol";
|
|
25
25
|
import {JB721TiersRulesetMetadataResolver} from "./libraries/JB721TiersRulesetMetadataResolver.sol";
|
|
26
|
+
import {JB721InitTiersConfig} from "./structs/JB721InitTiersConfig.sol";
|
|
26
27
|
import {JB721Tier} from "./structs/JB721Tier.sol";
|
|
27
28
|
import {JB721TierConfig} from "./structs/JB721TierConfig.sol";
|
|
28
|
-
import {JB721TiersSetDiscountPercentConfig} from "./structs/JB721TiersSetDiscountPercentConfig.sol";
|
|
29
|
-
import {JB721InitTiersConfig} from "./structs/JB721InitTiersConfig.sol";
|
|
30
29
|
import {JB721TiersHookFlags} from "./structs/JB721TiersHookFlags.sol";
|
|
31
30
|
import {JB721TiersMintReservesConfig} from "./structs/JB721TiersMintReservesConfig.sol";
|
|
31
|
+
import {JB721TiersSetDiscountPercentConfig} from "./structs/JB721TiersSetDiscountPercentConfig.sol";
|
|
32
32
|
|
|
33
33
|
/// @title JB721TiersHook
|
|
34
34
|
/// @notice A Juicebox project can use this hook to sell tiered ERC-721 NFTs with different prices and metadata. When
|
|
@@ -190,13 +190,6 @@ contract JB721TiersHook is JBOwnable, ERC2771Context, JB721Hook, IJB721TiersHook
|
|
|
190
190
|
return STORE.cashOutWeightOf({hook: address(this), tokenIds: tokenIds});
|
|
191
191
|
}
|
|
192
192
|
|
|
193
|
-
/// @notice Indicates if this contract adheres to the specified interface.
|
|
194
|
-
/// @dev See {IERC165-supportsInterface}.
|
|
195
|
-
/// @param interfaceId The ID of the interface to check for adherence to.
|
|
196
|
-
function supportsInterface(bytes4 interfaceId) public view override(IERC165, JB721Hook) returns (bool) {
|
|
197
|
-
return interfaceId == type(IJB721TiersHook).interfaceId || JB721Hook.supportsInterface(interfaceId);
|
|
198
|
-
}
|
|
199
|
-
|
|
200
193
|
/// @notice Initializes a cloned copy of the original hook contract.
|
|
201
194
|
/// @param projectId The ID of the project this this hook is associated with.
|
|
202
195
|
/// @param name The name of the NFT collection.
|
|
@@ -269,6 +262,13 @@ contract JB721TiersHook is JBOwnable, ERC2771Context, JB721Hook, IJB721TiersHook
|
|
|
269
262
|
_transferOwnership(_msgSender());
|
|
270
263
|
}
|
|
271
264
|
|
|
265
|
+
/// @notice Indicates if this contract adheres to the specified interface.
|
|
266
|
+
/// @dev See {IERC165-supportsInterface}.
|
|
267
|
+
/// @param interfaceId The ID of the interface to check for adherence to.
|
|
268
|
+
function supportsInterface(bytes4 interfaceId) public view override(IERC165, JB721Hook) returns (bool) {
|
|
269
|
+
return interfaceId == type(IJB721TiersHook).interfaceId || JB721Hook.supportsInterface(interfaceId);
|
|
270
|
+
}
|
|
271
|
+
|
|
272
272
|
/// @notice The metadata URI of the NFT with the specified token ID.
|
|
273
273
|
/// @dev Defers to the `tokenUriResolver` if it is set. Otherwise, use the `tokenUri` corresponding with the NFT's
|
|
274
274
|
/// tier.
|
|
@@ -3,12 +3,12 @@ pragma solidity 0.8.26;
|
|
|
3
3
|
|
|
4
4
|
import {IJBAddressRegistry} from "@bananapus/address-registry-v6/src/interfaces/IJBAddressRegistry.sol";
|
|
5
5
|
import {JBOwnable} from "@bananapus/ownable-v6/src/JBOwnable.sol";
|
|
6
|
-
import {LibClone} from "solady/src/utils/LibClone.sol";
|
|
7
6
|
import {ERC2771Context} from "@openzeppelin/contracts/metatx/ERC2771Context.sol";
|
|
7
|
+
import {LibClone} from "solady/src/utils/LibClone.sol";
|
|
8
8
|
|
|
9
9
|
import {JB721TiersHook} from "./JB721TiersHook.sol";
|
|
10
|
-
import {IJB721TiersHookDeployer} from "./interfaces/IJB721TiersHookDeployer.sol";
|
|
11
10
|
import {IJB721TiersHook} from "./interfaces/IJB721TiersHook.sol";
|
|
11
|
+
import {IJB721TiersHookDeployer} from "./interfaces/IJB721TiersHookDeployer.sol";
|
|
12
12
|
import {IJB721TiersHookStore} from "./interfaces/IJB721TiersHookStore.sol";
|
|
13
13
|
import {JBDeploy721TiersHookConfig} from "./structs/JBDeploy721TiersHookConfig.sol";
|
|
14
14
|
|
|
@@ -13,14 +13,14 @@ import {JBPermissionIds} from "@bananapus/permission-ids-v6/src/JBPermissionIds.
|
|
|
13
13
|
import {ERC2771Context} from "@openzeppelin/contracts/metatx/ERC2771Context.sol";
|
|
14
14
|
import {Context} from "@openzeppelin/contracts/utils/Context.sol";
|
|
15
15
|
|
|
16
|
+
import {IJB721TiersHook} from "./interfaces/IJB721TiersHook.sol";
|
|
16
17
|
import {IJB721TiersHookDeployer} from "./interfaces/IJB721TiersHookDeployer.sol";
|
|
17
18
|
import {IJB721TiersHookProjectDeployer} from "./interfaces/IJB721TiersHookProjectDeployer.sol";
|
|
18
|
-
import {IJB721TiersHook} from "./interfaces/IJB721TiersHook.sol";
|
|
19
19
|
import {JBDeploy721TiersHookConfig} from "./structs/JBDeploy721TiersHookConfig.sol";
|
|
20
|
-
import {JBLaunchRulesetsConfig} from "./structs/JBLaunchRulesetsConfig.sol";
|
|
21
|
-
import {JBQueueRulesetsConfig} from "./structs/JBQueueRulesetsConfig.sol";
|
|
22
20
|
import {JBLaunchProjectConfig} from "./structs/JBLaunchProjectConfig.sol";
|
|
21
|
+
import {JBLaunchRulesetsConfig} from "./structs/JBLaunchRulesetsConfig.sol";
|
|
23
22
|
import {JBPayDataHookRulesetConfig} from "./structs/JBPayDataHookRulesetConfig.sol";
|
|
23
|
+
import {JBQueueRulesetsConfig} from "./structs/JBQueueRulesetsConfig.sol";
|
|
24
24
|
|
|
25
25
|
/// @title JB721TiersHookProjectDeployer
|
|
26
26
|
/// @notice Deploys a project and a 721 tiers hook for it. Can be used to queue rulesets for the project if given
|
|
@@ -195,6 +195,27 @@ contract JB721TiersHookProjectDeployer is ERC2771Context, JBPermissioned, IJB721
|
|
|
195
195
|
});
|
|
196
196
|
}
|
|
197
197
|
|
|
198
|
+
//*********************************************************************//
|
|
199
|
+
// -------------------------- internal views ------------------------- //
|
|
200
|
+
//*********************************************************************//
|
|
201
|
+
|
|
202
|
+
/// @dev ERC-2771 specifies the context as being a single address (20 bytes).
|
|
203
|
+
function _contextSuffixLength() internal view virtual override(ERC2771Context, Context) returns (uint256) {
|
|
204
|
+
return ERC2771Context._contextSuffixLength();
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
/// @notice The calldata. Preferred to use over `msg.data`.
|
|
208
|
+
/// @return calldata The `msg.data` of this call.
|
|
209
|
+
function _msgData() internal view override(ERC2771Context, Context) returns (bytes calldata) {
|
|
210
|
+
return ERC2771Context._msgData();
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
/// @notice The message's sender. Preferred to use over `msg.sender`.
|
|
214
|
+
/// @return sender The address which sent this call.
|
|
215
|
+
function _msgSender() internal view override(ERC2771Context, Context) returns (address sender) {
|
|
216
|
+
return ERC2771Context._msgSender();
|
|
217
|
+
}
|
|
218
|
+
|
|
198
219
|
//*********************************************************************//
|
|
199
220
|
// ------------------------ internal functions ----------------------- //
|
|
200
221
|
//*********************************************************************//
|
|
@@ -393,21 +414,4 @@ contract JB721TiersHookProjectDeployer is ERC2771Context, JBPermissioned, IJB721
|
|
|
393
414
|
projectId: projectId, rulesetConfigurations: rulesetConfigurations, memo: queueRulesetsConfig.memo
|
|
394
415
|
});
|
|
395
416
|
}
|
|
396
|
-
|
|
397
|
-
/// @notice The calldata. Preferred to use over `msg.data`.
|
|
398
|
-
/// @return calldata The `msg.data` of this call.
|
|
399
|
-
function _msgData() internal view override(ERC2771Context, Context) returns (bytes calldata) {
|
|
400
|
-
return ERC2771Context._msgData();
|
|
401
|
-
}
|
|
402
|
-
|
|
403
|
-
/// @notice The message's sender. Preferred to use over `msg.sender`.
|
|
404
|
-
/// @return sender The address which sent this call.
|
|
405
|
-
function _msgSender() internal view override(ERC2771Context, Context) returns (address sender) {
|
|
406
|
-
return ERC2771Context._msgSender();
|
|
407
|
-
}
|
|
408
|
-
|
|
409
|
-
/// @dev ERC-2771 specifies the context as being a single address (20 bytes).
|
|
410
|
-
function _contextSuffixLength() internal view virtual override(ERC2771Context, Context) returns (uint256) {
|
|
411
|
-
return ERC2771Context._contextSuffixLength();
|
|
412
|
-
}
|
|
413
417
|
}
|
|
@@ -383,18 +383,6 @@ contract JB721TiersHookStore is IJB721TiersHookStore {
|
|
|
383
383
|
// -------------------------- public views --------------------------- //
|
|
384
384
|
//*********************************************************************//
|
|
385
385
|
|
|
386
|
-
/// @notice Get the tier with the provided ID from the provided 721 contract.
|
|
387
|
-
/// @param hook The 721 contract to get the tier from.
|
|
388
|
-
/// @param id The ID of the tier to get.
|
|
389
|
-
/// @param includeResolvedUri If set to `true`, if the contract has a token URI resolver, its content will be
|
|
390
|
-
/// resolved and included.
|
|
391
|
-
/// @return The tier.
|
|
392
|
-
function tierOf(address hook, uint256 id, bool includeResolvedUri) public view override returns (JB721Tier memory) {
|
|
393
|
-
return _getTierFrom({
|
|
394
|
-
hook: hook, tierId: id, storedTier: _storedTierOf[hook][id], includeResolvedUri: includeResolvedUri
|
|
395
|
-
});
|
|
396
|
-
}
|
|
397
|
-
|
|
398
386
|
/// @notice Get the number of NFTs that the specified address has from the specified 721 contract (across all
|
|
399
387
|
/// tiers).
|
|
400
388
|
/// @param hook The 721 contract to get the balance within.
|
|
@@ -454,6 +442,18 @@ contract JB721TiersHookStore is IJB721TiersHookStore {
|
|
|
454
442
|
return tokenId / _ONE_BILLION;
|
|
455
443
|
}
|
|
456
444
|
|
|
445
|
+
/// @notice Get the tier with the provided ID from the provided 721 contract.
|
|
446
|
+
/// @param hook The 721 contract to get the tier from.
|
|
447
|
+
/// @param id The ID of the tier to get.
|
|
448
|
+
/// @param includeResolvedUri If set to `true`, if the contract has a token URI resolver, its content will be
|
|
449
|
+
/// resolved and included.
|
|
450
|
+
/// @return The tier.
|
|
451
|
+
function tierOf(address hook, uint256 id, bool includeResolvedUri) public view override returns (JB721Tier memory) {
|
|
452
|
+
return _getTierFrom({
|
|
453
|
+
hook: hook, tierId: id, storedTier: _storedTierOf[hook][id], includeResolvedUri: includeResolvedUri
|
|
454
|
+
});
|
|
455
|
+
}
|
|
456
|
+
|
|
457
457
|
/// @notice The combined cash out weight for all NFTs from the provided 721 contract.
|
|
458
458
|
/// @param hook The 721 contract to get the total cash out weight of.
|
|
459
459
|
/// @return weight The total cash out weight.
|
|
@@ -17,8 +17,8 @@ import {JBRuleset} from "@bananapus/core-v6/src/structs/JBRuleset.sol";
|
|
|
17
17
|
import {IERC2981} from "@openzeppelin/contracts/interfaces/IERC2981.sol";
|
|
18
18
|
import {IERC165} from "@openzeppelin/contracts/utils/introspection/IERC165.sol";
|
|
19
19
|
|
|
20
|
-
import {ERC721} from "./ERC721.sol";
|
|
21
20
|
import {IJB721Hook} from "../interfaces/IJB721Hook.sol";
|
|
21
|
+
import {ERC721} from "./ERC721.sol";
|
|
22
22
|
|
|
23
23
|
/// @title JB721Hook
|
|
24
24
|
/// @notice When a project which uses this hook is paid, this hook may mint NFTs to the payer, depending on this hook's
|
|
@@ -68,26 +68,6 @@ abstract contract JB721Hook is ERC721, IJB721Hook {
|
|
|
68
68
|
// ------------------------- external views -------------------------- //
|
|
69
69
|
//*********************************************************************//
|
|
70
70
|
|
|
71
|
-
/// @notice The data calculated before a payment is recorded in the terminal store. This data is provided to the
|
|
72
|
-
/// terminal's `pay(...)` transaction.
|
|
73
|
-
/// @dev Sets this contract as the pay hook. Part of `IJBRulesetDataHook`.
|
|
74
|
-
/// @param context The payment context passed to this contract by the `pay(...)` function.
|
|
75
|
-
/// @return weight The new `weight` to use, overriding the ruleset's `weight`.
|
|
76
|
-
/// @return hookSpecifications The amount and data to send to pay hooks (this contract) instead of adding to the
|
|
77
|
-
/// terminal's balance.
|
|
78
|
-
function beforePayRecordedWith(JBBeforePayRecordedContext calldata context)
|
|
79
|
-
public
|
|
80
|
-
view
|
|
81
|
-
virtual
|
|
82
|
-
override
|
|
83
|
-
returns (uint256 weight, JBPayHookSpecification[] memory hookSpecifications)
|
|
84
|
-
{
|
|
85
|
-
// Forward the received weight and use this contract as the only pay hook.
|
|
86
|
-
weight = context.weight;
|
|
87
|
-
hookSpecifications = new JBPayHookSpecification[](1);
|
|
88
|
-
hookSpecifications[0] = JBPayHookSpecification({hook: this, amount: 0, metadata: bytes("")});
|
|
89
|
-
}
|
|
90
|
-
|
|
91
71
|
/// @notice The data calculated before a cash out is recorded in the terminal store. This data is provided to the
|
|
92
72
|
/// terminal's `cashOutTokensOf(...)` transaction.
|
|
93
73
|
/// @dev Sets this contract as the cash out hook. Part of `IJBRulesetDataHook`.
|
|
@@ -138,6 +118,26 @@ abstract contract JB721Hook is ERC721, IJB721Hook {
|
|
|
138
118
|
cashOutTaxRate = context.cashOutTaxRate;
|
|
139
119
|
}
|
|
140
120
|
|
|
121
|
+
/// @notice The data calculated before a payment is recorded in the terminal store. This data is provided to the
|
|
122
|
+
/// terminal's `pay(...)` transaction.
|
|
123
|
+
/// @dev Sets this contract as the pay hook. Part of `IJBRulesetDataHook`.
|
|
124
|
+
/// @param context The payment context passed to this contract by the `pay(...)` function.
|
|
125
|
+
/// @return weight The new `weight` to use, overriding the ruleset's `weight`.
|
|
126
|
+
/// @return hookSpecifications The amount and data to send to pay hooks (this contract) instead of adding to the
|
|
127
|
+
/// terminal's balance.
|
|
128
|
+
function beforePayRecordedWith(JBBeforePayRecordedContext calldata context)
|
|
129
|
+
public
|
|
130
|
+
view
|
|
131
|
+
virtual
|
|
132
|
+
override
|
|
133
|
+
returns (uint256 weight, JBPayHookSpecification[] memory hookSpecifications)
|
|
134
|
+
{
|
|
135
|
+
// Forward the received weight and use this contract as the only pay hook.
|
|
136
|
+
weight = context.weight;
|
|
137
|
+
hookSpecifications = new JBPayHookSpecification[](1);
|
|
138
|
+
hookSpecifications[0] = JBPayHookSpecification({hook: this, amount: 0, metadata: bytes("")});
|
|
139
|
+
}
|
|
140
|
+
|
|
141
141
|
/// @notice Required by the IJBRulesetDataHook interfaces. Return false to not leak any permissions.
|
|
142
142
|
function hasMintPermissionFor(uint256, JBRuleset memory, address) external pure returns (bool) {
|
|
143
143
|
return false;
|
|
@@ -175,24 +175,6 @@ abstract contract JB721Hook is ERC721, IJB721Hook {
|
|
|
175
175
|
// ---------------------- external transactions ---------------------- //
|
|
176
176
|
//*********************************************************************//
|
|
177
177
|
|
|
178
|
-
/// @notice Mints one or more NFTs to the `context.beneficiary` upon payment if conditions are met. Part of
|
|
179
|
-
/// `IJBPayHook`.
|
|
180
|
-
/// @dev Reverts if the calling contract is not one of the project's terminals.
|
|
181
|
-
/// @param context The payment context passed in by the terminal.
|
|
182
|
-
// slither-disable-next-line locked-ether
|
|
183
|
-
function afterPayRecordedWith(JBAfterPayRecordedContext calldata context) external payable virtual override {
|
|
184
|
-
uint256 projectId = PROJECT_ID;
|
|
185
|
-
|
|
186
|
-
// Make sure the caller is a terminal of the project, and that the call is being made on behalf of an
|
|
187
|
-
// interaction with the correct project.
|
|
188
|
-
if (!DIRECTORY.isTerminalOf(projectId, IJBTerminal(msg.sender)) || context.projectId != projectId) {
|
|
189
|
-
revert JB721Hook_InvalidPay();
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
// Process the payment.
|
|
193
|
-
_processPayment(context);
|
|
194
|
-
}
|
|
195
|
-
|
|
196
178
|
/// @notice Burns the specified NFTs upon token holder cash out, reclaiming funds from the project's balance for
|
|
197
179
|
/// `context.beneficiary`. Part of `IJBCashOutHook`.
|
|
198
180
|
/// @dev Reverts if the calling contract is not one of the project's terminals.
|
|
@@ -241,10 +223,32 @@ abstract contract JB721Hook is ERC721, IJB721Hook {
|
|
|
241
223
|
_didBurn(decodedTokenIds);
|
|
242
224
|
}
|
|
243
225
|
|
|
226
|
+
/// @notice Mints one or more NFTs to the `context.beneficiary` upon payment if conditions are met. Part of
|
|
227
|
+
/// `IJBPayHook`.
|
|
228
|
+
/// @dev Reverts if the calling contract is not one of the project's terminals.
|
|
229
|
+
/// @param context The payment context passed in by the terminal.
|
|
230
|
+
// slither-disable-next-line locked-ether
|
|
231
|
+
function afterPayRecordedWith(JBAfterPayRecordedContext calldata context) external payable virtual override {
|
|
232
|
+
uint256 projectId = PROJECT_ID;
|
|
233
|
+
|
|
234
|
+
// Make sure the caller is a terminal of the project, and that the call is being made on behalf of an
|
|
235
|
+
// interaction with the correct project.
|
|
236
|
+
if (!DIRECTORY.isTerminalOf(projectId, IJBTerminal(msg.sender)) || context.projectId != projectId) {
|
|
237
|
+
revert JB721Hook_InvalidPay();
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
// Process the payment.
|
|
241
|
+
_processPayment(context);
|
|
242
|
+
}
|
|
243
|
+
|
|
244
244
|
//*********************************************************************//
|
|
245
|
-
//
|
|
245
|
+
// ------------------------ internal functions ----------------------- //
|
|
246
246
|
//*********************************************************************//
|
|
247
247
|
|
|
248
|
+
/// @notice Executes after NFTs have been burned via cash out.
|
|
249
|
+
/// @param tokenIds The token IDs of the NFTs that were burned.
|
|
250
|
+
function _didBurn(uint256[] memory tokenIds) internal virtual;
|
|
251
|
+
|
|
248
252
|
/// @notice Initializes the contract by associating it with a project and adding ERC721 details.
|
|
249
253
|
/// @param projectId The ID of the project that this contract is associated with.
|
|
250
254
|
/// @param name The name of the NFT collection.
|
|
@@ -254,10 +258,6 @@ abstract contract JB721Hook is ERC721, IJB721Hook {
|
|
|
254
258
|
PROJECT_ID = projectId;
|
|
255
259
|
}
|
|
256
260
|
|
|
257
|
-
/// @notice Executes after NFTs have been burned via cash out.
|
|
258
|
-
/// @param tokenIds The token IDs of the NFTs that were burned.
|
|
259
|
-
function _didBurn(uint256[] memory tokenIds) internal virtual;
|
|
260
|
-
|
|
261
261
|
/// @notice Process a received payment.
|
|
262
262
|
/// @param context The payment context passed in by the terminal.
|
|
263
263
|
function _processPayment(JBAfterPayRecordedContext calldata context) internal virtual;
|
|
@@ -6,6 +6,7 @@ import {IJBDirectory} from "@bananapus/core-v6/src/interfaces/IJBDirectory.sol";
|
|
|
6
6
|
import {IJBPayHook} from "@bananapus/core-v6/src/interfaces/IJBPayHook.sol";
|
|
7
7
|
import {IJBRulesetDataHook} from "@bananapus/core-v6/src/interfaces/IJBRulesetDataHook.sol";
|
|
8
8
|
|
|
9
|
+
/// @notice A 721 hook that integrates with Juicebox as a data hook, pay hook, and cash out hook.
|
|
9
10
|
interface IJB721Hook is IJBRulesetDataHook, IJBPayHook, IJBCashOutHook {
|
|
10
11
|
/// @notice The directory of terminals and controllers for projects.
|
|
11
12
|
/// @return The directory contract.
|
|
@@ -13,11 +13,29 @@ import {JB721TiersHookFlags} from "../structs/JB721TiersHookFlags.sol";
|
|
|
13
13
|
import {JB721TiersMintReservesConfig} from "../structs/JB721TiersMintReservesConfig.sol";
|
|
14
14
|
import {JB721TiersSetDiscountPercentConfig} from "../structs/JB721TiersSetDiscountPercentConfig.sol";
|
|
15
15
|
|
|
16
|
+
/// @notice A 721 tiers hook that mints tiered NFTs for payments and tracks their cash out weight.
|
|
16
17
|
interface IJB721TiersHook is IJB721Hook {
|
|
18
|
+
/// @notice Emitted when pay credits are added for an account.
|
|
19
|
+
/// @param amount The amount of credits added.
|
|
20
|
+
/// @param newTotalCredits The new total credits balance for the account.
|
|
21
|
+
/// @param account The account that received the credits.
|
|
22
|
+
/// @param caller The address that called the function.
|
|
17
23
|
event AddPayCredits(
|
|
18
24
|
uint256 indexed amount, uint256 indexed newTotalCredits, address indexed account, address caller
|
|
19
25
|
);
|
|
26
|
+
|
|
27
|
+
/// @notice Emitted when a new tier is added.
|
|
28
|
+
/// @param tierId The ID of the tier that was added.
|
|
29
|
+
/// @param tier The configuration of the tier that was added.
|
|
30
|
+
/// @param caller The address that called the function.
|
|
20
31
|
event AddTier(uint256 indexed tierId, JB721TierConfig tier, address caller);
|
|
32
|
+
|
|
33
|
+
/// @notice Emitted when an NFT is minted from a payment.
|
|
34
|
+
/// @param tokenId The token ID of the minted NFT.
|
|
35
|
+
/// @param tierId The ID of the tier the NFT was minted from.
|
|
36
|
+
/// @param beneficiary The address that received the NFT.
|
|
37
|
+
/// @param totalAmountPaid The total amount paid in the transaction.
|
|
38
|
+
/// @param caller The address that called the function.
|
|
21
39
|
event Mint(
|
|
22
40
|
uint256 indexed tokenId,
|
|
23
41
|
uint256 indexed tierId,
|
|
@@ -25,25 +43,55 @@ interface IJB721TiersHook is IJB721Hook {
|
|
|
25
43
|
uint256 totalAmountPaid,
|
|
26
44
|
address caller
|
|
27
45
|
);
|
|
46
|
+
|
|
47
|
+
/// @notice Emitted when a reserved NFT is minted.
|
|
48
|
+
/// @param tokenId The token ID of the minted reserved NFT.
|
|
49
|
+
/// @param tierId The ID of the tier the reserved NFT was minted from.
|
|
50
|
+
/// @param beneficiary The address that received the reserved NFT.
|
|
51
|
+
/// @param caller The address that called the function.
|
|
28
52
|
event MintReservedNft(uint256 indexed tokenId, uint256 indexed tierId, address indexed beneficiary, address caller);
|
|
53
|
+
|
|
54
|
+
/// @notice Emitted when a tier is removed.
|
|
55
|
+
/// @param tierId The ID of the tier that was removed.
|
|
56
|
+
/// @param caller The address that called the function.
|
|
29
57
|
event RemoveTier(uint256 indexed tierId, address caller);
|
|
58
|
+
|
|
59
|
+
/// @notice Emitted when the base URI is set.
|
|
60
|
+
/// @param baseUri The new base URI.
|
|
61
|
+
/// @param caller The address that called the function.
|
|
30
62
|
event SetBaseUri(string indexed baseUri, address caller);
|
|
63
|
+
|
|
64
|
+
/// @notice Emitted when the contract URI is set.
|
|
65
|
+
/// @param uri The new contract URI.
|
|
66
|
+
/// @param caller The address that called the function.
|
|
31
67
|
event SetContractUri(string indexed uri, address caller);
|
|
68
|
+
|
|
69
|
+
/// @notice Emitted when a tier's discount percent is set.
|
|
70
|
+
/// @param tierId The ID of the tier whose discount percent was set.
|
|
71
|
+
/// @param discountPercent The new discount percent.
|
|
72
|
+
/// @param caller The address that called the function.
|
|
32
73
|
event SetDiscountPercent(uint256 indexed tierId, uint256 discountPercent, address caller);
|
|
74
|
+
|
|
75
|
+
/// @notice Emitted when a tier's encoded IPFS URI is set.
|
|
76
|
+
/// @param tierId The ID of the tier whose encoded IPFS URI was set.
|
|
77
|
+
/// @param encodedUri The new encoded IPFS URI.
|
|
78
|
+
/// @param caller The address that called the function.
|
|
33
79
|
event SetEncodedIPFSUri(uint256 indexed tierId, bytes32 encodedUri, address caller);
|
|
80
|
+
|
|
81
|
+
/// @notice Emitted when the token URI resolver is set.
|
|
82
|
+
/// @param resolver The new token URI resolver.
|
|
83
|
+
/// @param caller The address that called the function.
|
|
34
84
|
event SetTokenUriResolver(IJB721TokenUriResolver indexed resolver, address caller);
|
|
85
|
+
|
|
86
|
+
/// @notice Emitted when pay credits are used by an account.
|
|
87
|
+
/// @param amount The amount of credits used.
|
|
88
|
+
/// @param newTotalCredits The new total credits balance for the account.
|
|
89
|
+
/// @param account The account that used the credits.
|
|
90
|
+
/// @param caller The address that called the function.
|
|
35
91
|
event UsePayCredits(
|
|
36
92
|
uint256 indexed amount, uint256 indexed newTotalCredits, address indexed account, address caller
|
|
37
93
|
);
|
|
38
94
|
|
|
39
|
-
/// @notice The contract storing and managing project rulesets.
|
|
40
|
-
/// @return The rulesets contract.
|
|
41
|
-
function RULESETS() external view returns (IJBRulesets);
|
|
42
|
-
|
|
43
|
-
/// @notice The contract that stores and manages data for this contract's NFTs.
|
|
44
|
-
/// @return The store contract.
|
|
45
|
-
function STORE() external view returns (IJB721TiersHookStore);
|
|
46
|
-
|
|
47
95
|
/// @notice The base URI for the NFT `tokenUris`.
|
|
48
96
|
/// @return The base URI string.
|
|
49
97
|
function baseURI() external view returns (string memory);
|
|
@@ -68,6 +116,14 @@ interface IJB721TiersHook is IJB721Hook {
|
|
|
68
116
|
/// @return prices The prices contract used to resolve the value of payments in other currencies.
|
|
69
117
|
function pricingContext() external view returns (uint256 currency, uint256 decimals, IJBPrices prices);
|
|
70
118
|
|
|
119
|
+
/// @notice The contract storing and managing project rulesets.
|
|
120
|
+
/// @return The rulesets contract.
|
|
121
|
+
function RULESETS() external view returns (IJBRulesets);
|
|
122
|
+
|
|
123
|
+
/// @notice The contract that stores and manages data for this contract's NFTs.
|
|
124
|
+
/// @return The store contract.
|
|
125
|
+
function STORE() external view returns (IJB721TiersHookStore);
|
|
126
|
+
|
|
71
127
|
/// @notice Add or remove tiers.
|
|
72
128
|
/// @param tiersToAdd The tiers to add, as an array of `JB721TierConfig` structs.
|
|
73
129
|
/// @param tierIdsToRemove The tiers to remove, as an array of tier IDs.
|
|
@@ -94,15 +150,6 @@ interface IJB721TiersHook is IJB721Hook {
|
|
|
94
150
|
)
|
|
95
151
|
external;
|
|
96
152
|
|
|
97
|
-
/// @notice Set the discount percent for a tier.
|
|
98
|
-
/// @param tierId The ID of the tier to set the discount of.
|
|
99
|
-
/// @param discountPercent The discount percent to set.
|
|
100
|
-
function setDiscountPercentOf(uint256 tierId, uint256 discountPercent) external;
|
|
101
|
-
|
|
102
|
-
/// @notice Set the discount percent for multiple tiers.
|
|
103
|
-
/// @param configs The configs to set the discount percent for.
|
|
104
|
-
function setDiscountPercentsOf(JB721TiersSetDiscountPercentConfig[] calldata configs) external;
|
|
105
|
-
|
|
106
153
|
/// @notice Manually mint NFTs from the provided tiers.
|
|
107
154
|
/// @param tierIds The IDs of the tiers to mint from.
|
|
108
155
|
/// @param beneficiary The address to mint to.
|
|
@@ -118,6 +165,15 @@ interface IJB721TiersHook is IJB721Hook {
|
|
|
118
165
|
/// @param count The number of reserved NFTs to mint.
|
|
119
166
|
function mintPendingReservesFor(uint256 tierId, uint256 count) external;
|
|
120
167
|
|
|
168
|
+
/// @notice Set the discount percent for a tier.
|
|
169
|
+
/// @param tierId The ID of the tier to set the discount of.
|
|
170
|
+
/// @param discountPercent The discount percent to set.
|
|
171
|
+
function setDiscountPercentOf(uint256 tierId, uint256 discountPercent) external;
|
|
172
|
+
|
|
173
|
+
/// @notice Set the discount percent for multiple tiers.
|
|
174
|
+
/// @param configs The configs to set the discount percent for.
|
|
175
|
+
function setDiscountPercentsOf(JB721TiersSetDiscountPercentConfig[] calldata configs) external;
|
|
176
|
+
|
|
121
177
|
/// @notice Update this hook's URI metadata properties.
|
|
122
178
|
/// @param baseUri The new base URI.
|
|
123
179
|
/// @param contractUri The new contract URI.
|
|
@@ -4,7 +4,12 @@ pragma solidity ^0.8.0;
|
|
|
4
4
|
import {IJB721TiersHook} from "./IJB721TiersHook.sol";
|
|
5
5
|
import {JBDeploy721TiersHookConfig} from "../structs/JBDeploy721TiersHookConfig.sol";
|
|
6
6
|
|
|
7
|
+
/// @notice Deploys 721 tiers hooks for projects.
|
|
7
8
|
interface IJB721TiersHookDeployer {
|
|
9
|
+
/// @notice Emitted when a 721 tiers hook is deployed for a project.
|
|
10
|
+
/// @param projectId The ID of the project the hook was deployed for.
|
|
11
|
+
/// @param hook The deployed hook contract.
|
|
12
|
+
/// @param caller The address that called the function.
|
|
8
13
|
event HookDeployed(uint256 indexed projectId, IJB721TiersHook hook, address caller);
|
|
9
14
|
|
|
10
15
|
/// @notice Deploys a 721 tiers hook for the specified project.
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
// SPDX-License-Identifier: MIT
|
|
2
2
|
pragma solidity ^0.8.0;
|
|
3
3
|
|
|
4
|
-
import {IJBDirectory} from "@bananapus/core-v6/src/interfaces/IJBDirectory.sol";
|
|
5
4
|
import {IJBController} from "@bananapus/core-v6/src/interfaces/IJBController.sol";
|
|
5
|
+
import {IJBDirectory} from "@bananapus/core-v6/src/interfaces/IJBDirectory.sol";
|
|
6
6
|
|
|
7
7
|
import {IJB721TiersHook} from "./IJB721TiersHook.sol";
|
|
8
8
|
import {IJB721TiersHookDeployer} from "./IJB721TiersHookDeployer.sol";
|
|
@@ -11,6 +11,7 @@ import {JBLaunchProjectConfig} from "../structs/JBLaunchProjectConfig.sol";
|
|
|
11
11
|
import {JBLaunchRulesetsConfig} from "../structs/JBLaunchRulesetsConfig.sol";
|
|
12
12
|
import {JBQueueRulesetsConfig} from "../structs/JBQueueRulesetsConfig.sol";
|
|
13
13
|
|
|
14
|
+
/// @notice Deploys projects with 721 tiers hooks attached.
|
|
14
15
|
interface IJB721TiersHookProjectDeployer {
|
|
15
16
|
/// @notice The directory of terminals and controllers for projects.
|
|
16
17
|
/// @return The directory contract.
|
|
@@ -6,7 +6,11 @@ import {JB721Tier} from "../structs/JB721Tier.sol";
|
|
|
6
6
|
import {JB721TierConfig} from "../structs/JB721TierConfig.sol";
|
|
7
7
|
import {JB721TiersHookFlags} from "../structs/JB721TiersHookFlags.sol";
|
|
8
8
|
|
|
9
|
+
/// @notice Stores and manages data for 721 tiers hooks.
|
|
9
10
|
interface IJB721TiersHookStore {
|
|
11
|
+
/// @notice Emitted when removed tiers are cleaned from the sorting sequence.
|
|
12
|
+
/// @param hook The 721 contract whose tiers were cleaned.
|
|
13
|
+
/// @param caller The address that called the function.
|
|
10
14
|
event CleanTiers(address indexed hook, address caller);
|
|
11
15
|
|
|
12
16
|
/// @notice Emitted when the default reserve beneficiary is changed.
|