From 1bbd47814bf2711e0fdf2ac75044911929e2ee98 Mon Sep 17 00:00:00 2001 From: dynst <148708712+dynst@users.noreply.github.com> Date: Wed, 15 Oct 2025 00:00:00 +0000 Subject: [PATCH 1/2] amino: remove some type casts It's nonsensical to cast to the type before you check if it actually is that type, inside the function for checking that. --- packages/amino/src/pubkeys.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) 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"; } From 5853e99b13c48903d2222dd4541ea305bdde9fac Mon Sep 17 00:00:00 2001 From: dynst <148708712+dynst@users.noreply.github.com> Date: Wed, 15 Oct 2025 00:00:00 +0000 Subject: [PATCH 2/2] amino: add 2 missing pubkey function tests --- packages/amino/src/pubkeys.spec.ts | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) 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); + }); + }); });