decodeFromMemory enum, int, uint

pull/7/head
yann300 8 years ago
parent d4daac1fc1
commit b2bfec66b8
  1. 7
      src/solidity/types/Enum.js
  2. 5
      src/solidity/types/Int.js
  3. 5
      src/solidity/types/Uint.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

@ -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

@ -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

Loading…
Cancel
Save