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
162f5bb2
Unverified
Commit
162f5bb2
authored
Jun 23, 2020
by
yann300
Committed by
GitHub
Jun 23, 2020
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1497 from ethereum/resolveContract
build a contract object instead of referencing contract by name
parents
1f41096a
c338216f
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
25 additions
and
25 deletions
+25
-25
txListener.js
remix-lib/src/execution/txListener.js
+25
-25
No files found.
remix-lib/src/execution/txListener.js
View file @
162f5bb2
...
...
@@ -181,7 +181,8 @@ class TxListener {
* @return {String} - contract name
*/
resolvedContract
(
address
)
{
return
this
.
_resolvedContracts
[
address
]
if
(
this
.
_resolvedContracts
[
address
])
return
this
.
_resolvedContracts
[
address
].
name
return
null
}
/**
...
...
@@ -222,54 +223,53 @@ class TxListener {
_resolveTx
(
tx
,
receipt
,
cb
)
{
const
contracts
=
this
.
_api
.
contracts
()
if
(
!
contracts
)
return
cb
()
let
contractName
let
fun
let
contract
if
(
!
tx
.
to
||
tx
.
to
===
'0x0'
)
{
// testrpc returns 0x0 in that case
// contract creation / resolve using the creation bytes code
// if web3: we have to call getTransactionReceipt to get the created address
// if VM: created address already included
const
code
=
tx
.
input
contract
Name
=
this
.
_tryResolveContract
(
code
,
contracts
,
true
)
if
(
contract
Name
)
{
contract
=
this
.
_tryResolveContract
(
code
,
contracts
,
true
)
if
(
contract
)
{
let
address
=
receipt
.
contractAddress
this
.
_resolvedContracts
[
address
]
=
contract
Name
fun
=
this
.
_resolveFunction
(
contract
Name
,
contracts
,
tx
,
true
)
this
.
_resolvedContracts
[
address
]
=
contract
fun
=
this
.
_resolveFunction
(
contract
,
tx
,
true
)
if
(
this
.
_resolvedTransactions
[
tx
.
hash
])
{
this
.
_resolvedTransactions
[
tx
.
hash
].
contractAddress
=
address
}
return
cb
(
null
,
{
to
:
null
,
contractName
:
contract
N
ame
,
function
:
fun
,
creationAddress
:
address
})
return
cb
(
null
,
{
to
:
null
,
contractName
:
contract
.
n
ame
,
function
:
fun
,
creationAddress
:
address
})
}
return
cb
()
}
else
{
// first check known contract, resolve against the `runtimeBytecode` if not known
contract
Name
=
this
.
_resolvedContracts
[
tx
.
to
]
if
(
!
contract
Name
)
{
contract
=
this
.
_resolvedContracts
[
tx
.
to
]
if
(
!
contract
)
{
this
.
executionContext
.
web3
().
eth
.
getCode
(
tx
.
to
,
(
error
,
code
)
=>
{
if
(
error
)
return
cb
(
error
)
if
(
code
)
{
const
contract
Name
=
this
.
_tryResolveContract
(
code
,
contracts
,
false
)
if
(
contract
Name
)
{
this
.
_resolvedContracts
[
tx
.
to
]
=
contract
Name
const
fun
=
this
.
_resolveFunction
(
contract
Name
,
contracts
,
tx
,
false
)
return
cb
(
null
,
{
to
:
tx
.
to
,
contractName
:
contract
N
ame
,
function
:
fun
})
const
contract
=
this
.
_tryResolveContract
(
code
,
contracts
,
false
)
if
(
contract
)
{
this
.
_resolvedContracts
[
tx
.
to
]
=
contract
const
fun
=
this
.
_resolveFunction
(
contract
,
tx
,
false
)
return
cb
(
null
,
{
to
:
tx
.
to
,
contractName
:
contract
.
n
ame
,
function
:
fun
})
}
}
return
cb
()
})
return
}
if
(
contract
Name
)
{
fun
=
this
.
_resolveFunction
(
contract
Name
,
contracts
,
tx
,
false
)
return
cb
(
null
,
{
to
:
tx
.
to
,
contractName
:
contract
N
ame
,
function
:
fun
})
if
(
contract
)
{
fun
=
this
.
_resolveFunction
(
contract
,
tx
,
false
)
return
cb
(
null
,
{
to
:
tx
.
to
,
contractName
:
contract
.
n
ame
,
function
:
fun
})
}
return
cb
()
}
}
_resolveFunction
(
contractName
,
compiledContracts
,
tx
,
isCtor
)
{
const
contract
=
txHelper
.
getContract
(
contractName
,
compiledContracts
)
_resolveFunction
(
contract
,
tx
,
isCtor
)
{
if
(
!
contract
)
{
console
.
log
(
'txListener: cannot resolve
'
+
contractName
)
console
.
log
(
'txListener: cannot resolve
contract - contract is null'
)
return
}
const
abi
=
contract
.
object
.
abi
...
...
@@ -280,7 +280,7 @@ class TxListener {
if
(
methodIdentifiers
[
fn
]
===
inputData
.
substring
(
0
,
8
))
{
const
fnabi
=
txHelper
.
getFunction
(
abi
,
fn
)
this
.
_resolvedTransactions
[
tx
.
hash
]
=
{
contractName
:
contract
N
ame
,
contractName
:
contract
.
n
ame
,
to
:
tx
.
to
,
fn
:
fn
,
params
:
this
.
_decodeInputParams
(
inputData
.
substring
(
8
),
fnabi
)
...
...
@@ -294,7 +294,7 @@ class TxListener {
// receive function
if
(
!
inputData
&&
txHelper
.
getReceiveInterface
(
abi
))
{
this
.
_resolvedTransactions
[
tx
.
hash
]
=
{
contractName
:
contract
N
ame
,
contractName
:
contract
.
n
ame
,
to
:
tx
.
to
,
fn
:
'(receive)'
,
params
:
null
...
...
@@ -302,7 +302,7 @@ class TxListener {
}
else
{
// fallback function
this
.
_resolvedTransactions
[
tx
.
hash
]
=
{
contractName
:
contract
N
ame
,
contractName
:
contract
.
n
ame
,
to
:
tx
.
to
,
fn
:
'(fallback)'
,
params
:
null
...
...
@@ -315,7 +315,7 @@ class TxListener {
params
=
this
.
_decodeInputParams
(
inputData
.
substring
(
bytecode
.
length
),
txHelper
.
getConstructorInterface
(
abi
))
}
this
.
_resolvedTransactions
[
tx
.
hash
]
=
{
contractName
:
contract
N
ame
,
contractName
:
contract
.
n
ame
,
to
:
null
,
fn
:
'(constructor)'
,
params
:
params
...
...
@@ -329,7 +329,7 @@ class TxListener {
txHelper
.
visitContracts
(
compiledContracts
,
(
contract
)
=>
{
const
bytes
=
isCreation
?
contract
.
object
.
evm
.
bytecode
.
object
:
contract
.
object
.
evm
.
deployedBytecode
.
object
if
(
codeUtil
.
compareByteCode
(
codeToResolve
,
'0x'
+
bytes
))
{
found
=
contract
.
name
found
=
contract
return
true
}
})
...
...
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