Merge pull request #1431 from josepfo/fix/mock-scoring-flag
Fix: mock scoring flag
This commit is contained in:
commit
d0b57cfded
7 changed files with 80 additions and 38 deletions
|
|
@ -179,6 +179,9 @@ function doesTxReuseAddress (tx) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function getWalletScore (tx, pi) {
|
function getWalletScore (tx, pi) {
|
||||||
|
pi.isWalletScoringEnabled(tx)
|
||||||
|
.then(isEnabled => {
|
||||||
|
if(!isEnabled) return null
|
||||||
if (!tx.fiat || tx.fiat.isZero()) {
|
if (!tx.fiat || tx.fiat.isZero()) {
|
||||||
return pi.rateWallet(tx.cryptoCode, tx.toAddress)
|
return pi.rateWallet(tx.cryptoCode, tx.toAddress)
|
||||||
}
|
}
|
||||||
|
|
@ -189,6 +192,7 @@ function getWalletScore (tx, pi) {
|
||||||
score: tx.walletScore,
|
score: tx.walletScore,
|
||||||
isValid
|
isValid
|
||||||
}))
|
}))
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
function monitorPending (settings) {
|
function monitorPending (settings) {
|
||||||
|
|
|
||||||
|
|
@ -122,6 +122,9 @@ function getWalletScore (tx, pi) {
|
||||||
return tx
|
return tx
|
||||||
|
|
||||||
// Transaction shows up on the blockchain, we can request the sender address
|
// Transaction shows up on the blockchain, we can request the sender address
|
||||||
|
return pi.isWalletScoringEnabled(tx)
|
||||||
|
.then(isEnabled => {
|
||||||
|
if (!isEnabled) return tx
|
||||||
return pi.getTransactionHash(tx)
|
return pi.getTransactionHash(tx)
|
||||||
.then(rejectEmpty("No transaction hashes"))
|
.then(rejectEmpty("No transaction hashes"))
|
||||||
.then(txHashes => pi.getInputAddresses(tx, txHashes))
|
.then(txHashes => pi.getInputAddresses(tx, txHashes))
|
||||||
|
|
@ -146,6 +149,7 @@ function getWalletScore (tx, pi) {
|
||||||
errorCode: 'ciphertraceError',
|
errorCode: 'ciphertraceError',
|
||||||
dispense: true
|
dispense: true
|
||||||
}))
|
}))
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
function monitorLiveIncoming (settings) {
|
function monitorLiveIncoming (settings) {
|
||||||
|
|
|
||||||
|
|
@ -850,6 +850,10 @@ function plugins (settings, deviceId) {
|
||||||
return walletScoring.getInputAddresses(settings, tx.cryptoCode, txHashes)
|
return walletScoring.getInputAddresses(settings, tx.cryptoCode, txHashes)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function isWalletScoringEnabled (tx) {
|
||||||
|
return walletScoring.isWalletScoringEnabled(settings, tx.cryptoCode)
|
||||||
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
getRates,
|
getRates,
|
||||||
recordPing,
|
recordPing,
|
||||||
|
|
@ -882,7 +886,8 @@ function plugins (settings, deviceId) {
|
||||||
rateWallet,
|
rateWallet,
|
||||||
isValidWalletScore,
|
isValidWalletScore,
|
||||||
getTransactionHash,
|
getTransactionHash,
|
||||||
getInputAddresses
|
getInputAddresses,
|
||||||
|
isWalletScoringEnabled
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -126,10 +126,19 @@ function getInputAddresses (account, cryptoCode, txHashes) {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function isWalletScoringEnabled (account, cryptoCode) {
|
||||||
|
if (!SUPPORTED_COINS.includes(cryptoCode)) {
|
||||||
|
return Promise.reject(new Error('Unsupported crypto: ' + cryptoCode))
|
||||||
|
}
|
||||||
|
|
||||||
|
return Promise.resolve(!_.isNil(account) && account.enabled)
|
||||||
|
}
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
NAME,
|
NAME,
|
||||||
rateWallet,
|
rateWallet,
|
||||||
isValidWalletScore,
|
isValidWalletScore,
|
||||||
getTransactionHash,
|
getTransactionHash,
|
||||||
getInputAddresses
|
getInputAddresses,
|
||||||
|
isWalletScoringEnabled
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -36,10 +36,20 @@ function getInputAddresses (account, cryptoCode, txHashes) {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function isWalletScoringEnabled (account, cryptoCode) {
|
||||||
|
return new Promise((resolve, _) => {
|
||||||
|
setTimeout(() => {
|
||||||
|
return resolve(true)
|
||||||
|
}, 100)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
NAME,
|
NAME,
|
||||||
rateWallet,
|
rateWallet,
|
||||||
isValidWalletScore,
|
isValidWalletScore,
|
||||||
getTransactionHash,
|
getTransactionHash,
|
||||||
getInputAddresses
|
getInputAddresses,
|
||||||
|
isWalletScoringEnabled
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -47,9 +47,19 @@ function getInputAddresses (settings, cryptoCode, txHashes) {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function isWalletScoringEnabled (settings, cryptoCode) {
|
||||||
|
return Promise.resolve()
|
||||||
|
.then(() => {
|
||||||
|
const { plugin, account } = loadWalletScoring(settings)
|
||||||
|
|
||||||
|
return plugin.isWalletScoringEnabled(account, cryptoCode)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
rateWallet,
|
rateWallet,
|
||||||
isValidWalletScore,
|
isValidWalletScore,
|
||||||
getTransactionHash,
|
getTransactionHash,
|
||||||
getInputAddresses
|
getInputAddresses,
|
||||||
|
isWalletScoringEnabled
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -123,7 +123,7 @@
|
||||||
"test": "mocha --recursive tests",
|
"test": "mocha --recursive tests",
|
||||||
"jtest": "jest --detectOpenHandles",
|
"jtest": "jest --detectOpenHandles",
|
||||||
"build-admin": "npm run build-admin:css && npm run build-admin:main && npm run build-admin:lamassu",
|
"build-admin": "npm run build-admin:css && npm run build-admin:main && npm run build-admin:lamassu",
|
||||||
"server": "nodemon bin/lamassu-server --mockSms --logLevel silly",
|
"server": "nodemon bin/lamassu-server --mockSms --mockScoring --logLevel silly",
|
||||||
"admin-server": "nodemon bin/lamassu-admin-server --dev --logLevel silly",
|
"admin-server": "nodemon bin/lamassu-admin-server --dev --logLevel silly",
|
||||||
"graphql-server": "nodemon bin/new-graphql-dev-insecure",
|
"graphql-server": "nodemon bin/new-graphql-dev-insecure",
|
||||||
"watch": "concurrently \"npm:server\" \"npm:admin-server\" \"npm:graphql-server\"",
|
"watch": "concurrently \"npm:server\" \"npm:admin-server\" \"npm:graphql-server\"",
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue