Skip to content

Commit

Permalink
fix: use convert to check for address
Browse files Browse the repository at this point in the history
  • Loading branch information
dtdang committed Nov 14, 2024
1 parent 67fcf96 commit 041954f
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions silverback/_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

import click
import yaml # type: ignore[import-untyped]
from ape import Contract
from ape import Contract, convert
from ape.cli import (
AccountAliasPromptChoice,
ConnectedProviderCommand,
Expand All @@ -15,8 +15,9 @@
ape_cli_context,
network_option,
)
from ape.exceptions import Abort, ApeException
from ape.exceptions import Abort, ApeException, ConversionError
from ape.logging import LogLevel
from ape.types import AddressType

from silverback._click_ext import (
SectionedHelpGroup,
Expand Down Expand Up @@ -550,13 +551,14 @@ def create_payment_stream(
accepted_tokens = platform.get_accepted_tokens(network.chain_id)
if token:
try:
convert(token, AddressType)
token_symbol = Contract(token).symbol()
token = accepted_tokens.get(token_symbol)
except ValueError:
except ConversionError:
token = accepted_tokens.get(token)

if token is None:
raise click.UsageError("Token not found in accepted tokens.")
raise click.UsageError(f"Token not found in {accepted_tokens}.")

if not token:
token = accepted_tokens.get(
Expand Down

0 comments on commit 041954f

Please sign in to comment.