Commit b457d7d1 authored by Iuri Matias's avatar Iuri Matias Committed by aniket-engg

remove some unnecessary elses

parent b87ae778
......@@ -51,7 +51,9 @@ function extractStateDefinitions (contractName, sourcesList, contracts) {
contracts = extractContractDefinitions(sourcesList)
}
const node = contracts.contractsByName[contractName]
if (node) {
if (!node) {
return null
}
const stateItems = []
const stateVar = []
const baseContracts = getLinearizedBaseContracts(node.id, contracts.contractsById)
......@@ -66,12 +68,7 @@ function extractStateDefinitions (contractName, sourcesList, contracts) {
}
}
}
return {
stateDefinitions: stateItems,
stateVariables: stateVar
}
}
return null
return {stateDefinitions: stateItems, stateVariables: stateVar}
}
/**
......
......@@ -10,11 +10,10 @@ class Bool extends ValueType {
decodeValue (value) {
if (!value) {
return false
} else {
}
value = util.extractHexByteSlice(value, this.storageBytes, 0)
return value !== '00'
}
}
}
module.exports = Bool
......@@ -16,14 +16,12 @@ class Enum extends ValueType {
decodeValue (value) {
if (!value) {
return this.enumDef.children[0].attributes.name
} else {
}
value = parseInt(value, 16)
if (this.enumDef.children.length > value) {
return this.enumDef.children[value].attributes.name
} else {
return 'INVALID_ENUM<' + value + '>'
}
}
return 'INVALID_ENUM<' + value + '>'
}
}
......
......@@ -100,9 +100,8 @@ function extractLocation (type) {
let match = type.match(/( storage ref| storage pointer| memory| calldata)?$/)
if (match[1] !== '') {
return match[1].trim()
} else {
return null
}
return null
}
function extractLocationFromAstVariable (node) {
......@@ -110,9 +109,8 @@ function extractLocationFromAstVariable (node) {
return node.attributes.storageLocation
} else if (node.attributes.stateVariable) {
return 'storage'
} else {
return 'default' // local variables => storage, function parameters & return values => memory, state => storage
}
return 'default' // local variables => storage, function parameters & return values => memory, state => storage
}
function normalizeHex (hex) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment