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
c0dcb5a7
Commit
c0dcb5a7
authored
Apr 11, 2017
by
yann300
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
normalizeHex
parent
3ec6a80c
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
6 deletions
+10
-6
util.js
src/solidity/types/util.js
+10
-6
No files found.
src/solidity/types/util.js
View file @
c0dcb5a7
...
@@ -22,7 +22,7 @@ function decodeIntFromHex (value, byteLength, signed) {
...
@@ -22,7 +22,7 @@ function decodeIntFromHex (value, byteLength, signed) {
}
}
function
readFromStorage
(
slot
,
storageResolver
)
{
function
readFromStorage
(
slot
,
storageResolver
)
{
var
hexSlot
=
ethutil
.
bufferToHex
(
slot
)
var
hexSlot
=
'0x'
+
normalizeHex
(
ethutil
.
bufferToHex
(
slot
)
)
return
new
Promise
((
resolve
,
reject
)
=>
{
return
new
Promise
((
resolve
,
reject
)
=>
{
storageResolver
.
storageSlot
(
hexSlot
,
(
error
,
slot
)
=>
{
storageResolver
.
storageSlot
(
hexSlot
,
(
error
,
slot
)
=>
{
if
(
error
)
{
if
(
error
)
{
...
@@ -34,11 +34,7 @@ function readFromStorage (slot, storageResolver) {
...
@@ -34,11 +34,7 @@ function readFromStorage (slot, storageResolver) {
value
:
''
value
:
''
}
}
}
}
slot
.
value
=
slot
.
value
.
replace
(
'0x'
,
''
)
return
resolve
(
normalizeHex
(
slot
.
value
))
if
(
slot
.
value
.
length
<
64
)
{
slot
.
value
=
(
new
Array
(
64
-
slot
.
value
.
length
+
1
).
join
(
'0'
))
+
slot
.
value
}
return
resolve
(
slot
.
value
)
}
}
})
})
})
})
...
@@ -102,3 +98,11 @@ function extractLocation (type) {
...
@@ -102,3 +98,11 @@ function extractLocation (type) {
return
null
return
null
}
}
}
}
function
normalizeHex
(
hex
)
{
hex
=
hex
.
replace
(
'0x'
,
''
)
if
(
hex
.
length
<
64
)
{
return
(
new
Array
(
64
-
hex
.
length
+
1
).
join
(
'0'
))
+
hex
}
return
hex
}
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