Omniscia Evergon Labs Audit

ERC721Utils Code Style Findings

ERC721Utils Code Style Findings

ERU-01C: Error Ambiguity

Description:

The ERC721Utils::checkOnERC721Received function will yield the same error code (ERC721InvalidReceiver) regardless of whether the recipient actually implements the IERC721Receiver interface or not which we consider an incorrect approach.

Example:

packages/contracts/contracts/libs/ERC721Utils.sol
29try IERC721Receiver(to).onERC721Received(operator, from, tokenId, data) returns (bytes4 retval) {
30 if (retval != IERC721Receiver.onERC721Received.selector) {
31 // Token rejected
32 revert IERC721Errors.ERC721InvalidReceiver(to);
33 }
34} catch (bytes memory reason) {
35 if (reason.length == 0) {
36 // non-IERC721Receiver implementer
37 revert IERC721Errors.ERC721InvalidReceiver(to);
38 } else {
39 /// @solidity memory-safe-assembly
40 assembly {
41 revert(add(32, reason), mload(reason))
42 }
43 }
44}

Recommendation:

We advise distinct errors to be introduced for each case, properly depicting that the recipient contract is compatible with EIP-721 callback hooks yet failed to properly accept the asset transferred to it.

Alleviation (b64b659786cf3c84bea52feb3a69f546ba3601f0):

The error code yielded in case the IERC721Receiver::onERC721Received function is supported but does not yield the adequate value has been updated, addressing this exhibit.