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
6698706e
Commit
6698706e
authored
Jul 24, 2020
by
Iuri Matias
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactor storageResolver
parent
7feb9edb
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
26 additions
and
38 deletions
+26
-38
storageResolver.js
libs/remix-debug/src/storage/storageResolver.js
+26
-38
No files found.
libs/remix-debug/src/storage/storageResolver.js
View file @
6698706e
...
@@ -39,17 +39,14 @@ class StorageResolver {
...
@@ -39,17 +39,14 @@ class StorageResolver {
* @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).
* @return {Function} - callback
* @return {Function} - callback
*/
*/
initialPreimagesMappings
(
tx
,
stepIndex
,
address
,
corrections
)
{
async
initialPreimagesMappings
(
tx
,
stepIndex
,
address
,
corrections
)
{
return
new
Promise
((
resolve
,
reject
)
=>
{
if
(
this
.
preimagesMappingByAddress
[
address
])
{
if
(
this
.
preimagesMappingByAddress
[
address
])
{
return
this
.
preimagesMappingByAddress
[
address
]
return
resolve
(
this
.
preimagesMappingByAddress
[
address
])
}
}
const
storage
=
await
this
.
storageRange
(
tx
,
stepIndex
,
address
)
this
.
storageRange
(
tx
,
stepIndex
,
address
).
then
((
storage
)
=>
{
const
mappings
=
mappingPreimages
.
decodeMappingsKeys
(
this
.
web3
,
storage
,
corrections
)
const
mappings
=
mappingPreimages
.
decodeMappingsKeys
(
this
.
web3
,
storage
,
corrections
)
this
.
preimagesMappingByAddress
[
address
]
=
mappings
this
.
preimagesMappingByAddress
[
address
]
=
mappings
return
mappings
resolve
(
mappings
)
}).
catch
(
reject
)
})
}
}
/**
/**
...
@@ -61,12 +58,9 @@ class StorageResolver {
...
@@ -61,12 +58,9 @@ class StorageResolver {
* @param {String} - address - lookup address
* @param {String} - address - lookup address
* @param {Function} - callback - {key, hashedKey, value} -
* @param {Function} - callback - {key, hashedKey, value} -
*/
*/
storageSlot
(
slot
,
tx
,
stepIndex
,
address
)
{
async
storageSlot
(
slot
,
tx
,
stepIndex
,
address
)
{
return
new
Promise
((
resolve
,
reject
)
=>
{
const
storage
=
await
this
.
storageRangeInternal
(
this
,
slot
,
tx
,
stepIndex
,
address
)
this
.
storageRangeInternal
(
this
,
slot
,
tx
,
stepIndex
,
address
).
then
((
storage
)
=>
{
return
(
storage
[
slot
]
!==
undefined
?
storage
[
slot
]
:
null
)
resolve
(
storage
[
slot
]
!==
undefined
?
storage
[
slot
]
:
null
)
}).
catch
(
reject
)
})
}
}
/**
/**
...
@@ -85,27 +79,21 @@ class StorageResolver {
...
@@ -85,27 +79,21 @@ class StorageResolver {
* even if the next 1000 items are not in the cache.
* even if the next 1000 items are not in the cache.
* - If @arg slot is not cached, the corresponding value will be resolved and the next 1000 slots.
* - If @arg slot is not cached, the corresponding value will be resolved and the next 1000 slots.
*/
*/
storageRangeInternal
(
self
,
slotKey
,
tx
,
stepIndex
,
address
)
{
async
storageRangeInternal
(
self
,
slotKey
,
tx
,
stepIndex
,
address
)
{
return
new
Promise
((
resolve
,
reject
)
=>
{
var
cached
=
this
.
fromCache
(
self
,
address
)
var
cached
=
this
.
fromCache
(
self
,
address
)
if
(
cached
&&
cached
.
storage
[
slotKey
])
{
// we have the current slot in the cache and maybe the next 1000...
if
(
cached
&&
cached
.
storage
[
slotKey
])
{
// we have the current slot in the cache and maybe the next 1000...
return
cached
.
storage
return
resolve
(
cached
.
storage
)
}
}
const
result
=
await
this
.
storageRangeWeb3Call
(
tx
,
address
,
slotKey
,
self
.
maxSize
)
this
.
storageRangeWeb3Call
(
tx
,
address
,
slotKey
,
self
.
maxSize
).
then
((
result
)
=>
{
const
[
storage
,
nextKey
]
=
result
const
[
storage
,
nextKey
]
=
result
if
(
!
storage
[
slotKey
]
&&
slotKey
!==
self
.
zeroSlot
)
{
// we don't cache the zero slot (could lead to inconsistency)
if
(
!
storage
[
slotKey
]
&&
slotKey
!==
self
.
zeroSlot
)
{
// we don't cache the zero slot (could lead to inconsistency)
storage
[
slotKey
]
=
{
key
:
slotKey
,
value
:
self
.
zeroSlot
}
storage
[
slotKey
]
=
{
}
key
:
slotKey
,
self
.
toCache
(
self
,
address
,
storage
)
value
:
self
.
zeroSlot
if
(
slotKey
===
self
.
zeroSlot
&&
!
nextKey
)
{
// only working if keys are sorted !!
}
self
.
storageByAddress
[
address
].
complete
=
true
}
}
self
.
toCache
(
self
,
address
,
storage
)
return
storage
if
(
slotKey
===
self
.
zeroSlot
&&
!
nextKey
)
{
// only working if keys are sorted !!
self
.
storageByAddress
[
address
].
complete
=
true
}
return
resolve
(
storage
)
}).
catch
(
reject
)
})
}
}
/**
/**
...
...
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