Skip to content

Commit

Permalink
Better propagate EdgeTransaction.feeRateUsed
Browse files Browse the repository at this point in the history
If we don't have this saved on disk, let the engine's one pass through.
  • Loading branch information
swansontec committed May 21, 2024
1 parent b0524e6 commit 57fb310
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 8 deletions.
5 changes: 4 additions & 1 deletion src/core/currency/wallet/currency-wallet-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -677,6 +677,7 @@ export function combineTxWithFile(
blockHeight: tx.blockHeight,
confirmations: tx.confirmations,
currencyCode,
feeRateUsed: tx.feeRateUsed,
date: tx.date,
isSend: tx.isSend,
memos: tx.memos,
Expand Down Expand Up @@ -713,7 +714,9 @@ export function combineTxWithFile(
out.requestedCustomFee = file.feeRateRequested
}
}
out.feeRateUsed = file.feeRateUsed
if (out.feeRateUsed == null) {
out.feeRateUsed = file.feeRateUsed
}

if (file.payees != null) {
out.spendTargets = file.payees.map(payee => ({
Expand Down
20 changes: 14 additions & 6 deletions src/core/currency/wallet/currency-wallet-reducer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,19 +43,20 @@ export interface TxidHashes {
}

export interface MergedTransaction {
blockHeight: number
chainAction?: EdgeTxAction
chainAssetAction: Map<EdgeTokenId, EdgeAssetAction>
blockHeight: number
confirmations: EdgeTransaction['confirmations']
date: number
feeRateUsed?: object
isSend: boolean
memos: EdgeMemo[]
nativeAmount: EdgeBalanceMap
networkFee: EdgeBalanceMap
otherParams?: object
ourReceiveAddresses: string[]
signedTx: string
txid: string
nativeAmount: EdgeBalanceMap
networkFee: EdgeBalanceMap
}

export interface CurrencyWalletState {
Expand Down Expand Up @@ -432,13 +433,17 @@ export function mergeTx(
tx: EdgeTransaction,
oldTx: MergedTransaction | undefined
): MergedTransaction {
const { isSend = lt(tx.nativeAmount, '0'), tokenId = null } = tx
const {
confirmations = 'unconfirmed',
isSend = lt(tx.nativeAmount, '0'),
tokenId = null
} = tx

const out: MergedTransaction = {
chainAssetAction: new Map(oldTx?.chainAssetAction ?? []),
blockHeight: tx.blockHeight,
chainAction: tx.chainAction,
confirmations: tx.confirmations ?? 'unconfirmed',
chainAssetAction: new Map(oldTx?.chainAssetAction ?? []),
confirmations,
date: tx.date,
isSend,
memos: tx.memos,
Expand All @@ -451,6 +456,9 @@ export function mergeTx(
}
out.nativeAmount.set(tokenId, tx.nativeAmount)
out.networkFee.set(tokenId, tx.networkFee ?? '0')
if (tx.feeRateUsed != null) {
out.feeRateUsed = tx.feeRateUsed
}
if (tx.parentNetworkFee != null) {
out.networkFee.set(null, String(tx.parentNetworkFee))
}
Expand Down
4 changes: 3 additions & 1 deletion src/types/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -598,11 +598,13 @@ export interface EdgeTransaction {
/** App-provided action data for all assets in a transaction */
savedAction?: EdgeTxAction

/** This has the same format as the `customNetworkFee` */
feeRateUsed?: JsonObject

// Spend-specific metadata:
deviceDescription?: string
networkFeeOption?: 'high' | 'standard' | 'low' | 'custom'
requestedCustomFee?: JsonObject
feeRateUsed?: JsonObject
spendTargets?: Array<{
readonly currencyCode: string // Saved for future reference
readonly nativeAmount: string
Expand Down

0 comments on commit 57fb310

Please sign in to comment.