Skip to content

Commit b2af031

Browse files
committed
Fix: replace voucher Manager from cli to use new client service 'vouchers'
1 parent a0fbfcd commit b2af031

File tree

2 files changed

+10
-15
lines changed

2 files changed

+10
-15
lines changed

src/aleph_client/commands/account.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
import aiohttp
1111
import typer
12+
from aleph.sdk import AuthenticatedAlephHttpClient
1213
from aleph.sdk.account import _load_account
1314
from aleph.sdk.chains.common import generate_key
1415
from aleph.sdk.chains.solana import parse_private_key as parse_solana_private_key
@@ -42,7 +43,6 @@
4243
yes_no_input,
4344
)
4445
from aleph_client.utils import AsyncTyper, list_unlinked_keys
45-
from aleph_client.voucher import VoucherManager
4646

4747
logger = logging.getLogger(__name__)
4848
app = AsyncTyper(no_args_is_help=True)
@@ -301,8 +301,6 @@ async def balance(
301301
if account and not address:
302302
address = account.get_address()
303303

304-
voucher_manager = VoucherManager(account=account, chain=chain)
305-
306304
if address:
307305
try:
308306
balance_data = await get_balance(address)
@@ -335,7 +333,8 @@ async def balance(
335333
]
336334

337335
# Get vouchers and add them to Account Info panel
338-
vouchers = await voucher_manager.get_all(address=address)
336+
async with AuthenticatedAlephHttpClient(account=account) as client:
337+
vouchers = await client.voucher.get_vouchers(address=address)
339338
if vouchers:
340339
voucher_names = [voucher.name for voucher in vouchers]
341340
infos += [
@@ -422,11 +421,10 @@ async def vouchers(
422421
if account and not address:
423422
address = account.get_address()
424423

425-
voucher_manager = VoucherManager(account=account, chain=chain)
426-
427424
if address:
428425
try:
429-
vouchers = await voucher_manager.get_all(address=address)
426+
async with AuthenticatedAlephHttpClient(account=account) as client:
427+
vouchers = await client.voucher.get_vouchers(address=address)
430428
if vouchers:
431429
voucher_table = Table(title="", show_header=True, box=box.ROUNDED)
432430
voucher_table.add_column("Name", style="bright_cyan")

src/aleph_client/commands/instance/__init__.py

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,6 @@
8585
yes_no_input,
8686
)
8787
from aleph_client.utils import AsyncTyper, sanitize_url
88-
from aleph_client.voucher import VoucherManager
8988

9089
logger = logging.getLogger(__name__)
9190
app = AsyncTyper(no_args_is_help=True)
@@ -193,9 +192,7 @@ async def create(
193192
# Force-switches if NFT payment-type
194193
nft_chains = [Chain.AVAX, Chain.BASE, Chain.SOL]
195194
if payment_type == "nft":
196-
voucher_manager = VoucherManager(account=account, chain=Chain(account.CHAIN))
197195
payment_type = PaymentType.hold
198-
199196
if payment_chain is None or payment_chain not in nft_chains:
200197
if payment_chain:
201198
console.print(
@@ -210,11 +207,11 @@ async def create(
210207
default=Chain.AVAX.value,
211208
)
212209
)
213-
214-
vouchers = await voucher_manager.fetch_vouchers_by_chain(payment_chain)
215-
if len(vouchers) == 0:
216-
console.print("No NFT vouchers find on this account")
217-
raise typer.Exit(code=1)
210+
async with AuthenticatedAlephHttpClient(account=account) as client:
211+
vouchers = await client.voucher.fetch_vouchers_by_chain(chain=Chain(account.CHAIN))
212+
if len(vouchers) == 0:
213+
console.print("No NFT vouchers find on this account")
214+
raise typer.Exit(code=1)
218215

219216
elif payment_type in [ptype.value for ptype in PaymentType]:
220217
payment_type = PaymentType(payment_type)

0 commit comments

Comments
 (0)