Skip to content

Instantly share code, notes, and snippets.

@ac12644
Last active October 31, 2022 20:38
Show Gist options
  • Save ac12644/892d783c913ed81d5668ac6ddaeb449b to your computer and use it in GitHub Desktop.
Save ac12644/892d783c913ed81d5668ac6ddaeb449b to your computer and use it in GitHub Desktop.
...
uint256 constant maxLimit = 20;
function fundraisersCount() public view returns (uint256) {
return _fundraisers.length;
}
function fundraisers(uint256 limit, uint256 offset)
public
view
returns (Fundraiser[] memory coll)
{
require(offset <= fundraisersCount(), 'offset out of bounds');
uint256 size = fundraisersCount() - offset;
size = size < limit ? size : limit;
size = size < maxLimit ? size : maxLimit;
coll = new Fundraiser[](size);
for (uint256 i = 0; i < size; i++) {
coll[i] = _fundraisers[offset + i];
}
return coll;
}
...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment