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
d5651ae8
Commit
d5651ae8
authored
Sep 08, 2017
by
yann300
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
decoded ouput if VM
parent
780e93b3
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
43 additions
and
13 deletions
+43
-13
txFormat.js
src/app/execution/txFormat.js
+8
-4
txListener.js
src/app/execution/txListener.js
+12
-2
txLogger.js
src/app/execution/txLogger.js
+10
-0
universal-dapp.js
src/universal-dapp.js
+13
-7
No files found.
src/app/execution/txFormat.js
View file @
d5651ae8
...
...
@@ -122,8 +122,7 @@ module.exports = {
}
},
decodeResponse
:
function
(
response
,
fnabi
,
callback
)
{
// Only decode if there supposed to be fields
decodeResponseToTreeView
:
function
(
response
,
fnabi
)
{
var
treeView
=
new
TreeView
({
extractData
:
(
item
,
parent
,
key
)
=>
{
var
ret
=
{}
...
...
@@ -136,6 +135,11 @@ module.exports = {
return
ret
}
})
return
treeView
.
render
(
this
.
decodeResponse
(
response
,
fnabi
))
},
decodeResponse
:
function
(
response
,
fnabi
)
{
// Only decode if there supposed to be fields
if
(
fnabi
.
outputs
&&
fnabi
.
outputs
.
length
>
0
)
{
try
{
var
i
...
...
@@ -159,9 +163,9 @@ module.exports = {
}
}
return
callback
(
null
,
treeView
.
render
(
json
))
return
json
}
catch
(
e
)
{
return
callback
(
'Failed to decode output: '
+
e
)
return
{
error
:
'Failed to decode output: '
+
e
}
}
}
}
...
...
src/app/execution/txListener.js
View file @
d5651ae8
...
...
@@ -6,6 +6,7 @@ var EventManager = require('ethereum-remix').lib.EventManager
var
remix
=
require
(
'ethereum-remix'
)
var
codeUtil
=
remix
.
util
.
code
var
executionContext
=
require
(
'../../execution-context'
)
var
txFormat
=
require
(
'./txFormat'
)
/**
* poll web3 each 2s if web3
...
...
@@ -32,6 +33,7 @@ class TxListener {
})
opt
.
event
.
udapp
.
register
(
'transactionExecuted'
,
(
error
,
to
,
data
,
lookupOnly
,
txResult
)
=>
{
if
(
error
)
return
if
(
lookupOnly
)
return
// we go for that case if
// in VM mode
// in web3 mode && listen remix txs only
...
...
@@ -39,6 +41,8 @@ class TxListener {
if
(
this
.
_loopId
)
return
// we seems to already listen on the network
executionContext
.
web3
().
eth
.
getTransaction
(
txResult
.
transactionHash
,
(
error
,
tx
)
=>
{
if
(
error
)
return
console
.
log
(
error
)
if
(
txResult
&&
txResult
.
result
&&
txResult
.
result
.
vm
)
tx
.
returnValue
=
txResult
.
result
.
vm
.
return
this
.
_resolve
([
tx
],
()
=>
{
})
})
...
...
@@ -158,7 +162,9 @@ class TxListener {
async
.
each
(
transactions
,
(
tx
,
cb
)
=>
{
this
.
_resolveTx
(
tx
,
(
error
,
resolvedData
)
=>
{
if
(
error
)
cb
(
error
)
if
(
resolvedData
)
this
.
event
.
trigger
(
'txResolved'
,
[
tx
,
resolvedData
])
if
(
resolvedData
)
{
this
.
event
.
trigger
(
'txResolved'
,
[
tx
,
resolvedData
])
}
this
.
event
.
trigger
(
'newTransaction'
,
[
tx
])
cb
()
})
...
...
@@ -224,11 +230,15 @@ class TxListener {
if
(
!
isCtor
)
{
for
(
var
fn
in
compiledContracts
[
contractName
].
functionHashes
)
{
if
(
compiledContracts
[
contractName
].
functionHashes
[
fn
]
===
inputData
.
substring
(
0
,
8
))
{
var
fnabi
=
getFunction
(
abi
,
fn
)
this
.
_resolvedTransactions
[
tx
.
hash
]
=
{
contractName
:
contractName
,
to
:
tx
.
to
,
fn
:
fn
,
params
:
this
.
_decodeInputParams
(
inputData
.
substring
(
8
),
getFunction
(
abi
,
fn
))
params
:
this
.
_decodeInputParams
(
inputData
.
substring
(
8
),
fnabi
)
}
if
(
tx
.
returnValue
)
{
this
.
_resolvedTransactions
[
tx
.
hash
].
decodedReturnValue
=
txFormat
.
decodeResponse
(
tx
.
returnValue
,
fnabi
)
}
return
this
.
_resolvedTransactions
[
tx
.
hash
]
}
...
...
src/app/execution/txLogger.js
View file @
d5651ae8
...
...
@@ -142,6 +142,7 @@ function renderKnownTransaction (self, data) {
hash
:
data
.
tx
.
hash
,
input
:
data
.
tx
.
input
,
'decoded input'
:
data
.
resolvedData
&&
data
.
resolvedData
.
params
?
JSON
.
stringify
(
value
(
data
.
resolvedData
.
params
),
null
,
'
\
t'
)
:
' - '
,
'decoded output'
:
data
.
resolvedData
&&
data
.
resolvedData
.
decodedReturnValue
?
JSON
.
stringify
(
value
(
data
.
resolvedData
.
decodedReturnValue
),
null
,
'
\
t'
)
:
' - '
,
logs
:
JSON
.
stringify
(
data
.
logs
,
null
,
'
\
t'
)
||
'0'
,
val
:
data
.
tx
.
value
})
...
...
@@ -314,6 +315,15 @@ function createTable (opts) {
table
.
appendChild
(
inputDecoded
)
}
if
(
opts
[
'decoded output'
])
{
var
outputDecoded
=
yo
`
<tr class="
${
css
.
tr
}
">
<td class="
${
css
.
td
}
"> decoded output </td>
<td class="
${
css
.
td
}
">
${
opts
[
'decoded output'
]}
</td>
</tr class="
${
css
.
tr
}
">`
table
.
appendChild
(
outputDecoded
)
}
var
logs
=
yo
`
<tr class="
${
css
.
tr
}
">
<td class="
${
css
.
td
}
"> logs </td>
...
...
src/universal-dapp.js
View file @
d5651ae8
...
...
@@ -78,6 +78,8 @@ var css = csjs`
}
.buttonsContainer {
margin-top: 2%;
}
.contractActions {
display: flex;
}
.instanceButton {}
...
...
@@ -319,9 +321,8 @@ UniversalDApp.prototype.getCallButton = function (args) {
}
}
if
(
lookupOnly
)
{
txFormat
.
decodeResponse
(
executionContext
.
isVM
()
?
txResult
.
result
.
vm
.
return
:
ethJSUtil
.
toBuffer
(
txResult
.
result
),
args
.
funABI
,
(
error
,
decoded
)
=>
{
$outputOverride
.
html
(
error
?
'error'
+
error
:
decoded
)
})
var
decoded
=
txFormat
.
decodeResponseToTreeView
(
executionContext
.
isVM
()
?
txResult
.
result
.
vm
.
return
:
ethJSUtil
.
toBuffer
(
txResult
.
result
),
args
.
funABI
)
$outputOverride
.
html
(
decoded
)
}
}
else
{
modalDialogCustom
.
alert
(
error
)
...
...
@@ -332,12 +333,17 @@ UniversalDApp.prototype.getCallButton = function (args) {
}
})
}
// TODO the auto call to constant function has been removed. needs to readd it later.
var
$contractProperty
=
$
(
`<div class="contractProperty
${
css
.
buttonsContainer
}
"></div>`
)
$contractProperty
.
append
(
button
)
.
append
((
lookupOnly
&&
!
inputs
.
length
)
?
$outputOverride
:
inputField
)
var
$contractActions
=
$
(
`<div class="
${
css
.
contractActions
}
" ></div>`
)
$contractProperty
.
append
(
$contractActions
)
$contractActions
.
append
(
button
)
if
(
inputs
.
length
)
{
$contractActions
.
append
(
inputField
)
}
if
(
lookupOnly
)
{
$contractProperty
.
append
(
$outputOverride
)
}
if
(
lookupOnly
)
{
$contractProperty
.
addClass
(
'constant'
)
...
...
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