From 22fb9ec177b088428109effac09369232385cd53 Mon Sep 17 00:00:00 2001 From: antazoey Date: Wed, 19 Feb 2025 11:17:06 -0600 Subject: [PATCH] refactor: use method in a couple spots --- src/ape/managers/chain.py | 8 ++------ src/ape_console/plugin.py | 10 ++++------ 2 files changed, 6 insertions(+), 12 deletions(-) diff --git a/src/ape/managers/chain.py b/src/ape/managers/chain.py index 33a02b7633..e6c14dd622 100644 --- a/src/ape/managers/chain.py +++ b/src/ape/managers/chain.py @@ -22,7 +22,6 @@ APINotImplementedError, BlockNotFoundError, ChainError, - ConversionError, ProviderNotConnectedError, QueryEngineError, TransactionNotFoundError, @@ -955,11 +954,8 @@ def get_balance( if (isinstance(address, str) and not address.startswith("0x")) or not isinstance( address, str ): - try: - address = self.conversion_manager.convert(address, AddressType) - except ConversionError: - # Try to get the balance anyway; maybe the provider can handle it. - address = address + # Handles accounts, ENS, integers, aliases, everything. + address = self.account_manager.resolve(address) return self.provider.get_balance(address, block_id=block_id) diff --git a/src/ape_console/plugin.py b/src/ape_console/plugin.py index 532d4c4b72..2a52b85603 100644 --- a/src/ape_console/plugin.py +++ b/src/ape_console/plugin.py @@ -4,7 +4,6 @@ import click from click.testing import CliRunner -from eth_utils import is_hex from IPython import get_ipython from IPython.core.magic import Magics, line_magic, magics_class from rich import print as rich_print @@ -14,7 +13,6 @@ from ape.exceptions import Abort, ApeException, handle_ape_exception from ape.logging import logger from ape.managers.project import LocalProject -from ape.types.address import AddressType from ape.utils.basemodel import ManagerAccessMixin from ape.utils.os import clean_path @@ -67,11 +65,11 @@ def bal(self, line: str = ""): provider = ape.networks.provider ecosystem = provider.network.ecosystem result = eval(line, self.ipython.user_global_ns, self.ipython.user_ns) - if isinstance(result, str) and not is_hex(result): - # Check if is an account alias. - address = ape.accounts.load(result).address + if isinstance(result, str) and not result.startswith("0x"): + # Handles accounts, ENS, integers, aliases, everything. + address = ManagerAccessMixin.account_manager.resolve(result) else: - address = ape.convert(result, AddressType) + address = f"{result}" decimals = ecosystem.fee_token_decimals symbol = ecosystem.fee_token_symbol