-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathPropertyFacet.sol
45 lines (37 loc) · 1.35 KB
/
PropertyFacet.sol
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.17;
import "@contracts/interfaces/IProperty.sol";
import "@contracts/libraries/Errors.sol";
import "@contracts/libraries/Modifiers.sol";
import "@contracts/libraries/DeRentNFT.sol";
contract PropertyFacet is Modifiers, IPropertyFacet {
using DeRentNFT for AppStorage;
/**
* @dev see {IPropertyFacet-getTotalPropertyCount}.
*/
function getTotalPropertyCount() external view returns (uint256) {
return s.getCount();
}
/**
* @dev see {IPropertyFacet-createProperty}.
*/
function createProperty(string memory uri, uint256 rentPrice) external {
if (rentPrice < Constants.MIN_RENT_PRICE) {
revert Errors.IncorrectRentPrice();
}
uint256 propertyId = s.mint(msg.sender, uri);
s.properties[propertyId] = DataTypes.Property({rentPrice: rentPrice, published: true});
}
/**
* @dev see {IPropertyFacet-updateProperty}.
*/
function updateProperty(uint256 property, string memory uri) external requirePropertyOwner(property) {
s.setTokenURI(property, uri);
}
/**
* @dev see {IPropertyFacet-setPropertyVisibility}.
*/
function setPropertyVisibility(uint256 property, bool visibility) external requirePropertyOwner(property) {
s.properties[property].published = visibility;
}
}