From ebcba3fd0bb64f898a549db15714cf5d73724b8a Mon Sep 17 00:00:00 2001 From: Jeremy Klein Date: Sun, 22 Sep 2024 22:02:03 -0700 Subject: [PATCH] Remove msats from field names as per feedback --- nwc_backend/event_handlers/__tests__/get_budget_test.py | 8 ++++---- nwc_backend/event_handlers/get_budget_handler.py | 8 ++++---- nwc_backend/models/nip47_budget.py | 6 +++--- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/nwc_backend/event_handlers/__tests__/get_budget_test.py b/nwc_backend/event_handlers/__tests__/get_budget_test.py index fe41701..4f67058 100644 --- a/nwc_backend/event_handlers/__tests__/get_budget_test.py +++ b/nwc_backend/event_handlers/__tests__/get_budget_test.py @@ -64,8 +64,8 @@ async def test_get_budget_success__spending_limit_SAT_enabled( mock_get_budget_estimate.assert_not_called() spending_cycle = (await db.session.execute(select(SpendingCycle))).scalar_one() assert exclude_none_values(response.to_dict()) == { - "total_budget_msats": 1000000, - "used_budget_msats": 0, + "total_budget": 1000000, + "used_budget": 0, "renews_at": round(spending_cycle.end_time.timestamp()), } @@ -104,8 +104,8 @@ async def test_pay_invoice_success__spending_limit_USD_enabled( headers=ANY, ) assert exclude_none_values(response.to_dict()) == { - "total_budget_msats": estimated_budget_currency_amount * 1000, - "used_budget_msats": 0, + "total_budget": estimated_budget_currency_amount * 1000, + "used_budget": 0, "renews_at": ANY, "currency": { "code": "USD", diff --git a/nwc_backend/event_handlers/get_budget_handler.py b/nwc_backend/event_handlers/get_budget_handler.py index 9d31e1b..50bd6c2 100644 --- a/nwc_backend/event_handlers/get_budget_handler.py +++ b/nwc_backend/event_handlers/get_budget_handler.py @@ -24,8 +24,8 @@ async def get_budget(access_token: str, request: Nip47Request) -> Nip47BudgetRes current_spending_limit.amount - current_cycle_remaining_amount ) return Nip47BudgetResponse( - total_budget_msats=current_spending_limit.amount * 1000, - used_budget_msats=used_budget_sats * 1000, + total_budget=current_spending_limit.amount * 1000, + used_budget=used_budget_sats * 1000, renews_at=current_cycle_renews_at, ) @@ -53,7 +53,7 @@ async def get_budget(access_token: str, request: Nip47Request) -> Nip47BudgetRes name=budget_currency.name, decimals=budget_currency.decimals, ), - total_budget_msats=total_budget_sats * 1000, - used_budget_msats=used_budget_sats * 1000, + total_budget=total_budget_sats * 1000, + used_budget=used_budget_sats * 1000, renews_at=current_cycle_renews_at, ) diff --git a/nwc_backend/models/nip47_budget.py b/nwc_backend/models/nip47_budget.py index 73e99b0..522c178 100644 --- a/nwc_backend/models/nip47_budget.py +++ b/nwc_backend/models/nip47_budget.py @@ -14,12 +14,12 @@ class Nip47BudgetCurrency: @dataclass class Nip47BudgetResponse: - used_budget_msats: Optional[int] = None - total_budget_msats: Optional[int] = None + used_budget: Optional[int] = None + total_budget: Optional[int] = None renews_at: Optional[int] = None currency: Optional[Nip47BudgetCurrency] = None def to_dict(self): - if self.used_budget_msats is None: + if self.used_budget is None: return {} return {k: v for k, v in asdict(self).items() if v is not None}