Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion packages/amino/src/pubkeys.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { isMultisigThresholdPubkey, isSinglePubkey } from "./pubkeys";
import { isEd25519Pubkey, isMultisigThresholdPubkey, isSecp256k1Pubkey, isSinglePubkey } from "./pubkeys";

describe("pubkeys", () => {
const pubkeyEd25519 = {
Expand Down Expand Up @@ -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);
});
});
});
6 changes: 3 additions & 3 deletions packages/amino/src/pubkeys.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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 = {
Expand Down Expand Up @@ -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";
}
Loading