Skip to content

Commit ebfa809

Browse files
committed
feat(Account): warn unsupported version
1 parent c8104b6 commit ebfa809

1 file changed

Lines changed: 16 additions & 5 deletions

File tree

ape_safe/accounts.py

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
)
3838
from .factory import SafeFactory
3939
from .modules import SafeModuleManager
40-
from .packages import PackageType
40+
from .packages import MANIFESTS_BY_VERSION, PackageType
4141
from .types import SafeCacheData
4242
from .utils import encode_signatures, get_safe_tx_hash
4343

@@ -199,6 +199,7 @@ def _safe_tx_exec_args(safe_tx: SafeTx) -> list:
199199
class SafeAccount(AccountAPI):
200200
account_file_path: Path # NOTE: Cache any relevant data here
201201
_factory: ClassVar[SafeFactory] = SafeFactory()
202+
_warn_supported_version: ClassVar[bool] = True
202203

203204
def __dir__(self) -> list[str]:
204205
return [
@@ -350,11 +351,21 @@ def version(self) -> Version:
350351
outputs=[ABIType(type="string")],
351352
)
352353

353-
if isinstance(version := ContractCall(VERSION_ABI, address=self.address)(), str):
354-
return Version(version)
354+
if not isinstance(version := ContractCall(VERSION_ABI, address=self.address)(), str):
355+
# NOTE: If `eth_call` returns nothing, the safe is likely not on the correct network
356+
raise NoVersionDetected(self.address)
355357

356-
# NOTE: If `eth_call` returns nothing, the safe is likely not on the correct network
357-
raise NoVersionDetected(self.address)
358+
elif (
359+
version := Version(version)
360+
) not in MANIFESTS_BY_VERSION and self._warn_supported_version:
361+
supported_versions = "', 'v".join(map(str, MANIFESTS_BY_VERSION))
362+
logger.warning(
363+
f"'v{version}' is not a version supported by this library, "
364+
f"consider migrating to one of {supported_versions}"
365+
)
366+
self.__class__._warn_supported_version = False
367+
368+
return version
358369

359370
@property
360371
def signers(self) -> list[AddressType]:

0 commit comments

Comments
 (0)