Commit d19e441f authored by Iuri Matias's avatar Iuri Matias

refactor extractMappingsLocationChanges

parent 6698706e
...@@ -77,13 +77,8 @@ class StorageViewer { ...@@ -77,13 +77,8 @@ class StorageViewer {
async mappingsLocation (corrections) { async mappingsLocation (corrections) {
if (!this.currentMappingsLocationPromise) { if (!this.currentMappingsLocationPromise) {
this.currentMappingsLocationPromise = new Promise((resolve, reject) => { this.currentMappingsLocationPromise = new Promise((resolve, reject) => {
this.extractMappingsLocationChanges(this.storageChanges, corrections, (error, mappingsLocationChanges) => { const mappingsLocationChanges = this.extractMappingsLocationChanges(this.storageChanges, corrections)
if (error) { return resolve(mappingsLocationChanges)
reject(error)
} else {
resolve(mappingsLocationChanges)
}
})
}) })
} }
return this.currentMappingsLocationPromise return this.currentMappingsLocationPromise
...@@ -94,13 +89,13 @@ class StorageViewer { ...@@ -94,13 +89,13 @@ class StorageViewer {
* @param {Map} storageChanges * @param {Map} storageChanges
* @param {Array} corrections - used in case the calculated sha3 has been modifyed before SSTORE (notably used for struct in mapping). * @param {Array} corrections - used in case the calculated sha3 has been modifyed before SSTORE (notably used for struct in mapping).
*/ */
extractMappingsLocationChanges (storageChanges, corrections, callback) { extractMappingsLocationChanges (storageChanges, corrections) {
if (this.mappingsLocationChanges) { if (this.mappingsLocationChanges) {
return callback(null, this.mappingsLocationChanges) return this.mappingsLocationChanges
} }
const mappings = mappingPreimages.decodeMappingsKeys(this.web3, storageChanges, corrections) const mappings = mappingPreimages.decodeMappingsKeys(this.web3, storageChanges, corrections)
this.mappingsLocationChanges = mappings this.mappingsLocationChanges = mappings
return callback(null, this.mappingsLocationChanges) return 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