From 0528daa775738787f015d6ee9333737efe9c7fcb Mon Sep 17 00:00:00 2001 From: Philipp Walter Date: Thu, 7 Mar 2024 11:04:56 +0100 Subject: [PATCH] fix(lightning): remove temp hacks to sync ln activity --- src/store/types/activity.ts | 5 +---- src/store/utils/lightning.ts | 30 ++---------------------------- 2 files changed, 3 insertions(+), 32 deletions(-) diff --git a/src/store/types/activity.ts b/src/store/types/activity.ts index 7bf60301f..66b0ba7c6 100644 --- a/src/store/types/activity.ts +++ b/src/store/types/activity.ts @@ -1,9 +1,6 @@ -// import { TPaymentState } from '@synonymdev/react-native-ldk'; +import { TPaymentState } from '@synonymdev/react-native-ldk'; import { EPaymentType } from 'beignet'; -// TODO: update react-native-ldk and remove -type TPaymentState = 'pending' | 'successful' | 'failed'; - export enum EActivityType { onchain = 'onchain', lightning = 'lightning', diff --git a/src/store/utils/lightning.ts b/src/store/utils/lightning.ts index bf51d8298..18df7d8f6 100644 --- a/src/store/utils/lightning.ts +++ b/src/store/utils/lightning.ts @@ -2,6 +2,7 @@ import { LNURLChannelParams } from 'js-lnurl'; import { err, ok, Result } from '@synonymdev/result'; import { ldk, TChannel, TInvoice } from '@synonymdev/react-native-ldk'; import { getLNURLParams, lnurlChannel } from '@synonymdev/react-native-lnurl'; +import { EPaymentType } from 'beignet'; import { dispatch, getLightningStore, getMetaDataStore } from '../helpers'; import { updateActivityItems } from '../slices/activity'; @@ -17,12 +18,10 @@ import { import { moveMetaIncTxTag } from '../slices/metadata'; import { updateTransfer } from '../actions/wallet'; import { EAvailableNetwork } from '../../utils/networks'; -import { getActivityItemById } from '../../utils/activity'; import { getSelectedNetwork, getSelectedWallet } from '../../utils/wallet'; import { addPeers, createPaymentRequest, - decodeLightningInvoice, getClaimableBalances, getClaimedLightningPayments, getCustomLightningPeers, @@ -38,7 +37,6 @@ import { } from '../types/lightning'; import { ETransferType, TWalletName } from '../types/wallet'; import { EActivityType, TLightningActivityItem } from '../types/activity'; -import { EPaymentType } from 'beignet'; /** * Attempts to update the node id for the selected wallet and network. @@ -335,24 +333,12 @@ export const syncLightningTxsWithActivityList = async (): Promise< continue; } - // Decode invoice to get description - // TODO: Persist description in react-native-ldk so we don't have to decode here - let invoiceNote = ''; - if (payment.bolt11_invoice) { - const decodeInvoiceResponse = await decodeLightningInvoice({ - paymentRequest: payment.bolt11_invoice, - }); - if (decodeInvoiceResponse.isOk()) { - invoiceNote = decodeInvoiceResponse.value.description ?? ''; - } - } - items.push({ id: payment.payment_hash, activityType: EActivityType.lightning, txType: EPaymentType.sent, status: payment.state, - message: invoiceNote, + message: payment.description ?? '', address: payment.bolt11_invoice ?? '', confirmed: payment.state === 'successful', value: payment.amount_sat, @@ -361,18 +347,6 @@ export const syncLightningTxsWithActivityList = async (): Promise< }); } - // TODO: remove temp hack when this is complete and descriptions/bolt11 can be added from stored tx: https://github.com/synonymdev/react-native-ldk/issues/156 - items.forEach((item) => { - const res = getActivityItemById(item.id); - if (res.isOk()) { - const existingItem = res.value; - if (existingItem.activityType === EActivityType.lightning) { - item.message = existingItem.message; - item.address = existingItem.address; - } - } - }); - dispatch(updateActivityItems(items)); return ok('Stored lightning transactions synced with activity list.');