storage src updated

pull/697/head
aniket-engg 4 years ago committed by Aniket
parent 24d41a8761
commit 1187d4adcd
  1. 6
      libs/remix-debug/src/storage/mappingPreimages.ts
  2. 13
      libs/remix-debug/src/storage/storageResolver.ts
  3. 13
      libs/remix-debug/src/storage/storageViewer.ts

@ -1,9 +1,5 @@
const util = require('../solidity-decoder/types/util')
module.exports = {
decodeMappingsKeys: decodeMappingsKeys
}
/**
* extract the mappings location from the storage
* like { "<mapping_slot>" : { "<mapping-key1>": preimageOf1 }, { "<mapping-key2>": preimageOf2 }, ... }
@ -13,7 +9,7 @@ module.exports = {
* @param {Function} callback - calback
* @return {Map} - solidity mapping location (e.g { "<mapping_slot>" : { "<mapping-key1>": preimageOf1 }, { "<mapping-key2>": preimageOf2 }, ... })
*/
async function decodeMappingsKeys (web3, storage, corrections) {
export async function decodeMappingsKeys (web3, storage, corrections) {
const ret = {}
if (!corrections.length) corrections.push({offset: 0, slot: 0})
for (let hashedLoc in storage) {

@ -6,7 +6,14 @@ const mappingPreimages = require('./mappingPreimages')
* Basically one instance is created for one debugging session.
* (TODO: one instance need to be shared over all the components)
*/
class StorageResolver {
export class StorageResolver {
storageByAddress
preimagesMappingByAddress
maxSize
web3
zeroSlot
constructor (options) {
this.storageByAddress = {}
this.preimagesMappingByAddress = {}
@ -121,7 +128,7 @@ class StorageResolver {
self.storageByAddress[address].storage = Object.assign(self.storageByAddress[address].storage || {}, storage)
}
storageRangeWeb3Call (tx, address, start, maxSize) {
storageRangeWeb3Call (tx, address, start, maxSize): Promise<Array<unknown>> {
return new Promise((resolve, reject) => {
if (traceHelper.isContractCreation(address)) {
resolve([{}, null])
@ -144,5 +151,3 @@ class StorageResolver {
})
}
}
module.exports = StorageResolver

@ -8,7 +8,16 @@ const mappingPreimages = require('./mappingPreimages')
* Basically one instance is created foreach execution step and foreach component that need it.
* (TODO: one instance need to be shared over all the components)
*/
class StorageViewer {
export class StorageViewer {
context
storageResolver
web3
initialMappingsLocationPromise
currentMappingsLocationPromise
storageChanges
mappingsLocationChanges
constructor (_context, _storageResolver, _traceManager) {
this.context = _context
this.storageResolver = _storageResolver
@ -98,5 +107,3 @@ class StorageViewer {
return this.mappingsLocationChanges
}
}
module.exports = StorageViewer

Loading…
Cancel
Save