From 06fff024d7291338d171f065edaafd4466bf8249 Mon Sep 17 00:00:00 2001 From: liangping <18786721@qq.com> Date: Tue, 14 Dec 2021 13:47:30 +0800 Subject: [PATCH] Fixed uptime issue for band, odin --- package.json | 1 + src/libs/data/data.js | 11 ++++++++--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index 5a284d8f..d1d43a86 100644 --- a/package.json +++ b/package.json @@ -49,6 +49,7 @@ "prismjs": "1.24.0", "protobufjs-cli-dbx": "^7.0.7", "protobufjs-dbx": "^7.0.0", + "ripemd160": "^2.0.2", "swiper": "6.5.1", "trading-vue-js": "^1.0.2", "uuid": "8.3.2", diff --git a/src/libs/data/data.js b/src/libs/data/data.js index 8634b9ce..41abd87b 100644 --- a/src/libs/data/data.js +++ b/src/libs/data/data.js @@ -12,6 +12,7 @@ import dayjs from 'dayjs' import duration from 'dayjs/plugin/duration' import relativeTime from 'dayjs/plugin/relativeTime' import utc from 'dayjs/plugin/utc' +import RIPEMD160 from 'ripemd160' import localeData from 'dayjs/plugin/localeData' import { $themeColors } from '@themeConfig' // import { SigningStargateClient } from '@cosmjs/stargate' @@ -118,11 +119,15 @@ export function getUserCurrencySign() { export function consensusPubkeyToHexAddress(consensusPubkey) { let raw = null if (typeof consensusPubkey === 'object') { - raw = toHex(fromBase64(consensusPubkey.value)) + if (consensusPubkey.type === 'tendermint/PubKeySecp256k1') { + raw = new RIPEMD160().update(Buffer.from(sha256(fromBase64(consensusPubkey.value)))).digest('hex').toUpperCase() + return raw + } + raw = sha256(fromBase64(consensusPubkey.value)) } else { - raw = toHex(Bech32.decode(consensusPubkey).data).toUpperCase().replace('1624DE6420', '') + raw = sha256(fromHex(toHex(Bech32.decode(consensusPubkey).data).toUpperCase().replace('1624DE6420', ''))) } - const address = toHex(sha256(fromHex(raw))).slice(0, 40).toUpperCase() + const address = toHex(raw).slice(0, 40).toUpperCase() return address }