ProjectOpenSea / operator-filter-registry

MIT License
312 stars 89 forks source link

Backwards compatibility #2

Closed 0xGh closed 2 years ago

0xGh commented 2 years ago

Hey there, I think that backwards compatibility could be achieved with an intermediate contract. This is a quick and dirty proof of concept:

contract ERC721OperatorFiltererAdapter is DefaultOperatorFilterer, Ownable {
  address public target;

  constructor(address _target) {
    target = _target;
  }

  function transferFrom(address from, address to, uint256 tokenId) public override onlyAllowedOperator onlyApprovedOperator {
      IERC721(target).transferFrom(from, to, tokenId);
  }

  function safeTransferFrom(address from, address to, uint256 tokenId) public override onlyAllowedOperator onlyApprovedOperator {
      IERC721(target).safeTransferFrom(from, to, tokenId);
  }

  function safeTransferFrom(address from, address to, uint256 tokenId, bytes memory data)
      public
      override
      onlyAllowedOperator
      onlyApprovedOperator
  {
      IERC721(target).safeTransferFrom(from, to, tokenId, data);
  }

  mapping(address => bool) private _operatorApprovals;
  function setApprovalForAll(address operator, bool approved) public virtual override onlyOwner {
    _operatorApprovals[operator] = approved;
  }

  modifier onlyApprovedOperator {
    require(true == _operatorApprovals[msg.sender]);
    _;
  }
}
0xFlicker commented 2 years ago

This doesn't block other marketplaces from continuing to trade on the original contract

0xGh commented 2 years ago

Good point, that would happen regardless though so the only option is to not honor royalties. I guess I was trying to think of a registry that provides backwards compatibility but I assume it is not possible in this case.