Cleanup unused encodePubkey

This commit is contained in:
Simon Warta 2020-02-11 23:56:14 +01:00
parent a11b756ea6
commit 42369eba12
2 changed files with 5 additions and 7 deletions

View File

@ -67,8 +67,8 @@ describe("encode", () => {
},
];
describe("encodePubKey", () => {
it("encodes a Secp256k1 pubkey", () => {
describe("encodePubkey", () => {
it("works for compressed public key", () => {
expect(encodePubkey(defaultPubkey)).toEqual({
type: "tendermint/PubKeySecp256k1",
value: "AtQaCqFnshaZQp6rIkvAPyzThvCvXSDO+9AzbxVErqJP",

View File

@ -1,5 +1,5 @@
/* eslint-disable @typescript-eslint/camelcase */
import { encodeSecp256k1Signature, types } from "@cosmwasm/sdk";
import { encodeSecp256k1Pubkey, encodeSecp256k1Signature, types } from "@cosmwasm/sdk";
import {
Algorithm,
Amount,
@ -17,13 +17,11 @@ import { BankTokens, Erc20Token } from "./types";
const { toBase64 } = Encoding;
// TODO: This function seems to be unused and is not well tested (e.g. uncompressed secp256k1 or ed25519)
export function encodePubkey(pubkey: PubkeyBundle): types.PubKey {
switch (pubkey.algo) {
case Algorithm.Secp256k1:
return {
type: types.pubkeyType.secp256k1,
value: toBase64(pubkey.data),
};
return encodeSecp256k1Pubkey(pubkey.data);
case Algorithm.Ed25519:
return {
type: types.pubkeyType.ed25519,