dn404 icon indicating copy to clipboard operation
dn404 copied to clipboard

DN404 identification

Open ghost opened this issue 2 years ago • 3 comments

Currently, it would be possible to use staticcall for mirrorERC721 in order to detect if the contract is DN404 however this could also cause an issue with abi.decode since it doesn't catch decoding errors effectively

https://github.com/ethereum/solidity/issues/10381

Therefore, the cleanest method would be supporting an arbitrary value for supportsInterface function

https://github.com/Vectorized/dn404/pull/68

ghost avatar Feb 15 '24 09:02 ghost

function _getMirrorERC721(address possibleDN404) internal view returns (address result) {
    assembly {
        mstore(0x00, 0x4ef41efc) // `mirrorERC721()`.
        if and(
            gt(returndatasize(), 0x1f),
            staticcall(gas(), possibleDN404, 0x1c, 0x04, 0x00, 0x20)
        ) {
            // If result is a non-zero address, contract is very likely DN404.
            result := shr(96, mload(0x0c)) 
        }
    }   
}

Vectorized avatar Feb 15 '24 10:02 Vectorized

@Vectorized Would be great if we have a set of functions like this as a library contract

ghost avatar Feb 15 '24 10:02 ghost

Sounds like good suggestion.

Vectorized avatar Feb 15 '24 10:02 Vectorized