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
b28ff3dc
Commit
b28ff3dc
authored
Oct 11, 2022
by
tom
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixes
parent
23155089
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
25 additions
and
22 deletions
+25
-22
index.ts
pages/api/blocks/index.ts
+1
-1
BlocksContent.tsx
ui/blocks/BlocksContent.tsx
+11
-8
BlocksListItem.tsx
ui/blocks/BlocksListItem.tsx
+2
-2
BlocksTable.tsx
ui/blocks/BlocksTable.tsx
+5
-5
BlocksTableItem.tsx
ui/blocks/BlocksTableItem.tsx
+6
-6
No files found.
pages/api/blocks/index.ts
View file @
b28ff3dc
...
@@ -3,7 +3,7 @@ import type { NextApiRequest } from 'next';
...
@@ -3,7 +3,7 @@ import type { NextApiRequest } from 'next';
import
handler
from
'
lib/api/handler
'
;
import
handler
from
'
lib/api/handler
'
;
const
getUrl
=
(
req
:
NextApiRequest
)
=>
{
const
getUrl
=
(
req
:
NextApiRequest
)
=>
{
return
`/v2/blocks
?type=
${
req
.
query
.
type
}
`
;
return
`/v2/blocks
${
req
.
query
.
type
?
`?type=
${
req
.
query
.
type
}
`
:
''
}
`
;
};
};
const
requestHandler
=
handler
(
getUrl
,
[
'
GET
'
]);
const
requestHandler
=
handler
(
getUrl
,
[
'
GET
'
]);
...
...
ui/blocks/BlocksContent.tsx
View file @
b28ff3dc
import
{
Box
,
Text
,
Show
,
Alert
}
from
'
@chakra-ui/react
'
;
import
{
Box
,
Text
,
Show
,
Alert
,
Skeleton
}
from
'
@chakra-ui/react
'
;
import
{
useQuery
}
from
'
@tanstack/react-query
'
;
import
{
useQuery
}
from
'
@tanstack/react-query
'
;
import
React
from
'
react
'
;
import
React
from
'
react
'
;
...
@@ -21,15 +21,18 @@ const BlocksContent = ({ type }: Props) => {
...
@@ -21,15 +21,18 @@ const BlocksContent = ({ type }: Props) => {
const
{
data
,
isLoading
,
isError
}
=
useQuery
<
unknown
,
unknown
,
BlocksResponse
>
(
const
{
data
,
isLoading
,
isError
}
=
useQuery
<
unknown
,
unknown
,
BlocksResponse
>
(
[
'
blocks
'
,
type
],
[
'
blocks
'
,
type
],
async
()
=>
await
fetch
(
`/api/blocks
?type=
${
type
}
`
),
async
()
=>
await
fetch
(
`/api/blocks
${
type
?
`?type=
${
type
}
`
:
''
}
`
),
);
);
if
(
isLoading
)
{
if
(
isLoading
)
{
return
(
return
(
<>
<>
<
Show
below=
"lg"
><
BlocksSkeletonMobile
/></
Show
>
<
Show
below=
"lg"
key=
"skeleton-mobile"
>
<
Show
above=
"lg"
>
<
BlocksSkeletonMobile
/>
<
SkeletonTable
columns=
{
[
'
124px
'
,
'
112px
'
,
'
144px
'
,
'
64px
'
,
'
40%
'
,
'
30%
'
,
'
30%
'
]
}
/>
</
Show
>
<
Show
above=
"lg"
key=
"skeleton-desktop"
>
<
Skeleton
h=
{
6
}
mb=
{
8
}
w=
"150px"
/>
<
SkeletonTable
columns=
{
[
'
125px
'
,
'
112px
'
,
'
21%
'
,
'
64px
'
,
'
35%
'
,
'
22%
'
,
'
22%
'
]
}
/>
</
Show
>
</
Show
>
</>
</>
);
);
...
@@ -45,9 +48,9 @@ const BlocksContent = ({ type }: Props) => {
...
@@ -45,9 +48,9 @@ const BlocksContent = ({ type }: Props) => {
return
(
return
(
<>
<>
<
Text
>
Total of
15,044,883
blocks
</
Text
>
<
Text
>
Total of
{
data
.
items
[
0
].
height
.
toLocaleString
()
}
blocks
</
Text
>
<
Show
below=
"lg"
><
BlocksList
data=
{
data
.
items
}
/></
Show
>
<
Show
below=
"lg"
key=
"content-mobile"
><
BlocksList
data=
{
data
.
items
}
/></
Show
>
<
Show
above=
"lg"
><
BlocksTable
data=
{
data
.
items
}
/></
Show
>
<
Show
above=
"lg"
key=
"content-desktop"
><
BlocksTable
data=
{
data
.
items
}
/></
Show
>
<
Box
mx=
{
{
base
:
0
,
lg
:
6
}
}
my=
{
{
base
:
6
,
lg
:
3
}
}
>
<
Box
mx=
{
{
base
:
0
,
lg
:
6
}
}
my=
{
{
base
:
6
,
lg
:
3
}
}
>
<
Pagination
currentPage=
{
1
}
/>
<
Pagination
currentPage=
{
1
}
/>
</
Box
>
</
Box
>
...
...
ui/blocks/BlocksListItem.tsx
View file @
b28ff3dc
import
{
Flex
,
Link
,
Spinner
,
Text
,
Box
,
Icon
,
useColorModeValue
}
from
'
@chakra-ui/react
'
;
import
{
Flex
,
Link
,
Spinner
,
Text
,
Box
,
Icon
,
useColorModeValue
}
from
'
@chakra-ui/react
'
;
import
{
utils
}
from
'
ethers
'
;
import
{
constants
,
utils
}
from
'
ethers
'
;
import
React
from
'
react
'
;
import
React
from
'
react
'
;
import
type
{
Block
}
from
'
types/api/block
'
;
import
type
{
Block
}
from
'
types/api/block
'
;
...
@@ -67,7 +67,7 @@ const BlocksListItem = ({ data, isPending }: Props) => {
...
@@ -67,7 +67,7 @@ const BlocksListItem = ({ data, isPending }: Props) => {
<
Text
fontWeight=
{
500
}
>
Burnt fees
</
Text
>
<
Text
fontWeight=
{
500
}
>
Burnt fees
</
Text
>
<
Icon
as=
{
flameIcon
}
boxSize=
{
5
}
color=
"gray.500"
ml=
{
2
}
/>
<
Icon
as=
{
flameIcon
}
boxSize=
{
5
}
color=
"gray.500"
ml=
{
2
}
/>
<
Text
variant=
"secondary"
ml=
{
1
}
>
{
utils
.
formatUnits
(
burntFees
)
}
</
Text
>
<
Text
variant=
"secondary"
ml=
{
1
}
>
{
utils
.
formatUnits
(
burntFees
)
}
</
Text
>
<
Utilization
ml=
{
4
}
value=
{
burntFees
.
mul
(
10
_000
).
div
(
txFees
).
toNumber
()
/
10
_000
}
/>
<
Utilization
ml=
{
4
}
value=
{
txFees
.
eq
(
constants
.
Zero
)
?
1
:
burntFees
.
mul
(
10
_000
).
div
(
txFees
).
toNumber
()
/
10
_000
}
/>
</
Flex
>
</
Flex
>
</
AccountListItemMobile
>
</
AccountListItemMobile
>
);
);
...
...
ui/blocks/BlocksTable.tsx
View file @
b28ff3dc
...
@@ -18,13 +18,13 @@ const BlocksTable = ({ data }: Props) => {
...
@@ -18,13 +18,13 @@ const BlocksTable = ({ data }: Props) => {
<
Table
variant=
"simple"
minWidth=
"1040px"
size=
"md"
fontWeight=
{
500
}
>
<
Table
variant=
"simple"
minWidth=
"1040px"
size=
"md"
fontWeight=
{
500
}
>
<
Thead
>
<
Thead
>
<
Tr
>
<
Tr
>
<
Th
width=
"12
4
px"
>
Block
</
Th
>
<
Th
width=
"12
5
px"
>
Block
</
Th
>
<
Th
width=
"112px"
>
Size
</
Th
>
<
Th
width=
"112px"
>
Size
</
Th
>
<
Th
width=
"144px"
>
Miner
</
Th
>
<
Th
width=
"
21%"
minW=
"
144px"
>
Miner
</
Th
>
<
Th
width=
"64px"
isNumeric
>
Txn
</
Th
>
<
Th
width=
"64px"
isNumeric
>
Txn
</
Th
>
<
Th
width=
"
40
%"
>
Gas used
</
Th
>
<
Th
width=
"
35
%"
>
Gas used
</
Th
>
<
Th
width=
"
30
%"
>
Reward
{
network
?.
currency
}
</
Th
>
<
Th
width=
"
22
%"
>
Reward
{
network
?.
currency
}
</
Th
>
<
Th
width=
"
30
%"
>
Burnt fees
{
network
?.
currency
}
</
Th
>
<
Th
width=
"
22
%"
>
Burnt fees
{
network
?.
currency
}
</
Th
>
</
Tr
>
</
Tr
>
</
Thead
>
</
Thead
>
<
Tbody
>
<
Tbody
>
...
...
ui/blocks/BlocksTableItem.tsx
View file @
b28ff3dc
import
{
Tr
,
Td
,
Text
,
Link
,
Flex
,
Box
,
Icon
,
Tooltip
,
Spinner
,
useColorModeValue
}
from
'
@chakra-ui/react
'
;
import
{
Tr
,
Td
,
Text
,
Link
,
Flex
,
Box
,
Icon
,
Tooltip
,
Spinner
,
useColorModeValue
}
from
'
@chakra-ui/react
'
;
import
{
utils
}
from
'
ethers
'
;
import
{
constants
,
utils
}
from
'
ethers
'
;
import
React
from
'
react
'
;
import
React
from
'
react
'
;
import
type
{
Block
}
from
'
types/api/block
'
;
import
type
{
Block
}
from
'
types/api/block
'
;
...
@@ -27,7 +27,7 @@ const BlocksTableItem = ({ data, isPending }: Props) => {
...
@@ -27,7 +27,7 @@ const BlocksTableItem = ({ data, isPending }: Props) => {
<
Tr
>
<
Tr
>
<
Td
fontSize=
"sm"
>
<
Td
fontSize=
"sm"
>
<
Flex
columnGap=
{
2
}
alignItems=
"center"
>
<
Flex
columnGap=
{
2
}
alignItems=
"center"
>
{
isPending
&&
<
Spinner
size=
"sm"
color=
"blue.500"
emptyColor=
{
spinnerEmptyColor
}
/>
}
{
isPending
&&
<
Spinner
size=
"sm"
color=
"blue.500"
emptyColor=
{
spinnerEmptyColor
}
flexShrink=
{
0
}
/>
}
<
Link
<
Link
fontWeight=
{
600
}
fontWeight=
{
600
}
href=
{
link
(
'
block_index
'
,
{
id
:
String
(
data
.
height
)
})
}
href=
{
link
(
'
block_index
'
,
{
id
:
String
(
data
.
height
)
})
}
...
@@ -39,7 +39,7 @@ const BlocksTableItem = ({ data, isPending }: Props) => {
...
@@ -39,7 +39,7 @@ const BlocksTableItem = ({ data, isPending }: Props) => {
</
Td
>
</
Td
>
<
Td
fontSize=
"sm"
>
{
data
.
size
.
toLocaleString
(
'
en
'
)
}
bytes
</
Td
>
<
Td
fontSize=
"sm"
>
{
data
.
size
.
toLocaleString
(
'
en
'
)
}
bytes
</
Td
>
<
Td
fontSize=
"sm"
>
<
Td
fontSize=
"sm"
>
<
AddressLink
alias=
{
data
.
miner
.
name
}
hash=
{
data
.
miner
.
hash
}
truncation=
"constant"
/>
<
AddressLink
alias=
{
data
.
miner
.
name
}
hash=
{
data
.
miner
.
hash
}
truncation=
"constant"
display=
"inline-flex"
maxW=
"100%"
/>
</
Td
>
</
Td
>
<
Td
isNumeric
fontSize=
"sm"
>
{
data
.
tx_count
}
</
Td
>
<
Td
isNumeric
fontSize=
"sm"
>
{
data
.
tx_count
}
</
Td
>
<
Td
fontSize=
"sm"
>
<
Td
fontSize=
"sm"
>
...
@@ -56,11 +56,11 @@ const BlocksTableItem = ({ data, isPending }: Props) => {
...
@@ -56,11 +56,11 @@ const BlocksTableItem = ({ data, isPending }: Props) => {
<
Td
fontSize=
"sm"
>
<
Td
fontSize=
"sm"
>
<
Flex
alignItems=
"center"
columnGap=
{
1
}
>
<
Flex
alignItems=
"center"
columnGap=
{
1
}
>
<
Icon
as=
{
flameIcon
}
boxSize=
{
5
}
color=
{
useColorModeValue
(
'
gray.500
'
,
'
inherit
'
)
}
/>
<
Icon
as=
{
flameIcon
}
boxSize=
{
5
}
color=
{
useColorModeValue
(
'
gray.500
'
,
'
inherit
'
)
}
/>
{
utils
.
formatUnits
(
burntFees
)
}
{
Number
(
utils
.
formatUnits
(
burntFees
)).
toFixed
(
8
)
}
</
Flex
>
</
Flex
>
<
Tooltip
label=
"Burnt fees / Txn fees * 100%"
>
<
Tooltip
label=
"Burnt fees / Txn fees * 100%"
>
<
Box
>
<
Box
w=
"min-content"
>
<
Utilization
mt=
{
2
}
value=
{
burntFees
.
mul
(
10
_000
).
div
(
txFees
).
toNumber
()
/
10
_000
}
/>
<
Utilization
mt=
{
2
}
value=
{
txFees
.
eq
(
constants
.
Zero
)
?
1
:
burntFees
.
mul
(
10
_000
).
div
(
txFees
).
toNumber
()
/
10
_000
}
/>
</
Box
>
</
Box
>
</
Tooltip
>
</
Tooltip
>
</
Td
>
</
Td
>
...
...
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