From b2bfec66b8ff683125e8c5084ec2d943db7d4d12 Mon Sep 17 00:00:00 2001 From: yann300 Date: Wed, 14 Dec 2016 13:22:54 +0100 Subject: [PATCH] decodeFromMemory enum, int, uint --- src/solidity/types/Enum.js | 7 +++++++ src/solidity/types/Int.js | 5 +++++ src/solidity/types/Uint.js | 5 +++++ 3 files changed, 17 insertions(+) diff --git a/src/solidity/types/Enum.js b/src/solidity/types/Enum.js index f8950209b5..b2aad9e05e 100644 --- a/src/solidity/types/Enum.js +++ b/src/solidity/types/Enum.js @@ -30,6 +30,13 @@ Enum.prototype.decodeLocals = function (stackHeight, stack, memory) { return output(defaultValue, this.enumDef) } +Enum.prototype.decodeFromMemory = function (offset, memory) { + var value = memory.substr(offset, 64) + value = util.extractHexByteSlice(value, this.storageBytes, 0) + value = parseInt(value, 16) + return output(value, this.enumDef) +} + function output (value, enumDef) { if (enumDef.children.length > value) { return enumDef.children[value].attributes.name diff --git a/src/solidity/types/Int.js b/src/solidity/types/Int.js index 36839868ee..87934a2cb6 100644 --- a/src/solidity/types/Int.js +++ b/src/solidity/types/Int.js @@ -19,4 +19,9 @@ Int.prototype.decodeLocals = function (stackHeight, stack, memory) { } } +Int.prototype.decodeFromMemory = function (offset, memory) { + var value = memory.substr(offset, 64) + return util.decodeIntFromHex(value, 32, true) +} + module.exports = Int diff --git a/src/solidity/types/Uint.js b/src/solidity/types/Uint.js index c5d65bf6a7..815b2c8e6a 100644 --- a/src/solidity/types/Uint.js +++ b/src/solidity/types/Uint.js @@ -19,4 +19,9 @@ Uint.prototype.decodeLocals = function (stackHeight, stack, memory) { } } +Uint.prototype.decodeFromMemory = function (offset, memory) { + var value = memory.substr(offset, 64) + return util.decodeIntFromHex(value, this.storageBytes, false) +} + module.exports = Uint