Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Create Offers reverts #53

Merged
merged 7 commits into from
Jun 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
179 changes: 179 additions & 0 deletions .openzeppelin/unknown-1284.json
Original file line number Diff line number Diff line change
Expand Up @@ -753,6 +753,185 @@
},
"namespaces": {}
}
},
"78fdef84715c5d8c81d1fc2cc5d9adef7189b0d6a569c70639538d0c56b35a1a": {
"address": "0xA4c07bCF0ACE9e85Ce59BDD8eC7590a1d946216d",
"txHash": "0xc86a1c8baf7449787b18778506318c95d722735fb603e00b7981bb25c366baf9",
"layout": {
"solcVersion": "0.8.9",
"storage": [
{
"label": "_initialized",
"offset": 0,
"slot": "0",
"type": "t_uint8",
"contract": "Initializable",
"src": "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol:63",
"retypedFrom": "bool"
},
{
"label": "_initializing",
"offset": 1,
"slot": "0",
"type": "t_bool",
"contract": "Initializable",
"src": "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol:68"
},
{
"label": "__gap",
"offset": 0,
"slot": "1",
"type": "t_array(t_uint256)50_storage",
"contract": "ContextUpgradeable",
"src": "@openzeppelin/contracts-upgradeable/utils/ContextUpgradeable.sol:40"
},
{
"label": "_owner",
"offset": 0,
"slot": "51",
"type": "t_address",
"contract": "OwnableUpgradeable",
"src": "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol:22"
},
{
"label": "__gap",
"offset": 0,
"slot": "52",
"type": "t_array(t_uint256)49_storage",
"contract": "OwnableUpgradeable",
"src": "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol:94"
},
{
"label": "_paused",
"offset": 0,
"slot": "101",
"type": "t_bool",
"contract": "PausableUpgradeable",
"src": "@openzeppelin/contracts-upgradeable/security/PausableUpgradeable.sol:29"
},
{
"label": "__gap",
"offset": 0,
"slot": "102",
"type": "t_array(t_uint256)49_storage",
"contract": "PausableUpgradeable",
"src": "@openzeppelin/contracts-upgradeable/security/PausableUpgradeable.sol:116"
},
{
"label": "oriumMarketplaceRoyalties",
"offset": 0,
"slot": "151",
"type": "t_address",
"contract": "NftRentalMarketplace",
"src": "contracts/NftRentalMarketplace.sol:23"
},
{
"label": "isCreated",
"offset": 0,
"slot": "152",
"type": "t_mapping(t_bytes32,t_bool)",
"contract": "NftRentalMarketplace",
"src": "contracts/NftRentalMarketplace.sol:26"
},
{
"label": "nonceDeadline",
"offset": 0,
"slot": "153",
"type": "t_mapping(t_address,t_mapping(t_uint256,t_uint64))",
"contract": "NftRentalMarketplace",
"src": "contracts/NftRentalMarketplace.sol:29"
},
{
"label": "roleDeadline",
"offset": 0,
"slot": "154",
"type": "t_mapping(t_bytes32,t_mapping(t_address,t_mapping(t_uint256,t_uint64)))",
"contract": "NftRentalMarketplace",
"src": "contracts/NftRentalMarketplace.sol:32"
},
{
"label": "rentals",
"offset": 0,
"slot": "155",
"type": "t_mapping(t_bytes32,t_struct(Rental)8694_storage)",
"contract": "NftRentalMarketplace",
"src": "contracts/NftRentalMarketplace.sol:35"
}
],
"types": {
"t_address": {
"label": "address",
"numberOfBytes": "20"
},
"t_array(t_uint256)49_storage": {
"label": "uint256[49]",
"numberOfBytes": "1568"
},
"t_array(t_uint256)50_storage": {
"label": "uint256[50]",
"numberOfBytes": "1600"
},
"t_bool": {
"label": "bool",
"numberOfBytes": "1"
},
"t_bytes32": {
"label": "bytes32",
"numberOfBytes": "32"
},
"t_mapping(t_address,t_mapping(t_uint256,t_uint64))": {
"label": "mapping(address => mapping(uint256 => uint64))",
"numberOfBytes": "32"
},
"t_mapping(t_bytes32,t_bool)": {
"label": "mapping(bytes32 => bool)",
"numberOfBytes": "32"
},
"t_mapping(t_bytes32,t_mapping(t_address,t_mapping(t_uint256,t_uint64)))": {
"label": "mapping(bytes32 => mapping(address => mapping(uint256 => uint64)))",
"numberOfBytes": "32"
},
"t_mapping(t_bytes32,t_struct(Rental)8694_storage)": {
"label": "mapping(bytes32 => struct Rental)",
"numberOfBytes": "32"
},
"t_mapping(t_uint256,t_uint64)": {
"label": "mapping(uint256 => uint64)",
"numberOfBytes": "32"
},
"t_struct(Rental)8694_storage": {
"label": "struct Rental",
"members": [
{
"label": "borrower",
"type": "t_address",
"offset": 0,
"slot": "0"
},
{
"label": "expirationDate",
"type": "t_uint64",
"offset": 20,
"slot": "0"
}
],
"numberOfBytes": "32"
},
"t_uint256": {
"label": "uint256",
"numberOfBytes": "32"
},
"t_uint64": {
"label": "uint64",
"numberOfBytes": "8"
},
"t_uint8": {
"label": "uint8",
"numberOfBytes": "1"
}
},
"namespaces": {}
}
}
}
}
84 changes: 43 additions & 41 deletions addresses/moonbeam/index.json
Original file line number Diff line number Diff line change
@@ -1,42 +1,44 @@
{
"Multisig": {
"address": ""
},
"RolesRegistry": {
"address": ""
},
"SftRolesRegistrySingleRole": {
"address": ""
},
"KMSDeployer": {
"address": "0x04c8c6c56dab836f8bd62cb6884371507e706806"
},
"ImmutableOwnerCreate2Factory": {
"address": ""
},
"OriumMarketplaceRoyalties": {
"address": "0x1FdB03ee7e0A861D0495075C1459ef87bC4de54c",
"operator": "0x04c8c6c56dab836f8bd62cb6884371507e706806",
"implementation": "0xeE485138ae7b0A50F2342c67675c6D0a3bd1d3ea",
"proxyAdmin": "0xbee720D292d591cc94f522050cc2069070e3a15C"
},
"OriumSftMarketplace": {
"address": "",
"operator": "",
"implementation": "",
"proxyAdmin": "",
"libraries": [""]
},
"ERC7432WrapperForERC4907": {
"address": "0xc3154ccac181eb9d71ccd53f29f425bddd52d983"
},
"NftRentalMarketplace": {
"address": "0x201E1636BB21Dfd51F93815BCD008EAe2Fa29bD9",
"operator": "0x04c8c6c56dab836f8bd62cb6884371507e706806",
"implementation": "0xc4951f62E4f1df9fC411C6a9b752154FE6Bd0e0f",
"proxyAdmin": "0x668e73cF24361cfE13801681d8885e6632A7Eaa6",
"libraries": {
"LibNftRentalMarketplace": "0xD2f6956889241597b536C2E1Ae8d2E1052d17178"
}
}
}
"Multisig": {
"address": ""
},
"RolesRegistry": {
"address": ""
},
"SftRolesRegistrySingleRole": {
"address": ""
},
"KMSDeployer": {
"address": "0x04c8c6c56dab836f8bd62cb6884371507e706806"
},
"ImmutableOwnerCreate2Factory": {
"address": ""
},
"OriumMarketplaceRoyalties": {
"address": "0x1FdB03ee7e0A861D0495075C1459ef87bC4de54c",
"operator": "0x04c8c6c56dab836f8bd62cb6884371507e706806",
"implementation": "0xeE485138ae7b0A50F2342c67675c6D0a3bd1d3ea",
"proxyAdmin": "0xbee720D292d591cc94f522050cc2069070e3a15C"
},
"OriumSftMarketplace": {
"address": "",
"operator": "",
"implementation": "",
"proxyAdmin": "",
"libraries": [
""
]
},
"ERC7432WrapperForERC4907": {
"address": "0xc3154ccac181eb9d71ccd53f29f425bddd52d983"
},
"NftRentalMarketplace": {
"address": "0x201E1636BB21Dfd51F93815BCD008EAe2Fa29bD9",
"operator": "0x04c8c6c56dab836f8bd62cb6884371507e706806",
"implementation": "0xA4c07bCF0ACE9e85Ce59BDD8eC7590a1d946216d",
"proxyAdmin": "0x668e73cF24361cfE13801681d8885e6632A7Eaa6",
"libraries": {
"LibNftRentalMarketplace": "0x3c24b00dC7Cae303eF84560A9848f9775890D2d8"
}
}
}
18 changes: 14 additions & 4 deletions contracts/NftRentalMarketplace.sol
Original file line number Diff line number Diff line change
Expand Up @@ -116,9 +116,9 @@ contract NftRentalMarketplace is Initializable, OwnableUpgradeable, PausableUpgr
for (uint256 i = 0; i < _offer.roles.length; i++) {
require(
roleDeadline[_offer.roles[i]][_offer.tokenAddress][_offer.tokenId] < block.timestamp,
'NftRentalMarketplace: role still has an active offer'
'NftRentalMarketplace: role still has an active offer or rental'
);
roleDeadline[_offer.roles[i]][_offer.tokenAddress][_offer.tokenId] = _offer.deadline;
roleDeadline[_offer.roles[i]][_offer.tokenAddress][_offer.tokenId] = _offer.deadline - _offer.minDuration;
}

bytes32 _offerHash = LibNftRentalMarketplace.hashRentalOffer(_offer);
Expand Down Expand Up @@ -149,7 +149,6 @@ contract NftRentalMarketplace is Initializable, OwnableUpgradeable, PausableUpgr
function acceptRentalOffer(RentalOffer calldata _offer, uint64 _duration) external whenNotPaused {
bytes32 _offerHash = LibNftRentalMarketplace.hashRentalOffer(_offer);
uint64 _expirationDate = uint64(block.timestamp + _duration);

LibNftRentalMarketplace.validateAcceptRentalOfferParams(
_offer.borrower,
_offer.minDuration,
Expand Down Expand Up @@ -180,6 +179,12 @@ contract NftRentalMarketplace is Initializable, OwnableUpgradeable, PausableUpgr
_offer.rolesData
);

for (uint256 i = 0; i < _offer.roles.length; i++) {
if(_expirationDate > roleDeadline[_offer.roles[i]][_offer.tokenAddress][_offer.tokenId]) {
roleDeadline[_offer.roles[i]][_offer.tokenAddress][_offer.tokenId] = _expirationDate;
}
}

rentals[_offerHash] = Rental({ borrower: msg.sender, expirationDate: _expirationDate });

emit RentalStarted(_offer.lender, _offer.nonce, msg.sender, _expirationDate);
Expand Down Expand Up @@ -282,7 +287,12 @@ contract NftRentalMarketplace is Initializable, OwnableUpgradeable, PausableUpgr

nonceDeadline[msg.sender][_offer.nonce] = uint64(block.timestamp);
for (uint256 i = 0; i < _offer.roles.length; i++) {
roleDeadline[_offer.roles[i]][_offer.tokenAddress][_offer.tokenId] = uint64(block.timestamp);

if (rentals[_offerHash].expirationDate > uint64(block.timestamp)) {
roleDeadline[_offer.roles[i]][_offer.tokenAddress][_offer.tokenId] = rentals[_offerHash].expirationDate;
} else {
roleDeadline[_offer.roles[i]][_offer.tokenAddress][_offer.tokenId] = uint64(block.timestamp);
}
}
emit RentalOfferCancelled(_offer.lender, _offer.nonce);
}
Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading