Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: empty raises [APE-1378] #22

Merged
merged 1 commit into from
Sep 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
antazoey marked this conversation as resolved.
Show resolved Hide resolved
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