Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function formatEthResponse (obj) {
if (typeof obj === 'string' || obj instanceof String) {
obj = remove0x(obj)
} else if (Array.isArray(obj) && typeof obj[0] === 'object') {
for (let i = 0; i < obj.length; i++) {
obj[i] = formatEthResponse(obj[i])
}
} else if (Array.isArray(obj)) {
obj = obj.map(remove0x)
} else {
for (let key in obj) {
if (obj[key] === null) continue
if (Array.isArray(obj[key])) {
obj[key] = formatEthResponse(obj[key])
} else {
if ((Block.properties[key] &&
Block.properties[key].type === 'number') ||
(Transaction.properties[key] &&
Transaction.properties[key].type === 'number')) {
obj[key] = parseInt(obj[key])
} else {
if (obj[key]) {
obj[key] = remove0x(obj[key])
}
}
}
}
}
return obj
}
if (typeof obj === 'string' || obj instanceof String) {
obj = remove0x(obj)
} else if (Array.isArray(obj) && typeof obj[0] === 'object') {
for (let i = 0; i < obj.length; i++) {
obj[i] = formatEthResponse(obj[i])
}
} else if (Array.isArray(obj)) {
obj = obj.map(remove0x)
} else {
for (let key in obj) {
if (obj[key] === null) continue
if (Array.isArray(obj[key])) {
obj[key] = formatEthResponse(obj[key])
} else {
if ((Block.properties[key] &&
Block.properties[key].type === 'number') ||
(Transaction.properties[key] &&
Transaction.properties[key].type === 'number')) {
obj[key] = parseInt(obj[key])
} else {
if (obj[key]) {
obj[key] = remove0x(obj[key])
}
}
}
}
}
return obj
}