From 10833c014a95e9b993514674509d22fa03858dfd Mon Sep 17 00:00:00 2001 From: josepfo Date: Wed, 7 Dec 2022 15:21:28 +0000 Subject: [PATCH 1/3] fix: deprecate cashInFeeCrypto --- lib/cash-in/cash-in-low.js | 4 ++-- lib/new-admin/graphql/types/transaction.type.js | 1 - lib/notifier/test/notifier.test.js | 1 - lib/tx-batching.js | 2 +- lib/tx.js | 1 - .../1670425142650-deprecate-cash-in-fee-crypto.js | 13 +++++++++++++ 6 files changed, 16 insertions(+), 6 deletions(-) create mode 100644 migrations/1670425142650-deprecate-cash-in-fee-crypto.js diff --git a/lib/cash-in/cash-in-low.js b/lib/cash-in/cash-in-low.js index 804e569aa8..d1b115214f 100644 --- a/lib/cash-in/cash-in-low.js +++ b/lib/cash-in/cash-in-low.js @@ -35,7 +35,7 @@ function toObj (row) { keys.forEach(key => { const objKey = _.camelCase(key) - if (_.includes(key, ['crypto_atoms', 'fiat', 'cash_in_fee', 'cash_in_fee_crypto', 'commission_percentage', 'raw_ticker_price'])) { + if (_.includes(key, ['crypto_atoms', 'fiat', 'cash_in_fee', 'commission_percentage', 'raw_ticker_price'])) { newObj[objKey] = new BN(row[key]) return } @@ -102,7 +102,7 @@ function diff (oldTx, newTx) { } function ensureRatchet (oldField, newField, fieldKey) { - const monotonic = ['cryptoAtoms', 'fiat', 'cashInFeeCrypto', 'send', 'sendConfirmed', 'operatorCompleted', 'timedout', 'txVersion', 'batched'] + const monotonic = ['cryptoAtoms', 'fiat', 'send', 'sendConfirmed', 'operatorCompleted', 'timedout', 'txVersion', 'batched'] const free = ['sendPending', 'error', 'errorCode', 'customerId'] if (_.isNil(oldField)) return true diff --git a/lib/new-admin/graphql/types/transaction.type.js b/lib/new-admin/graphql/types/transaction.type.js index 2d95d751bc..b66e88cc0e 100644 --- a/lib/new-admin/graphql/types/transaction.type.js +++ b/lib/new-admin/graphql/types/transaction.type.js @@ -24,7 +24,6 @@ const typeDef = gql` operatorCompleted: Boolean sendPending: Boolean cashInFee: String - cashInFeeCrypto: String minimumTx: Float customerId: ID isAnonymous: Boolean diff --git a/lib/notifier/test/notifier.test.js b/lib/notifier/test/notifier.test.js index d29c4996b5..f49c109850 100644 --- a/lib/notifier/test/notifier.test.js +++ b/lib/notifier/test/notifier.test.js @@ -64,7 +64,6 @@ const tx = { operatorCompleted: false, sendPending: true, cashInFee: new BN(2), - cashInFeeCrypto: new BN(9500), minimumTx: 5, customerId: '47ac1184-8102-11e7-9079-8f13a7117867', txVersion: 6, diff --git a/lib/tx-batching.js b/lib/tx-batching.js index b395c791b9..2b7e793e66 100644 --- a/lib/tx-batching.js +++ b/lib/tx-batching.js @@ -65,7 +65,7 @@ function getOpenBatchCryptoValue (cryptoCode) { if (_.isNil(batch)) return Promise.resolve([]) return db.any(`SELECT * FROM cash_in_txs WHERE batch_id=$1`, [batch.id]) }) - .then(txs => _.reduce((acc, tx) => acc.plus(tx.cash_in_fee_crypto).plus(tx.crypto_atoms), BN(0), txs)) + .then(txs => _.reduce((acc, tx) => acc.plus(tx.crypto_atoms), BN(0), txs)) } module.exports = { diff --git a/lib/tx.js b/lib/tx.js index 6279077dd5..ab07e0c0ea 100644 --- a/lib/tx.js +++ b/lib/tx.js @@ -33,7 +33,6 @@ function massage (tx, pi) { cryptoAtoms: new BN(r.cryptoAtoms), fiat: new BN(r.fiat), cashInFee: new BN(r.cashInFee), - cashInFeeCrypto: new BN(r.cashInFeeCrypto), commissionPercentage: new BN(r.commissionPercentage), rawTickerPrice: r.rawTickerPrice ? new BN(r.rawTickerPrice) : null, minimumTx: new BN(r.minimumTx) diff --git a/migrations/1670425142650-deprecate-cash-in-fee-crypto.js b/migrations/1670425142650-deprecate-cash-in-fee-crypto.js new file mode 100644 index 0000000000..1e18d4501a --- /dev/null +++ b/migrations/1670425142650-deprecate-cash-in-fee-crypto.js @@ -0,0 +1,13 @@ +const db = require('./db') + +exports.up = function (next) { + var sql = [ + 'ALTER TABLE cash_in_txs DROP COLUMN cash_in_fee_crypto' + ] + + db.multi(sql, next) +} + +exports.down = function (next) { + next() +} From 9f03292951be4ffbee646055fb21b93fe5a6969f Mon Sep 17 00:00:00 2001 From: siiky Date: Wed, 14 Dec 2022 14:02:16 +0000 Subject: [PATCH 2/3] fix: remove `cashInFeeCrypto` from machine-cached transactions --- lib/cash-in/cash-in-low.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/cash-in/cash-in-low.js b/lib/cash-in/cash-in-low.js index d1b115214f..5b8066a010 100644 --- a/lib/cash-in/cash-in-low.js +++ b/lib/cash-in/cash-in-low.js @@ -8,7 +8,7 @@ const E = require('../error') const PENDING_INTERVAL_MS = 60 * T.minutes -const massageFields = ['direction', 'cryptoNetwork', 'bills', 'blacklisted', 'addressReuse', 'promoCodeApplied', 'validWalletScore'] +const massageFields = ['direction', 'cryptoNetwork', 'bills', 'blacklisted', 'addressReuse', 'promoCodeApplied', 'validWalletScore', 'cashInFeeCrypto'] const massageUpdateFields = _.concat(massageFields, 'cryptoAtoms') const massage = _.flow(_.omit(massageFields), From 5852c964f48be6106067514e05d31f5346823e9b Mon Sep 17 00:00:00 2001 From: Neal Date: Fri, 6 Jan 2023 14:35:35 -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 e9249e2d92..f2f3fc764b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "lamassu-server", - "version": "8.0.5", + "version": "8.0.6", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index 2667855f1a..385c08ca75 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "lamassu-server", "description": "bitcoin atm client server protocol module", "keywords": [], - "version": "8.0.5", + "version": "8.0.6", "license": "Unlicense", "author": "Lamassu (https://lamassu.is)", "dependencies": {