Skip to content

Commit

Permalink
we are absolutly sure about that new format (#308)
Browse files Browse the repository at this point in the history
  • Loading branch information
MauserBitfly authored May 17, 2024
1 parent 94d06e5 commit dd78588
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 9 deletions.
7 changes: 4 additions & 3 deletions frontend/components/dashboard/table/DashboardTableRewards.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { DAHSHBOARDS_ALL_GROUPS_ID, DAHSHBOARDS_NEXT_EPOCH_ID } from '~/types/da
import { totalElCl } from '~/utils/bigMath'
import { useValidatorDashboardRewardsStore } from '~/stores/dashboard/useValidatorDashboardRewardsStore'
import { getGroupLabel } from '~/utils/dashboard/group'
import { formatRewardValueOption } from '~/utils/dashboard/table'
const { dashboardKey, isPublic } = useDashboardKey()
Expand Down Expand Up @@ -201,7 +202,7 @@ const wrappedRewards = computed(() => {
v-else
:value="totalElCl(slotProps.data.reward)"
:use-colors="true"
:options="{ addPlus: true }"
:options="formatRewardValueOption"
/>
</template>
</Column>
Expand All @@ -220,7 +221,7 @@ const wrappedRewards = computed(() => {
v-else
:value="slotProps.data.reward?.el"
:use-colors="true"
:options="{ addPlus: true }"
:options="formatRewardValueOption"
/>
</template>
</Column>
Expand All @@ -239,7 +240,7 @@ const wrappedRewards = computed(() => {
v-else
:value="slotProps.data.reward?.cl"
:use-colors="true"
:options="{ addPlus: true }"
:options="formatRewardValueOption"
/>
</template>
</Column>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { FontAwesomeIcon } from '@fortawesome/vue-fontawesome'
import { DashboardValidatorEpochDutiesModal, IconSlotBlockProposal, IconSlotHeadAttestation, IconSlotSlashing, IconSlotSourceAttestation, IconSlotSync, IconSlotTargetAttestation } from '#components'
import type { VDBGroupRewardsDetails, VDBRewardsTableRow } from '~/types/api/validator_dashboard'
import type BcTooltip from '~/components/bc/BcTooltip.vue'
import { formatRewardValueOption } from '~/utils/dashboard/table'
interface Props {
row: VDBRewardsTableRow
Expand Down Expand Up @@ -183,7 +184,7 @@ const openDuties = () => {
:value="item.value.income"
:use-colors="item.value.income !== '0'"
:class="item.className"
:options="{ addPlus: true, fixedDecimalCount: 5 }"
:options="formatRewardValueOption"
/>
</div>
</div>
Expand All @@ -192,7 +193,7 @@ const openDuties = () => {
<div class="label">
{{ item.label }}
</div>
<BcFormatValue :value="item.value" :use-colors="item.value !== '0'" :options="{ addPlus: true, fixedDecimalCount: 5 }" />
<BcFormatValue :value="item.value" :use-colors="item.value !== '0'" :options="formatRewardValueOption" />
</div>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<script setup lang="ts">
import type { ValidatorHistoryDuties } from '~/types/api/common'
import { formatRewardValueOption } from '~/utils/dashboard/table'
import { totalDutyRewards } from '~/utils/dashboard/validator'
interface Props {
Expand Down Expand Up @@ -48,7 +49,7 @@ const mapped = computed(() => {
<BcFormatValue
:value="mapped.total"
:use-colors="true"
:options="{ addPlus: true, fixedDecimalCount: 5 }"
:options="formatRewardValueOption"
>
<template v-if="mapped.details?.length" #tooltip>
<div class="tooltip">
Expand All @@ -57,7 +58,7 @@ const mapped = computed(() => {
<BcFormatValue
:value="detail.value"
:use-colors="true"
:options="{ addPlus: true, fixedDecimalCount: 5, minUnitDecimalCount:0 }"
:options="formatRewardValueOption"
/>
</div>
</div>
Expand Down
4 changes: 2 additions & 2 deletions frontend/composables/useValue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ export function useValue () {
value = bigMul(value, rates.value[target])
}
let currencyLabel: string = target
const minDecimalCount: number | undefined = options?.fixedDecimalCount
let maxDecimalCount: number = options?.fixedDecimalCount ?? 5
const minDecimalCount: number | undefined = options?.fixedDecimalCount ?? options?.minDecimalCount
let maxDecimalCount: number = options?.fixedDecimalCount ?? options?.maxDecimalCount ?? 5

if (isFiat(target)) {
maxDecimalCount = Math.min(maxDecimalCount, 2)
Expand Down
2 changes: 2 additions & 0 deletions frontend/types/value.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ export type ValueConvertOptions = {
sourceUnit?: CryptoUnits // source unit - default main unit (like eth)
targetCurrency?: Currency // target currency - overrides the selected currency
fixedDecimalCount?: number // can override the usual settings, but can't go over 2 for fiat
maxDecimalCount?: number // max decimal count
minDecimalCount?: number // min decimal count
minUnit?: CryptoUnits // if output should only be in higher units (for example GWEI -> then it will never go down to WEI)
minUnitDecimalCount?: number // decimal count to check for value while unit conversion - defaults to max decimal count
fixedUnit?: CryptoUnits // fixed output unit - overrides min unit
Expand Down
5 changes: 5 additions & 0 deletions frontend/utils/dashboard/table.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import type { ValueConvertOptions } from '~/types/value'

export const formatRewardValueOption: ValueConvertOptions = {
addPlus: true, maxDecimalCount: 6, minUnit: 'MAIN', minDecimalCount: 0
}

0 comments on commit dd78588

Please sign in to comment.