From 938f52ddd584541df2d38830fab68192571ba3ac Mon Sep 17 00:00:00 2001 From: okjodom Date: Mon, 2 Dec 2024 07:24:25 +0300 Subject: [PATCH] fix: transaction status --- apps/solowallet/src/db/solowallet.schema.ts | 6 +++--- apps/solowallet/src/solowallet.service.ts | 9 ++++++++- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/apps/solowallet/src/db/solowallet.schema.ts b/apps/solowallet/src/db/solowallet.schema.ts index e069742..8a5f120 100644 --- a/apps/solowallet/src/db/solowallet.schema.ts +++ b/apps/solowallet/src/db/solowallet.schema.ts @@ -9,13 +9,13 @@ export class SolowalletDocument extends AbstractDocument { @Prop({ type: Number, required: true }) amountMsats: number; - @Prop({ type: Number, required: true }) - amountFiat: number; + @Prop({ type: Number, required: false }) + amountFiat?: number; @Prop({ type: String, - enum: Object.values(TransactionStatus), required: true, + enum: Object.values(TransactionStatus), }) status: TransactionStatus; diff --git a/apps/solowallet/src/solowallet.service.ts b/apps/solowallet/src/solowallet.service.ts index c49ae75..2716cf0 100644 --- a/apps/solowallet/src/solowallet.service.ts +++ b/apps/solowallet/src/solowallet.service.ts @@ -167,12 +167,19 @@ export class SolowalletService { }; } + let status = TransactionStatus.UNRECOGNIZED; + try { + status = Number(deposit.status) as TransactionStatus; + } catch (error) { + this.logger.warn('Error parsing deposit status', error); + } + return { ...deposit, + status, lightning, paymentTracker: lightning.operationId, id: deposit._id, - status: deposit.status, createdAt: deposit.createdAt.toDateString(), updatedAt: deposit.updatedAt.toDateString(), };