From db50414691e9ffc940c1f3b9c7661808f8cc92f2 Mon Sep 17 00:00:00 2001 From: yann300 Date: Tue, 31 Jan 2017 13:13:02 +0100 Subject: [PATCH 1/3] fix decoding mapping of array --- src/solidity/decodeInfo.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/solidity/decodeInfo.js b/src/solidity/decodeInfo.js index 082c1e3b4b..2550d2639c 100644 --- a/src/solidity/decodeInfo.js +++ b/src/solidity/decodeInfo.js @@ -254,12 +254,12 @@ function getStructMembers (type, stateDefinitions, contractName, location) { * @return {String} returns the token type (used to instanciate the right decoder) (uint[2] storage ref[2] will return 'array', uint256 will return uintX) */ function typeClass (fullType) { - if (fullType.indexOf(']') !== -1) { - return 'array' - } if (fullType.indexOf('mapping') === 0) { return 'mapping' } + if (fullType.indexOf(']') !== -1) { + return 'array' + } if (fullType.indexOf(' ') !== -1) { fullType = fullType.split(' ')[0] } From 01acbda319add88526f6db0c1c4582bd17c49471 Mon Sep 17 00:00:00 2001 From: yann300 Date: Tue, 31 Jan 2017 13:13:23 +0100 Subject: [PATCH 2/3] retrieve storage --- src/solidity/localDecoder.js | 4 ++-- src/ui/SolidityLocals.js | 8 ++++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/solidity/localDecoder.js b/src/solidity/localDecoder.js index c2e76a6d12..4721ccaa89 100644 --- a/src/solidity/localDecoder.js +++ b/src/solidity/localDecoder.js @@ -1,6 +1,6 @@ 'use strict' -function solidityLocals (vmtraceIndex, internalTreeCall, stack, memory) { +function solidityLocals (vmtraceIndex, internalTreeCall, stack, memory, storage) { var scope = internalTreeCall.findScope(vmtraceIndex) if (!scope) { var error = { 'message': 'Can\'t display locals. reason: compilation result might not have been provided' } @@ -11,7 +11,7 @@ function solidityLocals (vmtraceIndex, internalTreeCall, stack, memory) { for (var local in scope.locals) { let variable = scope.locals[local] if (variable.stackDepth < stack.length) { - locals[variable.name] = variable.type.decodeFromStack(variable.stackDepth, stack, memory) + locals[variable.name] = variable.type.decodeFromStack(variable.stackDepth, stack, memory, storage) } } return locals diff --git a/src/ui/SolidityLocals.js b/src/ui/SolidityLocals.js index f0c2725abb..d13dff4355 100644 --- a/src/ui/SolidityLocals.js +++ b/src/ui/SolidityLocals.js @@ -47,8 +47,12 @@ class SolidityLocals { var stack = result[0].value var memory = result[1].value try { - var locals = localDecoder.solidityLocals(index, this.internalTreeCall, stack, memory) - this.basicPanel.update(locals) + this.traceManager.getStorageAt(index, this.parent.tx, (error, storage) => { + if (!error) { + var locals = localDecoder.solidityLocals(index, this.internalTreeCall, stack, memory, storage) + this.basicPanel.update(locals) + } + }) } catch (e) { warningDiv.innerHTML = e.message } From 9fc9344ca260a07ac9f3d049033d81cc50c640e6 Mon Sep 17 00:00:00 2001 From: yann300 Date: Tue, 31 Jan 2017 13:13:42 +0100 Subject: [PATCH 3/3] use BN for storage decoding --- src/solidity/types/RefType.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/solidity/types/RefType.js b/src/solidity/types/RefType.js index 4701885a70..8d0d7fcca1 100644 --- a/src/solidity/types/RefType.js +++ b/src/solidity/types/RefType.js @@ -1,4 +1,5 @@ 'use strict' +var util = require('./util') class RefType { constructor (storageSlots, storageBytes, typeName, location) { @@ -29,10 +30,11 @@ class RefType { storage = {} // TODO this is a fallback, should manage properly locals store in storage } var offset = stack[stack.length - 1 - stackDepth] - offset = parseInt(offset, 16) if (this.isInStorage()) { + offset = util.toBN(offset) return this.decodeFromStorage({ offset: 0, slot: offset }, storage) } else if (this.isInMemory()) { + offset = parseInt(offset, 16) return this.decodeFromMemoryInternal(offset, memory) } else { return {