Commit c0dcb5a7 authored by yann300's avatar yann300

normalizeHex

parent 3ec6a80c
...@@ -22,7 +22,7 @@ function decodeIntFromHex (value, byteLength, signed) { ...@@ -22,7 +22,7 @@ function decodeIntFromHex (value, byteLength, signed) {
} }
function readFromStorage (slot, storageResolver) { function readFromStorage (slot, storageResolver) {
var hexSlot = ethutil.bufferToHex(slot) var hexSlot = '0x' + normalizeHex(ethutil.bufferToHex(slot))
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
storageResolver.storageSlot(hexSlot, (error, slot) => { storageResolver.storageSlot(hexSlot, (error, slot) => {
if (error) { if (error) {
...@@ -34,11 +34,7 @@ function readFromStorage (slot, storageResolver) { ...@@ -34,11 +34,7 @@ function readFromStorage (slot, storageResolver) {
value: '' value: ''
} }
} }
slot.value = slot.value.replace('0x', '') return resolve(normalizeHex(slot.value))
if (slot.value.length < 64) {
slot.value = (new Array(64 - slot.value.length + 1).join('0')) + slot.value
}
return resolve(slot.value)
} }
}) })
}) })
...@@ -102,3 +98,11 @@ function extractLocation (type) { ...@@ -102,3 +98,11 @@ function extractLocation (type) {
return null return null
} }
} }
function normalizeHex (hex) {
hex = hex.replace('0x', '')
if (hex.length < 64) {
return (new Array(64 - hex.length + 1).join('0')) + hex
}
return hex
}
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