-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Daniel Lima
committed
Apr 23, 2024
1 parent
685e026
commit 786d655
Showing
2 changed files
with
51 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,8 @@ pragma solidity 0.8.9; | |
|
||
import { IERC721 } from '@openzeppelin/contracts/token/ERC721/IERC721.sol'; | ||
import { IERC20 } from '@openzeppelin/contracts/token/ERC20/IERC20.sol'; | ||
import { IERC7432VaultExtension } from './interfaces/IERC7432VaultExtension.sol'; | ||
import { ERC165Checker } from '@openzeppelin/contracts/utils/introspection/ERC165Checker.sol'; | ||
import { IOriumMarketplaceRoyalties } from './interfaces/IOriumMarketplaceRoyalties.sol'; | ||
import { OwnableUpgradeable } from '@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol'; | ||
import { Initializable } from '@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol'; | ||
|
@@ -16,6 +18,8 @@ import { LibNftRentalMarketplace, RentalOffer, Rental } from './libraries/LibNft | |
* @author Orium Network Team - [email protected] | ||
*/ | ||
contract NftRentalMarketplace is Initializable, OwnableUpgradeable, PausableUpgradeable { | ||
using ERC165Checker for address; | ||
|
||
/** ######### Global Variables ########### **/ | ||
|
||
/// @dev oriumMarketplaceRoyalties stores the collection royalties and fees | ||
|
@@ -190,6 +194,34 @@ contract NftRentalMarketplace is Initializable, OwnableUpgradeable, PausableUpgr | |
*/ | ||
|
||
function cancelRentalOffer(RentalOffer calldata _offer) external whenNotPaused { | ||
_cancelRentalOffer(_offer); | ||
} | ||
|
||
/** | ||
* @notice Cancels a rental offer and withdraws the NFT. | ||
* @dev Can only be called by the lender, and only withdraws the NFT if the rental has expired. | ||
* @param _offer The rental offer struct. It should be the same as the one used to create the offer. | ||
*/ | ||
|
||
function cancelRentalOfferAndWithdraw(RentalOffer calldata _offer) external whenNotPaused { | ||
_cancelRentalOffer(_offer); | ||
|
||
address _rolesRegistry = IOriumMarketplaceRoyalties(oriumMarketplaceRoyalties).nftRolesRegistryOf( | ||
_offer.tokenAddress | ||
); | ||
require( | ||
_rolesRegistry.supportsERC165InterfaceUnchecked(type(IERC7432VaultExtension).interfaceId), | ||
'NftRentalMarketplace: roles registry does not support IERC7432VaultExtension' | ||
); | ||
IERC7432VaultExtension(_rolesRegistry).withdraw(_offer.tokenAddress, _offer.tokenId); | ||
} | ||
|
||
/** | ||
* @notice Cancels a rental offer. | ||
* @dev Internal function to cancel a rental offer. | ||
* @param _offer The rental offer struct. It should be the same as the one used to create the offer. | ||
*/ | ||
function _cancelRentalOffer(RentalOffer calldata _offer) internal { | ||
bytes32 _offerHash = LibNftRentalMarketplace.hashRentalOffer(_offer); | ||
LibNftRentalMarketplace.validateCancelRentalOfferParams( | ||
isCreated[_offerHash], | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters