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
10b5308e
Commit
10b5308e
authored
Jan 12, 2017
by
yann300
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ad extractLocatioin to util
parent
c38dc7f4
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
7 deletions
+18
-7
decodeInfo.js
src/solidity/decodeInfo.js
+7
-6
util.js
src/solidity/types/util.js
+11
-1
No files found.
src/solidity/decodeInfo.js
View file @
10b5308e
...
@@ -11,6 +11,7 @@ var StructType = require('./types/Struct')
...
@@ -11,6 +11,7 @@ var StructType = require('./types/Struct')
var
IntType
=
require
(
'./types/Int'
)
var
IntType
=
require
(
'./types/Int'
)
var
UintType
=
require
(
'./types/Uint'
)
var
UintType
=
require
(
'./types/Uint'
)
var
MappingType
=
require
(
'./types/Mapping'
)
var
MappingType
=
require
(
'./types/Mapping'
)
var
util
=
require
(
'./types/util'
)
/**
/**
* mapping decode the given @arg type
* mapping decode the given @arg type
...
@@ -73,9 +74,9 @@ function bool (type) {
...
@@ -73,9 +74,9 @@ function bool (type) {
* @return {Object} returns decoded info about the current type: { storageBytes, typeName}
* @return {Object} returns decoded info about the current type: { storageBytes, typeName}
*/
*/
function
dynamicByteArray
(
type
)
{
function
dynamicByteArray
(
type
)
{
var
match
=
type
.
match
(
/
(
storage ref| storage pointer| memory| calldata
)?
$/
)
var
location
=
util
.
extractLocation
(
type
)
if
(
match
.
length
>
1
)
{
if
(
location
)
{
return
new
BytesType
(
match
[
1
].
trim
()
)
return
new
BytesType
(
location
)
}
else
{
}
else
{
return
null
return
null
}
}
...
@@ -99,9 +100,9 @@ function fixedByteArray (type) {
...
@@ -99,9 +100,9 @@ function fixedByteArray (type) {
* @return {Object} returns decoded info about the current type: { storageBytes, typeName}
* @return {Object} returns decoded info about the current type: { storageBytes, typeName}
*/
*/
function
stringType
(
type
)
{
function
stringType
(
type
)
{
var
match
=
type
.
match
(
/
(
storage ref| storage pointer| memory| calldata
)?
$/
)
var
location
=
util
.
extractLocation
(
type
)
if
(
match
.
length
>
1
)
{
if
(
location
)
{
return
new
StringType
(
match
[
1
].
trim
()
)
return
new
StringType
(
location
)
}
else
{
}
else
{
return
null
return
null
}
}
...
...
src/solidity/types/util.js
View file @
10b5308e
...
@@ -12,7 +12,8 @@ module.exports = {
...
@@ -12,7 +12,8 @@ module.exports = {
toBN
:
toBN
,
toBN
:
toBN
,
add
:
add
,
add
:
add
,
storageStore
:
storageStore
,
storageStore
:
storageStore
,
memoryStore
:
memoryStore
memoryStore
:
memoryStore
,
extractLocation
:
extractLocation
}
}
function
decodeInt
(
location
,
storageContent
,
byteLength
,
signed
)
{
function
decodeInt
(
location
,
storageContent
,
byteLength
,
signed
)
{
...
@@ -94,6 +95,15 @@ function add (value1, value2) {
...
@@ -94,6 +95,15 @@ function add (value1, value2) {
return
toBN
(
value1
).
add
(
toBN
(
value2
))
return
toBN
(
value1
).
add
(
toBN
(
value2
))
}
}
function
extractLocation
(
type
)
{
var
match
=
type
.
match
(
/
(
storage ref| storage pointer| memory| calldata
)?
$/
)
if
(
match
[
1
]
!==
''
)
{
return
match
[
1
].
trim
()
}
else
{
return
null
}
}
function
storageStore
(
type
)
{
function
storageStore
(
type
)
{
return
type
.
location
.
indexOf
(
'storage'
)
===
0
return
type
.
location
.
indexOf
(
'storage'
)
===
0
}
}
...
...
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