Commit 967f95d9 authored by yann300's avatar yann300 Committed by GitHub

Merge pull request #526 from ethereum/constantState

show <constant> if the state variable is constant
parents fae944fc 2cd2e262
......@@ -336,23 +336,26 @@ 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 (type.storageSlots === 1 && storagelocation.offset + type.storageBytes <= 32) {
storagelocation.offset += type.storageBytes
} else {
storagelocation.slot += type.storageSlots
storagelocation.offset = 0
if (!variable.attributes.constant) {
if (type.storageSlots === 1 && storagelocation.offset + type.storageBytes <= 32) {
storagelocation.offset += type.storageBytes
} else {
storagelocation.slot += type.storageSlots
storagelocation.offset = 0
}
}
}
if (storagelocation.offset > 0) {
......
......@@ -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 + '>'
......
......@@ -13,7 +13,7 @@ function formatSelf (key, data) {
if (data.type === 'string') {
data.self = JSON.stringify(data.self)
}
return yo`<label style=${keyStyle}>${key}: <label style=${style}>${data.self}</label><label style='font-style:italic'> ${data.isProperty ? '' : data.type}</label></label>`
return yo`<label style=${keyStyle}>${key}: <label style=${style}>${data.self}</label><label style='font-style:italic'> ${data.isProperty ? '' : ' ' + data.type}</label></label>`
}
function extractData (item, parent, key) {
......
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