From be8ca28c560881ea0673cef8a2548a4f433dba06 Mon Sep 17 00:00:00 2001 From: liangping <18786721@qq.com> Date: Sat, 29 Apr 2023 18:21:42 +0800 Subject: [PATCH] Finish uptime --- src/components/UptimeBar.vue | 32 ++++++++++ src/libs/address.ts | 5 ++ src/libs/client.ts | 3 +- src/modules/[chain]/uptime/index.vue | 91 +++++++++++++++++++--------- src/types/base.ts | 14 +++-- src/types/common.ts | 6 ++ 6 files changed, 114 insertions(+), 37 deletions(-) create mode 100644 src/components/UptimeBar.vue diff --git a/src/components/UptimeBar.vue b/src/components/UptimeBar.vue new file mode 100644 index 00000000..168e9c6f --- /dev/null +++ b/src/components/UptimeBar.vue @@ -0,0 +1,32 @@ + + + + + {{ b.height }} + + + \ No newline at end of file diff --git a/src/libs/address.ts b/src/libs/address.ts index 98226d2f..8ed2765a 100644 --- a/src/libs/address.ts +++ b/src/libs/address.ts @@ -50,6 +50,11 @@ export function consensusPubkeyToHexAddress(consensusPubkey?: {"@type": string, } return '' } + + export function valconsToBase64(address: string) { + if(address) return toHex(fromBech32(address).data).toUpperCase() + return '' + } export function toETHAddress(cosmosAddress: string) { return `0x${toHex(fromBech32(cosmosAddress).data)}` diff --git a/src/libs/client.ts b/src/libs/client.ts index a8e4c829..a9e4ad24 100644 --- a/src/libs/client.ts +++ b/src/libs/client.ts @@ -63,7 +63,8 @@ export class CosmosRestClient { return this.request(this.registry.slashing_params, {}) } async getSlashingSigningInfos() { - return this.request(this.registry.slashing_signing_info, {}) + const query = "?pagination.limit=300" + return this.request(this.registry.slashing_signing_info, {}, query) } // Gov async getGovParamsVoting() { diff --git a/src/modules/[chain]/uptime/index.vue b/src/modules/[chain]/uptime/index.vue index ab1281fe..83e630f7 100644 --- a/src/modules/[chain]/uptime/index.vue +++ b/src/modules/[chain]/uptime/index.vue @@ -1,41 +1,72 @@ - - - {{ item.tabName }} - - - - - - {{item.tabName}} - - + + + Current Height: {{latest.block?.header?.height}} + + + + + + {{i + 1}}. {{v.description.moniker}} + {{ signingInfo[consensusPubkeyToHexAddress(v.consensus_pubkey)]?.missed_blocks_counter }} + {{ signingInfo[consensusPubkeyToHexAddress(v.consensus_pubkey)]?.missed_blocks_counter }} + + + + diff --git a/src/types/base.ts b/src/types/base.ts index 158d5368..a42533d1 100644 --- a/src/types/base.ts +++ b/src/types/base.ts @@ -80,15 +80,17 @@ export interface Block { "evidence": { "evidence": any[] }, - "last_commit": { - "height": string, - "round": number, - "block_id": BlockId, - "signatures": Signature[] - } + "last_commit": Commit } } +export interface Commit { + "height": string, + "round": number, + "block_id": BlockId, + "signatures": Signature[] +} + export interface TendermintValidator { "address": string, "pub_key": Key, diff --git a/src/types/common.ts b/src/types/common.ts index f659327a..580b107c 100644 --- a/src/types/common.ts +++ b/src/types/common.ts @@ -29,4 +29,10 @@ export class Response { export interface Coin { amount: string; denom: string; +} + +export interface UptimeStatus { + height: number; + filled: boolean; + signed: boolean; } \ No newline at end of file