From 9927e8f3620833c681c87320889602a8d7dcbba6 Mon Sep 17 00:00:00 2001 From: cephas samuel shehu Date: Thu, 15 Aug 2024 19:30:23 +0100 Subject: [PATCH] Assignment ERCtokens --- contracts/ERC20.sol | 4 ++-- contracts/ERC721.sol | 5 +++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/contracts/ERC20.sol b/contracts/ERC20.sol index 06e1ed09..542301ca 100644 --- a/contracts/ERC20.sol +++ b/contracts/ERC20.sol @@ -62,11 +62,11 @@ contract ERC20 is IERC20 { emit Transfer(from, address(0), amount); } - function mint(address to, uint256 amount) external { + function mint(address to, uint256 amount) internal { _mint(to, amount); } - function burn(address from, uint256 amount) external { + function burn(address from, uint256 amount) internal{ _burn(from, amount); } } diff --git a/contracts/ERC721.sol b/contracts/ERC721.sol index b53814c2..538f839f 100644 --- a/contracts/ERC721.sol +++ b/contracts/ERC721.sol @@ -74,8 +74,9 @@ contract ERC721 is IERC721 { } function ownerOf(uint256 id) external view returns (address owner) { - owner = _ownerOf[id]; require(owner != address(0), "token doesn't exist"); + owner = _ownerOf[id]; + } function balanceOf(address owner) external view returns (uint256) { @@ -118,7 +119,7 @@ contract ERC721 is IERC721 { function transferFrom(address from, address to, uint256 id) public { require(from == _ownerOf[id], "from != owner"); - require(to != address(0), "transfer to zero address"); + require(_isApprovedOrOwner(from, msg.sender, id), "not authorized");