refactor storageSlot

pull/62/head
Iuri Matias 4 years ago committed by aniket-engg
parent d8c64f75b8
commit ad8cfc967f
  1. 8
      libs/remix-debug/src/storage/storageResolver.js
  2. 8
      libs/remix-debug/src/storage/storageViewer.js

@ -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 {
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)
})
} }
/** /**

Loading…
Cancel
Save