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
553e4b43
Commit
553e4b43
authored
Apr 19, 2017
by
yann300
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix swarm hash extraction
parent
31ec2ae9
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
20 additions
and
9 deletions
+20
-9
sourceLocationTracker.js
src/code/sourceLocationTracker.js
+2
-1
util.js
src/helpers/util.js
+16
-7
solidityProxy.js
src/solidity/solidityProxy.js
+2
-1
No files found.
src/code/sourceLocationTracker.js
View file @
553e4b43
...
@@ -2,6 +2,7 @@
...
@@ -2,6 +2,7 @@
var
EventManager
=
require
(
'../lib/eventManager'
)
var
EventManager
=
require
(
'../lib/eventManager'
)
var
helper
=
require
(
'../helpers/traceHelper'
)
var
helper
=
require
(
'../helpers/traceHelper'
)
var
SourceMappingDecoder
=
require
(
'../util/sourceMappingDecoder'
)
var
SourceMappingDecoder
=
require
(
'../util/sourceMappingDecoder'
)
var
util
=
require
(
'../helpers/util'
)
/**
/**
* Process the source code location for the current executing bytecode
* Process the source code location for the current executing bytecode
...
@@ -67,7 +68,7 @@ function getSourceMap (address, code, contracts) {
...
@@ -67,7 +68,7 @@ function getSourceMap (address, code, contracts) {
var
isCreation
=
helper
.
isContractCreation
(
address
)
var
isCreation
=
helper
.
isContractCreation
(
address
)
var
byteProp
=
isCreation
?
'bytecode'
:
'runtimeBytecode'
var
byteProp
=
isCreation
?
'bytecode'
:
'runtimeBytecode'
for
(
var
k
in
contracts
)
{
for
(
var
k
in
contracts
)
{
if
(
code
.
replace
(
/.
{64}
0029$/
,
''
).
indexOf
(
'0x'
+
contracts
[
k
][
byteProp
].
replace
(
/.
{64}
0029$/
,
''
))
===
0
)
{
if
(
code
.
replace
(
util
.
swarmHashExtraction
(),
''
).
indexOf
(
'0x'
+
contracts
[
k
][
byteProp
].
replace
(
util
.
swarmHashExtraction
()
,
''
))
===
0
)
{
return
isCreation
?
contracts
[
k
].
srcmap
:
srcmapRuntime
(
contracts
[
k
])
return
isCreation
?
contracts
[
k
].
srcmap
:
srcmapRuntime
(
contracts
[
k
])
}
}
}
}
...
...
src/helpers/util.js
View file @
553e4b43
...
@@ -117,6 +117,13 @@ module.exports = {
...
@@ -117,6 +117,13 @@ module.exports = {
*/
*/
findCall
:
findCall
,
findCall
:
findCall
,
/**
* Find calls path from @args rootCall which leads to @args index (recursive)
*
* @param {Int} index - index of the vmtrace
* @param {Object} rootCall - call tree, built by the trace analyser
* @return {Array} - return the calls path to @args index
*/
buildCallPath
:
buildCallPath
,
buildCallPath
:
buildCallPath
,
/**
/**
...
@@ -129,16 +136,18 @@ module.exports = {
...
@@ -129,16 +136,18 @@ module.exports = {
var
ret
=
ethutil
.
bufferToHex
(
ethutil
.
setLengthLeft
(
value
,
32
))
var
ret
=
ethutil
.
bufferToHex
(
ethutil
.
setLengthLeft
(
value
,
32
))
ret
=
ethutil
.
sha3
(
ret
)
ret
=
ethutil
.
sha3
(
ret
)
return
ethutil
.
bufferToHex
(
ret
)
return
ethutil
.
bufferToHex
(
ret
)
}
},
}
/**
/**
* Find calls path from @args rootCall which leads to @args index (recursive)
* return a regex which extract the swarmhash from the bytecode.
*
*
* @param {Int} index - index of the vmtrace
* @return {RegEx}
* @param {Object} rootCall - call tree, built by the trace analyser
* @return {Array} - return the calls path to @args index
*/
*/
swarmHashExtraction
:
function
()
{
return
/a165627a7a72305820
([
0-9a-f
]{64})
0029$/
}
}
function
buildCallPath
(
index
,
rootCall
)
{
function
buildCallPath
(
index
,
rootCall
)
{
var
ret
=
[]
var
ret
=
[]
findCallInternal
(
index
,
rootCall
,
ret
)
findCallInternal
(
index
,
rootCall
,
ret
)
...
...
src/solidity/solidityProxy.js
View file @
553e4b43
...
@@ -2,6 +2,7 @@
...
@@ -2,6 +2,7 @@
var
traceHelper
=
require
(
'../helpers/traceHelper'
)
var
traceHelper
=
require
(
'../helpers/traceHelper'
)
var
stateDecoder
=
require
(
'./stateDecoder'
)
var
stateDecoder
=
require
(
'./stateDecoder'
)
var
astHelper
=
require
(
'./astHelper'
)
var
astHelper
=
require
(
'./astHelper'
)
var
util
=
require
(
'../helpers/util'
)
class
SolidityProxy
{
class
SolidityProxy
{
constructor
(
traceManager
,
codeManager
)
{
constructor
(
traceManager
,
codeManager
)
{
...
@@ -136,7 +137,7 @@ function contractNameFromCode (contracts, code, address) {
...
@@ -136,7 +137,7 @@ function contractNameFromCode (contracts, code, address) {
var
isCreation
=
traceHelper
.
isContractCreation
(
address
)
var
isCreation
=
traceHelper
.
isContractCreation
(
address
)
var
byteProp
=
isCreation
?
'bytecode'
:
'runtimeBytecode'
var
byteProp
=
isCreation
?
'bytecode'
:
'runtimeBytecode'
for
(
var
k
in
contracts
)
{
for
(
var
k
in
contracts
)
{
if
(
'0x'
+
contracts
[
k
][
byteProp
].
replace
(
/.
{64}
0029$/
,
''
)
===
code
.
replace
(
/.
{64}
0029$/
,
''
))
{
if
(
'0x'
+
contracts
[
k
][
byteProp
].
replace
(
util
.
swarmHashExtraction
(),
''
)
===
code
.
replace
(
util
.
swarmHashExtraction
()
,
''
))
{
return
k
return
k
}
}
}
}
...
...
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