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 = {
|
const SINGLE_ASSET_COINS = {
|
||||||
ZEC: {
|
ZEC: {
|
||||||
asset: 'ZEC',
|
asset: 'ZEC',
|
||||||
// TODO needs api to fetch blockchain name
|
|
||||||
blockchain: 'zcash'
|
blockchain: 'zcash'
|
||||||
},
|
},
|
||||||
BCH: {
|
BCH: {
|
||||||
asset: 'BCH',
|
asset: 'BCH',
|
||||||
// TODO needs api to fetch blockchain name
|
blockchain: 'bitcoin_cash'
|
||||||
blockchain: 'bitcoincash'
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -47,7 +45,7 @@ function rate (account, objectType, cryptoCode, objectId) {
|
||||||
subject: {
|
subject: {
|
||||||
asset: isHolistic ? 'holistic' : SINGLE_ASSET_COINS[cryptoCode].asset,
|
asset: isHolistic ? 'holistic' : SINGLE_ASSET_COINS[cryptoCode].asset,
|
||||||
blockchain: isHolistic ? 'holistic' : SINGLE_ASSET_COINS[cryptoCode].blockchain,
|
blockchain: isHolistic ? 'holistic' : SINGLE_ASSET_COINS[cryptoCode].blockchain,
|
||||||
type: TYPE[objectType],
|
type: objectType,
|
||||||
hash: objectId
|
hash: objectId
|
||||||
},
|
},
|
||||||
type: objectType === TYPE.ADDRESS ? 'wallet_exposure' : 'source_of_funds'
|
type: objectType === TYPE.ADDRESS ? 'wallet_exposure' : 'source_of_funds'
|
||||||
|
|
@ -61,9 +59,10 @@ function rate (account, objectType, cryptoCode, objectId) {
|
||||||
.then((res) => {
|
.then((res) => {
|
||||||
const resScore = res.data?.risk_score
|
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
|
// normalize score to 0-10 where 0 is the lowest risk
|
||||||
// elliptic score can be null and contains decimals
|
// 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