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
adcf81d3
Commit
adcf81d3
authored
Sep 19, 2017
by
yann300
Committed by
GitHub
Sep 19, 2017
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #798 from ethereum/fixDecoding3
Fix Decoding input/output/log
parents
c0bceb7f
a3e41906
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
51 additions
and
38 deletions
+51
-38
txHelper.js
src/app/execution/txHelper.js
+5
-1
txLogger.js
src/app/execution/txLogger.js
+9
-37
typeConversion.js
src/lib/typeConversion.js
+37
-0
No files found.
src/app/execution/txHelper.js
View file @
adcf81d3
...
@@ -7,10 +7,14 @@ module.exports = {
...
@@ -7,10 +7,14 @@ module.exports = {
var
types
=
[]
var
types
=
[]
if
(
funABI
.
inputs
&&
funABI
.
inputs
.
length
)
{
if
(
funABI
.
inputs
&&
funABI
.
inputs
.
length
)
{
for
(
var
i
=
0
;
i
<
funABI
.
inputs
.
length
;
i
++
)
{
for
(
var
i
=
0
;
i
<
funABI
.
inputs
.
length
;
i
++
)
{
types
.
push
(
funABI
.
inputs
[
i
].
type
)
var
type
=
funABI
.
inputs
[
i
].
type
types
.
push
(
type
)
if
(
args
.
length
<
types
.
length
)
{
if
(
args
.
length
<
types
.
length
)
{
args
.
push
(
''
)
args
.
push
(
''
)
}
}
if
(
args
[
i
].
indexOf
&&
args
[
i
].
indexOf
(
'0x'
)
===
0
)
{
args
[
i
]
=
new
Buffer
(
args
[
i
].
replace
(
'0x'
,
''
),
'hex'
)
}
}
}
}
}
...
...
src/app/execution/txLogger.js
View file @
adcf81d3
...
@@ -10,10 +10,9 @@ var styles = styleGuide()
...
@@ -10,10 +10,9 @@ var styles = styleGuide()
var
EventManager
=
remix
.
lib
.
EventManager
var
EventManager
=
remix
.
lib
.
EventManager
var
helper
=
require
(
'../../lib/helper'
)
var
helper
=
require
(
'../../lib/helper'
)
var
ethJSUtil
=
require
(
'ethereumjs-util'
)
var
BN
=
ethJSUtil
.
BN
var
executionContext
=
require
(
'../../execution-context'
)
var
executionContext
=
require
(
'../../execution-context'
)
var
modalDialog
=
require
(
'../ui/modal-dialog-custom'
)
var
modalDialog
=
require
(
'../ui/modal-dialog-custom'
)
var
typeConversion
=
require
(
'../../lib/typeConversion'
)
var
css
=
csjs
`
var
css
=
csjs
`
.log {
.log {
...
@@ -173,8 +172,8 @@ function renderKnownTransaction (self, data) {
...
@@ -173,8 +172,8 @@ function renderKnownTransaction (self, data) {
gas
:
data
.
tx
.
gas
,
gas
:
data
.
tx
.
gas
,
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
(
typeConversion
.
stringify
(
data
.
resolvedData
.
params
),
null
,
'
\
t'
)
:
' - '
,
'decoded output'
:
data
.
resolvedData
&&
data
.
resolvedData
.
decodedReturnValue
?
JSON
.
stringify
(
value
(
data
.
resolvedData
.
decodedReturnValue
),
null
,
'
\
t'
)
:
' - '
,
'decoded output'
:
data
.
resolvedData
&&
data
.
resolvedData
.
decodedReturnValue
?
JSON
.
stringify
(
typeConversion
.
stringify
(
data
.
resolvedData
.
decodedReturnValue
),
null
,
'
\
t'
)
:
' - '
,
logs
:
data
.
logs
,
logs
:
data
.
logs
,
val
:
data
.
tx
.
value
val
:
data
.
tx
.
value
})
})
...
@@ -204,7 +203,7 @@ function renderCall (self, data) {
...
@@ -204,7 +203,7 @@ function renderCall (self, data) {
<button class=
${
css
.
debug
}
onclick=
${
debug
}
>Debug</button>
<button class=
${
css
.
debug
}
onclick=
${
debug
}
>Debug</button>
</div>
</div>
</div>
</div>
<div>
${
JSON
.
stringify
(
value
(
data
.
resolvedData
.
decodedReturnValue
),
null
,
'
\
t'
)}
</div>
<div>
${
JSON
.
stringify
(
typeConversion
.
stringify
(
data
.
resolvedData
.
decodedReturnValue
),
null
,
'
\
t'
)}
</div>
</span>
</span>
`
`
return
tx
return
tx
...
@@ -264,40 +263,13 @@ function context (self, opts) {
...
@@ -264,40 +263,13 @@ function context (self, opts) {
var
block
=
data
.
tx
.
blockNumber
||
''
var
block
=
data
.
tx
.
blockNumber
||
''
var
i
=
data
.
tx
.
transactionIndex
var
i
=
data
.
tx
.
transactionIndex
if
(
executionContext
.
getProvider
()
===
'vm'
)
{
if
(
executionContext
.
getProvider
()
===
'vm'
)
{
return
yo
`<span><span class=
${
css
.
tx
}
>[vm]</span> from:
${
from
}
, to:
${
to
}
, value:
${
value
(
val
)}
wei, data:
${
input
}
,
${
logs
}
logs, hash:
${
hash
}
</span>`
return
yo
`<span><span class=
${
css
.
tx
}
>[vm]</span> from:
${
from
}
, to:
${
to
}
, value:
${
typeConversion
.
hexToInt
(
val
)}
wei, data:
${
input
}
,
${
logs
}
logs, hash:
${
hash
}
</span>`
}
else
if
(
executionContext
.
getProvider
()
!==
'vm'
&&
data
.
resolvedData
)
{
}
else
if
(
executionContext
.
getProvider
()
!==
'vm'
&&
data
.
resolvedData
)
{
return
yo
`<span><span class='
${
css
.
tx
}
'>[block:
${
block
}
txIndex:
${
i
}
]</span> from:
${
from
}
, to:
${
to
}
, value:
${
value
(
val
)}
wei,
${
logs
}
logs, data:
${
input
}
, hash:
${
hash
}
</span>`
return
yo
`<span><span class='
${
css
.
tx
}
'>[block:
${
block
}
txIndex:
${
i
}
]</span> from:
${
from
}
, to:
${
to
}
, value:
${
typeConversion
.
hexToInt
(
val
)}
wei,
${
logs
}
logs, data:
${
input
}
, hash:
${
hash
}
</span>`
}
else
{
}
else
{
to
=
helper
.
shortenHexData
(
to
)
to
=
helper
.
shortenHexData
(
to
)
hash
=
helper
.
shortenHexData
(
data
.
tx
.
blockHash
)
hash
=
helper
.
shortenHexData
(
data
.
tx
.
blockHash
)
return
yo
`<span><span class='
${
css
.
tx
}
'>[block:
${
block
}
txIndex:
${
i
}
]</span> from:
${
from
}
, to:
${
to
}
, value:
${
value
(
val
)}
wei</span>`
return
yo
`<span><span class='
${
css
.
tx
}
'>[block:
${
block
}
txIndex:
${
i
}
]</span> from:
${
from
}
, to:
${
to
}
, value:
${
typeConversion
.
hexToInt
(
val
)}
wei</span>`
}
}
function
value
(
v
)
{
try
{
if
(
v
instanceof
Array
)
{
var
ret
=
[]
for
(
var
k
in
v
)
{
ret
.
push
(
value
(
v
[
k
]))
}
return
ret
}
else
if
(
BN
.
isBN
(
v
)
||
(
v
.
constructor
&&
v
.
constructor
.
name
===
'BigNumber'
))
{
return
v
.
toString
(
10
)
}
else
if
(
v
.
indexOf
&&
v
.
indexOf
(
'0x'
)
===
0
)
{
return
(
new
BN
(
v
.
replace
(
'0x'
,
''
),
16
)).
toString
(
10
)
}
else
if
(
typeof
v
===
'object'
)
{
var
retObject
=
{}
for
(
var
i
in
v
)
{
retObject
[
i
]
=
value
(
v
[
i
])
}
return
retObject
}
else
{
return
v
}
}
catch
(
e
)
{
console
.
log
(
e
)
return
v
}
}
}
}
...
@@ -383,7 +355,7 @@ function createTable (opts) {
...
@@ -383,7 +355,7 @@ function createTable (opts) {
var
stringified
=
' - '
var
stringified
=
' - '
if
(
opts
.
logs
.
decoded
)
{
if
(
opts
.
logs
.
decoded
)
{
stringified
=
value
(
opts
.
logs
.
decoded
)
stringified
=
typeConversion
.
stringify
(
opts
.
logs
.
decoded
)
}
}
var
logs
=
yo
`
var
logs
=
yo
`
<tr class="
${
css
.
tr
}
">
<tr class="
${
css
.
tr
}
">
...
@@ -395,7 +367,7 @@ function createTable (opts) {
...
@@ -395,7 +367,7 @@ function createTable (opts) {
`
`
if
(
opts
.
logs
)
table
.
appendChild
(
logs
)
if
(
opts
.
logs
)
table
.
appendChild
(
logs
)
var
val
=
value
(
opts
.
val
)
var
val
=
typeConversion
.
hexToInt
(
opts
.
val
)
val
=
yo
`
val
=
yo
`
<tr class="
${
css
.
tr
}
">
<tr class="
${
css
.
tr
}
">
<td class="
${
css
.
td
}
"> value </td>
<td class="
${
css
.
td
}
"> value </td>
...
...
src/lib/typeConversion.js
0 → 100644
View file @
adcf81d3
'use strict'
var
ethJSUtil
=
require
(
'ethereumjs-util'
)
var
BN
=
ethJSUtil
.
BN
module
.
exports
=
{
hexToInt
:
(
h
)
=>
{
return
(
new
BN
(
h
.
replace
(
'0x'
,
''
),
16
)).
toString
(
10
)
},
stringify
:
stringify
}
function
stringify
(
v
)
{
try
{
if
(
v
instanceof
Array
)
{
var
ret
=
[]
for
(
var
k
in
v
)
{
ret
.
push
(
stringify
(
v
[
k
]))
}
return
ret
}
else
if
(
BN
.
isBN
(
v
)
||
(
v
.
constructor
&&
v
.
constructor
.
name
===
'BigNumber'
))
{
return
v
.
toString
(
10
)
}
else
if
(
v
.
_isBuffer
)
{
return
ethJSUtil
.
bufferToHex
(
v
)
}
else
if
(
typeof
v
===
'object'
)
{
var
retObject
=
{}
for
(
var
i
in
v
)
{
retObject
[
i
]
=
stringify
(
v
[
i
])
}
return
retObject
}
else
{
return
v
}
}
catch
(
e
)
{
console
.
log
(
e
)
return
v
}
}
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