Skip to content

Commit

Permalink
feat: update createRentalOffer and batch to verify if is weareable an…
Browse files Browse the repository at this point in the history
…d call legacy interface
  • Loading branch information
EDUARDO MELO DE SIQUEIRA authored and EDUARDO MELO DE SIQUEIRA committed Jul 4, 2024
1 parent dad6387 commit 17cd2f8
Showing 1 changed file with 25 additions and 1 deletion.
26 changes: 25 additions & 1 deletion contracts/OriumSftMarketplace.sol
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { Initializable } from '@openzeppelin/contracts-upgradeable/proxy/utils/I
import { PausableUpgradeable } from '@openzeppelin/contracts-upgradeable/security/PausableUpgradeable.sol';
import { IERC1155 } from '@openzeppelin/contracts/token/ERC1155/IERC1155.sol';
import { IERC7589 } from './interfaces/IERC7589.sol';
import { IERC7589Legacy } from './interfaces/IERC7589Legacy.sol';
import { LibOriumSftMarketplace, RentalOffer, CommitAndGrantRoleParams } from './libraries/LibOriumSftMarketplace.sol';
import { IOriumMarketplaceRoyalties } from './interfaces/IOriumMarketplaceRoyalties.sol';

Expand All @@ -21,6 +22,9 @@ contract OriumSftMarketplace is Initializable, OwnableUpgradeable, PausableUpgra
/// @dev oriumMarketplaceRoyalties stores the collection royalties and fees
address public oriumMarketplaceRoyalties;

/// @dev Wearable address
address public constant wearableAddress = 0x58de9AaBCaeEC0f69883C94318810ad79Cc6a44f;

/// @dev hashedOffer => bool
mapping(bytes32 => bool) public isCreated;

Expand Down Expand Up @@ -128,12 +132,21 @@ contract OriumSftMarketplace is Initializable, OwnableUpgradeable, PausableUpgra
_validateCreateRentalOffer(_offer, _rolesRegistryAddress);

if (_offer.commitmentId == 0) {
_offer.commitmentId = IERC7589(_rolesRegistryAddress).lockTokens(
if(_offer.tokenAddress == wearableAddress ){
_offer.commitmentId = IERC7589Legacy(_rolesRegistryAddress).commitTokens(
_offer.lender,
_offer.tokenAddress,
_offer.tokenId,
_offer.tokenAmount
);
}else {
_offer.commitmentId = IERC7589(_rolesRegistryAddress).lockTokens(
_offer.lender,
_offer.tokenAddress,
_offer.tokenId,
_offer.tokenAmount
);
}
}

nonceDeadline[msg.sender][_offer.nonce] = _offer.deadline;
Expand Down Expand Up @@ -301,15 +314,26 @@ contract OriumSftMarketplace is Initializable, OwnableUpgradeable, PausableUpgra
_params[i].tokenAddress
);

IERC7589Legacy _rolesRegistryLegacy = IERC7589Legacy(_rolesRegistryAddress);
IERC7589 _rolesRegistry = IERC7589(_rolesRegistryAddress);

uint256 _validCommitmentId = _params[i].commitmentId;
if (_params[i].commitmentId == 0) {
if(_params[i].tokenAddress == wearableAddress) {
_validCommitmentId = _rolesRegistryLegacy.commitTokens(
msg.sender,
_params[i].tokenAddress,
_params[i].tokenId,
_params[i].tokenAmount
);
} else {
_validCommitmentId = _rolesRegistry.lockTokens(
msg.sender,
_params[i].tokenAddress,
_params[i].tokenId,
_params[i].tokenAmount
);
}
} else {
// if the user provided a valid commitmentId, it's necessary to verify if they actually own it,
// and if all other parameters passed match the commitmentId
Expand Down

0 comments on commit 17cd2f8

Please sign in to comment.