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) { ...@@ -51,27 +51,24 @@ function extractStateDefinitions (contractName, sourcesList, contracts) {
contracts = extractContractDefinitions(sourcesList) contracts = extractContractDefinitions(sourcesList)
} }
const node = contracts.contractsByName[contractName] const node = contracts.contractsByName[contractName]
if (node) { if (!node) {
const stateItems = [] return null
const stateVar = [] }
const baseContracts = getLinearizedBaseContracts(node.id, contracts.contractsById) const stateItems = []
baseContracts.reverse() const stateVar = []
for (let k in baseContracts) { const baseContracts = getLinearizedBaseContracts(node.id, contracts.contractsById)
const ctr = baseContracts[k] baseContracts.reverse()
for (let i in ctr.children) { for (let k in baseContracts) {
const item = ctr.children[i] const ctr = baseContracts[k]
stateItems.push(item) for (let i in ctr.children) {
if (item.name === 'VariableDeclaration') { const item = ctr.children[i]
stateVar.push(item) 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 { ...@@ -10,10 +10,9 @@ class Bool extends ValueType {
decodeValue (value) { decodeValue (value) {
if (!value) { if (!value) {
return false 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 { ...@@ -16,14 +16,12 @@ class Enum extends ValueType {
decodeValue (value) { decodeValue (value) {
if (!value) { if (!value) {
return this.enumDef.children[0].attributes.name 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) { ...@@ -100,9 +100,8 @@ function extractLocation (type) {
let match = type.match(/( storage ref| storage pointer| memory| calldata)?$/) let match = type.match(/( storage ref| storage pointer| memory| calldata)?$/)
if (match[1] !== '') { if (match[1] !== '') {
return match[1].trim() return match[1].trim()
} else {
return null
} }
return null
} }
function extractLocationFromAstVariable (node) { function extractLocationFromAstVariable (node) {
...@@ -110,9 +109,8 @@ function extractLocationFromAstVariable (node) { ...@@ -110,9 +109,8 @@ function extractLocationFromAstVariable (node) {
return node.attributes.storageLocation return node.attributes.storageLocation
} else if (node.attributes.stateVariable) { } else if (node.attributes.stateVariable) {
return 'storage' 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) { 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