跳到主要内容

JBTiered721DelegateStore

Git Source

Inherits: IJBTiered721DelegateStore

This contract stores and manages data for an IJBTiered721Delegate's NFTs.

State Variables

_ONE_BILLION

Just a kind reminder to our readers.

Used in token ID generation.

uint256 private constant _ONE_BILLION = 1_000_000_000;

_tierIdAfter

Returns the tier ID which should come after the provided tier ID when sorting by contribution floor.

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

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

_reservedTokenBeneficiaryOf

Returns optional reserved token beneficiary addresses for the provided tier and NFT contract.

mapping(address => mapping(uint256 => address)) internal _reservedTokenBeneficiaryOf;

_storedTierOf

Returns the tier at the provided contract and tier ID.

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

_flagsOf

Returns flags that influence the behavior of each NFT contract.

mapping(address => JBTiered721Flags) internal _flagsOf;

_isTierRemovedBitmapWord

For each tier ID, return a bitmap containing flags indicating whether the tier has been removed.

mapping(address => mapping(uint256 => uint256)) internal _isTierRemovedBitmapWord;

_trackedLastSortTierIdOf

For each NFT, return the tier ID that comes last when sorting.

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

mapping(address => uint256) internal _trackedLastSortTierIdOf;

_startingTierIdOfCategory

Returns the ID of the first tier in the provided NFT contract and category.

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

maxTierIdOf

Returns the largest tier ID used on the provided NFT contract.

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

mapping(address => uint256) public override maxTierIdOf;

tierBalanceOf

Returns the number of NFTs held by the provided address which belong to the provided tier and NFT contract.

mapping(address => mapping(address => mapping(uint256 => uint256))) public override tierBalanceOf;

numberOfReservesMintedFor

Returns the number of reserved tokens which have been minted within the provided tier and NFT contract.

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

numberOfBurnedFor

Returns the number of tokens belonging to the provided tier and NFT contract which have been burned.

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

defaultReservedTokenBeneficiaryOf

Returns the reserved token beneficiary address used when a tier doesn't specify a beneficiary.

mapping(address => address) public override defaultReservedTokenBeneficiaryOf;

tokenUriResolverOf

Returns a custom token URI resolver which supersedes the base URI.

mapping(address => IJB721TokenUriResolver) public override tokenUriResolverOf;

encodedIPFSUriOf

Returns the encoded IPFS URI for the provided tier and NFT contract.

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

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

Functions

tiersOf

Gets an array of active tiers.

function tiersOf(
address _nft,
uint256[] calldata _categories,
bool _includeResolvedUri,
uint256 _startingId,
uint256 _size
) external view override returns (JB721Tier[] memory _tiers);

Parameters

NameTypeDescription
_nftaddressThe NFT contract to get tiers for.
_categoriesuint256[]The categories of the tiers to get. Send empty for all categories.
_includeResolvedUriboolIf enabled, if there's a token URI resolver, the content will be resolved and included.
_startingIduint256The starting tier ID of the array of tiers sorted by contribution floor. Send 0 to get all active tiers.
_sizeuint256The number of tiers to include.

Returns

NameTypeDescription
_tiersJB721Tier[]An array of active tiers.

tierOf

Return the tier for the provided tier ID and NFT contract.

function tierOf(address _nft, uint256 _id, bool _includeResolvedUri) public view override returns (JB721Tier memory);

Parameters

NameTypeDescription
_nftaddressThe NFT contract to get a tier from.
_iduint256The tier ID of the tier to get.
_includeResolvedUriboolIf enabled, if there's a token URI resolver, the content will be resolved and included.

Returns

NameTypeDescription
<none>JB721TierThe tier.

tierOfTokenId

Return the tier for the provided token ID and NFT contract.

function tierOfTokenId(address _nft, uint256 _tokenId, bool _includeResolvedUri)
external
view
override
returns (JB721Tier memory);

Parameters

NameTypeDescription
_nftaddressThe NFT contract to get a tier from.
_tokenIduint256The token ID to return the tier of.
_includeResolvedUriboolIf enabled, if there's a token URI resolver, the content will be resolved and included.

Returns

NameTypeDescription
<none>JB721TierThe tier.

totalSupplyOf

The total number of NFTs issued from all tiers of the provided NFT contract.

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

Parameters

NameTypeDescription
_nftaddressThe NFT contract to get a total supply of.

Returns

NameTypeDescription
supplyuint256The total number of NFTs issued from all tiers.

numberOfReservedTokensOutstandingFor

Returns the number of currently mintable reserved tokens for the provided tier ID and NFT contract.

function numberOfReservedTokensOutstandingFor(address _nft, uint256 _tierId) external view override returns (uint256);

Parameters

NameTypeDescription
_nftaddressThe NFT contract to check for mintable reserved tokens.
_tierIduint256The tier ID to check for mintable reserved tokens.

Returns

NameTypeDescription
<none>uint256The number of currently outstanding reserved tokens within the tier and contract.

votingUnitsOf

Returns the total voting units from all of an addresses' NFTs (across all tiers) for the provided NFT contract. NFTs have a tier-specific number of voting units.

function votingUnitsOf(address _nft, address _account) external view virtual override returns (uint256 units);

Parameters

NameTypeDescription
_nftaddressThe NFT contract to get voting units within.
_accountaddressThe address to get the voting units of.

Returns

NameTypeDescription
unitsuint256The total voting units for the address.

tierVotingUnitsOf

Returns the voting units for an addresses' NFTs in one tier. NFTs have a tier-specific number of voting units.

function tierVotingUnitsOf(address _nft, address _account, uint256 _tierId)
external
view
virtual
override
returns (uint256);

Parameters

NameTypeDescription
_nftaddressThe NFT contract to get voting units within.
_accountaddressThe address to get the voting units of.
_tierIduint256The tier ID to get voting units within.

Returns

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

encodedTierIPFSUriOf

Resolves the encoded IPFS URI of the tier for the provided token ID and NFT contract.

function encodedTierIPFSUriOf(address _nft, uint256 _tokenId) external view override returns (bytes32);

Parameters

NameTypeDescription
_nftaddressThe NFT contract to which the encoded IPFS URI belongs.
_tokenIduint256The token ID to get the encoded IPFS URI of.

Returns

NameTypeDescription
<none>bytes32The encoded IPFS URI.

flagsOf

Flags that influence the behavior of each NFT.

function flagsOf(address _nft) external view override returns (JBTiered721Flags memory);

Parameters

NameTypeDescription
_nftaddressThe NFT contract for which the flags apply.

Returns

NameTypeDescription
<none>JBTiered721FlagsThe flags.

isTierRemoved

Check if the provided tier has been removed from the current set of tiers.

function isTierRemoved(address _nft, uint256 _tierId) external view override returns (bool);

Parameters

NameTypeDescription
_nftaddressThe NFT contract of the tier to check for removal.
_tierIduint256The tier ID to check for removal.

Returns

NameTypeDescription
<none>boolTrue if the tier has been removed.

balanceOf

The total number of tokens owned by the provided address.

function balanceOf(address _nft, address _owner) public view override returns (uint256 balance);

Parameters

NameTypeDescription
_nftaddressThe NFT contract to check the balance within.
_owneraddressThe address to check the balance of.

Returns

NameTypeDescription
balanceuint256The number of tokens owned by the owner across all tiers within the NFT contract.

redemptionWeightOf

The cumulative redemption weight of the given token IDs compared to the totalRedemptionWeight.

function redemptionWeightOf(address _nft, uint256[] calldata _tokenIds) public view override returns (uint256 weight);

Parameters

NameTypeDescription
_nftaddressThe NFT contract which the redemption weight is being calculated within.
_tokenIdsuint256[]The IDs of the tokens to get the cumulative redemption weight of.

Returns

NameTypeDescription
weightuint256The weight.

totalRedemptionWeight

The cumulative redemption weight for all token IDs.

function totalRedemptionWeight(address _nft) public view override returns (uint256 weight);

Parameters

NameTypeDescription
_nftaddressThe NFT contract for which the redemption weight is being calculated.

Returns

NameTypeDescription
weightuint256The total weight.

tierIdOfToken

The tier ID of 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 to get the tier ID of.

Returns

NameTypeDescription
<none>uint256The tier ID for the provided token ID.

reservedTokenBeneficiaryOf

The reserved token beneficiary address for the provided tier ID and NFT contract.

function reservedTokenBeneficiaryOf(address _nft, uint256 _tierId) public view override returns (address);

Parameters

NameTypeDescription
_nftaddressThe NFT contract to check the reserved token beneficiary within.
_tierIduint256The tier ID to get the reserved token beneficiary of.

Returns

NameTypeDescription
<none>addressThe reserved token beneficiary address.

recordAddTiers

Adds tiers.

function recordAddTiers(JB721TierParams[] calldata _tiersToAdd) external override returns (uint256[] memory tierIds);

Parameters

NameTypeDescription
_tiersToAddJB721TierParams[]The tiers to add.

Returns

NameTypeDescription
tierIdsuint256[]The IDs of the tiers added.

recordMintReservesFor

Record reserved token mints within the provided tier.

function recordMintReservesFor(uint256 _tierId, uint256 _count) external override returns (uint256[] memory tokenIds);

Parameters

NameTypeDescription
_tierIduint256The ID of the tier to mint reserved tokens from.
_countuint256The number of reserved tokens to mint.

Returns

NameTypeDescription
tokenIdsuint256[]The IDs of the tokens being minted as reserves.

recordTransferForTier

Record a token transfer.

function recordTransferForTier(uint256 _tierId, address _from, address _to) external override;

Parameters

NameTypeDescription
_tierIduint256The tier ID of the token being transferred.
_fromaddressThe address the token is being transferred from.
_toaddressThe address the token is being transferred to.

recordRemoveTierIds

Record removing the provided tiers.

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

Parameters

NameTypeDescription
_tierIdsuint256[]The tiers IDs to remove.

recordMint

Record token mints in the provided tiers.

function recordMint(uint256 _amount, uint16[] calldata _tierIds, bool _isManualMint)
external
override
returns (uint256[] memory tokenIds, uint256 leftoverAmount);

Parameters

NameTypeDescription
_amountuint256The amount to base the mints on. All mints' price floors must fit within this amount.
_tierIdsuint16[]The tier IDs to mint from.
_isManualMintboolA flag indicating if the mint is being made manually by the NFT contract's owner.

Returns

NameTypeDescription
tokenIdsuint256[]The IDs of the minted tokens.
leftoverAmountuint256The amount left over after the mint.

recordBurn

Records token burns.

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

Parameters

NameTypeDescription
_tokenIdsuint256[]The IDs of the tokens being burned.

recordSetTokenUriResolver

Sets the token URI resolver.

function recordSetTokenUriResolver(IJB721TokenUriResolver _resolver) external override;

Parameters

NameTypeDescription
_resolverIJB721TokenUriResolverThe resolver to set.

recordSetEncodedIPFSUriOf

Sets the encoded IPFS URI of a tier.

function recordSetEncodedIPFSUriOf(uint256 _tierId, bytes32 _encodedIPFSUri) external override;

Parameters

NameTypeDescription
_tierIduint256The tier ID to set the encoded IPFS URI of.
_encodedIPFSUribytes32The encoded IPFS URI to set.

recordFlags

Sets flags.

function recordFlags(JBTiered721Flags calldata _flags) external override;

Parameters

NameTypeDescription
_flagsJBTiered721FlagsThe flags to set.

cleanTiers

Removes an NFT contract's removed tiers from sequencing.

function cleanTiers(address _nft) external override;

Parameters

NameTypeDescription
_nftaddressThe NFT contract to clean tiers for.

_getTierFrom

Returns a tier given a provided stored tier.

function _getTierFrom(address _nft, uint256 _tierId, JBStored721Tier memory _storedTier, bool _includeResolvedUri)
internal
view
returns (JB721Tier memory);

Parameters

NameTypeDescription
_nftaddressThe NFT contract to get the tier from.
_tierIduint256The tier ID of the tier to get.
_storedTierJBStored721TierThe stored tier to base the tier on.
_includeResolvedUriboolIf true, if there's a token URI resolver, the content will be resolved and included.

Returns

NameTypeDescription
<none>JB721Tiertier The tier object.

_isTierRemovedWithRefresh

Check if a tier is removed from the current set of tiers, while reusing a bitmap word.

function _isTierRemovedWithRefresh(address _nft, uint256 _tierId, JBBitmapWord memory _bitmapWord)
internal
view
returns (bool);

Parameters

NameTypeDescription
_nftaddressThe NFT contract on which to check if the tier is removed.
_tierIduint256The tier ID to check for removal.
_bitmapWordJBBitmapWordThe bitmap word to reuse.

Returns

NameTypeDescription
<none>boolTrue if the tier has been removed.

_numberOfReservedTokensOutstandingFor

The number of mintable reserved tokens within the provided tier.

function _numberOfReservedTokensOutstandingFor(address _nft, uint256 _tierId, JBStored721Tier memory _storedTier)
internal
view
returns (uint256);

Parameters

NameTypeDescription
_nftaddressThe NFT contract to check mintable reserved tokens on.
_tierIduint256The tier ID to check the number of mintable reserved tokens for.
_storedTierJBStored721TierThe stored tier to get the number of mintable reserved tokens for.

Returns

NameTypeDescription
<none>uint256numberReservedTokensOutstanding The number of outstanding mintable reserved tokens within the tier.

_generateTokenId

Finds the token ID 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 an ID for.
_tokenNumberuint256The number of the token in the tier.

Returns

NameTypeDescription
<none>uint256The ID of the token.

_nextSortedTierIdOf

The next sorted tier ID.

function _nextSortedTierIdOf(address _nft, uint256 _id, uint256 _max) internal view returns (uint256);

Parameters

NameTypeDescription
_nftaddressThe NFT contract for which the sorted tier ID applies.
_iduint256The ID relative to which the next sorted ID will be returned.
_maxuint256The maximum possible ID.

Returns

NameTypeDescription
<none>uint256The ID.

_firstSortedTierIdOf

The first sorted tier ID of an NFT contract.

function _firstSortedTierIdOf(address _nft, uint256 _category) internal view returns (uint256 id);

Parameters

NameTypeDescription
_nftaddressThe NFT contract to get the first sorted tier ID of.
_categoryuint256The category to get the first sorted tier ID of. Send 0 for the first overall sorted ID, which might not be of the 0 category if there isn't a tier of the 0 category.

Returns

NameTypeDescription
iduint256The first sorted tier ID.

_lastSortedTierIdOf

The last sorted tier ID of an NFT.

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

Parameters

NameTypeDescription
_nftaddressThe NFT contract to get the last sorted tier ID of.

Returns

NameTypeDescription
iduint256The last sorted tier ID.

_packBools

Pack three bools into a single uint8.

function _packBools(bool _allowManualMint, bool _transfersPausable, bool _useVotingUnits)
internal
pure
returns (uint8 _packed);

Parameters

NameTypeDescription
_allowManualMintboolWhether or not manual mints are allowed.
_transfersPausableboolWhether or not transfers are pausable.
_useVotingUnitsboolA flag indicating whether the voting units override should be used.

Returns

NameTypeDescription
_packeduint8The packed bools.

_unpackBools

Unpack three bools from a single uint8.

function _unpackBools(uint8 _packed)
internal
pure
returns (bool _allowManualMint, bool _transfersPausable, bool _useVotingUnits);

Parameters

NameTypeDescription
_packeduint8The packed bools.

Returns

NameTypeDescription
_allowManualMintboolWhether or not manual mints are allowed.
_transfersPausableboolWhether or not transfers are pausable.
_useVotingUnitsboolA flag indicating whether the voting units override should be used.

Errors

CANT_MINT_MANUALLY

error CANT_MINT_MANUALLY();

INSUFFICIENT_AMOUNT

error INSUFFICIENT_AMOUNT();

INSUFFICIENT_RESERVES

error INSUFFICIENT_RESERVES();

INVALID_CATEGORY_SORT_ORDER

error INVALID_CATEGORY_SORT_ORDER();

INVALID_QUANTITY

error INVALID_QUANTITY();

INVALID_TIER

error INVALID_TIER();

MAX_TIERS_EXCEEDED

error MAX_TIERS_EXCEEDED();

NO_QUANTITY

error NO_QUANTITY();

OUT

error OUT();

RESERVED_RATE_NOT_ALLOWED

error RESERVED_RATE_NOT_ALLOWED();

MANUAL_MINTING_NOT_ALLOWED

error MANUAL_MINTING_NOT_ALLOWED();

TIER_REMOVED

error TIER_REMOVED();

VOTING_UNITS_NOT_ALLOWED

error VOTING_UNITS_NOT_ALLOWED();