Skip to main content

JB721TiersHookStore

Git Source

Inherits: IJB721TiersHookStore

This contract stores and manages data for many IJB721TiersHooks and their NFTs.

State Variables

_ONE_BILLION

Just a kind reminder to our readers.

Used in 721 token ID generation.

uint256 private constant _ONE_BILLION = 1_000_000_000;

defaultReserveBeneficiaryOf

Returns the default reserve beneficiary for the provided 721 contract.

If a tier has a reserve beneficiary set, it will override this value.

mapping(address hook => address) public override defaultReserveBeneficiaryOf;

encodedIPFSUriOf

Returns the encoded IPFS URI for the provided tier ID of the provided 721 contract.

Token URIs managed by this contract are stored in 32 bytes, based on stripped down IPFS hashes.

Note: returns: The encoded IPFS URI.

mapping(address hook => mapping(uint256 tierId => bytes32)) public override encodedIPFSUriOf;

maxTierIdOf

Returns the largest tier ID currently used on the provided 721 contract.

This may not include the last tier ID if it has been removed.

mapping(address hook => uint256) public override maxTierIdOf;

numberOfBurnedFor

Returns the number of NFTs which have been burned from the provided tier ID of the provided 721 contract.

mapping(address hook => mapping(uint256 tierId => uint256)) public override numberOfBurnedFor;

numberOfReservesMintedFor

Returns the number of reserve NFTs which have been minted from the provided tier ID of the provided 721 contract.

mapping(address hook => mapping(uint256 tierId => uint256)) public override numberOfReservesMintedFor;

tierBalanceOf

Returns the number of NFTs which the provided owner address owns from the provided 721 contract and tier ID.

mapping(address hook => mapping(address owner => mapping(uint256 tierId => uint256))) public override tierBalanceOf;

tokenUriResolverOf

Returns the custom token URI resolver which overrides the default token URI resolver for the provided 721 contract.

mapping(address hook => IJB721TokenUriResolver) public override tokenUriResolverOf;

_flagsOf

Returns the flags which dictate the behavior of the provided IJB721TiersHook contract.

Note: returns: The flags.

mapping(address hook => JB721TiersHookFlags) internal _flagsOf;

_lastTrackedSortedTierIdOf

Return the ID of the last sorted tier from the provided 721 contract.

If not set, it is assumed the maxTierIdOf is the last sorted tier ID.

mapping(address hook => uint256) internal _lastTrackedSortedTierIdOf;

_removedTiersBitmapWordOf

Get the bitmap word at the provided depth from the provided 721 contract's tier removal bitmap.

See JBBitmap for more information.

Note: returns: word The bitmap row's content.

mapping(address hook => mapping(uint256 depth => uint256 word)) internal _removedTiersBitmapWordOf;

_reserveBeneficiaryOf

Returns the reserve beneficiary (if there is one) for the provided tier ID on the provided IJB721TiersHook contract.

Note: returns: The address of the reserved token beneficiary.

mapping(address hook => mapping(uint256 tierId => address)) internal _reserveBeneficiaryOf;

_startingTierIdOfCategory

Returns the ID of the first tier in the provided category on the provided 721 contract.

mapping(address hook => mapping(uint256 category => uint256)) internal _startingTierIdOfCategory;

_storedTierOf

Returns the stored tier of the provided tier ID on the provided IJB721TiersHook contract.

Note: returns: The stored tier, as a JBStored721Tier struct.

mapping(address hook => mapping(uint256 tierId => JBStored721Tier)) internal _storedTierOf;

_tierIdAfter

Returns the ID of the tier which comes after the provided tier ID (sorted by price).

If empty, assume the next tier ID should come after.

Note: returns: The following tier's ID.

mapping(address hook => mapping(uint256 tierId => uint256)) internal _tierIdAfter;

Functions

encodedTierIPFSUriOf

Resolves the encoded IPFS URI for the tier of the 721 with the provided token ID from the provided 721 contract.

function encodedTierIPFSUriOf(address hook, uint256 tokenId) external view override returns (bytes32);

Parameters

NameTypeDescription
hookaddressThe 721 contract that the encoded IPFS URI belongs to.
tokenIduint256The token ID of the 721 to get the encoded tier IPFS URI of.

Returns

NameTypeDescription
<none>bytes32The encoded IPFS URI.

flagsOf

Get the flags that dictate the behavior of the provided 721 contract.

function flagsOf(address hook) external view override returns (JB721TiersHookFlags memory);

Parameters

NameTypeDescription
hookaddressThe 721 contract to get the flags of.

Returns

NameTypeDescription
<none>JB721TiersHookFlagsThe flags.

isTierRemoved

Check if the provided tier has been removed from the provided 721 contract.

function isTierRemoved(address hook, uint256 tierId) external view override returns (bool);

Parameters

NameTypeDescription
hookaddressThe 721 contract the tier belongs to.
tierIduint256The ID of the tier to check the removal status of.

Returns

NameTypeDescription
<none>boolA bool which is true if the tier has been removed, and false otherwise.

numberOfPendingReservesFor

Get the number of pending reserve NFTs for the provided tier ID of the provided 721 contract.

"Pending" means that the NFTs have been reserved, but have not been minted yet.

function numberOfPendingReservesFor(address hook, uint256 tierId) external view override returns (uint256);

Parameters

NameTypeDescription
hookaddressThe 721 contract to check for pending reserved NFTs.
tierIduint256The ID of the tier to get the number of pending reserves for.

Returns

NameTypeDescription
<none>uint256The number of pending reserved NFTs.

tierOf

Get the tier with the provided ID from the provided 721 contract.

function tierOf(address hook, uint256 id, bool includeResolvedUri) public view override returns (JB721Tier memory);

Parameters

NameTypeDescription
hookaddressThe 721 contract to get the tier from.
iduint256The ID of the tier to get.
includeResolvedUriboolIf set to true, if the contract has a token URI resolver, its content will be resolved and included.

Returns

NameTypeDescription
<none>JB721TierThe tier.

tierOfTokenId

Get the tier of the 721 with the provided token ID in the provided 721 contract.

function tierOfTokenId(
address hook,
uint256 tokenId,
bool includeResolvedUri
)
external
view
override
returns (JB721Tier memory);

Parameters

NameTypeDescription
hookaddressThe 721 contract that the tier belongs to.
tokenIduint256The token ID of the 721 to get the tier of.
includeResolvedUriboolIf set to true, if the contract has a token URI resolver, its content will be resolved and included.

Returns

NameTypeDescription
<none>JB721TierThe tier.

tierVotingUnitsOf

Returns the number of voting units an addresses has within the specified tier of the specified 721 contract.

NFTs have a tier-specific number of voting units. If the tier does not have a custom number of voting units, the price is used.

function tierVotingUnitsOf(
address hook,
address account,
uint256 tierId
)
external
view
virtual
override
returns (uint256);

Parameters

NameTypeDescription
hookaddressThe 721 contract that the tier belongs to.
accountaddressThe address to get the voting units of within the tier.
tierIduint256The ID of the tier to get voting units within.

Returns

NameTypeDescription
<none>uint256The address' voting units within the tier.

tiersOf

Gets an array of currently active 721 tiers for the provided 721 contract.

function tiersOf(
address hook,
uint256[] calldata categories,
bool includeResolvedUri,
uint256 startingId,
uint256 size
)
external
view
override
returns (JB721Tier[] memory tiers);

Parameters

NameTypeDescription
hookaddressThe 721 contract to get the tiers of.
categoriesuint256[]An array tier categories to get tiers from. Send an empty array to get all categories.
includeResolvedUriboolIf set to true, if the contract has a token URI resolver, its content will be resolved and included.
startingIduint256The ID of the first tier to get (sorted by price). Send 0 to get all active tiers.
sizeuint256The number of tiers to include.

Returns

NameTypeDescription
tiersJB721Tier[]An array of active 721 tiers.

totalSupplyOf

Get the number of NFTs which have been minted from the provided 721 contract (across all tiers).

function totalSupplyOf(address hook) external view override returns (uint256 supply);

Parameters

NameTypeDescription
hookaddressThe 721 contract to get a total supply of.

Returns

NameTypeDescription
supplyuint256The total number of NFTs minted from all tiers on the contract.

votingUnitsOf

Get the number of voting units the provided address has for the provided 721 contract (across all tiers).

NFTs have a tier-specific number of voting units. If the tier does not have a custom number of voting units, the price is used.

function votingUnitsOf(address hook, address account) external view virtual override returns (uint256 units);

Parameters

NameTypeDescription
hookaddressThe 721 contract to get the voting units within.
accountaddressThe address to get the voting unit total of.

Returns

NameTypeDescription
unitsuint256The total voting units the address has within the 721 contract.

balanceOf

Get the number of NFTs that the specified address has from the specified 721 contract (across all tiers).

function balanceOf(address hook, address owner) public view override returns (uint256 balance);

Parameters

NameTypeDescription
hookaddressThe 721 contract to get the balance within.
owneraddressThe address to check the balance of.

Returns

NameTypeDescription
balanceuint256The number of NFTs the owner has from the 721 contract.

cashOutWeightOf

The combined cash out weight of the NFTs with the provided token IDs.

Cash out weight is based on 721 price.

Divide this result by the totalCashOutWeight to get the portion of funds that can be reclaimed by cashing out these NFTs.

function cashOutWeightOf(address hook, uint256[] calldata tokenIds) public view override returns (uint256 weight);

Parameters

NameTypeDescription
hookaddressThe 721 contract that the NFTs belong to.
tokenIdsuint256[]The token IDs of the NFTs to get the cash out weight of.

Returns

NameTypeDescription
weightuint256The cash out weight.

reserveBeneficiaryOf

The reserve beneficiary for the provided tier ID on the provided 721 contract.

function reserveBeneficiaryOf(address hook, uint256 tierId) public view override returns (address);

Parameters

NameTypeDescription
hookaddressThe 721 contract that the tier belongs to.
tierIduint256The ID of the tier to get the reserve beneficiary of.

Returns

NameTypeDescription
<none>addressThe reserve beneficiary for the tier.

tierIdOfToken

The tier ID for the 721 with the provided token ID.

Tiers are 1-indexed from the tiers array, meaning the 0th element of the array is tier 1.

function tierIdOfToken(uint256 tokenId) public pure override returns (uint256);

Parameters

NameTypeDescription
tokenIduint256The token ID of the 721 to get the tier ID of.

Returns

NameTypeDescription
<none>uint256The ID of the 721's tier.

totalCashOutWeight

The combined cash out weight for all NFTs from the provided 721 contract.

function totalCashOutWeight(address hook) public view override returns (uint256 weight);

Parameters

NameTypeDescription
hookaddressThe 721 contract to get the total cash out weight of.

Returns

NameTypeDescription
weightuint256The total cash out weight.

_firstSortedTierIdOf

Get the first tier ID from an 721 contract (when sorted by price) within a provided category.

function _firstSortedTierIdOf(address hook, uint256 category) internal view returns (uint256 id);

Parameters

NameTypeDescription
hookaddressThe 721 contract to get the first sorted tier ID of.
categoryuint256The category to get the first sorted tier ID within. Send 0 for the first ID across all tiers, which might not be in the 0th category if the 0th category does not exist.

Returns

NameTypeDescription
iduint256The first sorted tier ID within the provided category.

_generateTokenId

Generate a token ID for an 721 given a tier ID and a token number within that tier.

function _generateTokenId(uint256 tierId, uint256 tokenNumber) internal pure returns (uint256);

Parameters

NameTypeDescription
tierIduint256The ID of the tier to generate a token ID for.
tokenNumberuint256The token number of the 721 within the tier.

Returns

NameTypeDescription
<none>uint256The token ID of the 721.

_getTierFrom

Returns the tier corresponding to the stored tier provided.

Translate JBStored721Tier to JB721Tier.

function _getTierFrom(
address hook,
uint256 tierId,
JBStored721Tier memory storedTier,
bool includeResolvedUri
)
internal
view
returns (JB721Tier memory);

Parameters

NameTypeDescription
hookaddressThe 721 contract to get the tier from.
tierIduint256The ID of the tier to get.
storedTierJBStored721TierThe stored tier to get the corresponding tier for.
includeResolvedUriboolIf set to true, if the contract has a token URI resolver, its content will be resolved and included.

Returns

NameTypeDescription
<none>JB721Tiertier The tier as a JB721Tier struct.

_isTierRemovedWithRefresh

Check whether a tier has been removed while refreshing the relevant bitmap word if needed.

function _isTierRemovedWithRefresh(
address hook,
uint256 tierId,
JBBitmapWord memory bitmapWord
)
internal
view
returns (bool);

Parameters

NameTypeDescription
hookaddressThe 721 contract to check for removals on.
tierIduint256The ID of the tier to check the removal status of.
bitmapWordJBBitmapWordThe bitmap word to use.

Returns

NameTypeDescription
<none>boolA boolean which is true if the tier has been removed.

_lastSortedTierIdOf

The last sorted tier ID from an 721 contract (when sorted by price).

function _lastSortedTierIdOf(address hook) internal view returns (uint256 id);

Parameters

NameTypeDescription
hookaddressThe 721 contract to get the last sorted tier ID of.

Returns

NameTypeDescription
iduint256The last sorted tier ID.

_nextSortedTierIdOf

Get the tier ID which comes after the provided one when sorted by price.

function _nextSortedTierIdOf(address hook, uint256 id, uint256 max) internal view returns (uint256);

Parameters

NameTypeDescription
hookaddressThe 721 contract to get the next sorted tier ID from.
iduint256The tier ID to get the next sorted tier ID relative to.
maxuint256The maximum tier ID.

Returns

NameTypeDescription
<none>uint256The next sorted tier ID.

_numberOfPendingReservesFor

Get the number of pending reserve NFTs for the specified tier ID.

function _numberOfPendingReservesFor(
address hook,
uint256 tierId,
JBStored721Tier memory storedTier
)
internal
view
returns (uint256);

Parameters

NameTypeDescription
hookaddressThe 721 contract that the tier belongs to.
tierIduint256The ID of the tier to get the number of pending reserve NFTs for.
storedTierJBStored721TierThe stored tier to get the number of pending reserve NFTs for.

Returns

NameTypeDescription
<none>uint256numberReservedTokensOutstanding The number of pending reserve NFTs for the tier.

_packBools

Pack five bools into a single uint8.

function _packBools(
bool allowOwnerMint,
bool transfersPausable,
bool useVotingUnits,
bool cannotBeRemoved,
bool cannotIncreaseDiscountPercent
)
internal
pure
returns (uint8 packed);

Parameters

NameTypeDescription
allowOwnerMintboolWhether or not owner minting is allowed in new tiers.
transfersPausableboolWhether or not 721 transfers can be paused.
useVotingUnitsboolWhether or not custom voting unit amounts are allowed in new tiers.
cannotBeRemovedboolWhether or not attempts to remove the tier will revert.
cannotIncreaseDiscountPercentboolWhether or not attempts to increase the discount percent will revert.

Returns

NameTypeDescription
packeduint8The packed bools.

_unpackBools

Unpack five bools from a single uint8.

function _unpackBools(uint8 packed)
internal
pure
returns (
bool allowOwnerMint,
bool transfersPausable,
bool useVotingUnits,
bool cannotBeRemoved,
bool cannotIncreaseDiscountPercent
);

Parameters

NameTypeDescription
packeduint8The packed bools.

cleanTiers

Cleans an 721 contract's removed tiers from the tier sorting sequence.

function cleanTiers(address hook) external override;

Parameters

NameTypeDescription
hookaddressThe 721 contract to clean tiers for.

recordAddTiers

Record newly added tiers.

function recordAddTiers(JB721TierConfig[] calldata tiersToAdd) external override returns (uint256[] memory tierIds);

Parameters

NameTypeDescription
tiersToAddJB721TierConfig[]The tiers to add.

Returns

NameTypeDescription
tierIdsuint256[]The IDs of the tiers being added.

recordBurn

Records 721 burns.

function recordBurn(uint256[] calldata tokenIds) external override;

Parameters

NameTypeDescription
tokenIdsuint256[]The token IDs of the NFTs to burn.

recordFlags

Record newly set flags.

function recordFlags(JB721TiersHookFlags calldata flags) external override;

Parameters

NameTypeDescription
flagsJB721TiersHookFlagsThe flags to set.

recordMint

Record 721 mints from the provided tiers.

function recordMint(
uint256 amount,
uint16[] calldata tierIds,
bool isOwnerMint
)
external
override
returns (uint256[] memory tokenIds, uint256 leftoverAmount);

Parameters

NameTypeDescription
amountuint256The amount being spent on NFTs. The total price must not exceed this amount.
tierIdsuint16[]The IDs of the tiers to mint from.
isOwnerMintboolA flag indicating whether this function is being directly called by the 721 contract's owner.

Returns

NameTypeDescription
tokenIdsuint256[]The token IDs of the NFTs which were minted.
leftoverAmountuint256The amount remaining after minting.

recordMintReservesFor

Record reserve 721 minting for the provided tier ID on the provided 721 contract.

function recordMintReservesFor(uint256 tierId, uint256 count) external override returns (uint256[] memory tokenIds);

Parameters

NameTypeDescription
tierIduint256The ID of the tier to mint reserves from.
countuint256The number of reserve NFTs to mint.

Returns

NameTypeDescription
tokenIdsuint256[]The token IDs of the reserve NFTs which were minted.

recordRemoveTierIds

Record tiers being removed.

function recordRemoveTierIds(uint256[] calldata tierIds) external override;

Parameters

NameTypeDescription
tierIdsuint256[]The IDs of the tiers being removed.

recordSetDiscountPercentOf

Records the setting of a discount for a tier.

function recordSetDiscountPercentOf(uint256 tierId, uint256 discountPercent) external override;

Parameters

NameTypeDescription
tierIduint256The ID of the tier to record a discount for.
discountPercentuint256The new discount percent being applied.

recordSetEncodedIPFSUriOf

Record a new encoded IPFS URI for a tier.

function recordSetEncodedIPFSUriOf(uint256 tierId, bytes32 encodedIPFSUri) external override;

Parameters

NameTypeDescription
tierIduint256The ID of the tier to set the encoded IPFS URI of.
encodedIPFSUribytes32The encoded IPFS URI to set for the tier.

recordSetTokenUriResolver

Record a newly set token URI resolver.

function recordSetTokenUriResolver(IJB721TokenUriResolver resolver) external override;

Parameters

NameTypeDescription
resolverIJB721TokenUriResolverThe resolver to set.

recordTransferForTier

Record an 721 transfer.

function recordTransferForTier(uint256 tierId, address from, address to) external override;

Parameters

NameTypeDescription
tierIduint256The ID of the tier that the 721 being transferred belongs to.
fromaddressThe address that the 721 is being transferred from.
toaddressThe address that the 721 is being transferred to.

Errors

JB721TiersHookStore_CantMintManually

error JB721TiersHookStore_CantMintManually();

JB721TiersHookStore_CantRemoveTier

error JB721TiersHookStore_CantRemoveTier();

JB721TiersHookStore_DiscountPercentExceedsBounds

error JB721TiersHookStore_DiscountPercentExceedsBounds(uint256 percent, uint256 limit);

JB721TiersHookStore_DiscountPercentIncreaseNotAllowed

error JB721TiersHookStore_DiscountPercentIncreaseNotAllowed(uint256 percent, uint256 storedPercent);

JB721TiersHookStore_InsufficientPendingReserves

error JB721TiersHookStore_InsufficientPendingReserves(uint256 count, uint256 numberOfPendingReserves);

JB721TiersHookStore_InsufficientSupplyRemaining

error JB721TiersHookStore_InsufficientSupplyRemaining();

JB721TiersHookStore_InvalidCategorySortOrder

error JB721TiersHookStore_InvalidCategorySortOrder(uint256 tierCategory, uint256 previousTierCategory);

JB721TiersHookStore_InvalidQuantity

error JB721TiersHookStore_InvalidQuantity(uint256 quantity, uint256 limit);

JB721TiersHookStore_ManualMintingNotAllowed

error JB721TiersHookStore_ManualMintingNotAllowed();

JB721TiersHookStore_MaxTiersExceeded

error JB721TiersHookStore_MaxTiersExceeded(uint256 numberOfTiers, uint256 limit);

JB721TiersHookStore_PriceExceedsAmount

error JB721TiersHookStore_PriceExceedsAmount(uint256 price, uint256 leftoverAmount);

JB721TiersHookStore_ReserveFrequencyNotAllowed

error JB721TiersHookStore_ReserveFrequencyNotAllowed();

JB721TiersHookStore_TierRemoved

error JB721TiersHookStore_TierRemoved(uint256 tierId);

JB721TiersHookStore_UnrecognizedTier

error JB721TiersHookStore_UnrecognizedTier();

JB721TiersHookStore_VotingUnitsNotAllowed

error JB721TiersHookStore_VotingUnitsNotAllowed();

JB721TiersHookStore_ZeroInitialSupply

error JB721TiersHookStore_ZeroInitialSupply();