Merge pull request #1279 from josepfo/chore/update-ciphertrace-logs

chore: replace console.log with logger
This commit is contained in:
Rafael Taranto 2022-11-18 11:19:05 +01:00 committed by GitHub
commit 69372236ec

View file

@ -28,18 +28,18 @@ function rateWallet (account, cryptoCode, address) {
const { apiVersion, authHeader } = client
const threshold = account.scoreThreshold
console.log(`** DEBUG ** rateWallet ENDPOINT: https://rest.ciphertrace.com/aml/${apiVersion}/${_.toLower(cryptoCode)}/risk?address=${address}`)
logger.info(`** DEBUG ** rateWallet ENDPOINT: https://rest.ciphertrace.com/aml/${apiVersion}/${_.toLower(cryptoCode)}/risk?address=${address}`)
return axios.get(`https://rest.ciphertrace.com/aml/${apiVersion}/${_.toLower(cryptoCode)}/risk?address=${address}`, {
headers: authHeader
})
.then(res => ({ address, score: res.data.risk, isValid: res.data.risk < threshold }))
.then(result => {
console.log('** DEBUG ** rateWallet RETURN:', result)
logger.info(`** DEBUG ** rateWallet RETURN: ${result}`)
return result
})
.catch(err => {
console.log(`** DEBUG ** rateWallet ERROR: ${err.message}`)
logger.error(`** DEBUG ** rateWallet ERROR: ${err.message}`)
throw err
})
}
@ -54,7 +54,8 @@ function isValidWalletScore (account, score) {
function getAddressTransactionsHashes (receivingAddress, cryptoCode, client, wallet) {
const { apiVersion, authHeader } = client
console.log(`** DEBUG ** getTransactionHash ENDPOINT: https://rest.ciphertrace.com/api/${apiVersion}/${_.toLower(cryptoCode) !== 'btc' ? `${_.toLower(cryptoCode)}_` : ``}address/search?features=tx&address=${receivingAddress}&mempool=true`)
logger.info(`** DEBUG ** getTransactionHash ENDPOINT: https://rest.ciphertrace.com/api/${apiVersion}/${_.toLower(cryptoCode) !== 'btc' ? `${_.toLower(cryptoCode)}_` : ``}address/search?features=tx&address=${receivingAddress}&mempool=true`)
return axios.get(`https://rest.ciphertrace.com/api/${apiVersion}/${_.toLower(cryptoCode) !== 'btc' ? `${_.toLower(cryptoCode)}_` : ``}address/search?features=tx&address=${receivingAddress}&mempool=true`, {
headers: authHeader
@ -64,8 +65,8 @@ function getAddressTransactionsHashes (receivingAddress, cryptoCode, client, wal
_.map(_.get(['txHash']))
))
.catch(err => {
console.log(`** DEBUG ** getTransactionHash ERROR: ${err}`)
console.log(`** DEBUG ** Fetching transactions hashes via wallet node...`)
logger.error(`** DEBUG ** getTransactionHash ERROR: ${err}`)
logger.error(`** DEBUG ** Fetching transactions hashes via wallet node...`)
return wallet.getTxHashesByAddress(cryptoCode, receivingAddress)
})
}
@ -78,11 +79,11 @@ function getTransactionHash (account, cryptoCode, receivingAddress, wallet) {
if (_.size(txHashes) > 1) {
logger.warn('An address generated by this wallet was used in more than one transaction')
}
console.log('** DEBUG ** getTransactionHash RETURN: ', _.join(', ', txHashes))
logger.info('** DEBUG ** getTransactionHash RETURN: ', _.join(', ', txHashes))
return txHashes
})
.catch(err => {
console.log('** DEBUG ** getTransactionHash from wallet node ERROR: ', err)
logger.error('** DEBUG ** getTransactionHash from wallet node ERROR: ', err)
throw err
})
}
@ -116,12 +117,12 @@ function getInputAddresses (account, cryptoCode, txHashes) {
const transactionInputs = _.flatMap(it => it.inputs, data.transactions)
const inputAddresses = _.map(it => it.address, transactionInputs)
console.log(`** DEBUG ** getInputAddresses RETURN: ${inputAddresses}`)
logger.info(`** DEBUG ** getInputAddresses RETURN: ${inputAddresses}`)
return inputAddresses
})
.catch(err => {
console.log(`** DEBUG ** getInputAddresses ERROR: ${err.message}`)
logger.error(`** DEBUG ** getInputAddresses ERROR: ${err.message}`)
throw err
})
}