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
04016be5
Commit
04016be5
authored
Sep 11, 2017
by
yann300
Committed by
GitHub
Sep 11, 2017
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #779 from ethereum/returnValueForVM
decoded ouput if VM
parents
bc722ff5
3a41c86d
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
45 additions
and
13 deletions
+45
-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
compiling.js
test-browser/tests/compiling.js
+2
-0
No files found.
src/app/execution/txFormat.js
View file @
04016be5
...
@@ -122,8 +122,7 @@ module.exports = {
...
@@ -122,8 +122,7 @@ module.exports = {
}
}
},
},
decodeResponse
:
function
(
response
,
fnabi
,
callback
)
{
decodeResponseToTreeView
:
function
(
response
,
fnabi
)
{
// Only decode if there supposed to be fields
var
treeView
=
new
TreeView
({
var
treeView
=
new
TreeView
({
extractData
:
(
item
,
parent
,
key
)
=>
{
extractData
:
(
item
,
parent
,
key
)
=>
{
var
ret
=
{}
var
ret
=
{}
...
@@ -136,6 +135,11 @@ module.exports = {
...
@@ -136,6 +135,11 @@ module.exports = {
return
ret
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
)
{
if
(
fnabi
.
outputs
&&
fnabi
.
outputs
.
length
>
0
)
{
try
{
try
{
var
i
var
i
...
@@ -159,9 +163,9 @@ module.exports = {
...
@@ -159,9 +163,9 @@ module.exports = {
}
}
}
}
return
callback
(
null
,
treeView
.
render
(
json
))
return
json
}
catch
(
e
)
{
}
catch
(
e
)
{
return
callback
(
'Failed to decode output: '
+
e
)
return
{
error
:
'Failed to decode output: '
+
e
}
}
}
}
}
}
}
...
...
src/app/execution/txListener.js
View file @
04016be5
...
@@ -6,6 +6,7 @@ var EventManager = require('ethereum-remix').lib.EventManager
...
@@ -6,6 +6,7 @@ var EventManager = require('ethereum-remix').lib.EventManager
var
remix
=
require
(
'ethereum-remix'
)
var
remix
=
require
(
'ethereum-remix'
)
var
codeUtil
=
remix
.
util
.
code
var
codeUtil
=
remix
.
util
.
code
var
executionContext
=
require
(
'../../execution-context'
)
var
executionContext
=
require
(
'../../execution-context'
)
var
txFormat
=
require
(
'./txFormat'
)
/**
/**
* poll web3 each 2s if web3
* poll web3 each 2s if web3
...
@@ -32,6 +33,7 @@ class TxListener {
...
@@ -32,6 +33,7 @@ class TxListener {
})
})
opt
.
event
.
udapp
.
register
(
'transactionExecuted'
,
(
error
,
to
,
data
,
lookupOnly
,
txResult
)
=>
{
opt
.
event
.
udapp
.
register
(
'transactionExecuted'
,
(
error
,
to
,
data
,
lookupOnly
,
txResult
)
=>
{
if
(
error
)
return
if
(
error
)
return
if
(
lookupOnly
)
return
// we go for that case if
// we go for that case if
// in VM mode
// in VM mode
// in web3 mode && listen remix txs only
// in web3 mode && listen remix txs only
...
@@ -39,6 +41,8 @@ class TxListener {
...
@@ -39,6 +41,8 @@ class TxListener {
if
(
this
.
_loopId
)
return
// we seems to already listen on the network
if
(
this
.
_loopId
)
return
// we seems to already listen on the network
executionContext
.
web3
().
eth
.
getTransaction
(
txResult
.
transactionHash
,
(
error
,
tx
)
=>
{
executionContext
.
web3
().
eth
.
getTransaction
(
txResult
.
transactionHash
,
(
error
,
tx
)
=>
{
if
(
error
)
return
console
.
log
(
error
)
if
(
error
)
return
console
.
log
(
error
)
if
(
txResult
&&
txResult
.
result
&&
txResult
.
result
.
vm
)
tx
.
returnValue
=
txResult
.
result
.
vm
.
return
this
.
_resolve
([
tx
],
()
=>
{
this
.
_resolve
([
tx
],
()
=>
{
})
})
})
})
...
@@ -158,7 +162,9 @@ class TxListener {
...
@@ -158,7 +162,9 @@ class TxListener {
async
.
each
(
transactions
,
(
tx
,
cb
)
=>
{
async
.
each
(
transactions
,
(
tx
,
cb
)
=>
{
this
.
_resolveTx
(
tx
,
(
error
,
resolvedData
)
=>
{
this
.
_resolveTx
(
tx
,
(
error
,
resolvedData
)
=>
{
if
(
error
)
cb
(
error
)
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
])
this
.
event
.
trigger
(
'newTransaction'
,
[
tx
])
cb
()
cb
()
})
})
...
@@ -224,11 +230,15 @@ class TxListener {
...
@@ -224,11 +230,15 @@ class TxListener {
if
(
!
isCtor
)
{
if
(
!
isCtor
)
{
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
))
{
var
fnabi
=
getFunction
(
abi
,
fn
)
this
.
_resolvedTransactions
[
tx
.
hash
]
=
{
this
.
_resolvedTransactions
[
tx
.
hash
]
=
{
contractName
:
contractName
,
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
),
fnabi
)
}
if
(
tx
.
returnValue
)
{
this
.
_resolvedTransactions
[
tx
.
hash
].
decodedReturnValue
=
txFormat
.
decodeResponse
(
tx
.
returnValue
,
fnabi
)
}
}
return
this
.
_resolvedTransactions
[
tx
.
hash
]
return
this
.
_resolvedTransactions
[
tx
.
hash
]
}
}
...
...
src/app/execution/txLogger.js
View file @
04016be5
...
@@ -146,6 +146,7 @@ function renderKnownTransaction (self, data) {
...
@@ -146,6 +146,7 @@ function renderKnownTransaction (self, data) {
hash
:
data
.
tx
.
hash
,
hash
:
data
.
tx
.
hash
,
input
:
data
.
tx
.
input
,
input
:
data
.
tx
.
input
,
'decoded input'
:
data
.
resolvedData
&&
data
.
resolvedData
.
params
?
JSON
.
stringify
(
value
(
data
.
resolvedData
.
params
),
null
,
'
\
t'
)
:
' - '
,
'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'
,
logs
:
JSON
.
stringify
(
data
.
logs
,
null
,
'
\
t'
)
||
'0'
,
val
:
data
.
tx
.
value
val
:
data
.
tx
.
value
})
})
...
@@ -318,6 +319,15 @@ function createTable (opts) {
...
@@ -318,6 +319,15 @@ function createTable (opts) {
table
.
appendChild
(
inputDecoded
)
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
}
" id="decodedoutput" >
${
opts
[
'decoded output'
]}
</td>
</tr class="
${
css
.
tr
}
">`
table
.
appendChild
(
outputDecoded
)
}
var
logs
=
yo
`
var
logs
=
yo
`
<tr class="
${
css
.
tr
}
">
<tr class="
${
css
.
tr
}
">
<td class="
${
css
.
td
}
"> logs </td>
<td class="
${
css
.
td
}
"> logs </td>
...
...
src/universal-dapp.js
View file @
04016be5
...
@@ -78,6 +78,8 @@ var css = csjs`
...
@@ -78,6 +78,8 @@ var css = csjs`
}
}
.buttonsContainer {
.buttonsContainer {
margin-top: 2%;
margin-top: 2%;
}
.contractActions {
display: flex;
display: flex;
}
}
.instanceButton {}
.instanceButton {}
...
@@ -319,9 +321,8 @@ UniversalDApp.prototype.getCallButton = function (args) {
...
@@ -319,9 +321,8 @@ UniversalDApp.prototype.getCallButton = function (args) {
}
}
}
}
if
(
lookupOnly
)
{
if
(
lookupOnly
)
{
txFormat
.
decodeResponse
(
executionContext
.
isVM
()
?
txResult
.
result
.
vm
.
return
:
ethJSUtil
.
toBuffer
(
txResult
.
result
),
args
.
funABI
,
(
error
,
decoded
)
=>
{
var
decoded
=
txFormat
.
decodeResponseToTreeView
(
executionContext
.
isVM
()
?
txResult
.
result
.
vm
.
return
:
ethJSUtil
.
toBuffer
(
txResult
.
result
),
args
.
funABI
)
$outputOverride
.
html
(
error
?
'error'
+
error
:
decoded
)
$outputOverride
.
html
(
decoded
)
})
}
}
}
else
{
}
else
{
modalDialogCustom
.
alert
(
error
)
modalDialogCustom
.
alert
(
error
)
...
@@ -332,12 +333,17 @@ UniversalDApp.prototype.getCallButton = function (args) {
...
@@ -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>`
)
var
$contractProperty
=
$
(
`<div class="contractProperty
${
css
.
buttonsContainer
}
"></div>`
)
$contractProperty
var
$contractActions
=
$
(
`<div class="
${
css
.
contractActions
}
" ></div>`
)
.
append
(
button
)
$contractProperty
.
append
(
$contractActions
)
.
append
((
lookupOnly
&&
!
inputs
.
length
)
?
$outputOverride
:
inputField
)
$contractActions
.
append
(
button
)
if
(
inputs
.
length
)
{
$contractActions
.
append
(
inputField
)
}
if
(
lookupOnly
)
{
$contractProperty
.
append
(
$outputOverride
)
}
if
(
lookupOnly
)
{
if
(
lookupOnly
)
{
$contractProperty
.
addClass
(
'constant'
)
$contractProperty
.
addClass
(
'constant'
)
...
...
test-browser/tests/compiling.js
View file @
04016be5
...
@@ -34,6 +34,8 @@ function runTests (browser) {
...
@@ -34,6 +34,8 @@ function runTests (browser) {
.
click
(
'.instance button[title="f - transact (not payable)"]'
)
.
click
(
'.instance button[title="f - transact (not payable)"]'
)
.
waitForElementPresent
(
'#editor-container div[class^="terminal"] span[id="tx0xa178c603400a184ce5fedbcfab392d9b77822f6ffa7facdec693aded214523bc"]'
)
.
waitForElementPresent
(
'#editor-container div[class^="terminal"] span[id="tx0xa178c603400a184ce5fedbcfab392d9b77822f6ffa7facdec693aded214523bc"]'
)
.
assert
.
containsText
(
'#editor-container div[class^="terminal"] span[id="tx0xa178c603400a184ce5fedbcfab392d9b77822f6ffa7facdec693aded214523bc"]'
,
'[vm] from:0xca3...a733c, to:browser/Untitled.sol:TestContract.f() 0x692...77b3a, value:0 wei, data:0x261...21ff0, 0 logs, hash:0xa17...523bc'
)
.
assert
.
containsText
(
'#editor-container div[class^="terminal"] span[id="tx0xa178c603400a184ce5fedbcfab392d9b77822f6ffa7facdec693aded214523bc"]'
,
'[vm] from:0xca3...a733c, to:browser/Untitled.sol:TestContract.f() 0x692...77b3a, value:0 wei, data:0x261...21ff0, 0 logs, hash:0xa17...523bc'
)
.
click
(
'#editor-container div[class^="terminal"] span[id="tx0xa178c603400a184ce5fedbcfab392d9b77822f6ffa7facdec693aded214523bc"] button[class^="details"]'
)
.
assert
.
containsText
(
'#editor-container div[class^="terminal"] span[id="tx0xa178c603400a184ce5fedbcfab392d9b77822f6ffa7facdec693aded214523bc"] table[class^="txTable"] #decodedoutput'
,
`"uint256": "8"`
)
.
end
()
.
end
()
/*
/*
@TODO: need to check now the return value of the function
@TODO: need to check now the return value of the function
...
...
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