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
c20b8779
Commit
c20b8779
authored
Sep 23, 2021
by
yann300
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
make sure nonce, transactionIndex and logs are returned
parent
8c94d6de
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
47 additions
and
18 deletions
+47
-18
logsManager.ts
libs/remix-lib/src/execution/logsManager.ts
+21
-2
transactions.ts
libs/remix-simulator/src/methods/transactions.ts
+19
-12
vm-context.ts
libs/remix-simulator/src/vm-context.ts
+7
-4
No files found.
libs/remix-lib/src/execution/logsManager.ts
View file @
c20b8779
...
...
@@ -55,10 +55,11 @@ export class LogsManager {
if
(
queryFilter
.
topics
.
filter
((
logTopic
)
=>
changeEvent
.
log
.
topics
.
indexOf
(
logTopic
)
>=
0
).
length
===
0
)
return
false
if
(
queryType
===
'logs'
)
{
if
((
queryFilter
.
address
===
(
'0x'
+
changeEvent
.
tx
.
to
.
toString
(
'hex'
)))
&&
(
queryFilter
.
address
===
(
'0x'
+
changeEvent
.
tx
.
from
.
toString
(
'hex'
))))
{
if
((
queryFilter
.
address
===
(
changeEvent
.
tx
.
to
||
''
).
toString
())
||
queryFilter
.
address
===
(
changeEvent
.
tx
.
getSenderAddress
().
toString
()))
{
if
(
!
queryFilter
.
toBlock
)
{
return
true
}
else
if
(
parseInt
(
queryFilter
.
toBlock
)
>
parseInt
(
changeEvent
.
blockNumber
))
{
}
else
if
(
parseInt
(
queryFilter
.
toBlock
)
>
=
parseInt
(
changeEvent
.
blockNumber
))
{
return
true
}
}
...
...
@@ -144,6 +145,24 @@ export class LogsManager {
}
}
getLogsByTxHash
(
hash
)
{
return
this
.
oldLogs
.
filter
((
log
)
=>
'0x'
+
log
.
tx
.
hash
().
toString
(
'hex'
)
===
hash
)
.
map
((
log
)
=>
{
return
{
logIndex
:
'0x1'
,
// 1
blockNumber
:
log
.
blockNumber
,
blockHash
:
(
'0x'
+
log
.
block
.
hash
().
toString
(
'hex'
)),
transactionHash
:
(
'0x'
+
log
.
tx
.
hash
().
toString
(
'hex'
)),
transactionIndex
:
'0x'
+
log
.
txNumber
.
toString
(
16
),
// TODO: if it's a contract deploy, it should be that address instead
address
:
log
.
log
.
address
,
data
:
log
.
log
.
data
,
topics
:
log
.
log
.
topics
}
})
}
getLogsFor
(
params
)
{
const
results
=
[]
for
(
const
log
of
this
.
oldLogs
)
{
...
...
libs/remix-simulator/src/methods/transactions.ts
View file @
c20b8779
...
...
@@ -71,7 +71,7 @@ export class Transactions {
if
(
!
error
&&
result
)
{
this
.
vmContext
.
addBlock
(
result
.
block
)
const
hash
=
'0x'
+
result
.
tx
.
hash
().
toString
(
'hex'
)
this
.
vmContext
.
trackTx
(
hash
,
result
.
block
)
this
.
vmContext
.
trackTx
(
hash
,
result
.
block
,
result
.
tx
)
this
.
vmContext
.
trackExecResult
(
hash
,
result
.
result
.
execResult
)
return
cb
(
null
,
result
.
transactionHash
)
}
...
...
@@ -95,17 +95,19 @@ export class Transactions {
return
cb
(
error
)
}
const
txBlock
=
this
.
vmContext
.
txs
[
receipt
.
hash
]
const
txBlock
=
this
.
vmContext
.
blockByTxHash
[
receipt
.
hash
]
const
logs
=
this
.
vmContext
.
logsManager
.
getLogsByTxHash
(
receipt
.
hash
)
const
r
:
Record
<
string
,
unknown
>
=
{
transactionHash
:
receipt
.
hash
,
transactionIndex
:
'0x0
0
'
,
transactionIndex
:
'0x0'
,
blockHash
:
'0x'
+
txBlock
.
hash
().
toString
(
'hex'
),
blockNumber
:
'0x'
+
txBlock
.
header
.
number
.
toString
(
'hex'
),
gasUsed
:
receipt
.
gasUsed
,
cumulativeGasUsed
:
receipt
.
gasUsed
,
// only 1 tx per block
contractAddress
:
receipt
.
contractAddress
,
logs
:
receipt
.
logs
,
logs
,
status
:
receipt
.
status
,
to
:
receipt
.
to
}
...
...
@@ -151,7 +153,7 @@ export class Transactions {
if
(
!
error
&&
result
)
{
this
.
vmContext
.
addBlock
(
result
.
block
)
const
hash
=
'0x'
+
result
.
tx
.
hash
().
toString
(
'hex'
)
this
.
vmContext
.
trackTx
(
hash
,
result
.
block
)
this
.
vmContext
.
trackTx
(
hash
,
result
.
block
,
result
.
tx
)
this
.
vmContext
.
trackExecResult
(
hash
,
result
.
result
.
execResult
)
this
.
tags
[
tag
]
=
result
.
transactionHash
// calls are not supposed to return a transaction hash. we do this for keeping track of it and allowing debugging calls.
...
...
@@ -185,7 +187,8 @@ export class Transactions {
return
cb
(
error
)
}
const
txBlock
=
this
.
vmContext
.
txs
[
receipt
.
transactionHash
]
const
txBlock
=
this
.
vmContext
.
blockByTxHash
[
receipt
.
transactionHash
]
const
tx
=
this
.
vmContext
.
txByHash
[
receipt
.
transactionHash
]
// TODO: params to add later
const
r
:
Record
<
string
,
unknown
>
=
{
...
...
@@ -198,9 +201,9 @@ export class Transactions {
gasPrice
:
'0x4a817c800'
,
// 20000000000
hash
:
receipt
.
transactionHash
,
input
:
receipt
.
input
,
nonce
:
2
,
// 0x15 // the nonce should be updated
// "transactionIndex": 0
,
value
:
receipt
.
value
nonce
:
'0x'
+
tx
.
nonce
.
toString
(
'hex'
),
transactionIndex
:
'0x0'
,
value
:
receipt
.
value
,
// "value":"0xf3dbb76162000" // 4290000000000000
// "v": "0x25", // 37
// "r": "0x1b5e176d927f8e9ab405058b2d2457392da3e20f328b16ddabcebc33eaac5fea",
...
...
@@ -234,6 +237,8 @@ export class Transactions {
return
cb
(
error
)
}
const
tx
=
this
.
vmContext
.
txByHash
[
receipt
.
transactionHash
]
// TODO: params to add later
const
r
:
Record
<
string
,
unknown
>
=
{
blockHash
:
'0x'
+
txBlock
.
hash
().
toString
(
'hex'
),
...
...
@@ -245,7 +250,7 @@ export class Transactions {
gasPrice
:
'0x4a817c800'
,
// 20000000000
hash
:
receipt
.
transactionHash
,
input
:
receipt
.
input
,
nonce
:
2
,
// 0x15 // the nonce should be updated
nonce
:
'0x'
+
tx
.
nonce
.
toString
(
'hex'
),
// "transactionIndex": 0,
value
:
receipt
.
value
// "value":"0xf3dbb76162000" // 4290000000000000
...
...
@@ -277,6 +282,8 @@ export class Transactions {
return
cb
(
error
)
}
const
tx
=
this
.
vmContext
.
txByHash
[
receipt
.
transactionHash
]
// TODO: params to add later
const
r
:
Record
<
string
,
unknown
>
=
{
blockHash
:
'0x'
+
txBlock
.
hash
().
toString
(
'hex'
),
...
...
@@ -288,8 +295,8 @@ export class Transactions {
gasPrice
:
'0x4a817c800'
,
// 20000000000
hash
:
receipt
.
transactionHash
,
input
:
receipt
.
input
,
nonce
:
2
,
// 0x15 // the nonce should be updated
// "transactionIndex": 0
,
nonce
:
'0x'
+
tx
.
nonce
.
toString
(
'hex'
),
transactionIndex
:
'0x0'
,
value
:
receipt
.
value
// "value":"0xf3dbb76162000" // 4290000000000000
// "v": "0x25", // 37
...
...
libs/remix-simulator/src/vm-context.ts
View file @
c20b8779
...
...
@@ -85,7 +85,8 @@ export class VMContext {
customNetWorks
blocks
latestBlockNumber
txs
blockByTxHash
txByHash
currentVm
web3vm
logsManager
...
...
@@ -98,7 +99,8 @@ export class VMContext {
this
.
currentVm
=
this
.
createVm
(
this
.
currentFork
)
this
.
blocks
=
{}
this
.
latestBlockNumber
=
0
this
.
txs
=
{}
this
.
blockByTxHash
=
{}
this
.
txByHash
=
{}
this
.
exeResults
=
{}
this
.
logsManager
=
new
execution
.
LogsManager
()
}
...
...
@@ -151,8 +153,9 @@ export class VMContext {
this
.
logsManager
.
checkBlock
(
blockNumber
,
block
,
this
.
web3
())
}
trackTx
(
tx
,
block
)
{
this
.
txs
[
tx
]
=
block
trackTx
(
txHash
,
block
,
tx
)
{
this
.
blockByTxHash
[
txHash
]
=
block
this
.
txByHash
[
txHash
]
=
tx
}
trackExecResult
(
tx
,
execReult
)
{
...
...
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