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

remove some unnecessary elses

parent b87ae778
......@@ -51,27 +51,24 @@ function extractStateDefinitions (contractName, sourcesList, contracts) {
contracts = extractContractDefinitions(sourcesList)
}
const node = contracts.contractsByName[contractName]
if (node) {
const stateItems = []
const stateVar = []
const baseContracts = getLinearizedBaseContracts(node.id, contracts.contractsById)
baseContracts.reverse()
for (let k in baseContracts) {
const ctr = baseContracts[k]
for (let i in ctr.children) {
const item = ctr.children[i]
stateItems.push(item)
if (item.name === 'VariableDeclaration') {
stateVar.push(item)
}
if (!node) {
return null
}
const stateItems = []
const stateVar = []
const baseContracts = getLinearizedBaseContracts(node.id, contracts.contractsById)
baseContracts.reverse()
for (let k in baseContracts) {
const ctr = baseContracts[k]
for (let i in ctr.children) {
const item = ctr.children[i]
stateItems.push(item)
if (item.name === 'VariableDeclaration') {
stateVar.push(item)
}
}
return {
stateDefinitions: stateItems,
stateVariables: stateVar
}
}
return null
return {stateDefinitions: stateItems, stateVariables: stateVar}
}
/**
......
......@@ -10,10 +10,9 @@ class Bool extends ValueType {
decodeValue (value) {
if (!value) {
return false
} else {
value = util.extractHexByteSlice(value, this.storageBytes, 0)
return value !== '00'
}
value = util.extractHexByteSlice(value, this.storageBytes, 0)
return value !== '00'
}
}
......
......@@ -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 + '>'
}
}
value = parseInt(value, 16)
if (this.enumDef.children.length > value) {
return this.enumDef.children[value].attributes.name
}
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