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
acd644fd
Commit
acd644fd
authored
Jul 03, 2017
by
yann300
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add & use compareByteCode
parent
91b834b6
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
26 additions
and
1 deletion
+26
-1
sourceLocationTracker.js
src/code/sourceLocationTracker.js
+1
-1
util.js
src/helpers/util.js
+25
-0
No files found.
src/code/sourceLocationTracker.js
View file @
acd644fd
...
...
@@ -68,7 +68,7 @@ function getSourceMap (address, code, contracts) {
var
isCreation
=
helper
.
isContractCreation
(
address
)
var
byteProp
=
isCreation
?
'bytecode'
:
'runtimeBytecode'
for
(
var
k
in
contracts
)
{
if
(
contracts
[
k
][
byteProp
]
&&
code
.
replace
(
util
.
swarmHashExtraction
(),
''
).
indexOf
(
'0x'
+
contracts
[
k
][
byteProp
].
replace
(
util
.
swarmHashExtraction
(),
''
))
===
0
)
{
if
(
util
.
compareByteCode
(
code
,
'0x'
+
contracts
[
k
][
byteProp
])
)
{
return
isCreation
?
contracts
[
k
].
srcmap
:
srcmapRuntime
(
contracts
[
k
])
}
}
...
...
src/helpers/util.js
View file @
acd644fd
...
...
@@ -148,9 +148,34 @@ module.exports = {
*/
swarmHashExtraction
:
function
()
{
return
/a165627a7a72305820
([
0-9a-f
]{64})
0029$/
},
/**
* Compare bytecode. return true if the code is equal (handle swarm hash and library references)
* @param {String} code2 - the bytecode that is actually deployed (contains resolved library reference and a potentially different swarmhash)
* @param {String} code1 - the bytecode generated by the compiler (contains unresolved library reference and a potentially different swarmhash)
*
* @return {bool}
*/
compareByteCode
:
function
(
code1
,
code2
)
{
var
pos
=
-
1
while
((
pos
=
code2
.
search
(
/__
(
.*
)
__/
))
!==
-
1
)
{
code2
=
replaceLibReference
(
code2
,
pos
)
code1
=
replaceLibReference
(
code1
,
pos
)
}
code1
=
code1
.
replace
(
this
.
swarmHashExtraction
(),
''
)
code2
=
code2
.
replace
(
this
.
swarmHashExtraction
(),
''
)
if
(
code1
&&
code2
&&
code1
.
indexOf
(
code2
)
===
0
)
{
return
true
}
return
false
}
}
function
replaceLibReference
(
code
,
pos
)
{
return
code
.
substring
(
0
,
pos
)
+
'0000000000000000000000000000000000000000'
+
code
.
substring
(
pos
+
40
)
}
function
buildCallPath
(
index
,
rootCall
)
{
var
ret
=
[]
findCallInternal
(
index
,
rootCall
,
ret
)
...
...
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