diff --git a/libs/remix-debug/src/storage/storageResolver.js b/libs/remix-debug/src/storage/storageResolver.js index 1e5924c66a..9ee951f766 100644 --- a/libs/remix-debug/src/storage/storageResolver.js +++ b/libs/remix-debug/src/storage/storageResolver.js @@ -25,10 +25,8 @@ class StorageResolver { * @param {String} - address - lookup address * @param {Function} - callback - contains a map: [hashedKey] = {key, hashedKey, value} */ - storageRange (tx, stepIndex, address, callback) { - this.storageRangeInternal(this, this.zeroSlot, tx, stepIndex, address).then((result) => { - callback(null, result) - }).catch(callback) + storageRange (tx, stepIndex, address) { + return this.storageRangeInternal(this, this.zeroSlot, tx, stepIndex, address) } /** @@ -41,17 +39,16 @@ class StorageResolver { * @param {Array} corrections - used in case the calculated sha3 has been modifyed before SSTORE (notably used for struct in mapping). * @return {Function} - callback */ - initialPreimagesMappings (tx, stepIndex, address, corrections, callback) { - if (this.preimagesMappingByAddress[address]) { - return callback(null, this.preimagesMappingByAddress[address]) - } - this.storageRange(tx, stepIndex, address, (error, storage) => { - if (error) { - return callback(error) + initialPreimagesMappings (tx, stepIndex, address, corrections) { + return new Promise((resolve, reject) => { + if (this.preimagesMappingByAddress[address]) { + return resolve(this.preimagesMappingByAddress[address]) } - const mappings = mappingPreimages.decodeMappingsKeys(this.web3, storage, corrections) - this.preimagesMappingByAddress[address] = mappings - callback(null, mappings) + this.storageRange(tx, stepIndex, address).then((storage) => { + const mappings = mappingPreimages.decodeMappingsKeys(this.web3, storage, corrections) + this.preimagesMappingByAddress[address] = mappings + resolve(mappings) + }).catch(reject) }) } diff --git a/libs/remix-debug/src/storage/storageViewer.js b/libs/remix-debug/src/storage/storageViewer.js index d46b0cfc3b..59325f887f 100644 --- a/libs/remix-debug/src/storage/storageViewer.js +++ b/libs/remix-debug/src/storage/storageViewer.js @@ -31,13 +31,9 @@ class StorageViewer { * @param {Function} - callback - contains a map: [hashedKey] = {key, hashedKey, value} */ storageRange (callback) { - this.storageResolver.storageRange(this.context.tx, this.context.stepIndex, this.context.address, (error, storage) => { - if (error) { - callback(error) - } else { - callback(null, Object.assign({}, storage, this.storageChanges)) - } - }) + this.storageResolver.storageRange(this.context.tx, this.context.stepIndex, this.context.address).then((storage) => { + callback(null, Object.assign({}, storage, this.storageChanges)) + }).catch(callback) } /** @@ -76,15 +72,7 @@ class StorageViewer { */ async initialMappingsLocation (corrections) { if (!this.initialMappingsLocationPromise) { - this.initialMappingsLocationPromise = new Promise((resolve, reject) => { - this.storageResolver.initialPreimagesMappings(this.context.tx, this.context.stepIndex, this.context.address, corrections, (error, initialMappingsLocation) => { - if (error) { - reject(error) - } else { - resolve(initialMappingsLocation) - } - }) - }) + this.initialMappingsLocationPromise = this.storageResolver.initialPreimagesMappings(this.context.tx, this.context.stepIndex, this.context.address, corrections) } return this.initialMappingsLocationPromise }