Commit c85a49ec authored by yann300's avatar yann300

display <constant> if state var is constant

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