Skip to content

Commit

Permalink
Extend saveTxMetadata to save fiatData
Browse files Browse the repository at this point in the history
  • Loading branch information
paullinator committed Nov 27, 2023
1 parent 691c40d commit 15a676e
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 7 deletions.
9 changes: 6 additions & 3 deletions src/core/currency/wallet/currency-wallet-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import {
EdgeStakingStatus,
EdgeStreamTransactionOptions,
EdgeTransaction,
EdgeTxFiat,
EdgeWalletInfo
} from '../../../types/types'
import { mergeDeeply } from '../../../util/util'
Expand Down Expand Up @@ -552,14 +553,16 @@ export function makeCurrencyWalletApi(
async saveTxMetadata(
txid: string,
currencyCode: string,
metadata: EdgeMetadata
metadata?: EdgeMetadata,
fiatData?: EdgeTxFiat
): Promise<void> {
await setCurrencyWalletTxMetadata(
input,
txid,
currencyCode,
packMetadata(metadata, input.props.walletState.fiat),
fakeCallbacks
fakeCallbacks,
packMetadata(metadata ?? {}, input.props.walletState.fiat),
fiatData
)
},
async signMessage(
Expand Down
8 changes: 5 additions & 3 deletions src/core/currency/wallet/currency-wallet-files.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -384,8 +385,9 @@ export async function setCurrencyWalletTxMetadata(
input: CurrencyWalletInput,
txid: string,
currencyCode: string,
fakeCallbacks: EdgeCurrencyEngineCallbacks,
metadata: DiskMetadata,
fakeCallbacks: EdgeCurrencyEngineCallbacks
fiatData?: EdgeTxFiat
): Promise<void> {
const { dispatch, state, walletId } = input.props
const disklet = getStorageWalletDisklet(state, walletId)
Expand Down Expand Up @@ -427,7 +429,7 @@ export async function setCurrencyWalletTxMetadata(
currencies: {}
}
newFile.currencies[currencyCode] = {
metadata
metadata: { ...metadata, ...fiatData }
}
const json = mergeDeeply(oldFile, newFile)

Expand Down
3 changes: 2 additions & 1 deletion src/types/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1126,7 +1126,8 @@ export interface EdgeCurrencyWallet {
readonly saveTxMetadata: (
txid: string,
currencyCode: string,
metadata: EdgeMetadata
metadata?: EdgeMetadata,
fiatData?: EdgeTxFiat
) => Promise<void>
readonly signTx: (tx: EdgeTransaction) => Promise<EdgeTransaction>
readonly sweepPrivateKeys: (
Expand Down

0 comments on commit 15a676e

Please sign in to comment.