abstract contract ERC1155TokenReceiver is IERC1155TokenReceiver{
    
    bytes4 constant internal ERC1155_RECEIVED_VALUE = 0xf23a6e61;
    bytes4 constant internal ERC1155_BATCH_RECEIVED_VALUE = 0xbc197c81;
    
    //-------------------------------------ERC1155---------------------------------------------------------------------
    
    function onERC1155Received(address _operator, address _from, uint256 _id, uint256 _value, bytes calldata _data) external override returns(bytes4) {
        uint256[] memory _values = new uint256[](1);
        uint256[] memory _ids = new uint256[](1);
        _ids[0] = _id;
        _values[0] = _value;
        
        operateToken1155(msg.sender,_operator,_from,_ids,_values,_data);
        return ERC1155_RECEIVED_VALUE;
    }

    function onERC1155BatchReceived(address _operator, address _from, uint256[] calldata _ids, uint256[] calldata _values, bytes calldata _data) external override returns(bytes4) {
        operateToken1155(msg.sender,_operator,_from,_ids,_values,_data);
        return ERC1155_BATCH_RECEIVED_VALUE;
    }

    // ERC165 interface support
    function supportsInterface(bytes4 interfaceID) external override pure returns (bool) {
        return  interfaceID == 0x01ffc9a7 ||    // ERC165
                interfaceID == 0x4e2312e0;      // ERC1155_ACCEPTED ^ ERC1155_BATCH_ACCEPTED;
    }
    
    function operateToken1155(address msgSender, address _operator, address _from, uint256[] memory _ids, uint256[] memory _values, bytes calldata _data) internal virtual;
}
function onERC1155Received(address _operator, address _from, uint256 _id, uint256 _value, bytes calldata _data) external override returns(bytes4) {
    uint256[] memory _values = new uint256[](1);
    uint256[] memory _ids = new uint256[](1);
    _ids[0] = _id;
    _values[0] = _value;
        
    operateToken1155(msg.sender,_operator,_from,_ids,_values,_data);
    return ERC1155_RECEIVED_VALUE;
}

//-------------------------------------ERC1155---------------------------------------------------------------------