Add MultisigThresholdPubkey/isMultisigThresholdPubkey
This commit is contained in:
parent
6190ca5c64
commit
61aa989fb3
@ -5,4 +5,12 @@ export {
|
||||
encodeBech32Pubkey,
|
||||
encodeSecp256k1Pubkey,
|
||||
} from "./encoding";
|
||||
export { Pubkey, Secp256k1Pubkey, SinglePubkey, isSinglePubkey, pubkeyType } from "./pubkeys";
|
||||
export {
|
||||
MultisigThresholdPubkey,
|
||||
Pubkey,
|
||||
Secp256k1Pubkey,
|
||||
SinglePubkey,
|
||||
isMultisigThresholdPubkey,
|
||||
isSinglePubkey,
|
||||
pubkeyType,
|
||||
} from "./pubkeys";
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
import { isSinglePubkey } from "./pubkeys";
|
||||
import { isMultisigThresholdPubkey, isSinglePubkey } from "./pubkeys";
|
||||
|
||||
describe("pubkeys", () => {
|
||||
const pubkeyEd25519 = {
|
||||
@ -41,4 +41,12 @@ describe("pubkeys", () => {
|
||||
expect(isSinglePubkey(pubkeyMultisigThreshold)).toEqual(false);
|
||||
});
|
||||
});
|
||||
|
||||
describe("isMultisigThresholdPubkey", () => {
|
||||
it("works", () => {
|
||||
expect(isMultisigThresholdPubkey(pubkeyEd25519)).toEqual(false);
|
||||
expect(isMultisigThresholdPubkey(pubkeySecp256k1)).toEqual(false);
|
||||
expect(isMultisigThresholdPubkey(pubkeyMultisigThreshold)).toEqual(true);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@ -42,3 +42,16 @@ export function isSinglePubkey(pubkey: Pubkey): pubkey is SinglePubkey {
|
||||
const singPubkeyTypes: string[] = [pubkeyType.ed25519, pubkeyType.secp256k1, pubkeyType.sr25519];
|
||||
return singPubkeyTypes.includes(pubkey.type);
|
||||
}
|
||||
|
||||
export interface MultisigThresholdPubkey extends Pubkey {
|
||||
readonly type: "tendermint/PubKeyMultisigThreshold";
|
||||
readonly value: {
|
||||
/** A string-encoded integer */
|
||||
readonly threshold: string;
|
||||
readonly pubkeys: readonly SinglePubkey[];
|
||||
};
|
||||
}
|
||||
|
||||
export function isMultisigThresholdPubkey(pubkey: Pubkey): pubkey is MultisigThresholdPubkey {
|
||||
return (pubkey as MultisigThresholdPubkey).type === "tendermint/PubKeyMultisigThreshold";
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user