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
00f41bf2
Commit
00f41bf2
authored
Jun 09, 2016
by
Alex Beregszaszi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
UDapp: decode constant responses in web3 mode
parent
e7b581de
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
35 additions
and
21 deletions
+35
-21
universal-dapp.js
src/universal-dapp.js
+35
-21
No files found.
src/universal-dapp.js
View file @
00f41bf2
...
@@ -447,23 +447,7 @@ UniversalDApp.prototype.getCallButton = function (args) {
...
@@ -447,23 +447,7 @@ UniversalDApp.prototype.getCallButton = function (args) {
}
}
}
}
self
.
runTx
(
data
,
args
,
function
(
err
,
result
)
{
var
decodeResponse
=
function
(
response
)
{
if
(
err
)
{
replaceOutput
(
$result
,
$
(
'<span/>'
).
text
(
err
).
addClass
(
'error'
));
// VM only
}
else
if
(
self
.
options
.
vm
&&
result
.
vm
.
exception
&&
result
.
vm
.
exceptionError
)
{
replaceOutput
(
$result
,
$
(
'<span/>'
).
text
(
'VM Exception: '
+
result
.
vm
.
exceptionError
).
addClass
(
'error'
));
// VM only
}
else
if
(
self
.
options
.
vm
&&
result
.
vm
.
return
===
undefined
)
{
replaceOutput
(
$result
,
$
(
'<span/>'
).
text
(
'Exception during execution.'
).
addClass
(
'error'
));
}
else
if
(
isConstructor
)
{
replaceOutput
(
$result
,
getGasUsedOutput
(
result
,
result
.
vm
));
args
.
appendFunctions
(
self
.
options
.
vm
?
result
.
createdAddress
:
result
.
contractAddress
);
}
else
if
(
self
.
options
.
vm
)
{
var
outputObj
=
'0x'
+
result
.
vm
.
return
.
toString
(
'hex'
);
clearOutput
(
$result
);
$result
.
append
(
getReturnOutput
(
outputObj
)).
append
(
getGasUsedOutput
(
result
,
result
.
vm
));
// Only decode if there supposed to be fields
// Only decode if there supposed to be fields
if
(
args
.
abi
.
outputs
.
length
>
0
)
{
if
(
args
.
abi
.
outputs
.
length
>
0
)
{
try
{
try
{
...
@@ -475,7 +459,7 @@ UniversalDApp.prototype.getCallButton = function (args) {
...
@@ -475,7 +459,7 @@ UniversalDApp.prototype.getCallButton = function (args) {
}
}
// decode data
// decode data
var
decodedObj
=
ethJSABI
.
rawDecode
(
outputTypes
,
res
ult
.
vm
.
return
);
var
decodedObj
=
ethJSABI
.
rawDecode
(
outputTypes
,
res
ponse
);
// format decoded data
// format decoded data
decodedObj
=
ethJSABI
.
stringify
(
outputTypes
,
decodedObj
);
decodedObj
=
ethJSABI
.
stringify
(
outputTypes
,
decodedObj
);
...
@@ -488,13 +472,43 @@ UniversalDApp.prototype.getCallButton = function (args) {
...
@@ -488,13 +472,43 @@ UniversalDApp.prototype.getCallButton = function (args) {
}
}
}
}
$result
.
append
(
getDecodedOutput
(
decodedObj
)
);
return
getDecodedOutput
(
decodedObj
);
}
catch
(
e
)
{
}
catch
(
e
)
{
$result
.
append
(
getDecodedOutput
(
'Failed to decode output: '
+
e
)
);
return
getDecodedOutput
(
'Failed to decode output: '
+
e
);
}
}
}
}
};
var
decoded
;
self
.
runTx
(
data
,
args
,
function
(
err
,
result
)
{
if
(
err
)
{
replaceOutput
(
$result
,
$
(
'<span/>'
).
text
(
err
).
addClass
(
'error'
));
// VM only
}
else
if
(
self
.
options
.
vm
&&
result
.
vm
.
exception
&&
result
.
vm
.
exceptionError
)
{
replaceOutput
(
$result
,
$
(
'<span/>'
).
text
(
'VM Exception: '
+
result
.
vm
.
exceptionError
).
addClass
(
'error'
));
// VM only
}
else
if
(
self
.
options
.
vm
&&
result
.
vm
.
return
===
undefined
)
{
replaceOutput
(
$result
,
$
(
'<span/>'
).
text
(
'Exception during execution.'
).
addClass
(
'error'
));
}
else
if
(
isConstructor
)
{
replaceOutput
(
$result
,
getGasUsedOutput
(
result
,
result
.
vm
));
args
.
appendFunctions
(
self
.
options
.
vm
?
result
.
createdAddress
:
result
.
contractAddress
);
}
else
if
(
self
.
options
.
vm
)
{
var
outputObj
=
'0x'
+
result
.
vm
.
return
.
toString
(
'hex'
);
clearOutput
(
$result
);
$result
.
append
(
getReturnOutput
(
outputObj
)).
append
(
getGasUsedOutput
(
result
,
result
.
vm
));
decoded
=
decodeResponse
(
result
.
vm
.
return
);
if
(
decoded
)
{
$result
.
append
(
decoded
);
}
}
else
if
(
args
.
abi
.
constant
&&
!
isConstructor
)
{
}
else
if
(
args
.
abi
.
constant
&&
!
isConstructor
)
{
replaceOutput
(
$result
,
getReturnOutput
(
result
));
clearOutput
(
$result
);
$result
.
append
(
getReturnOutput
(
result
)).
append
(
getGasUsedOutput
({}));
decoded
=
decodeResponse
(
ethJSUtil
.
toBuffer
(
result
));
if
(
decoded
)
{
$result
.
append
(
decoded
);
}
}
else
{
}
else
{
clearOutput
(
$result
);
clearOutput
(
$result
);
$result
.
append
(
getReturnOutput
(
result
)).
append
(
getGasUsedOutput
(
result
));
$result
.
append
(
getReturnOutput
(
result
)).
append
(
getGasUsedOutput
(
result
));
...
...
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