Skip to content

Commit 36cc337

Browse files
committed
fix: use get_balance instead of get_credit_balance who does not exist anymore
1 parent 98e07d4 commit 36cc337

File tree

4 files changed

+14
-12
lines changed

4 files changed

+14
-12
lines changed

src/aleph_client/commands/account.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -335,11 +335,11 @@ async def balance(
335335
try:
336336
# Fetch user Credits
337337
async with AlephHttpClient() as client:
338-
credits_balance = await client.get_credit_balance(address)
338+
credits_balance = await client.get_balance(address).credit_balance
339339
infos += [
340340
Text("\nCredits:"),
341341
Text.from_markup(
342-
f"[bright_cyan] {displayable_amount(credits_balance.credits, decimals=2)}[/bright_cyan]"
342+
f"[bright_cyan] {displayable_amount(credits_balance, decimals=2)}[/bright_cyan]"
343343
),
344344
]
345345
except Exception as e:

src/aleph_client/commands/credit.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,14 +48,14 @@ async def show(
4848

4949
if address:
5050
async with AlephHttpClient(api_server=settings.API_HOST) as client:
51-
credit = await client.get_credit_balance(address=address)
51+
credit = await client.get_balance(address=address)
5252
if json:
5353
typer.echo(credit.model_dump_json(indent=4))
5454
else:
5555
infos = [
5656
Text.from_markup(f"Address: {address}\n"),
5757
Text("Credits:"),
58-
Text.from_markup(f" {displayable_amount(credit.credits, decimals=2)}"),
58+
Text.from_markup(f" {displayable_amount(credit.credit_balance, decimals=2)}"),
5959
]
6060
console.print(
6161
Panel(

src/aleph_client/commands/instance/__init__.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -451,12 +451,14 @@ async def create(
451451
if payment_type == PaymentType.credit:
452452
async with AlephHttpClient(api_server=settings.API_HOST) as client:
453453
try:
454-
credit_info = await client.get_credit_balance(address=address)
454+
credit_info = await client.get_balance(address=address)
455455
if isinstance(compute_unit_price, Price) and compute_unit_price.credit:
456456
credit_price = Decimal(str(compute_unit_price.credit)) * tier.compute_units
457-
if credit_info.credits < credit_price:
458-
raise InsufficientFundsError(TokenType.CREDIT, float(credit_price), float(credit_info.credits))
459-
available_funds = credit_info.credits
457+
if credit_info.credit_balance < credit_price:
458+
raise InsufficientFundsError(
459+
TokenType.CREDIT, float(credit_price), float(credit_info.credit_balance)
460+
)
461+
available_funds = credit_info.credit_balance
460462
else:
461463
echo("No credits price available for this tier.")
462464
raise typer.Exit(code=1)

tests/unit/test_instance.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -290,9 +290,9 @@ def create_mock_client(mock_crn_list_obj, mock_pricing_info_response, mock_setti
290290
payment_type=payment_type,
291291
)
292292
),
293-
get_credit_balance=AsyncMock(
293+
get_balance=AsyncMock(
294294
return_value=MagicMock(
295-
credits=5000, # Enough credits for testing
295+
credit_balance=5000, # Enough credits for testing
296296
)
297297
),
298298
)
@@ -339,9 +339,9 @@ def response_get_program_price(ptype):
339339
create_instance=AsyncMock(return_value=[mock_response_create_instance, 200]),
340340
get_program_price=None,
341341
forget=AsyncMock(return_value=(MagicMock(), 200)),
342-
get_credit_balance=AsyncMock(
342+
get_balance=AsyncMock(
343343
return_value=MagicMock(
344-
credits=5000, # Enough credits for testing
344+
credit_balance=5000, # Enough credits for testing
345345
)
346346
),
347347
)

0 commit comments

Comments
 (0)