decodeFromMemory DynamicByteArray

pull/7/head
yann300 8 years ago
parent 185f2ff3cf
commit b7b3249bab
  1. 18
      src/solidity/types/DynamicByteArray.js

@ -39,17 +39,21 @@ DynamicByteArray.prototype.decodeLocals = function (stackHeight, stack, memory)
if (stack.length - 1 < stackHeight) {
return {
value: '0x',
length: '0x'
length: '0x0'
}
} else {
var offset = stack[stack.length - 1 - stackHeight]
offset = 2 * parseInt(offset, 16)
var length = memory.substr(offset, 64)
length = parseInt(length, 16)
return {
length: 2 * length,
value: '0x' + memory.substr(offset + 64, 2 * length)
}
return this.decodeFromMemory(offset, memory)
}
}
DynamicByteArray.prototype.decodeFromMemory = function (offset, memory) {
var length = memory.substr(offset, 64)
length = 2 * parseInt(length, 16)
return {
length: '0x' + length.toString(16),
value: '0x' + memory.substr(offset + 64, length)
}
}

Loading…
Cancel
Save