Skip to content

Commit

Permalink
Remove msats from field names as per feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
jklein24 committed Sep 23, 2024
1 parent 7abc4ad commit ebcba3f
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
8 changes: 4 additions & 4 deletions nwc_backend/event_handlers/__tests__/get_budget_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()),
}

Expand Down Expand Up @@ -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",
Expand Down
8 changes: 4 additions & 4 deletions nwc_backend/event_handlers/get_budget_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
)

Expand Down Expand Up @@ -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,
)
6 changes: 3 additions & 3 deletions nwc_backend/models/nip47_budget.py
Original file line number Diff line number Diff line change
Expand Up @@ -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}

0 comments on commit ebcba3f

Please sign in to comment.