safe-global / safe-smart-account

Safe allows secure management of blockchain assets.
https://safe.global
GNU Lesser General Public License v3.0
1.84k stars 907 forks source link

Add an `ISafe` Interface For Interacting with Safes #701

Closed nlordell closed 8 months ago

nlordell commented 10 months ago

Context / issue

Many contracts such as CompatibilityFallbackHandler and the example guards pull in the entire Safe contracts in order to be able to cast addresses for interacting with calling Safes. For example:

https://github.com/safe-global/safe-contracts/blob/ba5324eb9609ce4290428f023843807fe46a83e2/contracts/handler/CompatibilityFallbackHandler.sol#L59

While this works, I would argue it is not perfect:

All in all, I would argue that the developer experience for modules and fallback handlers could be slightly improved.

Proposed solution

I would propose adding a ISafe interface with the public Safe methods, which can be used in cases where code is interacting with a Safe but does not need to actually deploy one. In particular this would mean extending the CompatabilityFallbackHandler would no longer require compiling all of the Safe contracts with it.

It is perfectly acceptable for the Safe contract to not extend the new ISafe interface if we run into compatibility issues, but we should at least try it.

Additional context

This can also help in cases where different Solidity compiler versions can lead to slight incompatibilities on the same code (see https://github.com/safe-global/safe-contracts/issues/544) which is less likely for plain/simple interfaces.