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
517f6db8
Commit
517f6db8
authored
Aug 14, 2019
by
Iuri Matias
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
match subscription to toBlock filter
parent
9524741a
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
28 deletions
+22
-28
logsManager.js
remix-lib/src/execution/logsManager.js
+12
-24
txProcess.js
remix-simulator/src/methods/txProcess.js
+10
-4
No files found.
remix-lib/src/execution/logsManager.js
View file @
517f6db8
...
...
@@ -12,34 +12,19 @@ class LogsManager {
async
.
eachOf
(
block
.
transactions
,
(
tx
,
i
,
next
)
=>
{
let
txHash
=
"0x"
+
tx
.
hash
().
toString
(
'hex'
)
let
subscriptions
=
this
.
getSubscriptionsFor
({
type
:
'block'
,
block
:
block
,
tx
:
tx
})
// console.dir("====================================================")
// console.dir(block)
// console.dir("====================================================")
web3
.
eth
.
getTransactionReceipt
(
txHash
,
(
error
,
receipt
)
=>
{
console
.
dir
(
"===================================================="
)
console
.
dir
(
"===================================================="
)
console
.
dir
(
"===================================================="
)
console
.
dir
(
receipt
)
// web3.eth.abi.decodeLog(inputs_abi, receipt.logs[0].data, receipt.logs[0].topics)
// console.dir(process.exit(0))
// // web3.eth.abi.decodeLog(inputs_abi, receipt.logs[0].data, receipt.logs[0].topics)
web3
.
eth
.
getTransactionReceipt
(
txHash
,
(
_error
,
receipt
)
=>
{
for
(
let
log
of
receipt
.
logs
)
{
let
subscriptions
=
this
.
getSubscriptionsFor
({
type
:
'block'
,
blockNumber
,
block
,
tx
,
log
})
for
(
let
subscriptionId
of
subscriptions
)
{
let
result
=
{
"logIndex"
:
"0x1"
,
// 1
// "blockNumber": ("0x" + blockNumber),
"blockNumber"
:
blockNumber
,
"blockHash"
:
(
'0x'
+
block
.
hash
().
toString
(
'hex'
)),
"transactionHash"
:
(
'0x'
+
tx
.
hash
().
toString
(
'hex'
)),
"transactionIndex"
:
"0x"
+
i
.
toString
(
16
),
// TODO: if it's a contract deploy, it should be that address instead
// "address": ('0x' + tx.to.toString('hex')),
"address"
:
log
.
address
,
// "data": "0x0000000000000000000000000000000000000000000000000000000000000000",
"data"
:
log
.
data
,
"topics"
:
log
.
topics
,
}
...
...
@@ -65,18 +50,21 @@ class LogsManager {
const
subscriptionParams
=
this
.
subscriptions
[
subscriptionId
]
const
[
queryType
,
queryFilter
]
=
subscriptionParams
if
(
queryType
===
'logs'
)
{
if
(
queryFilter
.
address
===
changeEvent
.
tx
.
toJSON
().
to
)
{
if
(
queryFilter
.
address
===
(
"0x"
+
changeEvent
.
tx
.
to
.
toString
(
'hex'
)))
{
if
(
!
queryFilter
.
toBlock
)
{
matchedSubscriptions
.
push
(
subscriptionId
)
}
else
if
(
parseInt
(
queryFilter
.
toBlock
)
>
parseInt
(
changeEvent
.
blockNumber
))
{
matchedSubscriptions
.
push
(
subscriptionId
)
}
}
if
(
queryFilter
.
address
===
(
'0x'
+
changeEvent
.
tx
.
from
.
toString
(
'hex'
)))
{
if
(
!
queryFilter
.
toBlock
)
{
matchedSubscriptions
.
push
(
subscriptionId
)
}
else
if
(
parseInt
(
queryFilter
.
toBlock
)
>
parseInt
(
changeEvent
.
blockNumber
))
{
matchedSubscriptions
.
push
(
subscriptionId
)
}
}
console
.
dir
(
"-----------------------> "
)
console
.
dir
(
subscriptionParams
)
matchedSubscriptions
.
push
(
subscriptionId
)
}
}
return
matchedSubscriptions
;
}
...
...
remix-simulator/src/methods/txProcess.js
View file @
517f6db8
...
...
@@ -41,6 +41,8 @@ function createContract (payload, from, data, value, gasLimit, txRunner, callbac
TxExecution
.
createContract
(
from
,
data
,
value
,
gasLimit
,
txRunner
,
callbacks
,
finalCallback
)
}
let
txRunner_instance
;
function
processTx
(
accounts
,
payload
,
isCall
,
callback
)
{
let
api
=
{
logMessage
:
(
msg
)
=>
{
...
...
@@ -65,7 +67,11 @@ function processTx (accounts, payload, isCall, callback) {
executionContext
.
init
(
api
.
config
)
let
txRunner
=
new
TxRunner
(
accounts
,
api
)
// let txRunner = new TxRunner(accounts, api)
if
(
!
txRunner_instance
)
{
txRunner_instance
=
new
TxRunner
(
accounts
,
api
)
}
txRunner_instance
.
vmaccounts
=
accounts
;
let
{
from
,
to
,
data
,
value
,
gas
}
=
payload
.
params
[
0
]
gas
=
gas
||
3000000
...
...
@@ -85,11 +91,11 @@ function processTx (accounts, payload, isCall, callback) {
}
if
(
isCall
)
{
runCall
(
payload
,
from
,
to
,
data
,
value
,
gas
,
txRunner
,
callbacks
,
callback
)
runCall
(
payload
,
from
,
to
,
data
,
value
,
gas
,
txRunner
_instance
,
callbacks
,
callback
)
}
else
if
(
to
)
{
runTx
(
payload
,
from
,
to
,
data
,
value
,
gas
,
txRunner
,
callbacks
,
callback
)
runTx
(
payload
,
from
,
to
,
data
,
value
,
gas
,
txRunner
_instance
,
callbacks
,
callback
)
}
else
{
createContract
(
payload
,
from
,
data
,
value
,
gas
,
txRunner
,
callbacks
,
callback
)
createContract
(
payload
,
from
,
data
,
value
,
gas
,
txRunner
_instance
,
callbacks
,
callback
)
}
}
...
...
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