refactor decodeMappingsKeys

pull/5370/head
Iuri Matias 4 years ago committed by aniket-engg
parent 24e4745e54
commit cc51c40785
  1. 4
      libs/remix-debug/src/storage/mappingPreimages.js
  2. 11
      libs/remix-debug/src/storage/storageResolver.js
  3. 11
      libs/remix-debug/src/storage/storageViewer.js

@ -13,7 +13,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, callback) {
async function decodeMappingsKeys (web3, storage, corrections) {
const ret = {}
if (!corrections.length) corrections.push({offset: 0, slot: 0})
for (let hashedLoc in storage) {
@ -38,7 +38,7 @@ async function decodeMappingsKeys (web3, storage, corrections, callback) {
ret[mappingSlot][mappingKey] = preimage
}
}
callback(null, ret)
return ret
}
/**

@ -47,14 +47,9 @@ class StorageResolver {
if (error) {
return callback(error)
}
mappingPreimages.decodeMappingsKeys(this.web3, storage, corrections, (error, mappings) => {
if (error) {
callback(error)
} else {
this.preimagesMappingByAddress[address] = mappings
callback(null, mappings)
}
})
const mappings = mappingPreimages.decodeMappingsKeys(this.web3, storage, corrections)
this.preimagesMappingByAddress[address] = mappings
callback(null, mappings)
})
}

@ -118,14 +118,9 @@ class StorageViewer {
if (this.mappingsLocationChanges) {
return callback(null, this.mappingsLocationChanges)
}
mappingPreimages.decodeMappingsKeys(this.web3, storageChanges, corrections, (error, mappings) => {
if (!error) {
this.mappingsLocationChanges = mappings
return callback(null, this.mappingsLocationChanges)
} else {
callback(error)
}
})
const mappings = mappingPreimages.decodeMappingsKeys(this.web3, storageChanges, corrections)
this.mappingsLocationChanges = mappings
return callback(null, this.mappingsLocationChanges)
}
}

Loading…
Cancel
Save