add contract type + don't throw if type not found

pull/7/head
yann300 8 years ago
parent 4fb58291b1
commit dffb217ffd
  1. 10
      src/solidity/decodeInfo.js
  2. 3
      src/solidity/stateDecoder.js

@ -203,6 +203,9 @@ function getStructMembers (type, stateDefinitions, contractName) {
for (var dec of state.stateDefinitions) {
if (dec.name === 'StructDefinition' && type === contractName + '.' + dec.attributes.name) {
var offsets = computeOffsets(dec.children, stateDefinitions, contractName)
if (!offsets) {
return null
}
return {
members: offsets.typesOffsets,
storageSlots: offsets.endLocation.slot
@ -244,6 +247,7 @@ function typeClass (fullType) {
function parseType (type, stateDefinitions, contractName) {
var decodeInfos = {
'address': Address,
'contract': Address,
'array': Array,
'bool': Bool,
'bytes': DynamicByteArray,
@ -260,7 +264,11 @@ function parseType (type, stateDefinitions, contractName) {
console.log('unable to retrieve decode info of ' + type)
return null
}
return decodeInfos[currentType](type, stateDefinitions, contractName)
if (decodeInfos[currentType]) {
return decodeInfos[currentType](type, stateDefinitions, contractName)
} else {
return null
}
}
/**

@ -31,6 +31,9 @@ function extractStateVariables (contractName, sourcesList) {
}
var types = states[contractName].stateVariables
var offsets = decodeInfo.computeOffsets(types, states, contractName)
if (!offsets) {
return [] // TODO should maybe return an error
}
return offsets.typesOffsets
}

Loading…
Cancel
Save