This library is used to manage the market's removal vintages.
- EnumerableSetUpgradeable for EnumerableSetUpgradeable.UintSet
- AddressArrayLib for
address[]
- UInt256ArrayLib for
uint256[]
function insert(struct RemovalsByYear collection, uint256 removalId) internal
Inserts a new removal into the collection.
The removal is added to the Enumerable Set that maps to the year of its year.
Name | Type | Description |
---|---|---|
collection | struct RemovalsByYear | the collection from storage. |
removalId | uint256 | a new removal to insert. |
function remove(struct RemovalsByYear collection, uint256 removalId) internal
Removes a removal from the collection.
Removes the removal from the Enumerable Set that corresponds to its year.
Name | Type | Description |
---|---|---|
collection | struct RemovalsByYear | the collection to search through. |
removalId | uint256 | the removal to remove. |
function isEmpty(struct RemovalsByYear collection) internal view returns (bool)
Checks if the collection is empty across all years.
Uses the latestYear property to check if any years have been set.
Name | Type | Description |
---|---|---|
collection | struct RemovalsByYear | the collection from storage. |
Name | Type | Description |
---|---|---|
[0] | bool | True if empty, false otherwise. |
function isEmptyForYear(struct RemovalsByYear collection, uint256 year) internal view returns (bool)
Checks if the collection is empty for a particular year.
Name | Type | Description |
---|---|---|
collection | struct RemovalsByYear | the collection from storage. |
year | uint256 | the year to check. |
Name | Type | Description |
---|---|---|
[0] | bool | True if empty, false otherwise. |
function getNextRemovalForSale(struct RemovalsByYear collection) internal view returns (uint256)
Gets the next removal in the collection for sale.
Gets the first item from the Enumerable Set that corresponds to the earliest year.
Name | Type | Description |
---|---|---|
collection | struct RemovalsByYear | the collection from storage. |
Name | Type | Description |
---|---|---|
[0] | uint256 | The next removal to sell. |
function getNextRemovalForSaleFromVintages(struct RemovalsByYear collection, uint256[] vintages) internal view returns (uint256)
Gets the next removal in the collection for sale that comes from any of the specified vintage years. If no removal exists on the valid range, 0 is returned.
Name | Type | Description |
---|---|---|
collection | struct RemovalsByYear | the collection from storage. |
vintages | uint256[] | the valid set of years from which to pull the removal ID. |
Name | Type | Description |
---|---|---|
[0] | uint256 | The next removal to sell, or 0 if no removal exists on that vintage range. |
function getCountForYear(struct RemovalsByYear collection, uint256 year) internal view returns (uint256)
Gets the count of unique removal IDs for a particular year.
Gets the size of the Enumerable Set that corresponds to the given year.
Name | Type | Description |
---|---|---|
collection | struct RemovalsByYear | the collection from storage. |
year | uint256 | the year to check. |
Name | Type | Description |
---|---|---|
[0] | uint256 | uint256 the size of the collection. |
function getAllRemovalIds(struct RemovalsByYear collection) internal view returns (uint256[] removalIds)
Gets all removal IDs belonging to all vintages for a collection.
Name | Type | Description |
---|---|---|
collection | struct RemovalsByYear | the collection from storage. |
Name | Type | Description |
---|---|---|
removalIds | uint256[] | an array of all removal IDs in the collection. |