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
311289a0
Commit
311289a0
authored
Jan 12, 2017
by
yann300
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
rename location storagelocation
parent
70a880a8
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
46 additions
and
46 deletions
+46
-46
decodeInfo.js
src/solidity/decodeInfo.js
+14
-14
stateDecoder.js
src/solidity/stateDecoder.js
+1
-1
Struct.js
src/solidity/types/Struct.js
+2
-2
storageLocation.js
test/solidity/storageLocation.js
+29
-29
No files found.
src/solidity/decodeInfo.js
View file @
311289a0
...
...
@@ -286,7 +286,7 @@ function parseType (type, stateDefinitions, contractName) {
*/
function
computeOffsets
(
types
,
stateDefinitions
,
contractName
)
{
var
ret
=
[]
var
location
=
{
var
storage
location
=
{
offset
:
0
,
slot
:
0
}
...
...
@@ -297,31 +297,31 @@ function computeOffsets (types, stateDefinitions, contractName) {
console
.
log
(
'unable to retrieve decode info of '
+
variable
.
attributes
.
type
)
return
null
}
if
(
location
.
offset
+
type
.
storageBytes
>
32
)
{
location
.
slot
++
location
.
offset
=
0
if
(
storage
location
.
offset
+
type
.
storageBytes
>
32
)
{
storage
location
.
slot
++
storage
location
.
offset
=
0
}
ret
.
push
({
name
:
variable
.
attributes
.
name
,
type
:
type
,
location
:
{
offset
:
location
.
offset
,
slot
:
location
.
slot
storage
location
:
{
offset
:
storage
location
.
offset
,
slot
:
storage
location
.
slot
}
})
if
(
type
.
storageSlots
===
1
&&
location
.
offset
+
type
.
storageBytes
<=
32
)
{
location
.
offset
+=
type
.
storageBytes
if
(
type
.
storageSlots
===
1
&&
storage
location
.
offset
+
type
.
storageBytes
<=
32
)
{
storage
location
.
offset
+=
type
.
storageBytes
}
else
{
location
.
slot
+=
type
.
storageSlots
location
.
offset
=
0
storage
location
.
slot
+=
type
.
storageSlots
storage
location
.
offset
=
0
}
}
if
(
location
.
offset
>
0
)
{
location
.
slot
++
if
(
storage
location
.
offset
>
0
)
{
storage
location
.
slot
++
}
return
{
typesOffsets
:
ret
,
endLocation
:
location
endLocation
:
storage
location
}
}
...
...
src/solidity/stateDecoder.js
View file @
311289a0
...
...
@@ -12,7 +12,7 @@ function decodeState (stateVars, storageContent) {
var
ret
=
{}
for
(
var
k
in
stateVars
)
{
var
stateVar
=
stateVars
[
k
]
ret
[
stateVar
.
name
]
=
stateVar
.
type
.
decodeFromStorage
(
stateVar
.
location
,
storageContent
)
ret
[
stateVar
.
name
]
=
stateVar
.
type
.
decodeFromStorage
(
stateVar
.
storage
location
,
storageContent
)
}
return
ret
}
...
...
src/solidity/types/Struct.js
View file @
311289a0
...
...
@@ -12,8 +12,8 @@ class Struct extends RefType {
var
ret
=
{}
this
.
members
.
map
(
function
(
item
,
i
)
{
var
globalLocation
=
{
offset
:
location
.
offset
+
item
.
location
.
offset
,
slot
:
util
.
add
(
location
.
slot
,
item
.
location
.
slot
)
offset
:
location
.
offset
+
item
.
storage
location
.
offset
,
slot
:
util
.
add
(
location
.
slot
,
item
.
storage
location
.
slot
)
}
ret
[
item
.
name
]
=
item
.
type
.
decodeFromStorage
(
globalLocation
,
storageContent
)
})
...
...
test/solidity/storageLocation.js
View file @
311289a0
...
...
@@ -8,43 +8,43 @@ tape('solidity', function (t) {
t
.
test
(
'storage location'
,
function
(
st
)
{
var
output
=
compiler
.
compile
(
contracts
,
0
)
var
stateDec
=
index
.
solidity
.
stateDecoder
.
extractStateVariables
(
'contractUint'
,
output
.
sources
)
checkLocation
(
st
,
stateDec
[
0
].
location
,
0
,
0
)
checkLocation
(
st
,
stateDec
[
1
].
location
,
1
,
0
)
checkLocation
(
st
,
stateDec
[
2
].
location
,
2
,
0
)
checkLocation
(
st
,
stateDec
[
3
].
location
,
3
,
0
)
checkLocation
(
st
,
stateDec
[
0
].
storage
location
,
0
,
0
)
checkLocation
(
st
,
stateDec
[
1
].
storage
location
,
1
,
0
)
checkLocation
(
st
,
stateDec
[
2
].
storage
location
,
2
,
0
)
checkLocation
(
st
,
stateDec
[
3
].
storage
location
,
3
,
0
)
stateDec
=
index
.
solidity
.
stateDecoder
.
extractStateVariables
(
'contractStructAndArray'
,
output
.
sources
)
checkLocation
(
st
,
stateDec
[
0
].
location
,
0
,
0
)
checkLocation
(
st
,
stateDec
[
1
].
location
,
2
,
0
)
checkLocation
(
st
,
stateDec
[
2
].
location
,
8
,
0
)
checkLocation
(
st
,
stateDec
[
0
].
storage
location
,
0
,
0
)
checkLocation
(
st
,
stateDec
[
1
].
storage
location
,
2
,
0
)
checkLocation
(
st
,
stateDec
[
2
].
storage
location
,
8
,
0
)
stateDec
=
index
.
solidity
.
stateDecoder
.
extractStateVariables
(
'contractArray'
,
output
.
sources
)
checkLocation
(
st
,
stateDec
[
0
].
location
,
0
,
0
)
checkLocation
(
st
,
stateDec
[
1
].
location
,
1
,
0
)
checkLocation
(
st
,
stateDec
[
2
].
location
,
2
,
0
)
checkLocation
(
st
,
stateDec
[
0
].
storage
location
,
0
,
0
)
checkLocation
(
st
,
stateDec
[
1
].
storage
location
,
1
,
0
)
checkLocation
(
st
,
stateDec
[
2
].
storage
location
,
2
,
0
)
stateDec
=
index
.
solidity
.
stateDecoder
.
extractStateVariables
(
'contractSmallVariable'
,
output
.
sources
)
checkLocation
(
st
,
stateDec
[
0
].
location
,
0
,
0
)
checkLocation
(
st
,
stateDec
[
1
].
location
,
0
,
1
)
checkLocation
(
st
,
stateDec
[
2
].
location
,
0
,
2
)
checkLocation
(
st
,
stateDec
[
3
].
location
,
0
,
4
)
checkLocation
(
st
,
stateDec
[
4
].
location
,
1
,
0
)
checkLocation
(
st
,
stateDec
[
5
].
location
,
2
,
0
)
checkLocation
(
st
,
stateDec
[
0
].
storage
location
,
0
,
0
)
checkLocation
(
st
,
stateDec
[
1
].
storage
location
,
0
,
1
)
checkLocation
(
st
,
stateDec
[
2
].
storage
location
,
0
,
2
)
checkLocation
(
st
,
stateDec
[
3
].
storage
location
,
0
,
4
)
checkLocation
(
st
,
stateDec
[
4
].
storage
location
,
1
,
0
)
checkLocation
(
st
,
stateDec
[
5
].
storage
location
,
2
,
0
)
stateDec
=
index
.
solidity
.
stateDecoder
.
extractStateVariables
(
'testSimpleStorage'
,
output
.
sources
)
checkLocation
(
st
,
stateDec
[
0
].
location
,
0
,
0
)
checkLocation
(
st
,
stateDec
[
1
].
location
,
1
,
0
)
checkLocation
(
st
,
stateDec
[
2
].
location
,
2
,
0
)
checkLocation
(
st
,
stateDec
[
3
].
location
,
3
,
0
)
checkLocation
(
st
,
stateDec
[
4
].
location
,
4
,
0
)
checkLocation
(
st
,
stateDec
[
5
].
location
,
8
,
0
)
checkLocation
(
st
,
stateDec
[
6
].
location
,
9
,
0
)
checkLocation
(
st
,
stateDec
[
8
].
location
,
17
,
0
)
checkLocation
(
st
,
stateDec
[
9
].
location
,
17
,
4
)
checkLocation
(
st
,
stateDec
[
10
].
location
,
17
,
6
)
checkLocation
(
st
,
stateDec
[
11
].
location
,
17
,
7
)
checkLocation
(
st
,
stateDec
[
12
].
location
,
18
,
0
)
checkLocation
(
st
,
stateDec
[
13
].
location
,
21
,
0
)
checkLocation
(
st
,
stateDec
[
0
].
storage
location
,
0
,
0
)
checkLocation
(
st
,
stateDec
[
1
].
storage
location
,
1
,
0
)
checkLocation
(
st
,
stateDec
[
2
].
storage
location
,
2
,
0
)
checkLocation
(
st
,
stateDec
[
3
].
storage
location
,
3
,
0
)
checkLocation
(
st
,
stateDec
[
4
].
storage
location
,
4
,
0
)
checkLocation
(
st
,
stateDec
[
5
].
storage
location
,
8
,
0
)
checkLocation
(
st
,
stateDec
[
6
].
storage
location
,
9
,
0
)
checkLocation
(
st
,
stateDec
[
8
].
storage
location
,
17
,
0
)
checkLocation
(
st
,
stateDec
[
9
].
storage
location
,
17
,
4
)
checkLocation
(
st
,
stateDec
[
10
].
storage
location
,
17
,
6
)
checkLocation
(
st
,
stateDec
[
11
].
storage
location
,
17
,
7
)
checkLocation
(
st
,
stateDec
[
12
].
storage
location
,
18
,
0
)
checkLocation
(
st
,
stateDec
[
13
].
storage
location
,
21
,
0
)
st
.
end
()
})
...
...
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