Commit 5c81c768 authored by Iuri Matias's avatar Iuri Matias Committed by aniket-engg

refactor decodeMappingsKeys

parent 6f411db3
......@@ -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)
}
}
......
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