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
6e43844d
Commit
6e43844d
authored
Nov 17, 2016
by
yann300
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
decode struct + fix uint decoding
parent
0997621f
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
51 additions
and
1 deletion
+51
-1
Struct.js
src/solidity/types/Struct.js
+9
-1
structArrayStorage.js
test/solidity/contracts/structArrayStorage.js
+29
-0
storageDecoder.js
test/solidity/storageDecoder.js
+13
-0
No files found.
src/solidity/types/Struct.js
View file @
6e43844d
...
@@ -8,7 +8,15 @@ function Struct (memberDetails) {
...
@@ -8,7 +8,15 @@ function Struct (memberDetails) {
}
}
Struct
.
prototype
.
decodeFromStorage
=
function
(
location
,
storageContent
)
{
Struct
.
prototype
.
decodeFromStorage
=
function
(
location
,
storageContent
)
{
return
'<not implemented yet>'
var
ret
=
{}
this
.
members
.
map
(
function
(
item
,
i
)
{
var
globalLocation
=
{
offset
:
location
.
offset
+
item
.
location
.
offset
,
slot
:
location
.
slot
+
item
.
location
.
slot
}
ret
[
item
.
name
]
=
item
.
type
.
decodeFromStorage
(
globalLocation
,
storageContent
)
})
return
ret
}
}
module
.
exports
=
Struct
module
.
exports
=
Struct
test/solidity/contracts/structArrayStorage.js
0 → 100644
View file @
6e43844d
'use strict'
module
.
exports
=
{
contract
:
`contract structArrayStorage {
struct intStruct {
int8 i8;
int16 i16;
uint32 ui32;
int i256;
uint16 ui16;
int32 i32;
}
intStruct intStructDec;
function structArrayStorage () {
intStructDec.i8 = 32;
intStructDec.i16 = -54;
intStructDec.ui32 = 128;
intStructDec.i256 = -1243565465756;
intStructDec.ui16 = 34556;
intStructDec.i32 = -345446546;
}
}
`
,
storage
:
{
'0x0000000000000000000000000000000000000000000000000000000000000000'
:
'0x0000000000000000000000000000000000000000000000000000000080ffca20'
,
'0x0000000000000000000000000000000000000000000000000000000000000001'
:
'0xfffffffffffffffffffffffffffffffffffffffffffffffffffffede75b8df64'
,
'0x0000000000000000000000000000000000000000000000000000000000000002'
:
'0x0000000000000000000000000000000000000000000000000000eb68e76e86fc'
}
}
test/solidity/storageDecoder.js
View file @
6e43844d
...
@@ -7,6 +7,7 @@ tape('solidity', function (t) {
...
@@ -7,6 +7,7 @@ tape('solidity', function (t) {
t
.
test
(
'storage decoder'
,
function
(
st
)
{
t
.
test
(
'storage decoder'
,
function
(
st
)
{
testIntStorage
(
st
)
testIntStorage
(
st
)
testByteStorage
(
st
)
testByteStorage
(
st
)
testStructArrayStorage
(
st
)
st
.
end
()
st
.
end
()
})
})
})
})
...
@@ -197,3 +198,15 @@ function shrinkStorage (storage) {
...
@@ -197,3 +198,15 @@ function shrinkStorage (storage) {
}
}
return
shrinkedStorage
return
shrinkedStorage
}
}
function
testStructArrayStorage
(
st
)
{
var
structArrayStorage
=
require
(
'./contracts/structArrayStorage'
)
var
output
=
compiler
.
compile
(
structArrayStorage
.
contract
,
0
)
var
decoded
=
stateDecoder
.
solidityState
(
structArrayStorage
.
storage
,
output
.
sources
,
'structArrayStorage'
)
st
.
equal
(
decoded
[
'intStructDec'
][
'i8'
],
'32'
)
st
.
equal
(
decoded
[
'intStructDec'
][
'i16'
],
'-54'
)
st
.
equal
(
decoded
[
'intStructDec'
][
'ui32'
],
'128'
)
st
.
equal
(
decoded
[
'intStructDec'
][
'i256'
],
'-1243565465756'
)
st
.
equal
(
decoded
[
'intStructDec'
][
'ui16'
],
'34556'
)
st
.
equal
(
decoded
[
'intStructDec'
][
'i32'
],
'-345446546'
)
}
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