Commit 1187d4ad authored by aniket-engg's avatar aniket-engg Committed by Aniket

storage src updated

parent 24d41a87
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
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