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
c1829e8d
Commit
c1829e8d
authored
Oct 10, 2022
by
tom
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
genesis block
parent
d301754e
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
73 additions
and
54 deletions
+73
-54
getBlockReward.ts
lib/block/getBlockReward.ts
+7
-1
BlockDetails.tsx
ui/block/BlockDetails.tsx
+66
-53
No files found.
lib/block/getBlockReward.ts
View file @
c1829e8d
...
@@ -5,7 +5,13 @@ import type { Block } from 'types/api/block';
...
@@ -5,7 +5,13 @@ import type { Block } from 'types/api/block';
export
default
function
getBlockReward
(
block
:
Block
)
{
export
default
function
getBlockReward
(
block
:
Block
)
{
const
txFees
=
utils
.
parseUnits
(
block
.
tx_fees
||
'
0
'
,
'
wei
'
);
const
txFees
=
utils
.
parseUnits
(
block
.
tx_fees
||
'
0
'
,
'
wei
'
);
const
burntFees
=
utils
.
parseUnits
(
String
(
block
.
burnt_fees
||
'
0
'
),
'
wei
'
);
const
burntFees
=
utils
.
parseUnits
(
String
(
block
.
burnt_fees
||
'
0
'
),
'
wei
'
);
const
totalReward
=
utils
.
parseUnits
(
String
(
block
.
rewards
?.
find
(({
type
})
=>
type
===
'
Miner Reward
'
||
type
===
'
Validator Reward
'
)?.
reward
||
'
0
'
),
'
wei
'
);
const
totalReward
=
utils
.
parseUnits
(
String
(
block
.
rewards
?.
find
(({
type
})
=>
type
===
'
Miner Reward
'
||
type
===
'
Validator Reward
'
)?.
reward
||
'
0
'
,
),
'
wei
'
,
);
const
staticReward
=
totalReward
.
sub
(
txFees
).
add
(
burntFees
);
const
staticReward
=
totalReward
.
sub
(
txFees
).
add
(
burntFees
);
return
{
return
{
...
...
ui/block/BlockDetails.tsx
View file @
c1829e8d
import
{
Grid
,
GridItem
,
Text
,
Icon
,
Link
,
Box
,
Tooltip
,
Alert
}
from
'
@chakra-ui/react
'
;
import
{
Grid
,
GridItem
,
Text
,
Icon
,
Link
,
Box
,
Tooltip
,
Alert
}
from
'
@chakra-ui/react
'
;
import
{
useQuery
}
from
'
@tanstack/react-query
'
;
import
{
useQuery
}
from
'
@tanstack/react-query
'
;
import
{
utils
}
from
'
ethers
'
;
import
{
utils
,
constants
}
from
'
ethers
'
;
import
{
useRouter
}
from
'
next/router
'
;
import
{
useRouter
}
from
'
next/router
'
;
import
React
from
'
react
'
;
import
React
from
'
react
'
;
import
{
scroller
,
Element
}
from
'
react-scroll
'
;
import
{
scroller
,
Element
}
from
'
react-scroll
'
;
...
@@ -75,12 +75,13 @@ const BlockDetails = () => {
...
@@ -75,12 +75,13 @@ const BlockDetails = () => {
hint=
"The block height of a particular block is defined as the number of blocks preceding it in the blockchain."
hint=
"The block height of a particular block is defined as the number of blocks preceding it in the blockchain."
>
>
{
data
.
height
}
{
data
.
height
}
{
data
.
height
===
0
&&
<
Text
whiteSpace=
"pre"
>
- Genesis Block
</
Text
>
}
<
PrevNext
<
PrevNext
ml=
{
6
}
ml=
{
6
}
onClick=
{
handlePrevNextClick
}
onClick=
{
handlePrevNextClick
}
prevLabel=
"View previous block"
prevLabel=
"View previous block"
nextLabel=
"View next block"
nextLabel=
"View next block"
isPrevDisabled=
{
router
.
query
.
id
===
'
0
'
}
isPrevDisabled=
{
data
.
height
===
0
}
/>
/>
</
DetailsInfoItem
>
</
DetailsInfoItem
>
<
DetailsInfoItem
<
DetailsInfoItem
...
@@ -116,6 +117,7 @@ const BlockDetails = () => {
...
@@ -116,6 +117,7 @@ const BlockDetails = () => {
{
/* api doesn't return the block processing time yet */
}
{
/* api doesn't return the block processing time yet */
}
{
/* <Text>{ dayjs.duration(block.minedIn, 'second').humanize(true) }</Text> */
}
{
/* <Text>{ dayjs.duration(block.minedIn, 'second').humanize(true) }</Text> */
}
</
DetailsInfoItem
>
</
DetailsInfoItem
>
{
!
totalReward
.
eq
(
constants
.
Zero
)
&&
(
<
DetailsInfoItem
<
DetailsInfoItem
title=
"Block reward"
title=
"Block reward"
hint=
{
hint=
{
...
@@ -125,20 +127,31 @@ const BlockDetails = () => {
...
@@ -125,20 +127,31 @@ const BlockDetails = () => {
columnGap=
{
1
}
columnGap=
{
1
}
>
>
<
Text
>
{
utils
.
formatUnits
(
totalReward
)
}
{
network
?.
currency
}
</
Text
>
<
Text
>
{
utils
.
formatUnits
(
totalReward
)
}
{
network
?.
currency
}
</
Text
>
{
(
!
txFees
.
eq
(
constants
.
Zero
)
||
!
burntFees
.
eq
(
constants
.
Zero
))
&&
(
<
Text
variant=
"secondary"
whiteSpace=
"break-spaces"
>
(
<
Text
variant=
"secondary"
whiteSpace=
"break-spaces"
>
(
<
Tooltip
label=
"Static block reward"
>
<
Tooltip
label=
"Static block reward"
>
<
span
>
{
utils
.
formatUnits
(
staticReward
)
}
</
span
>
<
span
>
{
utils
.
formatUnits
(
staticReward
)
}
</
span
>
</
Tooltip
>
</
Tooltip
>
{
!
txFees
.
eq
(
constants
.
Zero
)
&&
(
<>
{
space
}
+
{
space
}
{
space
}
+
{
space
}
<
Tooltip
label=
"Txn fees"
>
<
Tooltip
label=
"Txn fees"
>
<
span
>
{
utils
.
formatUnits
(
txFees
)
}
</
span
>
<
span
>
{
utils
.
formatUnits
(
txFees
)
}
</
span
>
</
Tooltip
>
</
Tooltip
>
</>
)
}
{
!
burntFees
.
eq
(
constants
.
Zero
)
&&
(
<>
{
space
}
-
{
space
}
{
space
}
-
{
space
}
<
Tooltip
label=
"Burnt fees"
>
<
Tooltip
label=
"Burnt fees"
>
<
span
>
{
utils
.
formatUnits
(
burntFees
)
}
</
span
>
<
span
>
{
utils
.
formatUnits
(
burntFees
)
}
</
span
>
</
Tooltip
>
</
Tooltip
>
</>
)
}
)
</
Text
>
)
</
Text
>
)
}
</
DetailsInfoItem
>
</
DetailsInfoItem
>
)
}
{
sectionGap
}
{
sectionGap
}
...
@@ -172,7 +185,6 @@ const BlockDetails = () => {
...
@@ -172,7 +185,6 @@ const BlockDetails = () => {
</
Text
>
</
Text
>
</
DetailsInfoItem
>
</
DetailsInfoItem
>
)
}
)
}
{
data
.
burnt_fees
&&
(
<
DetailsInfoItem
<
DetailsInfoItem
title=
"Burnt fees"
title=
"Burnt fees"
hint=
{
hint=
{
...
@@ -182,7 +194,7 @@ const BlockDetails = () => {
...
@@ -182,7 +194,7 @@ const BlockDetails = () => {
>
>
<
Icon
as=
{
flameIcon
}
boxSize=
{
5
}
color=
"gray.500"
/>
<
Icon
as=
{
flameIcon
}
boxSize=
{
5
}
color=
"gray.500"
/>
<
Text
ml=
{
1
}
>
{
utils
.
formatUnits
(
burntFees
)
}
{
network
?.
currency
}
</
Text
>
<
Text
ml=
{
1
}
>
{
utils
.
formatUnits
(
burntFees
)
}
{
network
?.
currency
}
</
Text
>
{
data
.
tx_fees
&&
(
{
!
txFees
.
eq
(
constants
.
Zero
)
&&
(
<
Tooltip
label=
"Burnt fees / Txn fees * 100%"
>
<
Tooltip
label=
"Burnt fees / Txn fees * 100%"
>
<
Box
>
<
Box
>
<
Utilization
<
Utilization
...
@@ -193,7 +205,6 @@ const BlockDetails = () => {
...
@@ -193,7 +205,6 @@ const BlockDetails = () => {
</
Tooltip
>
</
Tooltip
>
)
}
)
}
</
DetailsInfoItem
>
</
DetailsInfoItem
>
)
}
{
/* api doesn't support extra data yet */
}
{
/* api doesn't support extra data yet */
}
{
/* <DetailsInfoItem
{
/* <DetailsInfoItem
title="Extra data"
title="Extra data"
...
@@ -272,7 +283,9 @@ const BlockDetails = () => {
...
@@ -272,7 +283,9 @@ const BlockDetails = () => {
>
>
{
data
.
nonce
}
{
data
.
nonce
}
</
DetailsInfoItem
>
</
DetailsInfoItem
>
{
data
.
rewards
?.
map
(({
type
,
reward
})
=>
(
{
data
.
rewards
?.
filter
(({
type
})
=>
type
!==
'
Validator Reward
'
&&
type
!==
'
Miner Reward
'
)
.
map
(({
type
,
reward
})
=>
(
<
DetailsInfoItem
<
DetailsInfoItem
key=
{
type
}
key=
{
type
}
title=
{
type
}
title=
{
type
}
...
...
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