Skip to content

Commit 0398812

Browse files
committed
refactor(Account): better error display when version not detected
1 parent 7997cb9 commit 0398812

2 files changed

Lines changed: 18 additions & 7 deletions

File tree

ape_safe/accounts.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
NoLocalSigners,
2929
NotASigner,
3030
NotEnoughSignatures,
31+
NoVersionDetected,
3132
SafeClientException,
3233
handle_safe_logic_error,
3334
)
@@ -344,12 +345,8 @@ def version(self) -> Version:
344345
if isinstance(version := ContractCall(VERSION_ABI, address=self.address)(), str):
345346
return Version(version)
346347

347-
# NOTE: If `eth_call` returns nothing, it will be rendered as randomly
348-
raise ContractNotFoundError(
349-
self.address,
350-
bool(self.provider.network.explorer),
351-
self.provider.network_choice,
352-
)
348+
# NOTE: If `eth_call` returns nothing, the safe is likely not on the correct network
349+
raise NoVersionDetected(self.address)
353350

354351
@property
355352
def signers(self) -> list[AddressType]:

ape_safe/exceptions.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,13 @@
11
from contextlib import ContextDecorator
22
from typing import TYPE_CHECKING, Optional
33

4-
from ape.exceptions import AccountsError, ApeException, ContractLogicError, SignatureError
4+
from ape.exceptions import (
5+
AccountsError,
6+
ApeException,
7+
ContractLogicError,
8+
DecodingError,
9+
SignatureError,
10+
)
511

612
if TYPE_CHECKING:
713
from ape.types import AddressType
@@ -18,6 +24,14 @@ class ApeSafeError(ApeSafeException, AccountsError):
1824
"""
1925

2026

27+
class NoVersionDetected(ApeSafeException, DecodingError):
28+
def __init__(self, safe: "AddressType"):
29+
super().__init__(
30+
f"Could not detect `VERSION()` for {safe}.\n\n"
31+
"**Are you sure you are on the right network?**"
32+
)
33+
34+
2135
class NotASigner(ApeSafeException):
2236
def __init__(self, signer: "AddressType"):
2337
super().__init__(f"{signer} is not a valid signer.")

0 commit comments

Comments
 (0)