diff --git a/libs/remix-debug/src/debugger/VmDebugger.js b/libs/remix-debug/src/debugger/VmDebugger.js index b96092085b..8c3226203b 100644 --- a/libs/remix-debug/src/debugger/VmDebugger.js +++ b/libs/remix-debug/src/debugger/VmDebugger.js @@ -102,13 +102,13 @@ class VmDebuggerLogic { var storageViewer = new StorageViewer({ stepIndex: this.stepManager.currentStepIndex, tx: this.tx, address: address }, this.storageResolver, this._traceManager) - storageViewer.storageRange((error, storage) => { - if (error) { - this.event.trigger('traceManagerStorageUpdate', [{}]) - } else if (this.stepManager.currentStepIndex === index) { + storageViewer.storageRange().then((storage) => { + if (this.stepManager.currentStepIndex === index) { var header = storageViewer.isComplete(address) ? '[Completely Loaded]' : '[Partially Loaded]' this.event.trigger('traceManagerStorageUpdate', [storage, header]) } + }).catch((_error) => { + this.event.trigger('traceManagerStorageUpdate', [{}]) }) } catch (error) { } @@ -185,11 +185,9 @@ class VmDebuggerLogic { for (var k in this.addresses) { var address = this.addresses[k] var storageViewer = new StorageViewer({ stepIndex: this.stepManager.currentStepIndex, tx: this.tx, address: address }, this.storageResolver, this._traceManager) - storageViewer.storageRange((error, result) => { - if (!error) { - storageJSON[address] = result - this.event.trigger('traceStorageUpdate', [storageJSON]) - } + storageViewer.storageRange().then((result) => { + storageJSON[address] = result + this.event.trigger('traceStorageUpdate', [storageJSON]) }) } }) diff --git a/libs/remix-debug/src/storage/storageViewer.js b/libs/remix-debug/src/storage/storageViewer.js index 3da4d6ca06..a5c9e80e42 100644 --- a/libs/remix-debug/src/storage/storageViewer.js +++ b/libs/remix-debug/src/storage/storageViewer.js @@ -30,10 +30,12 @@ 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).then((storage) => { - callback(null, Object.assign({}, storage, this.storageChanges)) - }).catch(callback) + storageRange () { + return new Promise((resolve, reject) => { + this.storageResolver.storageRange(this.context.tx, this.context.stepIndex, this.context.address).then((storage) => { + resolve(Object.assign({}, storage, this.storageChanges)) + }).catch(reject) + }) } /** diff --git a/libs/remix-debug/test/debugger.js b/libs/remix-debug/test/debugger.js index 7d0a47c2dc..81a800ee09 100644 --- a/libs/remix-debug/test/debugger.js +++ b/libs/remix-debug/test/debugger.js @@ -224,9 +224,11 @@ function testDebugging (debugManager) { const address = debugManager.traceManager.getCurrentCalledAddressAt(38) console.log(address) var storageView = debugManager.storageViewAt(196, address) - storageView.storageRange((error, storage) => { - if (error) return t.end(error) + + storageView.storageRange().then((storage) => { t.equal(JSON.stringify(storage), JSON.stringify({ '0x290decd9548b62a8d60345a988386fc84ba6bc95484008f6362f93160ef3e563': { key: '0x0000000000000000000000000000000000000000000000000000000000000000', value: '0x0000000000000000000000004b0897b0513fdc7c541b6d9d7e929c4e5364d2db' } })) + }).catch((error) => { + if (error) return t.end(error) }) } catch (error) { return t.end(error)