//Write your own contracts here. Currently compiles using solc v0.4.15+commit.bbb8e64f. pragma solidity >=0.7.0 <0.9.0; contract Asset is Ownable { address public originalOwner; mapping(uint256 => address) ownerHistory; mapping(uint256 => uint256) priceHistory; uint256 public price = 0; uint256 public royalty = 0; uint256 private ownerIndex = 0; bool public isLocked = false; bool public canSell = false; uint256 public tokenId; MarketplaceProxy public marketplaceProxy; event UpdatePrice ( address indexed _owner, uint256 _previousPrice, uint256 _newPrice, uint256 _id ); event UpdateRoyalty ( address indexed _owner, uint256 _previousRoyalty, uint256 _newRoyalty, uint256 _id ); event Purchase ( address indexed _recipient, address indexed _buyee, uint256 _price, uint256 _id ); event Transfer ( address indexed _from, address indexed _to, uint256 _id ); event Create ( address indexed _owner, uint256 _id ); event Lock ( uint256 _id, bool _lockedState ); event List ( uint256 _id, bool _sellState ); modifier unlocked() { require(!isLocked, "Asset is locked."); _; } modifier sellable() { require(canSell, "Asset is not for sale."); _; } constructor (uint256 _tokenId, MarketplaceProxy _marketplaceProxy) { tokenId = _tokenId; originalOwner = msg.sender; updateOwner(); marketplaceProxy = _marketplaceProxy; } function updateOwner() private { ownerHistory[ownerIndex++] = msg.sender; transferOwnership(msg.sender); } function setSellable(bool state) internal { canSell = state; emit List(tokenId, state); } function setPrice(uint256 _price) public onlyOwner { if (!canSell && _price >= 0) setSellable(true); require(price != _price, "Cannot set price to same value."); emit UpdatePrice(owner(), price, _price); price = _price; } function setRoyalty(uint256 _royalty) public onlyOwner unlocked { require(royalty != _royalty, "Cannot set royalty to same value."); require(0 <= _royalty <= 90, "Displaced royalties"); emit UpdateRoyalty(owner(), royalty, _royalty); royalty = _royalty; } function distributeFees() internal { if (isLocked == false) isLocked = true; setSellable(false); } function purchase() public payable sellable { require( msg.sender != owner(), "Buyer and owner cannot be the same." ); require(msg.value == price, "Invalid funds to purchase."); setSellable(false); distributeFees(); emit Purchase(owner(), msg.sender, price); transfer(msg.sender); updateOwner(); } function getOwner() public view returns (address) { return owner(); } function getLockedState() public view returns (bool) { return isLocked; } }
0.7.1