fix: normalize return from elliptic
This commit is contained in:
parent
92de30de01
commit
d7d2b89556
1 changed files with 4 additions and 5 deletions
|
|
@ -15,13 +15,11 @@ const HOLLISTIC_COINS = {
|
|||
const SINGLE_ASSET_COINS = {
|
||||
ZEC: {
|
||||
asset: 'ZEC',
|
||||
// TODO needs api to fetch blockchain name
|
||||
blockchain: 'zcash'
|
||||
},
|
||||
BCH: {
|
||||
asset: 'BCH',
|
||||
// TODO needs api to fetch blockchain name
|
||||
blockchain: 'bitcoincash'
|
||||
blockchain: 'bitcoin_cash'
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -47,7 +45,7 @@ function rate (account, objectType, cryptoCode, objectId) {
|
|||
subject: {
|
||||
asset: isHolistic ? 'holistic' : SINGLE_ASSET_COINS[cryptoCode].asset,
|
||||
blockchain: isHolistic ? 'holistic' : SINGLE_ASSET_COINS[cryptoCode].blockchain,
|
||||
type: TYPE[objectType],
|
||||
type: objectType,
|
||||
hash: objectId
|
||||
},
|
||||
type: objectType === TYPE.ADDRESS ? 'wallet_exposure' : 'source_of_funds'
|
||||
|
|
@ -61,9 +59,10 @@ function rate (account, objectType, cryptoCode, objectId) {
|
|||
.then((res) => {
|
||||
const resScore = res.data?.risk_score
|
||||
|
||||
// elliptic returns 0-1 score, but we're accepting 0-100 config
|
||||
// normalize score to 0-10 where 0 is the lowest risk
|
||||
// elliptic score can be null and contains decimals
|
||||
return {score: Math.trunc((resScore || 0) / 10), isValid: (resScore || 0) < threshold}
|
||||
return {score: (resScore || 0) * 10, isValid: ((resScore || 0) * 100) < threshold}
|
||||
})
|
||||
})
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue