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
01336798
Commit
01336798
authored
Aug 15, 2017
by
yann300
Committed by
GitHub
Aug 15, 2017
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #684 from ethereum/fixCall
display call result
parents
a354e881
ebe128eb
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
40 additions
and
15 deletions
+40
-15
txFormat.js
src/app/execution/txFormat.js
+19
-4
universal-dapp.js
src/universal-dapp.js
+21
-11
No files found.
src/app/execution/txFormat.js
View file @
01336798
'use strict'
'use strict'
var
$
=
require
(
'jquery'
)
var
$
=
require
(
'jquery'
)
var
ethJSABI
=
require
(
'ethereumjs-abi'
)
var
ethJSABI
=
require
(
'ethereumjs-abi'
)
var
ethJSUtil
=
require
(
'ethereumjs-util'
)
var
BN
=
ethJSUtil
.
BN
var
helper
=
require
(
'./txHelper'
)
var
helper
=
require
(
'./txHelper'
)
var
TreeView
=
require
(
'ethereum-remix'
).
ui
.
TreeView
module
.
exports
=
{
module
.
exports
=
{
/**
/**
...
@@ -121,6 +124,18 @@ module.exports = {
...
@@ -121,6 +124,18 @@ module.exports = {
decodeResponse
:
function
(
response
,
fnabi
,
callback
)
{
decodeResponse
:
function
(
response
,
fnabi
,
callback
)
{
// Only decode if there supposed to be fields
// Only decode if there supposed to be fields
var
treeView
=
new
TreeView
({
extractData
:
(
item
,
parent
,
key
)
=>
{
var
ret
=
{}
if
(
BN
.
isBN
(
item
))
{
ret
.
self
=
item
.
toString
(
10
)
ret
.
children
=
[]
}
else
{
ret
=
treeView
.
extractDataDefault
(
item
,
parent
,
key
)
}
return
ret
}
})
if
(
fnabi
.
outputs
&&
fnabi
.
outputs
.
length
>
0
)
{
if
(
fnabi
.
outputs
&&
fnabi
.
outputs
.
length
>
0
)
{
try
{
try
{
var
i
var
i
...
@@ -134,17 +149,17 @@ module.exports = {
...
@@ -134,17 +149,17 @@ module.exports = {
var
decodedObj
=
ethJSABI
.
rawDecode
(
outputTypes
,
response
)
var
decodedObj
=
ethJSABI
.
rawDecode
(
outputTypes
,
response
)
// format decoded data
// format decoded data
decodedObj
=
ethJSABI
.
stringify
(
outputTypes
,
decodedObj
)
var
json
=
{}
for
(
i
=
0
;
i
<
outputTypes
.
length
;
i
++
)
{
for
(
i
=
0
;
i
<
outputTypes
.
length
;
i
++
)
{
var
name
=
fnabi
.
outputs
[
i
].
name
var
name
=
fnabi
.
outputs
[
i
].
name
if
(
name
.
length
>
0
)
{
if
(
name
.
length
>
0
)
{
decodedObj
[
i
]
=
outputTypes
[
i
]
+
' '
+
name
+
': '
+
decodedObj
[
i
]
json
[
outputTypes
[
i
]
+
' '
+
name
]
=
decodedObj
[
i
]
}
else
{
}
else
{
decodedObj
[
i
]
=
outputTypes
[
i
]
+
': '
+
decodedObj
[
i
]
json
[
outputTypes
[
i
]]
=
decodedObj
[
i
]
}
}
}
}
return
callback
(
null
,
decodedObj
)
return
callback
(
null
,
treeView
.
render
(
json
)
)
}
catch
(
e
)
{
}
catch
(
e
)
{
return
callback
(
'Failed to decode output: '
+
e
)
return
callback
(
'Failed to decode output: '
+
e
)
}
}
...
...
src/universal-dapp.js
View file @
01336798
...
@@ -361,19 +361,28 @@ UniversalDApp.prototype.getCallButton = function (args) {
...
@@ -361,19 +361,28 @@ UniversalDApp.prototype.getCallButton = function (args) {
.
attr
(
'title'
,
title
)
.
attr
(
'title'
,
title
)
.
text
(
title
)
.
text
(
title
)
.
click
(()
=>
{
.
click
(()
=>
{
txFormat
.
buildData
(
args
.
contractAbi
,
self
.
contracts
,
false
,
args
.
funABI
,
inputField
.
val
(),
self
,
self
.
executionContext
,
(
error
,
data
)
=>
{
call
()
if
(
!
error
)
{
txExecution
.
callFunction
(
args
.
address
,
data
,
args
.
funABI
,
self
,
(
error
,
txResult
)
=>
{
// TODO here should send the result to the dom-console
console
.
log
(
'function call'
,
error
,
txResult
)
alert
(
error
+
' '
+
txResult
.
transactionHash
)
})
}
else
{
alert
(
error
)
}
})
})
})
function
call
()
{
txFormat
.
buildData
(
args
.
contractAbi
,
self
.
contracts
,
false
,
args
.
funABI
,
inputField
.
val
(),
self
,
self
.
executionContext
,
(
error
,
data
)
=>
{
if
(
!
error
)
{
txExecution
.
callFunction
(
args
.
address
,
data
,
args
.
funABI
,
self
,
(
error
,
txResult
)
=>
{
if
(
!
error
)
{
if
(
lookupOnly
)
{
txFormat
.
decodeResponse
(
self
.
executionContext
.
isVM
()
?
txResult
.
result
.
vm
.
return
:
ethJSUtil
.
toBuffer
(
txResult
.
result
),
args
.
funABI
,
(
error
,
decoded
)
=>
{
$outputOverride
.
html
(
error
?
'error'
+
error
:
decoded
)
})
}
}
else
{
alert
(
error
)
}
})
}
else
{
alert
(
error
)
}
})
}
// TODO the auto call to constant function has been removed. needs to readd it later.
// 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>`
)
...
@@ -383,6 +392,7 @@ UniversalDApp.prototype.getCallButton = function (args) {
...
@@ -383,6 +392,7 @@ UniversalDApp.prototype.getCallButton = function (args) {
if
(
lookupOnly
)
{
if
(
lookupOnly
)
{
$contractProperty
.
addClass
(
'constant'
)
$contractProperty
.
addClass
(
'constant'
)
call
()
}
}
if
(
args
.
funABI
.
inputs
&&
args
.
funABI
.
inputs
.
length
>
0
)
{
if
(
args
.
funABI
.
inputs
&&
args
.
funABI
.
inputs
.
length
>
0
)
{
...
...
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