Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix filecoin spend saving #618

Merged
merged 3 commits into from
Sep 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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('-'),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should just be true

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do other engines detect sends based on the sign of the number?

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