From ec243302850e30d37451ed11693a173bd39761c7 Mon Sep 17 00:00:00 2001 From: Juliya Smith Date: Tue, 31 Oct 2023 14:04:32 -0500 Subject: [PATCH] fix: regression issues --- ape_safe/_cli.py | 16 ++++++++-------- ape_safe/accounts.py | 11 ++++++++++- 2 files changed, 18 insertions(+), 9 deletions(-) diff --git a/ape_safe/_cli.py b/ape_safe/_cli.py index 93d05df..cfa5f20 100644 --- a/ape_safe/_cli.py +++ b/ape_safe/_cli.py @@ -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. @@ -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." ) diff --git a/ape_safe/accounts.py b/ape_safe/accounts.py index d916c3c..85427bd 100644 --- a/ape_safe/accounts.py +++ b/ape_safe/accounts.py @@ -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 @@ -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 @@ -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: