Skip to content

Commit 24bb8e2

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

1 file changed

Lines changed: 14 additions & 5 deletions

File tree

ape_safe/accounts.py

Lines changed: 14 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,19 @@ 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 version not in MANIFESTS_BY_VERSION and self._warn_supported_version:
359+
supported_versions = "', 'v".join(map(str, MANIFESTS_BY_VERSION))
360+
logger.warning(
361+
f"'v{version}' is not a version supported by this library, "
362+
f"consider migrating to one of {supported_versions}"
363+
)
364+
self.__class__._warn_supported_version = False
365+
366+
return Version(version)
358367

359368
@property
360369
def signers(self) -> list[AddressType]:

0 commit comments

Comments
 (0)