From 035a9c0e35a9143d05491fa5768c23362a105989 Mon Sep 17 00:00:00 2001 From: Samuel Holmes Date: Fri, 8 Sep 2023 12:46:47 -0700 Subject: [PATCH 1/3] Fix incorrect `isSend` for filecoin and zcash --- src/filecoin/FilecoinEngine.ts | 6 +++--- src/zcash/ZcashEngine.ts | 8 +++++--- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/filecoin/FilecoinEngine.ts b/src/filecoin/FilecoinEngine.ts index 6d228335e..969ecf729 100644 --- a/src/filecoin/FilecoinEngine.ts +++ b/src/filecoin/FilecoinEngine.ts @@ -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, diff --git a/src/zcash/ZcashEngine.ts b/src/zcash/ZcashEngine.ts index 6c36f6986..64f12204f 100644 --- a/src/zcash/ZcashEngine.ts +++ b/src/zcash/ZcashEngine.ts @@ -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, @@ -338,13 +338,15 @@ 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('-'), + nativeAmount: txNativeAmount, // nativeAmount + isSend: true, networkFee: this.networkInfo.defaultNetworkFee, // networkFee ourReceiveAddresses: [], // ourReceiveAddresses signedTx: '', // signedTx From fcc2448b3eb00ee2e3822dcd0c3c37e97d55caf8 Mon Sep 17 00:00:00 2001 From: Samuel Holmes Date: Thu, 7 Sep 2023 12:16:05 -0700 Subject: [PATCH 2/3] Remove redundant comments --- src/zcash/ZcashEngine.ts | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/zcash/ZcashEngine.ts b/src/zcash/ZcashEngine.ts index 64f12204f..ecbae2469 100644 --- a/src/zcash/ZcashEngine.ts +++ b/src/zcash/ZcashEngine.ts @@ -341,15 +341,15 @@ export class ZcashEngine extends CurrencyEngine< const txNativeAmount = mul(totalTxAmount, '-1') const edgeTransaction: EdgeTransaction = { - txid: '', // txid - date: 0, // date - currencyCode, // currencyCode - blockHeight: 0, // blockHeight - nativeAmount: txNativeAmount, // nativeAmount + txid: '', + date: 0, + currencyCode, + blockHeight: 0, + nativeAmount: txNativeAmount, isSend: true, - networkFee: this.networkInfo.defaultNetworkFee, // networkFee - ourReceiveAddresses: [], // ourReceiveAddresses - signedTx: '', // signedTx + networkFee: this.networkInfo.defaultNetworkFee, + ourReceiveAddresses: [], + signedTx: '', spendTargets, walletId: this.walletId } From 4a02b12e74763c7b9d62204c14e2c4f6ef68ec8f Mon Sep 17 00:00:00 2001 From: Samuel Holmes Date: Thu, 7 Sep 2023 12:52:15 -0700 Subject: [PATCH 3/3] Add missing transaction date for Filecoin `signTx` --- src/filecoin/FilecoinEngine.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/filecoin/FilecoinEngine.ts b/src/filecoin/FilecoinEngine.ts index 969ecf729..636ddccc9 100644 --- a/src/filecoin/FilecoinEngine.ts +++ b/src/filecoin/FilecoinEngine.ts @@ -230,6 +230,8 @@ export class FilecoinEngine extends CurrencyEngine< sigJson: signature.toJSON() } + edgeTransaction.date = Date.now() / 1000 + return edgeTransaction }