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
abc5a479
Commit
abc5a479
authored
Jan 12, 2017
by
yann300
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
rename decode -> decodeFromMemory
parent
4c09db37
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
26 additions
and
41 deletions
+26
-41
ArrayType.js
src/solidity/types/ArrayType.js
+2
-2
DynamicByteArray.js
src/solidity/types/DynamicByteArray.js
+1
-1
RefType.js
src/solidity/types/RefType.js
+19
-23
StringType.js
src/solidity/types/StringType.js
+2
-2
Struct.js
src/solidity/types/Struct.js
+2
-2
ValueType.js
src/solidity/types/ValueType.js
+0
-11
No files found.
src/solidity/types/ArrayType.js
View file @
abc5a479
...
@@ -56,7 +56,7 @@ class ArrayType extends RefType {
...
@@ -56,7 +56,7 @@ class ArrayType extends RefType {
}
}
}
}
decodeFromMemory
(
offset
,
memory
)
{
decodeFromMemory
Internal
(
offset
,
memory
)
{
var
ret
=
[]
var
ret
=
[]
var
length
=
this
.
arraySize
var
length
=
this
.
arraySize
if
(
this
.
arraySize
===
'dynamic'
)
{
if
(
this
.
arraySize
===
'dynamic'
)
{
...
@@ -66,7 +66,7 @@ class ArrayType extends RefType {
...
@@ -66,7 +66,7 @@ class ArrayType extends RefType {
}
}
for
(
var
k
=
0
;
k
<
length
;
k
++
)
{
for
(
var
k
=
0
;
k
<
length
;
k
++
)
{
var
contentOffset
=
offset
var
contentOffset
=
offset
ret
.
push
(
this
.
underlyingType
.
decode
(
contentOffset
,
memory
))
ret
.
push
(
this
.
underlyingType
.
decode
FromMemory
(
contentOffset
,
memory
))
offset
+=
32
offset
+=
32
}
}
return
ret
return
ret
...
...
src/solidity/types/DynamicByteArray.js
View file @
abc5a479
...
@@ -35,7 +35,7 @@ class DynamicByteArray extends RefType {
...
@@ -35,7 +35,7 @@ class DynamicByteArray extends RefType {
}
}
}
}
decodeFromMemory
(
offset
,
memory
)
{
decodeFromMemory
Internal
(
offset
,
memory
)
{
offset
=
2
*
offset
offset
=
2
*
offset
var
length
=
memory
.
substr
(
offset
,
64
)
var
length
=
memory
.
substr
(
offset
,
64
)
length
=
2
*
parseInt
(
length
,
16
)
length
=
2
*
parseInt
(
length
,
16
)
...
...
src/solidity/types/RefType.js
View file @
abc5a479
...
@@ -14,29 +14,39 @@ class RefType {
...
@@ -14,29 +14,39 @@ class RefType {
*
*
* @param {Int} stackDepth - position of the type in the stack
* @param {Int} stackDepth - position of the type in the stack
* @param {Array} stack - stack
* @param {Array} stack - stack
* @return {String} - memory
* @param {String} - memory
* @return {Object} - storage
* @param {Object} - storage
* @return {Object} decoded value
*/
*/
decodeFromStack
(
stackDepth
,
stack
,
memory
,
storage
)
{
decodeFromStack
(
stackDepth
,
stack
,
memory
,
storage
)
{
if
(
stack
.
length
-
1
<
stackDepth
)
{
if
(
stack
.
length
-
1
<
stackDepth
)
{
return
{
error
:
'<decoding failed - stack underflow '
+
stackDepth
+
'>'
}
return
{
error
:
'<decoding failed - stack underflow '
+
stackDepth
+
'>'
}
}
}
if
(
!
storage
)
{
storage
=
{}
// TODO this is a fallback, should manage properly locals store in storage
}
var
offset
=
stack
[
stack
.
length
-
1
-
stackDepth
]
var
offset
=
stack
[
stack
.
length
-
1
-
stackDepth
]
offset
=
parseInt
(
offset
,
16
)
offset
=
parseInt
(
offset
,
16
)
return
decodeInternal
(
this
,
offset
,
memory
,
storage
)
if
(
this
.
storageStore
())
{
return
this
.
decodeFromStorage
({
offset
:
0
,
slot
:
offset
},
storage
)
}
else
if
(
this
.
memoryStore
())
{
return
this
.
decodeFromMemoryInternal
(
offset
,
memory
)
}
else
{
return
{
error
:
'<decoding failed - no decoder for '
+
this
.
location
+
'>'
}
}
}
}
/**
/**
* decode the type
with the @arg offset location from the memory or storage
* decode the type
from the memory
*
*
* @param {Int} offset - position of the
type in the
memory
* @param {Int} offset - position of the
ref of the type in
memory
* @
return {String}
- memory
* @
param {String} memory
- memory
* @return {Object}
- storag
e
* @return {Object}
decoded valu
e
*/
*/
decode
(
offset
,
memory
,
storage
)
{
decode
FromMemory
(
offset
,
memory
)
{
offset
=
memory
.
substr
(
2
*
offset
,
64
)
offset
=
memory
.
substr
(
2
*
offset
,
64
)
offset
=
parseInt
(
offset
,
16
)
offset
=
parseInt
(
offset
,
16
)
return
decodeInternal
(
this
,
offset
,
memory
,
storage
)
return
this
.
decodeFromMemoryInternal
(
offset
,
memory
)
}
}
/**
/**
...
@@ -56,20 +66,6 @@ class RefType {
...
@@ -56,20 +66,6 @@ class RefType {
memoryStore
()
{
memoryStore
()
{
return
this
.
location
.
indexOf
(
'memory'
)
===
0
return
this
.
location
.
indexOf
(
'memory'
)
===
0
}
}
}
function
decodeInternal
(
self
,
offset
,
memory
,
storage
)
{
if
(
!
storage
)
{
storage
=
{}
// TODO this is a fallback, should manage properly locals store in storage
}
if
(
self
.
storageStore
())
{
return
self
.
decodeFromStorage
({
offset
:
0
,
slot
:
offset
},
storage
)
}
else
if
(
self
.
memoryStore
())
{
return
self
.
decodeFromMemory
(
offset
,
memory
)
}
else
{
return
{
error
:
'<decoding failed - no decoder for '
+
self
.
location
+
'>'
}
}
}
}
module
.
exports
=
RefType
module
.
exports
=
RefType
src/solidity/types/StringType.js
View file @
abc5a479
...
@@ -16,8 +16,8 @@ class StringType extends DynamicBytes {
...
@@ -16,8 +16,8 @@ class StringType extends DynamicBytes {
return
super
.
decodeFromStack
(
stackDepth
,
stack
,
memory
)
return
super
.
decodeFromStack
(
stackDepth
,
stack
,
memory
)
}
}
decodeFromMemory
(
offset
,
memory
)
{
decodeFromMemory
Internal
(
offset
,
memory
)
{
var
decoded
=
super
.
decodeFromMemory
(
offset
,
memory
)
var
decoded
=
super
.
decodeFromMemory
Internal
(
offset
,
memory
)
return
format
(
decoded
)
return
format
(
decoded
)
}
}
}
}
...
...
src/solidity/types/Struct.js
View file @
abc5a479
...
@@ -20,11 +20,11 @@ class Struct extends RefType {
...
@@ -20,11 +20,11 @@ class Struct extends RefType {
return
ret
return
ret
}
}
decodeFromMemory
(
offset
,
memory
)
{
decodeFromMemory
Internal
(
offset
,
memory
)
{
var
ret
=
{}
var
ret
=
{}
this
.
members
.
map
((
item
,
i
)
=>
{
this
.
members
.
map
((
item
,
i
)
=>
{
var
contentOffset
=
offset
var
contentOffset
=
offset
var
member
=
item
.
type
.
decode
(
contentOffset
,
memory
)
var
member
=
item
.
type
.
decode
FromMemory
(
contentOffset
,
memory
)
ret
[
item
.
name
]
=
member
ret
[
item
.
name
]
=
member
offset
+=
32
offset
+=
32
})
})
...
...
src/solidity/types/ValueType.js
View file @
abc5a479
...
@@ -48,17 +48,6 @@ class ValueType {
...
@@ -48,17 +48,6 @@ class ValueType {
var
value
=
memory
.
substr
(
2
*
offset
,
64
)
var
value
=
memory
.
substr
(
2
*
offset
,
64
)
return
this
.
decodeValue
(
util
.
extractHexByteSlice
(
value
,
this
.
storageBytes
,
0
))
return
this
.
decodeValue
(
util
.
extractHexByteSlice
(
value
,
this
.
storageBytes
,
0
))
}
}
/**
* decode the type with the @arg offset location from the memory
*
* @param {Int} offset - position of the type in the memory
* @return {String} - memory
* @return {Object} - storage
*/
decode
(
offset
,
memory
)
{
return
this
.
decodeFromMemory
(
offset
,
memory
)
}
}
}
module
.
exports
=
ValueType
module
.
exports
=
ValueType
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