From 5f7339c04bf8ce79d0519ff880fd752d08ef88af Mon Sep 17 00:00:00 2001 From: liangping <18786721@qq.com> Date: Fri, 21 Apr 2023 16:08:31 +0800 Subject: [PATCH] add accounts --- src/components/charts/DonutChart.vue | 22 ++++ src/components/charts/PriceMarketChart.vue | 2 +- .../{apexCharConfig.ts => apexChartConfig.ts} | 10 +- src/libs/registry.ts | 2 +- src/modules/[chain]/account/[address].vue | 110 +++++++++++++++--- src/stores/useFormatter.ts | 2 +- src/types/staking.ts | 13 ++- 7 files changed, 134 insertions(+), 27 deletions(-) create mode 100644 src/components/charts/DonutChart.vue rename src/components/charts/{apexCharConfig.ts => apexChartConfig.ts} (98%) diff --git a/src/components/charts/DonutChart.vue b/src/components/charts/DonutChart.vue new file mode 100644 index 00000000..dae181ad --- /dev/null +++ b/src/components/charts/DonutChart.vue @@ -0,0 +1,22 @@ + + + diff --git a/src/components/charts/PriceMarketChart.vue b/src/components/charts/PriceMarketChart.vue index ae36430f..eb010810 100644 --- a/src/components/charts/PriceMarketChart.vue +++ b/src/components/charts/PriceMarketChart.vue @@ -1,7 +1,7 @@ @@ -80,7 +108,7 @@ loadAccount(props.address) - xx + @@ -89,10 +117,10 @@ loadAccount(props.address) - + @@ -110,10 +138,10 @@ loadAccount(props.address) - + @@ -132,10 +160,10 @@ loadAccount(props.address) - + @@ -149,6 +177,29 @@ loadAccount(props.address) {{ format.calculatePercent(v.amount, totalAmount) }} + + + + + + {{ format.formatToken({amount: String(unbondingTotal), denom: stakingStore.params.bond_denom}) }} + + + ≈${{ 0 }} + + + {{ totalAmount }} @@ -177,6 +228,29 @@ loadAccount(props.address) + + + Unbonding Delegations + + + Creation HeightInitial BalanceBalanceCompletion Time + + +
+ + {{ format.validatorFromBech32(v.validator_address) }} + + + {{ entry.creation_height }} + {{ format.formatToken({ amount: entry.initial_balance, denom: stakingStore.params.bond_denom }, true, "0,0.[00]") }} + {{ format.formatToken({ amount: entry.balance, denom: stakingStore.params.bond_denom }, true, "0,0.[00]") }} + {{ format.toDay(entry.completion_time, "to") }} + +
+ +
+
+
Transactions diff --git a/src/stores/useFormatter.ts b/src/stores/useFormatter.ts index de040f03..3c9dc00f 100644 --- a/src/stores/useFormatter.ts +++ b/src/stores/useFormatter.ts @@ -124,7 +124,7 @@ export const useFormatter = defineStore('formatter', { const validator = this.staking.validators.find(x => x.operator_address === address) return validator?.description?.moniker }, - calculatePercent(input?: string, total?: string|number ) { + calculatePercent(input?: string|number, total?: string|number ) { if(!input || !total) return '0' const percent = Number(input)/Number(total) console.log(input, total, percent); diff --git a/src/types/staking.ts b/src/types/staking.ts index eb2ce901..484b6045 100644 --- a/src/types/staking.ts +++ b/src/types/staking.ts @@ -29,6 +29,17 @@ export interface CommissionRate { "update_time": string } +export interface UnbondingResponses { + delegator_address: string, + validator_address: string, + entries: { + creation_height: string, + completion_time: string, + initial_balance: string, + balance: string + }[] + } + export interface Delegation { delegation: { delegator_address: string, @@ -70,7 +81,7 @@ export interface PaginatedRedelegations extends PaginatedResponse { } export interface PaginatedUnbonding extends PaginatedResponse { - unbonding_responses: any[] + unbonding_responses: UnbondingResponses[] } export interface PaginatedValdiators extends PaginatedResponse {