Skip to content

Commit

Permalink
update struct for vali dashboard epochs modal (#182)
Browse files Browse the repository at this point in the history
  • Loading branch information
LuccaBitfly authored Apr 8, 2024
1 parent f4c735c commit 4df07c7
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 30 deletions.
26 changes: 26 additions & 0 deletions backend/pkg/api/types/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ package types

import (
"time"

"github.com/shopspring/decimal"
)

// frontend can ignore ApiResponse type, it's just for the backend
Expand Down Expand Up @@ -85,3 +87,27 @@ type SearchResult struct {
type SearchResponse struct {
Data []SearchResult `json:"data"`
}

type ValidatorHistoryEvent struct {
Status string `json:"status" tstype:"'success' | 'partial' | 'failed'"`
Income decimal.Decimal `json:"income"`
}

type ValidatorHistoryProposal struct {
Status string `json:"status" tstype:"'success' | 'partial' | 'failed' | 'orphaned'"`
ElIncome decimal.Decimal `json:"el_income"`
ClAttestationInclusionIncome decimal.Decimal `json:"cl_attestation_inclusion_income"`
ClSyncInclusionIncome decimal.Decimal `json:"cl_sync_inclusion_income"`
ClSlashingInclusionIncome decimal.Decimal `json:"cl_slashing_inclusion_income"`
}

type ValidatorHistoryDuties struct {
AttestationSource *ValidatorHistoryEvent `json:"attestation_source,omitempty"`
AttestationTarget *ValidatorHistoryEvent `json:"attestation_target,omitempty"`
AttestationHead *ValidatorHistoryEvent `json:"attestation_head,omitempty"`
Sync *ValidatorHistoryEvent `json:"sync,omitempty"`
Slashing *ValidatorHistoryEvent `json:"slashing,omitempty"`
Proposal *ValidatorHistoryProposal `json:"proposal,omitempty"`

SyncCount uint64 `json:"sync_count,omitempty"` // count of successful sync duties for the epoch
}
19 changes: 5 additions & 14 deletions backend/pkg/api/types/validator_dashboard.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,19 +115,10 @@ type InternalGetValidatorDashboardGroupRewardsResponse ApiDataResponse[VDBGroupR
type InternalGetValidatorDashboardRewardsChartResponse ApiDataResponse[ChartData[int]] // bar chart, series id is group id, stack is 'execution' or 'consensus'

// Duties Modal
type VDBEpochDutiesItem struct {
Status string `json:"status" tstype:"'success' | 'partial' | 'failed' | 'orphaned'"`
Reward decimal.Decimal `json:"reward"`
}
type VDBEpochDutiesTableRow struct {
Validator uint64 `json:"validator"`

AttestationsSource VDBEpochDutiesItem `json:"attestations_source"`
AttestationsTarget VDBEpochDutiesItem `json:"attestations_target"`
AttestationsHead VDBEpochDutiesItem `json:"attestations_head"`
Proposal VDBEpochDutiesItem `json:"proposal"`
Sync VDBEpochDutiesItem `json:"sync"`
Slashing VDBEpochDutiesItem `json:"slashing"`
type VDBEpochDutiesTableRow struct {
Validator uint64 `json:"validator"`
Duties ValidatorHistoryDuties `json:"duties"`
}
type InternalGetValidatorDashboardDutiesResponse ApiPagingResponse[VDBEpochDutiesTableRow]

Expand All @@ -149,8 +140,8 @@ type InternalGetValidatorDashboardBlocksResponse ApiPagingResponse[VDBBlocksTabl
// ------------------------------------------------------------
// Heatmap Tab
type VDBHeatmapCell struct {
X uint64 `json:"x" ts_doc:"Epoch"`
Y uint64 `json:"y" ts_doc:"Group ID"`
X uint64 `json:"x"` // Epoch
Y uint64 `json:"y"` // Group ID
Value float64 `json:"value"` // Attestaton Rewards
}
type VDBHeatmap struct {
Expand Down
20 changes: 20 additions & 0 deletions frontend/types/api/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,3 +71,23 @@ export interface SearchResult {
export interface SearchResponse {
data: SearchResult[];
}
export interface ValidatorHistoryEvent {
status: 'success' | 'partial' | 'failed';
income: string /* decimal.Decimal */;
}
export interface ValidatorHistoryProposal {
status: 'success' | 'partial' | 'failed' | 'orphaned';
el_income: string /* decimal.Decimal */;
cl_attestation_inclusion_income: string /* decimal.Decimal */;
cl_sync_inclusion_income: string /* decimal.Decimal */;
cl_slashing_inclusion_income: string /* decimal.Decimal */;
}
export interface ValidatorHistoryDuties {
attestation_source?: ValidatorHistoryEvent;
attestation_target?: ValidatorHistoryEvent;
attestation_head?: ValidatorHistoryEvent;
sync?: ValidatorHistoryEvent;
slashing?: ValidatorHistoryEvent;
proposal?: ValidatorHistoryProposal;
sync_count?: number /* uint64 */; // count of successful sync duties for the epoch
}
20 changes: 4 additions & 16 deletions frontend/types/api/validator_dashboard.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Code generated by tygo. DO NOT EDIT.
/* eslint-disable */
import type { PeriodicValues, ClElValue, ApiDataResponse, ApiPagingResponse, StatusCount, Luck, ChartData, Address, PubKey, Hash } from './common'
import type { PeriodicValues, ClElValue, ApiDataResponse, ApiPagingResponse, StatusCount, Luck, ChartData, ValidatorHistoryDuties, Address, PubKey, Hash } from './common'

//////////
// source: validator_dashboard.go
Expand Down Expand Up @@ -102,21 +102,9 @@ export interface VDBGroupRewardsData {
}
export type InternalGetValidatorDashboardGroupRewardsResponse = ApiDataResponse<VDBGroupRewardsData>;
export type InternalGetValidatorDashboardRewardsChartResponse = ApiDataResponse<ChartData<number /* int */>>; // bar chart, series id is group id, stack is 'execution' or 'consensus'
/**
* Duties Modal
*/
export interface VDBEpochDutiesItem {
status: 'success' | 'partial' | 'failed' | 'orphaned';
reward: string /* decimal.Decimal */;
}
export interface VDBEpochDutiesTableRow {
validator: number /* uint64 */;
attestations_source: VDBEpochDutiesItem;
attestations_target: VDBEpochDutiesItem;
attestations_head: VDBEpochDutiesItem;
proposal: VDBEpochDutiesItem;
sync: VDBEpochDutiesItem;
slashing: VDBEpochDutiesItem;
duties: ValidatorHistoryDuties;
}
export type InternalGetValidatorDashboardDutiesResponse = ApiPagingResponse<VDBEpochDutiesTableRow>;
/**
Expand All @@ -140,8 +128,8 @@ export type InternalGetValidatorDashboardBlocksResponse = ApiPagingResponse<VDBB
* Heatmap Tab
*/
export interface VDBHeatmapCell {
x: number /* uint64 */;
y: number /* uint64 */;
x: number /* uint64 */; // Epoch
y: number /* uint64 */; // Group ID
value: number /* float64 */; // Attestaton Rewards
}
export interface VDBHeatmap {
Expand Down

0 comments on commit 4df07c7

Please sign in to comment.