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
c2113932
Commit
c2113932
authored
Mar 14, 2017
by
yann300
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
move sha3 function outside of solidity code
parent
668daa86
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
19 additions
and
10 deletions
+19
-10
util.js
src/helpers/util.js
+15
-1
ArrayType.js
src/solidity/types/ArrayType.js
+2
-1
DynamicByteArray.js
src/solidity/types/DynamicByteArray.js
+2
-1
util.js
src/solidity/types/util.js
+0
-7
No files found.
src/helpers/util.js
View file @
c2113932
'use strict'
var
ethutil
=
require
(
'ethereumjs-util'
)
module
.
exports
=
{
/*
ints: IntArray
...
...
@@ -115,7 +117,19 @@ module.exports = {
*/
findCall
:
findCall
,
buildCallPath
:
buildCallPath
buildCallPath
:
buildCallPath
,
/**
* sha3 the given @arg value
*
* @param {String} value - value to sha3
* @return {Object} - return sha3ied value
*/
sha3
:
function
(
value
)
{
var
ret
=
ethutil
.
bufferToHex
(
ethutil
.
setLengthLeft
(
value
,
32
))
ret
=
ethutil
.
sha3
(
ret
)
return
ethutil
.
bufferToHex
(
ret
)
}
}
/**
...
...
src/solidity/types/ArrayType.js
View file @
c2113932
'use strict'
var
util
=
require
(
'./util'
)
var
helper
=
require
(
'../../helpers/util'
)
var
BN
=
require
(
'ethereumjs-util'
).
BN
var
RefType
=
require
(
'./RefType'
)
...
...
@@ -33,7 +34,7 @@ class ArrayType extends RefType {
}
if
(
this
.
arraySize
===
'dynamic'
)
{
size
=
util
.
toBN
(
'0x'
+
slotValue
)
currentLocation
.
slot
=
util
.
sha3
(
location
.
slot
)
currentLocation
.
slot
=
helper
.
sha3
(
location
.
slot
)
}
else
{
size
=
new
BN
(
this
.
arraySize
)
}
...
...
src/solidity/types/DynamicByteArray.js
View file @
c2113932
'use strict'
var
util
=
require
(
'./util'
)
var
helper
=
require
(
'../../helpers/util'
)
var
BN
=
require
(
'ethereumjs-util'
).
BN
var
RefType
=
require
(
'./RefType'
)
...
...
@@ -13,7 +14,7 @@ class DynamicByteArray extends RefType {
var
bn
=
new
BN
(
value
,
16
)
if
(
bn
.
testn
(
0
))
{
var
length
=
bn
.
div
(
new
BN
(
2
))
var
dataPos
=
new
BN
(
util
.
sha3
(
location
.
slot
).
replace
(
'0x'
,
''
),
16
)
var
dataPos
=
new
BN
(
helper
.
sha3
(
location
.
slot
).
replace
(
'0x'
,
''
),
16
)
var
ret
=
''
var
currentSlot
=
await
util
.
readFromStorage
(
dataPos
,
storageContent
)
while
(
length
.
gt
(
ret
.
length
)
&&
ret
.
length
<
32000
)
{
...
...
src/solidity/types/util.js
View file @
c2113932
...
...
@@ -7,7 +7,6 @@ module.exports = {
decodeIntFromHex
:
decodeIntFromHex
,
extractHexValue
:
extractHexValue
,
extractHexByteSlice
:
extractHexByteSlice
,
sha3
:
sha3
,
toBN
:
toBN
,
add
:
add
,
extractLocation
:
extractLocation
,
...
...
@@ -67,12 +66,6 @@ async function extractHexValue (location, storageContent, byteLength) {
return
extractHexByteSlice
(
slotvalue
,
byteLength
,
location
.
offset
)
}
function
sha3
(
slot
)
{
var
remoteSlot
=
ethutil
.
bufferToHex
(
ethutil
.
setLengthLeft
(
slot
,
32
))
var
key
=
ethutil
.
sha3
(
remoteSlot
)
return
ethutil
.
bufferToHex
(
key
)
}
function
toBN
(
value
)
{
if
(
value
instanceof
BN
)
{
return
value
...
...
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