diff --git a/packages/amino/src/pubkeys.spec.ts b/packages/amino/src/pubkeys.spec.ts index ec47bdcb3d..ad11937c45 100644 --- a/packages/amino/src/pubkeys.spec.ts +++ b/packages/amino/src/pubkeys.spec.ts @@ -1,4 +1,4 @@ -import { isMultisigThresholdPubkey, isSinglePubkey } from "./pubkeys"; +import { isEd25519Pubkey, isMultisigThresholdPubkey, isSecp256k1Pubkey, isSinglePubkey } from "./pubkeys"; describe("pubkeys", () => { const pubkeyEd25519 = { @@ -49,4 +49,20 @@ describe("pubkeys", () => { expect(isMultisigThresholdPubkey(pubkeyMultisigThreshold)).toEqual(true); }); }); + + describe("isEd25519Pubkey", () => { + it("works", () => { + expect(isEd25519Pubkey(pubkeyEd25519)).toEqual(true); + expect(isEd25519Pubkey(pubkeySecp256k1)).toEqual(false); + expect(isEd25519Pubkey(pubkeyMultisigThreshold)).toEqual(false); + }); + }); + + describe("isSecp256k1Pubkey", () => { + it("works", () => { + expect(isSecp256k1Pubkey(pubkeyEd25519)).toEqual(false); + expect(isSecp256k1Pubkey(pubkeySecp256k1)).toEqual(true); + expect(isSecp256k1Pubkey(pubkeyMultisigThreshold)).toEqual(false); + }); + }); }); diff --git a/packages/amino/src/pubkeys.ts b/packages/amino/src/pubkeys.ts index d61bfa3c39..1ddf97ce47 100644 --- a/packages/amino/src/pubkeys.ts +++ b/packages/amino/src/pubkeys.ts @@ -12,7 +12,7 @@ export interface Ed25519Pubkey extends SinglePubkey { } export function isEd25519Pubkey(pubkey: Pubkey): pubkey is Ed25519Pubkey { - return (pubkey as Ed25519Pubkey).type === "tendermint/PubKeyEd25519"; + return pubkey.type === "tendermint/PubKeyEd25519"; } export interface Secp256k1Pubkey extends SinglePubkey { @@ -21,7 +21,7 @@ export interface Secp256k1Pubkey extends SinglePubkey { } export function isSecp256k1Pubkey(pubkey: Pubkey): pubkey is Secp256k1Pubkey { - return (pubkey as Secp256k1Pubkey).type === "tendermint/PubKeySecp256k1"; + return pubkey.type === "tendermint/PubKeySecp256k1"; } export const pubkeyType = { @@ -67,5 +67,5 @@ export interface MultisigThresholdPubkey extends Pubkey { } export function isMultisigThresholdPubkey(pubkey: Pubkey): pubkey is MultisigThresholdPubkey { - return (pubkey as MultisigThresholdPubkey).type === "tendermint/PubKeyMultisigThreshold"; + return pubkey.type === "tendermint/PubKeyMultisigThreshold"; }