From 8f7ea633764af727ab01511905499bc9e310f117 Mon Sep 17 00:00:00 2001 From: Tom Beynon Date: Wed, 15 Jun 2022 22:20:43 +0100 Subject: [PATCH] Handle unmatched on-chain validator --- validators/validator.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/validators/validator.js b/validators/validator.js index 208ceea..4713c57 100644 --- a/validators/validator.js +++ b/validators/validator.js @@ -2,7 +2,6 @@ import { fromBase64, toHex } from '@cosmjs/encoding' import { sha256 } from '@cosmjs/crypto' -import RIPEMD160 from 'ripemd160' export class Validator { constructor(data, registryData, blocks){ @@ -16,9 +15,11 @@ export class Validator { hexAddress(){ const pubKey = this.data.consensus_pubkey - const raw = sha256(fromBase64(pubKey.key)) - const address = toHex(raw).slice(0, 40).toUpperCase() - return address + if(pubKey){ + const raw = sha256(fromBase64(pubKey.key)) + const address = toHex(raw).slice(0, 40).toUpperCase() + return address + } } uptimePercentage(){