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
d53d2ad3
Commit
d53d2ad3
authored
Nov 14, 2016
by
yann300
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
rename decode -> parseType
parent
5b06c33d
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
20 additions
and
20 deletions
+20
-20
decodeInfo.js
src/solidity/decodeInfo.js
+2
-2
stateDecoder.js
src/solidity/stateDecoder.js
+1
-1
decodeInfo.js
test/solidity/decodeInfo.js
+17
-17
No files found.
src/solidity/decodeInfo.js
View file @
d53d2ad3
...
@@ -263,7 +263,7 @@ function typeClass (fullType) {
...
@@ -263,7 +263,7 @@ function typeClass (fullType) {
* @param {Object} stateDefinitions - all state stateDefinitions given by the AST (including struct and enum type declaration)
* @param {Object} stateDefinitions - all state stateDefinitions given by the AST (including struct and enum type declaration)
* @return {Object} - return the corresponding decoder or null on error
* @return {Object} - return the corresponding decoder or null on error
*/
*/
function
decod
e
(
type
,
stateDefinitions
)
{
function
parseTyp
e
(
type
,
stateDefinitions
)
{
var
decodeInfos
=
{
var
decodeInfos
=
{
'address'
:
Address
,
'address'
:
Address
,
'array'
:
ArrayType
,
'array'
:
ArrayType
,
...
@@ -285,7 +285,7 @@ function decode (type, stateDefinitions) {
...
@@ -285,7 +285,7 @@ function decode (type, stateDefinitions) {
}
}
module
.
exports
=
{
module
.
exports
=
{
decode
:
decod
e
,
decode
:
parseTyp
e
,
Uint
:
Uint
,
Uint
:
Uint
,
Address
:
Address
,
Address
:
Address
,
Bool
:
Bool
,
Bool
:
Bool
,
...
...
src/solidity/stateDecoder.js
View file @
d53d2ad3
...
@@ -41,7 +41,7 @@ function extractStateVariables (contractName, sourcesList) {
...
@@ -41,7 +41,7 @@ function extractStateVariables (contractName, sourcesList) {
for
(
var
k
in
stateDefinitions
)
{
for
(
var
k
in
stateDefinitions
)
{
var
variable
=
stateDefinitions
[
k
]
var
variable
=
stateDefinitions
[
k
]
if
(
variable
.
name
===
'VariableDeclaration'
)
{
if
(
variable
.
name
===
'VariableDeclaration'
)
{
var
decoded
=
decodeInfo
.
decod
e
(
variable
.
attributes
.
type
,
stateDefinitions
)
var
decoded
=
decodeInfo
.
parseTyp
e
(
variable
.
attributes
.
type
,
stateDefinitions
)
var
type
=
new
types
[
decoded
.
typeName
](
decoded
)
var
type
=
new
types
[
decoded
.
typeName
](
decoded
)
if
(
location
.
offset
+
type
.
storageBytes
>
32
)
{
if
(
location
.
offset
+
type
.
storageBytes
>
32
)
{
location
.
slot
++
location
.
slot
++
...
...
test/solidity/decodeInfo.js
View file @
d53d2ad3
...
@@ -9,47 +9,47 @@ tape('solidity', function (t) {
...
@@ -9,47 +9,47 @@ tape('solidity', function (t) {
var
output
=
compiler
.
compile
(
contracts
,
0
)
var
output
=
compiler
.
compile
(
contracts
,
0
)
var
stateDec
=
index
.
solidity
.
astHelper
.
extractStateVariables
(
'contractUint'
,
output
.
sources
)
var
stateDec
=
index
.
solidity
.
astHelper
.
extractStateVariables
(
'contractUint'
,
output
.
sources
)
var
decodeInfo
=
index
.
solidity
.
decodeInfo
.
decod
e
(
stateDec
[
0
].
attributes
.
type
,
stateDec
)
var
decodeInfo
=
index
.
solidity
.
decodeInfo
.
parseTyp
e
(
stateDec
[
0
].
attributes
.
type
,
stateDec
)
checkDecodeInfo
(
st
,
decodeInfo
,
1
,
1
,
'uint'
)
checkDecodeInfo
(
st
,
decodeInfo
,
1
,
1
,
'uint'
)
decodeInfo
=
index
.
solidity
.
decodeInfo
.
decod
e
(
stateDec
[
2
].
attributes
.
type
,
stateDec
)
decodeInfo
=
index
.
solidity
.
decodeInfo
.
parseTyp
e
(
stateDec
[
2
].
attributes
.
type
,
stateDec
)
checkDecodeInfo
(
st
,
decodeInfo
,
1
,
32
,
'uint'
)
checkDecodeInfo
(
st
,
decodeInfo
,
1
,
32
,
'uint'
)
decodeInfo
=
index
.
solidity
.
decodeInfo
.
decod
e
(
stateDec
[
3
].
attributes
.
type
,
stateDec
)
decodeInfo
=
index
.
solidity
.
decodeInfo
.
parseTyp
e
(
stateDec
[
3
].
attributes
.
type
,
stateDec
)
checkDecodeInfo
(
st
,
decodeInfo
,
1
,
32
,
'uint'
)
checkDecodeInfo
(
st
,
decodeInfo
,
1
,
32
,
'uint'
)
decodeInfo
=
index
.
solidity
.
decodeInfo
.
decod
e
(
stateDec
[
4
].
attributes
.
type
,
stateDec
)
decodeInfo
=
index
.
solidity
.
decodeInfo
.
parseTyp
e
(
stateDec
[
4
].
attributes
.
type
,
stateDec
)
checkDecodeInfo
(
st
,
decodeInfo
,
1
,
16
,
'bytesX'
)
checkDecodeInfo
(
st
,
decodeInfo
,
1
,
16
,
'bytesX'
)
stateDec
=
index
.
solidity
.
astHelper
.
extractStateVariables
(
'contractStructAndArray'
,
output
.
sources
)
stateDec
=
index
.
solidity
.
astHelper
.
extractStateVariables
(
'contractStructAndArray'
,
output
.
sources
)
decodeInfo
=
index
.
solidity
.
decodeInfo
.
decod
e
(
stateDec
[
1
].
attributes
.
type
,
stateDec
)
decodeInfo
=
index
.
solidity
.
decodeInfo
.
parseTyp
e
(
stateDec
[
1
].
attributes
.
type
,
stateDec
)
checkDecodeInfo
(
st
,
decodeInfo
,
2
,
32
,
'struct'
)
checkDecodeInfo
(
st
,
decodeInfo
,
2
,
32
,
'struct'
)
decodeInfo
=
index
.
solidity
.
decodeInfo
.
decod
e
(
stateDec
[
2
].
attributes
.
type
,
stateDec
)
decodeInfo
=
index
.
solidity
.
decodeInfo
.
parseTyp
e
(
stateDec
[
2
].
attributes
.
type
,
stateDec
)
checkDecodeInfo
(
st
,
decodeInfo
,
6
,
32
,
'array'
)
checkDecodeInfo
(
st
,
decodeInfo
,
6
,
32
,
'array'
)
decodeInfo
=
index
.
solidity
.
decodeInfo
.
decod
e
(
stateDec
[
3
].
attributes
.
type
,
stateDec
)
decodeInfo
=
index
.
solidity
.
decodeInfo
.
parseTyp
e
(
stateDec
[
3
].
attributes
.
type
,
stateDec
)
checkDecodeInfo
(
st
,
decodeInfo
,
2
,
32
,
'array'
)
checkDecodeInfo
(
st
,
decodeInfo
,
2
,
32
,
'array'
)
stateDec
=
index
.
solidity
.
astHelper
.
extractStateVariables
(
'contractArray'
,
output
.
sources
)
stateDec
=
index
.
solidity
.
astHelper
.
extractStateVariables
(
'contractArray'
,
output
.
sources
)
decodeInfo
=
index
.
solidity
.
decodeInfo
.
decod
e
(
stateDec
[
0
].
attributes
.
type
,
stateDec
)
decodeInfo
=
index
.
solidity
.
decodeInfo
.
parseTyp
e
(
stateDec
[
0
].
attributes
.
type
,
stateDec
)
checkDecodeInfo
(
st
,
decodeInfo
,
1
,
32
,
'array'
)
checkDecodeInfo
(
st
,
decodeInfo
,
1
,
32
,
'array'
)
decodeInfo
=
index
.
solidity
.
decodeInfo
.
decod
e
(
stateDec
[
1
].
attributes
.
type
,
stateDec
)
decodeInfo
=
index
.
solidity
.
decodeInfo
.
parseTyp
e
(
stateDec
[
1
].
attributes
.
type
,
stateDec
)
checkDecodeInfo
(
st
,
decodeInfo
,
1
,
32
,
'array'
)
checkDecodeInfo
(
st
,
decodeInfo
,
1
,
32
,
'array'
)
decodeInfo
=
index
.
solidity
.
decodeInfo
.
decod
e
(
stateDec
[
2
].
attributes
.
type
,
stateDec
)
decodeInfo
=
index
.
solidity
.
decodeInfo
.
parseTyp
e
(
stateDec
[
2
].
attributes
.
type
,
stateDec
)
checkDecodeInfo
(
st
,
decodeInfo
,
4
,
32
,
'array'
)
checkDecodeInfo
(
st
,
decodeInfo
,
4
,
32
,
'array'
)
stateDec
=
index
.
solidity
.
astHelper
.
extractStateVariables
(
'contractEnum'
,
output
.
sources
)
stateDec
=
index
.
solidity
.
astHelper
.
extractStateVariables
(
'contractEnum'
,
output
.
sources
)
decodeInfo
=
index
.
solidity
.
decodeInfo
.
decod
e
(
stateDec
[
1
].
attributes
.
type
,
stateDec
)
decodeInfo
=
index
.
solidity
.
decodeInfo
.
parseTyp
e
(
stateDec
[
1
].
attributes
.
type
,
stateDec
)
checkDecodeInfo
(
st
,
decodeInfo
,
1
,
2
,
'enum'
)
checkDecodeInfo
(
st
,
decodeInfo
,
1
,
2
,
'enum'
)
stateDec
=
index
.
solidity
.
astHelper
.
extractStateVariables
(
'contractSmallVariable'
,
output
.
sources
)
stateDec
=
index
.
solidity
.
astHelper
.
extractStateVariables
(
'contractSmallVariable'
,
output
.
sources
)
decodeInfo
=
index
.
solidity
.
decodeInfo
.
decod
e
(
stateDec
[
0
].
attributes
.
type
,
stateDec
)
decodeInfo
=
index
.
solidity
.
decodeInfo
.
parseTyp
e
(
stateDec
[
0
].
attributes
.
type
,
stateDec
)
checkDecodeInfo
(
st
,
decodeInfo
,
1
,
1
,
'int'
)
checkDecodeInfo
(
st
,
decodeInfo
,
1
,
1
,
'int'
)
decodeInfo
=
index
.
solidity
.
decodeInfo
.
decod
e
(
stateDec
[
1
].
attributes
.
type
,
stateDec
)
decodeInfo
=
index
.
solidity
.
decodeInfo
.
parseTyp
e
(
stateDec
[
1
].
attributes
.
type
,
stateDec
)
checkDecodeInfo
(
st
,
decodeInfo
,
1
,
1
,
'uint'
)
checkDecodeInfo
(
st
,
decodeInfo
,
1
,
1
,
'uint'
)
decodeInfo
=
index
.
solidity
.
decodeInfo
.
decod
e
(
stateDec
[
2
].
attributes
.
type
,
stateDec
)
decodeInfo
=
index
.
solidity
.
decodeInfo
.
parseTyp
e
(
stateDec
[
2
].
attributes
.
type
,
stateDec
)
checkDecodeInfo
(
st
,
decodeInfo
,
1
,
2
,
'uint'
)
checkDecodeInfo
(
st
,
decodeInfo
,
1
,
2
,
'uint'
)
decodeInfo
=
index
.
solidity
.
decodeInfo
.
decod
e
(
stateDec
[
3
].
attributes
.
type
,
stateDec
)
decodeInfo
=
index
.
solidity
.
decodeInfo
.
parseTyp
e
(
stateDec
[
3
].
attributes
.
type
,
stateDec
)
checkDecodeInfo
(
st
,
decodeInfo
,
1
,
4
,
'int'
)
checkDecodeInfo
(
st
,
decodeInfo
,
1
,
4
,
'int'
)
decodeInfo
=
index
.
solidity
.
decodeInfo
.
decod
e
(
stateDec
[
4
].
attributes
.
type
,
stateDec
)
decodeInfo
=
index
.
solidity
.
decodeInfo
.
parseTyp
e
(
stateDec
[
4
].
attributes
.
type
,
stateDec
)
checkDecodeInfo
(
st
,
decodeInfo
,
1
,
32
,
'uint'
)
checkDecodeInfo
(
st
,
decodeInfo
,
1
,
32
,
'uint'
)
decodeInfo
=
index
.
solidity
.
decodeInfo
.
decod
e
(
stateDec
[
5
].
attributes
.
type
,
stateDec
)
decodeInfo
=
index
.
solidity
.
decodeInfo
.
parseTyp
e
(
stateDec
[
5
].
attributes
.
type
,
stateDec
)
checkDecodeInfo
(
st
,
decodeInfo
,
1
,
2
,
'int'
)
checkDecodeInfo
(
st
,
decodeInfo
,
1
,
2
,
'int'
)
st
.
end
()
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