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
ac627348
Commit
ac627348
authored
Oct 07, 2022
by
tom
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
block data
parent
95d1bcbb
Changes
7
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
185 additions
and
59 deletions
+185
-59
getBlockReward.ts
lib/block/getBlockReward.ts
+17
-0
index.ts
pages/api/blocks/[id]/index.ts
+11
-0
block.ts
types/api/block.ts
+4
-4
reward.ts
types/api/reward.ts
+1
-1
BlockDetails.tsx
ui/block/BlockDetails.tsx
+106
-50
BlockDetailsSkeleton.tsx
ui/block/details/BlockDetailsSkeleton.tsx
+41
-0
GasUsedToTargetRatio.tsx
ui/shared/GasUsedToTargetRatio.tsx
+5
-4
No files found.
lib/block/getBlockReward.ts
0 → 100644
View file @
ac627348
import
{
utils
}
from
'
ethers
'
;
import
type
{
Block
}
from
'
types/api/block
'
;
export
default
function
getBlockReward
(
block
:
Block
)
{
const
txFees
=
utils
.
parseUnits
(
block
.
tx_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
staticReward
=
totalReward
.
sub
(
txFees
).
add
(
burntFees
);
return
{
totalReward
,
staticReward
,
txFees
,
burntFees
,
};
}
pages/api/blocks/[id]/index.ts
0 → 100644
View file @
ac627348
import
type
{
NextApiRequest
}
from
'
next
'
;
import
handler
from
'
lib/api/handler
'
;
const
getUrl
=
(
req
:
NextApiRequest
)
=>
{
return
`/v2/blocks/
${
req
.
query
.
id
}
`
;
};
const
requestHandler
=
handler
(
getUrl
,
[
'
GET
'
]);
export
default
requestHandler
;
types/api/block.ts
View file @
ac627348
...
@@ -9,10 +9,10 @@ export interface Block {
...
@@ -9,10 +9,10 @@ export interface Block {
size
:
number
;
size
:
number
;
hash
:
string
;
hash
:
string
;
parent_hash
:
string
;
parent_hash
:
string
;
difficulty
:
number
;
difficulty
:
string
;
total_difficulty
:
number
;
total_difficulty
:
string
;
gas_used
:
number
;
gas_used
:
string
;
gas_limit
:
number
;
gas_limit
:
string
;
nonce
:
number
;
nonce
:
number
;
base_fee_per_gas
:
number
|
null
;
base_fee_per_gas
:
number
|
null
;
burnt_fees
:
number
|
null
;
burnt_fees
:
number
|
null
;
...
...
types/api/reward.ts
View file @
ac627348
export
interface
Reward
{
export
interface
Reward
{
reward
:
number
;
reward
:
number
;
type
:
'
Miner Reward
'
|
'
Emission Reward
'
|
'
Chore Reward
'
|
'
Uncle Reward
'
;
type
:
'
Miner Reward
'
|
'
Validator Reward
'
|
'
Emission Reward
'
|
'
Chore Reward
'
|
'
Uncle Reward
'
;
}
}
ui/block/BlockDetails.tsx
View file @
ac627348
This diff is collapsed.
Click to expand it.
ui/block/details/BlockDetailsSkeleton.tsx
0 → 100644
View file @
ac627348
import
{
Grid
,
GridItem
,
Skeleton
,
SkeletonCircle
}
from
'
@chakra-ui/react
'
;
import
React
from
'
react
'
;
const
SkeletonRow
=
({
w
=
'
100%
'
}:
{
w
?:
string
})
=>
(
<>
<
GridItem
display=
"flex"
columnGap=
{
2
}
w=
{
{
base
:
'
50%
'
,
lg
:
'
auto
'
}
}
_notFirst=
{
{
mt
:
{
base
:
3
,
lg
:
0
}
}
}
>
<
SkeletonCircle
h=
{
5
}
w=
{
5
}
/>
<
Skeleton
flexGrow=
{
1
}
h=
{
5
}
borderRadius=
"full"
/>
</
GridItem
>
<
GridItem
pl=
{
{
base
:
7
,
lg
:
0
}
}
>
<
Skeleton
h=
{
5
}
borderRadius=
"full"
w=
{
{
base
:
'
100%
'
,
lg
:
w
}
}
/>
</
GridItem
>
</>
);
const
BlockDetailsSkeleton
=
()
=>
{
const
sectionGap
=
<
GridItem
colSpan=
{
{
base
:
undefined
,
lg
:
2
}
}
mt=
{
{
base
:
1
,
lg
:
4
}
}
/>;
return
(
<
Grid
columnGap=
{
8
}
rowGap=
{
{
base
:
5
,
lg
:
7
}
}
templateColumns=
{
{
base
:
'
1fr
'
,
lg
:
'
210px 1fr
'
}
}
maxW=
"1000px"
>
<
SkeletonRow
w=
"25%"
/>
<
SkeletonRow
w=
"25%"
/>
<
SkeletonRow
w=
"65%"
/>
<
SkeletonRow
w=
"25%"
/>
<
SkeletonRow
/>
<
SkeletonRow
/>
{
sectionGap
}
<
SkeletonRow
w=
"50%"
/>
<
SkeletonRow
w=
"25%"
/>
<
SkeletonRow
w=
"50%"
/>
<
SkeletonRow
w=
"50%"
/>
<
SkeletonRow
w=
"50%"
/>
{
sectionGap
}
<
GridItem
colSpan=
{
{
base
:
undefined
,
lg
:
2
}
}
>
<
Skeleton
h=
{
5
}
borderRadius=
"full"
w=
"100px"
/>
</
GridItem
>
</
Grid
>
);
};
export
default
BlockDetailsSkeleton
;
ui/shared/GasUsedToTargetRatio.tsx
View file @
ac627348
...
@@ -2,13 +2,14 @@ import { Stat, StatArrow, Text, chakra } from '@chakra-ui/react';
...
@@ -2,13 +2,14 @@ import { Stat, StatArrow, Text, chakra } from '@chakra-ui/react';
import
React
from
'
react
'
;
import
React
from
'
react
'
;
interface
Props
{
interface
Props
{
used
:
number
;
used
?:
number
;
target
:
number
;
target
?:
number
;
value
?:
number
;
className
?:
string
;
className
?:
string
;
}
}
const
GasUsedToTargetRatio
=
({
used
,
target
,
className
}:
Props
)
=>
{
const
GasUsedToTargetRatio
=
({
used
,
target
,
value
,
className
}:
Props
)
=>
{
const
percentage
=
(
used
/
target
-
1
)
*
100
;
const
percentage
=
value
||
((
used
||
0
)
/
(
target
||
0
)
-
1
)
*
100
;
return
(
return
(
<
Stat
className=
{
className
}
>
<
Stat
className=
{
className
}
>
...
...
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