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
d02be3b9
Commit
d02be3b9
authored
Nov 09, 2016
by
yann300
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
simple error handling
parent
e8faaf52
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
3 deletions
+20
-3
decodeInfo.js
src/solidity/decodeInfo.js
+20
-3
No files found.
src/solidity/decodeInfo.js
View file @
d02be3b9
...
...
@@ -110,13 +110,18 @@ function ArrayType (type, stateDefinitions) {
var
storageBytes
var
match
=
type
.
match
(
/
(
.*
)\[(
.*
?)\](
storage ref| storage pointer| memory| calldata
)?
$/
)
if
(
!
match
)
{
if
(
!
match
||
match
.
length
<
3
)
{
console
.
log
(
'unable to parse type '
+
type
)
return
null
}
arraySize
=
match
[
2
]
===
''
?
'dynamic'
:
parseInt
(
match
[
2
])
var
underlyingType
=
decode
(
match
[
1
],
stateDefinitions
)
if
(
underlyingType
===
null
)
{
console
.
log
(
'unable to parse type '
+
type
)
return
null
}
if
(
arraySize
===
'dynamic'
)
{
storageBytes
=
32
...
...
@@ -146,10 +151,14 @@ function ArrayType (type, stateDefinitions) {
*/
function
Enum
(
type
,
stateDefinitions
)
{
var
enumDef
=
getEnum
(
type
,
stateDefinitions
)
if
(
enumDef
===
null
)
{
console
.
log
(
'unable to retrieve decode info of '
+
type
)
return
null
}
var
length
=
enumDef
.
children
.
length
var
storageBytes
=
0
while
(
length
>
1
)
{
length
=
length
/
25
5
length
=
length
/
25
6
storageBytes
++
}
return
{
...
...
@@ -190,7 +199,7 @@ function Struct (type, stateDefinitions) {
function
getEnum
(
type
,
stateDefinitions
)
{
for
(
var
k
in
stateDefinitions
)
{
var
dec
=
stateDefinitions
[
k
]
if
(
dec
.
name
===
'EnumDefinition'
&&
type
.
indexOf
(
'enum '
+
dec
.
attributes
.
name
)
===
0
)
{
if
(
type
===
'enum '
+
dec
.
attributes
.
name
)
{
return
dec
}
}
...
...
@@ -213,6 +222,10 @@ function getStructMembers (typeName, stateDefinitions) {
for
(
var
i
in
dec
.
children
)
{
var
member
=
dec
.
children
[
i
]
var
decoded
=
decode
(
member
.
attributes
.
type
,
stateDefinitions
)
if
(
!
decoded
)
{
console
.
log
(
'unable to retrieve decode info of '
+
member
.
attributes
.
type
)
continue
}
members
.
push
(
decoded
)
if
(
decoded
.
needsFreeStorageSlot
)
{
storageBytes
=
Math
.
ceil
(
storageBytes
/
32
)
*
32
...
...
@@ -266,6 +279,10 @@ function decode (type, stateDefinitions) {
'uint'
:
Uint
}
var
currentType
=
typeClass
(
type
)
if
(
currentType
===
null
)
{
console
.
log
(
'unable to retrieve decode info of '
+
type
)
return
null
}
return
decodeInfos
[
currentType
](
type
,
stateDefinitions
)
}
...
...
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