Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: token flag for cluster pay #171

Merged
merged 7 commits into from
Nov 25, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 17 additions & 3 deletions silverback/_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

import click
import yaml # type: ignore[import-untyped]
from ape import Contract, convert
from ape.cli import (
AccountAliasPromptChoice,
ConnectedProviderCommand,
Expand All @@ -14,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 @@ -546,8 +548,20 @@ def create_payment_stream(
sm = platform.get_stream_manager(network.chain_id)
product = configuration.get_product_code(account.address, cluster.id)

if not token:
accepted_tokens = platform.get_accepted_tokens(network.chain_id)
accepted_tokens = platform.get_accepted_tokens(network.chain_id)
if token:
try:
convert(token, AddressType)
token_symbol = Contract(token).symbol()
fubuloubu marked this conversation as resolved.
Show resolved Hide resolved
except ConversionError:
token_symbol = token
finally:
token = accepted_tokens.get(token_symbol)

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

else:
token = accepted_tokens.get(
click.prompt(
"Select one of the following tokens to fund your stream with",
Expand Down
Loading