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) { ...@@ -51,7 +51,9 @@ 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) {
return null
}
const stateItems = [] const stateItems = []
const stateVar = [] const stateVar = []
const baseContracts = getLinearizedBaseContracts(node.id, contracts.contractsById) const baseContracts = getLinearizedBaseContracts(node.id, contracts.contractsById)
...@@ -66,12 +68,7 @@ function extractStateDefinitions (contractName, sourcesList, contracts) { ...@@ -66,12 +68,7 @@ function extractStateDefinitions (contractName, sourcesList, contracts) {
} }
} }
} }
return { return {stateDefinitions: stateItems, stateVariables: stateVar}
stateDefinitions: stateItems,
stateVariables: stateVar
}
}
return null
} }
/** /**
......
...@@ -10,11 +10,10 @@ class Bool extends ValueType { ...@@ -10,11 +10,10 @@ class Bool extends ValueType {
decodeValue (value) { decodeValue (value) {
if (!value) { if (!value) {
return false return false
} else { }
value = util.extractHexByteSlice(value, this.storageBytes, 0) value = util.extractHexByteSlice(value, this.storageBytes, 0)
return value !== '00' return value !== '00'
} }
}
} }
module.exports = Bool module.exports = Bool
...@@ -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) value = parseInt(value, 16)
if (this.enumDef.children.length > value) { if (this.enumDef.children.length > value) {
return this.enumDef.children[value].attributes.name return this.enumDef.children[value].attributes.name
} else {
return 'INVALID_ENUM<' + value + '>'
}
} }
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