Marketplace Viewer
The MarketplaceViewer
contract acts as a viewer for the Marketplace
contract. It provides functions that allow users to retrieve Offers
and Deals
in a paginated manner. Its aim is to improve the readability and accessibility of the data stored in the Marketplace
contract.
Public State Variables
marketplace
: This is a state variable that holds a reference to the mainMarketplace
contract. This enables theMarketplaceViewer
to access the functions and state of theMarketplace
.
Functions
getPaginatedOffers
Retrieves a page of offers starting from a specific offer ID up to the specified page size.
function getPaginatedOffers(
uint marketplaceId,
uint start,
uint pageSize
) external view returns (
Marketplace.Offer[] memory results,
uint lastAccessedId,
uint autoIncrement,
uint totalItems
);
Parameters:
Name | Type | |
---|---|---|
marketplaceId | uint | The id of the marketplace. |
start | uint | The starting offer ID. |
pageSize | uint | The number of offers to retrieve. |
Return values:
Type | |
---|---|
Offer[] memory | An array of offers. |
uint | The last accessed offer ID. |
uint | The auto-increment value of the marketplace for offers. |
uint | The total number of offers. |
getPaginatedDeals
Fetches deals either associated with a provider or a client in a paginated manner.
function getPaginatedDeals(
uint marketplaceId,
address _address,
bool isProvider,
uint start,
uint pageSize
) external view returns (
Marketplace.Deal[] memory results,
uint totalItems
);
Parameters:
Name | Type | |
---|---|---|
marketplaceId | uint | The id of the marketplace. |
_address | address | The address of the provider or client. |
isProvider | bool | A boolean to determine if the address is of a provider or client. |
start | uint | Starting index for pagination. |
pageSize | uint | The number of deals to retrieve. |
Return values:
Type | |
---|---|
Marketplace.Deal[] memory | An array of deals. |
uint | The total number of deals for the provided address. |
note
This is a high-level technical breakdown. For a deep understanding of each function's inner workings and logic, refer to the smart contract's actual implementation.