ViewAggregator
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
Name | Type | Description |
---|---|---|
_nftAddress | address | The 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
Name | Type | Description |
---|---|---|
_startingNftId | uint256 | The starting NFT ID. |
_endingNftId | uint256 | The ending NFT ID. |
Returns
Name | Type | Description |
---|---|---|
results | SettlementData[] | 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
Name | Type | Description |
---|---|---|
requestedNumber | uint256 | The number of NFTs to return. |
Returns
Name | Type | Description |
---|---|---|
results | SettlementData[] | 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
Name | Type | Description |
---|---|---|
_mintTimestamp | uint256 | The timestamp when the NFT was minted. |
Returns
Name | Type | Description |
---|---|---|
daysSinceMint | uint256 | The 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
Name | Type | Description |
---|---|---|
i | uint256 | The NFT ID. |
Returns
Name | Type | Description |
---|---|---|
data | SettlementData | The SettlementData struct for the NFT. |
Structs
SettlementData
struct SettlementData {
address owner;
uint256 daysSinceMint;
uint256 tokens;
uint256 chainId;
uint256 nftId;
}