Skip to content

Commit

Permalink
fix: regression issues
Browse files Browse the repository at this point in the history
  • Loading branch information
antazoey committed Oct 31, 2023
1 parent 16bafe7 commit ec24330
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 9 deletions.
16 changes: 8 additions & 8 deletions ape_safe/_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,14 @@ def remove(cli_ctx: SafeCliContext, alias):
# value of `--execute` was provided.
def _handle_execute_cli_arg(ctx, param, val):
# Account alias - execute using this account.
if val in ctx.obj.account_manager.aliases:
if val is None:
# Was not given any value.
# If it is determined in `pending` that a tx can execute,
# the user will get prompted.
# Avoid this by always doing `--execute false`.
return val

elif val in ctx.obj.account_manager.aliases:
return ctx.obj.account_manager.load(val)

# Account address - execute using this account.
Expand All @@ -131,13 +138,6 @@ def _handle_execute_cli_arg(ctx, param, val):
elif val.lower() in ("false", "f", "0"):
return False

elif val is None:
# Was not given any value.
# If it is determined in `pending` that a tx can execute,
# the user will get prompted.
# Avoid this by always doing `--execute false`.
return val

raise BadOptionUsage(
"--execute", f"`--execute` value '{val}` not a boolean or account identifier."
)
Expand Down
11 changes: 10 additions & 1 deletion ape_safe/accounts.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from ape.api.address import BaseAddress
from ape.api.networks import LOCAL_NETWORK_NAME, ForkedNetworkAPI
from ape.contracts import ContractInstance
from ape.exceptions import ProviderNotConnectedError
from ape.logging import logger
from ape.managers.accounts import AccountManager, TestAccountManager
from ape.types import AddressType, HexBytes, MessageSignature, SignableMessage
Expand Down Expand Up @@ -69,6 +70,9 @@ def __iter__(self) -> Iterator["SafeAccount"]:
yield from self.accounts

def __contains__(self, item: Union[str, "SafeAccount"]) -> bool:
if item is None:
return False

if isinstance(item, str):
return item in self.aliases or item in self.addresses

Expand Down Expand Up @@ -178,7 +182,12 @@ def account_file(self) -> dict:

@property
def address(self) -> AddressType:
return self.provider.network.ecosystem.decode_address(self.account_file["address"])
try:
ecosystem = self.provider.network.ecosystem
except ProviderNotConnectedError:
ecosystem = self.network_manager.ethereum

return ecosystem.decode_address(self.account_file["address"])

@cached_property
def contract(self) -> ContractInstance:
Expand Down

0 comments on commit ec24330

Please sign in to comment.