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
a947450a
Commit
a947450a
authored
Feb 27, 2025
by
tom
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: block rewards fields can be null
parent
c3ff0d15
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
14 additions
and
5 deletions
+14
-5
block.ts
types/api/block.ts
+2
-2
BlockEpochRewards.tsx
ui/block/BlockEpochRewards.tsx
+1
-1
BlockEpochElectionRewards.tsx
ui/block/epochRewards/BlockEpochElectionRewards.tsx
+4
-0
BlockEpochRewardsDistribution.tsx
ui/block/epochRewards/BlockEpochRewardsDistribution.tsx
+4
-0
utils.ts
ui/block/epochRewards/utils.ts
+3
-2
No files found.
types/api/block.ts
View file @
a947450a
...
...
@@ -172,8 +172,8 @@ export interface BlockEpoch {
carbon_offsetting_transfer
:
TokenTransfer
|
null
;
community_transfer
:
TokenTransfer
|
null
;
reserve_bolster_transfer
:
TokenTransfer
|
null
;
};
aggregated_election_rewards
:
Record
<
EpochRewardsType
,
BlockEpochElectionReward
|
null
>
;
}
|
null
;
aggregated_election_rewards
:
Record
<
EpochRewardsType
,
BlockEpochElectionReward
|
null
>
|
null
;
}
export
interface
BlockEpochElectionRewardDetails
{
...
...
ui/block/BlockEpochRewards.tsx
View file @
a947450a
...
...
@@ -25,7 +25,7 @@ const BlockEpochRewards = ({ heightOrHash }: Props) => {
return
<
DataFetchAlert
/>;
}
if
(
!
query
.
data
)
{
if
(
!
query
.
data
||
(
!
query
.
data
.
aggregated_election_rewards
&&
!
query
.
data
.
distribution
)
)
{
return
<
span
>
No block epoch rewards data
</
span
>;
}
...
...
ui/block/epochRewards/BlockEpochElectionRewards.tsx
View file @
a947450a
...
...
@@ -12,6 +12,10 @@ interface Props {
}
const
BlockEpochElectionRewards
=
({
data
,
isLoading
}:
Props
)
=>
{
if
(
!
data
.
aggregated_election_rewards
)
{
return
null
;
}
return
(
<
Box
mt=
{
8
}
>
<
Heading
as=
"h4"
size=
"sm"
mb=
{
3
}
>
Election rewards
</
Heading
>
...
...
ui/block/epochRewards/BlockEpochRewardsDistribution.tsx
View file @
a947450a
...
...
@@ -15,6 +15,10 @@ interface Props {
const
BlockEpochRewardsDistribution
=
({
data
,
isLoading
}:
Props
)
=>
{
const
isMobile
=
useIsMobile
();
if
(
!
data
.
distribution
)
{
return
null
;
}
if
(
!
data
.
distribution
.
community_transfer
&&
!
data
.
distribution
.
carbon_offsetting_transfer
&&
!
data
.
distribution
.
reserve_bolster_transfer
)
{
return
null
;
}
...
...
ui/block/epochRewards/utils.ts
View file @
a947450a
import
type
{
BlockEpoch
}
from
'
types/api/block
'
;
import
type
{
ExcludeNull
}
from
'
types/utils
'
;
export
function
getRewardNumText
(
type
:
keyof
BlockEpoch
[
'
aggregated_election_rewards
'
],
num
:
number
)
{
const
postfix1
=
num
!==
1
?
'
s
'
:
''
;
...
...
@@ -26,7 +27,7 @@ export function getRewardNumText(type: keyof BlockEpoch['aggregated_election_rew
return
`
${
num
}
${
text
}
`
;
}
export
function
getRewardDetailsTableTitles
(
type
:
keyof
BlockEpoch
[
'
aggregated_election_rewards
'
]
):
[
string
,
string
]
{
export
function
getRewardDetailsTableTitles
(
type
:
keyof
ExcludeNull
<
BlockEpoch
[
'
aggregated_election_rewards
'
]
>
):
[
string
,
string
]
{
switch
(
type
)
{
case
'
delegated_payment
'
:
return
[
'
Beneficiary
'
,
'
Validator
'
];
...
...
@@ -39,6 +40,6 @@ export function getRewardDetailsTableTitles(type: keyof BlockEpoch['aggregated_e
}
}
export
function
formatRewardType
(
type
:
keyof
BlockEpoch
[
'
aggregated_election_rewards
'
]
)
{
export
function
formatRewardType
(
type
:
keyof
ExcludeNull
<
BlockEpoch
[
'
aggregated_election_rewards
'
]
>
)
{
return
type
.
replaceAll
(
'
_
'
,
'
-
'
);
}
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