👀View Function
Here are the main view functions in Philand
ViewPhiland
/*
* @title viewPhiland
* @notice Return philand object
* @param name : ens name
* @dev List of objects written to map contract.
*/
function viewPhiland(string memory name) external view returns (ObjectInfo[] memory) {
return userObject[name];
}
/* --------------------------------- OBJECT --------------------------------- */
mapping(string => ObjectInfo[]) public userObject;
struct ObjectInfo {
address contractAddress;
uint256 tokenId;
uint8 xStart;
uint8 yStart;
uint8 xEnd;
uint8 yEnd;
Link link;
}
Check Wallpaper/Baseplate
/*
* @title checkWallPaper
* @notice Functions for check WallPaper status
* @param name : ens name
* @dev Check WallPaper information
* @return contractAddress,tokenId
*/
function checkWallPaper(string memory name) external view returns (WallPaper memory) {
return wallPaper[name];
}
/*
* @title checkBasePlate
* @notice Functions for check BasePlate status
* @param name : ens name
* @dev Check BasePlate information
* @return contractAddress,tokenId
*/
function checkBasePlate(string memory name) external view returns (BasePlate memory) {
return basePlate[name];
}
viewLinks
/*
* @title viewLinks
* @notice Functions for check all link status
* @param name : Ens name
* @dev Check all link information
*/
function viewLinks(string memory name) external view returns (Link[] memory) {
uint256 objectLength = userObject[name].length;
ObjectInfo[] memory _userObjects = userObject[name];
Link[] memory links = new Link[](objectLength);
for (uint256 i = 0; i < objectLength; ++i) {
links[i] = _userObjects[i].link;
}
return links;
}
viewPhilandArray
/*
* @title viewPhilandArray
* @param name : ens name
* @notice Return array of philand
*/
function viewPhilandArray(string memory name) external view returns (uint256[] memory) {
if (ownerOfPhiland(name) == address(0)) {
revert NotReadyPhiland({ sender: msg.sender, owner: ownerOfPhiland(name) });
}
uint256 sizeX = mapSettings.maxX;
uint256 sizeY = mapSettings.maxY;
uint256[] memory philandArray = new uint256[](sizeX * sizeY);
uint256 objectLength = userObject[name].length;
ObjectInfo[] memory _userObjects = userObject[name];
for (uint256 i = 0; i < objectLength; ++i) {
if (_userObjects[i].contractAddress != address(0)) {
uint256 xStart = _userObjects[i].xStart;
uint256 xEnd = _userObjects[i].xEnd;
uint256 yStart = _userObjects[i].yStart;
uint256 yEnd = _userObjects[i].yEnd;
for (uint256 x = xStart; x < xEnd; ++x) {
for (uint256 y = yStart; y < yEnd; ++y) {
philandArray[x + sizeY * y] = 1;
}
}
}
}
return philandArray;
}
Last updated