cartesi / rollups-contracts

Smart Contracts for Cartesi Rollups
https://cartesi.github.io/rollups-contracts/
Apache License 2.0
18 stars 38 forks source link

Make input relays implement EIP-165 #151

Closed guidanoli closed 9 months ago

guidanoli commented 9 months ago

šŸ“š Context

EIP-165 defines an interface for contracts to let others know whether they implement some interface or not. This is possible thanks to the following function:

function supportsInterface(bytes4 interfaceID) external view returns (bool);

Where interfaceID is the XOR (exclusive or) of all function selectors in the interface. In Solidity, this value can be computed at compile time, which is very convenient for contract developers.

In #150, we specify that the ICartesiDApp interface returns an array of addresses that can be used to add inputs to the DApp. But, at first, we don't know which functions they implement. So, we should make them implement EIP-165!

āœ”ļø Solution

Make input relays implement EIP-165 and return true for their specific interface and IInputRelay. We should, therefore, also make the specific interfaces NOT inherit from IInputRelay!! The implementations already implement IInputRelay through InputRelay. So, for example, EtherPortal should support IEtherPortal and IInputRelay.

We may use OpenZeppelin's ERC-165 implementation.