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
03f9f717
Commit
03f9f717
authored
Aug 28, 2020
by
Iuri Matias
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactor codeResolver
parent
c055231b
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
21 deletions
+20
-21
codeManager.js
libs/remix-debug/src/code/codeManager.js
+10
-1
codeResolver.js
libs/remix-debug/src/code/codeResolver.js
+10
-20
No files found.
libs/remix-debug/src/code/codeManager.js
View file @
03f9f717
...
...
@@ -16,7 +16,16 @@ function CodeManager (_traceManager) {
this
.
event
=
new
EventManager
()
this
.
isLoading
=
false
this
.
traceManager
=
_traceManager
this
.
codeResolver
=
new
CodeResolver
({
web3
:
this
.
traceManager
.
web3
})
this
.
codeResolver
=
new
CodeResolver
({
getCode
:
async
(
address
)
=>
{
return
new
Promise
((
resolve
,
reject
)
=>
{
this
.
traceManager
.
web3
.
eth
.
getCode
(
address
,
(
error
,
code
)
=>
{
if
(
error
)
{
return
reject
(
error
)
}
return
resolve
(
code
)
})
})
}})
}
/**
...
...
libs/remix-debug/src/code/codeResolver.js
View file @
03f9f717
'use strict'
const
codeUtils
=
require
(
'./codeUtils'
)
function
CodeResolver
(
options
)
{
this
.
web3
=
options
.
web3
function
CodeResolver
(
{
getCode
}
)
{
this
.
getCode
=
getCode
this
.
bytecodeByAddress
=
{}
// bytes code by contract addesses
this
.
instructionsByAddress
=
{}
// assembly items instructions list by contract addesses
...
...
@@ -16,20 +16,13 @@ CodeResolver.prototype.clear = function () {
}
CodeResolver
.
prototype
.
resolveCode
=
async
function
(
address
)
{
return
new
Promise
((
resolve
,
reject
)
=>
{
const
cache
=
this
.
getExecutingCodeFromCache
(
address
)
if
(
cache
)
{
return
resolve
(
cache
)
}
const
cache
=
this
.
getExecutingCodeFromCache
(
address
)
if
(
cache
)
{
return
cache
}
this
.
web3
.
eth
.
getCode
(
address
,
(
error
,
code
)
=>
{
if
(
error
)
{
// return console.log(error)
return
reject
(
error
)
}
return
resolve
(
this
.
cacheExecutingCode
(
address
,
code
))
})
})
const
code
=
await
this
.
getCode
(
address
)
return
this
.
cacheExecutingCode
(
address
,
code
)
}
CodeResolver
.
prototype
.
cacheExecutingCode
=
function
(
address
,
hexCode
)
{
...
...
@@ -41,11 +34,8 @@ CodeResolver.prototype.cacheExecutingCode = function (address, hexCode) {
}
CodeResolver
.
prototype
.
formatCode
=
function
(
hexCode
)
{
const
code
=
codeUtils
.
nameOpCodes
(
Buffer
.
from
(
hexCode
.
substring
(
2
),
'hex'
))
return
{
code
:
code
[
0
],
instructionsIndexByBytesOffset
:
code
[
1
]
}
const
[
code
,
instructionsIndexByBytesOffset
]
=
codeUtils
.
nameOpCodes
(
Buffer
.
from
(
hexCode
.
substring
(
2
),
'hex'
))
return
{
code
,
instructionsIndexByBytesOffset
}
}
CodeResolver
.
prototype
.
getExecutingCodeFromCache
=
function
(
address
)
{
...
...
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