Files
core/contracts/misc/UIDataProvider.sol
donosonaumczuk 8eb7ca8ef0 misc: Redundant getters removed to reduce bytecode size
Co-authored-by: Victor Naumik <vicnaum@gmail.com>
2023-06-09 17:49:03 +02:00

46 lines
1.3 KiB
Solidity

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.15;
import {ILensHub} from 'contracts/interfaces/ILensHub.sol';
import {Types} from 'contracts/libraries/constants/Types.sol';
/**
* @dev This struct contains both a `Profile` and a `Publication`.
*
* @param profile A standard profile struct.
* @param publication A standard Publication.
*/
struct LatestData {
Types.Profile profile;
Types.Publication publication;
}
/**
* @title UIDataProvider
* @author Lens Protocol
*
* @dev This is a helper contract to fetch a profile and its latest publication in a single call.
*/
contract UIDataProvider {
ILensHub immutable HUB;
constructor(ILensHub hub) {
HUB = hub;
}
/**
* @notice Returns the profile struct and latest publication struct associated with the passed
* profile ID.
*
* @param profileId The profile ID to query.
*
* @return LensData A struct containing the `Profile` and the `Publication` queried.
*/
function getLatestDataByProfile(uint256 profileId) external view returns (LatestData memory) {
Types.Profile memory profile = HUB.getProfile(profileId);
uint256 pubCount = profile.pubCount;
return LatestData(profile, HUB.getPublication(profileId, pubCount));
}
}