Skip to content

Commit

Permalink
refactor: use method in a couple spots
Browse files Browse the repository at this point in the history
  • Loading branch information
antazoey committed Feb 19, 2025
1 parent 7526b79 commit 22fb9ec
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 12 deletions.
8 changes: 2 additions & 6 deletions src/ape/managers/chain.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
APINotImplementedError,
BlockNotFoundError,
ChainError,
ConversionError,
ProviderNotConnectedError,
QueryEngineError,
TransactionNotFoundError,
Expand Down Expand Up @@ -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)

Expand Down
10 changes: 4 additions & 6 deletions src/ape_console/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 22fb9ec

Please sign in to comment.