Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
B
baas-ide
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
JIRA
JIRA
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
guxukai
baas-ide
Commits
0958b7eb
Commit
0958b7eb
authored
May 22, 2017
by
yann300
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add doc
parent
ce169246
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
0 deletions
+21
-0
mappingPreimages.js
src/storage/mappingPreimages.js
+21
-0
No files found.
src/storage/mappingPreimages.js
View file @
0958b7eb
...
@@ -4,6 +4,13 @@ module.exports = {
...
@@ -4,6 +4,13 @@ module.exports = {
extractMappingPreimages
:
extractMappingPreimages
extractMappingPreimages
:
extractMappingPreimages
}
}
/**
* Uses the storageViewer to retrieve the storage and returns a mapping containing possible solidity mappping type location.
* like { "<mapping_slot>" : { "<mapping-key1>": preimageOf1 }, { "<mapping-key2>": preimageOf2 }, ... }
*
* @param {Object} address - storageViewer
* @return {Map} - solidity mapping location
*/
async
function
extractMappingPreimages
(
storageViewer
)
{
async
function
extractMappingPreimages
(
storageViewer
)
{
return
new
Promise
((
resolve
,
reject
)
=>
{
return
new
Promise
((
resolve
,
reject
)
=>
{
storageViewer
.
storageRange
(
function
(
error
,
storage
)
{
storageViewer
.
storageRange
(
function
(
error
,
storage
)
{
...
@@ -22,6 +29,14 @@ async function extractMappingPreimages (storageViewer) {
...
@@ -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 { "<mapping_slot>" : { "<mapping-key1>": preimageOf1 }, { "<mapping-key2>": 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 { "<mapping_slot>" : { "<mapping-key1>": preimageOf1 }, { "<mapping-key2>": preimageOf2 }, ... })
*/
async
function
decodeMappingsKeys
(
storage
,
callback
)
{
async
function
decodeMappingsKeys
(
storage
,
callback
)
{
var
ret
=
{}
var
ret
=
{}
for
(
var
hashedLoc
in
storage
)
{
for
(
var
hashedLoc
in
storage
)
{
...
@@ -45,6 +60,12 @@ async function decodeMappingsKeys (storage, callback) {
...
@@ -45,6 +60,12 @@ async function decodeMappingsKeys (storage, callback) {
callback
(
null
,
ret
)
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
)
{
function
getPreimage
(
key
)
{
return
new
Promise
((
resolve
,
reject
)
=>
{
return
new
Promise
((
resolve
,
reject
)
=>
{
global
.
web3
.
debug
.
preimage
(
key
,
function
(
error
,
preimage
)
{
global
.
web3
.
debug
.
preimage
(
key
,
function
(
error
,
preimage
)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment