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
978b8023
Commit
978b8023
authored
Jul 23, 2019
by
Iuri Matias
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
initial subscription matchign
parent
02fbc043
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
43 additions
and
7 deletions
+43
-7
logsManager.js
remix-lib/src/execution/logsManager.js
+43
-7
No files found.
remix-lib/src/execution/logsManager.js
View file @
978b8023
...
...
@@ -8,22 +8,58 @@ class LogsManager {
}
checkBlock
(
blockNumber
,
block
)
{
let
subscriptionId
=
Object
.
keys
(
this
.
subscriptions
)[
0
];
for
(
let
i
=
0
;
i
<
block
.
transactions
.
length
;
i
++
)
{
let
tx
=
block
.
transactions
[
i
]
let
subscriptions
=
this
.
getSubscriptionsFor
({
type
:
'block'
,
block
:
block
,
tx
:
tx
})
for
(
let
subscriptionId
of
subscriptions
)
{
let
result
=
{
"logIndex"
:
"0x1"
,
// 1
"blockNumber"
:
"0x1b4"
,
// 436
"blockHash"
:
"0x8216c5785ac562ff41e2dcfdf5785ac562ff41e2dcfdf829c5a142f1fccd7d"
,
"transactionHash"
:
"0xdf829c5a142f1fccd7d8216c5785ac562ff41e2dcfdf5785ac562ff41e2dcf"
,
"transactionIndex"
:
"0x0"
,
// 0
"address"
:
"0x16c5785ac562ff41e2dcfdf829c5a142f1fccd7d"
,
// "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'
)),
"data"
:
"0x0000000000000000000000000000000000000000000000000000000000000000"
,
"topics"
:
[
"0x59ebeb90bc63057b6515673c3ecf9438e5058bca0f92585014eced636878c9a5"
]
// "topics": ["0x59ebeb90bc63057b6515673c3ecf9438e5058bca0f92585014eced636878c9a5"]
"topics"
:
[]
}
if
(
result
.
address
===
"0x"
)
{
delete
result
.
address
}
let
response
=
{
'jsonrpc'
:
'2.0'
,
"method"
:
"eth_subscription"
,
params
:
{
'result'
:
result
,
'subscription'
:
subscriptionId
}
};
this
.
transmit
(
response
);
}
}
}
// TODO:
// * need to get address of deployed contract if it's a tx that create a contract
getSubscriptionsFor
(
changeEvent
)
{
let
matchedSubscriptions
=
[]
for
(
let
subscriptionId
of
Object
.
keys
(
this
.
subscriptions
))
{
const
subscriptionParams
=
this
.
subscriptions
[
subscriptionId
]
const
[
queryType
,
queryFilter
]
=
subscriptionParams
if
(
queryType
===
'logs'
)
{
if
(
queryFilter
.
address
===
changeEvent
.
tx
.
toJSON
().
to
)
{
matchedSubscriptions
.
push
(
subscriptionId
)
}
if
(
queryFilter
.
address
===
(
'0x'
+
changeEvent
.
tx
.
from
.
toString
(
'hex'
)))
{
matchedSubscriptions
.
push
(
subscriptionId
)
}
}
console
.
dir
(
"-----------------------> "
)
console
.
dir
(
subscriptionParams
)
matchedSubscriptions
.
push
(
subscriptionId
)
}
return
matchedSubscriptions
;
}
transmit
(
result
)
{
console
.
dir
(
"-----------------"
)
...
...
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