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:
While this works, I would argue it is not perfect:
A of additional code needs to be compiled when only the contract interface is actually used
Makes vendoring more complicated
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.
Context / issue
Many contracts such as
CompatibilityFallbackHandler
and the example guards pull in the entireSafe
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 theCompatabilityFallbackHandler
would no longer require compiling all of theSafe
contracts with it.It is perfectly acceptable for the
Safe
contract to not extend the newISafe
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.