Skip to content

Commit

Permalink
fix: empty raises
Browse files Browse the repository at this point in the history
  • Loading branch information
antazoey committed Sep 7, 2023
1 parent 5d9190c commit 5fed708
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 7 deletions.
19 changes: 13 additions & 6 deletions ape_safe/accounts.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,14 @@
from eth_utils import keccak, to_bytes, to_int
from ethpm_types import ContractType

from .client import SafeClient, SafeTx
from .exceptions import NoLocalSigners, NotASigner, NotEnoughSignatures, handle_safe_logic_error
from ape_safe.client import SafeClient, SafeTx
from ape_safe.exceptions import (
ClientUnavailable,
NoLocalSigners,
NotASigner,
NotEnoughSignatures,
handle_safe_logic_error,
)


class AccountContainer(AccountContainerAPI):
Expand Down Expand Up @@ -102,8 +108,9 @@ def fallback_handler(self) -> Optional[ContractInstance]:

@cached_property
def client(self) -> SafeClient:
if self.provider.chain_id not in self.account_file["deployed_chain_ids"]:
raise # Not valid on this chain
chain_id = self.provider.chain_id
if chain_id not in self.account_file["deployed_chain_ids"]:
raise ClientUnavailable(f"Safe client not valid on chain '{chain_id}'.")

return SafeClient(address=self.address, chain_id=self.provider.chain_id)

Expand Down Expand Up @@ -325,7 +332,7 @@ def sign_transaction(

# Determine who is submitting the transaction (if enough signatures are gathered)
if not submit and submitter:
raise # Cannot specify a submitter if not submitting
raise ValueError("Cannot specify a submitter if not submitting.")

elif submit and not submitter:
if len(self.local_signers) == 0:
Expand All @@ -345,7 +352,7 @@ def sign_transaction(
submitter = self.account_manager.load(submitter)

elif not isinstance(submitter, AccountAPI):
raise # Cannot handle `submitter=type(submitter)`
raise TypeError(f"Cannot handle 'submitter={type(submitter)}'.")

# Invariant: `submitter` should be either `AccountAPI` or we are not submitting here
assert isinstance(submitter, AccountAPI) or not submit
Expand Down
7 changes: 6 additions & 1 deletion ape_safe/exceptions.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from contextlib import ContextDecorator
from typing import Type
from typing import Optional, Type

from ape.exceptions import ApeException, ContractLogicError, SignatureError
from ape.types import AddressType
Expand Down Expand Up @@ -27,6 +27,11 @@ def __init__(self, expected: int, actual: int):
)


class ClientUnavailable(ApeSafeException):
def __init__(self, message: Optional[str] = None) -> None:
super().__init__(message or "Client unavailable.")


SAFE_ERROR_CODES = {
"GS000": "Could not finish initialization",
"GS001": "Threshold needs to be defined",
Expand Down

0 comments on commit 5fed708

Please sign in to comment.