fix: clean up code
This commit is contained in:
parent
677cb39f0c
commit
01303d6454
4 changed files with 13 additions and 22 deletions
|
|
@ -40,28 +40,31 @@ function post (machineTx, pi) {
|
|||
|
||||
const isFirstPost = !r.tx.fiat || r.tx.fiat.isZero()
|
||||
if (isFirstPost) {
|
||||
promises.push(checkForBlacklisted(updatedTx), doesTxReuseAddress(updatedTx), getWalletScore(updatedTx, pi))
|
||||
promises.push(
|
||||
checkForBlacklisted(updatedTx),
|
||||
doesTxReuseAddress(updatedTx),
|
||||
getWalletScore(updatedTx, pi)
|
||||
)
|
||||
}
|
||||
|
||||
return Promise.all(promises)
|
||||
.then(([config, blacklistItems = false, isReusedAddress = false, fetchedWalletScore = null]) => {
|
||||
.then(([config, isBlacklisted = false, isReusedAddress = false, fetchedWalletScore = null]) => {
|
||||
const rejectAddressReuse = configManager.getCompliance(config).rejectAddressReuse
|
||||
|
||||
walletScore = fetchedWalletScore
|
||||
|
||||
if (_.some(it => it.address === updatedTx.toAddress)(blacklistItems)) {
|
||||
blacklisted = _.find(it => it.address === updatedTx.toAddress)(blacklistItems)
|
||||
if (isBlacklisted) {
|
||||
notifier.notifyIfActive('compliance', 'blacklistNotify', r.tx, false)
|
||||
} else if (isReusedAddress && rejectAddressReuse) {
|
||||
notifier.notifyIfActive('compliance', 'blacklistNotify', r.tx, true)
|
||||
addressReuse = true
|
||||
}
|
||||
return postProcess(r, pi, blacklisted, addressReuse, walletScore)
|
||||
return postProcess(r, pi, isBlacklisted, addressReuse, walletScore)
|
||||
})
|
||||
.then(changes => _.set('walletScore', _.isNil(walletScore) ? null : walletScore.score, changes))
|
||||
.then(changes => cashInLow.update(db, updatedTx, changes))
|
||||
.then(tx => _.set('bills', machineTx.bills, tx))
|
||||
.then(tx => _.set('blacklisted', Boolean(blacklisted), tx))
|
||||
.then(tx => _.set('blacklisted', isBlacklisted, tx))
|
||||
.then(tx => _.set('blacklistMessage', blacklisted?.content, tx))
|
||||
.then(tx => _.set('addressReuse', addressReuse, tx))
|
||||
.then(tx => _.set('validWalletScore', _.isNil(walletScore) ? true : walletScore.isValid, tx))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue