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
a31fd10b
Commit
a31fd10b
authored
Sep 19, 2018
by
yann300
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
decode / encode array of tuple
parent
20e1a605
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
11 additions
and
7 deletions
+11
-7
txFormat.js
remix-lib/src/execution/txFormat.js
+1
-1
txHelper.js
remix-lib/src/execution/txHelper.js
+9
-5
txListener.js
remix-lib/src/execution/txListener.js
+1
-1
No files found.
remix-lib/src/execution/txFormat.js
View file @
a31fd10b
...
...
@@ -364,7 +364,7 @@ module.exports = {
var
outputTypes
=
[]
for
(
i
=
0
;
i
<
fnabi
.
outputs
.
length
;
i
++
)
{
var
type
=
fnabi
.
outputs
[
i
].
type
outputTypes
.
push
(
type
===
'tuple'
?
helper
.
makeFullTupleTypeDefinition
(
fnabi
.
outputs
[
i
])
:
type
)
outputTypes
.
push
(
type
.
indexOf
(
'tuple'
)
===
0
?
helper
.
makeFullTupleTypeDefinition
(
fnabi
.
outputs
[
i
])
:
type
)
}
if
(
!
response
.
length
)
response
=
new
Uint8Array
(
32
*
fnabi
.
outputs
.
length
)
// ensuring the data is at least filled by 0 cause `AbiCoder` throws if there's not engouh data
...
...
remix-lib/src/execution/txHelper.js
View file @
a31fd10b
...
...
@@ -3,9 +3,9 @@ var ethers = require('ethers')
module
.
exports
=
{
makeFullTupleTypeDefinition
:
function
(
typeDef
)
{
if
(
typeDef
&&
typeDef
.
type
===
'tuple'
&&
typeDef
.
components
)
{
if
(
typeDef
&&
typeDef
.
type
.
indexOf
(
'tuple'
)
===
0
&&
typeDef
.
components
)
{
var
innerTypes
=
typeDef
.
components
.
map
((
innerType
)
=>
innerType
.
type
)
return
'tuple('
+
innerTypes
.
join
(
','
)
+
')'
return
`tuple(
${
innerTypes
.
join
(
','
)}
)
${
this
.
extractSize
(
typeDef
.
type
)}
`
}
return
typeDef
.
type
},
...
...
@@ -15,7 +15,7 @@ module.exports = {
if
(
funABI
.
inputs
&&
funABI
.
inputs
.
length
)
{
for
(
var
i
=
0
;
i
<
funABI
.
inputs
.
length
;
i
++
)
{
var
type
=
funABI
.
inputs
[
i
].
type
types
.
push
(
type
===
'tuple'
?
this
.
makeFullTupleTypeDefinition
(
funABI
.
inputs
[
i
])
:
type
)
types
.
push
(
type
.
indexOf
(
'tuple'
)
===
0
?
this
.
makeFullTupleTypeDefinition
(
funABI
.
inputs
[
i
])
:
type
)
if
(
args
.
length
<
types
.
length
)
{
args
.
push
(
''
)
}
...
...
@@ -85,14 +85,18 @@ module.exports = {
return
serialized
},
extractSize
:
function
(
type
)
{
var
size
=
type
.
match
(
/
([
a-zA-Z0-9
])(\[
.*
\])
/
)
return
size
?
size
[
2
]
:
''
},
getFunction
:
function
(
abi
,
fnName
)
{
for
(
var
i
=
0
;
i
<
abi
.
length
;
i
++
)
{
var
fn
=
abi
[
i
]
if
(
fn
.
type
===
'function'
&&
fnName
===
fn
.
name
+
'('
+
fn
.
inputs
.
map
((
value
)
=>
{
if
(
value
.
components
)
{
// we extract the size (if array) and append it later
var
size
=
value
.
type
.
match
(
/
([
a-zA-Z0-9
])(\[
.*
\])
/
)
size
=
size
?
size
[
2
]
:
''
var
size
=
this
.
extractSize
(
value
.
type
)
return
`(
${
value
.
components
.
map
((
value
)
=>
{
return
value
.
type
}).
join
(
','
)}
)
${
size
}
`
}
else
{
return
value
.
type
...
...
remix-lib/src/execution/txListener.js
View file @
a31fd10b
...
...
@@ -330,7 +330,7 @@ class TxListener {
var
inputTypes
=
[]
for
(
var
i
=
0
;
i
<
abi
.
inputs
.
length
;
i
++
)
{
var
type
=
abi
.
inputs
[
i
].
type
inputTypes
.
push
(
type
===
'tuple'
?
txHelper
.
makeFullTupleTypeDefinition
(
abi
.
inputs
[
i
])
:
type
)
inputTypes
.
push
(
type
.
indexOf
(
'tuple'
)
===
0
?
txHelper
.
makeFullTupleTypeDefinition
(
abi
.
inputs
[
i
])
:
type
)
}
var
abiCoder
=
new
ethers
.
utils
.
AbiCoder
()
var
decoded
=
abiCoder
.
decode
(
inputTypes
,
data
)
...
...
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