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

update openzeppelin version to latest #415

Merged
merged 4 commits into from
Jun 25, 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
7 changes: 3 additions & 4 deletions contracts/LockDealNFT/LockDealNFT.sol
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
/// @title LockDealNFT contract
/// @notice Implements a non-fungible token (NFT) contract for locking deals
contract LockDealNFT is LockDealNFTInternal, IERC721Receiver {
constructor(address _vaultManager, string memory _baseURI) ERC721("LockDealNFT", "LDNFT") {
constructor(address _vaultManager, string memory _baseURI) ERC721("LockDealNFT", "LDNFT") Ownable(_msgSender()){
_notZeroAddress(_vaultManager);
vaultManager = IVaultManager(_vaultManager);
approvedContracts[address(this)] = true;
Expand Down Expand Up @@ -71,7 +71,7 @@ contract LockDealNFT is LockDealNFTInternal, IERC721Receiver {
/// @dev Sets the approved status of a contract
/// @param contractAddress The address of the contract
/// @param status The new approved status (true or false)
function setApprovedContract(address contractAddress, bool status) external onlyOwner onlyContract(contractAddress) {
function setApprovedContract(address contractAddress, bool status) external onlyOwner notZeroAddress(contractAddress) {
approvedContracts[contractAddress] = status;
emit ContractApproved(contractAddress, status);
}
Expand All @@ -98,8 +98,7 @@ contract LockDealNFT is LockDealNFTInternal, IERC721Receiver {
}

function transferFrom(address from, address to, uint256 tokenId) public override(ERC721, IERC721) {
require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: transfer caller is not owner nor approved");
_safeTransfer(from, to, tokenId, "");
ERC721.transferFrom(from, to, tokenId);
}

function setBaseURI(string memory newBaseURI) external onlyOwner {
Expand Down
23 changes: 10 additions & 13 deletions contracts/LockDealNFT/LockDealNFTInternal.sol
Original file line number Diff line number Diff line change
Expand Up @@ -8,26 +8,23 @@ import "@poolzfinance/poolz-helper-v2/contracts/interfaces/IInnerWithdraw.sol";
import "@ironblocks/firewall-consumer/contracts/FirewallConsumer.sol";

abstract contract LockDealNFTInternal is LockDealNFTModifiers, FirewallConsumer {
function _transfer(address from, address to, uint256 poolId)
internal
override
firewallProtectedSig(0x30e0789e)
{
if (
from != address(0) &&
ERC165Checker.supportsInterface(address(poolIdToProvider[poolId]), type(IBeforeTransfer).interfaceId)
) {
IBeforeTransfer(address(poolIdToProvider[poolId])).beforeTransfer(from, to, poolId);
function _update(
address to,
uint256 poolId,
address auth
) internal override firewallProtectedSig(0x30e0789e) returns (address from) {
if (auth != address(0) && ERC165Checker.supportsInterface(address(poolIdToProvider[poolId]), type(IBeforeTransfer).interfaceId)) {
IBeforeTransfer(address(poolIdToProvider[poolId])).beforeTransfer(auth, to, poolId);
}
// check for split and withdraw transfers
if (!(approvedContracts[to] || approvedContracts[from])) {
require(approvedPoolUserTransfers[from], "Pool transfer not approved by user");
if (auth != address(0) && !(approvedContracts[to] || approvedContracts[auth])) {
require(approvedPoolUserTransfers[auth], "Pool transfer not approved by user");
require(
vaultManager.vaultIdToTradeStartTime(poolIdToVaultId[poolId]) < block.timestamp,
"Can't transfer before trade start time"
);
}
super._transfer(from, to, poolId);
from = super._update(to, poolId, auth);
}

/// @param owner The address to assign the token to
Expand Down
9 changes: 0 additions & 9 deletions contracts/LockDealNFT/LockDealNFTModifiers.sol
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,6 @@ abstract contract LockDealNFTModifiers is LockDealNFTState {
_;
}

modifier onlyContract(address contractAddress) {
_onlyContract(contractAddress);
_;
}

modifier notZeroAddress(address _address) {
_notZeroAddress(_address);
_;
Expand All @@ -36,10 +31,6 @@ abstract contract LockDealNFTModifiers is LockDealNFTState {
require(_address != address(0x0), "Zero Address is not allowed");
}

function _onlyContract(address contractAddress) private view {
require(Address.isContract(contractAddress), "Invalid contract address");
}

function _onlyApprovedContract(address contractAddress) internal view {
require(approvedContracts[contractAddress], "Contract not approved");
}
Expand Down
4 changes: 4 additions & 0 deletions contracts/LockDealNFT/LockDealNFTState.sol
Original file line number Diff line number Diff line change
Expand Up @@ -137,4 +137,8 @@ abstract contract LockDealNFTState is ERC721Enumerable, ILockDealNFTEvents, Owna
}
}
}

function _exists(uint256 poolId) internal view returns (bool) {
return _ownerOf(poolId) != address(0);
}
}
Loading