diff --git a/src/components/CardParameter.vue b/src/components/CardParameter.vue index 5d225f76..6df31437 100644 --- a/src/components/CardParameter.vue +++ b/src/components/CardParameter.vue @@ -3,6 +3,7 @@ import type { PropType } from 'vue'; import { useFormatter } from '@/stores'; import { formatSeconds, formatTitle } from '@/libs/utils'; import { fromAscii, toBase64 } from '@cosmjs/encoding'; +import numeral from 'numeral'; const props = defineProps({ cardItem: { type: Object as PropType<{ title: string; items: Array }>, @@ -14,7 +15,7 @@ function calculateValue(value: any) { if (!value) return; if (value instanceof Uint8Array) { - return formatter.formatDecimalToPercent(fromAscii(value)); + return formatter.formatDecimalToPercent(fromAscii(value), 1e18); } if (Array.isArray(value)) { @@ -33,7 +34,7 @@ function calculateValue(value: any) { } // check is correct percent format - const decimalFormat = formatter.toDecimal(value); + const decimalFormat = numeral(value); if (decimalFormat) { const decimalValue = decimalFormat.value(); if (decimalValue && decimalValue < 1 && decimalValue > 0) { diff --git a/src/components/ValidatorCommissionRate.vue b/src/components/ValidatorCommissionRate.vue index dd057344..a8a58d6b 100644 --- a/src/components/ValidatorCommissionRate.vue +++ b/src/components/ValidatorCommissionRate.vue @@ -3,6 +3,7 @@ import ApexCharts from 'vue3-apexcharts'; import { computed, type PropType } from 'vue'; import { useFormatter } from '@/stores'; import type { Commission } from 'cosmjs-types/cosmos/staking/v1beta1/staking'; +import numeral from 'numeral'; const props = defineProps({ commission: { type: Object as PropType }, @@ -11,18 +12,18 @@ const format = useFormatter(); let rate = computed( () => - (format.toDecimal(props.commission?.commissionRates.rate)?.value() || 0) * - 100 + (numeral(props.commission?.commissionRates.rate).divide(1e18)?.value() || + 0) * 100 ); let change = computed( () => - (format - .toDecimal(props.commission?.commissionRates.maxChangeRate) + (numeral(props.commission?.commissionRates.maxChangeRate) + .divide(1e18) ?.value() || 0) * 100 ); let max = computed( () => - (format.toDecimal(props.commission?.commissionRates.maxRate)?.value() || + (numeral(props.commission?.commissionRates.maxRate).divide(1e18)?.value() || 1) * 100 ); diff --git a/src/libs/registry.ts b/src/libs/registry.ts index 628f3d0e..ac362810 100644 --- a/src/libs/registry.ts +++ b/src/libs/registry.ts @@ -2,7 +2,6 @@ import type { AuthAccount, Block, ClientStateWithProof, - Coin, ConnectionWithProof, DenomTrace, NodeInfo, @@ -43,6 +42,7 @@ import type { } from '@/types/staking'; import type { PaginatedTxs, Tx, TxResponse } from '@/types'; import semver from 'semver'; +import type { Coin } from 'cosmjs-types/cosmos/base/v1beta1/coin'; export interface Request { url: string; adapter: (source: any) => T; diff --git a/src/modules/[chain]/indexStore.ts b/src/modules/[chain]/indexStore.ts index bc521a0f..397c7b9e 100644 --- a/src/modules/[chain]/indexStore.ts +++ b/src/modules/[chain]/indexStore.ts @@ -1,16 +1,16 @@ import { + useBankStore, + useBaseStore, useBlockchain, useCoingecko, - useBaseStore, - useBankStore, useFormatter, useGovStore, } from '@/stores'; import { useDistributionStore } from '@/stores/useDistributionStore'; import { useMintStore } from '@/stores/useMintStore'; import { useStakingStore } from '@/stores/useStakingStore'; -import type { Coin, Tally } from '@/types'; -import type { Pool } from 'cosmjs-types/cosmos/staking/v1beta1/staking'; +import type { Tally } from '@/types'; +import type { Coin } from '@cosmjs/stargate'; import numeral from 'numeral'; import { defineStore } from 'pinia'; @@ -170,14 +170,14 @@ export const useIndexModule = defineStore('module-index', { title: 'Supply', color: 'success', icon: 'mdi-currency-usd', - stats: formatter.formatTokenAmount(bank.supply!), + stats: formatter.formatToken(bank.supply!), change: 0, }, { title: 'Bonded Tokens', color: 'warning', icon: 'mdi-lock', - stats: formatter.formatTokenAmount({ + stats: formatter.formatToken({ // @ts-ignore amount: this.pool.bondedTokens, denom: staking.params.bondDenom, @@ -195,11 +195,15 @@ export const useIndexModule = defineStore('module-index', { title: 'Community Pool', color: 'primary', icon: 'mdi-bank', - stats: formatter.formatTokens( + stats: formatter.formatToken( // @ts-ignore - this.communityPool?.filter( + this?.communityPool?.find( (x: Coin) => x.denom === staking.params.bondDenom - ) + ), + undefined, + undefined, + undefined, + 1e18 ), change: 0, }, diff --git a/src/modules/[chain]/staking/[validator].vue b/src/modules/[chain]/staking/[validator].vue index f6c9c69c..19b8a540 100644 --- a/src/modules/[chain]/staking/[validator].vue +++ b/src/modules/[chain]/staking/[validator].vue @@ -18,8 +18,9 @@ import { useStakingStore, useTxDialog, } from '@/stores'; -import { PageRequest, type Coin } from '@/types'; +import { PageRequest } from '@/types'; import { fromAscii, fromBech32, toBase64, toHex } from '@cosmjs/encoding'; +import type { Coin } from '@cosmjs/stargate'; import type { Event } from '@cosmjs/tendermint-rpc'; import { Icon } from '@iconify/vue'; import type { QueryValidatorDelegationsResponse } from 'cosmjs-types/cosmos/staking/v1beta1/query'; @@ -441,7 +442,10 @@ function mapDelegators(messages: any[]) { amount: v.delegatorShares, denom: staking.params.bondDenom, }, - false + true, + undefined, + undefined, + 1e18 ) }} @@ -458,7 +462,10 @@ function mapDelegators(messages: any[]) { amount: v.delegatorShares, denom: staking.params.bondDenom, }, - false + true, + undefined, + undefined, + 1e18 ) }} @@ -544,7 +551,7 @@ function mapDelegators(messages: any[]) { />
-

{{ v.unbondingHeight }}

+

{{ Number(v.unbondingHeight) || '-' }}

{{ $t('staking.unbonding_height') }} @@ -562,9 +569,7 @@ function mapDelegators(messages: any[]) {

{{ format.toDay(v.unbondingTime, 'from') }} diff --git a/src/modules/[chain]/staking/index.vue b/src/modules/[chain]/staking/index.vue index af60a2c2..5d48e387 100644 --- a/src/modules/[chain]/staking/index.vue +++ b/src/modules/[chain]/staking/index.vue @@ -491,7 +491,8 @@ loadAvatars(); {{ format.formatCommissionRate( - v.commission?.commissionRates?.rate + v.commission?.commissionRates?.rate, + 1e18 ) }} diff --git a/src/modules/wallet/accounts.vue b/src/modules/wallet/accounts.vue index 6ffb2d4e..599f80a5 100644 --- a/src/modules/wallet/accounts.vue +++ b/src/modules/wallet/accounts.vue @@ -1,7 +1,7 @@