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
d5b890fb
Commit
d5b890fb
authored
May 17, 2021
by
yann300
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactor calldata decoding & fix nested array decoding
parent
f8be36a5
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
26 additions
and
8 deletions
+26
-8
RefType.ts
libs/remix-debug/src/solidity-decoder/types/RefType.ts
+26
-8
No files found.
libs/remix-debug/src/solidity-decoder/types/RefType.ts
View file @
d5b890fb
...
...
@@ -52,6 +52,13 @@ export class RefType {
offset
=
parseInt
(
offset
,
16
)
return
this
.
decodeFromMemoryInternal
(
offset
,
memory
,
cursor
)
}
else
if
(
this
.
isInCallData
())
{
return
this
.
_decodeFromCallData
(
variableDetails
,
calldata
)
}
else
{
return
{
error
:
'<decoding failed - no decoder for '
+
this
.
location
+
'>'
,
type
:
this
.
typeName
}
}
}
_decodeFromCallData
(
variableDetails
,
calldata
)
{
calldata
=
calldata
.
length
>
0
?
calldata
[
0
]
:
'0x'
const
ethersAbi
=
new
ethers
.
utils
.
Interface
(
variableDetails
.
abi
)
const
fnSign
=
calldata
.
substr
(
0
,
10
)
...
...
@@ -59,20 +66,31 @@ export class RefType {
let
decodedValue
=
decodedData
[
variableDetails
.
name
]
const
isArray
=
Array
.
isArray
(
decodedValue
)
if
(
isArray
)
{
decodedValue
=
decodedValue
.
map
((
el
)
=>
{
return
{
value
:
el
.
toString
(),
type
:
this
.
underlyingType
.
typeName
}
})
return
this
.
_decodeCallDataArray
(
decodedValue
,
this
)
}
return
{
length
:
Array
.
isArray
(
decodedValue
)
?
'0x'
+
decodedValue
.
length
.
toString
(
16
)
:
undefined
,
length
:
isArray
?
'0x'
+
decodedValue
.
length
.
toString
(
16
)
:
undefined
,
value
:
decodedValue
,
type
:
this
.
typeName
}
}
_decodeCallDataArray
(
value
,
type
)
{
const
isArray
=
Array
.
isArray
(
value
)
if
(
isArray
)
{
value
=
value
.
map
((
el
)
=>
{
return
this
.
_decodeCallDataArray
(
el
,
this
.
underlyingType
)
})
return
{
length
:
value
.
length
.
toString
(
16
),
value
:
value
,
type
:
type
.
typeName
}
}
else
{
return
{
error
:
'<decoding failed - no decoder for '
+
this
.
location
+
'>'
,
type
:
this
.
typeName
}
return
{
value
:
value
.
toString
(),
type
:
type
.
underlyingType
.
typeName
}
}
}
...
...
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