Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
fixed linter errors
  • Loading branch information
nastassiasachs committed Feb 15, 2018
commit 75e80874bf22b12d35fd16d41034075d05ea14c8
21 changes: 9 additions & 12 deletions contracts/mocks/ERC721DeedMock.sol
Original file line number Diff line number Diff line change
Expand Up @@ -6,26 +6,23 @@ import "../token/ERC721/ERC721Deed.sol";
* @title ERC721DeedMock
* This mock just provides a public mint and burn functions for testing purposes.
*/


contract ERC721DeedMock is ERC721Deed {

// ERC-165
bytes4 internal constant INTERFACE_SIGNATURE_ERC165 = // 0x01ffc9a7
bytes4(keccak256('supportsInterface(bytes4)'));
// ERC-165 interface implementation

// 0x01ffc9a7
bytes4 internal constant INTERFACE_SIGNATURE_ERC165 = bytes4(keccak256("supportsInterface(bytes4)"));

bytes4 internal constant INTERFACE_SIGNATURE_ERC721 = // 0xda671b9b
bytes4(keccak256('ownerOf(uint256)')) ^
bytes4(keccak256('countOfDeeds()')) ^
bytes4(keccak256('countOfDeedsByOwner(address)')) ^
bytes4(keccak256('deedOfOwnerByIndex(address,uint256)')) ^
bytes4(keccak256('approve(address,uint256)')) ^
bytes4(keccak256('takeOwnership(uint256)'));
// 0xda671b9b
bytes4 internal constant INTERFACE_SIGNATURE_ERC721 = bytes4(keccak256("ownerOf(uint256)")) ^ bytes4(keccak256("countOfDeeds()")) ^ bytes4(keccak256("countOfDeedsByOwner(address)")) ^ bytes4(keccak256("deedOfOwnerByIndex(address,uint256)")) ^ bytes4(keccak256("approve(address,uint256)")) ^ bytes4(keccak256("takeOwnership(uint256)"));

function ERC721DeedMock() ERC721Deed() public {}

function supportsInterface(bytes4 _interfaceID) external pure returns (bool) {
return (
_interfaceID == INTERFACE_SIGNATURE_ERC165
|| _interfaceID == INTERFACE_SIGNATURE_ERC721
_interfaceID == INTERFACE_SIGNATURE_ERC165 || _interfaceID == INTERFACE_SIGNATURE_ERC721
);
}

Expand Down
50 changes: 19 additions & 31 deletions contracts/token/ERC721/ERC721Deed.sol
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,13 @@ pragma solidity ^0.4.18;

import "./ERC721.sol";
import "../../math/SafeMath.sol";

/**
* @title ERC721Deed
* Generic implementation for the required functionality of the ERC721 standard
*/


contract ERC721Deed is ERC721 {
using SafeMath for uint256;

Expand Down Expand Up @@ -41,8 +44,7 @@ contract ERC721Deed is ERC721 {
* @param _deedId uint256 ID of the deed to query the owner of
* @return owner address currently marked as the owner of the given deed ID
*/
function ownerOf(uint256 _deedId)
external view returns (address _owner) {
function ownerOf(uint256 _deedId) external view returns (address _owner) {
require(deedOwner[_deedId] != address(0));
_owner = deedOwner[_deedId];
}
Expand All @@ -51,8 +53,7 @@ contract ERC721Deed is ERC721 {
* @dev Gets the total amount of deeds stored by the contract
* @return uint256 representing the total amount of deeds
*/
function countOfDeeds()
external view returns (uint256) {
function countOfDeeds() external view returns (uint256) {
return totalDeeds;
}

Expand All @@ -61,8 +62,7 @@ contract ERC721Deed is ERC721 {
* @param _owner address to query the number of deeds
* @return uint256 representing the number of deeds owned by the passed address
*/
function countOfDeedsByOwner(address _owner)
external view returns (uint256 _count) {
function countOfDeedsByOwner(address _owner) external view returns (uint256 _count) {
require(_owner != address(0));
_count = ownedDeeds[_owner].length;
}
Expand All @@ -73,8 +73,7 @@ contract ERC721Deed is ERC721 {
* @param _index uint256 for the n-th deed in the list of deeds owned by this owner
* @return uint256 representing the ID of the deed
*/
function deedOfOwnerByIndex(address _owner, uint256 _index)
external view returns (uint256 _deedId) {
function deedOfOwnerByIndex(address _owner, uint256 _index) external view returns (uint256 _deedId) {
require(_owner != address(0));
require(_index < ownedDeeds[_owner].length);
_deedId = ownedDeeds[_owner][_index];
Expand All @@ -85,8 +84,7 @@ contract ERC721Deed is ERC721 {
* @param _owner address for the deed's owner
* @return uint256[] representing all deed IDs owned by the passed address
*/
function deedsOf(address _owner)
external view returns (uint256[] _ownedDeedIds) {
function deedsOf(address _owner) external view returns (uint256[] _ownedDeedIds) {
require(_owner != address(0));
_ownedDeedIds = ownedDeeds[_owner];
}
Expand All @@ -96,10 +94,9 @@ contract ERC721Deed is ERC721 {
* @param _to address to be approved for the given deed ID
* @param _deedId uint256 ID of the deed to be approved
*/
function approve(address _to, uint256 _deedId)
external onlyOwnerOf(_deedId) payable {
function approve(address _to, uint256 _deedId) external onlyOwnerOf(_deedId) payable {
require(_to != msg.sender);
if(_to != address(0) || approvedFor(_deedId) != address(0)) {
if (_to != address(0) || approvedFor(_deedId) != address(0)) {
Approval(msg.sender, _to, _deedId);
}
deedApprovedFor[_deedId] = _to;
Expand All @@ -109,8 +106,7 @@ contract ERC721Deed is ERC721 {
* @dev Claims the ownership of a given deed ID
* @param _deedId uint256 ID of the deed being claimed by the msg.sender
*/
function takeOwnership(uint256 _deedId)
external payable {
function takeOwnership(uint256 _deedId) external payable {
require(approvedFor(_deedId) == msg.sender);
clearApprovalAndTransfer(deedOwner[_deedId], msg.sender, _deedId);
}
Expand All @@ -120,8 +116,7 @@ contract ERC721Deed is ERC721 {
* @param _deedId uint256 ID of the deed to query the approval of
* @return address currently approved to take ownership of the given deed ID
*/
function approvedFor(uint256 _deedId)
public view returns (address) {
function approvedFor(uint256 _deedId) public view returns (address) {
return deedApprovedFor[_deedId];
}

Expand All @@ -130,17 +125,15 @@ contract ERC721Deed is ERC721 {
* @param _to address to receive the ownership of the given deed ID
* @param _deedId uint256 ID of the deed to be transferred
*/
function transfer(address _to, uint256 _deedId)
public onlyOwnerOf(_deedId) {
function transfer(address _to, uint256 _deedId) public onlyOwnerOf(_deedId) {
clearApprovalAndTransfer(msg.sender, _to, _deedId);
}

/**
* @dev Mint deed function
* @param _to The address that will own the minted deed
*/
function _mint(address _to, uint256 _deedId)
internal {
function _mint(address _to, uint256 _deedId) internal {
require(_to != address(0));
addDeed(_to, _deedId);
Transfer(0x0, _to, _deedId);
Expand All @@ -150,8 +143,7 @@ contract ERC721Deed is ERC721 {
* @dev Burns a specific deed
* @param _deedId uint256 ID of the deed being burned by the msg.sender
*/
function _burn(uint256 _deedId) onlyOwnerOf(_deedId)
internal {
function _burn(uint256 _deedId) onlyOwnerOf(_deedId) internal {
if (approvedFor(_deedId) != 0) {
clearApproval(msg.sender, _deedId);
}
Expand All @@ -165,8 +157,7 @@ contract ERC721Deed is ERC721 {
* @param _to address which you want to transfer the deed to
* @param _deedId uint256 ID of the deed to be transferred
*/
function clearApprovalAndTransfer(address _from, address _to, uint256 _deedId)
internal {
function clearApprovalAndTransfer(address _from, address _to, uint256 _deedId) internal {
require(_to != address(0));
require(_to != _from);
require(deedOwner[_deedId] == _from);
Expand All @@ -181,8 +172,7 @@ contract ERC721Deed is ERC721 {
* @dev Internal function to clear current approval of a given deed ID
* @param _deedId uint256 ID of the deed to be transferred
*/
function clearApproval(address _owner, uint256 _deedId)
private {
function clearApproval(address _owner, uint256 _deedId) private {
require(deedOwner[_deedId] == _owner);
deedApprovedFor[_deedId] = 0;
Approval(_owner, 0, _deedId);
Expand All @@ -193,8 +183,7 @@ contract ERC721Deed is ERC721 {
* @param _to address representing the new owner of the given deed ID
* @param _deedId uint256 ID of the deed to be added to the deeds list of the given address
*/
function addDeed(address _to, uint256 _deedId)
private {
function addDeed(address _to, uint256 _deedId) private {
require(deedOwner[_deedId] == address(0));
deedOwner[_deedId] = _to;
uint256 length = ownedDeeds[_to].length;
Expand All @@ -208,8 +197,7 @@ contract ERC721Deed is ERC721 {
* @param _from address representing the previous owner of the given deed ID
* @param _deedId uint256 ID of the deed to be removed from the deeds list of the given address
*/
function removeDeed(address _from, uint256 _deedId)
private {
function removeDeed(address _from, uint256 _deedId) private {
require(deedOwner[_deedId] == _from);

uint256 deedIndex = ownedDeedsIndex[_deedId];
Expand Down