From 9e4bc2d34beeb5e1fccd6041d1ca1aa9f4777bc5 Mon Sep 17 00:00:00 2001 From: josepfo Date: Wed, 7 Dec 2022 15:28:10 +0000 Subject: [PATCH 1/3] fix: deprecate cashInFeeCrypto --- lib/tx.js | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/lib/tx.js b/lib/tx.js index 22b10ddd9..584291fba 100644 --- a/lib/tx.js +++ b/lib/tx.js @@ -23,15 +23,13 @@ function mergeTx (oldTx, updateTx) { const bills = _.unionBy(_.get('id'), oldTx.bills, updateTx.bills) const cryptoCode = oldTx.cryptoCode const mergedTx = _.defaults(oldTx, updateTx) - const cashInFee = mergedTx.cashInFee ? BN(mergedTx.cashInFee) : BN(0) const cashInNewFields = () => ({ bills, fiat: updateTx.fiat ? oldTx.fiat.add(updateTx.fiat) : oldTx.fiat, cryptoAtoms: truncateCrypto( _.reduce((acc, v) => acc.add(toCrypto(mergedTx, BN(v.fiat).minus(v.cashInFee))), BN(0), bills), - cryptoCode), - cashInFeeCrypto: truncateCrypto(toCrypto(mergedTx, cashInFee), cryptoCode) + cryptoCode) }) const cashOutNewFields = () => ({ @@ -172,9 +170,7 @@ function createBillDeprecated (bill, exchangeRate, tx) { const atomRate = exchangeRate.div(unitScaleFactor) const fiatCode = tx.fiatCode const cashInFee = applyCashInFee ? tx.cashInFee : BN(0) - const cashInFeeCrypto = truncateCrypto(cashInFee.div(atomRate), cryptoCode) const cryptoAtoms = truncateCrypto(BN(bill).div(atomRate), cryptoCode) - const cryptoAtomsAfterFee = truncateCrypto(cryptoAtoms.sub(cashInFeeCrypto), cryptoCode) const deviceTime = Date.now() return { @@ -182,10 +178,8 @@ function createBillDeprecated (bill, exchangeRate, tx) { fiat: BN(bill), fiatCode, cryptoAtoms, - cryptoAtomsAfterFee, cryptoCode, cashInFee, - cashInFeeCrypto, cashInTxsId: tx.id, deviceTime } From 52fa0cb2346c0734d4506775cb7bbe9183d3ad09 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Oliveira?= Date: Fri, 9 Dec 2022 15:58:00 +0000 Subject: [PATCH 2/3] fix: add backwards compatibility for cashInFeeCrypto --- lib/tx.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/tx.js b/lib/tx.js index 584291fba..5c68d20cf 100644 --- a/lib/tx.js +++ b/lib/tx.js @@ -23,13 +23,17 @@ function mergeTx (oldTx, updateTx) { const bills = _.unionBy(_.get('id'), oldTx.bills, updateTx.bills) const cryptoCode = oldTx.cryptoCode const mergedTx = _.defaults(oldTx, updateTx) + // BACKWARDS_COMPATIBILITY 8.1 + // servers before 8.1 expect a cashInFeeCrypto field + const cashInFeeCrypto = BN(0) const cashInNewFields = () => ({ bills, fiat: updateTx.fiat ? oldTx.fiat.add(updateTx.fiat) : oldTx.fiat, cryptoAtoms: truncateCrypto( _.reduce((acc, v) => acc.add(toCrypto(mergedTx, BN(v.fiat).minus(v.cashInFee))), BN(0), bills), - cryptoCode) + cryptoCode), + cashInFeeCrypto: cashInFeeCrypto }) const cashOutNewFields = () => ({ From a8a2a68470379f568b73d26e44bc199a9419c0e3 Mon Sep 17 00:00:00 2001 From: Neal Date: Fri, 6 Jan 2023 14:40:42 -0500 Subject: [PATCH 3/3] chore: version 8.0.6 --- package-lock.json | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/package-lock.json b/package-lock.json index 76e00c3dd..587fbb165 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "lamassu-machine", - "version": "8.0.4", + "version": "8.0.6", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index d4e902471..1b292b020 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "lamassu-machine", "license": "Unlicense", - "version": "8.0.4", + "version": "8.0.6", "dependencies": { "@fczbkk/uuid4": "^3.0.0", "@lamassu/coins": "1.2.0",