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
cb160c43
Commit
cb160c43
authored
Aug 10, 2017
by
yann300
Committed by
GitHub
Aug 10, 2017
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #673 from ethereum/txLogger
TxLogger
parents
03ac24aa
96bc02e3
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
67 additions
and
30 deletions
+67
-30
app.js
src/app.js
+22
-26
txListener.js
src/app/execution/txListener.js
+4
-1
txLogger.js
src/app/execution/txLogger.js
+35
-0
run-tab.js
src/app/tabs/run-tab.js
+0
-2
universal-dapp.js
src/universal-dapp.js
+6
-1
No files found.
src/app.js
View file @
cb160c43
...
@@ -32,6 +32,7 @@ var RighthandPanel = require('./app/panels/righthand-panel')
...
@@ -32,6 +32,7 @@ var RighthandPanel = require('./app/panels/righthand-panel')
var
examples
=
require
(
'./app/editor/example-contracts'
)
var
examples
=
require
(
'./app/editor/example-contracts'
)
var
modalDialogCustom
=
require
(
'./app/ui/modal-dialog-custom'
)
var
modalDialogCustom
=
require
(
'./app/ui/modal-dialog-custom'
)
var
Txlistener
=
require
(
'./app/execution/txListener'
)
var
Txlistener
=
require
(
'./app/execution/txListener'
)
var
txLogger
=
require
(
'./app/execution/txLogger'
)
var
EventsDecoder
=
require
(
'./app/execution/eventsDecoder'
)
var
EventsDecoder
=
require
(
'./app/execution/eventsDecoder'
)
var
Web3VMProvider
=
remix
.
web3
.
web3VMProvider
var
Web3VMProvider
=
remix
.
web3
.
web3VMProvider
...
@@ -812,33 +813,28 @@ function run () {
...
@@ -812,33 +813,28 @@ function run () {
txlistener
.
startListening
()
txlistener
.
startListening
()
txlistener
.
event
.
register
(
'newTransaction'
,
(
tx
)
=>
{
txLogger
({
var
resolvedTransaction
=
txlistener
.
resolvedTransaction
(
tx
.
hash
)
api
:
{
var
address
=
null
/**
if
(
resolvedTransaction
)
{
* log the given transaction.
var
resolvedContract
*
address
=
resolvedTransaction
.
contractAddress
?
resolvedTransaction
.
contractAddress
:
tx
.
to
* @param {Object} tx - DOM element representing the transaction
resolvedContract
=
txlistener
.
resolvedContract
(
address
)
*/
if
(
resolvedContract
)
{
log
:
function
(
tx
)
{
eventsDecoder
.
parseLogs
(
tx
,
resolvedContract
,
compiledContracts
(),
(
error
,
log
)
=>
{
// terminal.log(tx)
console
.
log
({
},
tx
:
tx
,
resolvedTransaction
:
function
(
hash
)
{
resolvedTransaction
:
resolvedTransaction
,
return
txlistener
.
resolvedTransaction
(
hash
)
resolvedContract
:
resolvedContract
,
},
resolvedEvents
:
(
!
error
?
log
:
error
)
parseLogs
:
function
(
tx
,
contractName
,
contracts
,
cb
)
{
})
eventsDecoder
.
parseLogs
(
tx
,
contractName
,
contracts
,
cb
)
})
},
}
else
{
compiledContracts
:
function
()
{
console
.
log
({
return
compiledContracts
()
tx
:
tx
,
resolvedTransaction
:
resolvedTransaction
})
}
}
}
else
{
},
// contract unknown - just displaying raw tx.
events
:
{
console
.
log
({
txListener
:
txlistener
.
event
tx
:
tx
})
}
}
})
})
...
...
src/app/execution/txListener.js
View file @
cb160c43
...
@@ -25,7 +25,7 @@ class TxListener {
...
@@ -25,7 +25,7 @@ class TxListener {
this
.
startListening
(
context
)
this
.
startListening
(
context
)
}
}
})
})
opt
.
event
.
udapp
.
register
(
'transactionExecuted'
,
(
to
,
data
,
lookupOnly
,
txResult
)
=>
{
opt
.
event
.
udapp
.
register
(
'transactionExecuted'
,
(
to
,
data
,
txResult
)
=>
{
if
(
this
.
loopId
&&
this
.
_api
.
isVM
())
{
if
(
this
.
loopId
&&
this
.
_api
.
isVM
())
{
this
.
_api
.
web3
().
eth
.
getTransaction
(
txResult
.
transactionHash
,
(
error
,
tx
)
=>
{
this
.
_api
.
web3
().
eth
.
getTransaction
(
txResult
.
transactionHash
,
(
error
,
tx
)
=>
{
if
(
error
)
return
console
.
log
(
error
)
if
(
error
)
return
console
.
log
(
error
)
...
@@ -186,6 +186,7 @@ class TxListener {
...
@@ -186,6 +186,7 @@ class TxListener {
for
(
var
fn
in
compiledContracts
[
contractName
].
functionHashes
)
{
for
(
var
fn
in
compiledContracts
[
contractName
].
functionHashes
)
{
if
(
compiledContracts
[
contractName
].
functionHashes
[
fn
]
===
inputData
.
substring
(
0
,
8
))
{
if
(
compiledContracts
[
contractName
].
functionHashes
[
fn
]
===
inputData
.
substring
(
0
,
8
))
{
this
.
_resolvedTransactions
[
tx
.
hash
]
=
{
this
.
_resolvedTransactions
[
tx
.
hash
]
=
{
contractName
:
contractName
,
to
:
tx
.
to
,
to
:
tx
.
to
,
fn
:
fn
,
fn
:
fn
,
params
:
this
.
_decodeInputParams
(
inputData
.
substring
(
8
),
getFunction
(
abi
,
fn
))
params
:
this
.
_decodeInputParams
(
inputData
.
substring
(
8
),
getFunction
(
abi
,
fn
))
...
@@ -195,6 +196,7 @@ class TxListener {
...
@@ -195,6 +196,7 @@ class TxListener {
}
}
// fallback function
// fallback function
this
.
_resolvedTransactions
[
tx
.
hash
]
=
{
this
.
_resolvedTransactions
[
tx
.
hash
]
=
{
contractName
:
contractName
,
to
:
tx
.
to
,
to
:
tx
.
to
,
fn
:
'(fallback)'
,
fn
:
'(fallback)'
,
params
:
null
params
:
null
...
@@ -206,6 +208,7 @@ class TxListener {
...
@@ -206,6 +208,7 @@ class TxListener {
params
=
this
.
_decodeInputParams
(
inputData
.
substring
(
bytecode
.
length
),
getConstructorInterface
(
abi
))
params
=
this
.
_decodeInputParams
(
inputData
.
substring
(
bytecode
.
length
),
getConstructorInterface
(
abi
))
}
}
this
.
_resolvedTransactions
[
tx
.
hash
]
=
{
this
.
_resolvedTransactions
[
tx
.
hash
]
=
{
contractName
:
contractName
,
to
:
null
,
to
:
null
,
fn
:
'(constructor)'
,
fn
:
'(constructor)'
,
params
:
params
params
:
params
...
...
src/app/execution/txLogger.js
0 → 100644
View file @
cb160c43
'use strict'
/**
* This just export a function that register to `newTransaction` and forward them to the logger.
*
*/
module
.
exports
=
(
opts
=
{})
=>
{
opts
.
events
.
txListener
.
register
(
'newTransaction'
,
(
tx
)
=>
{
log
(
tx
,
opts
.
api
)
})
}
function
log
(
tx
,
api
)
{
var
resolvedTransaction
=
api
.
resolvedTransaction
(
tx
.
hash
)
if
(
resolvedTransaction
)
{
api
.
parseLogs
(
tx
,
resolvedTransaction
.
contractName
,
api
.
compiledContracts
(),
(
error
,
logs
)
=>
{
if
(
!
error
)
{
api
.
log
(
renderResolvedTransaction
(
tx
,
resolvedTransaction
,
logs
))
}
})
}
else
{
// contract unknown - just displaying raw tx.
api
.
log
(
renderTransaction
(
tx
))
}
}
function
renderResolvedTransaction
(
tx
,
resolvedTransaction
,
logs
)
{
console
.
log
([
tx
,
resolvedTransaction
])
return
JSON
.
stringify
([
tx
,
resolvedTransaction
])
}
function
renderTransaction
(
tx
)
{
console
.
log
(
tx
)
return
JSON
.
stringify
(
tx
)
}
src/app/tabs/run-tab.js
View file @
cb160c43
...
@@ -257,8 +257,6 @@ function contractDropdown (appAPI, appEvents, instanceContainer) {
...
@@ -257,8 +257,6 @@ function contractDropdown (appAPI, appEvents, instanceContainer) {
txFormat
.
buildData
(
contract
,
contracts
,
true
,
constructor
,
args
,
appAPI
.
udapp
(),
appAPI
.
executionContext
(),
(
error
,
data
)
=>
{
txFormat
.
buildData
(
contract
,
contracts
,
true
,
constructor
,
args
,
appAPI
.
udapp
(),
appAPI
.
executionContext
(),
(
error
,
data
)
=>
{
if
(
!
error
)
{
if
(
!
error
)
{
txExecution
.
createContract
(
data
,
appAPI
.
udapp
(),
(
error
,
txResult
)
=>
{
txExecution
.
createContract
(
data
,
appAPI
.
udapp
(),
(
error
,
txResult
)
=>
{
// TODO here should send the result to the dom-console
console
.
log
(
'Contract creation'
,
error
,
txResult
)
var
address
=
appAPI
.
executionContext
().
isVM
()
?
txResult
.
result
.
createdAddress
:
txResult
.
result
.
contractAddress
var
address
=
appAPI
.
executionContext
().
isVM
()
?
txResult
.
result
.
createdAddress
:
txResult
.
result
.
contractAddress
if
(
!
init
)
{
if
(
!
init
)
{
instanceContainer
.
innerHTML
=
''
instanceContainer
.
innerHTML
=
''
...
...
src/universal-dapp.js
View file @
cb160c43
...
@@ -473,7 +473,12 @@ UniversalDApp.prototype.runTx = function (args, cb) {
...
@@ -473,7 +473,12 @@ UniversalDApp.prototype.runTx = function (args, cb) {
},
},
// run transaction
// run transaction
function
(
callback
)
{
function
(
callback
)
{
self
.
txRunner
.
rawRun
(
tx
,
function
(
error
,
result
)
{
callback
(
error
,
result
)
})
self
.
txRunner
.
rawRun
(
tx
,
function
(
error
,
result
)
{
if
(
!
args
.
useCall
)
{
self
.
event
.
trigger
(
'transactionExecuted'
,
[
args
.
to
,
args
.
data
,
result
])
}
callback
(
error
,
result
)
})
}
}
],
cb
)
],
cb
)
}
}
...
...
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