Commit ad8cfc96 authored by Iuri Matias's avatar Iuri Matias Committed by aniket-engg

refactor storageSlot

parent d8c64f75
...@@ -61,10 +61,12 @@ class StorageResolver { ...@@ -61,10 +61,12 @@ class StorageResolver {
* @param {String} - address - lookup address * @param {String} - address - lookup address
* @param {Function} - callback - {key, hashedKey, value} - * @param {Function} - callback - {key, hashedKey, value} -
*/ */
storageSlot (slot, tx, stepIndex, address, callback) { storageSlot (slot, tx, stepIndex, address) {
return new Promise((resolve, reject) => {
this.storageRangeInternal(this, slot, tx, stepIndex, address).then((storage) => { this.storageRangeInternal(this, slot, tx, stepIndex, address).then((storage) => {
callback(null, storage[slot] !== undefined ? storage[slot] : null) resolve(storage[slot] !== undefined ? storage[slot] : null)
}).catch(callback) }).catch(reject)
})
} }
/** /**
......
...@@ -46,13 +46,9 @@ class StorageViewer { ...@@ -46,13 +46,9 @@ class StorageViewer {
if (this.storageChanges[hashed]) { if (this.storageChanges[hashed]) {
return callback(null, this.storageChanges[hashed]) return callback(null, this.storageChanges[hashed])
} }
this.storageResolver.storageSlot(hashed, this.context.tx, this.context.stepIndex, this.context.address, (error, storage) => { this.storageResolver.storageSlot(hashed, this.context.tx, this.context.stepIndex, this.context.address).then((storage) => {
if (error) {
callback(error)
} else {
callback(null, storage) callback(null, storage)
} }).catch(callback)
})
} }
/** /**
......
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