Skip to content

Commit

Permalink
refactor(core): remove PartialWalletDescriptor type
Browse files Browse the repository at this point in the history
  • Loading branch information
vindard committed Apr 26, 2024
1 parent bef65c6 commit 317d6eb
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 17 deletions.
5 changes: 1 addition & 4 deletions core/api/src/domain/shared/index.types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,9 @@ type BalanceAmount<T extends WalletCurrency> = Amount<T> & {
readonly brand?: unique symbol
}

type PartialWalletDescriptor<T extends WalletCurrency> = {
type WalletDescriptor<T extends WalletCurrency> = {
id: WalletId
currency: T
accountId?: AccountId // TODO: unify when we migrate accountId to invoices collection
}
type WalletDescriptor<T extends WalletCurrency> = PartialWalletDescriptor<T> & {
accountId: AccountId
}

Expand Down
2 changes: 1 addition & 1 deletion core/api/src/domain/wallet-invoices/index.types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ type WalletInvoiceWithOptionalLnInvoice = {
selfGenerated: boolean
pubkey: Pubkey
usdAmount?: UsdPaymentAmount
recipientWalletDescriptor: PartialWalletDescriptor<WalletCurrency>
recipientWalletDescriptor: WalletDescriptor<WalletCurrency>
paid: boolean
createdAt: Date
processingCompleted: boolean
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ describe("update pending invoices", () => {
recipientWalletDescriptor: {
id: randomUUID() as WalletId,
currency: WalletCurrency.Usd,
accountId: randomUUID() as AccountId,
},
paid: false,
lnInvoice: mockLnInvoice,
Expand Down Expand Up @@ -130,6 +131,7 @@ describe("update pending invoices", () => {
recipientWalletDescriptor: {
id: randomUUID() as WalletId,
currency: WalletCurrency.Btc,
accountId: randomUUID() as AccountId,
},
paid: false,
lnInvoice: mockLnInvoice,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}

Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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)),
Expand Down Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 317d6eb

Please sign in to comment.