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
0b347188
Commit
0b347188
authored
Aug 26, 2019
by
Iuri Matias
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add filter support
parent
2e64ca7e
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
75 additions
and
15 deletions
+75
-15
logsManager.js
remix-lib/src/execution/logsManager.js
+37
-1
README.md
remix-simulator/README.md
+6
-8
filters.js
remix-simulator/src/methods/filters.js
+32
-6
No files found.
remix-lib/src/execution/logsManager.js
View file @
0b347188
...
...
@@ -6,6 +6,8 @@ class LogsManager {
constructor
()
{
this
.
notificationCallbacks
=
[]
this
.
subscriptions
=
{}
this
.
filters
=
{}
this
.
filterTracking
=
{}
this
.
oldLogs
=
[]
}
...
...
@@ -66,7 +68,7 @@ class LogsManager {
const
subscriptionParams
=
this
.
subscriptions
[
subscriptionId
]
const
[
queryType
,
queryFilter
]
=
subscriptionParams
if
(
this
.
eventMatchesFilter
(
changeEvent
,
queryType
,
queryFilter
))
{
if
(
this
.
eventMatchesFilter
(
changeEvent
,
queryType
,
queryFilter
||
{
topics
:
[]}
))
{
matchedSubscriptions
.
push
(
subscriptionId
)
}
}
...
...
@@ -104,6 +106,40 @@ class LogsManager {
delete
this
.
subscriptions
[
subscriptionId
]
}
newFilter
(
filterType
,
params
)
{
let
filterId
=
'0x'
+
crypto
.
randomBytes
(
16
).
toString
(
'hex'
)
if
(
filterType
===
'block'
||
filterType
===
'pendingTransactions'
)
{
this
.
filters
[
filterId
]
=
{
filterType
}
}
if
(
filterType
===
'filter'
)
{
this
.
filters
[
filterId
]
=
{
filterType
,
params
}
}
this
.
filterTracking
[
filterId
]
=
{}
return
filterId
}
uninstallFilter
(
filterId
)
{
delete
this
.
filters
[
filterId
]
}
getLogsForFilter
(
filterId
,
logsOnly
)
{
const
{
filterType
,
params
}
=
this
.
filter
[
filterId
]
const
tracking
=
this
.
filterTracking
[
filterId
]
if
(
logsOnly
||
filterType
===
'filter'
)
{
return
this
.
getLogsFor
(
params
||
{
topics
:
[]})
}
if
(
filterType
===
'block'
)
{
let
blocks
=
oldLogs
.
filter
(
x
=>
x
.
type
===
'block'
).
filter
(
x
=>
tracking
.
block
===
undefined
||
x
.
blockNumber
>=
tracking
.
block
)
tracking
.
block
=
blocks
[
blocks
.
length
-
1
]
return
blocks
.
map
(
block
=>
(
'0x'
+
block
.
hash
().
toString
(
'hex'
)))
}
if
(
filterType
===
'pendingTransactions'
)
{
// TODO: pending transaction hashes
return
[]
}
}
getLogsFor
(
params
)
{
let
results
=
[]
for
(
let
log
of
this
.
oldLogs
)
{
...
...
remix-simulator/README.md
View file @
0b347188
...
...
@@ -40,12 +40,12 @@ Implemented:
*
[
X
]
eth_compileSolidity (DEPRECATED)
*
[
X
]
eth_compileLLL (DEPRECATED)
*
[
X
]
eth_compileSerpent (DEPRECATED)
*
[
_
]
eth_newFilter
*
[
_
]
eth_newBlockFilter
*
[
_
]
eth_newPendingTransactionFilter
*
[
_
]
eth_uninstallFilter
*
[
_
]
eth_getFilterChanges
*
[
X
]
eth_getFilterLogs
*
[
X
]
eth_newFilter
*
[
X
]
eth_newBlockFilter
*
[
X
]
eth_newPendingTransactionFilter
*
[
X
]
eth_uninstallFilter
*
[
~
]
eth_getFilterChanges
*
[
~
]
eth_getFilterLogs
*
[
X
]
eth_getLogs
*
[
_
]
eth_getWork
*
[
_
]
eth_submitWork
...
...
@@ -79,5 +79,3 @@ Implemented:
*
[
_
]
personal_unlockAccount
*
[
_
]
personal_sendTransaction
*
[
_
]
rpc_modules
*
[
_
]
web3_clientVersion
*
[
_
]
web3_sha3
remix-simulator/src/methods/filters.js
View file @
0b347188
...
...
@@ -13,12 +13,6 @@ Filters.prototype.methods = function () {
}
}
Filters
.
prototype
.
eth_getFilterLogs
=
function
(
payload
,
cb
)
{
let
subscriptionId
=
payload
.
params
[
0
];
let
results
=
executionContext
.
logsManager
.
getLogsForSubscription
(
subscriptionId
)
cb
(
null
,
results
)
}
Filters
.
prototype
.
eth_getLogs
=
function
(
payload
,
cb
)
{
let
results
=
executionContext
.
logsManager
.
getLogsFor
(
payload
.
params
[
0
])
cb
(
null
,
results
)
...
...
@@ -34,4 +28,36 @@ Filters.prototype.eth_unsubscribe = function (payload, cb) {
cb
(
null
,
true
)
}
Filters
.
prototype
.
eth_newFilter
=
function
(
payload
,
cb
)
{
const
filterId
=
executionContext
.
logsManager
.
newFilter
(
'filter'
,
payload
.
params
[
0
])
cb
(
null
,
filterId
)
}
Filters
.
prototype
.
eth_newBlockFilter
=
function
(
payload
,
cb
)
{
const
filterId
=
executionContext
.
logsManager
.
newFilter
(
'block'
)
cb
(
null
,
filterId
)
}
Filters
.
prototype
.
eth_newPendingTransactionFilter
=
function
(
payload
,
cb
)
{
const
filterId
=
executionContext
.
logsManager
.
newFilter
(
'pendingTransactions'
)
cb
(
null
,
filterId
)
}
Filters
.
prototype
.
eth_uninstallfilter
=
function
(
payload
,
cb
)
{
const
result
=
executionContext
.
logsManager
.
uninstallFilter
(
payload
.
params
[
0
])
cb
(
null
,
result
)
}
Filters
.
prototype
.
eth_getFilterChanges
=
function
(
payload
,
cb
)
{
const
filterId
=
payload
.
params
[
0
]
let
results
=
executionContext
.
logsManager
.
getLogsForFilter
(
filterId
)
cb
(
null
,
results
)
}
Filters
.
prototype
.
eth_getFilterLogs
=
function
(
payload
,
cb
)
{
const
filterId
=
payload
.
params
[
0
]
let
results
=
executionContext
.
logsManager
.
getLogsForFilter
(
filterId
,
true
)
cb
(
null
,
results
)
}
module
.
exports
=
Filters
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