Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
F
frontend
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
vicotor
frontend
Commits
e5af9612
Commit
e5af9612
authored
Oct 10, 2022
by
tom
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
decoding for topics
parent
f6caf9b7
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
42 additions
and
23 deletions
+42
-23
hexToAddress.ts
lib/hexToAddress.ts
+3
-0
TxLogItem.tsx
ui/tx/logs/TxLogItem.tsx
+0
-3
TxLogTopic.tsx
ui/tx/logs/TxLogTopic.tsx
+39
-20
No files found.
lib/hexToAddress.ts
0 → 100644
View file @
e5af9612
export
default
function
hexToAddress
(
hex
:
string
)
{
return
hex
.
slice
(
0
,
2
)
+
hex
.
slice
(
26
);
}
ui/tx/logs/TxLogItem.tsx
View file @
e5af9612
...
@@ -22,7 +22,6 @@ const TxLogItem = ({ address, index, topics, data, decoded }: Props) => {
...
@@ -22,7 +22,6 @@ const TxLogItem = ({ address, index, topics, data, decoded }: Props) => {
const
borderColor
=
useColorModeValue
(
'
blackAlpha.200
'
,
'
whiteAlpha.200
'
);
const
borderColor
=
useColorModeValue
(
'
blackAlpha.200
'
,
'
whiteAlpha.200
'
);
const
dataBgColor
=
useColorModeValue
(
'
blackAlpha.50
'
,
'
whiteAlpha.50
'
);
const
dataBgColor
=
useColorModeValue
(
'
blackAlpha.50
'
,
'
whiteAlpha.50
'
);
const
decodedTopics
=
decoded
?.
parameters
.
filter
(({
indexed
})
=>
indexed
);
return
(
return
(
<
Grid
<
Grid
...
@@ -69,8 +68,6 @@ const TxLogItem = ({ address, index, topics, data, decoded }: Props) => {
...
@@ -69,8 +68,6 @@ const TxLogItem = ({ address, index, topics, data, decoded }: Props) => {
<
TxLogTopic
<
TxLogTopic
key=
{
index
}
key=
{
index
}
hex=
{
item
}
hex=
{
item
}
decoded=
{
decodedTopics
?.[
index
-
1
]?.
value
}
type=
{
decodedTopics
?.[
index
-
1
]?.
type
}
index=
{
index
}
index=
{
index
}
/>
/>
))
}
))
}
...
...
ui/tx/logs/TxLogTopic.tsx
View file @
e5af9612
import
{
Flex
,
Button
,
Select
,
Box
}
from
'
@chakra-ui/react
'
;
import
{
Flex
,
Button
,
Select
,
Box
}
from
'
@chakra-ui/react
'
;
import
capitalize
from
'
lodash/capitalize
'
;
import
React
from
'
react
'
;
import
React
from
'
react
'
;
import
hexToAddress
from
'
lib/hexToAddress
'
;
import
hexToUtf8
from
'
lib/hexToUtf8
'
;
import
AddressLink
from
'
ui/shared/address/AddressLink
'
;
import
AddressLink
from
'
ui/shared/address/AddressLink
'
;
import
CopyToClipboard
from
'
ui/shared/CopyToClipboard
'
;
import
HashStringShortenDynamic
from
'
ui/shared/HashStringShortenDynamic
'
;
import
HashStringShortenDynamic
from
'
ui/shared/HashStringShortenDynamic
'
;
interface
Props
{
interface
Props
{
hex
:
string
;
hex
:
string
;
decoded
?:
string
;
type
?:
string
;
index
:
number
;
index
:
number
;
}
}
type
DataType
=
'
Hex
'
|
'
Dec
'
;
type
DataType
=
'
hex
'
|
'
text
'
|
'
address
'
|
'
number
'
;
const
OPTIONS
:
Array
<
DataType
>
=
[
'
Hex
'
,
'
Dec
'
];
const
TxLogTopic
=
({
hex
,
index
,
decoded
,
type
}:
Props
)
=>
{
const
VALUE_CONVERTERS
:
Record
<
DataType
,
(
hex
:
string
)
=>
string
>
=
{
const
[
selectedDataType
,
setSelectedDataType
]
=
React
.
useState
<
DataType
>
(
'
Hex
'
);
hex
:
(
hex
)
=>
hex
,
text
:
hexToUtf8
,
address
:
hexToAddress
,
number
:
(
hex
)
=>
BigInt
(
hex
).
toString
(),
};
const
OPTIONS
:
Array
<
DataType
>
=
[
'
hex
'
,
'
address
'
,
'
text
'
,
'
number
'
];
const
TxLogTopic
=
({
hex
,
index
}:
Props
)
=>
{
const
[
selectedDataType
,
setSelectedDataType
]
=
React
.
useState
<
DataType
>
(
'
hex
'
);
const
handleSelectChange
=
React
.
useCallback
((
event
:
React
.
ChangeEvent
<
HTMLSelectElement
>
)
=>
{
const
handleSelectChange
=
React
.
useCallback
((
event
:
React
.
ChangeEvent
<
HTMLSelectElement
>
)
=>
{
setSelectedDataType
(
event
.
target
.
value
as
DataType
);
setSelectedDataType
(
event
.
target
.
value
as
DataType
);
},
[]);
},
[]);
const
value
=
VALUE_CONVERTERS
[
selectedDataType
.
toLowerCase
()
as
Lowercase
<
DataType
>
](
hex
);
const
content
=
(()
=>
{
const
content
=
(()
=>
{
if
(
selectedDataType
===
'
Dec
'
&&
type
===
'
address
'
&&
decoded
)
{
switch
(
selectedDataType
)
{
return
(
case
'
hex
'
:
<
AddressLink
hash=
{
decoded
}
/>
case
'
number
'
:
);
case
'
text
'
:
{
}
return
(
<>
<
Box
overflow=
"hidden"
whiteSpace=
"nowrap"
>
<
HashStringShortenDynamic
hash=
{
value
}
/>
</
Box
>
<
CopyToClipboard
text=
{
value
}
/>
</>
);
}
const
value
=
selectedDataType
===
'
Dec
'
&&
decoded
?
decoded
:
hex
;
case
'
address
'
:
{
return
(
return
(
<
Box
overflow=
"hidden"
whiteSpace=
"nowrap"
>
<
AddressLink
hash=
{
hexToAddress
(
hex
)
}
/
>
<
HashStringShortenDynamic
hash=
{
value
}
/>
);
</
Box
>
}
);
}
})();
})();
return
(
return
(
...
@@ -41,18 +60,18 @@ const TxLogTopic = ({ hex, index, decoded, type }: Props) => {
...
@@ -41,18 +60,18 @@ const TxLogTopic = ({ hex, index, decoded, type }: Props) => {
<
Button
variant=
"outline"
colorScheme=
"gray"
isActive
size=
"xs"
fontWeight=
{
400
}
mr=
{
3
}
w=
{
6
}
>
<
Button
variant=
"outline"
colorScheme=
"gray"
isActive
size=
"xs"
fontWeight=
{
400
}
mr=
{
3
}
w=
{
6
}
>
{
index
}
{
index
}
</
Button
>
</
Button
>
{
decoded
&&
(
{
index
!==
0
&&
(
<
Select
<
Select
size=
"sm"
size=
"sm"
borderRadius=
"base"
borderRadius=
"base"
value=
{
selectedDataType
}
value=
{
selectedDataType
}
onChange=
{
handleSelectChange
}
onChange=
{
handleSelectChange
}
focusBorderColor=
"none"
focusBorderColor=
"none"
w=
"75px"
mr=
{
3
}
mr=
{
3
}
flexShrink=
{
0
}
flexShrink=
{
0
}
w=
"auto"
>
>
{
OPTIONS
.
map
((
option
)
=>
<
option
key=
{
option
}
value=
{
option
}
>
{
option
}
</
option
>)
}
{
OPTIONS
.
map
((
option
)
=>
<
option
key=
{
option
}
value=
{
option
}
>
{
capitalize
(
option
)
}
</
option
>)
}
</
Select
>
</
Select
>
)
}
)
}
{
content
}
{
content
}
...
...
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