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 * @param {Function} callback - calback
* @return {Map} - solidity mapping location (e.g { "<mapping_slot>" : { "<mapping-key1>": preimageOf1 }, { "<mapping-key2>": preimageOf2 }, ... }) * @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 = {} const ret = {}
if (!corrections.length) corrections.push({offset: 0, slot: 0}) if (!corrections.length) corrections.push({offset: 0, slot: 0})
for (let hashedLoc in storage) { for (let hashedLoc in storage) {
@ -38,7 +38,7 @@ async function decodeMappingsKeys (web3, storage, corrections, callback) {
ret[mappingSlot][mappingKey] = preimage ret[mappingSlot][mappingKey] = preimage
} }
} }
callback(null, ret) return ret
} }
/** /**

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

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

Loading…
Cancel
Save