Skip to content

Commit

Permalink
feat(notifications): add group efficiency
Browse files Browse the repository at this point in the history
See: BEDS-656
  • Loading branch information
marcel-bitfly authored and LuccaBitfly committed Oct 22, 2024
1 parent dd52986 commit df7d583
Show file tree
Hide file tree
Showing 8 changed files with 72 additions and 28 deletions.
19 changes: 13 additions & 6 deletions frontend/components/bc/BcAccordion.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { FontAwesomeIcon } from '@fortawesome/vue-fontawesome'
const props = defineProps<{
infoCopy?: string,
item?: T,
items?: T[],
open?: boolean,
}>()
Expand Down Expand Up @@ -56,17 +57,22 @@ const copyText = async () => {
</summary>
<BcCard class="bc-accordion__content">
<ul
v-if="items?.length"
:id="idList"
class="bc-accordion-list"
>
<li
v-for="(item, index) in items"
:key="`${index}-${item}`"
class="bc-accordion-list__item"
v-for="(element, index) in items"
:key="`${index}-${element}`"
class="bc-accordion-list__element"
>
<slot name="item" :item />
<slot name="item" :item="element" />
</li>
</ul>
<slot
v-if="item"
name="item" :item
/>
<template #floating-action-button>
<BcButtonIcon
v-if="isSupported"
Expand Down Expand Up @@ -118,10 +124,10 @@ const copyText = async () => {
padding-inline-start: 0;
display: inline;
}
.bc-accordion-list__item {
.bc-accordion-list__element {
display: inline;
}
.bc-accordion-list__item:not(:last-child)::after {
.bc-accordion-list__element:not(:last-child)::after {
content: ', ';
}
.bc-accordion__button {
Expand All @@ -136,6 +142,7 @@ content: ', ';
position: absolute;
bottom: 6px;
right: 11px;
cursor: pointer
}
.bc-accordion__button-icon {
width: .9375rem;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { FontAwesomeIcon } from '@fortawesome/vue-fontawesome'
import {
faAlarmSnooze,
faArrowsRotate,
faChartLineUp,
faCube,
faFileSignature,
faGlobe,
Expand Down Expand Up @@ -280,6 +281,29 @@ const formatValueWei = (value: string) => {
-->
</template>
</BcAccordion>
<BcAccordion
v-if="details?.group_efficiency_below"
:item="details?.group_efficiency_below"
>
<template #headingIcon>
<FontAwesomeIcon
:icon="faChartLineUp"
class="notifications-dashboard-dialog-entity__icon__red"
/>
</template>
<template #heading>
{{ $t('notifications.dashboards.dialog.entity.group_efficiency.heading') }}
</template>
<template #item="{ item: groupEfficiencyBelow }">
{{ details?.group_name }}
(<BcLink :to="`/dashboard/${props?.dashboard_id}`">
{{ details?.dashboard_name }}
</BcLink>)
{{ $t('notifications.dashboards.dialog.entity.group_efficiency_text', {
percentage: formatFractionToPercent(groupEfficiencyBelow),
}) }}
</template>
</BcAccordion>
<BcAccordion
v-if="details?.validator_offline_reminder?.length"
:items="details?.validator_offline_reminder"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,8 @@ const mapEventtypeToText = (eventType: NotificationDashboardsTableRow['event_typ
switch (eventType) {
case 'attestation_missed':
return $t('notifications.dashboards.event_type.attestation_missed')
case 'group_offline':
return $t('notifications.dashboards.event_type.group_offline')
case 'group_online':
return $t('notifications.dashboards.event_type.group_online')
case 'group_efficiency_below':
return $t('notifications.dashboards.event_type.group_efficiency_below')
case 'incoming_tx':
return $t('notifications.dashboards.event_type.incoming_tx')
case 'max_collateral':
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,6 @@ const wrappedDashboards: ComputedRef<
if (settingsValidatorDashboard.is_validator_offline_subscribed) {
result.push($t('notifications.subscriptions.validators.validator_is_offline.label'))
}
if (settingsValidatorDashboard.is_group_offline_subscribed) {
result.push($t('notifications.subscriptions.validators.group_is_offline.label'))
}
if (settingsValidatorDashboard.is_attestations_missed_subscribed) {
result.push($t('notifications.subscriptions.validators.attestation_missed.label'))
}
Expand All @@ -127,12 +124,12 @@ const wrappedDashboards: ComputedRef<
if (settingsValidatorDashboard.is_min_collateral_subscribed) {
result.push($t('notifications.subscriptions.validators.min_collateral_reached.label'))
}
if (settingsValidatorDashboard.is_group_efficiency_below_subscribed) {
result.push($t('notifications.subscriptions.accounts.group_efficiency.label'))
}
if (settingsValidatorDashboard.is_max_collateral_subscribed) {
result.push($t('notifications.subscriptions.validators.max_collateral_reached.label'))
}
if (settingsValidatorDashboard.is_real_time_mode_enabled) {
result.push($t('notifications.subscriptions.validators.real_time_mode.label'))
}
return result
}
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,25 +10,28 @@ const {
secondsPerEpoch,
} = useNetworkStore()
const { user } = useUserStore()
const hasPremiumPerkGroupEfficiency = computed(
() => user.value?.premium_perks.notifications_validator_dashboard_group_efficiency,
)
function closeDialog(): void {
dialogRef?.value.close()
}
const checkboxes = ref({
is_attestations_missed_subscribed: props.value?.is_attestations_missed_subscribed ?? false,
is_block_proposal_subscribed: props.value?.is_block_proposal_subscribed ?? false,
is_group_offline_subscribed: props.value?.is_group_offline_subscribed ?? false,
is_group_efficiency_below_subscribed: props.value?.is_group_efficiency_below_subscribed ?? false,
is_max_collateral_subscribed: props.value?.is_max_collateral_subscribed ?? false,
is_min_collateral_subscribed: props.value?.is_min_collateral_subscribed ?? false,
is_real_time_mode_enabled: props.value?.is_real_time_mode_enabled ?? false,
is_slashed_subscribed: props.value?.is_slashed_subscribed ?? false,
is_sync_subscribed: props.value?.is_sync_subscribed ?? false,
is_upcoming_block_proposal_subscribed: props.value?.is_upcoming_block_proposal_subscribed ?? false,
is_validator_offline_subscribed: props.value?.is_validator_offline_subscribed ?? false,
is_withdrawal_processed_subscribed: props.value?.is_withdrawal_processed_subscribed ?? false,
})
const thresholds = ref({
group_offline_threshold: formatFraction(props.value?.group_offline_threshold ?? 0),
group_efficiency_below_threshold: formatFraction(props.value?.group_efficiency_below_threshold ?? 0),
max_collateral_threshold: formatFraction(props.value?.max_collateral_threshold ?? 0),
min_collateral_threshold: formatFraction(props.value?.min_collateral_threshold ?? 0),
})
Expand All @@ -43,7 +46,7 @@ watchDebounced([
], () => {
emit('change-settings', {
...checkboxes.value,
group_offline_threshold: Number(formatToFraction(thresholds.value.group_offline_threshold)),
group_efficiency_below_threshold: Number(formatToFraction(thresholds.value.group_efficiency_below_threshold)),
max_collateral_threshold: Number(formatToFraction(thresholds.value.max_collateral_threshold)),
min_collateral_threshold: Number(formatToFraction(thresholds.value.min_collateral_threshold)),
})
Expand Down Expand Up @@ -118,6 +121,14 @@ watch(hasAllEvents, () => {
v-model:checkbox="checkboxes.is_slashed_subscribed"
:label="$t('notifications.subscriptions.validators.validator_got_slashed.label')"
/>
<BcSettingsRow
v-model:checkbox="checkboxes.is_group_efficiency_below_subscribed"
v-model:input="thresholds.group_efficiency_below_threshold"
has-unit
:info="$t('notifications.subscriptions.validators.group_efficiency.info', { percentage: thresholds.group_efficiency_below_threshold })"
:label="$t('notifications.subscriptions.validators.group_efficiency.label')"
:has-premium-gem="hasPremiumPerkGroupEfficiency"
/>
<BcSettingsRow
v-model:checkbox="checkboxes.is_min_collateral_subscribed"
v-model:input="thresholds.min_collateral_threshold"
Expand Down
5 changes: 2 additions & 3 deletions frontend/components/playground/PlaygroundDialog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,12 @@ const openQuestion = (yesLabel?: string, noLabel?: string) => {
}
const validatorSub: NotificationSettingsValidatorDashboard = {
group_offline_threshold: 0, // means "deactivated/unchecked"
group_efficiency_below_threshold: 0,
is_attestations_missed_subscribed: true,
is_block_proposal_subscribed: true,
is_group_offline_subscribed: true,
is_group_efficiency_below_subscribed: true,
is_max_collateral_subscribed: false,
is_min_collateral_subscribed: false,
is_real_time_mode_enabled: false,
is_slashed_subscribed: false,
is_sync_subscribed: true,
is_upcoming_block_proposal_subscribed: false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,13 +83,12 @@ export function useNotificationsManagementDashboards() {
return
}
const accountDashboarSettings = settings as NotificationSettingsValidatorDashboard
accountDashboarSettings.group_offline_threshold = 0
accountDashboarSettings.group_efficiency_below_threshold = 0
accountDashboarSettings.is_attestations_missed_subscribed = false
accountDashboarSettings.is_block_proposal_subscribed = false
accountDashboarSettings.is_group_offline_subscribed = false
accountDashboarSettings.is_group_efficiency_below_subscribed = false
accountDashboarSettings.is_max_collateral_subscribed = false
accountDashboarSettings.is_min_collateral_subscribed = false
accountDashboarSettings.is_real_time_mode_enabled = false
accountDashboarSettings.is_slashed_subscribed = false
accountDashboarSettings.is_sync_subscribed = false
accountDashboarSettings.is_upcoming_block_proposal_subscribed = false
Expand Down
13 changes: 11 additions & 2 deletions frontend/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -616,6 +616,8 @@
},
"entity": {
"attestation_missed":"Attestation missed",
"group_efficiency": "Group efficiency ",
"group_efficiency_text": "efficiency below {percentage}",
"max_collateral":"Maximum collateral reached",
"min_collateral":"Minimum collateral reached",
"proposal_done": "Proposal done",
Expand Down Expand Up @@ -650,8 +652,7 @@
},
"event_type": {
"attestation_missed": "Attestation missed",
"group_offline": "Group offline",
"group_online": "Group online",
"group_efficiency_below": "Low group efficiency",
"incoming_tx": "Incoming Tx.",
"max_collateral": "Max. collateral",
"min_collateral": "Min. collateral",
Expand Down Expand Up @@ -814,6 +815,10 @@
"erc1155_token_transfers": {
"label": "ERC1155 token transfers"
},
"group_efficiency": {
"info": "efficiency below {percentage}",
"label": "Group efficiency"
},
"ignore_spam_transactions": {
"hint": [
"Ignores",
Expand Down Expand Up @@ -844,6 +849,10 @@
"label": "Block proposal (missed & success)"
},
"explanation": "All notifications are sent after network finality (~20min).",
"group_efficiency": {
"info": "Notifies you if your group's efficiency falls below {percentage}% in any given epoch",
"label": "Group efficiency below"
},
"max_collateral_reached": {
"label": "Max collateral reached"
},
Expand Down

0 comments on commit df7d583

Please sign in to comment.