diff --git a/src/storage/mappingPreimages.js b/src/storage/mappingPreimages.js index b85901e8ef..5156f0191a 100644 --- a/src/storage/mappingPreimages.js +++ b/src/storage/mappingPreimages.js @@ -4,6 +4,13 @@ module.exports = { extractMappingPreimages: extractMappingPreimages } +/** + * Uses the storageViewer to retrieve the storage and returns a mapping containing possible solidity mappping type location. + * like { "" : { "": preimageOf1 }, { "": preimageOf2 }, ... } + * + * @param {Object} address - storageViewer + * @return {Map} - solidity mapping location + */ async function extractMappingPreimages (storageViewer) { return new Promise((resolve, reject) => { storageViewer.storageRange(function (error, storage) { @@ -22,6 +29,14 @@ async function extractMappingPreimages (storageViewer) { }) } +/** + * Uses the storageViewer to retrieve the storage and returns a mapping containing possible solidity mappping type location. + * like { "" : { "": preimageOf1 }, { "": preimageOf2 }, ... } + * + * @param {Object} storage - storage given by storage Viewer (basically a mapping hashedkey : {key, value}) + * @param {Function} callback - calback + * @return {Map} - solidity mapping location (e.g { "" : { "": preimageOf1 }, { "": preimageOf2 }, ... }) + */ async function decodeMappingsKeys (storage, callback) { var ret = {} for (var hashedLoc in storage) { @@ -45,6 +60,12 @@ async function decodeMappingsKeys (storage, callback) { callback(null, ret) } +/** + * Uses web3 to return preimage of a key + * + * @param {String} key - key to retrieve the preimage of + * @return {String} - preimage of the given key + */ function getPreimage (key) { return new Promise((resolve, reject) => { global.web3.debug.preimage(key, function (error, preimage) {