Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const clean_input = function(str) {
if ((typeof str === 'number') || (str.isBigNumber === true) || BN.isBN(str)) str = `${ str.toString(16) }`
if ((!str) || (typeof str !== 'string') || (str === '0x')) str = '00'
if (str.indexOf('0x') === 0) str = str.substr(2)
if (str.length % 2 === 1) str = `0${str}`
return `0x${str}`
}
const clean_input = function(str) {
if ((typeof str === 'number') || (str.isBigNumber === true) || BN.isBN(str)) str = `${ str.toString(16) }`
if ((!str) || (typeof str !== 'string') || (str === '0x')) str = '00'
if (str.indexOf('0x') === 0) str = str.substr(2)
if (str.length % 2 === 1) str = `0${str}`
return `0x${str}`
}
function feeSubtracted(x, n = 1) {
assert(BN.isBN(x), "x is not a bignum")
assert(Number.isInteger(n) && n > 0, "n is not a valid integer")
const result = x.mul(FEE_DENOMINATOR_MINUS_ONE).div(FEE_DENOMINATOR)
return n === 1 ? result : feeSubtracted(result, n - 1)
}
function feeAdded(x) {
assert(BN.isBN(x))
return x.mul(feeDenominator).div(feeDenominatorMinusOne)
}