Skip to content

Latest commit

 

History

History
160 lines (101 loc) · 4.35 KB

RemovalsByYearLib.md

File metadata and controls

160 lines (101 loc) · 4.35 KB

RemovalsByYearLib

This library is used to manage the market's removal vintages.

Uses:

insert

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.

remove

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.

isEmpty

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.

isEmptyForYear

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.

getNextRemovalForSale

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.

getNextRemovalForSaleFromVintages

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.

getCountForYear

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.

getAllRemovalIds

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.