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
c38dc7f4
Commit
c38dc7f4
authored
Jan 12, 2017
by
yann300
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
use lowercase for function
parent
a9b3e009
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
32 additions
and
32 deletions
+32
-32
decodeInfo.js
src/solidity/decodeInfo.js
+32
-32
No files found.
src/solidity/decodeInfo.js
View file @
c38dc7f4
...
@@ -18,7 +18,7 @@ var MappingType = require('./types/Mapping')
...
@@ -18,7 +18,7 @@ var MappingType = require('./types/Mapping')
* @param {String} type - type given by the AST
* @param {String} type - type given by the AST
* @return {Object} returns decoded info about the current type: { storageBytes, typeName}
* @return {Object} returns decoded info about the current type: { storageBytes, typeName}
*/
*/
function
M
apping
(
type
)
{
function
m
apping
(
type
)
{
return
new
MappingType
()
return
new
MappingType
()
}
}
...
@@ -28,7 +28,7 @@ function Mapping (type) {
...
@@ -28,7 +28,7 @@ function Mapping (type) {
* @param {String} type - type given by the AST (e.g uint256, uint32)
* @param {String} type - type given by the AST (e.g uint256, uint32)
* @return {Object} returns decoded info about the current type: { storageBytes, typeName}
* @return {Object} returns decoded info about the current type: { storageBytes, typeName}
*/
*/
function
U
int
(
type
)
{
function
u
int
(
type
)
{
type
===
'uint'
?
'uint256'
:
type
type
===
'uint'
?
'uint256'
:
type
var
storageBytes
=
parseInt
(
type
.
replace
(
'uint'
,
''
))
/
8
var
storageBytes
=
parseInt
(
type
.
replace
(
'uint'
,
''
))
/
8
return
new
UintType
(
storageBytes
)
return
new
UintType
(
storageBytes
)
...
@@ -40,7 +40,7 @@ function Uint (type) {
...
@@ -40,7 +40,7 @@ function Uint (type) {
* @param {String} type - type given by the AST (e.g int256, int32)
* @param {String} type - type given by the AST (e.g int256, int32)
* @return {Object} returns decoded info about the current type: { storageBytes, typeName}
* @return {Object} returns decoded info about the current type: { storageBytes, typeName}
*/
*/
function
I
nt
(
type
)
{
function
i
nt
(
type
)
{
type
===
'int'
?
'int256'
:
type
type
===
'int'
?
'int256'
:
type
var
storageBytes
=
parseInt
(
type
.
replace
(
'int'
,
''
))
/
8
var
storageBytes
=
parseInt
(
type
.
replace
(
'int'
,
''
))
/
8
return
new
IntType
(
storageBytes
)
return
new
IntType
(
storageBytes
)
...
@@ -52,7 +52,7 @@ function Int (type) {
...
@@ -52,7 +52,7 @@ function Int (type) {
* @param {String} type - type given by the AST (e.g address)
* @param {String} type - type given by the AST (e.g address)
* @return {Object} returns decoded info about the current type: { storageBytes, typeName}
* @return {Object} returns decoded info about the current type: { storageBytes, typeName}
*/
*/
function
A
ddress
(
type
)
{
function
a
ddress
(
type
)
{
return
new
AddressType
()
return
new
AddressType
()
}
}
...
@@ -62,7 +62,7 @@ function Address (type) {
...
@@ -62,7 +62,7 @@ function Address (type) {
* @param {String} type - type given by the AST (e.g bool)
* @param {String} type - type given by the AST (e.g bool)
* @return {Object} returns decoded info about the current type: { storageBytes, typeName}
* @return {Object} returns decoded info about the current type: { storageBytes, typeName}
*/
*/
function
B
ool
(
type
)
{
function
b
ool
(
type
)
{
return
new
BoolType
()
return
new
BoolType
()
}
}
...
@@ -72,7 +72,7 @@ function Bool (type) {
...
@@ -72,7 +72,7 @@ function Bool (type) {
* @param {String} type - type given by the AST (e.g bytes storage ref)
* @param {String} type - type given by the AST (e.g bytes storage ref)
* @return {Object} returns decoded info about the current type: { storageBytes, typeName}
* @return {Object} returns decoded info about the current type: { storageBytes, typeName}
*/
*/
function
D
ynamicByteArray
(
type
)
{
function
d
ynamicByteArray
(
type
)
{
var
match
=
type
.
match
(
/
(
storage ref| storage pointer| memory| calldata
)?
$/
)
var
match
=
type
.
match
(
/
(
storage ref| storage pointer| memory| calldata
)?
$/
)
if
(
match
.
length
>
1
)
{
if
(
match
.
length
>
1
)
{
return
new
BytesType
(
match
[
1
].
trim
())
return
new
BytesType
(
match
[
1
].
trim
())
...
@@ -87,7 +87,7 @@ function DynamicByteArray (type) {
...
@@ -87,7 +87,7 @@ function DynamicByteArray (type) {
* @param {String} type - type given by the AST (e.g bytes16)
* @param {String} type - type given by the AST (e.g bytes16)
* @return {Object} returns decoded info about the current type: { storageBytes, typeName}
* @return {Object} returns decoded info about the current type: { storageBytes, typeName}
*/
*/
function
F
ixedByteArray
(
type
)
{
function
f
ixedByteArray
(
type
)
{
var
storageBytes
=
parseInt
(
type
.
replace
(
'bytes'
,
''
))
var
storageBytes
=
parseInt
(
type
.
replace
(
'bytes'
,
''
))
return
new
BytesXType
(
storageBytes
)
return
new
BytesXType
(
storageBytes
)
}
}
...
@@ -98,7 +98,7 @@ function FixedByteArray (type) {
...
@@ -98,7 +98,7 @@ function FixedByteArray (type) {
* @param {String} type - type given by the AST (e.g string storage ref)
* @param {String} type - type given by the AST (e.g string storage ref)
* @return {Object} returns decoded info about the current type: { storageBytes, typeName}
* @return {Object} returns decoded info about the current type: { storageBytes, typeName}
*/
*/
function
String
(
type
)
{
function
stringType
(
type
)
{
var
match
=
type
.
match
(
/
(
storage ref| storage pointer| memory| calldata
)?
$/
)
var
match
=
type
.
match
(
/
(
storage ref| storage pointer| memory| calldata
)?
$/
)
if
(
match
.
length
>
1
)
{
if
(
match
.
length
>
1
)
{
return
new
StringType
(
match
[
1
].
trim
())
return
new
StringType
(
match
[
1
].
trim
())
...
@@ -115,7 +115,7 @@ function String (type) {
...
@@ -115,7 +115,7 @@ function String (type) {
* @param {String} contractName - contract the @args typeName belongs to
* @param {String} contractName - contract the @args typeName belongs to
* @return {Object} returns decoded info about the current type: { storageBytes, typeName, arraySize, subArray}
* @return {Object} returns decoded info about the current type: { storageBytes, typeName, arraySize, subArray}
*/
*/
function
A
rray
(
type
,
stateDefinitions
,
contractName
)
{
function
a
rray
(
type
,
stateDefinitions
,
contractName
)
{
var
arraySize
var
arraySize
var
match
=
type
.
match
(
/
(
.*
)\[(
.*
?)\](
storage ref| storage pointer| memory| calldata
)?
$/
)
var
match
=
type
.
match
(
/
(
.*
)\[(
.*
?)\](
storage ref| storage pointer| memory| calldata
)?
$/
)
if
(
!
match
||
match
.
length
<
3
)
{
if
(
!
match
||
match
.
length
<
3
)
{
...
@@ -140,7 +140,7 @@ function Array (type, stateDefinitions, contractName) {
...
@@ -140,7 +140,7 @@ function Array (type, stateDefinitions, contractName) {
* @param {String} contractName - contract the @args typeName belongs to
* @param {String} contractName - contract the @args typeName belongs to
* @return {Object} returns decoded info about the current type: { storageBytes, typeName, enum}
* @return {Object} returns decoded info about the current type: { storageBytes, typeName, enum}
*/
*/
function
Enum
(
type
,
stateDefinitions
,
contractName
)
{
function
enumType
(
type
,
stateDefinitions
,
contractName
)
{
var
match
=
type
.
match
(
/enum
(
.*
)
/
)
var
match
=
type
.
match
(
/enum
(
.*
)
/
)
var
enumDef
=
getEnum
(
match
[
1
],
stateDefinitions
,
contractName
)
var
enumDef
=
getEnum
(
match
[
1
],
stateDefinitions
,
contractName
)
if
(
enumDef
===
null
)
{
if
(
enumDef
===
null
)
{
...
@@ -158,7 +158,7 @@ function Enum (type, stateDefinitions, contractName) {
...
@@ -158,7 +158,7 @@ function Enum (type, stateDefinitions, contractName) {
* @param {String} contractName - contract the @args typeName belongs to
* @param {String} contractName - contract the @args typeName belongs to
* @return {Object} returns decoded info about the current type: { storageBytes, typeName, members}
* @return {Object} returns decoded info about the current type: { storageBytes, typeName, members}
*/
*/
function
S
truct
(
type
,
stateDefinitions
,
contractName
)
{
function
s
truct
(
type
,
stateDefinitions
,
contractName
)
{
var
match
=
type
.
match
(
/struct
(
.*
?)(
storage ref| storage pointer| memory| calldata
)?
$/
)
var
match
=
type
.
match
(
/struct
(
.*
?)(
storage ref| storage pointer| memory| calldata
)?
$/
)
if
(
match
&&
match
.
length
>
2
)
{
if
(
match
&&
match
.
length
>
2
)
{
var
memberDetails
=
getStructMembers
(
match
[
1
],
stateDefinitions
,
contractName
)
// type is used to extract the ast struct definition
var
memberDetails
=
getStructMembers
(
match
[
1
],
stateDefinitions
,
contractName
)
// type is used to extract the ast struct definition
...
@@ -255,17 +255,17 @@ function typeClass (fullType) {
...
@@ -255,17 +255,17 @@ function typeClass (fullType) {
*/
*/
function
parseType
(
type
,
stateDefinitions
,
contractName
)
{
function
parseType
(
type
,
stateDefinitions
,
contractName
)
{
var
decodeInfos
=
{
var
decodeInfos
=
{
'address'
:
A
ddress
,
'address'
:
a
ddress
,
'array'
:
A
rray
,
'array'
:
a
rray
,
'bool'
:
B
ool
,
'bool'
:
b
ool
,
'bytes'
:
D
ynamicByteArray
,
'bytes'
:
d
ynamicByteArray
,
'bytesX'
:
F
ixedByteArray
,
'bytesX'
:
f
ixedByteArray
,
'enum'
:
Enum
,
'enum'
:
enumType
,
'string'
:
String
,
'string'
:
stringType
,
'struct'
:
S
truct
,
'struct'
:
s
truct
,
'int'
:
I
nt
,
'int'
:
i
nt
,
'uint'
:
U
int
,
'uint'
:
u
int
,
'mapping'
:
M
apping
'mapping'
:
m
apping
}
}
var
currentType
=
typeClass
(
type
)
var
currentType
=
typeClass
(
type
)
if
(
currentType
===
null
)
{
if
(
currentType
===
null
)
{
...
@@ -327,14 +327,14 @@ function computeOffsets (types, stateDefinitions, contractName) {
...
@@ -327,14 +327,14 @@ function computeOffsets (types, stateDefinitions, contractName) {
module
.
exports
=
{
module
.
exports
=
{
parseType
:
parseType
,
parseType
:
parseType
,
computeOffsets
:
computeOffsets
,
computeOffsets
:
computeOffsets
,
Uint
:
U
int
,
Uint
:
u
int
,
Address
:
A
ddress
,
Address
:
a
ddress
,
Bool
:
B
ool
,
Bool
:
b
ool
,
DynamicByteArray
:
D
ynamicByteArray
,
DynamicByteArray
:
d
ynamicByteArray
,
FixedByteArray
:
F
ixedByteArray
,
FixedByteArray
:
f
ixedByteArray
,
Int
:
I
nt
,
Int
:
i
nt
,
String
:
String
,
String
:
stringType
,
Array
:
A
rray
,
Array
:
a
rray
,
Enum
:
Enum
,
Enum
:
enumType
,
Struct
:
S
truct
Struct
:
s
truct
}
}
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