ViewAggregator

Git Source

Author: EridianAlpha

An aggregator contract for multi-calling view functions on Ethereum Settlers contracts.

State Variables

SETTLEMENT_NFT

SettlementNft public immutable SETTLEMENT_NFT;

SETTLERS_TOKEN

SettlerToken public immutable SETTLERS_TOKEN;

Functions

constructor

Constructor to initialize the Settlement NFT and SETTLER token addresses.

constructor(address _nftAddress);

Parameters

NameTypeDescription
_nftAddressaddressThe address of the Settlement NFT contract.

getSequentialData

Get the sequential data for a range of NFTs.

function getSequentialData(uint256 _startingNftId, uint256 _endingNftId)
    public
    view
    returns (SettlementData[] memory results);

Parameters

NameTypeDescription
_startingNftIduint256The starting NFT ID.
_endingNftIduint256The ending NFT ID.

Returns

NameTypeDescription
resultsSettlementData[]The array of SettlementData structs for the range of NFTs.

getRandomData

Get a pseudo-random selection of NFTs.

This function uses pseudo-randomness as it is only used to return a selection of NFTs for display purposes. This function could have been implemented offchain but the point of this view contract is to make interacting with the contracts easier for the front-end.

function getRandomData(uint256 requestedNumber) external view returns (SettlementData[] memory results);

Parameters

NameTypeDescription
requestedNumberuint256The number of NFTs to return.

Returns

NameTypeDescription
resultsSettlementData[]The array of SettlementData structs for the random NFTs.

_daysSinceMint

Calculates the days since mint for an NFT.

function _daysSinceMint(uint256 _mintTimestamp) internal view returns (uint256 daysSinceMint);

Parameters

NameTypeDescription
_mintTimestampuint256The timestamp when the NFT was minted.

Returns

NameTypeDescription
daysSinceMintuint256The days since the NFT was minted.

_populateSettlementData

Populates the SettlementData struct for an NFT.

function _populateSettlementData(uint256 i) internal view returns (SettlementData memory data);

Parameters

NameTypeDescription
iuint256The NFT ID.

Returns

NameTypeDescription
dataSettlementDataThe SettlementData struct for the NFT.

Structs

SettlementData

struct SettlementData {
    address owner;
    uint256 daysSinceMint;
    uint256 tokens;
    uint256 chainId;
    uint256 nftId;
}