Skip to content

Commit 3ef8b7b

Browse files
committed
fix: use get_balance instead of get_credit_balance who does not exist anymore
1 parent eb1eb76 commit 3ef8b7b

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
@@ -338,11 +338,11 @@ async def balance(
338338
try:
339339
# Fetch user Credits
340340
async with AlephHttpClient() as client:
341-
credits_balance = await client.get_credit_balance(address)
341+
credits_balance = await client.get_balance(address).credit_balance
342342
infos += [
343343
Text("\nCredits:"),
344344
Text.from_markup(
345-
f"[bright_cyan] {displayable_amount(credits_balance.credits, decimals=2)}[/bright_cyan]"
345+
f"[bright_cyan] {displayable_amount(credits_balance, decimals=2)}[/bright_cyan]"
346346
),
347347
]
348348
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
@@ -454,12 +454,14 @@ async def create(
454454
if payment_type == PaymentType.credit:
455455
async with AlephHttpClient(api_server=settings.API_HOST) as client:
456456
try:
457-
credit_info = await client.get_credit_balance(address=address)
457+
credit_info = await client.get_balance(address=address)
458458
if isinstance(compute_unit_price, Price) and compute_unit_price.credit:
459459
credit_price = Decimal(str(compute_unit_price.credit)) * tier.compute_units
460-
if credit_info.credits < credit_price:
461-
raise InsufficientFundsError(TokenType.CREDIT, float(credit_price), float(credit_info.credits))
462-
available_funds = credit_info.credits
460+
if credit_info.credit_balance < credit_price:
461+
raise InsufficientFundsError(
462+
TokenType.CREDIT, float(credit_price), float(credit_info.credit_balance)
463+
)
464+
available_funds = credit_info.credit_balance
463465
else:
464466
echo("No credits price available for this tier.")
465467
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, payment_type="superfluid"):
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)