-
Notifications
You must be signed in to change notification settings - Fork 12.4k
Open
Labels
featureNew contracts, functions, or helpers.New contracts, functions, or helpers.
Description
The current API only provides access via .length() and .at(). It'd be great to have a .list(start, end) that returned a partial view of the set's elements.
The reasoning behind making this a non-complete view is to let the caller decide how much gas they want to spend. Calls to view functions from off-chain sources (i.e. eth_call) are also capped in gas, and a large enough set can cause them to fail.
The implementation should be quite simple:
function list(
EnumerableSet.AddressSet storage set,
uint256 start,
uint256 end
) internal view returns (address[] memory) {
address[] memory elements = new address[](end - start);
for (uint256 i = 0; i < elements.length; ++i) {
elements[i] = set.at(i + start);
}
return elements;
}abcoathup, Amxx and jummy123
Metadata
Metadata
Assignees
Labels
featureNew contracts, functions, or helpers.New contracts, functions, or helpers.