From 15a676eb2dedafb3a766cf747677f9e028a1a64e Mon Sep 17 00:00:00 2001 From: Paul Puey Date: Sun, 26 Nov 2023 16:32:11 -0800 Subject: [PATCH] Extend saveTxMetadata to save fiatData --- src/core/currency/wallet/currency-wallet-api.ts | 9 ++++++--- src/core/currency/wallet/currency-wallet-files.ts | 8 +++++--- src/types/types.ts | 3 ++- 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/src/core/currency/wallet/currency-wallet-api.ts b/src/core/currency/wallet/currency-wallet-api.ts index 02e6f3dfa..a9caf8651 100644 --- a/src/core/currency/wallet/currency-wallet-api.ts +++ b/src/core/currency/wallet/currency-wallet-api.ts @@ -31,6 +31,7 @@ import { EdgeStakingStatus, EdgeStreamTransactionOptions, EdgeTransaction, + EdgeTxFiat, EdgeWalletInfo } from '../../../types/types' import { mergeDeeply } from '../../../util/util' @@ -552,14 +553,16 @@ export function makeCurrencyWalletApi( async saveTxMetadata( txid: string, currencyCode: string, - metadata: EdgeMetadata + metadata?: EdgeMetadata, + fiatData?: EdgeTxFiat ): Promise { await setCurrencyWalletTxMetadata( input, txid, currencyCode, - packMetadata(metadata, input.props.walletState.fiat), - fakeCallbacks + fakeCallbacks, + packMetadata(metadata ?? {}, input.props.walletState.fiat), + fiatData ) }, async signMessage( diff --git a/src/core/currency/wallet/currency-wallet-files.ts b/src/core/currency/wallet/currency-wallet-files.ts index d0c3f8f72..76fc39fca 100644 --- a/src/core/currency/wallet/currency-wallet-files.ts +++ b/src/core/currency/wallet/currency-wallet-files.ts @@ -3,7 +3,8 @@ import { Disklet, justFiles, navigateDisklet } from 'disklet' import { EdgeCurrencyEngineCallbacks, - EdgeTransaction + EdgeTransaction, + EdgeTxFiat } from '../../../types/types' import { makeJsonFile } from '../../../util/file-helpers' import { mergeDeeply } from '../../../util/util' @@ -384,8 +385,9 @@ export async function setCurrencyWalletTxMetadata( input: CurrencyWalletInput, txid: string, currencyCode: string, + fakeCallbacks: EdgeCurrencyEngineCallbacks, metadata: DiskMetadata, - fakeCallbacks: EdgeCurrencyEngineCallbacks + fiatData?: EdgeTxFiat ): Promise { const { dispatch, state, walletId } = input.props const disklet = getStorageWalletDisklet(state, walletId) @@ -427,7 +429,7 @@ export async function setCurrencyWalletTxMetadata( currencies: {} } newFile.currencies[currencyCode] = { - metadata + metadata: { ...metadata, ...fiatData } } const json = mergeDeeply(oldFile, newFile) diff --git a/src/types/types.ts b/src/types/types.ts index e332f446f..5c44941eb 100644 --- a/src/types/types.ts +++ b/src/types/types.ts @@ -1126,7 +1126,8 @@ export interface EdgeCurrencyWallet { readonly saveTxMetadata: ( txid: string, currencyCode: string, - metadata: EdgeMetadata + metadata?: EdgeMetadata, + fiatData?: EdgeTxFiat ) => Promise readonly signTx: (tx: EdgeTransaction) => Promise readonly sweepPrivateKeys: (