Commit c85a49ec authored by yann300's avatar yann300

display <constant> if state var is constant

parent 91b834b6
......@@ -336,18 +336,20 @@ function computeOffsets (types, stateDefinitions, contractName, location) {
console.log('unable to retrieve decode info of ' + variable.attributes.type)
return null
}
if (storagelocation.offset + type.storageBytes > 32) {
if (!variable.attributes.constant && storagelocation.offset + type.storageBytes > 32) {
storagelocation.slot++
storagelocation.offset = 0
}
ret.push({
name: variable.attributes.name,
type: type,
constant: variable.attributes.constant,
storagelocation: {
offset: storagelocation.offset,
slot: storagelocation.slot
offset: variable.attributes.constant ? 0 : storagelocation.offset,
slot: variable.attributes.constant ? 0 : storagelocation.slot
}
})
if (!variable.attributes.constant) {
if (type.storageSlots === 1 && storagelocation.offset + type.storageBytes <= 32) {
storagelocation.offset += type.storageBytes
} else {
......@@ -355,7 +357,8 @@ function computeOffsets (types, stateDefinitions, contractName, location) {
storagelocation.offset = 0
}
}
if (storagelocation.offset > 0) {
}
if (!variable.attributes.constant && storagelocation.offset > 0) {
storagelocation.slot++
}
return {
......
......@@ -13,7 +13,12 @@ async function decodeState (stateVars, storageResolver) {
for (var k in stateVars) {
var stateVar = stateVars[k]
try {
ret[stateVar.name] = await stateVar.type.decodeFromStorage(stateVar.storagelocation, storageResolver)
var decoded = await stateVar.type.decodeFromStorage(stateVar.storagelocation, storageResolver)
decoded.constant = stateVar.constant
if (decoded.constant) {
decoded.value = '<constant>'
}
ret[stateVar.name] = decoded
} catch (e) {
console.log(e)
ret[stateVar.name] = '<decoding failed - ' + e.message + '>'
......
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