Skip to content

Commit

Permalink
Merge pull request #618 from EdgeApp/sam/filecoin-saved-sends
Browse files Browse the repository at this point in the history
- fixed: Bug prevent Filecoin spend trasactions from being saved in the wallet (by saveTx)
  • Loading branch information
samholmes authored Sep 8, 2023
2 parents 2240ac2 + 4a02b12 commit 9351e32
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 13 deletions.
8 changes: 5 additions & 3 deletions src/filecoin/FilecoinEngine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -189,15 +189,15 @@ export class FilecoinEngine extends CurrencyEngine<
}

const networkFee = mul(txJson.GasLimit.toString(), txJson.GasPremium) // TODO: Include base fee and burn fee somehow?
const totalTxAmount = add(nativeAmount, networkFee)
const txNativeAmount = mul(add(nativeAmount, networkFee), '-1')

const edgeTransaction: EdgeTransaction = {
txid: '',
date: 0,
currencyCode,
blockHeight: 0,
nativeAmount: `-${totalTxAmount}`,
isSend: nativeAmount.startsWith('-'),
nativeAmount: txNativeAmount,
isSend: true,
networkFee,
ourReceiveAddresses: [],
otherParams,
Expand Down Expand Up @@ -230,6 +230,8 @@ export class FilecoinEngine extends CurrencyEngine<
sigJson: signature.toJSON()
}

edgeTransaction.date = Date.now() / 1000

return edgeTransaction
}

Expand Down
22 changes: 12 additions & 10 deletions src/zcash/ZcashEngine.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { abs, add, eq, gt, lte, sub } from 'biggystring'
import { abs, add, eq, gt, lte, mul, sub } from 'biggystring'
import {
EdgeCurrencyEngine,
EdgeCurrencyEngineOptions,
Expand Down Expand Up @@ -338,16 +338,18 @@ export class ZcashEngine extends CurrencyEngine<
publicAddress
}))

const txNativeAmount = mul(totalTxAmount, '-1')

const edgeTransaction: EdgeTransaction = {
txid: '', // txid
date: 0, // date
currencyCode, // currencyCode
blockHeight: 0, // blockHeight
nativeAmount: `-${totalTxAmount}`, // nativeAmount
isSend: nativeAmount.startsWith('-'),
networkFee: this.networkInfo.defaultNetworkFee, // networkFee
ourReceiveAddresses: [], // ourReceiveAddresses
signedTx: '', // signedTx
txid: '',
date: 0,
currencyCode,
blockHeight: 0,
nativeAmount: txNativeAmount,
isSend: true,
networkFee: this.networkInfo.defaultNetworkFee,
ourReceiveAddresses: [],
signedTx: '',
spendTargets,
walletId: this.walletId
}
Expand Down

0 comments on commit 9351e32

Please sign in to comment.