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
9524741a
Commit
9524741a
authored
Aug 14, 2019
by
Iuri Matias
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
return tx logs with in subscription
parent
7b8d7951
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
48 additions
and
35 deletions
+48
-35
execution-context.js
remix-lib/src/execution/execution-context.js
+1
-1
logsManager.js
remix-lib/src/execution/logsManager.js
+45
-26
package.json
remix-simulator/package.json
+2
-1
filters.js
remix-simulator/src/methods/filters.js
+0
-7
No files found.
remix-lib/src/execution/execution-context.js
View file @
9524741a
...
@@ -310,7 +310,7 @@ function ExecutionContext () {
...
@@ -310,7 +310,7 @@ function ExecutionContext () {
self
.
blocks
[
'0x'
+
block
.
hash
().
toString
(
'hex'
)]
=
block
self
.
blocks
[
'0x'
+
block
.
hash
().
toString
(
'hex'
)]
=
block
self
.
blocks
[
blockNumber
]
=
block
self
.
blocks
[
blockNumber
]
=
block
this
.
logsManager
.
checkBlock
(
blockNumber
,
block
)
this
.
logsManager
.
checkBlock
(
blockNumber
,
block
,
this
.
web3
()
)
}
}
this
.
trackTx
=
function
(
tx
,
block
)
{
this
.
trackTx
=
function
(
tx
,
block
)
{
...
...
remix-lib/src/execution/logsManager.js
View file @
9524741a
var
crypto
=
require
(
'crypto'
)
const
async
=
require
(
'async'
)
const
crypto
=
require
(
'crypto'
)
class
LogsManager
{
class
LogsManager
{
...
@@ -7,34 +8,53 @@ class LogsManager {
...
@@ -7,34 +8,53 @@ class LogsManager {
this
.
subscriptions
=
{}
this
.
subscriptions
=
{}
}
}
checkBlock
(
blockNumber
,
block
)
{
checkBlock
(
blockNumber
,
block
,
web3
)
{
for
(
let
i
=
0
;
i
<
block
.
transactions
.
length
;
i
++
)
{
async
.
eachOf
(
block
.
transactions
,
(
tx
,
i
,
next
)
=>
{
let
tx
=
block
.
transactions
[
i
]
let
tx
Hash
=
"0x"
+
tx
.
hash
().
toString
(
'hex'
)
let
subscriptions
=
this
.
getSubscriptionsFor
({
type
:
'block'
,
block
:
block
,
tx
:
tx
})
let
subscriptions
=
this
.
getSubscriptionsFor
({
type
:
'block'
,
block
:
block
,
tx
:
tx
})
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'
)),
"data"
:
"0x0000000000000000000000000000000000000000000000000000000000000000"
,
// "topics": ["0x59ebeb90bc63057b6515673c3ecf9438e5058bca0f92585014eced636878c9a5"]
"topics"
:
[]
}
if
(
result
.
address
===
"0x"
)
{
// console.dir("====================================================")
delete
result
.
address
// 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)
for
(
let
log
of
receipt
.
logs
)
{
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
,
}
if
(
result
.
address
===
"0x"
)
{
delete
result
.
address
}
let
response
=
{
'jsonrpc'
:
'2.0'
,
"method"
:
"eth_subscription"
,
params
:
{
'result'
:
result
,
'subscription'
:
subscriptionId
}
};
this
.
transmit
(
response
);
}
}
}
})
let
response
=
{
'jsonrpc'
:
'2.0'
,
"method"
:
"eth_subscription"
,
params
:
{
'result'
:
result
,
'subscription'
:
subscriptionId
}
};
},
(
err
)
=>
{
this
.
transmit
(
response
);
});
}
}
}
}
// TODO:
// TODO:
...
@@ -91,7 +111,6 @@ class LogsManager {
...
@@ -91,7 +111,6 @@ class LogsManager {
}
}
unsubscribe
(
subscriptionId
)
{
unsubscribe
(
subscriptionId
)
{
let
subscriptionId
=
"0x"
+
crypto
.
randomBytes
(
16
).
toString
(
'hex'
)
delete
this
.
subscriptions
[
subscriptionId
]
delete
this
.
subscriptions
[
subscriptionId
]
}
}
...
...
remix-simulator/package.json
View file @
9524741a
...
@@ -15,6 +15,7 @@
...
@@ -15,6 +15,7 @@
"main"
:
"./index.js"
,
"main"
:
"./index.js"
,
"dependencies"
:
{
"dependencies"
:
{
"ansi-gray"
:
"^0.1.1"
,
"ansi-gray"
:
"^0.1.1"
,
"async"
:
"^3.1.0"
,
"body-parser"
:
"^1.18.2"
,
"body-parser"
:
"^1.18.2"
,
"color-support"
:
"^1.1.3"
,
"color-support"
:
"^1.1.3"
,
"commander"
:
"^2.19.0"
,
"commander"
:
"^2.19.0"
,
...
@@ -28,7 +29,7 @@
...
@@ -28,7 +29,7 @@
"remix-lib"
:
"0.4.12"
,
"remix-lib"
:
"0.4.12"
,
"standard"
:
"^10.0.3"
,
"standard"
:
"^10.0.3"
,
"time-stamp"
:
"^2.0.0"
,
"time-stamp"
:
"^2.0.0"
,
"web3"
:
"
1.0.0-beta.2
7"
"web3"
:
"
^1.0.0-beta.3
7"
},
},
"devDependencies"
:
{
"devDependencies"
:
{
"@babel/core"
:
"^7.4.5"
,
"@babel/core"
:
"^7.4.5"
,
...
...
remix-simulator/src/methods/filters.js
View file @
9524741a
...
@@ -23,13 +23,6 @@ Filters.prototype.eth_getLogs = function (payload, cb) {
...
@@ -23,13 +23,6 @@ Filters.prototype.eth_getLogs = function (payload, cb) {
// address: '0xdb2eb1480cb3ac3a5c0ee957045d1ad9dcd34f01',
// address: '0xdb2eb1480cb3ac3a5c0ee957045d1ad9dcd34f01',
// topics: [] } ]
// topics: [] } ]
// console.dir(executionContext.vm().stateManager)
// console.dir(executionContext.vm().blockchain)
// var block = executionContext.blocks[payload.params[0]]
// executionContext.vm().stateManager.getLogs(address, (err, account) => {
let
results
=
executionContext
.
logsManager
.
getLogsFor
(
payload
.
params
);
let
results
=
executionContext
.
logsManager
.
getLogsFor
(
payload
.
params
);
cb
(
null
,
results
)
cb
(
null
,
results
)
...
...
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