@bananapus/721-hook-v6 0.0.60 → 0.0.62
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
CHANGED
package/src/JB721Checkpoints.sol
CHANGED
|
@@ -119,8 +119,8 @@ contract JB721Checkpoints is Votes, IJB721Checkpoints {
|
|
|
119
119
|
_ownerCheckpointsOf[tokenId].push({key: uint96(block.number), value: uint160(to)});
|
|
120
120
|
}
|
|
121
121
|
|
|
122
|
-
// Look up this token's tier
|
|
123
|
-
uint256 votingUnits = STORE.
|
|
122
|
+
// Look up this token's tier voting units (lightweight getter — avoids full tier struct construction).
|
|
123
|
+
uint256 votingUnits = STORE.tierVotingUnitsOfTokenId({hook: hook, tokenId: tokenId});
|
|
124
124
|
|
|
125
125
|
// Move checkpointed voting power from the previous owner to the new owner.
|
|
126
126
|
_transferVotingUnits({from: from, to: to, amount: votingUnits});
|
|
@@ -261,6 +261,24 @@ contract JB721TiersHookStore is IJB721TiersHookStore {
|
|
|
261
261
|
transfersPausable = (storedTier.packedBools & 0x2) != 0;
|
|
262
262
|
}
|
|
263
263
|
|
|
264
|
+
/// @notice Get only the per-unit voting value for a token's tier, avoiding full struct construction.
|
|
265
|
+
/// @dev Mirrors the `votingUnits` field computed in `_getTierFrom`: a tier with custom voting units configured
|
|
266
|
+
/// (the `useVotingUnits` flag, bit 2 of `packedBools`) contributes its stored voting units per NFT, otherwise it
|
|
267
|
+
/// contributes its price per NFT. Multiply by an account's balance in the tier to get its voting power there.
|
|
268
|
+
/// @param hook The 721 hook contract that the token belongs to.
|
|
269
|
+
/// @param tokenId The token ID.
|
|
270
|
+
/// @return The per-unit voting value for the token's tier.
|
|
271
|
+
function tierVotingUnitsOfTokenId(address hook, uint256 tokenId) external view override returns (uint256) {
|
|
272
|
+
// Get a reference to the tier's ID.
|
|
273
|
+
uint256 tierId = tierIdOfToken(tokenId);
|
|
274
|
+
|
|
275
|
+
// Keep a reference to the stored tier.
|
|
276
|
+
JBStored721Tier memory storedTier = _storedTierOf[hook][tierId];
|
|
277
|
+
|
|
278
|
+
// Bit 2 (0-indexed) of packedBools is useVotingUnits. Use custom voting units if set, otherwise the price.
|
|
279
|
+
return (storedTier.packedBools & 0x4 != 0) ? _tierVotingUnitsOf[hook][tierId] : storedTier.price;
|
|
280
|
+
}
|
|
281
|
+
|
|
264
282
|
/// @notice Get all active (non-removed) tiers for a hook, with optional filtering by category and pagination.
|
|
265
283
|
/// Tiers are returned sorted by category.
|
|
266
284
|
/// @param hook The 721 hook contract to get tiers from.
|
|
@@ -151,6 +151,12 @@ interface IJB721TiersHookStore {
|
|
|
151
151
|
view
|
|
152
152
|
returns (uint256 tierId, bool transfersPausable);
|
|
153
153
|
|
|
154
|
+
/// @notice Get only the per-unit voting value for a token's tier, avoiding full struct construction.
|
|
155
|
+
/// @param hook The 721 hook address.
|
|
156
|
+
/// @param tokenId The token ID.
|
|
157
|
+
/// @return The per-unit voting value for the token's tier (custom voting units if set, otherwise the tier price).
|
|
158
|
+
function tierVotingUnitsOfTokenId(address hook, uint256 tokenId) external view returns (uint256);
|
|
159
|
+
|
|
154
160
|
/// @notice Get an array of currently active 721 tiers for the provided 721 contract.
|
|
155
161
|
/// @param hook The 721 contract to get the tiers of.
|
|
156
162
|
/// @param categories An array of tier categories to get tiers from. Empty for all categories.
|