Skip to main content

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 main Marketplace contract. This enables the MarketplaceViewer to access the functions and state of the Marketplace.

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:

NameType
marketplaceIduintThe id of the marketplace.
startuintThe starting offer ID.
pageSizeuintThe number of offers to retrieve.

Return values:

Type
Offer[] memoryAn array of offers.
uintThe last accessed offer ID.
uintThe auto-increment value of the marketplace for offers.
uintThe 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:

NameType
marketplaceIduintThe id of the marketplace.
_addressaddressThe address of the provider or client.
isProviderboolA boolean to determine if the address is of a provider or client.
startuintStarting index for pagination.
pageSizeuintThe number of deals to retrieve.

Return values:

Type
Marketplace.Deal[] memoryAn array of deals.
uintThe 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.