Skip to content

Commit

Permalink
[issue:558]remove Address.sol, replace isContract with address(...).c…
Browse files Browse the repository at this point in the history
…ode.length > 0
  • Loading branch information
Alexzhuangyao committed May 6, 2024
1 parent 3e0ab22 commit f7281db
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 22 deletions.
14 changes: 0 additions & 14 deletions 34_ERC721/Address.sol

This file was deleted.

4 changes: 1 addition & 3 deletions 34_ERC721/ERC721.sol
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,9 @@ import "./IERC165.sol";
import "./IERC721.sol";
import "./IERC721Receiver.sol";
import "./IERC721Metadata.sol";
import "./Address.sol";
import "./String.sol";

contract ERC721 is IERC721, IERC721Metadata{
using Address for address; // 使用Address库,用isContract来判断地址是否为合约
using Strings for uint256; // 使用String库,

// Token名称
Expand Down Expand Up @@ -231,7 +229,7 @@ contract ERC721 is IERC721, IERC721Metadata{
uint tokenId,
bytes memory _data
) private returns (bool) {
if (to.isContract()) {
if (to.code.length > 0) {
return
IERC721Receiver(to).onERC721Received(
msg.sender,
Expand Down
8 changes: 3 additions & 5 deletions 34_ERC721/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ interface IERC721Receiver {
uint tokenId,
bytes memory _data
) private returns (bool) {
if (to.isContract()) {
if (to.code.length > 0) {
return
IERC721Receiver(to).onERC721Received(
msg.sender,
Expand Down Expand Up @@ -199,11 +199,9 @@ import "./IERC165.sol";
import "./IERC721.sol";
import "./IERC721Receiver.sol";
import "./IERC721Metadata.sol";
import "./Address.sol";
import "./String.sol";
contract ERC721 is IERC721, IERC721Metadata{
using Address for address; // 使用Address库,用isContract来判断地址是否为合约
using Strings for uint256; // 使用String库,
// Token名称
Expand Down Expand Up @@ -294,7 +292,7 @@ contract ERC721 is IERC721, IERC721Metadata{
_approve(owner, to, tokenId);
}
// 查询 spender地址是否可以使用tokenId(他是owner或被授权地址)。
// 查询 spender地址是否可以使用tokenId(需要是owner或被授权地址)
function _isApprovedOrOwner(
address owner,
address spender,
Expand Down Expand Up @@ -424,7 +422,7 @@ contract ERC721 is IERC721, IERC721Metadata{
uint tokenId,
bytes memory _data
) private returns (bool) {
if (to.isContract()) {
if (to.code.length > 0) {
return
IERC721Receiver(to).onERC721Received(
msg.sender,
Expand Down

0 comments on commit f7281db

Please sign in to comment.