From 317d6ebba71b8e768278186c38c2534b86d9ef17 Mon Sep 17 00:00:00 2001 From: vindard <17693119+vindard@users.noreply.github.com> Date: Fri, 26 Apr 2024 14:48:22 -0400 Subject: [PATCH] refactor(core): remove PartialWalletDescriptor type --- core/api/src/domain/shared/index.types.d.ts | 5 +---- .../src/domain/wallet-invoices/index.types.d.ts | 2 +- .../app/wallets/update-pending-invoices.spec.ts | 2 ++ .../wallet-invoice-receiver.spec.ts | 16 +++++----------- .../wallet-invoice-status-checker.spec.ts | 6 +++++- 5 files changed, 14 insertions(+), 17 deletions(-) diff --git a/core/api/src/domain/shared/index.types.d.ts b/core/api/src/domain/shared/index.types.d.ts index d9e15a6b890..ad66180b2f4 100644 --- a/core/api/src/domain/shared/index.types.d.ts +++ b/core/api/src/domain/shared/index.types.d.ts @@ -38,12 +38,9 @@ type BalanceAmount = Amount & { readonly brand?: unique symbol } -type PartialWalletDescriptor = { +type WalletDescriptor = { id: WalletId currency: T - accountId?: AccountId // TODO: unify when we migrate accountId to invoices collection -} -type WalletDescriptor = PartialWalletDescriptor & { accountId: AccountId } diff --git a/core/api/src/domain/wallet-invoices/index.types.d.ts b/core/api/src/domain/wallet-invoices/index.types.d.ts index 4ca3558308b..2ee1deacb5d 100644 --- a/core/api/src/domain/wallet-invoices/index.types.d.ts +++ b/core/api/src/domain/wallet-invoices/index.types.d.ts @@ -98,7 +98,7 @@ type WalletInvoiceWithOptionalLnInvoice = { selfGenerated: boolean pubkey: Pubkey usdAmount?: UsdPaymentAmount - recipientWalletDescriptor: PartialWalletDescriptor + recipientWalletDescriptor: WalletDescriptor paid: boolean createdAt: Date processingCompleted: boolean diff --git a/core/api/test/integration/app/wallets/update-pending-invoices.spec.ts b/core/api/test/integration/app/wallets/update-pending-invoices.spec.ts index 0a25e9dee16..0f29fba01ae 100644 --- a/core/api/test/integration/app/wallets/update-pending-invoices.spec.ts +++ b/core/api/test/integration/app/wallets/update-pending-invoices.spec.ts @@ -72,6 +72,7 @@ describe("update pending invoices", () => { recipientWalletDescriptor: { id: randomUUID() as WalletId, currency: WalletCurrency.Usd, + accountId: randomUUID() as AccountId, }, paid: false, lnInvoice: mockLnInvoice, @@ -130,6 +131,7 @@ describe("update pending invoices", () => { recipientWalletDescriptor: { id: randomUUID() as WalletId, currency: WalletCurrency.Btc, + accountId: randomUUID() as AccountId, }, paid: false, lnInvoice: mockLnInvoice, diff --git a/core/api/test/unit/domain/wallet-invoices/wallet-invoice-receiver.spec.ts b/core/api/test/unit/domain/wallet-invoices/wallet-invoice-receiver.spec.ts index f42ef801d90..d9cf22305e5 100644 --- a/core/api/test/unit/domain/wallet-invoices/wallet-invoice-receiver.spec.ts +++ b/core/api/test/unit/domain/wallet-invoices/wallet-invoice-receiver.spec.ts @@ -30,21 +30,15 @@ describe("WalletInvoiceReceiver", () => { const recipientAccountId = "recipientAccountId" as AccountId - const partialRecipientBtcWalletDescriptor = { + const recipientBtcWalletDescriptor = { id: "recipientBtcWalletId" as WalletId, currency: WalletCurrency.Btc, - } - const recipientBtcWalletDescriptor = { - ...partialRecipientBtcWalletDescriptor, accountId: recipientAccountId, } - const partialRecipientUsdWalletDescriptor = { + const recipientUsdWalletDescriptor = { id: "recipientUsdWalletId" as WalletId, currency: WalletCurrency.Usd, - } - const recipientUsdWalletDescriptor = { - ...partialRecipientUsdWalletDescriptor, accountId: recipientAccountId, } @@ -77,7 +71,7 @@ describe("WalletInvoiceReceiver", () => { pubkey: "pubkey" as Pubkey, usdAmount: undefined, paid: false, - recipientWalletDescriptor: partialRecipientBtcWalletDescriptor, + recipientWalletDescriptor: recipientBtcWalletDescriptor, createdAt: new Date(), lnInvoice: mockLnInvoice, processingCompleted: false, @@ -116,7 +110,7 @@ describe("WalletInvoiceReceiver", () => { const amountUsdInvoice: WalletInvoice = { paymentHash: "paymentHash" as PaymentHash, secret: "secret" as SecretPreImage, - recipientWalletDescriptor: partialRecipientUsdWalletDescriptor, + recipientWalletDescriptor: recipientUsdWalletDescriptor, selfGenerated: false, pubkey: "pubkey" as Pubkey, usdAmount: UsdPaymentAmount(BigInt(100)), @@ -153,7 +147,7 @@ describe("WalletInvoiceReceiver", () => { const noAmountUsdInvoice: WalletInvoice = { paymentHash: "paymentHash" as PaymentHash, secret: "secret" as SecretPreImage, - recipientWalletDescriptor: partialRecipientUsdWalletDescriptor, + recipientWalletDescriptor: recipientUsdWalletDescriptor, selfGenerated: false, pubkey: "pubkey" as Pubkey, paid: false, diff --git a/core/api/test/unit/domain/wallet-invoices/wallet-invoice-status-checker.spec.ts b/core/api/test/unit/domain/wallet-invoices/wallet-invoice-status-checker.spec.ts index 04184e677ec..2f615058fad 100644 --- a/core/api/test/unit/domain/wallet-invoices/wallet-invoice-status-checker.spec.ts +++ b/core/api/test/unit/domain/wallet-invoices/wallet-invoice-status-checker.spec.ts @@ -9,7 +9,11 @@ const baseInvoice: WalletInvoice = { secret: "secretPreImage" as SecretPreImage, selfGenerated: true, pubkey: "pubkey" as Pubkey, - recipientWalletDescriptor: { id: "walletId" as WalletId, currency: WalletCurrency.Usd }, + recipientWalletDescriptor: { + id: "walletId" as WalletId, + currency: WalletCurrency.Usd, + accountId: "accountId" as AccountId, + }, paid: false, createdAt: new Date(Date.now()), processingCompleted: false,